Commit Graph

12270 Commits

Author SHA1 Message Date
Soe Lynn 0c6fd0a86b Implement Percentage support for gap styles (#44067)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44067

X-link: https://github.com/facebook/litho/pull/980

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

Changelog [Internal]:
- Added percentage value for flex layout gap
- Wired up to pass proper available width and height to implement this feature

Reviewed By: NickGerleman

Differential Revision: D56002340

fbshipit-source-id: c0bc86ac70a1391f115c87da99c2ef411535f68b
2024-04-15 16:44:16 -07:00
Nick Gerleman d1e8328f7e Add QualifierAlignment to Clang Format Config (#44098)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44098

This sets `QualiferAlignment` so that code is automatically formatted to west const.

I did a pass at this before, but now that we are on new Clang Format, we can enforce it automatically, and I think a couple more cases not previously changed now are.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D56143678

fbshipit-source-id: 8f12b288476ea6019fd7d7a93a39b4fe2e75af14
2024-04-15 16:03:26 -07:00
Andrew Datsenko d53a2bd4a2 //xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast:toastAndroid (#44100)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44100

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D56138594

fbshipit-source-id: a3010e4d99e5ba9948c7214d546461cbbf959851
2024-04-15 14:09:52 -07:00
Ruslan Lesiutin e7154bdd9b upgrade[react-devtools]: v5.1.0 (#44093)
Summary:
X-link: https://github.com/facebook/flipper/pull/5575

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

# Changelog: [Internal]

Bump `react-devtools-*` packages to 5.1.0.

allow-large-files

Reviewed By: motiz88

Differential Revision: D56141042

fbshipit-source-id: 33ae0351dd1db21002d6323addd51ad98d86e3c3
2024-04-15 13:30:07 -07:00
Pieter De Baets 5e7f74d3a2 Support more stubbed methods in BridgelessCatalystInstance (#44091)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44091

These can be stubbed easily using existing ReactHostImpl/ReactInstance API's

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D56139806

fbshipit-source-id: cefabe3aa0fb6556f8e296243ff233df07ddffee
2024-04-15 12:46:50 -07:00
Riccardo Cipolleschi 6dd83cbb35 Backport fix for Ccache from 0.74 to main (#44089)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44089

While doing the release of 0.74.0-RC.9, we encountered some failures while building because the committed project had some new flags that have been added by cocoapods and that required Ccache.

However, Ccache is not a hard requirement to run React Native and the build started failing on systems that does not have ccache installed.
That happened because we were missing the piece of code that removed Ccache from the project in case the tool is not installed in the system.

We already committed such commit in the stable branch of 0.74, with [this commit](https://github.com/facebook/react-native/commit/2b18fdf8063b423a0fb5762f2c6044244b4c35e6). This change will port the same fix in main.

## Changelog
[iOS][Fixed] - Make sure to remove ccache scripts when ccache is not installed

Reviewed By: cortinico

Differential Revision: D56140015

fbshipit-source-id: 24e7ebb4e5c08766b29705e8b6f03c3f164a96ab
2024-04-15 10:11:03 -07:00
Rob Hogan 704756352c Inspector proxy: Add ping/pong keepalive/heartbeat to debugger connection (#44086)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44086

When a debugger frontend is connected to inspector-proxy via another proxy or tunnel that times out on idle (such as [VS Code's remote tunnel](https://github.com/microsoft/vscode/blob/main/src/vs/platform/tunnel/node/tunnelService.ts)), the connection between proxy and debugger may be dropped.

In addition, when the connection is dropped without a closing handshake, the proxy does *not* detect the disconnection - no disconnect is logged to the reporter and no notifications are sent to any connected devices.

This adds a mechanism using the WebSocket-standard `ping` and `pong` frames to:
1. Keep the connection alive
2. Detect when the debugger has gone away

Note that as all WebSocket clients already **must** reply to a ping with a pong, this is non-breaking for compliant implementations: https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.2

Changelog:
[General][Added] Inspector proxy: Add ping/pong keepalive to debugger connections.

Reviewed By: hoxyq

Differential Revision: D56069185

fbshipit-source-id: e322de631c652a502f3d554c15ed5412a751ee04
2024-04-15 08:55:05 -07:00
Nicola Corti 718041a9e4 ReactFeatureFlags.mFabricEnabled should default to ReactFeatureFlags.enableFabricRenderer (#44087)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44087

The `mFabricEnabled` field is initialized to false. This is a misalignment with how other classes are behaving like
ReactActivityDelegate.

Changelog:
[Internal] [Changed] - ReactFeatureFlags.mFabricEnabled should default to ReactFeatureFlags.enableFabricRenderer

Reviewed By: arushikesarwani94

Differential Revision: D56013057

fbshipit-source-id: fcab903ab42d3b30094dcebbcf5b662cd2f2c506
2024-04-15 07:51:50 -07:00
Nicola Corti 5d538ec105 Clarify documentation for debuggableVariants (#44040)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44040

This is just a clarification for the KDoc of this property.

Changelog:
[Internal] [Changed] - Clarify documentation for debuggableVariants

Reviewed By: andrewdacenko

Differential Revision: D56012825

fbshipit-source-id: 837d2dbc0f7ca5853ba1cedf71a4a5c36661318f
2024-04-15 06:54:33 -07:00
Andres Suarez a5eeea814d Apply clang-format 18
Summary: Previously this code conformed from clang-format 12.

Reviewed By: igorsugak

Differential Revision: D56065247

fbshipit-source-id: f5a985dd8f8b84f2f9e1818b3719b43c5a1b05b3
2024-04-14 11:28:32 -07:00
Nick Gerleman 314a919df6 Introduce "BoxShadowDrawable" for Android box shadows (#43722)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43722

This change adds a drawable, when when drawn on the bounds of a border-box sized view, will draw a spec compliant box-shadow outside the box. This is reliant on Android `RenderNode` and `RenderEffect` APIs provided by API 31.

Inset box shadows can also be added using a similar method, but this is not done yet.

The code which manages this is in flux, but the underlying drawable should be good. Will add some tests once it's more wired up.

Changelog: [Internal]

Reviewed By: javache, cortinico

Differential Revision: D55561465

fbshipit-source-id: 6180568cff2779b826e73bb9184dbe042863b262
2024-04-13 15:34:12 -07:00
Nick Gerleman c710386e72 Encapsulate border radius resolution logic (#43983)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43983

We duplicate some pretty hairy code related to conversion between logical and physical edges, along with the grafting between uniform and non uniform radii. This encapsulates border radius resolution/assignment logic.

Changelog: [Internal]

Reviewed By: alanleedev

Differential Revision: D55635743

fbshipit-source-id: 906c35af2bf18f0586d71d05f9cf61d4248ede1e
2024-04-13 15:34:12 -07:00
Nick Gerleman efc5ddd3ee Allow sigma blur without filter prop (#43721)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43721

Makes some changes to `FilterHelper` to expose RenderEffects for filters publicly to other classes in the module. We use this in box-shadow, in order to reuse logic for sigma accepting blur filters.

Also fixes a crash related to the conversions back and forward between sigma and radius, where small values would cause a crash.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D55563775

fbshipit-source-id: fabc888eecb451e75a88c8633fe5cca1f6644faa
2024-04-13 15:34:12 -07:00
Nick Gerleman d7766fa927 Move background drawing code from "react/views/view" to "react/uimanager/drawable" (#43720)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43720

This lets us use BG drawing code in rules which view depends on. I also removed some lib usage.

The original class is still present, subclassing the class in its new location, but is marked deprecated.

Next diffs in stack clean up some of our own now deprecated usage.

Changelog:
[Android][Breaking] - Deprecate `ReactViewBackgroundDrawable` in favor of `CSSBackgroundDrawable`

Reviewed By: javache

Differential Revision: D55565035

fbshipit-source-id: 501b3e2f674c09a88b1825657ba6349823054e8c
2024-04-13 15:34:12 -07:00
Arushi Kesarwani b72f5e9982 Implement getJavaScriptContextHolder for BridgelessCatalystInstance (#44054)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44054

Implement `getJavaScriptContextHolder()` for BridgelessCatalystInstance

Changelog:
[Android][Breaking] Implement `getJavaScriptContextHolder()` for Bridgeless Catalyst Instance

Reviewed By: christophpurrer

Differential Revision: D56046452

fbshipit-source-id: b7fed1da3064608d8ef5fa84f4e53a4f7a84cba7
2024-04-12 12:55:05 -07:00
Arushi Kesarwani 6a5aaad9e0 Implement getRuntimeExecutor for BridgelessCatalystInstance (#44053)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44053

Implement `getRuntimeExecutor()` for BridgelessCatalystInstance

Changelog:
[Android][Breaking] Implement `getRuntimeExecutor()` for Bridgeless Catalyst Instance

Reviewed By: christophpurrer

Differential Revision: D56046398

fbshipit-source-id: b9f947cf6f83ce7c1d334558a11b76fccab45dbd
2024-04-12 12:35:43 -07:00
Riccardo Cipolleschi 18916f391a Fix Open Debugger dev menu item missing from iOS Bridgeless
Summary:
After a [recent change](https://github.com/facebook/react-native/commit/90296be1d4fab09a52e02dd09f34f819136d0a07) we break part of the integration with the debug menu, which is was using the presence/absence of the bridge to decide whether we were in bridge or bridgeless.

For backward compatibility reasosn, the bridge ivar is now populated with the bridgeProxy, so just checking whether is nil or not is not enough to verify whether we are in bridge or in bridgeless mode anymore.

## Changelog:
[iOS][Fixed] - Make sure that the Open Debugger appears in bridgeless mode

Reviewed By: fkgozali

Differential Revision: D56067897

fbshipit-source-id: e2501ed730ff35bc755c24ef400130c551032e28
2024-04-12 11:37:41 -07:00
zhongwuzw 776f90024f Change bridgeless check in dev menu (#43976)
Summary:
We would set the value of  _bridge ivar to bridgeProxy for turbo module in bridgeless mode in https://github.com/facebook/react-native/issues/43757 , so we need to change the way of bridgeless/bridge check.

## Changelog:

[IOS] [FIXED] - Change bridgeless check in dev menu

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

Test Plan: Dev menu shows bridgeless/bridge mode correctly.

Reviewed By: christophpurrer

Differential Revision: D56056640

Pulled By: cipolleschi

fbshipit-source-id: 1358c3027c1d5f12c70dd4486cc1d5975c7a185a
2024-04-12 09:56:16 -07:00
Ruslan Shestopalyuk 214a1e0722 Kotlinify DevSupportManager interface (#44056)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44056

## Changelog:
[Internal] -

Was looking into how devsupport is exactly implemented on different platforms (in the context of doing it for a new platform) and figured I may just well convert this to Koltin in the process (helped to understand inner working details as well).

Reviewed By: christophpurrer

Differential Revision: D56058560

fbshipit-source-id: 1e2ffcec480c5fa3fd8b6494c29a0db6f94aec78
2024-04-12 09:40:31 -07:00
Ruslan Shestopalyuk b15d438498 Convert interfaces inside devsupport/interfaces to Kotlin (#44055)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44055

## Changelog:
[Internal] -

Was looking into how devsupport is exactly implemented on different platforms (in the context of doing it for a new platform) and figured I may just well convert this to Koltin in the process (helped to understand inner working details as well).

Reviewed By: christophpurrer

Differential Revision: D56052137

fbshipit-source-id: 25280a57f46bec95dc1437ea6eb2eef08332797f
2024-04-12 09:40:31 -07:00
Andrew Datsenko a666718879 Make OverrideColorScheme fun interface (#44059)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44059

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D56062919

fbshipit-source-id: 3181608ae6be5250831ce2d2f22ab2a424409168
2024-04-12 09:26:30 -07:00
Ruslan Shestopalyuk 72a78d674c Fix unsafe downcasting in ShadowTree::emitLayoutEvents (#44058)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44058

## Changelog:
[Internal] -

This was revealed when running an ASAN build on MacOS - we were doing an unsafe downcast from `LayoutableShadowNode->ViewShadowNode` inside `ShadowTree::emitLayoutEvents`.

Which, even though incidentally worked, is generally unsafe, as we may get e.g. `ImageShadowNode` there, which doesn't inherit from `ViewShadowNode`.

That downcast to `ViewShadowNode` wasn't even required, to begin with, as all the needed information can be already extracted from the `LayoutableShadowNode` itself.

Reviewed By: christophpurrer, javache

Differential Revision: D56062334

fbshipit-source-id: 08d5b3f5e0c57dc51b051d23506c7933581fea29
2024-04-12 09:21:15 -07:00
Oskar Kwaśniewski 5aea518d88 feat: allow use of RCTRootViewFactory from Swift (#43590)
Summary:
The goal of this PR is to allow the usage of `RCTRootViewFactory` from Swift. The issue with `RCTTurboModuleManager.h` is that it uses C++ in its header file, which is not allowed in Swift, making this initializer unavailable.

This PR allows users to just pass configuration + adds a nullable annotation to bundleURL.

Example usage:

```swift
import Foundation
import UIKit
import React
import React_RCTAppDelegate

main
class AppDelegate: NSObject, UIApplicationDelegate {
  var window: UIWindow?
  private var rootViewFactory: RCTRootViewFactory?

  func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
  ) -> Bool {

    // Create config
    let config = RCTRootViewFactoryConfiguration(
      bundleURL: self.bundleURL(),
      newArchEnabled: true,
      turboModuleEnabled: true,
      bridgelessEnabled: false
    )

    // Create rootview factory
    rootViewFactory = RCTRootViewFactory(configuration: config)

    // Create rootview
    let rootView = rootViewFactory?.view(withModuleName: "RN0740RC4")
    let rootViewController = UIViewController()
    rootViewController.view = rootView

    // Create window and assign view controller
    window = UIWindow(frame: UIScreen.main.bounds)
    window?.rootViewController = rootViewController;
    window?.makeKeyAndVisible()

    return true
  }

  func bundleURL() -> URL? {
    RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
  }
}
```

## Changelog:

[IOS] [FIXED] - Allow usage of `RCTRootViewFactory` from Swift

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

Test Plan: CI Green, check usage of initializer without turbo module delegate

Reviewed By: christophpurrer

Differential Revision: D56055938

Pulled By: cipolleschi

fbshipit-source-id: c80d9f7f707c376f590f3dc4c9bb8f88f2e57e6a
2024-04-12 09:20:47 -07:00
Riccardo Cipolleschi 18f0a90358 Properly recycle RCTPullToRefreshViewcomponentView (#44047)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44047

This change properly recycles the RCTPullToRefreshViewComponentView so that it fixes some misbehaviors of the UIRefreshControl in OSS.

This should fix https://github.com/facebook/react-native/issues/37308 and https://github.com/facebook/react-native/issues/36173

## Changelog:
[iOS][Fixed] - Properly recycle the RCTPullToRefreshViewComponentView

Reviewed By: sammy-SC

Differential Revision: D56018924

fbshipit-source-id: 3c71328aa0f6fb2a98a19593f0f06419e04e9cae
2024-04-12 08:08:19 -07:00
Fabrizio Cucci 7131f94895 Revert D55964787: Push ReactContext logic in derived classes
Differential Revision:
D55964787

Original commit changeset: b404efe0c709

Original Phabricator Diff: D55964787

fbshipit-source-id: 0742b9aa870a08fed603cf6f33774d4813f5050c
2024-04-12 06:11:04 -07:00
Dmitry Rykun b7812a8b6c Fix race condition in native module invalidation (#44048)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44048

This is an attempt to fix a couple of similar memory corruption crashes that happen during the deallocation of RCTHost.

**Hypotheis:** there is a race condition between [this](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm#L1038-L1058) and [this](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm#L1062) chunks of work.
I.e. let's say we are invalidating 10 modules. Because of the race condition it is possible that we call `dispatch_group_enter`/`dispatch_group_leave` for the first five before we call `dispatch_group_enter` for the sixth one. In that case we would resume at [dispatch_group_wait](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm#L1079), not waiting for the remaining modules to invalidate. That would lead to `RCTInstance` potentially being invalidated prematurely, deallocating all its ivars including `_turboModuleManager` and `_jsThreadManager`. That in turn would lead to memory access error during the invalidation of remaining modules.

This diff is trying to solve this problem by calling `dispatch_group_enter` for all modules before any other work is performed.

Changelog: [iOS][Fixed] - Fixed race condition in native module invalidation.

Reviewed By: cipolleschi

Differential Revision: D55965290

fbshipit-source-id: 0c2b5957371bf3573155cee687c661603da162de
2024-04-12 03:17:12 -07:00
Moti Zilberman 91d3bc5be6 Update CDPAgent reentrancy test to cover evaluate ordering
Summary:
Changelog: [Internal]

With the Hermes fix in D55250610, we're able to make stronger assertions in `CDPAgentReentrancyRegressionTest`, which is an integration test covering a class of related bugs.

bypass-github-export-checks

Reviewed By: mattbfb

Differential Revision: D55962593

fbshipit-source-id: 09d03effc51d6f1904842f1c7c2f7e4407fefc63
2024-04-12 03:10:16 -07:00
Samuel Susla 2ef59c988d move to unified feature flag system for new state reconciliation algorithm (#44022)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44022

changelog: [internal]

move the new state reconciliation algorithm to the unified feature flag system.

Reviewed By: rubennorte

Differential Revision: D55965530

fbshipit-source-id: 3edde0858a670e86dc2d1cb561f03f584ff21896
2024-04-12 02:47:01 -07:00
Samuel Susla 4d9b11b45d Introduce new State Alignment Mechanism (#44021)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44021

changelog: [internal]

This is an evolution of cloneless state progression, introduced in D49012353.

# Problem

## When React clones the wrong node revision
Whenever React wants to commit a new change, it first needs to clone shadow nodes. React sometimes clones from the wrong revision. This has mostly been fine, Fabric does state reconciliation to pass newest state forward. State reconciliation is needed, as we need to keep native state in the shadow tree.
However, when React clones a node that has never been through layout step, it will clone a node without any layout information and its yoga node is dirtied. Even though there might be a subsequent revision of the node with layout information already calculated. As a result, Yoga needs to traverse bigger parts of the tree, even though layout has been calculated before. It is just cached on a different revision that was used as a source.

There are two main sources (there is more but they don't help to paint the picture) when this can happen. Background Executor and State Progression. Let's start with the simpler one but less severe: Background Executor.

Background Executor moves layout from JavaScript thread. React can start cloning nodes right away, even though they might not have layout information calculated yet. This is a race condition and depending on when the node is cloned, we can see different results. In this case, React eventually clones node from the correct revision with the layout cache. It will be in a correct state in the end. This case is not as bad as far as I can tell but I included it here because it better illustrates what is going on.

State Progression is where things get worse. In this scenario, React will never clone from the correct revision and will never recover from this. Anytime React clones node with a state that needs to be progressed, it will get cloned one more time during commit but React will hold the wrong revision. Depending on where this node is located in the view hierarchy, it may lead to expensive layout calculations.

Example:
Let's use notation A/r1 as node of family A revision 1.

- React calls create node. Node A/r1 is created and React holds reference to this. It will later use it to clone it.
Node A has native state that was updated. New revision A/r2 is created. Now React and RN do not observe the same node anymore (this is sometimes necessary).
- React now clones node A to create A/r3. This revision may have the wrong yoga cache. Now this might sound like one off but let's explore what happens next.
- During commit, Fabric must do state progression to give node A/r3 state from A/r2. This requires cloning and new revision A/r4 is created. React has again a wrong node that does not have Yoga cache and can't recover from this state.

The blast radius of this varies depending on where in the tree the node is.

# Solution - State Alignment Mechanism
The main principle for new state progression is to make sure React references the correct shadow node after commit to avoid layout cache miss on subsequent commit.

Agenda for the diagrams below:
- Black colour: node was not cloned.
- Blue colour: node was cloned by React.
- Orange colour: node was cloned by host platform.
- Blue and Orange colour: node was cloned by both React and host platform.

## Simple cases
### Base case

 {F1483309510}

### React Cloned

 {F1483308354}

### React and host platform clone the same node

 {F1483309324}

## Medium difficulty

### React clones a different branch than host platform

 {F1483349393}

### React deletes a branch that was cloned by host platform
 {F1483349259}

### React changes structure of the tree, node cloned by host platform remains

 {F1483349758}

### React reorders nodes that were cloned by host platform

 {F1483350283}

Reviewed By: rubennorte

Differential Revision: D53405702

fbshipit-source-id: c7d4b0772c144c86d72e39965e9626a2daefa6fd
2024-04-12 02:47:01 -07:00
Samuel Susla 223c0398fd extend StateReconciliationTests (#44020)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44020

changelog: [internal]

This diff only adds more tests for state reconciliation to cover more cases.
Thanks to this, I discovered bugs in my previous implementation of cloneless state progression.

Reviewed By: rubennorte

Differential Revision: D55926491

fbshipit-source-id: 5945ba9bc1d6fed111fbca07e19589cbef50712d
2024-04-12 02:47:01 -07:00
Samuel Susla cc40c59993 Use size_t instead of casting to int32_t (#44019)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44019

changelog: [internal]

use size_t instead of int32_t so that caller of `ShadowNode::replaceChild` does not need to cast.

Reviewed By: rubennorte

Differential Revision: D55923333

fbshipit-source-id: 8f8062708d9aaddedb600aa7dac419a177e2ab24
2024-04-12 02:47:01 -07:00
Samuel Susla 669aa1c3c2 Introduce new trait: ClonedByNativeStateUpdate (#44018)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44018

changelog: [internal]

New trait ClonedByNativeStateUpdate is used to mark the path that was cloned by native state update.

This is a pre-requisite for new state reconciliation algorithm. It will mark part of shadow tree that was affected by native state update.

Reviewed By: rubennorte

Differential Revision: D55922776

fbshipit-source-id: 6d4515460346c341af3ee6117d570b3201328bc9
2024-04-12 02:47:01 -07:00
Samuel Susla 3b49db3bfe add option to set traits when cloning up to the root (#44017)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44017

changelog: [internal]

Add an option to mark all nodes clone indirectly by `ShadowNode::cloneTree`.

This is a pre-requisite for new state reconciliation algorithm. It will be used to mark part of shadow tree that was affected by native state update.

Reviewed By: rubennorte

Differential Revision: D55745323

fbshipit-source-id: 5e2a2e8a572cc5077d907608f83992a43625d58e
2024-04-12 02:47:01 -07:00
Samuel Susla 49f7ec30d6 add option to set traits with ShadowNodeFragment (#44016)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44016

changelog: [internal]

Add option to set traits when node is created or cloned via ShadowNodeFragment.

This is a pre-requisite for new state reconciliation algorithm.

Reviewed By: rubennorte

Differential Revision: D55691094

fbshipit-source-id: 0bdf024c3c9b28304969ddc9b9c63b0f0b924bb0
2024-04-12 02:47:01 -07:00
Max Hoffmann 2b85a236a1 delete deprecated Xcode version check (#43949)
Summary:
IOS builds started failing due to Xcode version checks falsely claiming newer versions are not installed

TODO affecting Xcode version checking reads: Remove this code after April 2024, when Apple will push the lower version of Xcode required to upload apps to the Store.

## Changelog:

remove deprecated Xcode version check

Pick one each for the category and type tags:

[IOS] [REMOVED] - Message

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

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

Test Plan: Should run as before, only the deprecated version check has been removed.

Reviewed By: dmytrorykun

Differential Revision: D56056701

Pulled By: cipolleschi

fbshipit-source-id: 47288e04bd1cfc989cf05994cb47421fd2379af0
2024-04-12 02:46:04 -07:00
Fabrizio Cucci 05ef779c0b Push ReactContext logic in derived classes (#44026)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44026

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

Yet another attempt to land this (last one was D55505416).

Copy-pasting below the amazing summary from RSNara.

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

NOTE: Intentionally not converting `BridgeReactContext` to Kotlin to minimize the risk of these changes.

Reviewed By: RSNara

Differential Revision: D55964787

fbshipit-source-id: b404efe0c7095894fa815165cc8682f78dccfa17
2024-04-12 01:47:52 -07:00
Samuel Susla b4f9aa1479 fix sticky header with tappable element (#44046)
Summary:
X-link: https://github.com/facebook/react-fbsource-import/pull/5

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

changelog: [internal]

`passthroughAnimatedPropExplicitValues` from sticky header were removed in D46703731 with assumption that native animations trigger on complete callback and it can be used as a synchronisation point for Fabric.
On complete callback is triggered for native animations do trigger on complete callback with one exception: when the native animation is driven by scroll view's content offset.
As a result, synchronisation between React and Fabric doesn't happen and Pressability stops working if there is a pressable element in the sticky header.

Reviewed By: rubennorte

Differential Revision: D56005408

fbshipit-source-id: daead3a566e157593aa3f1b3ae3553ec1094b6da
2024-04-12 01:35:07 -07:00
Ruslan Lesiutin aacde17954 Fusebox/RDT: setup global for Fusebox React DevTools dispatcher (#43418)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43418

Changelog: [Internal]

This diff adds a script, which will be later imported from `InitializeCore` to setup a required global for communication between React Native runtime (RDT Backend in it) and Chrome DevTools Frontend (RDT Frontend in it).

See README for the architecture overview and how bidirectional communication is established.

Corresponding PR in Chrome DevTools frontend - https://github.com/facebookexperimental/rn-chrome-devtools-frontend/pull/15

Reviewed By: motiz88

Differential Revision: D54770207

fbshipit-source-id: 0f0f04a338b5c7eab817c843a99b07cca95e57fd
2024-04-12 01:14:22 -07:00
Sam Zhou 78d523d178 Fix type errors that will be exposed in future versions of Flow (#44049)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44049

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D56036891

fbshipit-source-id: e7771d51bd8797c7237a66b499e1e6e082b8912d
2024-04-11 16:28:25 -07:00
D N 401f2fbb14 chore: [TS] Transform TouchableHighlight from class to ForwardRef component (#44038)
Summary:
If you check the source of truth `packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js` I'll find that `TouchableHighlight` is a result of `React.forwardRef(...)` :

https://github.com/facebook/react-native/blob/44d59ea6f9a1705487314e33de52f7056651ba25/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js#L382-L391

So the TS type isn't correct : (

```tsx
<TouchableHighlight ref={ref => {   }} />
//                     ^^^ ref should be a `View` (but now it's `TouchableHighlight`)
```

 ---

**Breaking  changes**

As `TouchableHighlight` isn't class anymore it can't be used as value & type

```tsx
import {TouchableHighlight} from 'react-native';
const ref = useRef<TouchableHighlight>();
//                ^^^ TS2749: TouchableHighlight refers to a value, but is being used as a type here.
//                            Did you mean typeof TouchableHighlight?
```

**Recommend solution:** use build-in react type `React.ElementRef`

```diff
-const ref = useRef<TouchableHighlight>();
+const ref = useRef<React.ElementRef<typeof TouchableHighlight>>();
```

Also, it possible to use `View` as type:

```diff
-const ref = useRef<TouchableHighlight>();
+const ref = useRef<View>();
```

## Changelog:

[GENERAL] [BREAKING] - [Typescript] Transform TouchableHighlight from JS class to ForwardRef component

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

Test Plan: See: `packages/react-native/types/__typetests__/index.tsx`

Reviewed By: NickGerleman

Differential Revision: D56015309

Pulled By: dmytrorykun

fbshipit-source-id: fee346536787a5921626ed69a4c01da2b599dc2f
2024-04-11 14:21:55 -07:00
D N 3d00549399 chore: [TS] Transform TouchableOpacity from class to ForwardRef component (#44030)
Summary:
If you check the source of truth `packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js` I'll find that `TouchableOpacity` is a result of `React.forwardRef(...)` :

https://github.com/facebook/react-native/blob/f7eaf63881b23216c06ab3c81ea94d0312cd6a7b/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js#L326-L335

So the TS type isn't correct : (

```tsx
<TouchableOpacity ref={ref => {   }} />
//                     ^^^ ref should be a `View` (but now it's `TouchableOpacity`)
```

 ---

**Breaking  changes**

As `TouchableOpacity` isn't class anymore it can't be used as value & type

```tsx
import {TouchableOpacity} from 'react-native';
const ref = useRef<TouchableOpacity>();
//                ^^^ TS2749: TouchableOpacity refers to a value, but is being used as a type here.
//                            Did you mean typeof TouchableOpacity?
```

**Recommend solution:** use build-in react type `React.ElementRef`

```diff
-const ref = useRef<TouchableOpacity>();
+const ref = useRef<React.ElementRef<typeof TouchableOpacity>>();
```

Also, it possible to use `View` as type:

```diff
-const ref = useRef<TouchableOpacity>();
+const ref = useRef<View>();
```

## Changelog:

[GENERAL] [BREAKING] - [Typescript] Transform `TouchableOpacity` from JS `class` to `ForwardRef` component

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

Test Plan: See: `packages/react-native/types/__typetests__/index.tsx`

Reviewed By: NickGerleman

Differential Revision: D56017133

Pulled By: dmytrorykun

fbshipit-source-id: 58f4c1a14c9b3bd2407ea6c825a90b355acb16bb
2024-04-11 14:15:27 -07:00
Riccardo Cipolleschi 46b6453eb6 Fix the Redefinition of 'NativeXXXSpecJSI' error with Frameworks (#44005)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44005

When using frameworks on iOS, there is a possibility that modules import the Spec.h file twice and this might end up in a Redefinition of some symbols and duplication of symbols which ends up in build errors, as reported here: https://github.com/facebook/react-native/issues/42670.

This change adds some [`#include guards`](https://en.wikipedia.org/wiki/Include_guard) in codegen to avoid the redefinition of those symbols if the header is imported/included multiple times.

Note: I also experimented with `#pragma once`, but it looks like Apple is not happy with that directive. [It seems](https://forums.developer.apple.com/forums/thread/739964) that it started working flakely from Xcode 15.

## Changelog:
[General][Fixed] - Make sure that we can't include Codegen symbols multiple times

Reviewed By: cortinico

Differential Revision: D55925605

fbshipit-source-id: 15ca076aace2ffbd03ab8fa8a68a3d8ce0d1ea65
2024-04-11 11:39:43 -07:00
Sophie L 9433506465 chore(AndroidExecutors): clean up outdated compat function (#43958)
Summary:
this PR cleans up an outdated compatibility function in AndroidExecutors. the function in question was checking whether the code was running on Gingerbread or later - this is no longer needed, as RN requires Marshmallow or later.

## Changelog:

[INTERNAL] [FIXED] - Clean up outdated compatibility function

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

Test Plan: this should work as normal.

Reviewed By: cortinico

Differential Revision: D55877661

Pulled By: dmytrorykun

fbshipit-source-id: 02eac50b0898d683f6abf731bf8e438ae4219a41
2024-04-11 10:41:54 -07:00
Samuel Susla 77efd191a8 use availableSize instead of measure result for measureLines (#43979)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43979

changelog: [internal]

using `availableSize` instead of `measurement` to avoid dependency on calling `textLayoutManager_->measure` before dispatching `onTextLayout` event.
This is important in subsequent optimisation.

Reviewed By: javache

Differential Revision: D55796594

fbshipit-source-id: 06b516e2afaf668c6359ad86b570229824933bae
2024-04-11 10:00:25 -07:00
Blake Friedman affadb6da8 core-cli-utils - Added version information
Summary:
Using version information previously housed in react-native-communtiy/cli

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D55960009

fbshipit-source-id: 38f8b2310942a9337a7b64b51a87ae629d9bbbaf
2024-04-11 07:59:01 -07:00
Fabrizio Cucci e14e6ce2a1 Fix rn-tester label color in drawer example (#44039)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44039

Changelog: [Internal]

Get label color from theme to fix dark mode.

Reviewed By: NickGerleman

Differential Revision: D56011777

fbshipit-source-id: 3ef14d6437c51118f0c0db3950b24f7e71d33fb3
2024-04-11 07:45:10 -07:00
Samuel Susla 840fd30194 delete text measure cache experiment (#43914)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43914

changelog: [internal]

This QE with caching text measurement and NSTextStorage did not deliver the desired results. Let's remove the code to simplify the text measure infra.

Reviewed By: javache

Differential Revision: D55753670

fbshipit-source-id: b194c4ca1eded70b0d00da748716628c264a47b9
2024-04-11 05:47:41 -07:00
Andrew Datsenko 88c7391485 //xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/appstate:appstateAndroid (#43938)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43938

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D55726807

fbshipit-source-id: 7338ee8949c05e192c47c6c06e999600dfad07a9
2024-04-11 05:25:47 -07:00
Blake Friedman b530371b7f react-native-info - clean up licenses + docs
Summary:
Capturing the correct attribution in the licenses as well as adding some documentation.

I think the code will have changed significantly enough across the files that once we change to flow, we can drop the attribution in the files but leave the mention in the README.

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: huntie

Differential Revision: D55752899

fbshipit-source-id: b436d745d5ad439661d2af840b2cc8df4bff0038
2024-04-11 05:16:46 -07:00
Samuel Susla 564f86ef92 add .gitignore for rn-tester build artifacts (#44041)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44041

changelog: [internal]

Building rn-tester left artifacts that would be picked up by mercurial.

```
❯ hg s
? rn-tester.xcodeproj.local/Project Settings.plist
? rn-tester.xcodeproj.local/Project Settings.plist.lock
```

To mitigate this, add  `rn-tester.xcodeproj.local` introduce .gitignore for rn-tester.

Reviewed By: fabriziocucci

Differential Revision: D56006193

fbshipit-source-id: 5701f1adf395e98f84ca59574dbd8747cf7e85db
2024-04-11 04:53:08 -07:00