Commit Graph

38536 Commits

Author SHA1 Message Date
Tim Yung 18302831c4 RN: Improvements to LogBoxInspectorHeader (#45194)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45194

Makes a couple improvmeents to `LogBoxInspectorHeader`:

- Avoid eagerly initializing the `StatusBar` TurboModule until it is actually needed (which is only when the inspector is rendered on Android).
- Switch to `SafeAreaView` on iOS, for more accurate spacing (instead of the hardcoded iPhone X notch size).

Changelog:
[General][Changed] - Improve LogBox initialization performance
[iOS][Changed] - Improve LogBox safe area insets styling

Reviewed By: lyahdav

Differential Revision: D59081529

fbshipit-source-id: 01cc351fa9267f96b7a3c13cf1db80de3e597f93
2024-06-26 20:17:05 -07:00
Rubén Norte 39b33f158f Add unmount method in UIManagerMountHook and use it to notify not intersecting state in IntersectionObserver (#45186)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45186

Changelog: [internal]

(this is an internal change because `IntersectionObserver` hasn't been released yet).

When testing IntersectionObserver, I realized that it wasn't triggering notifications for elements not intersecting when the surface that contained them was completely deallocated.

This is unexpected because IntersectionObserver notifications are delivered when the element is removed from the root, but not when the root itself is removed.

This fixes that behavior by:
1. Adding a method in `UIManagerMountHooks` to get a notification about the surface being unmounted. This is necessary to keep the API backwards compatible.
2. Using that method in `IntersectionObserverManager` to notify all observers (and report a change if necessary).

Reviewed By: javache

Differential Revision: D59061136

fbshipit-source-id: ef5669f9d6b08d98652489e6731902d192ec28f8
2024-06-26 11:40:21 -07:00
Alex Hunt 2cb04b4e2a Implement new HostTargetMetadata fields (iOS) (#44933)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44933

Resubmission of D58288489 (reverted due to C++ types in ObjC header).

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D58522256

fbshipit-source-id: 5a413f1d5cca9555e309ab07e4de0e19ad2603cc
2024-06-26 10:44:26 -07:00
Leon Xu 873ebc8055 Normalize newlines in public-api-test (#45145)
Summary:
Tests were failing on windows due to parsing CRLF line endings. This change enables the API tests for windows by normalizing line endings before parsing the file.

## Changelog:
[INTERNAL] [ADDED] - `public-api-test` now runs on Windows.

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

Pick one each for the category and type tags:

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

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

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

Test Plan: Build-time-only change; relying on CircleCI

Reviewed By: cipolleschi

Differential Revision: D59001867

Pulled By: huntie

fbshipit-source-id: a7a41945e8c93288be1d5b7b59df7f621e467657
2024-06-26 10:42:47 -07:00
Alex Hunt 2c210939d3 Unify versioning step in release process (#45185)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45185

Follow-up to D59058085.

Since the release branch for 0.75 has been cut, we are able to simplify this step.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D59058084

fbshipit-source-id: 21b77a74e13bb196336a63b984f921f0c9fde587
2024-06-26 10:14:12 -07:00
Alex Hunt 5f60ad65ca Rename set-rn-version script, mark as deprecated (#45184)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45184

This is a follow-up to D59055522.

> NOTE:This diff will be followed up by a merge of the set-rn-version script into set-version. (I had considered a rename to version-rn-artifacts, intentionally keeping this script separate and distinct from a future [lerna version + this script] setup — however the current UX and confusion with this naming would be too confusing. It can move into a util 👍🏻.)

- Rename `set-rn-version` to `set-rn-artifacts-version` (more accurate).
- Mark this script as deprecated.
    - For now, there are too many references to this script in CI test jobs to refactor away this entry point, so I am avoiding this — these should later be standardised to `set-version`.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D59058085

fbshipit-source-id: 4123ac73b5c7a2e07a1d1b6da61e0ad94fc31f84
2024-06-26 10:14:12 -07:00
evanbacon 8989c9b71d mark all of react-native as client boundary for React Server Components (#43986)
Summary:
While developing React Server Component support for React Native, I've been adding this patch to the `react-native` package. It opts the entire `react-native` package out of being server rendered.

In the future, we'll want to circle back and refactor the `react-native` package to be more isomorphic so we can allow for utilities like `processColor` to be used in server bundles that target native platforms.

## Changelog:

[GENERAL] [ADDED] - Added support for importing `react-native` in a `react-server` environment for React Server Components support.

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

Pick one each for the category and type tags:

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

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

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

Test Plan:
Using react-native with this patch in a framework that supports React Server Components for native platforms, such as my unreleased branch of Expo Router, will allow for server rendering views from `react-native` to RSC Flight code with client references to the `react-native` package, e.g.

```js
import { View } from 'react-native';

export default function App() {
  return <View testID="basic-view" style={{ "backgroundColor":"#191A20" }}/>
}
```

Can be server rendered to ↓

```
2:I["/node_modules/react-native/index.bundle?platform=ios&dev=true#798513620",["..."],"View"]
1:["$","$L2",null,{"testID":"basic-view","style":{"backgroundColor":"#191A20"}}]
```

> The client boundaries (URL paths) are specific to the current Expo CLI implementation (based on Metro) and may look different in other implementations.

Reviewed By: rickhanlonii

Differential Revision: D55891243

Pulled By: TheSavior

fbshipit-source-id: d8dc9590039181ebf2c013dacca5f255d7a8f625
2024-06-26 09:25:56 -07:00
Alex Hunt ebf1a7b79b Bump packages for next major release (#45015)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45015

Set package versions to `0.76.0-main` (`0.75-stable` branch was cut).

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D58687399

fbshipit-source-id: 27ed987e4557705845d57d64e7547cddbd982a03
2024-06-26 07:59:49 -07:00
Alex Hunt 4a6b889e93 Move all package.json updates into set-version script (#45180)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45180

- Simplifies the responsibilities of `scripts/releases/set-rn-version.js`.
    - This no longer modifies `packages/react-native/package.json`, delegating this to `set-version`.
- Simplifies logic in `set-version`, **fixing behaviour** against deps in `packages/react-native/package.json`.
- This also acts as cleanup since D58469912 (template removal) — removing the unreferenced `update-template-package.js` util.

NOTE: This diff will be followed up by a merge of the `set-rn-version` script into `set-version`. (I had considered a rename to `version-rn-artifacts`, intentionally keeping this script separate and distinct from a future [`lerna version` + this script] setup — however the current UX and confusion with this naming would be too confusing. It can move into a util 👍🏻.)

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D59055522

fbshipit-source-id: 79b937f9e0ac790512b180ab4147aefef7f5202c
2024-06-26 07:59:49 -07:00
Alex Hunt 616d7f2095 Fix set-version script to skip react-native interdependencies (#45028)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45028

Since the addition of new workspaces to the repo which introduce interdependencies on `react-native` (`helloworld`, `react-native-test-library`), this fix is needed to preserve our current versioning strategy and bump the repo after yesterday's `0.75-stable` branch cut.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D58725561

fbshipit-source-id: ab282806560f47dc5acf7e694302ca6b85649b14
2024-06-26 07:59:49 -07:00
Alex Hunt 0fb611009e Back out "Expose preprocessor flag for fuseboxEnabledDebug"
Summary:
Reverting. The behaviour of [`exported_preprocessor_flags`](https://buck.build/rule/cxx_library.html#:~:text=in%20platform_preprocessor_flags.-,exported_preprocessor_flags,-(defaults%20to%20%5B%5D) was misunderstood (applies this flag).

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: hoxyq

Differential Revision: D59058502

fbshipit-source-id: bf05fbfb3cf865ae6501545561952742ebd0a122
2024-06-26 07:12:20 -07:00
Riccardo Cipolleschi e6dd44d6e5 Create Changelog for 0.75.0-RC.2 (#45183)
Summary:
Adds the Changelog for RC.2

## Changelog:
[General][Added] - Add changelog lines for RC2

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

Test Plan: N/A

Reviewed By: huntie

Differential Revision: D59058256

Pulled By: cortinico

fbshipit-source-id: 055eab41ac67fadf9414ab58216ed9428e2b4f76
2024-06-26 06:40:00 -07:00
Riccardo Cipolleschi aead3db639 Remove the workaround to import the Paper renderer (#44814)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44814

We needed this workaround to import the paper renderer in the New Architecture to make sure that the event emitter is properly registered before we use it.

With the previous change, we don't need this lines of code anymore as we are using a different mechanism for the events.

## Changelog:
[Internal] - Avoid to import the old Renderer in the New Architecture

## Facebook:
This diff was initially part of D57097880, but I split them for the OTA

Reviewed By: cortinico

Differential Revision: D58234325

fbshipit-source-id: 1335992460635e9e97ee83615f9fd2651936b32c
2024-06-26 06:38:51 -07:00
Edmond Chui c6cbaf278c Update debugger-frontend from 750ed14...7cd81c1 (#45177)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45177

Changelog: [Internal] - Update `react-native/debugger-frontend` from 750ed14...7cd81c1

Resyncs `react-native/debugger-frontend` from GitHub - see `rn-chrome-devtools-frontend` [changelog](https://github.com/facebookexperimental/rn-chrome-devtools-frontend/compare/750ed147da1c0edd118f359f906d5c7553c338a8...7cd81c1548a4bca19732037dcf82662a6ed9ca39).

Reviewed By: hoxyq

Differential Revision: D59053693

fbshipit-source-id: f3b22340d3ddd6efe8f9963f025ebd47a07830ab
2024-06-26 04:27:14 -07:00
Alex Hunt 981141c9a1 Expose preprocessor flag for fuseboxEnabledDebug (#45167)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45167

Configures a `REACT_NATIVE_ENABLE_FUSEBOX_DEBUG` flag, and exposes this flag in the Buck target. This is an additional hook to enable the new debugger stack (codename Fusebox) as part of our internal rollout.

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D59014161

fbshipit-source-id: f05e8b01ed07da90ef6d7a66ade05f462dd82023
2024-06-26 03:53:54 -07:00
Pieter De Baets 2dfb09c51a Match convertRawProp error handling in iterator-based props parsing (#45156)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45156

We don't want to bubble up exceptions from props parsing, so match the behaviour from convertRawProp and fall back to the default value when an exception is encountered.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D59000397

fbshipit-source-id: f6f64a80fed98525cdd2a5b5d360c2d6ede76a12
2024-06-26 03:46:25 -07:00
Nicola Corti 88a9b6e89f Only build_android should write to the Gradle Cache (#45160)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45160

This should optimize the Gradle cache, so that only `build_android` which
effectively builds everything Android related, should be allowed to write there.

More info on this strategy here:
https://github.com/gradle/actions/blob/main/docs/setup-gradle.md

Changelog:
[Internal] [Changed] - Only build_android should write to the Gradle Cache

Reviewed By: cipolleschi

Differential Revision: D59002323

fbshipit-source-id: 31b815747efdf93bfc7baf97799e287c8dcd7f02
2024-06-26 03:40:50 -07:00
Dmitry Rykun d3e0430dea Fix output path for generated artifacts (#45165)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45165

This is a fix for https://github.com/facebook/react-native/issues/45112
This diff changes the codegen so that the output path is computed relative to project root (or `path` if provided) instead of current working directory.

Changelog: [General][Fixed] - Codegen computes output path relative to project root instead of current working directory.

Reviewed By: fkgozali

Differential Revision: D59009821

fbshipit-source-id: 3a138a3508fc239c8600b8c9f242f1c665f8e3c0
2024-06-26 01:59:54 -07:00
Peng Jiang b9ec0e5a1a use view.getPaddingStart() directly (#45150)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45150

As the androidx.core 1.13.1 change, ViewCompact.getPaddingStart and getPaddingEnd are deprecated.

based on the suggestion from https://developer.android.com/reference/kotlin/androidx/core/view/ViewCompat#getPaddingStart(android.view.View), use: view.getPaddingStart and view.getPaddingEnd directly.
 {F1717102270}

Changelog: [Internal] - Migrating deprecated APIs with AndroidX.Core 1.13.1

Reviewed By: alanleedev

Differential Revision: D58955567

fbshipit-source-id: b84377e1ded0d94e9035dcfa4dbd9c463396a322
2024-06-26 01:47:24 -07:00
Peng Jiang 71f8d7608f use view.LAYOUT_DIRECTION_RTL directly (#45152)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45152

As the androidx.core 1.13.1 change, ViewCompat.LAYOUT_DIRECTION_RTL is deprecated. Based on the suggestion from https://developer.android.com/reference/androidx/core/view/ViewCompat#LAYOUT_DIRECTION_RTL(), use view LAYOUT_DIRECTION_RTL directly and they have the same value.
 {F1716960190}

Changelog: [Internal] - Migrating deprecated APIs with AndroidX.Core 1.13.1

Reviewed By: alanleedev

Differential Revision: D58953460

fbshipit-source-id: 938200d1d0b1c7cc167f0119cc20ba72d16351a4
2024-06-26 01:47:24 -07:00
Jingbo Yang 8bd9952eaf Replace YogaConstants.UNDEFINED with Float.NaN (#45141)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45141

Reviewed By: javache, NickGerleman

Differential Revision: D58915391

fbshipit-source-id: 73ebee6abaced092366abdfc0ff41a66e7ff6c03
2024-06-25 18:48:15 -07:00
Neil Dhar 993f9fd8db Implement more missing methods on WithRuntimeDecorator (#45049)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45049

WithRuntimeDecorator is missing many methods that were added after it.
Add implementations for them.

The underlying issue here is that because this inherits from
RuntimeDecorator, which implements all methods, there is no compilation
error for this runtime when we add new methods.

Changelog:
[GENERAL] [FIXED] - Add missing methods to the WithRuntimeDecorator class.

Reviewed By: avp

Differential Revision: D58752127

fbshipit-source-id: d80b4ed1c38698ed3850d0cd961bf7ddde2449a0
2024-06-25 18:11:47 -07:00
Bartłomiej Błoniarz 218ea5d44c Add missing WithRuntimeDecorator methods (#45042)
Summary:
This PR adds missing `WithRuntimeDecorator` methods related to `NativeState`. This pattern is used by reanimated to ensure no concurrent access to the runtime. Without this `override` the `RuntimeDecorator` implementation was used, bypassing our mutex.

Changelog:
[GENERAL] [FIXED] - Add missing `NativeState` methods to the `WithRuntimeDecorator` class.

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

Reviewed By: fbmal7

Differential Revision: D58744051

Pulled By: neildhar

fbshipit-source-id: 3f5c85d0bf7cd6445d0c434ac4ae7ed54df203ba
2024-06-25 18:11:47 -07:00
Gijs Weterings 295626bc35 Upgrade @grpc/grpc-js from 1.7.0 to 1.10.9 (#45131)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45131

Changelog: [General][Security] Upgrade grpc/grpc-js from 1.7.0 to 1.10.9 (CVE-2024-37168)

Reviewed By: fabriziocucci

Differential Revision: D58948299

fbshipit-source-id: fc1d0047eedfd081212be68cf95fca571efd78d3
2024-06-25 17:30:10 -07:00
Gijs Weterings d538879e08 Upgrade braces from 3.0.2 to 3.0.3 (#45132)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45132

Changelog: [General][Security] Upgrade braces from 3.0.2 to 3.0.3 (CVE-2024-4068)

Reviewed By: hoxyq

Differential Revision: D58948245

fbshipit-source-id: 4ef653f2574e763f3a8d227310b55e0f336f19f4
2024-06-25 17:30:10 -07:00
Gijs Weterings 13f1b9e10f upgrade ws from 7.5.1 to 7.5.10 (#45129)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45129

X-link: https://github.com/facebook/metro/pull/1297

Changelog: [General][Security] Update ws from 7.5.1 to 7.5.10 (CVE-2024-37890)

Reviewed By: hoxyq

Differential Revision: D58947571

fbshipit-source-id: 43ee200e02fcc17a47a30e0baaab4f01043fc6fd
2024-06-25 17:30:10 -07:00
Gijs Weterings 80cfacef78 Upgrade ws from 6.2.2 to 6.2.3 (#45130)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45130

Changelog: [General][Security] Update ws from 6.2.2 to 6.2.3 (CVE-2024-37890)

6.2.3 is a patch to mitigate a dos vuln https://github.com/websockets/ws/releases/tag/6.2.3

Reviewed By: hoxyq

Differential Revision: D58946681

fbshipit-source-id: ff73f31ffd9b14392e3bea4e616cb5f4c9b8d13f
2024-06-25 17:30:10 -07:00
Zeya Peng b5683a7516 Create util functions to convert Color <-> uint8_t RGBA values (#45139)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45139

## Changelog

Sometimes we pass down int RGBA values in [0, 255] to represent color components in ReactNative;
and other times we use float. Since we introduce display P3, we probably want to use color depth more than 8bit

In the first case, when RGBA are passed down as uint8_t, we can directly calculate Color/SharedColor without normalizing them to [0,1] and scale back to [0, 255] as `colorFromComponents` does; otherwise there could be some precision loss..

So here I'm adding some new utils for that purpose: see `colorFromRGBA`, `redFromColor`, `greenFromColor`, etc

[Internal]
Examples in codebase:
* rgba in [0, 255]:
https://www.internalfb.com/code/fbsource/[67148a47147b0e15f0f0748003394040611c2bc2]/xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/graphics/fromRawValueShared.h?lines=28-35

* rgba in [0, 1]:
https://www.internalfb.com/code/fbsource/[67148a47147b0e15f0f0748003394040611c2bc2]/xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/graphics/fromRawValueShared.h?lines=37-45

https://www.internalfb.com/code/fbsource/[67148a47147b0e15f0f0748003394040611c2bc2]/xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/graphics/fromRawValueShared.h?lines=47-64

Reviewed By: rshest

Differential Revision: D58872165

fbshipit-source-id: 748a12a99591c895fed65cda6deeaa2a3e0c3cf5
2024-06-25 16:04:56 -07:00
Tim Yung 08b05f30c2 RN: Refactor ScrollView Native Component Imports (#45168)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45168

Refactors the native component imports in `ScrollView` so that 1) they create less clutter in the `ScrollView` implementation file, and 2) they offer more efficient import inlining.

Currently, `ScrollView` has to evaluate both horizontal and vertical components even though only one may be used. Now this optimization is possible.

Changelog: [Internal]

Reviewed By: lyahdav

Differential Revision: D59015990

fbshipit-source-id: 963009821a7d3019d36a43269e9792ac1f2f38ec
2024-06-25 13:25:43 -07:00
Ruslan Lesiutin 2e03d262d4 upgrade[react-devtools-*]: v.5.3.0 (#45159)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45159

Changelog: [Internal]

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

allow-large-files

Reviewed By: EdmondChuiHW

Differential Revision: D59001348

fbshipit-source-id: e17e1070b38256644fa987bd00510b8a7c5d848a
2024-06-25 10:52:46 -07:00
Dmitry Rykun a44dd57f10 Update codegen artifacts for react-native-test-library (#45164)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45164

Some changes have been made to the codegen since `react-native-test-library` was published. This diff updates the generated artifacts in that library.
Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D59010093

fbshipit-source-id: f11ccd3645da72d45c70581e485f8546166ca182
2024-06-25 09:57:04 -07:00
zhongwuzw 70b43bb013 Fixes js bundle failed (#45155)
Summary:
When I enabled `FORCE_BUNDLING`, it build errors like below. cc blakef
![image](https://github.com/facebook/react-native/assets/5061845/d23f6bad-ed60-4f1f-8111-2361c93e93a4)

## Changelog:

[INTERNAL] [FIXED] - Fixes js bundle failed

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

Test Plan: Enable FORCE_BUNDLING and build success.

Reviewed By: cipolleschi

Differential Revision: D59006962

Pulled By: blakef

fbshipit-source-id: 1142d1ddbae7346b67712fac0237950847211992
2024-06-25 08:57:21 -07:00
Ramanpreet Nara 7522336412 Bridgeless: Allow js bundle configuration via filepaths
Summary:
## Summary
Right now, the only way to load the javascript bundle is through the assets:// directory.

But, legacy react native also supports loading bundles via regular file urls.

If present, those file urls override the assets:// bundle urls.

This diff implements that support in bridgeless.

Changelog: [Android][Added] Allow js bundle file urls

Reviewed By: christophpurrer

Differential Revision: D58977143

fbshipit-source-id: 6f1a170546c8bbeac3a1b9d2dd5633177e33a688
2024-06-25 07:13:39 -07:00
Ramanpreet Nara 80e1dd70b0 ReactHost: Make ReactInstanceEventListener APIs public
Summary:
The ReactInstanceManager allows applications to register a ReactInstanceEventListener with itself.

Exposing a similar functionality to ReactHost. So, applications can do the same in bridgeless.

Changelog: [Android][Added] - Make ReactInstanceEventListener available on ReactHost

Reviewed By: christophpurrer

Differential Revision: D58890092

fbshipit-source-id: c18ee8a45d274c5cba859c6a5b4049904f1d308a
2024-06-25 07:13:39 -07:00
Rob Hogan 88ba9a6042 Inspector: Support /open-debugger specifying target param (#45138)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45138

Add a new `/open-debugger` endpoint format that allows specifying `target` - the proxy-unique target `id`. This is logically equivalent to specifying both device and page.

Changelog:
[General][Added]: Inspector: Support `/open-debugger` specifying `target` param

Reviewed By: hoxyq

Differential Revision: D58950622

fbshipit-source-id: 9665f8a24ba2bb0561cc3c693dfb84bfffdeb4a4
2024-06-25 06:28:57 -07:00
Rob Hogan c7970379a1 Inspector: Enforce device and appId filters if both are given to /open-debugger (#45140)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45140

Previously, if the `/open-debugger` endpoint was provided with both `device` and `appId` query params, we would:
 - Try to find a target with a matching `device` (note that these logical "devices" are unique per-app) - if found, use it. Otherwise,
 - Try to find a target with a matching `appId` - if found, use that.

This could go "wrong" in two ways:
 - If a `device` is given with a spurious `appId`, we'd open to a target with an `appId` differing from the one specified.
 - If the `device` has gone away but there is a different target with the same app, we'd use that as a fallback (right app, wrong device).

This applies the filters more strictly so that if both are given, both must match.

Changelog:
[General][Changed]: Inspector: Enforce device and appId filters if both are given to /open-debugger

Reviewed By: hoxyq

Differential Revision: D58951952

fbshipit-source-id: a95f1160e5c88f957445058f3273e922a5d28c1e
2024-06-25 06:28:57 -07:00
Dmitry Rykun 1fda630d87 Make RawPropsParser::iterateOverValues more performant (#45088)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45088

This diff should make iterator-style prop setting more performant.
- It removes some layers of indirection. Now `ConcreteComponentDescriptor` calls into `setProp` directly.
- On both platforms, we will use `folly::dynamic` parser, it seems it is slightly faster.
- On Android, we will reuse `props->rawProps` parsed as a `folly::dynamic` representation, instead of parsing stuff twice.

Changelog: [Internal] - This hasn't been rolled out to OSS yet.

Reviewed By: javache

Differential Revision: D58593492

fbshipit-source-id: aa2dcb4e7ba2248f6ba7aa82a60355efdf769b2c
2024-06-25 05:09:08 -07:00
zhongwuzw 9b9c780cc8 Fixes TextInput crash when undo if text longer than maxLength (#45097)
Summary:
Fixes https://github.com/facebook/react-native/issues/45050 . System pass the range bigger than we allowed because we limit the maxLength. We truncated the range to fix the undo crash.

cc. cortinico .

## Changelog:

[IOS] [FIXED] - Fixes TextInput crash when undo if text longer than maxLength

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

Test Plan: Repro please see https://github.com/facebook/react-native/issues/45050.

Reviewed By: cortinico

Differential Revision: D58947130

Pulled By: cipolleschi

fbshipit-source-id: 1c09cad8ac7ee99f3a3eef93fafb5aeac425d146
2024-06-25 04:23:38 -07:00
Biki-das cf015f93ef feat:- added UIInterfaceOrientation in place of statusBarOrient… (#44825)
Summary:
This PR replaces the depreacted `statusBarOrientation` method to `interfaceOrientation`, as in the apple developer docs it clearly says the method has been deprecated
https://developer.apple.com/documentation/uikit/uiapplication/1623026-statusbarorientation

## Changelog:
[iOS] feat:- added UIInterfaceOrientation in place of statusBarOrietation.

[IOS] [ADDED] - Added RCTUIInterfaceOrientation helper method

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

Test Plan: Tried `RNTester` build after the changes and it ran successfully!

Reviewed By: cortinico

Differential Revision: D58947500

Pulled By: cipolleschi

fbshipit-source-id: 401abf1d46b415093f441d1dbee139e7aaf8712c
2024-06-25 04:14:30 -07:00
Miklós Fazekas f903f34837 Allow library podspec to declare Swift Package Manager dependencies (#44627)
Summary:
React-Native uses Cocapods for native dependency management on iOS. While CocoaPods is flexible and popular, Apple's Swift Package Manager is the new standard. Currently consuming packages available only via Swift Package Manager is not possible. This change implements a single extension so .podspec files can declare Swift Package Manager dependencies via
```ruby
ReactNativePodsUtils.spm_dependency(s,
     url: 'https://github.com/apple/swift-atomics.git',
     requirement: {kind: 'upToNextMajorVersion', minimumVersion: '1.1.0'},
     products: ['Atomics']
   )
```

bypass-github-export-checks

## Changelog:

[IOS] [ADDED] - libraries can now declare Swift Package Manager dependencies in their .podspec with `ReactNativePodsUtils.spm_dependency`

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

Test Plan:
https://github.com/mfazekas/rn-spm-rfc-poc/

Is a simple demo for the feature:

1. Podspec declare dependency with:

   ```ruby
   if const_defined?(:ReactNativePodsUtils) && ReactNativePodsUtils.respond_to?(:spm_dependency)
     ReactNativePodsUtils.spm_dependency(s,
       url: 'https://github.com/apple/swift-atomics.git',
       requirement: {kind: 'upToNextMajorVersion', minimumVersion: '1.1.0'},
       products: ['Atomics']
     )
   else
     raise "Please upgrade React Native to >=0.75.0 to use SPM dependencies."
   end
   ```

2. [`import Atomics`](https://github.com/mfazekas/rn-spm-rfc-poc/blob/e4eb1034f7498dedee4cb673d327c34a6048bda2/ios/MultiplyInSwift.swift#L1C2-L1C15) and [`ManagedAtomic`](https://github.com/mfazekas/rn-spm-rfc-poc/blob/e4eb1034f7498dedee4cb673d327c34a6048bda2/ios/MultiplyInSwift.swift#L7-L13) is used in the code

3.) `spm_dependency` causes the dependency to be added via `post_install` hook in the workspace

<img width="261" alt="image" src="https://github.com/facebook/react-native/assets/52435/ad6aee1c-ac88-4c84-8aa3-50e148c4f5b2">

4.) `spm_dependecy` causes the library to be linked with `Atomics` library

<img width="817" alt="image" src="https://github.com/facebook/react-native/assets/52435/bfc8dfc0-aeb7-4c75-acbd-937eab1cbf80">

Limitations:
1.) only works `USE_FRAMEWORKS=dynamic pod install` otherwise the linker fails [with known Xcode issue - duplicate link issue](https://forums.swift.org/t/objc-flag-causes-duplicate-symbols-with-swift-packages/27926)
2.) .xcworkspace needs to be reopened after `pod install` - this could be worked around by not removing/readding spm dependencies

### See also:

https://github.com/react-native-community/discussions-and-proposals/issues/587#issuecomment-2117025448
https://github.com/react-native-community/discussions-and-proposals/pull/787

Reviewed By: cortinico

Differential Revision: D58947066

Pulled By: cipolleschi

fbshipit-source-id: ae3bf955cd36a02cc78472595fa003cc9e843dd5
2024-06-25 03:45:07 -07:00
Moti Zilberman 4a8f0ee58a Keep HostTarget registered until ReactHostImpl/ReactInstanceManager is invalidated (#45146)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45146

Changelog: [Internal]

Currently, on Android, we destroy the Fusebox `HostTarget` when we receive the `onHostDestroy` event, which (counterintuitively) does not mean the ReactHost/InstanceManager ("Java Host") is being destroyed. This can lead to situations where the `HostTarget` is destroyed too soon (e.g. when a single Java Host is reused across multiple Activities).

Now that we have the `invalidate()` method on the Java Host classes, we can tie `HostTarget`'s destruction to that instead.

Since calling `invalidate()` is explicitly optional, we also need to account for the case where the caller just lets go of the Java Host reference and expects GC to handle cleanup. This includes:

* Breaking the retain cycle between the Java Host and its C++ part. We achieve this using `WeakReference` to reference the Java Host.
* Making the C++ part of the Host safe to destroy from any thread (and in particular the finalizer thread). We achieve this by scheduling `HostTarget`'s unregistration (in C++) on the executor supplied by the Java Host.

Reviewed By: hoxyq

Differential Revision: D58284590

fbshipit-source-id: 4ee4780354fb81137b891d5891d6138ac215cbff
2024-06-24 14:35:53 -07:00
Moti Zilberman a7adfef0bb Reject debugger connections to unknown page IDs (#45148)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45148

Changelog: [General][Fixed] Reconnecting to an unknown inspector page no longer results in a zombie connection

TSIA

Reviewed By: hoxyq

Differential Revision: D58954759

fbshipit-source-id: 99c5caccc3cc917e0691e94326c7a35874f9a385
2024-06-24 12:59:53 -07:00
Christoph Purrer 6daccf75da Enable EventEmitter parsing for TypeScript TM Specs (#45118)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45118

## Changelog:

[General] [Fixed] - Enable EventEmitter parsing for TypeScript TM Specs

Reviewed By: rshest

Differential Revision: D58929364

fbshipit-source-id: 0f95aee2f387edf0a148b368d71b0325c805f724
2024-06-24 11:36:49 -07:00
Robert Pasiński af04eb773c fix: Improve Timers error handling and web compatibility (fixes #45085) (#45105)
Summary:
Improve compatibility with web implementations of JS timers.

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

## Changelog:

[GENERAL] [CHANGED] - Timer functions are now throwing exceptions in less cases and are instead quiet quitting (similar to browsers)
[GENERAL] [CHANGED] - Timer functions `timeout` argument is now coerced to a number

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

Test Plan: Updated RN tester

Reviewed By: christophpurrer

Differential Revision: D58952146

Pulled By: javache

fbshipit-source-id: 5b6de524f6a03f5221f0d11e0ae2a9313951c767
2024-06-24 11:24:46 -07:00
Rubén Norte 0062435d2e Rename some methods in RuntimeScheduler_Modern to refer to event loop more explicitly (#45143)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45143

Changelog: [internal]

Just a small refactor of some private methods in `RuntimeScheduler_Modern` to refer to some concepts in terms of the event loop.

Reviewed By: christophpurrer

Differential Revision: D58948811

fbshipit-source-id: 979c78ccd4cf5d96f00061049366171934b43ee2
2024-06-24 10:22:38 -07:00
Blake Friedman 2d737bbf9a fix: podfile lock cache keys (#45128)
Summary:
These keys weren't evaluating`hashfiles(...)`.

{F1716603166}

## Changelog: [Internal]

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

Reviewed By: cipolleschi

Differential Revision: D58947839

Pulled By: blakef

fbshipit-source-id: d3c36235387a1c54f637b2b9bf53198bd29226e2
2024-06-24 09:40:43 -07:00
Moti Zilberman 986cf18dd2 Migrate ReactHost / ReactInstanceManager destroy() call sites to use invalidate() (#45082)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45082

Changelog: [Android][Breaking] `ReactNativeHost` invalidates the instance manager on `clear()`

Changes `ReactNativeHost.clear()` to invalidate the underlying `ReactInstanceManager`, rather than merely destroying the instance.

This is technically a **breaking change** because the underlying `ReactInstanceManager` may have escaped (via `ReactNativeHost.getReactInstanceManager()`) before the `clear()` call. In my reading of the API and of usages like [this one in Expo](https://github.com/expo/expo/blob/23a905b17065703882ebeda1fc9f65a05cc69fa7/packages/expo-dev-menu-interface/android/src/main/java/expo/interfaces/devmenu/ReactHostWrapper.kt#L117), this should rarely occur in practice.

The plan:
1. D58811090: Add the basic `invalidate()` functionality.
2. **[This diff]**: Add `invalidate()` call sites where it makes sense in core.
3. [Upcoming diff]: Keep the Fusebox debugging target registered until the Host is explicitly invalidated.

Reviewed By: javache

Differential Revision: D58811091

fbshipit-source-id: 5dfebad46a2bdf3601642b3c3fe3e79e8695e193
2024-06-24 09:14:01 -07:00
Moti Zilberman a3db352e25 Add invalidate() method to ReactHost and ReactInstanceManager (#45081)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45081

Changelog: [Android][Added] Add `invalidate()` method to ReactHost and ReactInstanceManager

Adds an `invalidate()` method to both `ReactHost` (Bridgeless) and `ReactInstanceManager` (Bridge). This method is an *optional* signal that the application is about to permanently stop using the Host, and that the Host can therefore fully clean up any resources it's holding.

Reusing a Host after it's invalidated is illegal and will trigger a Java assertion.

The plan:
1. **[This diff]**: Add the basic `invalidate()` functionality.
2. [Upcoming diff]: Add `invalidate()` call sites where it makes sense in core
3. [Upcoming diff]: Keep the Fusebox debugging target registered until the Host is explicitly invalidated.

Reviewed By: tdn120

Differential Revision: D58811090

fbshipit-source-id: 79b607dcc74de38b85fc0ebb4c640b9654595c9a
2024-06-24 09:14:01 -07:00
Jorge Cabiedes Acosta d11a7b0d18 Add DropShadow effect on Android (#44937)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44937

Continuing CSS filters support efforts for Android this diff implements support for dropShadow.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D58488573

fbshipit-source-id: 393e43ba1e24705d8f1fc4ba3df8e12272d874b3
2024-06-24 08:45:51 -07:00
Jorge Cabiedes Acosta b56ce9d35b JS plumbing to get dropShadow into native (#44939)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44939

DropShadow is a filter so we need to add the logic for sending it to native through the same process function for the other filters.

Drop shadow can have more arguments than the other filters. I'm following a similar pattern to boxShadow D57872933.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D58370127

fbshipit-source-id: dba06bb2e0ea2799d20e8b0b9065a5729df22bb6
2024-06-24 08:45:51 -07:00