Commit Graph

38536 Commits

Author SHA1 Message Date
Bruce Mitchener ebd170bec3 Fix typos.
Summary:
This fixes a variety of spelling mistakes in file names, identifiers, and comments.

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

Reviewed By: NickGerleman

Differential Revision: D54987359

Pulled By: yungsters

fbshipit-source-id: 6b7ca20f4855f5f654036672bc10f8b079288acd
2024-03-19 02:52:40 -07:00
Wendi Du ff5e1a605a Revert D55013623: Migrate back to chromium-edge-launcher since Windows fix was merged
Differential Revision:
D55013623

Original commit changeset: bff2aa2801dd

Original Phabricator Diff: D55013623

fbshipit-source-id: d7f19068327b5cf427750fbcae01d3c10f9c89b5
2024-03-18 14:29:02 -07:00
Alex Hunt a87fb56ef5 Fix new release workflow script (#43530)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43530

Fixes and changes following D54956345, encountered during the release process for 0.74 RC4 today.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D55017872

fbshipit-source-id: 616b387088db00c6f076f4571b4ab1541467361c
2024-03-18 12:18:55 -07:00
Arushi Kesarwani 6dd0cc99f8 Refactor ReactDelegate to provide DevSupportManager (#43520)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43520

Refactor ReactDelegate to have a private `getDevSupportManager()` that can also be re-used  by `reload()`

This method conditionally provides the correct DevSupportManager in cases of Bridge & Bridgeless

Changelog:
[Internal] internal

Reviewed By: cortinico

Differential Revision: D54967130

fbshipit-source-id: 37d585de33a50b98d01803d3080c5693a8c494b9
2024-03-18 11:54:03 -07:00
Tommy Nguyen 43ffce9fb3 Migrate back to chromium-edge-launcher since Windows fix was merged (#43524)
Summary:
The [Windows fix](https://github.com/cezaraugusto/chromium-edge-launcher/pull/1) was merged and published. We no longer need to use the fork.

## Changelog:

[INTERNAL] [FIXED] - Fix experimental debugger launch flow with Edge on Windows

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

Test Plan: n/a

Reviewed By: robhogan

Differential Revision: D55013623

Pulled By: motiz88

fbshipit-source-id: bff2aa2801dd0dcdd6975dca0a2ec2aa9864ff6f
2024-03-18 10:45:04 -07:00
Pieter De Baets 6014dce04c Revert D54630694: Fix duplication across and rncore and FBReactNativeComponentSpec
Differential Revision:
D54630694

Original commit changeset: 75cb961ded9f

Original Phabricator Diff: D54630694

fbshipit-source-id: 50832c934e5bcc1a92456d949995c05a33767a92
2024-03-18 10:38:35 -07:00
Blake Friedman a380ea55fb Summary: minor fix found in nightly logs from Publish NPM job (#43519)
Summary:
Minor fix to package.json which newer version of npm warn about when publishing, after running `npm pkg fix -ws` on the workspace.

{F1470070110}

## Changelog: [Internal] npm pkg fix -ws

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

Test Plan: eyescloseddog

Reviewed By: cortinico

Differential Revision: D55012872

Pulled By: blakef

fbshipit-source-id: ff3c63a3eefaf56d369219a3d4b32d44d6d842c9
2024-03-18 08:29:10 -07:00
Lluís 91d725136e eslint: Update @typescript-eslint monorepo to v7 & eslint-plugin-jest to v27 (#43406)
Summary:
This PR updates `typescript-eslint/eslint-plugin` and `typescript-eslint/parser` to `v7` and `eslint-plugin-jest` to `v27`, removing any dependencies on `typescript-eslint` `v6`, allowing projects using `react-native/eslint-config` to safely update to  `typescript-eslint` `v7` without having to worry about duplicate major versions installed

## Changelog:

- [General] [Changed]: Updated `eslint-plugin-jest` to `v27`
- [General] [Changed]: Updated `typescript-eslint` monorepo to `v7`

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

Test Plan: `yarn run lint` executed locally successfully

Reviewed By: robhogan

Differential Revision: D54749676

Pulled By: tdn120

fbshipit-source-id: f6fae92fc95333e28b36a3d2bd8470c8869d38bc
2024-03-18 07:46:35 -07:00
Pieter De Baets ef77087293 Fix duplication across and rncore and FBReactNativeComponentSpec (#43385)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43385

`rncore` and `FBReactNativeComponentSpec` contain the same symbols, which leads to conflicts when we try to merge them into a single shared library. Cleanup the duplication and standardize on `FBReactNativeComponentSpec` everywhere. I've left the Android OSS targets as is, to avoid breaking deps.

Changelog: [Internal]

Reviewed By: cortinico, dmytrorykun

Differential Revision: D54630694

fbshipit-source-id: 75cb961ded9fd75508755c0530e29409fef801cf
2024-03-18 07:30:33 -07:00
Delphine Bugner d53cc2b46d Fix/image methods mock in jest setup (#43497)
Summary:
### Context

- Since RN 0.73, in the jest.setup file, methods of the Image module (Image.getSize, Image.resolveAssetSource...) are mocked on the **JS side** (introduced in https://github.com/facebook/react-native/pull/36996)
- It causes issues like https://github.com/facebook/react-native/issues/41907 : `Image.resolveAssetSource` returns nothing in test env with the new JS mock, when some test relies on it.
- On my project, it broke the snapshots : the URL of images disappeared. I use `react-native-fast-image` which uses `Image.resolveAssetSource` to compute URLs.
- I first opened a PR to fix exclusively Image.resolveAssetSource: https://github.com/facebook/react-native/pull/41957. I will close it to focus on this new one.
- As suggested by ryancat and idrissakhi, it should be better to return to the previous mock, where no method is mocked on the JS side, and we can trust the actual JS to work in test.

This is what this PR intends to do.

### Content

Along fixing the Image module mock in jest.setup, this PR :

- adds unit test on each one of the methods, ensuring they have a consistent behavior even when the module is mocked.
- adds 3 missing native mocks for `NativeImageLoader`: `prefetchImageWithMetadata`, `getSizeWithHeaders` & `queryCache`. After this PR, no method from NativeImageLoader remains unmocked.

## Changelog:

[GENERAL][FIXED] - fix jest setup for Image methods (resolveAssetSource, getSize, prefetch, queryCache)

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

Test Plan:
See exhaustive unit tests in PR.

You can re-use the mock with all the methods mocked and see how the new unit tests fail.

I also patched those changes on my project: my snapshot did have their URL back (see demonstrative screenshots in my original PR: https://github.com/facebook/react-native/pull/41957 - NB; fixed mock was different but result was the same -> those screenshots cover only two cases, but anyway they illustrate well the case!)

Reviewed By: ryancat

Differential Revision: D54959063

Pulled By: tdn120

fbshipit-source-id: 837266bd6991eb8292d9f6af1774e897ac7a8890
2024-03-18 06:53:39 -07:00
Rubén Norte a2e22404fb Remove feature flag to skip mount hook notifications (#43504)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43504

Changelog: [internal]

We identified the issue in the experiments already, so we can remove this flag.

Reviewed By: sammy-SC

Differential Revision: D54945099

fbshipit-source-id: 4d547569eb3bbfd011f5d6894d87bfa542cac07b
2024-03-18 06:15:52 -07:00
Rubén Norte ebe26c198e Improve thread safety of MountingCoordinator (#43503)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43503

Changelog: [internal]

## Context

In the experiments to enable mount hooks on Android we saw some crashes that we couldn't reproduce or pinpoint accurately.

We ran another experiment excluding part of the code in one of the variants, and we found that the problem was in this block (only crashes when `skipMountHookNotifications` is false):
https://github.com/facebook/react-native/blob/121b26184acbb77ff4f2360647cb322ff560b145/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp#L726-L734

Looking more closely at the mounting coordinator code, I realized that some of the methods are not thread-safe, which is likely causing these issues.

~~We're probably only seeing these issues on Android because we have a push model there (we call `pullTransaction` from whatever thread we're committing to, JS thread or Fabric background thread) whereas in the rest of platforms we have a pull model and we always access call `pullTransaction` from the main thread, as we do to report mounts.~~

This is probably fine because both cases are protected by a mutex when accessing through `ShadowTreeRegistry::visit`. But there's a case that doesn't go through it that could be causing the issues: prerendering:
https://github.com/facebook/react-native/blob/121b26184acbb77ff4f2360647cb322ff560b145/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp#L289

## Changes

1) Make `getBaseRevision` return a copy of the revision rather than a reference.
2) Make all methods that access `baseRevision_` and `lastRevision_` thread-safe.

Reviewed By: javache

Differential Revision: D54945100

fbshipit-source-id: d8b211137d0eac02a5814cc6c376c22733290eab
2024-03-18 06:15:52 -07:00
Rubén Norte 87b73a0bad Enable event loop by default when bridgeless is enabled (#43396)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43396

Changelog: [General][Changed] Enabled new event loop behavior when bridgeless (new architecture) is enabled.

Reviewed By: rshest

Differential Revision: D54682678

fbshipit-source-id: ff8c45bc1caae0e9182aa94d915d7b6f9427caf9
2024-03-18 04:51:39 -07:00
Rubén Norte a1c752cd87 Update OSS renderers with compatibility with event loop (#43507)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43507

Changelog: [General][Changed] - sync React renderers to 18.3.0-canary-9372c6311-20240315

Syncs React renderers to https://github.com/facebook/react/commit/9372c63116fc1e855c51d93d83f5150661371ec3 which is canary for 18.3.0-canary-9372c6311-20240315.

This includes the necessary changes to enable the use of microtasks for scheduling in Fabric.

Reviewed By: yungsters

Differential Revision: D54947212

fbshipit-source-id: 8fd5def5107d77e6a248f653a9d0260b392fab6b
2024-03-18 04:51:39 -07:00
Alex Hunt 14a7202983 Add prepare_release_new workflow, configure via flag (#43518)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43518

This is a minimum approach to achieve a **single-command publish flow** for React Native, unifying the previous `yarn bump-all-updated-packages` and `yarn trigger-react-native-release` workflow entry points.

This diff aims to change as little as possible to achieve the above — introducing a new job that merges operations to create the versioning commit. The triggered publish jobs are unchanged. In future, we may follow this change with further simplifications down the workflow tree.

**Key changes**

- Adds a new CircleCI workflow, `prepare_release_new`, which versions **all packages** and writes a single release commit.
- This replaces `yarn bump-all-updated-packages`, now implemented with the newer `set-version` script.
- Wires this up as an experiment within `trigger-react-native-release.js`, conditionally running the new workflow when `--use-new-workflow` is passed.

**Not changed**

- The single release commit written will continue to trigger both of the existing CI workflows on push (`publish_release` and `publish_bumped_packages`), which are unchanged.
    - The commit summary now includes the `#publish-packages-to-npm` marker, in order to trigger `publish_bumped_packages`.
- Usage: Release Crew members will continue to use the existing local script entry point (as [documented in the releases repo](https://github.com/reactwg/react-native-releases/blob/main/docs/guide-release-process.md#step-7-publish-react-native)), with the opt in flag.
    ```
    yarn trigger-react-native-release --use-new-workflow [...args]
    ```

After we're happy with the E2E behaviour of this workflow in the next 0.74 RC, I will follow up by dropping the `--use-new-workflow` flag and removing the old scripts (T182533699).

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D54956345

fbshipit-source-id: 35fd7af8f3e60a39507b5d978ccd97472bf03ddb
2024-03-18 02:22:46 -07:00
Samuel Susla 06dc448d85 use structs instead of class for TextInputMetrics and KeyPressMetrics (#43510)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43510

changelog: [internal]

- use designated initializers.
- make TextInputMetrics and KeyPressMetrics structs.
- move TextInputMetrics and KeyPressMetrics inside of TextInputEventEmitter.
- Utilise RCTSizeFromCGSize, RCTEdgeInsetsFromUIEdgeInsets and RCTPointFromCGPoint when creating  TextInputMetrics.

Reviewed By: rshest

Differential Revision: D54895928

fbshipit-source-id: 4afd49ffa77c5afafc794808aac7f11bb8213944
2024-03-16 12:12:46 -07:00
Jane Li f2f62cdf54 Back out "Add onUserLeaveHint support to ReactActivityDelegate"
Summary:
This is causing Twilight Android app to hang and crash on start

Original commit changeset: 3f24271405f6

Original Phabricator Diff: D54905564

Reviewed By: sammy-SC

Differential Revision: D54960053

fbshipit-source-id: 5c1063f11ae1314e71288905eb6d8da32ddbfadd
2024-03-15 13:37:22 -07:00
Fabrizio Cucci e19d77828d Make rn-tester navbar follow the current theme (#43514)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43514

Changelog: [Internal]

The navbar active/inactive colors were fundamentally broken on dark theme.

Reviewed By: rubennorte

Differential Revision: D54952629

fbshipit-source-id: 9cfd7d4eb904c7b6a8d7e1e900b4ff076b8aba12
2024-03-15 12:17:21 -07:00
Moti Zilberman 0277871f77 Fix ConsoleApiTest
Summary:
Changelog: [Internal]

bypass-github-export-checks

Reviewed By: huntie

Differential Revision: D54957923

fbshipit-source-id: 2178f2715e9c924ee58ac39b728279c914d4891d
2024-03-15 11:48:33 -07:00
Alex Hunt d43cdee98c Remove dangerous "9999" version string default (#43516)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43516

As titled. This seems dangerous — removing with the motivation that we'd prefer this script to fail during execution than to succeed in publishing `9999`.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D54956661

fbshipit-source-id: 23f8d49abd300385dde74871b6d2492ef63f058e
2024-03-15 11:48:22 -07:00
Rob Hogan e180f805e5 Update eslint to ^8.57.0 (#43481)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43481

Update `eslint` to `8.57.0` to satisfy the peer dependency requirements of some incoming plugin updates.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D54898017

fbshipit-source-id: 39a8ac0f9653a104277a7f0054bb7e1fe3ec54f4
2024-03-15 10:33:20 -07:00
Alex Hunt 6f6aaae73e Fix RNTester Podfile.lock update in release workflow (#43513)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43513

The previous `update_podfile_lock.sh` script would fail as executed from the repo root (could not locate RNTester dir). Delete this and replace with direct calls in `prepare-package-for-release.js`, which will fail script on error.

 {F1469216632}

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D54949214

fbshipit-source-id: 4f032069e803e84f835c279d01332d16787dfafc
2024-03-15 10:32:07 -07:00
Fabrizio Cucci f2c335ac96 Fix auto-download of CMake (#43511)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43511

Changelog: [Internal]

This is an attempt to fix [#39783](https://github.com/facebook/react-native/issues/39783).

It seems that when `configureBuildForHermes` runs (as part of `yarn android` in `rn-tester`) cmake may not be available and is not installed automatically:
* for 3p, even after installing the latest Android Studio, cmake 3.22.1 is not available by default but needs to be installed manually
* for Meta employees, same story when looking at the `ANDROID_HOME` set by the `setup_fb4a.sh` in the `.zshrc` file:
```
# added by setup_fb4a.sh
export ANDROID_SDK=/opt/android_sdk
export ANDROID_NDK_REPOSITORY=/opt/android_ndk
export ANDROID_HOME=${ANDROID_SDK}
export PATH=${PATH}:${ANDROID_SDK}/emulator:${ANDROID_SDK}/tools:${ANDROID_SDK}/tools/bin:${ANDROID_SDK}/platform-tools
```

This diff introduces an explicit task to install cmake.

### ALTERNATIVE 1

See D54897379.

### ALTERNATIVE 2

Suggested by cortinico:

> Create a mini module called :packages:react-native:ReactAndroid:hermes-engine:cmake-downloader which just triggers an empty cmake build via Android SDK

Reviewed By: cortinico

Differential Revision: D54859484

fbshipit-source-id: f9ecdf78ff408947b1e85e7da4f112c89d3a8c89
2024-03-15 10:16:29 -07:00
Rubén Norte fb42a55bdf Remove unnecessary enable_shared_from_this from built-in C++ TMs (#43506)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43506

Changelog: [internal]

We've been making all the built-in C++ TurboModules in RN extend `enable_shared_from_this` because we copied from the same template that needed it, but none of them do. This removes that unnecessary extension.

Reviewed By: sammy-SC

Differential Revision: D54901332

fbshipit-source-id: 795c7696e70041d640399e3b9f177999e22fd90b
2024-03-15 07:48:44 -07:00
Rubén Norte 60d3b75d92 Extract user timing classes to a separate module (#43471)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43471

Changelog: [internal]

Just a minor refactor

Reviewed By: sammy-SC

Differential Revision: D54854693

fbshipit-source-id: 4ba4a74cd9a2f0d96fe6259b15b348d990a66d37
2024-03-15 07:48:44 -07:00
Rubén Norte af44ba25bc Create method in NativePerformance module for performance.now (#43469)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43469

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D54854692

fbshipit-source-id: cfcdbb0596ced71d9eddc39c3a6a8d8ae8d9a543
2024-03-15 07:48:44 -07:00
Rubén Norte 5f7483c7f6 Move native code for NativePerformance to ReactCommon (#43470)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43470

Changelog: [internal]

This moves the native code for the Web Performance API to `ReactCommon`, to align with the other default C++ native modules we've defined there.

Reviewed By: sammy-SC

Differential Revision: D54860194

fbshipit-source-id: 32dccb080fb8ebd1e2acbdd59fa2dfe47e372c17
2024-03-15 07:48:44 -07:00
Alex Hunt 3515e51856 Use Hermes CDPAgent by default (#43482)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43482

## Context

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

## This diff

Now that we are confident that `CDPAgent` is stable, switch to it by default and remove the previous integration.

- Drop `inspectorEnableHermesCDPAgent` feature flag.
- Rename and replace `HermesRuntimeAgentDelegateNew` as `HermesRuntimeAgentDelegate`.
- Drop "Hermes integration: CDPAgent" log message.
- Update tests.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D54897841

fbshipit-source-id: 8a5212d27f21c54112c0820a2a3611e05d606880
2024-03-15 07:14:40 -07:00
zhongwuzw fa8fdc7888 iOS: Change image source url encode ascii to utf8 (#43502)
Summary:
We should use utf8 to cover more characters.

## Changelog:

[IOS] [FIXED] - [Fabric] iOS: Change image source url encode ascii to utf8

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

Test Plan: Fixes https://github.com/facebook/react-native/issues/43462

Reviewed By: rshest

Differential Revision: D54944653

Pulled By: cortinico

fbshipit-source-id: 0bbd3d46c8e5c04ceffe7e0ebae46dc2ce9507df
2024-03-15 06:15:44 -07:00
Moti Zilberman 04de21abb9 Console API tests
Summary:
TSIA

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: huntie

Differential Revision: D54846940

fbshipit-source-id: f322ed9b60f35f0b01b64a74a329572a16b1d485
2024-03-15 06:09:26 -07:00
Wojciech Dróżdż 3cf6c64a80 Add onUserLeaveHint support to ReactActivityDelegate (#43488)
Summary:
This PR adds `onUserLeaveHint` support into the `ReactActivityDelegate`. It allows modules to receive an event every time user moves the app into the background. This is slightly different than `onPause` - it's called only when the user intentionally moves the app into the background, e.g. when receiving a call `onPause` should be called but `onUserLeaveHint` shouldn't.

This feature is especially useful for libraries implementing features like Picture in Picture (PiP), where using `onUserLeaveHint` is the [recommended way of auto-entering PiP](https://developer.android.com/develop/ui/views/picture-in-picture#:~:text=You%20might%20want%20to%20include%20logic%20that%20switches%20an%20activity%20into%20PiP%20mode%20instead%20of%20going%20into%20the%20background.%20For%20example%2C%20Google%20Maps%20switches%20to%20PiP%20mode%20if%20the%20user%20presses%20the%20home%20or%20recents%20button%20while%20the%20app%20is%20navigating.%20You%20can%20catch%20this%20case%20by%20overriding%20onUserLeaveHint()%3A) for android < 12.

This is a re-submission of https://github.com/facebook/react-native/pull/42741. The problematic `assert` has been changed to an `if` - it's not a problem if onUserLeaveHint is received from an activity different to the current one, but in that case we shouldn't emit the event.

## Changelog:

[ANDROID] [ADDED] - Added `onUserLeaveHint` support into `ReactActivityDelegate`

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

Test Plan: Tested in the `rn-tester` app - callbacks are correctly called on both old and new architecture.

Reviewed By: javache

Differential Revision: D54905564

Pulled By: cortinico

fbshipit-source-id: 3f24271405f66bf3a9450320a484e522224eefc1
2024-03-15 05:48:59 -07:00
Nicola Corti 9c7742b7db Bump needs-attention to v2.0.0 (#43493)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43493

This is a bump of one of our external GH custom action
Closes #38046

Changelog:
[Internal] [Changed] - Bump needs-attention to v2.0.0

Reviewed By: GijsWeterings

Differential Revision: D54905530

fbshipit-source-id: 1ecc25926144641bfc080b4ca7b8551a00a0caa1
2024-03-15 05:41:20 -07:00
Moti Zilberman 121b26184a Make JsiIntegrationPortableTest reusable in other test suites
Summary:
Changelog: [Internal]

TSIA - useful for the `console` test suite I'm currently writing (D54846940) which would be awkward to fit into `JsiIntegrationTest.cpp`.

bypass-github-export-checks

Reviewed By: huntie

Differential Revision: D54846938

fbshipit-source-id: 9e20bfae7c518b3822da468adf484e51cdc4d0b9
2024-03-15 04:23:57 -07:00
Moti Zilberman 949296571b Console polyfill: preserve unknown methods from originalConsole if found (#43459)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43459

Changelog: [General][Changed] - Console polyfill now copies all properties from the existing `console` object

Fusebox now exposes a full WHATWG `console` object integrated directly with CDP debugging (D54826073). Some WHATWG `console` methods are missing from React Native's polyfill/shim, so let's pass those through unmodified so they can still be called.

(Long term, we shouldn't need most of `console.js`, but let's get there gradually as there are many RN users still depending on `nativeLoggingHook` etc.)

NOTE: We also update the "bundled" copy of `console.js` that lives in the jsinspector-modern C++ test suite.

Reviewed By: huntie

Differential Revision: D54827902

fbshipit-source-id: c6c9128903496810192614f4f8d80b68b02e25c4
2024-03-15 04:23:57 -07:00
Ruslan Shestopalyuk 80bcdc9942 Fix broken RNTester build in OSS (Android) (#43495)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43495

## Changelog:
[Internal] -

Fixes build regression of RNTester on  OSS, coming from D54764898.

NOTE: This is only Android bit for now, looking into the iOS one.

Reviewed By: cortinico

Differential Revision: D54908736

fbshipit-source-id: 70081d1378a56dd0df3f76322377f5a0e6615f80
2024-03-15 03:44:10 -07:00
Moti Zilberman c0e84ece4f Add regression test for Hermes CDP + lazy compilation bug (#43461)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43461

Adds a regression test for the duplicate `scriptParsed` bug in Hermes (T182003727). In the process, we enable Hermes lazy compilation in all our CDPAgent JSI integration tests.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D54852326

fbshipit-source-id: 52e23458d3e9e21902c3659fc944ef85c68731ac
2024-03-15 03:43:28 -07:00
Janic Duplessis a9e6759bb5 Fix maintainVisibleContentPosition on Android during momentum scroll (#43425)
Summary:
When using maintainVisibleContentPosition (mvcp) on Android it doesn't work properly when items are added during a momentum scroll. This happens because the android scrollview momentum scroll animation overrides the scroll position that the mvcp implementation sets [here](https://github.com/facebook/react-native/blob/2d547a3252b328251e49dabfeec85f8d46c85411/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/MaintainVisibleScrollPositionHelper.java#L132).

To fix this we need to cancel the momentum scroll animation, update the scroll position then restart the scroll animation with the previous animation remaining momentum.

## Changelog:

[ANDROID] [FIXED] - Fix maintainVisibleContentPosition during momentum scroll

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

Test Plan:
Tested in RNTester on Android with both vertical and horizontal scrollviews using the following code:

```ts
// packages/rn-tester/js/RNTesterAppShared.js

import {
  Button,
  SafeAreaView,
  ScrollView,
  Text,
  View,
} from 'react-native';
import React, {useLayoutEffect, useRef, useState} from 'react';

const generateUniqueKey = () => `_${Math.random().toString(36).substr(2, 9)}`

const initialData = Array.from(Array(100).keys()).map(n => ({
  id: generateUniqueKey(),
  value: n,
}))

function ListItem({item}) {
  const color = `hsl(${item.value * 10}, 75%, 85%)`;

  return (
    <View
      style={{
        backgroundColor: color,
        height: 100,
      }}>
      <Text>List item: {item.value}</Text>
    </View>
  );
}

export default function FlatListRepro() {
  const numToAdd = 10;
  const [numbers, setNumbers] = useState(initialData);
  const ref = useRef();

  const addAbove = () => {
    setNumbers(prev => {
      const additionalNumbers = Array.from(Array(numToAdd).keys())
        .map(n => ({
          id: generateUniqueKey(),
          value: prev[0].value - n - 1,
        }))
        .reverse();

      return additionalNumbers.concat(prev);
    });
  };

  useLayoutEffect(() => {
    ref.current.scrollTo({y: numbers.length * 100, animated: false});
  // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);

  return (
    <SafeAreaView style={{flex: 1}}>
      <View style={{flexDirection: 'row', alignItems: 'center'}}>
        <Button title="Add Above" onPress={addAbove} />
      </View>
      <View>
        <ScrollView
          ref={ref}
          maintainVisibleContentPosition={{
            minIndexForVisible: 0,
          }}
        >
          {numbers.map((item) => (
            <ListItem key={item.id} item={item} />
          ))}
        </ScrollView>
      </View>
    </SafeAreaView>
  )
}
```

Before:

https://github.com/facebook/react-native/assets/2677334/a7102665-991e-449e-9d0a-ef06c370dc71

After:

https://github.com/facebook/react-native/assets/2677334/5430ecb1-26a9-4c92-9f16-c762d75685db

Reviewed By: javache

Differential Revision: D54883984

Pulled By: NickGerleman

fbshipit-source-id: 95fd673a87cf5ada3bf9a7c166bba77ce557c89b
2024-03-14 20:00:56 -07:00
Dmitry Rykun 5c34ce0587 Fix RNTester OSS build (#43496)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43496

This diff adds another sub-sub-spec to React-Fabric pod to fix import paths in `textinput`.

Changelog: [Internal]

Reviewed By: philIip, rshest

Differential Revision: D54918454

fbshipit-source-id: 3949f8b8b201157f4c9eb256f3eb5bd5d66bc228
2024-03-14 19:24:35 -07:00
Samuel Susla b3a8eba5a1 merge BatchedEventQueue into EventQueue (#43438)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43438

changelog: [internal]

EventQueue can now be merged with BatchedEventQueue since there isn't anything else subclassing it.

Reviewed By: javache

Differential Revision: D54687859

fbshipit-source-id: f646583db0e46789b667f8d79d24d0cf9d7fc00c
2024-03-14 13:39:14 -07:00
Moti Zilberman 7af288e523 Lazy-init HermesRuntimeTargetDelegate
Summary:
Changelog: [Internal]

We are currently eagerly constructing a `HermesRuntimeTargetDelegate` regardless of whether the Fusebox feature flags are enabled. This can interfere with the legacy CDP backend. Instead, let's lazily construct the target delegate in a code path that only runs when the modern backend is in use.

bypass-github-export-checks

Reviewed By: rozele

Differential Revision: D54907887

fbshipit-source-id: 7dc13506739866ea6690ed21d03d91ad24ef68c5
2024-03-14 12:44:44 -07:00
Pieter De Baets a2d277f740 Flag missing DefaultHardwareBackBtnHandler interface in bridgeless too (#43487)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43487

Inconsistent between bridge and bridgeless, but if you forget to implement this interface, ReactDelegate will silently not do anything in bridgeless.

Changelog: [Android] Enforce Activities using ReactDelegate implement DefaultHardwareBackBtnHandler.

Reviewed By: arushikesarwani94

Differential Revision: D54900747

fbshipit-source-id: 5dd31d4f81e4ec37e1c3ee906be836a8a9c6a944
2024-03-14 12:21:47 -07:00
Arushi Kesarwani f345fcf3e8 Support onKeyLongPress in Bridgeless (#43472)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43472

Implement `onKeyLongPress` in Bridgeless

Changelog:
[Android][Breaking] Implement onKeyLongPress in Bridgeless

Reviewed By: cortinico

Differential Revision: D54876052

fbshipit-source-id: 88d572eab087d913205bdfa02dba96b169066393
2024-03-14 12:10:57 -07:00
Arushi Kesarwani b14f7d58e3 Support onKeyDown in Bridgeless (#43466)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43466

Implement `onKeyDown` in Bridgeless by adding it to ReactHostImpl

Changelog:
[Android][Breaking] Implement `onKeyDown` in Bridgeless

Reviewed By: cortinico

Differential Revision: D54870966

fbshipit-source-id: 0f8e48b29679f1bca92f6ac7b6ebf1592cdc5dac
2024-03-14 12:10:57 -07:00
Dmitry Rykun 9700540bec Bring back the UNSET constant to TextAttributeProps (#43491)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43491

This diff brings back the `UNSET` constant to `TextAttributeProps`.
The removal of this constant was an unnecessary breaking change, that has broken several third-party libraries.

Changelog: [Android][Fixed] - Bring back the UNSET constant to TextAttributeProps.

Reviewed By: fabriziocucci

Differential Revision: D54899524

fbshipit-source-id: 368bde77d43f310fd458537d0191d09174fa5167
2024-03-14 11:10:54 -07:00
Moti Zilberman 305c2811cf Implement native console object in RuntimeTarget (#43456)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43456

Changelog: [Internal]

Implements the [WHATWG `console` spec](https://console.spec.whatwg.org/) directly in `RuntimeTarget`, based on the Hermes-powered `addConsoleMessage` method first used in D54494298.

Benefits:

* This allows the console API to work independently of the polyfill shipped in RN, including very early during JS execution.
* It also opens the door to better stack traces (once we start reporting those) and richer functionality in the `console` object itself.

Reviewed By: robhogan

Differential Revision: D54826073

fbshipit-source-id: d5b0bd004bf35c2fce91742ae84ea86225ec1c61
2024-03-14 10:33:47 -07:00
Pieter De Baets eca4d76d81 Rollout enableBridgelessArchitectureSoftExceptions (#43485)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43485

Already fully rolled out internally.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D54804177

fbshipit-source-id: 128822d408b6943f1f1536eb0101c6684cd45106
2024-03-14 10:31:37 -07:00
Pieter De Baets 7488dc05e8 Use CopyOnWriteArrayList in MemoryPressureRouter (#43486)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43486

We use `CopyOnWriteArrayList` in other places across the React Native codebase, as it assumes that reading happens more frequently than updating. This saves us from needing to synchronize and copy when we access the list of listeners.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D54806272

fbshipit-source-id: d1b54d532edb2af3391a7e4fdc758f705621227d
2024-03-14 10:31:37 -07:00
Pieter De Baets a27e2acef4 Rollout bridgelessArchitectureMemoryPressureHackyBoltsFix (#43478)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43478

This is rolled out internally already. Also exposing `memoryPressureRouter` to match the ReactInstanceManager interface.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D54802021

fbshipit-source-id: b74dcde71296d3925acfc2171d2a77d90960e15e
2024-03-14 10:31:37 -07:00
zhongwuzw 10d48134c9 iOS: Fixes textinput onscroll event payload (#43445)
Summary:
Fixes https://github.com/facebook/react-native/issues/43428 . cc cortinico .

## Changelog:

[IOS] [FIXED] - [Fabric] iOS: Fixes textinput onscroll event payload

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

Test Plan:
```
    const onInputScroll = (e) => {
      if (Platform.OS !== "web") {
        const {
          nativeEvent: {
            contentOffset: { x, y },
          },
        } = e;
        console.log('onInputScroll ====', e?.nativeEvent)
      }
    };

<TextInput
          onScroll={onInputScroll}
          // ref={inputRef}
          multiline
  />
```

Reviewed By: cortinico

Differential Revision: D54813378

Pulled By: sammy-SC

fbshipit-source-id: 76671fbb390c2fbc67a9c29b6c2a834ba699fff4
2024-03-14 08:33:49 -07:00
Moti Zilberman 4148a31912 Integration test for CDPAgent reentrancy bugs
Summary:
Changelog: [Internal]

Adds a regression test for a Hermes CDPAgent bug using `JsiIntegrationTest`. See details in comments.

bypass-github-export-checks

Reviewed By: huntie

Differential Revision: D54890188

fbshipit-source-id: 325a32b83b145d2d35f99feaef9988028f15f196
2024-03-14 07:59:31 -07:00