Commit Graph

12270 Commits

Author SHA1 Message Date
Cedric van Putten 3dee6d31b9 fix(dev-middleware): allow inspector proxy to fetch sourcemaps on lan connections (#43307)
Summary:
The inspector proxy is inlining source maps on `Debugger.scriptParsed` CDP events. The inlining prevents Chrome DevTools from downloading this remotely, as that's not supported in newer versions anymore.

The current implementation locks this inlining mechanism to just `localhost` and/or `127.0.0.1` addresses, making it incompatible with LAN or tunnel device connections.

This PR removes that limitation to allow source map inlining on these LAN and tunnel connections.

## 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][FIXED] Allow Inspector proxy to inline source maps on LAN connections

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

Test Plan:
- See added test
- Start Metro and connect a device over LAN, open the chrome devtools

Reviewed By: huntie

Differential Revision: D54485247

Pulled By: robhogan

fbshipit-source-id: 6fcb0c6dd762d2f0a013497ba0a1126095b9130b
2024-03-11 03:48:49 -07:00
Ruslan Lesiutin e2157f063a bump react-devtools-* packages to ^5.0.2 (#43384)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43384

Changelog: [Internal]

via `js1 upgrade react-devtools -v ^5.0.2`

5.0.1 and 5.0.2 mostly include fixes, biggest change is the way how we find source location of the element and the symbolication.

Backend from `react-devtools-core` 5.0.2 is required for symbolication.

allow-large-files

Reviewed By: huntie

Differential Revision: D54679238

fbshipit-source-id: 13656b2d9bad106246c019e1627b87ffbc2735fe
2024-03-08 13:07:49 -08:00
Ruslan Shestopalyuk 6c28c87c4d TurboModule::emitDeviceEvent doesn't require jsi::Runtime argument anymore (#43376)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43376

## Changelog:
[Internal] -

Make it possible to call `emitDeviceEvent` from C++ TurboModules without the need to explicitly provide the reference to `jsi::Runtime`, as in some contexts (when we call e.g. not from the JS thread itself) it may be hard to get hold of.

Reviewed By: rubennorte

Differential Revision: D54643903

fbshipit-source-id: 25cea413e66c6e76c958395879db1169899e3bc9
2024-03-08 10:28:45 -08:00
Ruslan Shestopalyuk 76ce789014 Pass jsi::Runtime reference into CallInvoker::invoke* callbacks (#43375)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43375

## Changelog:
[Internal] -

As discussed with the team, it makes more sense to pass the reference to the correct `jsi::Runtime` object as an argument to the ` CallInvoker::invoke*` callbacks, that are provided by the user.

There are various use cases when user would like to get a hold of the `jsi::Runtime` in the callback, and it makes sense, since it is guaranteed to run on the JS thread.

So far people have been coming up with all kinds of workarounds for that, none of them safe enough.

Reviewed By: rubennorte

Differential Revision: D54643171

fbshipit-source-id: 2f6015426a9e29cb9fcf5a9a3e2f6f33ff692538
2024-03-08 10:28:45 -08:00
Alexey Litvinov eadcebbb3e add support for text highlighting (#43386)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43386

Changes:
- fixes `RCTAttributedTextUtils` to set `RCTAttributedStringIsHighlightedAttributeName` attribute according to `isHighlighted` textAttribute value.
- adds block to `drawAttributedString` and passed highlighted bezier curve to it.
- updates `drawRect` to visually highlight selected text.

## Changelog:
[iOS][Fixed] - Fixed text highlighting in the New Architecture

Reviewed By: sammy-SC

Differential Revision: D54594472

fbshipit-source-id: ed454e3a1660fa76d96cb131e33fba1c05f47776
2024-03-08 09:24:45 -08:00
Rick Hanlon 7bb204a160 Fix public-api-test "expected parse error" assertion (#43378)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43378

## Overview
I noticed while running this test, that there's an existing `console.error` to remove a file from the `FILES_WITH_KNOWN_ERRORS` list, but the tests pass despite the error. This happens because the `console.error` throws to fail the test, but this `console.error` is inside a try/catch, so the error is swallowed.

This diff moves the check to a finally, which fails the test.

I also fixed the `FILES_WITH_KNOWN_ERRORS` list.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D54587062

fbshipit-source-id: c46e98326ef6654452871337364d7e66ff204e2c
2024-03-08 08:53:49 -08:00
Alex Hunt cfa39c0a69 Integrate CDPAgent into HermesRuntimeTargetDelegate behind flag (#43353)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43353

## Context

We are migrating to the new Hermes `CDPAgent` and `CDPDebugAPI` APIs in the modern CDP server (previously `HermesCDPHandler`).

## This diff

Integrates `HermesRuntimeAgentDelegateNew` (using the new Hermes `CDPAgent` setup) into `HermesRuntimeTargetDelegate` behind a new feature flag, `inspectorEnableHermesCDPAgent`. This completes the initial integration for all platforms.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D54586162

fbshipit-source-id: 5f26c28af4414d961b1c8c9cb4cd7135bd00b410
2024-03-08 07:29:22 -08:00
Alex Hunt 166fdc5125 Create wrapper class for Hermes CDPAgent + CDPDebugAPI (#43352)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43352

## Context

We are migrating to the new Hermes `CDPAgent` and `CDPDebugAPI` APIs in the modern CDP server (previously `HermesCDPHandler`).

## This diff

Adds the `HermesRuntimeAgentDelegateNew` class to provide a swap-in replacement for the existing `HermesRuntimeAgentDelegate` when we enable this via an incoming feature flag.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D53810356

fbshipit-source-id: c63684252230a747ecf0bd8cbb6f4e22052ed9bf
2024-03-08 07:29:22 -08:00
Alex Hunt 52bd8418d8 Create InspectorFlagOverridesGuard util, substitute in tests (#43372)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43372

Create a shared `InspectorFlagOverridesGuard` util for our `jsinspector-modern` tests, update `ReactInstanceIntegrationTestWithFlags` to reuse this.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D54639775

fbshipit-source-id: 9b23e4c05bcdbb8ebc2a02a6e69326eb749d1cfd
2024-03-08 07:29:22 -08:00
Pieter De Baets 5ed3057822 Make ReactActivityDelegate methods public (#43367)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43367

Enable `ReactActivityDelegate` to be used outside of `ReactActivity` as well.

Changelog: [Internal]

Reviewed By: arushikesarwani94

Differential Revision: D54634339

fbshipit-source-id: 977e0da689d5a827feca89a5dcc9416ad5178334
2024-03-08 07:04:12 -08:00
Samuel Susla da913236ab add missing synchronisation call for native animated (#43374)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43374

changelog: [internal]

when animation that uses native driver finishes, it must synchronise the end state with shadow tree.

`onUpdateRef` for native animated is only called when the animation finishes.

Reviewed By: javache, yungsters

Differential Revision: D54582987

fbshipit-source-id: 4320ed172b8bb4b22f82c6e24b47f88f1603e4fb
2024-03-08 06:48:58 -08:00
Oskar Kwaśniewski 4adef35e97 fix(iOS) [0.74]: RCTRedBox not appearing in Bridgeless when metro is not running (#43147)
Summary:
When testing out `0.74.0-rc0` I found that when the metro is not running we are not displaying RedBox which bumps users to start the packager and reload the app. It also fixes the case where users try to reload by clicking the "Reload" button on RedBox.

## Before

https://github.com/facebook/react-native/assets/52801365/086c557f-ea1f-4a97-b4c7-df8a945cc7a0

## After

https://github.com/facebook/react-native/assets/52801365/9f8421b3-5e83-466f-8cdb-38f97981275d

## Changelog:

[IOS] [FIXED] - RCTRedBox not appearing in Bridgeless when metro is not running

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

Test Plan: Build the app without metro running check if RedBox is shown

Reviewed By: javache

Differential Revision: D54632056

Pulled By: dmytrorykun

fbshipit-source-id: fb6742898d3bd82545bfffd9175208e1a5984cb6
2024-03-08 04:53:42 -08:00
Tomek Zawadzki 642b4e5c2c Expose react_render_textlayoutmanager via prefab (#43381)
Summary:
The `react_render_textlayoutmanager` 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 `react_render_textlayoutmanager` via prefab.

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

Reviewed By: javache

Differential Revision: D54676207

Pulled By: cortinico

fbshipit-source-id: 90e3b90ff842250bf1e3abcc0c54f057b68a82fd
2024-03-08 04:32:44 -08:00
Kudo Chien 6bc95b2074 Add registerCallableModule types (#43366)
Summary:
`registerCallableModule()` was added from 7f549ec7be but no typescript types there. this pr tries to add the corresponding types.

## Changelog:

[GENERAL] [FIXED] - Add missing `registerCallableModule` TypeScript definitions

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

Test Plan: patch locally and try to `import { registerCallableModule } from 'react-native';` in a 0.74.0-rc.2 project

Reviewed By: fabriziocucci

Differential Revision: D54676151

Pulled By: cortinico

fbshipit-source-id: cd01f2ebe2d2516b458fae5b2e83cba3d3794455
2024-03-08 02:30:17 -08:00
Rick Hanlon 5126bace65 Fix VirtualizedList-test.js (#43377)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43377

Fixes `VirtualizedList-test.js`, which assumes fake timers (e.g. using `jest.runAllTimers()` and `jest.runOnlyPendingTimers()`) but did not actually use fake timers.

Changelog:
[Internal]

Reviewed By: yungsters

Differential Revision: D54668281

fbshipit-source-id: b14757744bb7a21a4e5573053549c36178826021
2024-03-07 23:19:27 -08:00
Rick Hanlon ed32b4ba0a Organize component stack regexes better (#43371)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43371

This file has a lot of regexes, let's organize and comment them all.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D54638520

fbshipit-source-id: eed61133758ccefd2a640f121c4da214bcad4880
2024-03-07 23:15:55 -08:00
Rick Hanlon adaf5eba3e Fix component stacks for tsx, ts, and jsx files (#43370)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43370

Component stacks with files ending in .ts, .tsx, or .jsx were skipped in LogBox reporting. This diff fixes the regex.

Changelog:
[General][Fixed] - Support .tsx, .ts, and .jsx in component stacks

Reviewed By: yungsters

Differential Revision: D54638526

fbshipit-source-id: a5271daaa7b687e8e075be3f94ab9b9c03f79b66
2024-03-07 23:15:55 -08:00
Vojtech Novak 2d547a3252 feat: RCTConvert to support UIModalPresentationStyle (#43297)
Summary:
Currently, the ability to convert JS values to `UIModalPresentationStyle` is not present directly on `RCTConvert`.

In the RN code base itself, there's not a lot of need to do this type of conversion, but in community modules, presenting ViewControllers can be a fairly common scenario and it'd be nice to be able to use this conversion directly from `RCTConvert`, rather than from `RCTModalHostViewManager`, as it'd improve its "discoverability" and consistency.

If someone relied on this, then it's technically speaking a breaking change but I'd say it's for the better, and searching `#import <React/RCTModalHostViewManager.h>` on github doesn't reveal a lot of results.

## Changelog:

[IOS] [ADDED] - RCTConvert to support UIModalPresentationStyle

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

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

Test Plan:
Tested using RN Tester

https://github.com/facebook/react-native/assets/1566403/6e62df86-dde3-47b0-b2e9-bb6b483cadf6

Reviewed By: fkgozali

Differential Revision: D54635896

Pulled By: dmytrorykun

fbshipit-source-id: c6747857830762cd0333c31c287954f3f10d4954
2024-03-07 18:05:34 -08:00
Dmitry Rykun ff03b149e7 Use fs.cpSync instead of execSync('cp ... (#43368)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43368

This diff replaces direct invocation of the `cp` command with the platform agnostic `fs.cpSync`.
Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D54634108

fbshipit-source-id: 41fe7b44b6534026ef1b930da85725bf3eb1e7bb
2024-03-07 09:19:09 -08:00
Adam Ernst f7bbaffdc3 Apply RN_EXPORT to ReactNativeFeatureFlags functions (#43356)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43356

To make it accessible across different dylib/bundle.

Changelog: [Internal]

Reviewed By: d16r

Differential Revision: D54601288

fbshipit-source-id: e65b724b228a680784e81b8c51ecd3f4df3fd668
2024-03-06 20:09:49 -08:00
Arushi Kesarwani c771011fed Support onActivityResult in Bridgeless (#43351)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43351

Implement `onActivityResult` on Bridgeless

Changelog:
[Internal] internal

Reviewed By: cortinico

Differential Revision: D54574139

fbshipit-source-id: f2369077199186ac6ef0187b5dfe7ed95f3b87fc
2024-03-06 13:19:55 -08:00
Rubén Norte c645646a20 Create new flag to disable the last part of the notifications for mount hooks on Android (#43349)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43349

Changelog: [internal]

We still haven't found the root cause of some of the crashes we're seeing in the experiments to enable mount hooks on Android.

This adds a new feature flag to skip part of the mount hooks pipeline to see if we can scope the investigation to that specific part (where we query the root tree in the base revision from the mounting coordinator).

Reviewed By: sammy-SC

Differential Revision: D54587739

fbshipit-source-id: 792aa8b06808e96638d1bba072bf4060ec492bd2
2024-03-06 12:41:49 -08:00
Rubén Norte fafd64e9c3 Migrate mount hooks flag to new system (#43350)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43350

Changelog: [internal]

Mount hooks have been shipped on iOS, so this removes the flag for them.

On Android, we're still testing them so it's worth moving them to the new system and scoping them to that platform.

Reviewed By: sammy-SC

Differential Revision: D54587740

fbshipit-source-id: d074927fee1a967bd3928970c31975d07cd393bb
2024-03-06 12:41:49 -08:00
Rubén Norte a66f4450e5 Improve logic to report mounted surfaces (#43337)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43337

Changelog: [internal]

Mount instructions and listeners are only called from the UI thread, so there's no need to have synchronization mechanisms for concurrency.

We're also scheduling mount hooks notifications once, but subsequent calls are ignored instead of accumulated to be notified together. This also changes that to collect all the surface IDs in the array that is read on notification.

Reviewed By: sammy-SC

Differential Revision: D54547194

fbshipit-source-id: a861e3b0113914aae5325c1486bcf8acd50eef79
2024-03-06 12:41:49 -08:00
D N 028615180b Add missing Headers methods (#43279)
Summary:
```tsx
// Hermes runtime (RN 73.x)
console.log({...Headers.prototype})
// result:
{
  "append": [Function anonymous],
  "delete": [Function anonymous],
  "entries": [Function anonymous],
  "forEach": [Function anonymous],
  "get": [Function anonymous],
  "has": [Function anonymous],
  "keys": [Function anonymous],
  "set": [Function anonymous],
  "values": [Function anonymous],
  Symbol(Symbol.iterator): [Function anonymous]
}
```

But in typescript

```tsx
new Headers().entries()
// ^^^ Error: Property entries does not exist on type Headers
Object.fromEntries(new Headers())
// ^^^ Error: Property [Symbol.iterator] is missing in type Headers but required in type Iterable<readonly any[]>
```

## Changelog:

[GENERAL] [ADDED] - [TypeScript] Add missing `Header` methods

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

Test Plan: Use code above in your RN project and run `yarn tsc --noEmit`

Reviewed By: rshest

Differential Revision: D54554523

Pulled By: arushikesarwani94

fbshipit-source-id: ae7f05f9526771ff003aaf22f786b5503661c739
2024-03-06 11:07:48 -08:00
Rob Hogan 3ed0ff34b3 Add helpers for formatting JSON CDP responses (#43340)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43340

Adds convenience methods `jsonResult`, `jsonError` and `jsonNotification` for more ergonomic construction of CDP JSON responses. Note that CDP is *loosely* based on [JSON-RPC 2.0](https://www.jsonrpc.org/specification), but differs for example in the  omission of `"jsonrpc": "2.0"`.

Before:
```
frontendChannel_(folly::toJson(folly::dynamic::object("id", req.id)(
            "error",
            folly::dynamic::object("code", -32602)(
                "message",
                "executionContextName is mutually exclusive with executionContextId"))));
```

After:
```
frontendChannel_(cdp::jsonError(
            req.id,
            cdp::ErrorCode::InvalidParams,
            "executionContextName is mutually exclusive with executionContextId"));
```

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D54202854

fbshipit-source-id: 76a407ae39ff9c2ec79bcaddb6cd4d494afb7693
2024-03-06 09:27:50 -08:00
Samuel Susla 9426d249cb delete butter module (#43300)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43300

changelog: [internal]

not used, let's delete

Reviewed By: fkgozali

Differential Revision: D54462125

fbshipit-source-id: f6cb5199e00e139c0340ad5c7b338acfb99f0d15
2024-03-06 08:38:55 -08:00
Rick Hanlon 82db330360 Fix parseLogBoxLog test that test hermes component stacks (#43281)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43281

## Overview
This diff fixes a bug in the hermes component stack location parser, and fixes the hermes component stack tests which were not using hermes stack parsing, which is why the bug wasn't caught.

The bug fix is that React component stacks may not all have stack frame locations. For example, this stack:

```
at MyComponent (/path/to/filename.js:1:2)
at MyOtherComponent                         <-- no location
at MyAppComponent (/path/to/app.js:100:20)
```

This can happen when we're unable to make a component throw (e.g. it doesn't use a hook or access props). We have plans to fix these frames, but currently they can exist.

The bug was when `parseHermesStack` finds a frame without an `entry`, it would reset the `entries`. But if entries is already non-null, or if the current frame is a frame without a source, we should continue.

### Caveats

The handling here fixes the behavior to go back to skipping these frames. I'm not sure what the best way to handle these cases are, since these frames do not have source location and should skip symbolication. We should follow up with handling for these frames.

## Why it wasn't caught

In D18627930 we changed the hermes component stack parsing to check `global.HermesInternal`, but the tests for the hermes component stacks were still using the `stacktrace-parser`. I updated the tests to set/reset the global, which caught the bug.

Changelog:
[General][Fixed] - Support hermes component stacks with missing source info.

Reviewed By: yungsters

Differential Revision: D54423252

fbshipit-source-id: 80ded8b99eab919e60f847369dcb1f3afa72b6be
2024-03-06 07:44:01 -08:00
Oskar Kwaśniewski b2fba371df feat: optimize RCTKeyWindow() for iOS 15+ (#43066)
Summary:
This PR further optimizes RCTKeyWindow() for iOS 15+ removing the need for additional loop
bypass-github-export-checks
## Changelog:

[IOS] [ADDED] - optimize RCTKeyWindow() for iOS 15+

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

Test Plan: Launch RNTester, check if proper keyWindow is returned for iOS 15+

Reviewed By: javache

Differential Revision: D54541838

Pulled By: cipolleschi

fbshipit-source-id: be79ff48f825d10c8fd71efc18629377aadc29fd
2024-03-06 07:07:53 -08:00
Oskar Kwaśniewski 7c953698b4 Allow importing RCTAppDelegate in Swift (#43339)
Summary:
This PR fixes importing RCTAppDelegate, cleans up the imports, and properly sets the background color for bridgeless mode when using `RCTRootViewFactory`.

The issue with importing to Swift was that `RCTTurboModuleManager` has C++ in headers which caused Swift to error out.

bypass-github-export-checks

## Changelog:

[IOS] [FIXED] - Allow importing RCTAppDelegate in Swift
[INTERNAL] [REMOVED] - Remove unnecessary imports in AppDelegate
[INTERNAL] [FIXED] - Properly set background color for bridgeless

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

Test Plan:
- CI Green
- Check if background color is correct

Reviewed By: dmytrorykun

Differential Revision: D54584489

Pulled By: cipolleschi

fbshipit-source-id: cb4b947ca9d0f375b1852dbf5a7d889e920562f7
2024-03-06 06:51:31 -08:00
Tomek Zawadzki 1c69100a2b Expose rrc_text via prefab (#43275)
Summary:
The `rrc_text` 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_text` via prefab.

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

Reviewed By: cipolleschi

Differential Revision: D54536468

Pulled By: cortinico

fbshipit-source-id: 8c4ef983467bfc46930f10bf7bd95761c2d11788
2024-03-06 03:54:46 -08:00
Nicola Corti e1702f44c9 Do not publish src/**/__tests__ folder for react-native (#43261)
Summary:
We should not be publishing the `__tests__` folder to the npm package.
Fixes https://github.com/facebook/react-native/issues/43242

## Changelog:

[INTERNAL] [CHANGED] - Do not publish src/**/__tests__ for react-native

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

Test Plan: Nothing to test

Reviewed By: cipolleschi

Differential Revision: D54540896

Pulled By: cortinico

fbshipit-source-id: 10b557a911b9b17d64c4697724825248a597feae
2024-03-06 03:21:44 -08:00
Pieter De Baets fb9872d4fe Fix DefaultReactNativeHost assuming lazyViewManagers are always available (#43334)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43334

cortinico flagged that bridge + fabric regressed in 0.74, likely due to D53406841.

Changelog: [Android][Fixed] Fix registration of ViewManagers in new renderer when not using lazyViewManagers.

Reviewed By: fkgozali

Differential Revision: D54551645

fbshipit-source-id: 0783030cd0d2900a3a254ae04c9ea4e51035272a
2024-03-06 03:11:33 -08:00
Pieter De Baets e4f3338069 Remove deprecated Pressability methods (#43328)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43328

These have been deprecated since 2019 (D18742620), probably time we remove them.

Changelog: [General][Removed] Removed deprecated methods from Pressability.

Reviewed By: NickGerleman

Differential Revision: D54535029

fbshipit-source-id: 45f85fb002824c94363c839fee2f831c01ad4dbd
2024-03-06 02:53:17 -08:00
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
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
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