Commit Graph

38536 Commits

Author SHA1 Message Date
Fabrizio Cucci 0a1a7cafa3 Kotlinify ReactConstants (#43758)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43758

Changelog: [Internal]

As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)).

Reviewed By: rshest

Differential Revision: D55632715

fbshipit-source-id: 9461c131ba250061647b37a5dcc20de10ee8393d
2024-04-02 16:17:39 -07:00
Alan Lee e5db122924 Convert WindowOverlayCompat to Kotlin (#43749)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43749

Convert Java to Kotlin: `react/devsupport/WindowOverlayCompat.java`

Changelog:
[Internal] internal

Reviewed By: rshest

Differential Revision: D55604746

fbshipit-source-id: 413bf28c8f692e85150a04de05dc7bae324ddd26
2024-04-02 15:12:58 -07:00
Fabrizio Cucci 477611c8db Kotlinify InspectorFlags (#43772)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43772

Changelog: [Internal]

As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)).

Reviewed By: rshest

Differential Revision: D55637558

fbshipit-source-id: b0bcbed4790940e52af6ca82c0ee50e6a4fd510c
2024-04-02 13:43:39 -07:00
Fabrizio Cucci 9bebab5ab1 Kotlinify LayoutDeleteAnimation (#43741)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43741

Changelog: [Internal]

As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)).

Reviewed By: rshest

Differential Revision: D55589024

fbshipit-source-id: dc14584b0f52fb20ba2b533c48de062824757256
2024-04-02 13:43:39 -07:00
Jakub Grzywacz 493dbb2190 Remove AutoFill from context menu when using contextMenuHidden (#43468)
Summary:
This pull request resolves the issue https://github.com/facebook/react-native/issues/43452
Previously, when utilizing `contextMenuHidden`, the context menu wasn't entirely hidden as the "AutoFill" option remained visible. However, it's now possible to eliminate it using the menu builder.

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

[IOS] [FIXED] - hide AutoFill from context menu when using `contextMenuHidden`

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

Test Plan:
Manual tests in RNTester:

https://github.com/facebook/react-native/assets/39670088/dc0f828c-f613-412d-b560-f3b795dd3ffb

Reviewed By: javache

Differential Revision: D54902269

Pulled By: tdn120

fbshipit-source-id: e0f3d3b5a0817db1c072caf2f01648432c7d868d
2024-04-02 12:22:32 -07:00
Arushi Kesarwani 3571f9a5c8 Migrate JSCInstance to Kotlin (#43750)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43750

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D55610929

fbshipit-source-id: eb269bdb9a2d123605ae07d86739b32c576f5fa5
2024-04-02 12:18:50 -07:00
Fabrizio Cucci 1252f63c18 Kotlinify LayoutCreateAnimation (#43740)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43740

Changelog: [Internal]

As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)).

Reviewed By: rshest

Differential Revision: D55588908

fbshipit-source-id: 4e502e32e6b43ca1df866ab7ba4653d3cee0ec65
2024-04-02 12:05:06 -07:00
Eric Rozell 1a164fae6a Avoid shared_mutex re-entrancy for setNativeProps_DEPRECATED (#43777)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43777

It's best to avoid mutex reentrancy, even when using "read" locks (i.e., std::shared_lock). Since we already have a read lock on the ShadowTree in `UIManager::setNativeProps_DEPRECATED`, we can avoid the reentrancy by grabbing ancestor node from the shadow tree instead of relying on a recursive call to ShadowTreeRegistry::visit

## Changelog

[GENERAL][FIXED] - Avoid ShadowTreeRegistry::mutex_ read lock reentrancy

Reviewed By: rubennorte

Differential Revision: D55640201

fbshipit-source-id: 7a5c6674d290ea280ab584ae734733f12a65f6f8
2024-04-02 11:55:07 -07:00
Alex Hunt 0b23ff6631 Add capability flag to select rn_fusebox debugger frontend (#43688)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43688

Context: https://github.com/facebookexperimental/rn-chrome-devtools-frontend/pull/34.

Changelog: [Internal]

Reviewed By: EdmondChuiHW

Differential Revision: D55474522

fbshipit-source-id: 4f514dba228bfa4df41a0eb9687f2525cc32b2d7
2024-04-02 10:12:49 -07:00
Pieter De Baets d195fd0c06 Use useDevSupport instead of ReactHostImpl.DEV (#43673)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43673

Changelog: [Android][Changed] In bridgeless, `useDevSupport` now is configurable by ReactNativeHost.

Reviewed By: cortinico

Differential Revision: D55365753

fbshipit-source-id: 691ceb648be30029e753b234038c0997aa59ffd8
2024-04-02 09:39:04 -07:00
Oskar Kwaśniewski 0c02b26c1e fix: remove loadSourceForBridge in RCTRootViewFactory (#43656)
Summary:
This PR removes forward declaration of `loadSourceForBridge` methods from the RCTRootViewFactory as it was causing an issue on old architecture, where the RedBox wouldn't popup when metro wasn't running.

As stated by Kudo [here](https://github.com/reactwg/react-native-releases/issues/177):

> the problem was coming from the implementation
> https://github.com/facebook/react-native/blob/00725fadff28bb3c7fed65f208e647f0dab69e75/packages/react-native/React/CxxBridge/RCTCxxBridge.mm#L519-L540
>
> we should dynamically override loadSourceForBridge:onProgress:onComplete: and loadSourceForBridge:withBlock: in RCTRootViewFactory only when AppDelegate override it. one way to achieve this might be tricky that we may need to override respondsToSelector:.
>
> otherwise, we could just skip the loadSourceForBridge:onProgress:onComplete: and loadSourceForBridge:withBlock: support.

There is no straight forward solution to implement this without some _hacks_ so I'm removing this forward block for now.

## Changelog:

[IOS] [FIXED] - remove loadSourceForBridge in RCTRootViewFactory

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

Test Plan: CI Green

Reviewed By: rshest

Differential Revision: D55485094

Pulled By: cortinico

fbshipit-source-id: 1e391e0795c3d99686f2805165f64a7715b013f6
2024-04-02 06:46:23 -07:00
Ruslan Shestopalyuk c32a053722 Fix broken build due to a land time race
Summary:
With D55574528 and D55623682 having landed concurrently, and the latter enabling warnings-as-errors for Kotlin files vs the former having one such warning, this caused a build breakage.

This diff fixes  it.

Reviewed By: andrewdacenko

Differential Revision: D55636176

fbshipit-source-id: 781b8cf40a4e9aa8a3da3005d26dca975f146c09
2024-04-02 06:40:01 -07:00
Rubén Norte 2f1643dc0c Remove unnecessary wrapper from Performance/PerformanceObserver examples screen in RNTester (#43706)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43706

Changelog: [internal]

Just a small improvement of the UI for the Performance API examples in RNTester.

Reviewed By: christophpurrer

Differential Revision: D55489933

fbshipit-source-id: a1fe4f4962227941827f02cf18a0d4685e18f006
2024-04-02 06:27:05 -07:00
Rubén Norte f9c61f6ecd Remove unnecessary UNDEFINED entry type from PerformanceObserver (#43701)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43701

Changelog: [internal]

We were defining an `UNDEFINED` type of entry that should never happen in practice and we were using unnecessarily to signal "no type" where an optional type would be more suitable. Most importantly, **we were incorrectly allocating a buffer for entries of this type**.

This removes that type and the unnecessary buffer.

Reviewed By: rshest

Differential Revision: D55478890

fbshipit-source-id: 145210a9c4e2614a342f2d913b9eb6b3d62f676f
2024-04-02 06:27:05 -07:00
Rubén Norte 9284fcb97f Use C++20 designated initializers in PerformanceEntryReporter (#43702)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43702

Changelog: [internal]

Just a minor refactor to use C++20 designated initializers in `PerformanceEntryReporter` and its tests, while removing unnecessary initialization for optional fields.

Reviewed By: rshest

Differential Revision: D55477745

fbshipit-source-id: a643adf7ae48df23c5c383420fd4c4dd550e1322
2024-04-02 06:27:05 -07:00
Rubén Norte 20598949c8 Fix measure not using the last reported mark with a given name (#43703)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43703

Changelog: [internal]

(internal because this API isn't available in OSS yet)

I found a bug in the current implementation of `performance.measure` where the API would use the first `mark` reported under a specific name instead of the last one (found it in the new example in RNTester in D55477746 that re-logs the marks every time we click on a button).

The root cause for this problem is that we were using `insert` from `std::unordered_set` to update the value, but `insert` doesn't modify the value if it's already present.

This fixes the issue by doing a lookup and removing the value prior to inserting it.

Reviewed By: rshest

Differential Revision: D55477743

fbshipit-source-id: e72aa784a936828db64b572988fe0acb2ad78214
2024-04-02 06:27:05 -07:00
Rubén Norte 636289c441 Add example of performance.mark and performance.measure in RNTester (#43704)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43704

Changelog: [internal]

Adding examples of the rest of APIs in `Performance`/`PerformanceObserver` starting with marks and measures.

Reviewed By: rshest

Differential Revision: D55477746

fbshipit-source-id: 965796b6a97dc527192093e3c93af837a4d5b714
2024-04-02 06:27:05 -07:00
Rubén Norte fa47c27eae Support dark theme in PerformanceApiExample in RNTester (#43705)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43705

Changelog: [internal]

Reviewed By: rshest

Differential Revision: D55477744

fbshipit-source-id: 6960366330343678e493dd54292bda7df5a61e6a
2024-04-02 06:27:05 -07:00
Alex Hunt 1dea81cc10 Add changelog for 0.74.0-rc.6 (#43762)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43762

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D55635543

fbshipit-source-id: e4470cb72d1fe41e23f26a40bc55bde54e57e9b6
2024-04-02 05:58:40 -07:00
Nick Gerleman 2ba07df426 Update align-content handling of overflow (#43752)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43752

Gentest tests started failing because Chrome changed behavior of overflowed align-content container. Spec says should fallback to "safe center", which is really just "start", instead of previous "center" behavior. This changes behavior accordingly.

There is one bit where I think we are doing the wrong thing wrt alignment of flex start vs start (which we don't support yet), but couldn't repro a failing chrome test.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D55617689

fbshipit-source-id: 08f23d198c75f2c2f51ccaa8795289e6e4a92cb8
2024-04-02 04:47:09 -07:00
Fabrizio Cucci 584e8b90be Kotlinify NoSuchNativeViewException (#43739)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43739

Changelog: [Internal]

As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)).

Reviewed By: rshest

Differential Revision: D55588272

fbshipit-source-id: 6dff095322959e9eada0fc50ca18da870053cc52
2024-04-02 04:38:39 -07:00
Rob Anderson 036ffbc530 convert circleci workflows to github actions for android build and test (#43644)
Summary:
This pull request converts the CircleCI workflows to GitHub actions workflows. This change only inlcudes the android build and test jobs.

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

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

Test Plan:
[Here is the latest workflow run in my fork](https://github.com/robandpdx-org/react-native/actions/runs/8426560047).

 ---
https://fburl.com/workplace/f6mz6tmw

Reviewed By: NickGerleman

Differential Revision: D55417814

Pulled By: cortinico

fbshipit-source-id: 918c6be6fa06bb6605fad6efe21def5fe397f024
2024-04-02 04:04:34 -07:00
Ruslan Shestopalyuk db60eca6d0 Migrate react/devsupport/LogBox*.java to Kotlin (#43730)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43730

# Changelog:
[Internal] -

As in the title, converts corresponding type declarations in `react/devsupport/LogBox*.java` to Kotlin.

Reviewed By: NickGerleman

Differential Revision: D55574528

fbshipit-source-id: 56cf5de75d18cd73929cb7f0c9375a3f62e83574
2024-04-02 03:29:30 -07:00
Nick Gerleman 15a965f0f2 Enable Kotlin warnings as errors in rn_android_library (#43755)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43755

This is another place where the OSS build went ahead of the internal source of truth, which has caused build breaks more than once.

This enables warnings as errors in `rn_android_library` for consistency. This is used for a couple libraries outside of ReactAndroid that might need fixup/suppression.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D55623682

fbshipit-source-id: 37da30c642de2c3d8390334a0d0bff365a4ed7a1
2024-04-02 03:21:55 -07:00
Fabrizio Cucci d6fbc6b241 Kotlinify ViewDefaults (#43738)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43738

Changelog: [Internal]

As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)).

Reviewed By: rshest

Differential Revision: D55584737

fbshipit-source-id: 1b009ac9cc7f7670ee36d705d0439c0743bd5165
2024-04-02 02:47:48 -07:00
Nick Gerleman ac74bd8c64 Fix PixelUtil OSS Build failure (#43754)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43754

Moves off of deprecated `DisplayMetrics.scaledDensity` API to builtin font scaling API, while still clamping to max multiplier using previous logic.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D55623674

fbshipit-source-id: 2668eea8dbd154cc046e2c515323ad66b289dc64
2024-04-02 01:52:39 -07:00
Nick Gerleman 2477fbc600 Back out "fix: prevent error when react extension was already created" (#43753)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43753

New build failures when this was merged seem likely related.

```
FAILURE: Build failed with an exception.

* Where:
Build file '/root/react-native/packages/react-native/ReactAndroid/build.gradle.kts' line: 784

* What went wrong:
Script compilation errors:

  Line 784: react {
            ^ Unresolved reference: react

  Line 787:   libraryName = "rncore"
              ^ Unresolved reference: libraryName

  Line 788:   jsRootDir = file("../src")
              ^ Unresolved reference: jsRootDir
```

Changelog: [Internal]

Reviewed By: arushikesarwani94

Differential Revision: D55618667

fbshipit-source-id: 1a188ba31b013863f3d46a773ff3ebbdd5f696cb
2024-04-01 19:50:33 -07:00
Ruslan Shestopalyuk 08f57473cc Convert react/uimanager/*Util.java -> Kotlin (#43729)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43729

# Changelog:
[Internal] -

As in the title, converts corresponding type declarations in `react/uimanager/*Util.kt` to Kotlin.

Reviewed By: tdn120

Differential Revision: D55574531

fbshipit-source-id: 974234bd57c77e863aa723388e48ffc455e73a96
2024-04-01 16:17:13 -07:00
Ruslan Shestopalyuk 287b5d697f LayoutAnimation types to Kotlin (#43728)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43728

# Changelog:
[Internal] -

As in the title, converts corresponding type declarations in `react/uimanager/layoutanimation/*Type.kt` to Kotlin.

Differential Revision: D55574530

fbshipit-source-id: 8527b5c9b491435c60ed9c05092ffeccd7552f9c
2024-04-01 12:37:48 -07:00
Ruslan Shestopalyuk 1e44cbe9f4 Migrate ErrorType.java to Kotlin (#43727)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43727

# Changelog:
[Internal] -

As in the title, converts this one particular Java file to Kotlin.

Reviewed By: arushikesarwani94

Differential Revision: D55574526

fbshipit-source-id: 04af5b870670a5560eaba7ab8c029c580032d09a
2024-04-01 12:37:48 -07:00
Tommy Nguyen 489d9f6c62 fix: version checker not considering nightlies (#43712)
Summary:
Fix version checker not considering nightlies:

```
  WARNING: You should run npx react-native@latest to ensure you're always using the most current version of the CLI. NPX
 has cached version (0.74.0-nightly-20240214-b8ad91732) != current release (0.73.6)
```

## Changelog:

[GENERAL] [FIXED] - Fix version checker not considering nightlies

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

Test Plan: On a recent nightly version, run any cli command.

Reviewed By: rshest

Differential Revision: D55525055

Pulled By: zeyap

fbshipit-source-id: 6dd08e30e542d9ddd191bf95c968a26c0cc14e4e
2024-04-01 12:37:05 -07:00
Alexander Eggers b9dad7fc0c fix: prevent error when react extension was already created (#43694)
Summary:
Currently the react-native-gradle-plugin does not allow the "react" plugin extension to already exist when running its apply block. I had a use-case where I wanted to create a new gradle plugin which would take care of applying the react plugin including setting some of its options. Without the change in this PR, this would currently turn into a build failure.

## Changelog:

[ANDROID] [FIXED] - prevent error when the "react" extension was already created by another gradle plugin

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

Reviewed By: rshest

Differential Revision: D55478611

Pulled By: zeyap

fbshipit-source-id: cc743a99cb72ed315d21c52597efd5ee92a3be62
2024-04-01 11:31:53 -07:00
Ruslan Shestopalyuk 220588004b ImageResizeMethod/Mode to Kotlin (#43725)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43725

## Changelog:
[Internal] -

Converts `react/views/image/ImageResizeMethod.java` and `react/views/image/ImageResizeMode.java` to Kotlin.

Grouped together, as it kind of makes sense.

Reviewed By: fabriziocucci

Differential Revision: D55574319

fbshipit-source-id: 5fb47425e1eb0fca1e06527e16e994d659a749a8
2024-03-31 16:14:53 -07:00
Rob Hogan 8769378e0d Delete unused RCT_ENABLE_LOADING_FROM_PACKAGER (#43677)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43677

Remove `RCT_ENABLE_LOADING_FROM_PACKAGER` from `RCTDefines`, as it is not referenced anywhere and does nothing.

Changelog: [Internal]

Reviewed By: hoxyq, realsoelynn

Differential Revision: D55421282

fbshipit-source-id: ae29a8a421a6cc23d863b489eae2175392f684cd
2024-03-31 08:46:03 -07:00
Ramanpreet Nara fa4bfde630 Revert D55505416: Pull react instance method impls out of ReactContext
Differential Revision:
D55505416

Original commit changeset: ce1e3ab379eb

Original Phabricator Diff: D55505416

fbshipit-source-id: ae988ae3464f40923521922d4c3ac4a57846a3ef
2024-03-31 06:10:45 -07:00
Ramanpreet Nara 14fb1cc335 Pull react instance method impls out of ReactContext
Summary:
## Context
Prior, ReactContext used to implement bridge logic.

For bridgeless mode, we created BridgelessReactContext < ReactContext

## Problem

This could lead to failures: we could call bridge methods in bridgeless mode.

## Changes
Primary change:
- Make all the react instance methods inside ReactContext abstract.

Secondary changes: Implement react instance methods in concrete subclasses:
- **New:** BridgeReactContext: By delegating to CatalystInstance
- **New:** ThemedReactContext: By delegating to inner ReactContext
- **Unchanged:** BridgelessReactContext: By delegating to ReactHost

## Auxiliary changes
This fixes ThemedReactContext in bridgeless mode.

**Problem:** Prior, ThemedReactContext's react instance methods did not work in bridgeless mode: ThemedReactContext wasn't initialized in bridgeless mode, so all those methods had undefined behaviour.

**Solution:** ThemedReactContext now implements all react instance methods, by just forwarding to the initialized ReactContext it decorates (which has an instance).

Changelog: [Android][Removed] Delete ReactContext.initializeWithInstance(). ReactContext now no longer contains legacy react instance methods. Please use BridgeReactInstance instead.

 ---

Reviewed By: fkgozali

Differential Revision: D55505416

fbshipit-source-id: ce1e3ab379eb788d26130dd44a66544aada3db02
2024-03-30 16:53:30 -07:00
Rob Hogan e05319cc87 Inspector proxy: catch and report errors in device message handling (#43697)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43697

Currently, messages from a device are handled by async handlers added to a promise chain.

If a handler rejects, the end of the chain becomes a rejected promise, picked up only asynchronously by Metro's global `unhandledRejection` handler.

This triggers a warning from Node.js, and worse, prevents any `then()` callback chained by subsequent messages from being invoked at all.

Handlers *should* attempt to gracefully deal with errors (as we do with source map fetching errors, for example), but this diff adds a catch-all fallback for anything we might've missed (in this case, a frontend socket disconnecting while we're busy fetching a source map). Errors are caught and logged to EventReporter.

**To follow**: Gracefully handle socket disconnections while an async handler is working or queued.

Changelog:
[General][Fixed] Inspector proxy: prevent errors proxying a device message from blocking the handler queue or spamming logs.

Reviewed By: EdmondChuiHW

Differential Revision: D55482735

fbshipit-source-id: bb726218495e105f9cb4f723a1d110c9815abdef
2024-03-30 15:29:47 -07:00
Christoph Purrer 04bf8cfb23 Clean up old Cxx TM member generation (#43710)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43710

As we had already cut a branch for RN 0.74
https://github.com/facebook/react-native/releases/tag/v0.74.0-rc.1

We can delete this code already

Changelog: [Internal]

Reviewed By: shwanton

Differential Revision: D55511382

fbshipit-source-id: 3ef15af338b5ad31b02e0a1eed7ac873566d9562
2024-03-29 14:39:24 -07:00
Alex Taylor (alta) 1b4a0cd9f2 Use hook syntax for builtin React hooks in xplat (1/2) (#43714)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43714

Migrate React builtin hooks to use the new React "hook" type. This diff converts all builtin hooks except for `useContext` which will be updated after the next flow release.

Details:
- Announcement: https://fb.workplace.com/groups/react.fyi/posts/7642294409114198
- Docs: https://www.internalfb.com/intern/wiki/Component_Syntax_Documentation/Hook_syntax_0/
- Support group: https://fb.workplace.com/groups/749069370011855

Changelog: [internal]

Reviewed By: SamChou19815

Differential Revision: D55500989

fbshipit-source-id: 8a13898b1d2e851dfc2afed3b41e0f1a6332b6bd
2024-03-29 14:24:01 -07:00
Nick Gerleman 3f88821167 Avoid TextInput example styles causing non-deterministic rendering on iOS (#43599)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43599

iOS E2E tests non-deterministic rendering happens around examples with a border set to `StyleSheet.hairlineWidth`. That value has special subpixel math, that doesn't seem to render consistently on iOS (this is its own bug).

To unblock adding some new E2E iOS TextInput tests, this removes usage of `hairlineWidth` in styles, and more generally, tries to unify TextInput styles in the examples.

This will break a whole bunch of RNTester Jest E2E baselines on different apps, which I will update from land-time runs or after continuous builds are available for different endpoints.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D55213090

fbshipit-source-id: 6d81b9355adc538a3ade6f50ef93c3ca08782ae7
2024-03-29 02:41:26 -07:00
sebmarkbage 78d6873b04 Don't Rethrow Errors at the Root (#28627)
Summary:
Stacked on top of #28498 for test fixes.

### Don't Rethrow

When we started React it was 1:1 setState calls a series of renders and
if they error, it errors where the setState was called. Simple. However,
then batching came and the error actually got thrown somewhere else.
With concurrent mode, it's not even possible to get setState itself to
throw anymore.

In fact, all APIs that can rethrow out of React are executed either at
the root of the scheduler or inside a DOM event handler.
If you throw inside a React.startTransition callback that's sync, then
that will bubble out of the startTransition but if you throw inside an
async callback or a useTransition we now need to handle it at the hook
site. So in 19 we need to make all React.startTransition swallow the
error (and report them to reportError).

The only one remaining that can throw is flushSync but it doesn't really
make sense for it to throw at the callsite neither because batching.
Just because something rendered in this flush doesn't mean it was
rendered due to what was just scheduled and doesn't mean that it should
abort any of the remaining code afterwards. setState is fire and forget.
It's send an instruction elsewhere, it's not part of the current
imperative code.

Error boundaries never rethrow. Since you should really always have
error boundaries, most of the time, it wouldn't rethrow anyway.

Rethrowing also actually currently drops errors on the floor since we
can only rethrow the first error, so to avoid that we'd need to call
reportError anyway. This happens in RN events.

The other issue with rethrowing is that it logs an extra console.error.
Since we're not sure that user code will actually log it anywhere we
still log it too just like we do with errors inside error boundaries
which leads all of these to log twice.
The goal of this PR is to never rethrow out of React instead, errors
outside of error boundaries get logged to reportError. Event system
errors too.

### Breaking Changes

The main thing this affects is testing where you want to inspect the
errors thrown. To make it easier to port, if you're inside `act` we
track the error into act in an aggregate error and then rethrow it at
the root of `act`. Unlike before though, if you flush synchronously
inside of act it'll still continue until the end of act before
rethrowing.

I expect most user code breakages would be to migrate from `flushSync`
to `act` if you assert on throwing.

However, in the React repo we also have `internalAct` and the
`waitForThrow` helpers. Since these have to use public production
implementations we track these using the global onerror or process
uncaughtException. Unlike regular act, includes both event handler
errors and onRecoverableError by default too. Not just render/commit
errors. So I had to account for that in our tests.

We restore logging an extra log for uncaught errors after the main log
with the component stack in it. We use `console.warn`. This is not yet
ignorable if you preventDefault to the main error event. To avoid
confusion if you don't end up logging the error to console I just added
`An error occurred`.

### Polyfill

All browsers we support really supports `reportError` but not all test
and server environments do, so I implemented a polyfill for browser and
node in `shared/reportGlobalError`. I don't love that this is included
in all builds and gets duplicated into isomorphic even though it's not
actually needed in production. Maybe in the future we can require a
polyfill for this.

### Follow Ups

In a follow up, I'll make caught vs uncaught error handling be
configurable too.

---------

DiffTrain build for commit https://github.com/facebook/react/commit/6786563f3cbbc9b16d5a8187207b5bd904386e53.

Changelog:
[Internal]

Reviewed By: kassens

Differential Revision: D55408481

Pulled By: yungsters

fbshipit-source-id: 598aa306369e21cb3e93ad6041a87bfbaa9eef9e

Co-authored-by: Ricky Hanlon <rickhanlonii@gmail.com>
2024-03-29 01:42:24 -07:00
Tim Yung e175912e7d RN: Fix Open Source Test Scripts
Summary:
Changelog:
[Internal]

Reviewed By: NickGerleman

Differential Revision: D55502889

fbshipit-source-id: aabba96bd816982f7bce9cbd752ba9eee409bbf6
2024-03-29 01:42:24 -07:00
TatianaKapos d0cac87c6e Fix [Windows]: Rename utils/jsi files (#43700)
Summary:
This PR: https://github.com/facebook/react-native/pull/42801/files#diff-ff466c93fb60f2b0e79ed187f492c9935349a2b2f2a7300b310e2bb30e31c33e creates a new jsi.h and jsi.cpp file in ReactCommon. On windows, even though the files have different paths, MSVC doesn't allow two files to have the same name in the same project. This PR changes the name of the new jsi.h and jsi.cpp files.

## Changelog:

[General][Fixed] - Rename utils/jsi files

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

Test Plan: tested on windows

Reviewed By: zeyap

Differential Revision: D55491700

Pulled By: arushikesarwani94

fbshipit-source-id: 2995c0602a9528ed0f8e8eb2230945cb6bd516e9
2024-03-28 20:03:38 -07:00
Viresh Umbre f7ec4694a6 Revert D53145010: Pull react instance method impls out of ReactContext
Differential Revision:
D53145010

Original commit changeset: 2405bc24afb0

Original Phabricator Diff: D53145010

fbshipit-source-id: 2d37cef8f6b6810f9b114ea633373668bcc805dc
2024-03-28 16:14:07 -07:00
Fabrizio Bertoglio f6badca2f9 Fix Multiline TextInput with a fixed height scrolls to the bottom when prepending new lines to the text (#38679)
Summary:
### Please re-state the problem that we are trying to solve in this issue.

Multiline TextInput with a fixed height will scroll to the bottom of the screen when prepending new lines to the text.

### What is the root cause of that problem?

The issue is caused by iOS UITextView:
- The cursor moves to the end of the text when prepending new lines.
- Moving the cursor to the end of the text triggers the scroll to the bottom.

The behavior was reproduced on an iOS App (without react-native).
The example included below implements a Component RCTUITextView based on UITextView, which modifies the UITextView attributedText with the textViewDidChange callback (source code available in this [comment](https://github.com/Expensify/App/issues/19507#issuecomment-1595730348)).

Adding a new line on top of the UITextView on iOS results in:
Issue 1) The cursor moves to the end of TextInput text
Issue 2) The TextInput scrolls to the bottom

<details><summary>Reproducing the issue on an iOS App without react-native</summary>
<p>

<video src="https://user-images.githubusercontent.com/24992535/246601549-99f480f3-ce80-4678-9378-f71c8aa67e17.mp4" width="900" />

</p>
</details>

Issue 1) is already fixed in react-native, which restores the previous cursor position (on Fabric with  [_setAttributedString](https://github.com/fabriziobertoglio1987/react-native/blob/71e7bbbc2cf21abacf7009e300f5bba737e20d17/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm#L600-L610)) after changing the text.
Issue 2) needs to be fixed in react-native.

### What changes do you think we should make in order to solve the problem?

Setting the correct TextInput scroll position after re-setting the cursor.

## Changelog:

[IOS] [FIXED] - Fix Multiline TextInput with a fixed height scrolls to the bottom when changing AttributedText

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

Test Plan:
Fabric (reproduces on controlled/not controlled TextInput example):

| Before    | After |
| ----------- | ----------- |
| <video src="https://github.com/facebook/react-native/assets/24992535/e06b31fe-407d-4897-b608-73e0cc0f224a" width="350" />      | <video src="https://github.com/facebook/react-native/assets/24992535/fa2eaa31-c616-43c5-9596-f84e7b70d80a" width="350" />       |

Paper (reproduces only on controlled TextInput example):

```javascript
function TextInputExample() {
  const [text, setText] = React.useState('');

  return (
    <View style={{marginTop: 200}}>
      <TextInput
        style={{height: 50, backgroundColor: 'white'}}
        multiline={true}
        value={text}
        onChangeText={text => {
          setText(text);
        }}
      />
    </View>
  );
}
```

| Before    | After |
| ----------- | ----------- |
| <video src="https://github.com/facebook/react-native/assets/24992535/6cb1f2de-717e-4dce-be0a-644f6a051c08" width="350" />      | <video src="https://github.com/facebook/react-native/assets/24992535/dee6edb6-76c6-48b0-b78f-99626235d30e" width="350" />       |

Reviewed By: sammy-SC, cipolleschi

Differential Revision: D48674090

Pulled By: NickGerleman

fbshipit-source-id: 349e7b0910e314ec94b45b68c38571fed41ef117
2024-03-28 16:05:06 -07:00
Rob Hogan fd1e5e7063 Inspector proxy: Fix "Buffer() is deprecated" warning (#43686)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43686

Under Node 20, the use of `new Buffer(string)` is deprecated and logs a warning. This replaces it with the recommended `Buffer.from(string)`.

Changelog:
[General][Fixed] FIx "Buffer() is deprecated" warning from debugger proxy.

Reviewed By: huntie

Differential Revision: D55472025

fbshipit-source-id: 8b5af9e2d7e026cbdf6aa68f71ff0f856fb164db
2024-03-28 15:17:02 -07:00
Samuel Susla 164815a03b return correct isAccessibilityElement from RCTViewComponentView (#43698)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43698

changelog: [internal]

RCTViewComponentView was missing isAccessibilityElement override. Here I add it and use contentView to determine if element is accessible.

Reviewed By: rubennorte

Differential Revision: D55483944

fbshipit-source-id: f29c82a42d17140ae421f27871a3bf6f7f36bc12
2024-03-28 15:13:48 -07:00
Ramanpreet Nara f99dc486cd Pull react instance method impls out of ReactContext
Summary:
## Context
Prior, ReactContext used to implement bridge logic.

For bridgeless mode, we created BridgelessReactContext < ReactContext

## Problem

This could lead to failures: we could call bridge methods in bridgeless mode.

## Changes
Primary change:
- Make all the react instance methods inside ReactContext abstract.

Secondary changes: Implement react instance methods in concrete subclasses:
- **New:** BridgeReactContext: By delegating to CatalystInstance
- **New:** ThemedReactContext: By delegating to inner ReactContext
- **Unchanged:** BridgelessReactContext: By delegating to ReactHost

## Auxiliary changes
This fixes ThemedReactContext in bridgeless mode.

**Problem:** Prior, ThemedReactContext's react instance methods did not work in bridgeless mode: ThemedReactContext wasn't initialized in bridgeless mode, so all those methods had undefined behaviour.

**Solution:** ThemedReactContext now implements all react instance methods, by just forwarding to the initialized ReactContext it decorates (which has an instance).

Changelog: [Android][Removed] Delete ReactContext.initializeWithInstance(). ReactContext now no longer contains legacy react instance methods. Please use BridgeReactInstance instead.

Reviewed By: javache

Differential Revision: D53145010

fbshipit-source-id: 2405bc24afb00864117d3c504fc9c4cbffd7203a
2024-03-28 14:31:51 -07:00
Nicola Corti 5ceb92801e Flip explicitApi to True for everyone (#43696)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43696

This just sets explicitApi to true for every module inside ReactAndroid

Changelog:
[Internal] [Changed] - Flip explicitApi to True for everyone

Reviewed By: tdn120

Differential Revision: D55478674

fbshipit-source-id: c9aeba89ad5b0f88bca7fd480c6aa66e0152a456
2024-03-28 14:22:28 -07:00
Dmitry Rykun 95a881b80c Set HERMES_RELEASE_VERSION correctly (#43699)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43699

This diff initializes `RELEASE_VERSION` with the value that is provided by the `get_react_native_version` job (it stores its output into `/tmp/react-native-version`).

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D55484988

fbshipit-source-id: f0b5bb473096f3691f50152beb3181a454916fdc
2024-03-28 14:17:31 -07:00