Commit Graph

12270 Commits

Author SHA1 Message Date
Thomas Nardone 7cfb19e7e3 Add ReactBuildConfig.ENABLE_PERFETTO (#48981)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48981

Add entry for this flag in ReactBuildConfig

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D68725330

fbshipit-source-id: afce4093665ba0c78f4630ab412297219f65d157
2025-01-31 10:02:12 -08:00
Mateo Guzmán 491ede6404 Migrate com.facebook.react.packagerconnection interfaces to Kotlin (#49025)
Summary:
Migrate com.facebook.react.packagerconnection interfaces to Kotlin. Also, moving to `org.mockito.kotlin` instead of `org.mockito.Mockito` for JSPackagerClientTest to make it compatible with the migrated files.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.packagerconnection interfaces to Kotlin

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

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: cortinico, Abbondanzo

Differential Revision: D68842336

Pulled By: tdn120

fbshipit-source-id: c3062675b5535277970fd97490720739fc748f2a
2025-01-31 09:19:52 -08:00
Nicola Corti d37a8d2830 Convert com.facebook.react.devsupport.inspector to Kotlin (#49087)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49087

I'm moving the whole module to be in Kotlin and updating the BUCK file.
Those files also have 0 usages in OSS so not a breaking change.

Changelog:
[Internal] [Changed] -

Reviewed By: robhogan

Differential Revision: D68953731

fbshipit-source-id: d8238bf805661cbdd6fb070a60f3e32b44ec9832
2025-01-31 07:50:28 -08:00
Jakub Piasecki c3ea606660 Align TextInput types with TypeScript (#48972)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48972

Changelog: [Internal]

Align TextInput types with TypeScript definitions.

Reviewed By: huntie

Differential Revision: D68713179

fbshipit-source-id: bb36d9333e45f2a30db91a17b8698b34cd792eb6
2025-01-31 04:54:42 -08:00
Jakub Piasecki e815fdae53 Align TextInput event types with TypeScript (#48971)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48971

Changelog: [Internal]

Mosltly align event types of TextInput components with TypeScript definitions.

Reviewed By: mellyeliu, thatmichael85

Differential Revision: D68713180

fbshipit-source-id: d8e9c0458466ef492fecf516fd58bc5459b35e26
2025-01-31 04:54:42 -08:00
Alex Hunt 21541b51b3 Apply stripPrivateProperties transform to public-api-test (#49064)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49064

Update `public-api-test` to disregard all object/type members prefixed with an underscore (`_`). These are considered existing internal APIs.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D68895376

fbshipit-source-id: db581df7cc37802fa5f7d3aa4d7c07514223209a
2025-01-31 04:27:13 -08:00
Rubén Norte 3d4906e7ec Optimize data structure to store listeners in EventTarget (#48964)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48964

Changelog: [internal]

This replaces the data structure used to store listeners in `EventTarget`, from a map of arrays to a map of maps.

This essentially optimizes listener registration/deregistraton at the expense of event dispatching. Given that it'll be common to have many nodes registering to events that are never dispatched, this might be the right trade-off.

* Before:

| (index) | Task name                                                             | Latency average (ns)  | Latency median (ns)    | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | --------------------------------------------------------------------- | --------------------- | ---------------------- | -------------------------- | ------------------------- | ------- |
| 0       | 'dispatchEvent, no bubbling, no listeners'                            | '4624.68 ± 0.49%'     | '4570.00'              | '218089 ± 0.02%'           | '218818'                  | 216232  |
| 1       | 'dispatchEvent, no bubbling, single listener'                         | '5771.34 ± 0.99%'     | '5670.00'              | '175389 ± 0.02%'           | '176367'                  | 173270  |
| 2       | 'dispatchEvent, no bubbling, multiple listeners'                      | '48207.35 ± 1.18%'    | '47290.00'             | '20964 ± 0.04%'            | '21146'                   | 20744   |
| 3       | 'dispatchEvent, bubbling, no listeners'                               | '185005.29 ± 0.16%'   | '184060.00'            | '5410 ± 0.05%'             | '5433'                    | 5406    |
| 4       | 'dispatchEvent, bubbling, single listener per target'                 | '286630.57 ± 0.11%'   | '285560.00'            | '3491 ± 0.06%'             | '3502'                    | 3489    |
| 5       | 'dispatchEvent, bubbling, multiple listeners per target'              | '4435944.62 ± 0.27%'  | '4425840.00 ± 30.00'   | '226 ± 0.12%'              | '226'                     | 1000    |
| 6       | 'addEventListener, one listener'                                      | '1734.88 ± 0.57%'     | '1670.00'              | '594938 ± 0.01%'           | '598802'                  | 576411  |
| 7       | 'addEventListener, one target, one type, multiple listeners'          | '266031.11 ± 0.68%'   | '261810.00'            | '3781 ± 0.15%'             | '3820'                    | 3759    |
| 8       | 'addEventListener, one target, multiple types, one listener per type' | '124768.56 ± 0.39%'   | '121160.00'            | '8112 ± 0.16%'             | '8254'                    | 8015    |
| 9       | 'addEventListener, one target, multiple types, multiple listeners'    | '27141326.31 ± 0.15%' | '27298945.00 ± 115.00' | '37 ± 0.15%'               | '37'                      | 1000    |
| 10      | 'addEventListener, multiple targets, one type, one listener'          | '142646.24 ± 0.49%'   | '137460.00'            | '7123 ± 0.19%'             | '7275'                    | 7011    |

* After:

| (index) | Task name                                                             | Latency average (ns)  | Latency median (ns)   | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | --------------------------------------------------------------------- | --------------------- | --------------------- | -------------------------- | ------------------------- | ------- |
| 0       | 'dispatchEvent, no bubbling, no listeners'                            | '4518.27 ± 0.51%'     | '4460.00'             | '223269 ± 0.02%'           | '224215'                  | 221324  |
| 1       | 'dispatchEvent, no bubbling, single listener'                         | '6563.10 ± 0.98%'     | '6450.00'             | '154311 ± 0.02%'           | '155039'                  | 152367  |
| 2       | 'dispatchEvent, no bubbling, multiple listeners'                      | '65429.69 ± 0.25%'    | '64840.00'            | '15330 ± 0.05%'            | '15423'                   | 15284   |
| 3       | 'dispatchEvent, bubbling, no listeners'                               | '181104.21 ± 0.13%'   | '180300.00'           | '5525 ± 0.05%'             | '5546'                    | 5522    |
| 4       | 'dispatchEvent, bubbling, single listener per target'                 | '367231.05 ± 0.10%'   | '366035.00 ± 5.00'    | '2724 ± 0.07%'             | '2732'                    | 2724    |
| 5       | 'dispatchEvent, bubbling, multiple listeners per target'              | '6269141.58 ± 0.24%'  | '6253275.00 ± 155.00' | '160 ± 0.11%'              | '160'                     | 1000    |
| 6       | 'addEventListener, one listener'                                      | '1665.23 ± 0.51%'     | '1610.00'             | '618122 ± 0.01%'           | '621118'                  | 600517  |
| 7       | 'addEventListener, one target, one type, multiple listeners'          | '97724.12 ± 1.34%'    | '94640.00'            | '10433 ± 0.14%'            | '10566'                   | 10233   |
| 8       | 'addEventListener, one target, multiple types, one listener per type' | '116915.60 ± 0.54%'   | '113380.00'           | '8707 ± 0.17%'             | '8820'                    | 8554    |
| 9       | 'addEventListener, one target, multiple types, multiple listeners'    | '12276537.38 ± 0.42%' | '11924070.00 ± 10.00' | '82 ± 0.35%'               | '84'                      | 1000    |
| 10      | 'addEventListener, multiple targets, one type, one listener'          | '133307.67 ± 0.58%'   | '128340.00'           | '7666 ± 0.20%'             | '7792'                    | 7502    |

Reviewed By: rshest

Differential Revision: D68671944

fbshipit-source-id: 1a555ba9400e5830b4a56cdf12fd9418cd4a2a4f
2025-01-31 04:00:31 -08:00
Rubén Norte 1f8ace8cce Expand benchmarks for EventTarget to include perf for addEventListener (#49070)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49070

Changelog: [internal]

Adds benchmarks for `addEventListener` in benchmark file for `EventTarget`.

Baseline:

| (index) | Task name                                                             | Latency average (ns)  | Latency median (ns)    | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | --------------------------------------------------------------------- | --------------------- | ---------------------- | -------------------------- | ------------------------- | ------- |
| 0       | 'dispatchEvent, no bubbling, no listeners'                            | '4624.68 ± 0.49%'     | '4570.00'              | '218089 ± 0.02%'           | '218818'                  | 216232  |
| 1       | 'dispatchEvent, no bubbling, single listener'                         | '5771.34 ± 0.99%'     | '5670.00'              | '175389 ± 0.02%'           | '176367'                  | 173270  |
| 2       | 'dispatchEvent, no bubbling, multiple listeners'                      | '48207.35 ± 1.18%'    | '47290.00'             | '20964 ± 0.04%'            | '21146'                   | 20744   |
| 3       | 'dispatchEvent, bubbling, no listeners'                               | '185005.29 ± 0.16%'   | '184060.00'            | '5410 ± 0.05%'             | '5433'                    | 5406    |
| 4       | 'dispatchEvent, bubbling, single listener per target'                 | '286630.57 ± 0.11%'   | '285560.00'            | '3491 ± 0.06%'             | '3502'                    | 3489    |
| 5       | 'dispatchEvent, bubbling, multiple listeners per target'              | '4435944.62 ± 0.27%'  | '4425840.00 ± 30.00'   | '226 ± 0.12%'              | '226'                     | 1000    |
| 6       | 'addEventListener, one listener'                                      | '1734.88 ± 0.57%'     | '1670.00'              | '594938 ± 0.01%'           | '598802'                  | 576411  |
| 7       | 'addEventListener, one target, one type, multiple listeners'          | '266031.11 ± 0.68%'   | '261810.00'            | '3781 ± 0.15%'             | '3820'                    | 3759    |
| 8       | 'addEventListener, one target, multiple types, one listener per type' | '124768.56 ± 0.39%'   | '121160.00'            | '8112 ± 0.16%'             | '8254'                    | 8015    |
| 9       | 'addEventListener, one target, multiple types, multiple listeners'    | '27141326.31 ± 0.15%' | '27298945.00 ± 115.00' | '37 ± 0.15%'               | '37'                      | 1000    |
| 10      | 'addEventListener, multiple targets, one type, one listener'          | '142646.24 ± 0.49%'   | '137460.00'            | '7123 ± 0.19%'             | '7275'                    | 7011    |

Reviewed By: lenaic

Differential Revision: D68708145

fbshipit-source-id: b3f2f1f9e239856dcc9d8e699edf4ed2ada404dd
2025-01-31 04:00:31 -08:00
Nicola Corti 64c2a52ca9 Remove unnecessary public keyword (#49062)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49062

Another round of cleanup for the `public` keyword that I found around.
Those are unnecessary here as those classes are `internal` and we should remove them.

Changelog:
[Internal] [Changed] -

Reviewed By: mdvacca

Differential Revision: D68894182

fbshipit-source-id: 6f7bac6051e17785a1bfb0d544950250429c71cb
2025-01-30 14:13:57 -08:00
Nicola Corti 9afa3596cb Make DevSettingsActivity internal (#49073)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49073

This activity should be internal as it's exposed by ReactNative's Debug Manifest.
No need to have it public. I checked that there are no OSS usages of it:

https://www.google.com/url?q=https://github.com/search?type%3Dcode%26q%3DNOT%2Bis%253Afork%2BNOT%2Borg%253Afacebook%2BNOT%2Brepo%253Areact-native-tvos%252Freact-native-tvos%2BNOT%2Brepo%253Anuagoz%252Freact-native%2BNOT%2Brepo%253A2lambda123%252Freact-native%2BNOT%2Brepo%253Apvinis%252Freact-native---investigation%2BNOT%2Brepo%253Abeanchips%252Ffacebookreactnative%2BNOT%2Brepo%253AfabOnReact%252Freact-native-notes%2BNOT%2Buser%253Ahuntie%2Bcom.facebook.react.devsupport.DevSettingsActivity&sa=D&source=editors&ust=1738261498882961&usg=AOvVaw295OXKV-8dAbdsMTY5usSx

Changelog:
[Internal] [Changed] -

Reviewed By: mdvacca

Differential Revision: D68904656

fbshipit-source-id: b98b417e60a3e8ebba0c9946959ee43ea963b066
2025-01-30 12:21:54 -08:00
Alex Hunt 9ba4dd81db Delete Libraries/JSInspector (#49019)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49019

Removes the `JSInspector` class and its dependencies.

- This was related to the legacy `ReactCommon/inspector/` subsystem (D4021490) — which added a compat layer from JavaScriptCore to CDP for an earlier version of Chrome debugging.
- The JS components of this system (`JSInspector.js`, `NetworkAgent.js`) were added in D4021516.

`ReactCommon/inspector/` has since been deleted and these components are no longer load bearing.

- We intend to replace this logic (at least, the archaic `XHRInterceptor` behaviour, which worked at one point) with native debugger `Network` domain support in our C++ layer.

**Changes**

- Remove all modules under `Libraries/JSInspector/`.
- Remove all `XHRInterceptor` call sites.
- Remove the `JSInspector.registerAgent()` mount point in `setUpDeveloperTools.js`.
- Exclude `Libraries/Core/setUp*` from `public-api-test` (these are side-effect setup files with no exported API).

Changelog:
[General][Breaking] - Remove legacy Libraries/JSInspector modules

Reviewed By: christophpurrer

Differential Revision: D68780147

fbshipit-source-id: 3d11cc89886a91055e6b69ac6f0609c288965801
2025-01-30 11:30:05 -08:00
Jorge Cabiedes Acosta accde40e1b Fix gapbetween making backgroundColor render when width/height is 0 (#49074)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49074

This used to not be noticeable when we were clipping the background even without a border, after fixing that, we got line when the width/height was 0

This is again not an issue with new Background and Border since they take a slightly different approach

Diff that caused the issue D68279400

ie.
 {F1974794589}

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D68843649

fbshipit-source-id: a25ace46b604690e3385c49d6f4bb3a4163bc594
2025-01-30 11:04:19 -08:00
Vitali Zaidman 566a45e28c adjust rntester readme to use "yarn prepare-ios" (#49067)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49067

## Changelog:

[Internal] [Fixed] - fixed rntester readme to guide users to launch the correct ios prepare command

Reviewed By: cipolleschi

Differential Revision: D68897627

fbshipit-source-id: 93d30b2728f452e27448d0ef468ee148296f2324
2025-01-30 08:45:24 -08:00
Iwo Plaza 8783196ee5 Migrate files in Libraries/EventEmitter and Libraries/Image to use export syntax (#49020)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49020

## Motivation
Modernising the RN codebase to allow for modern Flow tooling to process it.

## This diff
- Migrates the `Libraries/EventEmitter/*.js` and `Libraries/Image/*.js` files to use the `export` syntax.
- Updates deep-imports of these files to use `.default`
- Updates the current iteration of API snapshots (intended).

Changelog:
[General][Breaking] - Deep imports to modules inside `Libraries/EventEmitter` and `Libraries/Image/*.js` with `require` syntax need to be appended with '.default'.

Reviewed By: huntie

Differential Revision: D68780876

fbshipit-source-id: bd8e702aba33878e38df6d9c89bec27e7c8df0ac
2025-01-30 07:27:03 -08:00
Rubén Norte 82cc465645 Clean up disableEventLoopOnBridgeless feature flag (#49065)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49065

Changelog: [internal]

Cleaning up the flag because it's no longer necessary.

Reviewed By: sammy-SC

Differential Revision: D68892995

fbshipit-source-id: 4e0290bfb11181dc388e6590af1b82581588b9ee
2025-01-30 07:20:52 -08:00
Iwo Plaza 4101a2f0b6 Add compat layer for react-native-codegen and processColorArray (#49063)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49063

## Motivation
Modernising the RN codebase to allow for modern Flow tooling to process it.

## This diff
- Updates react-native-codegen to generate ViewConfigs that are compatible with react-native both before and after the export syntax migration.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D68894819

fbshipit-source-id: fca46c1b91c15e22f1e1128ce8621c05341e2fe6
2025-01-30 07:16:54 -08:00
Rubén Norte 105e3ab837 Implement additional traversal methods on ReactNativeDocument (#49013)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49013

Changelog: [internal]

Adds `Document`-specific traversal methods to `ReactNativeDocument`:
* `childElementCount`
* `children`
* `firstElementChild`
* `lastElementChild`

Reviewed By: yungsters

Differential Revision: D67693032

fbshipit-source-id: 1e3279586ece809c5c3584279c07f991cadf0fc6
2025-01-30 07:11:43 -08:00
Rubén Norte 2436e3ba84 Implement ReactNativeDocument (#49012)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49012

Changelog: [internal]

(This is internal for now, until we rollout the DOM APIs in stable).

This refines the concept of root elements from the merged proposal for [DOM Traversal & Layout APIs](https://github.com/react-native-community/discussions-and-proposals/blob/main/proposals/0607-dom-traversal-and-layout-apis.md).

The original proposal included a reference to have the root node in the tree as `getRootNode()` and no other methods/accessors to access it.

This makes the following changes:
* The root node is a new abstraction in React Native implementing the concept of `Document` from Web. `node.getRootNode()`, as well as `node.ownerDocument` now return instances to this node (except when the node is detached, in which case `getRootNode` returns the node itself, aligning with the spec).
* The existing root node in the shadow tree is exposed as the `documentElement` of the new document instance. It would be the first and only child of the document instance, and the topmost parent of all the host nodes rendered in the tree.

In terms of APIs:
* Implements `getRootNode` correctly, according to the specified semantics.
* Adds `ownerDocument` to the `ReadOnlyNode` interface.
* Adds the `ReactNativeDocument` interface, which extends `ReadOnlyNode` (with no new methods on its own, which will be added in a following PR).

NOTE: This is currently gated under `ReactNativeFeatureFlags.enableDOMDocumentAPI` feature flag, which is disabled by default.

Reviewed By: yungsters

Differential Revision: D67526381

fbshipit-source-id: dff3645469e7ea2b2026dbbaa94d9fd0e00291be
2025-01-30 07:11:43 -08:00
Rubén Norte 3dab9c66ba Expose new method in Fabric renderer to access root instance from root tag (#49011)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49011

Changelog: [internal]

This exposes the new `getPublicInstanceFromRoot` method from the React renderer in our RN façades, preparing for the new change to implement the document interface in RN.

Reviewed By: javache

Differential Revision: D68767143

fbshipit-source-id: 9a3403f9bc1612b402305695d084497a46ee4480
2025-01-30 07:11:43 -08:00
Rubén Norte 8f7f3be9af Add support for document instance in React Native (#32260) (#49051)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49051

## Summary

We're adding support for `Document` instances in React Native (as
`ReactNativeDocument` instances) in
https://github.com/facebook/react-native/pull/49012 , which requires the
React Fabric renderer to handle its lifecycle.

This modifies the renderer to create those document instances and
associate them with the React root, and provides a new method for React
Native to access them given its containerTag / rootTag.

## How did you test this change?

Tested e2e in https://github.com/facebook/react-native/pull/49012
manually syncing these changes.

DiffTrain build for [b2357ecd8203341a3668a96d32d68dd519e5430d](https://github.com/facebook/react/commit/b2357ecd8203341a3668a96d32d68dd519e5430d)

Reviewed By: javache

Differential Revision: D68839346

fbshipit-source-id: 589ddce15d0f32ba3eab1c03306c405d38616723
2025-01-30 07:11:43 -08:00
Iwo Plaza 4d6785bdb5 Migrate LayoutAnimation and Linking libraries to use export syntax (#49021)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49021

## Motivation
Modernising the RN codebase to allow for modern Flow tooling to process it.

## This diff
- Migrates files in `Libraries/LayoutAnimation/*.js` and `Libraries/Linking/*.js` to use the `export` syntax.
- Updates deep-imports of these files to use `.default`
- Updates jest mocks
- Updates the current iteration of API snapshots (intended).

Changelog:
[General][Breaking] - Deep imports to modules inside `Libraries/LayoutAnimation` and `Libraries/Linking` with `require` syntax need to be appended with '.default'.

Reviewed By: huntie

Differential Revision: D68782429

fbshipit-source-id: c9ea4fadbc44587a165d311b054fcd03444842c8
2025-01-30 07:07:08 -08:00
Alex Hunt 45a2d9c5a8 Delete deprecated YellowBox API (#49061)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49061

Changelog:
[General][Breaking] - Remove deprecated `YellowBox` and `console.ignoredYellowBox` APIs. Use `LogBox`.

Reviewed By: cortinico, hezi

Differential Revision: D68893550

fbshipit-source-id: 5030a20a2d1a60ca37eaf928339b8dd5d5abaa27
2025-01-30 06:49:13 -08:00
Rubén Norte 252294bc76 Improve naming for benchmark suite options (#49014)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49014

Changelog: [internal]

Use better names for the Fantom benchmarking API than the ones defined in `tinybench`:
* `time` => `minDuration`
* `iterations` = `minIterations`
* `warmupTime` => `minWarmupDuration`
* `warmupIterations` => `minWarmupIterations`

Reviewed By: rshest

Differential Revision: D68710952

fbshipit-source-id: 05dc1145a72a50ea73de7ccbb08bb28d7975245f
2025-01-30 03:24:39 -08:00
Tommy Nguyen ee8088b615 fix(dev-middleware): add missing invariant dependency (#49047)
Summary:
`dev-middleware` uses `invariant` but does not declare it as a dependency. Under certain hoisting scenarios, or when using pnpm, this will cause `dev-middleware` to fail while being loaded.

## Changelog:

[GENERAL] [FIXED] - add missing `invariant` dependency

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

Test Plan: n/a

Reviewed By: cortinico

Differential Revision: D68835789

Pulled By: huntie

fbshipit-source-id: 13718f4970ed55e6e062b7c2bd719be977abdd0c
2025-01-30 01:58:27 -08:00
David Vacca 40575f26d2 Internalize ReactBridge (#49049)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49049

ReactBridge can be internalize, there are no usages in OSS

changelog: [internal] internal

Reviewed By: NickGerleman

Differential Revision: D68540710

fbshipit-source-id: ce7fe6ca52186414650dcc529c5891dc59cab51a
2025-01-29 17:32:25 -08:00
Erica Klein 04afbd90e6 Back out "Fabric: Fixes crash of dynamic color when light/dark mode changed" (#49054)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49054

Original commit changeset: 01959845b742

Original Phabricator Diff: D68157559

Reviewed By: javache

Differential Revision: D68861984

fbshipit-source-id: c2e6fcf5d626447bd658b047adbb64947c2a5266
2025-01-29 15:55:32 -08:00
Rubén Norte 2c406d8b49 Remove logged errors for feature flags not implemented in native when skipNativeAPI is used (#49050)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49050

Changelog: [internal]

We added support for feature flags that don't have a native module definition so we could handle cases where the JS changes progressed faster than native ones, but we recently saw that when native catches up, the API starts logging an error through `console.error` about the native module method not being available.

That's an expected result of this feature and it's when we can clean up the code in JS, so we shouldn't be logging errors in that case.

This removes the error for them specifically.

Reviewed By: elicwhite

Differential Revision: D68843247

fbshipit-source-id: 730f3eba8c26959825cd9c3897f055a02a5f9591
2025-01-29 12:17:45 -08:00
Rubén Norte 17c34295a1 Migrate mounting tests to Fantom (#49018)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49018

Changelog: [internal]

Migrates the mounting layer logs from C++ (640 lines of code) to Fantom (248 lines!!!).

This is 1:1 translation of the test.

Reviewed By: javache

Differential Revision: D67549200

fbshipit-source-id: 735fa3203cd04dd5b3b4b5174e0c96fdc2354993
2025-01-29 11:31:51 -08:00
Rubén Norte bb24ad0397 Print nativeID in debug props for Props (#49017)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49017

Changelog: [internal]

The debug string for props doesn't log `nativeID` so we can't access it in Fantom. This fixes that to simply future tests.

Reviewed By: javache

Differential Revision: D68779903

fbshipit-source-id: 9800ef2b6d173e2fc8e21d3d910139a30ae91342
2025-01-29 11:31:51 -08:00
Rubén Norte 9c521bb68c Improve format of mounting logs (#49016)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49016

Changelog: [internal]

This replaces the existing string-based logs with something more structured, and increases the coverage to properly log all operations.

As part of this work I had to refactor how we record mutations so they would be done while applying the mutations, and not before/after where necessary metadata might not be available yet/anymore.

Reviewed By: sammy-SC

Differential Revision: D67549201

fbshipit-source-id: 0bcb1642a6b3d7e704f4ee24a550d4189c406aed
2025-01-29 11:31:51 -08:00
Rubén Norte fb9b476d12 Rename getMountingLogs as takeMountingManagerLogs (#49015)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49015

Changelog: [internal]

This name better reflects the fact that we're emptying the buffer when calling it.

Reviewed By: javache

Differential Revision: D67549202

fbshipit-source-id: 7523a130f26bced122acd4f50b45c2b61a39bba9
2025-01-29 11:31:51 -08:00
Christoph Purrer 67981efa14 Fix Turbo Module example in RNTester in bridgeless mode (#49028)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49028

## Changelog: [General] [Fixed]] - Fix Turbo Module example in RNTester in bridgeless mode

Reviewed By: cortinico, philIip

Differential Revision: D68810934

fbshipit-source-id: 5eab0e72fe383974fe02747acd1683a995300d4d
2025-01-29 11:06:49 -08:00
Rubén Norte a8bf742f29 Unbreak Flow
Summary:
Changelog: [internal]

Fixes broken Flow check after some files were moved.

bypass-github-export-checks

Reviewed By: elicwhite

Differential Revision: D68844033

fbshipit-source-id: edf5bc58c5ce94ef5c089998b52a4bb72a2d3997
2025-01-29 11:05:03 -08:00
Rubén Norte ea1260accb Set up test to validate refactor of XHR, FileReader and WebSocket classes to use the built-in EventTarget implementation (#48930)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48930

Changelog: [internal]

This creates new versions of `XMLHttpRequest`, `FileReader` and `WebSocket` that extend the new built-in `EventTarget` implementation, instead of the implementation from the `event-target-shim` package.

It also sets up a test to choose between the 2 implementations at runtime to verify correctness and performance. This doesn't use the RN feature flags infra because we use this flag very early on startup, before we have a chance to set overrides. We could use a native feature flag instead but it'd slow down the rollout of the test.

Reviewed By: yungsters

Differential Revision: D68625226

fbshipit-source-id: bff715c43a237b65d5a02a3fdb56f3275689ea46
2025-01-29 10:06:08 -08:00
Rubén Norte d80284c607 Make some objects read-only in event-related APIs (#49045)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49045

Changelog: [internal]

Making some objects read-only to reflect usage and allow callers to pass both read-only and writable objects.

Reviewed By: yungsters

Differential Revision: D68831136

fbshipit-source-id: e9a2d96ec0abd13f609d26d376e6da946f802011
2025-01-29 10:06:08 -08:00
Rubén Norte 4ba0e79712 Refactor NetworkOverlay to use a symbol instead of a public property in XHR (#48928)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48928

Changelog: [internal]

Just a minor change to reduce the number of Flow errors we will get when we refactor XHR soon.

Reviewed By: javache

Differential Revision: D68625224

fbshipit-source-id: e952f3f52de8081a0773ef3a01e1259c3be67a92
2025-01-29 10:06:08 -08:00
Alex Hunt 389779c348 Move XHRInterceptor to src/private/inspector/ (#49023)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49023

Changelog:
[General][Breaking] - Move `XHRInterceptor` API to `src/private/`

Reviewed By: christophpurrer

Differential Revision: D68781897

fbshipit-source-id: af52f65b0f64da68a78babf326a1a9b8a1fc1d96
2025-01-29 09:56:54 -08:00
Alex Hunt 0bde08fe67 Move Libraries/Inspector/ to src/private/ (#49022)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49022

These modules support the in-app Inspector Overlay.

Breaking change that's unlikely to hit any users. Unreferenced by Expo.

Changelog:
[General][Breaking] Move `Libraries/Inspector/` modules to `src/private/`

Reviewed By: cortinico

Differential Revision: D68781896

fbshipit-source-id: 8fcd72d56684319019f64a375c2e2ef317a47c13
2025-01-29 09:56:54 -08:00
Rubén Norte 8678d15892 Prepare ReactNativePrivateInterface for new React renderer calls to handle root/document nodes (#49010)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49010

Changelog: [internal]

This adds a stub method for `ReactNativePrivateInterface.createPublicRootInstance`, which just returns `null` for now, so we can synchronize the React renderer that will try to use it to create root instances.

Initially, this will not do anything and React will just pass the `null` value around. When we implement the document API, we will return a proper instance and React will pass it to `createPublicInstance` so we can link things at runtime.

Reviewed By: javache

Differential Revision: D68561173

fbshipit-source-id: 632a7c3523910059a1f63f35b5f0f52f5660a961
2025-01-29 09:39:49 -08:00
Rubén Norte 7cdc3d81ad Abstract away use of shadow nodes as native node references (#49009)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49009

Changelog: [internal]

Native APIs so far have returned instance handles from React to reference nodes in the rendered UI tree, but now that we're adding support for the document API, this isn't sufficient to represent all types of nodes. Both for the document and for its `documentElement`, we don't have an instance handle from React that links to the node, but we're going to represent that differently.

This is a refactor so the existing methods use a mostly opaque `NativeNodeReference` type so we can implement it as a union of React instance handles and the future types we're going to introduce to support document.

Reviewed By: javache

Differential Revision: D67704855

fbshipit-source-id: 0568143d9ce39be65986e1a4b92fdaebd79e4f66
2025-01-29 09:39:49 -08:00
Rubén Norte 591b0ffc0e Add basic benchmarks for rendering views (#49008)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49008

Changelog: [internal]

We're modifying some core APIs in the RN render in following diffs, so this adds a simple benchmark as a safety mechanism to verify those don't regress performance significantly.

Reviewed By: yungsters

Differential Revision: D68772175

fbshipit-source-id: 3bc446e68495dc04590b613297baa00589fb5f8d
2025-01-29 09:39:49 -08:00
Rickard Zrinski 97cf42f979 Fix maxFontSizeMultiplier prop on Text and TextInput components in new architecture (#47614)
Summary:
The `maxFontSizeMultiplier` prop for `Text` and `TextInput` was not handled in Fabric / New Architecture as documented in https://github.com/facebook/react-native/issues/47499.

bypass-github-export-checks

## Changelog:

[GENERAL] [FIXED] - Fix `maxFontSizeMultiplier` prop on `Text` and `TextInput` components in Fabric / New Architecture

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

Test Plan:
I have not added any automated tests for this change but try to do so if requested. I have however added examples to RN Tester for both the Text and TextInput components, as well as compared the behaviour with Paper / Old Architecture. Both on version 0.76.

Noticed now I didn't do exactly the same steps in both videos, oops! Be aware that reapplying changes made in the Settings are currently half-broken on the new architecture, thus I'm restarting the app on Android and iOS. But this issue is unrelated to my changes. I've tested on main branch and it has the same issue.

Here are comparison videos between Paper and Fabric on iOS *after* I've made my fix.

### Text
| Paper  | Fabric |
| ------------- | ------------- |
| <video src="https://github.com/user-attachments/assets/f4fd009f-aa6d-41ab-92fa-8dcf1e351ba1" /> | <video src="https://github.com/user-attachments/assets/fda42cc6-34c2-42a7-a6e2-028e7c866075" /> |

### TextInput
| Paper  | Fabric |
| ------------- | ------------- |
| <video src="https://github.com/user-attachments/assets/59b59f7b-25d2-4b5b-a8e2-d2054cc6390b" /> | <video src="https://github.com/user-attachments/assets/72068566-8f2a-4463-874c-45a6f5b63b0d" /> |

Reviewed By: Abbondanzo

Differential Revision: D65953019

Pulled By: cipolleschi

fbshipit-source-id: 90c3c7e236229e9ad9bd346941fafe4af8a9d9fc
2025-01-29 09:27:44 -08:00
Alex Hunt 97ee93fd5a Add Content-Type header to dev server requests (#49042)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49042

Minor fix to align with adjacent `/open-stack-frame` call: https://fburl.com/code/o9rwbmxr.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D68830215

fbshipit-source-id: 87ef0c14bdedd34153014721b85bd24af24c1db7
2025-01-29 09:18:46 -08:00
Pieter De Baets 26afc804b7 Error when tests finish with pending tasks (#49032)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49032

Add a native API to validate the RuntimeScheduler has no pending tasks, and automatically validate after every test that there's no pending tasks left to execute.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D68797481

fbshipit-source-id: dbbef894a57bd29eb5a033ac8aaeedef770dcba2
2025-01-29 08:49:49 -08:00
Mateo Guzmán 2f6cb8ba08 Migrate com.facebook.react.uimanager.layoutanimation interfaces to Kotlin (#49026)
Summary:
Migrate com.facebook.react.uimanager.layoutanimation interfaces to Kotlin

## Changelog:

[INTERNAL] - Migrate com.facebook.react.uimanager.layoutanimation interfaces to Kotlin

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

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: NickGerleman

Differential Revision: D68794415

Pulled By: Abbondanzo

fbshipit-source-id: 690d69e8360fb51eb0232b2ed2b4676e0d1a9ee6
2025-01-29 07:09:04 -08:00
Pieter De Baets e4d1cf8ce9 Delete RawProps assignment operators (#49030)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49030

Overwriting another RawProps object via `operator=` is rarely what we want, and these objects should be considered immutable once constructed.

This will catch issues such as D68633985

Changelog: [General][Changed] Removed `RawProps::operator=`

Reviewed By: sammy-SC

Differential Revision: D68797484

fbshipit-source-id: 766a65db1dbf4485c78007f8f69cc9426d27a943
2025-01-29 06:16:20 -08:00
Jakub Piasecki 5d7fedacd0 Add flow definitions for Alert and align them with TypeScript (#49006)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49006

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D68774525

fbshipit-source-id: 509f26b0f5f0d309502681f3228ae519689d480a
2025-01-29 05:36:53 -08:00
Jakub Piasecki df6be9f665 Use alert to test type generation prototype (#49038)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49038

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D68774524

fbshipit-source-id: 791da64babebc8d08f671262fa63f67aff2c0942
2025-01-29 05:36:53 -08:00
Pieter De Baets 90c6f7eab8 Fix ScrollEvent DebugStringCovertible (#49029)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49029

This was never being compiled, because we didn't import the header that set `RN_DEBUG_STRING_CONVERTIBLE`

Will look at enabling `-Wundef` to catch these.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D68797482

fbshipit-source-id: 6a01192c799903b6f956f9b0acea94bd93183f3b
2025-01-29 05:05:04 -08:00
Nicola Corti 6307fe869f Remove unused methods from TurboModulePerfLogger (#49033)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49033

Those methods are not used at all in the codebase, let's clean them up.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D68826893

fbshipit-source-id: 36e2f0ae247ed72305c1d9d346c6cf32cef6f8f2
2025-01-29 05:04:27 -08:00