Commit Graph

33558 Commits

Author SHA1 Message Date
Ruslan Lesiutin
3dfe22bd27 fix[Runtime.evaluate]: registered RuntimeExecutor should go through RuntimeScheduler (#47119)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47119

# Changelog:
[General] [Fixed] - Microtasks are now correctly executed after the code evaluation in Console panel of DevTools.

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

`runtimeExecutor` which is propagated here, is actually being used by Hermes:
https://www.internalfb.com/code/fbsource/[cba75f2b515a]/xplat/js/react-native-github/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp?lines=112-113

The issue was that any expression that should be evaluated as part of `Runtime.evaluate` was not going through `RuntimeScheduler`, because specified `runtimeExecutor` was not going through it as well, and it was defined prior to `RuntimeScheduler`. Because of this, `RuntimeScheduler` was not draining out the microtasks queue and basically any scheduled Microtasks were not executed, see T200616136.

With this fix, we create an executor that goes through `RuntimeScheduler`, which is using another executor that makes sure that all scheduled callbacks are only executed after `Inspector` was setup.

It is extremely messy and in the future we should untangle these circular dependencies and try to simplify the approach.

Reviewed By: rubennorte

Differential Revision: D64552372

fbshipit-source-id: 467d37c71a2eb7c940297ce90ca8d68268b1ff33
2024-10-21 22:10:28 -07:00
Jorge Cabiedes Acosta
cc23aea2fc Enable new **Border** and **Background** drawables on BackgroundStyleApplicator (#47124)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47124

With this we start the experiment to analyze the effect of the new `BackgroundDrawable.kt` and `BorderDrawable.kt` classes. This is also essentially a kotlinification of `CSSBackgroundDrawable`

We also start using CompositeBackgroundDrawable as the source of truth for **borderRadius** and **borderInsets**

We are hoping to get neutral results and a general win for code readability.

In general when the FeatureFlag passes we should not generate a CSSBackgroundDrawable at all and just use BackgroundDrawable and BorderDrawable

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63287222

fbshipit-source-id: 7ca98290c2e152b22d09b838e5f0e1cac97b1268
2024-10-21 21:24:19 -07:00
Jorge Cabiedes Acosta
b3d5b793a4 Add BorderDrawable to replace border logic on CSSBackgroundDrawable (#46745)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46745

**Note:** This diff still does nothing yet, it will be enabled on a diff further up the stack. This split is just to simplify reviewing

`CSSBackgroundDrawable` holds the drawing logic for both **Borders** and **Background**. This is not ideal since it results in a huge file which does 2 things.

We now have `CompositeBackgroundDrawable` which allows us to set a different drawable per "layer" on our view.

By splitting up **Border** and **Background** logic we get better modularity and it'll make it easier to implement more `backgroundImage` features without further bloating the `CSSBackgroundDrawable` file

Also, this helps with the kotlinification efforts

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D62898246

fbshipit-source-id: 15d1a4ef61f0c757e648c002fc7ef26626d8e3f6
2024-10-21 21:24:19 -07:00
Jorge Cabiedes Acosta
f41c59da96 Add BackgroundDrawable to replace background logic on CSSBackgroundDrawable (#46709)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46709

**Note:** This diff still does nothing yet, it will be enabled on a diff further up the stack. This split is just to simplify reviewing

`CSSBackgroundDrawable` holds the drawing logic for both **Borders** and **Background**. This is not ideal since it results in a huge file which does 2 things.

We now have `CompositeBackgroundDrawable` which allows us to set a different drawable per "layer" on our view.

By splitting up **Border** and **Background** logic we get better modularity and it'll make it easier to implement more `backgroundImage` features without further bloating the `CSSBackgroundDrawable` file

Also, this helps  with the kotlinification efforts

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63137921

fbshipit-source-id: fc459beadfda1832e146e36d74c3d424a28ca905
2024-10-21 21:24:19 -07:00
SamChou19815 (Meta Employee)
6205aad81e Eliminate usage of more than 1-arg React.AbstractComponent in React codebase (#31314)
Summary:
<!--
  Thanks for submitting a pull request!
We appreciate you spending the time to work on these changes. Please
provide enough information so that others can review your pull request.
The three fields below are mandatory.

Before submitting a pull request, please make sure the following is
done:

1. Fork [the repository](https://github.com/facebook/react) and create
your branch from `main`.
  2. Run `yarn` in the repository root.
3. If you've fixed a bug or added code that should be tested, add tests!
4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch
TestName` is helpful in development.
5. Run `yarn test --prod` to test in the production environment. It
supports the same options as `yarn test`.
6. If you need a debugger, run `yarn test --debug --watch TestName`,
open `chrome://inspect`, and press "Inspect".
7. Format your code with
[prettier](https://github.com/prettier/prettier) (`yarn prettier`).
8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only
check changed files.
  9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
  10. If you haven't already, complete the CLA.

Learn more about contributing:
https://reactjs.org/docs/how-to-contribute.html
-->

## Summary

In order to adopt react 19's ref-as-prop model, Flow needs to eliminate
all the places where they are treated differently.
`React.AbstractComponent` is the worst example of this, and we need to
eliminate it.

This PR eliminates them from the react repo, and only keeps the one that
has 1 argument of props.

## How did you test this change?

yarn flow

DiffTrain build for [45804af18d589fd2c181f3b020f07661c46b73ea](45804af18d)

Reviewed By: jbrown215

Differential Revision: D64725736

Pulled By: SamChou19815

fbshipit-source-id: c9f6f316c95d12a9ae98926faba111395b550ccf
2024-10-21 19:52:01 -07:00
Panos Vekris
363818ea20 pre-suppress errors before enabling experimental.object_freeze_fix (#47141)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47141

D64152004 fixed a soundness hole in Flow's checking of frozen object types (e.g. try-Flow https://fburl.com/rmct2mf6). This diff suppresses Flow errors that appear when this fix is enabled (`experimental.object_freeze_fix` flag is set).

For most of these cases the result of `Object.freeze()` is assigned to some variable typed as a mutable type. The variable is then passed to a context where its fields can be written to. Thus changing the annotation type to a readonly version would only cause more errors downstream. So, instead, these assignments are suppressed so that the choice of using Object.freeze can be revisited.

Changelog: [internal]

Reviewed By: SamChou19815

Differential Revision: D64699992

fbshipit-source-id: 48e4376d4ed3dbda21d32cabe512e6457384994f
2024-10-21 19:26:02 -07:00
Panos Vekris
d25f0c5edd prepare for fix in Object.freeze typing [2/n] (#47131)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47131

D64152004 fixed a soundness hole in Flow's checking of frozen object types (e.g. try-Flow https://fburl.com/rmct2mf6)

This diff prevents Flow errors from appearing when `experimental.object_freeze_fix` flag is set.

Changelog: [internal]

Reviewed By: SamChou19815

Differential Revision: D64641920

fbshipit-source-id: b6de954d3474f5c4c2e2a58f69cf8cff61be53e5
2024-10-21 19:26:02 -07:00
Sam Zhou
036e4f64c4 Eliminate 2 more remaining React.AbstractComponent<...> in react native
Summary:
In order to adopt react 19's ref-as-prop model, we need to eliminate all the places where they are treated differently. `React.AbstractComponent` is the worst example of this, and we need to eliminate it.

This diff replaces 2 more remaining ones in react-native. Now the only remaining one is the one synced from react repo.

Changelog: [Internal]

Reviewed By: alexmckenley

Differential Revision: D64722899

fbshipit-source-id: 2b2484c385fc5d6c173253f9bee66dfc736368a5
2024-10-21 19:10:42 -07:00
Sam Zhou
71e9039e9f Prepare typing changes for HostComponent (#47150)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47150

In https://github.com/facebook/react/pull/31314, I will change the host component type that will be synced to react-native. Notably, it will expose the issue where all the `HostComponent<mixed>` types are wrong, since it doesn't make sense to write `React.AbstractComponent<mixed>`. This diff fixes the existing usages first in prep for that typing change.

Changelog: [Internal]

Reviewed By: alexmckenley

Differential Revision: D64722939

fbshipit-source-id: 14e1477090128205d8be8fc7b135a8478f94b790
2024-10-21 18:15:34 -07:00
Eli White
4c37431c7f Support new codegen schema for native modules (#47114)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47114

Export the EventEmitter annotation from the codegen

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D63995813

fbshipit-source-id: 0211c21d7813da03bf8b6680095e016a621c188b
2024-10-21 16:43:49 -07:00
David Vacca
e10c07d5ae Rollout enableDeletionOfUnmountedViews in OSS and NewArchitecture apps (#47144)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47144

I'm fully rolling out enableDeletionOfUnmountedViews in OSS

changelog: [internal] internal

Reviewed By: shwanton

Differential Revision: D64613764

fbshipit-source-id: 6dfecb9fe143ec59ddb71b614f12563a564578fc
2024-10-21 16:39:40 -07:00
Sam Zhou
723a37cb26 Replace most of the remaining React.AbstractComponent in react-native (#47143)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47143

In order to adopt react 19's ref-as-prop model, we need to eliminate all the places where they are treated differently. `React.AbstractComponent` is the worst example of this, and we need to eliminate it.

This diff replaces most of the remaining `React.AbstractComponent` in react-native.

Changelog: [Internal]

Reviewed By: alexmckenley

Differential Revision: D64701145

fbshipit-source-id: c765674fdf59812895c4fae43df97cf8b9d24f05
2024-10-21 15:48:25 -07:00
Nicola Corti
dbf09fbe58 Stable API - Make AppStateModule internal (#47121)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47121

This class should be internal. I've verified this API is not used in OSS so this is technically breaking but not really affecting anyone in OSS.

Changelog:
[Android] [Breaking] - Stable API - Make AppStateModule internal

Reviewed By: Abbondanzo

Differential Revision: D64598660

fbshipit-source-id: aebc385c741e2e1f352d473db2be87d918f0ef65
2024-10-21 15:34:50 -07:00
David Vacca
1aaedc7fca Turnon enableEventEmitterRetentionDuringGesturesOnAndroid for all apps depending on ReactNativeNewArchitectureFeatureFlagsDefaults (#47142)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47142

I'm turning on enableEventEmitterRetentionDuringGesturesOnAndroid for all apps depending on ReactNativeNewArchitectureFeatureFlagsDefaults

Reviewed By: cortinico

Differential Revision: D64610897

fbshipit-source-id: c301f616918484ed41790247d1e0cd7284602b09
2024-10-21 13:57:09 -07:00
Mateo Guzmán
d784d95568 docs(rn-tester): adding extra instructions to disable fabric (#47127)
Summary:
While working on https://github.com/facebook/react-native/pull/47110, I wanted to disable fabric in the `rn-tester` to test some things in Paper. I followed all the steps but ended up deleting the whole repository locally, cloning it again and explicitly installing the pods `fabric_enabled` in all steps and it didn't work. I ended up disabling the new architecture by passing `RCT_NEW_ARCH_ENABLED=0` and then it worked immediately.

Wanted to add this extra hint as it might help other contributors.

## Changelog:

[INTERNAL] [ADDED] - extra instructions to disable fabric in the `rn-tester` package

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

Test Plan: Follow the instructions to disable fabric, try passing `RCT_NEW_ARCH_ENABLED=0` if `fabric_enabled = false` is not enough.

Reviewed By: cortinico

Differential Revision: D64652149

Pulled By: rshest

fbshipit-source-id: 0fc4149832a7973c57161b4fff5815414f304a3c
2024-10-21 09:18:25 -07:00
Parsa Nasirimehr
5697d923a0 fix(Android) - remove some unused imports in canvas utils (#47132)
Summary:
Was working on something, saw that CanvasUtils has some unused imports. Figured i'd send a PR to clean up.

## Changelog:

[INTERNAL] [FIXED] - Cleanup CanvasUtils imports

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

Test Plan:
Ran yarn test:

<img width="513" alt="Screenshot 2024-10-19 at 22 54 13" src="https://github.com/user-attachments/assets/6ca86852-cab5-425a-b71c-785c7d1ea95e">

Also tried running ./gradlew test, but it appears it is not having fun with my Node version (18.20.3), so `createBundleHermesReleaseJsAndAssets` randomly fails, to be investigated why:

<img width="1515" alt="Screenshot 2024-10-19 at 22 56 02" src="https://github.com/user-attachments/assets/f860cdc5-4f42-4d54-9497-7eaa028b6bc6">

Reviewed By: NickGerleman

Differential Revision: D64663918

Pulled By: cortinico

fbshipit-source-id: a681d6ee76dfcbc56889e76da6cf8ea11907bdf2
2024-10-20 18:28:11 -07:00
Jakub Piasecki
e7a3f479fe Add support for display: contents (#46584)
Summary:
This PR adds support for `display: contents` style by effectively skipping nodes with `display: contents` set during layout.

This required changes in the logic related to children traversal - before this PR a node would be always laid out in the context of its direct parent. After this PR that assumption is no longer true - `display: contents` allows nodes to be skipped, i.e.:

```html
<div id="node1">
  <div id="node2" style="display: contents;">
    <div id="node3" />
  </div>
</div>
```

`node3` will be laid out as if it were a child of `node1`.

Because of this, iterating over direct children of a node is no longer correct to achieve the correct layout. This PR introduces `LayoutableChildren::Iterator` which can traverse the subtree of a given node in a way that nodes with `display: contents` are replaced with their concrete children.

A tree like this:
```mermaid
flowchart TD
    A((A))
    B((B))
    C((C))
    D((D))
    E((E))
    F((F))
    G((G))
    H((H))
    I((I))
    J((J))

    A --> B
    A --> C
    B --> D
    B --> E
    C --> F
    D --> G
    F --> H
    G --> I
    H --> J

    style B fill:https://github.com/facebook/react-native/issues/050
    style C fill:https://github.com/facebook/react-native/issues/050
    style D fill:https://github.com/facebook/react-native/issues/050
    style H fill:https://github.com/facebook/react-native/issues/050
    style I fill:https://github.com/facebook/react-native/issues/050
```

would be laid out as if the green nodes (ones with `display: contents`) did not exist. It also changes the logic where children were accessed by index to use the iterator instead as random access would be non-trivial to implement and it's not really necessary - the iteration was always sequential and indices were only used as boundaries.

There's one place where knowledge of layoutable children is required to calculate the gap. An optimization for this is for a node to keep a counter of how many `display: contents` nodes are its children. If there are none, a short path of just returning the size of the children vector can be taken, otherwise it needs to iterate over layoutable children and count them, since the structure may be complex.

One more major change this PR introduces is `cleanupContentsNodesRecursively`. Since nodes with `display: contents` would be entirely skipped during the layout pass, they would keep previous metrics, would be kept as dirty, and, in the case of nested `contents` nodes, would not be cloned, breaking `doesOwn` relation. All of this is handled in the new method which clones `contents` nodes recursively, sets empty layout, and marks them as clean and having a new layout so that it can be used on the React Native side.

Relies on https://github.com/facebook/yoga/pull/1725

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

This PR adds a few things over the corresponding one in Yoga:
- new value in the `DisplayType` enum - `Contents`
- new `ShadowNodeTrait` - `ForceFlattenView`, that forces the node not to form a host view
- updates TS types to include `display: contents`
- aliases `display: contents` to `display: none` on the old architecture

## Changelog:

[GENERAL] [ADDED] - Added support for `display: contents`

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

Test Plan:
<details>
<summary>So far I've been testing on relatively simple snippets like this one and on entirety of RNTester by inserting views with `display: contents` in random places and seeing if anything breaks.</summary>

```jsx
import React from 'react';
import { Button, Pressable, SafeAreaView, ScrollView, TextInput, View, Text } from 'react-native';

export default function App() {
  const [toggle, setToggle] = React.useState(false);
  return (
    <View style={{flex: 1, paddingTop: 100}}>
      <SafeAreaView style={{width: '100%', height: 200}}>
        <Pressable style={{width: 100, height: 100, backgroundColor: 'black'}} onPress={() => setToggle(!toggle)}>
          <ScrollView />
        </Pressable>
        <View style={{display: 'flex', flexDirection: 'row', flex: 1, backgroundColor: 'magenta'}}>
          <SafeAreaView style={{
            // display: 'contents',
            flex: 1,
            }}>
            <View style={{
              display: 'contents',
              width: '100%',
              height: 200,
              }}>
              <View style={{
                  display: 'contents',
                  flex: 1,
                }}>
                { toggle && <View style={{flex: 1, backgroundColor: 'yellow'}} /> }
                <View style={{flex: 1, backgroundColor: 'blue'}} />
                <View style={{flex: 1, backgroundColor: 'cyan'}} />
              </View>
            </View>
          </SafeAreaView>
        </View>
        {/* <View style={{width: 100, height: 100, backgroundColor: 'magenta', display: 'flex'}} /> */}
        <TextInput style={{width: 200, height: 100, backgroundColor: 'red', display: 'flex'}}>
          <Text style={{color: 'white'}}>Hello</Text>
          <Text style={{color: 'green'}}>World</Text>
        </TextInput>
      </SafeAreaView>
    </View>
  );
}
```

</details>

Reviewed By: joevilches

Differential Revision: D64584476

Pulled By: NickGerleman

fbshipit-source-id: bec77b5087ff95f0980cf02274fbb2c8581eb3c0
2024-10-18 22:05:41 -07:00
Jakub Piasecki
e5296cfc81 Add support for display: contents style (#47035)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47035

This PR adds support for `display: contents` style by effectively skipping nodes with `display: contents` set during layout.

This required changes in the logic related to children traversal - before this PR a node would be always laid out in the context of its direct parent. After this PR that assumption is no longer true - `display: contents` allows nodes to be skipped, i.e.:

```html
<div id="node1">
  <div id="node2" style="display: contents;">
    <div id="node3" />
  </div>
</div>
```

`node3` will be laid out as if it were a child of `node1`.

Because of this, iterating over direct children of a node is no longer correct to achieve the correct layout. This PR introduces `LayoutableChildren::Iterator` which can traverse the subtree of a given node in a way that nodes with `display: contents` are replaced with their concrete children.

A tree like this:
```mermaid
flowchart TD
    A((A))
    B((B))
    C((C))
    D((D))
    E((E))
    F((F))
    G((G))
    H((H))
    I((I))
    J((J))

    A --> B
    A --> C
    B --> D
    B --> E
    C --> F
    D --> G
    F --> H
    G --> I
    H --> J

    style B fill:https://github.com/facebook/yoga/issues/050
    style C fill:https://github.com/facebook/yoga/issues/050
    style D fill:https://github.com/facebook/yoga/issues/050
    style H fill:https://github.com/facebook/yoga/issues/050
    style I fill:https://github.com/facebook/yoga/issues/050
```

would be laid out as if the green nodes (ones with `display: contents`) did not exist. It also changes the logic where children were accessed by index to use the iterator instead as random access would be non-trivial to implement and it's not really necessary - the iteration was always sequential and indices were only used as boundaries.

There's one place where knowledge of layoutable children is required to calculate the gap. An optimization for this is for a node to keep a counter of how many `display: contents` nodes are its children. If there are none, a short path of just returning the size of the children vector can be taken, otherwise it needs to iterate over layoutable children and count them, since the structure may be complex.

One more major change this PR introduces is `cleanupContentsNodesRecursively`. Since nodes with `display: contents` would be entirely skipped during the layout pass, they would keep previous metrics, would be kept as dirty, and, in the case of nested `contents` nodes, would not be cloned, breaking `doesOwn` relation. All of this is handled in the new method which clones `contents` nodes recursively, sets empty layout, and marks them as clean and having a new layout so that it can be used on the React Native side.

Relies on https://github.com/facebook/yoga/pull/1725

Changelog: [Internal]

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

Test Plan: Added tests for `display: contents` based on existing tests for `display: none` and ensured that all the tests were passing.

Reviewed By: joevilches

Differential Revision: D64404340

Pulled By: NickGerleman

fbshipit-source-id: f6f6e9a6fad82873f18c8a0ead58aad897df5d09
2024-10-18 22:05:41 -07:00
Fabrizio Cucci
f3e37e29e2 Back out "Account for diffrent frame size when using maintainVisibleContentPosition in virtualized lists" (#47125)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47125

Original commit changeset: 9f05a461d178

Original Phabricator Diff: D64238887

Changelog: [Internal]

NOTE: while this seems to work on IGVR it breaks on the two use cases highlighted in D64339251, backing out the diff while trying to find out a solution that works on all cases!

Reviewed By: Abbondanzo

Differential Revision: D64611594

fbshipit-source-id: b43353b17448c181a76b2af09968cf0e4934c53c
2024-10-18 13:49:46 -07:00
Fabrizio Cucci
16ceb6f74c Add maintainVisibleContentPosition example in rn-tester (#47126)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47126

This will be used to validate the fix to `maintainVisibleContentPosition` for the two major use cases when the FlatList resizes:
* when the items have fixed size
* when the items scale with the size of the list

Changelog: [Internal]

Reviewed By: Abbondanzo

Differential Revision: D64339251

fbshipit-source-id: d0ee8d73cd9e6527a7ce0950e8f3941337b70474
2024-10-18 13:48:52 -07:00
David Vacca
1cc648feca Interrupt thread before throwing in BridgelessDevSupportManager (#47100)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47100

We should interrupt thread before throwing

changelog: [internal] internal

Reviewed By: bvanderhoof, arushikesarwani94

Differential Revision: D64545258

fbshipit-source-id: dec90ca2e75b8f3bceb258edbb525372065962ee
2024-10-18 11:13:40 -07:00
Alex Hunt
6f421230c1 Drop appId from /open-debugger calls, disable matching for modern targets (#47120)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47120

Fixes no-op behaviour of the "Open DevTools" Dev Menu item (bug on `main` introduced with D63329456).

This was caused by a change to the `description` field contents in our CDP `/json/list` response, when under Fusebox. In the `/open-debugger` call from the Dev Menu, we were still using the older `appId` param.

This did not affect `j` to debug, which uses the `target` param.

{F1937186832}

Changes:

In short: Matching against the `description` string is now fully eliminated for modern debugger targets.

- Update native Dev Menu implementation to omit `appId` parameter (`device` param alone is sufficient and fully precise on these platforms).
- Update `/open-debugger` implementation to ignore the `appId` parameter for modern targets, and document this in the `dev-middleware` README.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D64597581

fbshipit-source-id: 46f536e7d0a4ececab0d52f4c0704e8698466cd0
2024-10-18 11:02:51 -07:00
Nicola Corti
dc1a498d39 Undo breaking change on UIManager eventDispatcher accessor (#47088)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47088

Whe migrating this interface to Kotlin we've subtly introduced a breaking change which is causing a lot of breakages in the ecosystem.

This is forcing users to do:
```
// Before
reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
// After
reactContext.getNativeModule(UIManagerModule::class.java)!!.getEventDispatcher()
```

This reverts this breaking change.

Plus the method had a generic parameters which was completely unnecessary so I'm removing it.

Changelog:
[Android] [Fixed] - Undo breaking change on UIManager eventDispatcher accessor

Reviewed By: cipolleschi

Differential Revision: D64533594

fbshipit-source-id: c4f9a36993a22839fae90fb239f883305422ecec
2024-10-18 08:33:25 -07:00
Samuel Susla
5c6edc6861 add comment to EventBeat clarifying its use (#47065)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47065

changelog: [internal]

Just a comment explaining intended use.

Reviewed By: tdn120

Differential Revision: D64469189

fbshipit-source-id: 65cb0c5ea4669f748abe1e78fd25816e895c3f58
2024-10-18 05:47:47 -07:00
shubhamguptadream11
45b177f50d fix: height and width added back in props (#47044)
Summary:
Fixes this: https://github.com/facebook/react-native/issues/41151

## Changelog:

[GENERAL] [FIXED] - Passed height and width as native props to support cases where source is an array.

**Issue**: Unable to use height and width as props in Image components when passing source as an array.

This functionality worked before this [commit](https://github.com/facebook/react-native/pull/34481). In Image.android.js and Image.ios.js, height and width props are extracted before passing them to the native side. This extraction makes these props ineffective when passed directly. Although setting height and width in style is a workaround, these props should still be respected since they exist for this purpose.

The issue occurs only when the source prop is an array. When source is an object, width and height are manually passed to the style object, so the issue doesn't arise.

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

Test Plan: Tested this on `rn-tester` app

Reviewed By: necolas, javache

Differential Revision: D64458292

Pulled By: cipolleschi

fbshipit-source-id: 5cacad79b8d4468a4a1fd0977221e42ce4b2e5d1
2024-10-18 05:04:11 -07:00
Samuel Susla
b0f0f0631c delete typealias RunLoopObserver::Unique (#47117)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47117

changelog: [internal]

use unique_ptr directly instead of typealias obscuring the type.

Reviewed By: christophpurrer

Differential Revision: D64302758

fbshipit-source-id: 5a7ee2408a04de6cf1e60036463227cd2b455fcf
2024-10-18 04:52:45 -07:00
Tim Yung
c9ea05552f RN: Fix lint/sort-imports Errors (#47109)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47109

Fixes the `lint/sort-imports` errors that are now surfaced after fixing the lint configuration.

For a couple files, I added lint suppressions instead because the unsorted import ordering is important due to interleaved calls with side effects.

Changelog:
[Internal]

Reviewed By: GijsWeterings

Differential Revision: D64569485

fbshipit-source-id: 26415d792e2b9efe08c05d1436f723faae549882
2024-10-18 04:07:02 -07:00
Frank Calise
e14a2f3862 test(rn-tester): skip loading indicators when list is empty (#47094)
Summary:
During testing for 0.76-RC6, I came across the following behavior in RNTester.

Components > FlatList > Basic > Toggle `Empty` switch

You'll notice there are activity indicators in the header/footer (see video) for some time and things appear to be somewhat janky. I think the expectations would be to see only the `ListEmptyComponent` that is defined for this to look more correct. This will help not give any false indication that something has gone wrong with the latest picks when testing newer versions.

## Changelog:

[INTERNAL] [FIXED] - Fixed FlatList Empty behavior in RNTester

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

Test Plan: https://github.com/user-attachments/assets/6e116641-5b24-473c-a654-7d32a081b83f

Reviewed By: yungsters

Differential Revision: D64541905

Pulled By: cipolleschi

fbshipit-source-id: 0447d99588d85f9e1a46c6da169a0838e94994bc
2024-10-18 03:33:22 -07:00
Pieter De Baets
95a5d1c628 Explicity reset typeface in updateTextPaint (#47097)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47097

Calling Paint.reset() doesn't reset the active type face (https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/libs/hwui/hwui/PaintImpl.cpp;l=86), which causes measurements bugs for Text which don't specify a font to be incorrect.

Changelog: [Android][Fixed] Text without explicit font styles was potentially cut-off.

Reviewed By: NickGerleman

Differential Revision: D64535719

fbshipit-source-id: d300c26bf828a0e2e4b170254f9be5f409aff2dc
2024-10-18 03:29:34 -07:00
Nick Gerleman
0a2dec175e Remove legacy absolute positioning path (#46984)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46984

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

The legacy (wrong) absolute positioning path positions in two places, including work that is definitely always overwritten in the new absolute layout path.

This came up before for position: static, but we didn't clean this up at the time. This code is also now leading display: contents impl being more annoying.

This diff tries to converge to the more spec correct implementation of positioning here, that also only happens in one place.

Previous path would potentially also incorrectly justify when `justify-content` was non-default, but not handled in the previous few cases? We don't have access to the flexLine at this point later, and apart from the existing tests now passing I reused the new correct logic for justification (spec says we should position child as if its the only child in the container https://www.w3.org/TR/css-flexbox-1/#abspos-items).

I added a new, more scoped errata `AbsolutePositionWithoutInsetsExcludesPadding` to preserve some of the legacy behavior that showed as very breaking.

I also did not try removing `AbsolutePercentAgainstInnerSize` which I suspect would be more breaking than this change.

Changelog:
[General][Breaking] - More spec compliant absolute positioning

Reviewed By: joevilches

Differential Revision: D64244949

fbshipit-source-id: ca97570e0de82e8f0424a0912adfd0b05254559e
2024-10-17 22:40:16 -07:00
Phillip Pan
2ffd31bbd7 set modal rendered state to false on unmount (#47078)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47078

Changelog: [Internal]

in fabric, we've found a scenario where this modal state update is required to cleanup all artifacts from the modal presentation views. it is safe to add this back, as it was originally removed for a scenario that no longer exists.

Reviewed By: shwanton

Differential Revision: D64388550

fbshipit-source-id: f13571260379554b0126c379ace9f9e1b81866be
2024-10-17 22:09:43 -07:00
Nick Gerleman
0ba00fc998 Merge Android ViewNativeComponent ViewConfig into BaseViewConfig (#47105)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47105

`codegenNativeComponent` expects we declare props as extending `ViewProps`, but the generated ViewConfig extends from BaseViewConfig.

This doesn't matter on iOS, where ViewProps are implemented more uniformly across components, but on Android, means we miss about 40 view props, since `ReactViewManager` backing `<View>` supports quite a bit more than `BaseViewManager`. This means that any components which extend `ReactViewManager` have some ViewProps omitted.

In this diff, I went with the solution of moving the props specific to View's ViewConfig to BaseViewConfig. This means the SVC may treat more props as valid than the underlying native component, but this should be safe compared to undercounting, and this will make future moves from ReactViewManager to BaseViewManager safer.

BaseViewConfig was already exposing props not supported by BaseViewManager, like those related to border widths (which effect LayoutShadowNode, but cannot be drawn out of the box?), so this shouldn't be too out there.

The alternative to this was to publicly expose the View ViewConfig and extend from that in codegen instead, but this seemed more complicated without much benefit.

Changelog:
[Android][Fixed] - Merge Android ViewNativeComponent ViewConfig into BaseViewConfig

Reviewed By: elicwhite

Differential Revision: D64570806

fbshipit-source-id: de5c590e935c879e33d59c36ddce1f2481023c19
2024-10-17 20:51:11 -07:00
Sam Zhou
797d013308 Deploy 0.250.0 to xplat (#47108)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47108

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D64577261

fbshipit-source-id: 265e1f6755fde3836bb7aa15116e2bb380cee091
2024-10-17 19:54:04 -07:00
Shawn Dempsey
d78cb78b15 React Activity exposes ReactHost (#46980)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46980

Changelog: [Android][Added]  React Activity exposes ReactHost

**Context:**

*These changes will not impact `DefaultReactHost` which is the way most OSS apps interface with `ReactHost`*

* We are simplifying `ReactHost` and `ReactHostDelegate` for Brownfield uses.
* We fetch the `ReactHost` to create the `ReactDelegate`
https://www.internalfb.com/code/fbsource/[00ee07afc695]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java?lines=110-112

* With Bridgeless, you must use or extend `ReactHostDelegate` to get the `ReactHost` since we don't expose a getter on `ReactActivity`.
* If there is a custom Application, then getting the `ReactHost` will need a custom implementation.
* For the base case, we shouldn't need to subclass the delegate.

**Change:**

* Expose `ReactHost` on `ReactActivity` for Bridgeless access.
* Expose `ReactActivity` on `ReactActivityDelegate`. This will help us avoid keeping a reference to Activity in each subclass.
* Update the RN Android API's

Reviewed By: arushikesarwani94

Differential Revision: D64150994

fbshipit-source-id: a9d790a4b4ce4eca29dee4bdc8d9fc56cf742f1f
2024-10-17 19:33:40 -07:00
Jorge Cabiedes Acosta
398512a4ed Fix getOpacity() for drawables (#47103)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47103

`getOpacity()` is supposed to return a PixelFormat enum instead of a value between 0..255.
https://developer.android.com/reference/android/graphics/drawable/Drawable#getOpacity()

Also, I'm taking the value from the paint instead of the color's alpha since the paint might've been modified by setAlpha by this point and otherwise the paint will hold the alpha set by the color anyway since setAlpha() on Paints is just a helper for setColor() (https://developer.android.com/reference/android/graphics/Paint#setAlpha(int))

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D64273014

fbshipit-source-id: e2c524f1d816ee3705c5118232be759898e666ea
2024-10-17 17:37:25 -07:00
Jorge Cabiedes Acosta
02e4f3e16a Nullable borderRadius optimization on shadows and outline (#46819)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46819

Just some preparation to implement the new `BackgroundDrawable` and `BorderDrawable`.

This makes shadows and outline rely on `CompositeBackgroundDrawable` to set the state of `BorderRadiusStyle` and also makes them have a nullable borderRadius variable and initialize it only if we have it set saving a bit of overhead and performance

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63798853

fbshipit-source-id: 994327415ba160cf8e5ccb3135c4917809499f81
2024-10-17 17:37:25 -07:00
Tim Yung
892ce1b980 RN: Fix sort-imports Lint Configuration (#47104)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47104

In https://github.com/facebook/react-native/pull/46082, the lint configuration for `lint/sort-imports` was accidentally removed.

This has happened on more than one occasion in the past. In order to prevent this from happening again in the future, I'm also adding a Jest integration test to verify that this lint rule is enabled in the `eslintrc.js` configuration.

Changelog:
[Internal]

Reviewed By: robhogan

Differential Revision: D64547410

fbshipit-source-id: ec4f14aff140691b644189dfa3116a3d39285f80
2024-10-17 17:06:20 -07:00
Rubén Norte
14bbb87516 Fix incorrect type being passed to NativePerformance.mark (#47102)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47102

Changelog: [internal]

In D64466057 / 32f7b3b4e0 we accidentally modified the API of `NativePerformance.mark` (which we wanted to preserve and move the changes to `NativePerformance.markWithResult` after some iteration) to make `startTime` optional, which isn't compatible with the previous native API.

This fixes the issue by reverting the type back to being required and always passing it from the JS API.

Differential Revision: D64557467

fbshipit-source-id: 3ade4271622ac6213fd4c2d4948c7d40e4abe715
2024-10-17 13:05:01 -07:00
Edmond Chui
d11954e800 add appId to Telemetry (#47099)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47099

Changelog: [Internal]

As discussed in D64547367, recent changes caused `description` to stop reporting `appId`.

This impacted Telemetry's "top apps" dashboards.
{F1936011487}

Reviewed By: hoxyq

Differential Revision: D64548348

fbshipit-source-id: 46af650a89e2bef7be000482e7b774f56f84cac3
2024-10-17 12:47:05 -07:00
Edmond Chui
0d591d9dc3 add appId as a standalone field (#47098)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47098

Changelog: [Internal]

D63329456 updated the `description` field to be human-readable.
Unfortunately, InspectorProxy relies on this field to compare the incoming `/open-debugger` calls.

hoxyq discovered the symptom of Fusebox failing to launch with `No compatible apps connected. React Native DevTools can only be used with the Hermes engine.` in Metro

Reviewed By: hoxyq

Differential Revision: D64547367

fbshipit-source-id: deed6851f3ede2c74be2b492def1eba6e58c43e6
2024-10-17 12:47:05 -07:00
Joe Vilches
1d6ac09530 Fix animating background colors in View (#47101)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47101

See https://github.com/facebook/react-native/issues/47011

borders do not have this problem because they call `removeAllAnimations` on the layer after changing it, which is what I am doing here

Changelog: [iOS] [fixed] - Fixed bug where background colors would sometimes animate when changing on Views

Reviewed By: cipolleschi

Differential Revision: D64493968

fbshipit-source-id: cf81549f21b124b67c6e7647c6ae827bfe80a9cf
2024-10-17 11:58:12 -07:00
Samuel Susla
d3fa580508 unify overlapping logic among platform specific EventBeats (#47085)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47085

changelog: [internal]

Move induce method from  AppleEventBeat and AndroidEventBeat to its subclass EventBeat.

# Goal of this stack:
Centralise event beat logic into EventBeat class inside react-native-github. Subclasses should only override EventBeat::request and EventBeat::induce.

Reviewed By: christophpurrer

Differential Revision: D64302639

fbshipit-source-id: cdea5ee64dc25633ae59fdce5b1ce6aff8a97d68
2024-10-17 11:51:22 -07:00
Samuel Susla
9fe253d677 delete AsynchronousEventBeat in favour of platform specific EventBeats (#47058)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47058

changelog: [internal]

# Goal of this stack:
Centralise event beat logic into EventBeat class inside react-native-github. Subclasses should only override EventBeat::request and EventBeat::induce.

Reviewed By: christophpurrer

Differential Revision: D64291889

fbshipit-source-id: fa46e2c5246e1a9a1b5f3bd02e5c0efa562188e9
2024-10-17 11:51:22 -07:00
Nicola Corti
7168a9d1a2 Stable API - Make AccessibilityInfoModule internal (#47092)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47092

This class should not be public. I'm updating the BUCK rule to make it `internal` and remove it from the public API surface.

Technically breaking however I haven't found meaningful usages of this API in OSS so this should be safe to ship.

Changelog:
[Android] [Breaking] - Make `AccessibilityInfoModule` internal

Reviewed By: mdvacca

Differential Revision: D64539866

fbshipit-source-id: 21c9965dc95b697bef93bbad23872921a73566aa
2024-10-17 11:46:41 -07:00
Peter Abbondanzo
c54b23ff9e Ensure alert dialog title wraps to two lines, uses default style (#47095)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47095

The [internal `DialogTitle` implementation from Android](https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/com/android/internal/widget/DialogTitle.java;l=63?q=DialogTitle) makes additional checks to see if the title should wrap to two lines before applying ellipsis, so this change recreates those same checks. This change also removes the text appearance and size changes made to the layout.

Reverts some of the changes made to https://github.com/facebook/react-native/pull/45395.

**Changelog:**
[Android][Fixed] - Fixed styling on alert dialog titles to wrap two lines and retain bold appearance

Reviewed By: cortinico

Differential Revision: D64543105

fbshipit-source-id: 30d1f9091aa7216eb5d00e4f8f14cbc719c803ea
2024-10-17 11:34:00 -07:00
yungsters (Meta Employee)
dc737a7356 Delete __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED from React Native Renderer (#31276)
Summary:
## Summary

The React Native Renderer exports a
`__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED` property with a
single method that has no remaining call sites:
`computeComponentStackForErrorReporting`

This PR cleans up this unused export.

## How did you test this change?

```
$ yarn
$ yarn flow fabric
$ yarn test
```

DiffTrain build for [a3d9ea05bf01f3c3d7aedc2d938c581ad11fd14a](a3d9ea05bf)

Reviewed By: rickhanlonii, kassens

Differential Revision: D64484457

Pulled By: yungsters

fbshipit-source-id: 9a7629210739d23175480191d30fc02ba3ee2fee
2024-10-17 10:56:28 -07:00
Riccardo Cipolleschi
8e80257f23 Add Changelog for 0.76.0-rc.6 (#47096)
Summary:
See changelog

## Changelog:
[Internal] - Add changelog for 0.76.0-rc.6

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

Test Plan: N/A

Reviewed By: blakef

Differential Revision: D64545320

Pulled By: cipolleschi

fbshipit-source-id: ebfe57f5009f9b1906856cc90a19dd858e7e6583
2024-10-17 10:39:08 -07:00
Cristian Matteu
4ae999b90b Add announceForAccessibilityWithOptions method mock. (#47063)
Summary:
Currently, tests on components that use the `AccessibilityInfo.announceForAccessibilityWithOptions` method fail because a mock for this method is not present in the `jest` setup file. This PR adds the mock for the before mentioned method in the appropriate `setup.js` file
## Changelog:
[General][Added] - Added the missing `announceForAccessibilityWithOptions` function mock in the `packages/react-native/jest/setup.js` file.

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

Test Plan:
Here are the commands I executed after making the modification:
- `yarn prettier`
- `yarn lint`
- `yarn test`
### Test output
![rn-tests-output](https://github.com/user-attachments/assets/81e9772e-37ce-43ad-9869-5f7f64c292f0)

Reviewed By: tdn120

Differential Revision: D64495941

Pulled By: lunaleaps

fbshipit-source-id: 6ab835e2934b87ec3ac64cf0aebd8dcb58cd0da1
2024-10-17 09:20:32 -07:00
Alex Hunt
52ea8b07e2 Specify package manager version for project (#47091)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47091

Prompted by https://github.com/facebook/react-native/pull/47083, this change adds a `"packageManager"` field to the root `package.json` specifying `yarn@1.22.22`. This will configure a compatible, predictable version of Yarn for users using [Corepack](https://nodejs.org/api/corepack.html) via the Yarn Modern install process.

See https://yarnpkg.com/getting-started/install and https://nodejs.org/api/corepack.html.

Tested on a fresh system (GitHub Codespaces).

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D64536673

fbshipit-source-id: 535c0ca725172e4a06de04b19c6cd2d31788f5a4
2024-10-17 07:55:07 -07:00
Riccardo Cipolleschi
f1d2331dfb We use the right filename as hash in CI cache key (#47087)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47087

In the repo, we don't have a `build-apple-framewroks.sh` file, but we do have a `build-apple-framewrok.sh` file, with no ending `s`

## Changelog:
[Internal] - Fix CI cache key

Reviewed By: cortinico

Differential Revision: D64531456

fbshipit-source-id: 05c104390b875eeef2cf15f8a30c8672cfc9b61d
2024-10-17 07:47:51 -07:00