Commit Graph

12270 Commits

Author SHA1 Message Date
Rubén Norte b28ab79f1b Make constants in Event more spec compliant (#48918)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48918

Changelog: [internal]

Makes the constants read-only and accessible through `Event.prototype` as well.

Reviewed By: yungsters

Differential Revision: D67830012

fbshipit-source-id: 730622a642f08f532cebd4c183d859ccb2ca0641
2025-01-27 07:48:50 -08:00
Rubén Norte e04e502f77 Further optimizations for event dispatching (#48426)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48426

Changelog: [internal]

This improves the performance of DOM `Event` interface implementation by migrating away from private fields.

Reviewed By: yungsters

Differential Revision: D67751821

fbshipit-source-id: e58e5a9cbb04e7d91cbc676ec7d1b00fff357e2e
2025-01-27 07:48:50 -08:00
Rubén Norte 47e490f084 Make EventTarget compatible with the existing implementation of ReadOnlyNode (#48427)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48427

Changelog: [internal]

The `ReactNativeElement` class was refactored for performance reasons, and the current implementation does **NOT** call `super()`, and it inlines the parent constructor instead.

When it eventually extends `EventTarget`, things won't work as expected because the existing `EventTarget` implementation has constructor dependencies.

This refactors the current implementation of `EventTarget` to eliminate those constructor side-effects, and eliminates the constructor altogether.

This breaks encapsulation, but it has some positive side-effects on performance:
1. Creating `EventTarget` instances is faster because it has no constructor logic.
2. Improves memory by not creating maps to hold the event listeners if no event listeners are ever added to the target (which is very common).
3. Improves the overall runtime performance of the methods in the class by migrating away from private methods (which are known to be slow on the babel transpiled version we're currently using).

Extra: it also simplifies making window/the global scope implement the EventTarget interface :)

## Benchmark results

Before:

| Latency average (ns) | Latency median (ns) | Samples | Task name                                              | Throughput average (ops/s) | Throughput median (ops/s) |
| ---|--- |--- |--- |---|---|
| 8234.22 ± 0.27%      | 8132.00             | 121445  | dispatchEvent, no bubbling, no listeners               | 122323 ± 0.02%             | 122971                   |
| 9001.22 ± 0.41%      | 8883.00             | 111097  | dispatchEvent, no bubbling, single listener            | 111981 ± 0.02%             | 112575                   |
| 51777.94 ± 0.58%     | 51247.00            | 19314   | dispatchEvent, no bubbling, multiple listeners         | 19393 ± 0.04%              | 19513                    |
| 8256.65 ± 0.29%      | 8152.00             | 121115  | dispatchEvent, bubbling, no listeners                  | 122031 ± 0.02%             | 122669                   |
| 9064.32 ± 0.44%      | 8933.00             | 110323  | dispatchEvent, bubbling, single listener per target    | 111265 ± 0.02%             | 111944                   |
| 51879.66 ± 0.27%     | 51447.00            | 19276   | dispatchEvent, bubbling, multiple listeners per target | 19325 ± 0.04%              | 19437               |

After:

| Latency average (ns) | Latency median (ns) | Samples | Task name                                              | Throughput average (ops/s) | Throughput median (ops/s)|
| ---------------------|---------------------|---------|--------------------------------------------------------|----------------------------|--------------------------|
| 5664.62 ± 0.50%      | 5588.00             | 176535  | dispatchEvent, no bubbling, no listeners               | 178219 ± 0.02%             | 178955                   |
| 7232.86 ± 0.50%      | 7131.00             | 138258  | dispatchEvent, no bubbling, single listener            | 139540 ± 0.02%             | 140233                   |
| 50957.51 ± 0.71%     | 50336.00            | 19625   | dispatchEvent, no bubbling, multiple listeners         | 19751 ± 0.04%              | 19866                    |
| 5692.36 ± 0.50%      | 5618.00             | 175675  | dispatchEvent, bubbling, no listeners                  | 177315 ± 0.02%             | 177999                   |
| 7277.82 ± 0.38%      | 7181.00             | 137404  | dispatchEvent, bubbling, single listener per target    | 138560 ± 0.02%             | 139256                   |
| 50493.64 ± 0.28%     | 50105.00            | 19805   | dispatchEvent, bubbling, multiple listeners per target | 19855 ± 0.04%              | 19958                    |

Reviewed By: yungsters

Differential Revision: D67758408

fbshipit-source-id: f8da1788251c9e21377de5ab730875bcc7610361
2025-01-27 07:48:50 -08:00
Rubén Norte 07df02d14d Add regression test for EventTarget (#48431)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48431

Changelog: [internal]

Adds a regression test to make sure we implement the correct spec-compliant behavior for a possible bug in ~~the Web spec~~ __Chrome__: https://github.com/whatwg/dom/issues/1346

Edit: the bug is in the Chrome implementation, not in the spec.

Reviewed By: javache

Differential Revision: D67758702

fbshipit-source-id: ecaeacac3bce286e692880f05d70297ba0c2c736
2025-01-27 07:48:50 -08:00
Rubén Norte 3c50d87d05 Add benchmark for EventTarget (#48886)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48886

Changelog: [internal]

Creates a benchmarks to measure the performance of `EventTarget`.

Reviewed By: javache

Differential Revision: D67750677

fbshipit-source-id: 7023d5f3bcdc5eec1f5f03298781800d2f9bfe16
2025-01-27 07:48:50 -08:00
Rubén Norte e5024a08d1 Implement Event and EventTarget (#48429)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48429

Changelog: [internal]

This implements a (mostly) spec-compliant version of the [`Event`](https://dom.spec.whatwg.org/#interface-event) and [`EventTarget`](https://dom.spec.whatwg.org/#interface-eventtarget) Web interfaces.

It does not implement legacy methods in either of the interfaces, and ignores the parts of the spec that are related to Web-specific quirks (shadow roots, re-mapping of animation events with webkit prefixes, etc.).

IMPORTANT: This only creates the interfaces and does not expose them externally yet (no `Event` or `EventTarget` in the global scope).

Reviewed By: yungsters

Differential Revision: D67738145

fbshipit-source-id: c86db29821552cc1a1b6e1023cc3a21ae55febd5
2025-01-27 07:48:50 -08:00
Thomas Nardone fc98babe3e Nullsafe jcf/react/animated (#48932)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48932

Results of running nullsafe script with `--patch=apply_fixmes`, `--patch=mark_nullsafe`, with minimal manual fixes to get all checks passing.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D68629827

fbshipit-source-id: f9d3e741c634743731bdc2870cdccbf73ab58cc1
2025-01-27 07:21:12 -08:00
Mateo Guzmán bbd1e0ff17 Fix FlatList dark mode examples (#48873)
Summary:
- Fix FlatList Nested and Multicolumn dark mode examples
- Convert MultiColumn example from class to functional component
- Fixing several FlowFixMe annotations for both examples

## Changelog:

[INTERNAL] - Fix FlatList dark mode examples

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

Test Plan:
<details>
<summary>Screenshots</summary>

| Before                           | After                          |
|------------------------------------|------------------------------------|
| ![Image 1](https://github.com/user-attachments/assets/c22cbbc1-26e0-4e6b-a21a-0e0a47a23fc2) | ![Image 2](https://github.com/user-attachments/assets/bea957e5-9633-4d1f-91ed-0f4eac58b723) |
| ![Image 3](https://github.com/user-attachments/assets/0d601cdc-a84d-4b06-9f15-ebf793414f53) | ![Image 4](https://github.com/user-attachments/assets/4b605fa5-98d9-4d62-9108-1f7c7148a445) |

</details>

Reviewed By: cortinico

Differential Revision: D68630288

Pulled By: Abbondanzo

fbshipit-source-id: 41c240e4f8c6e6eacf537d53ab4a06bb0b7ef0de
2025-01-27 07:05:50 -08:00
Matthew Horan c499ae1192 Fixes for Keyboard Observer, KeyboardAvoidingView on iOS (#48131)
Summary:
**Convert keyboard position to window coordinate space on iOS**
The keyboard frame passed to keyboardWillChangeFrame is in the screen's coordinate space [1]. It needs to be converted to the window's coordinate space to support Slide Over and Stage Manager.

[1] https://developer.apple.com/documentation/uikit/uikeyboardframeenduserinfokey?language=objc

|Before|After|
|---|---|
|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 18 58 31](https://github.com/user-attachments/assets/6af21fde-32f1-4b15-83be-09a6dbae8784)|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 19 01 27](https://github.com/user-attachments/assets/c63c2bef-c1a6-4ad4-91cf-74629c26dbb0)|

**Improve detached keyboard detection on iOS**
The iOS keyboard may be in one of three states:
1) floating (previously supported with a width check)
2) split
3) or undocked.

In addition, when using Stage Manager, the keyboard may be wider than the window itself. This would cause the floating keyboard check to incorrectly set the bottom position to zero.

Instead, rely on the fact that the UIKeyboardWillHideNotification notification is sent when the keyboard is in any detached state.

This requires listening for UIKeyboardWillShowNotification instead of UIKeyboardWillChangeFrameNotification. This is fine, since the show notification is also sent when the keyboard resizes while open.

Combined with the coordinate system adjustments in the previous commit, this also fixes an issue with Stage Manager, since the keyboard may be attached yet wider than the application window.

|Before|After|
|---|---|
|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 18 58 40](https://github.com/user-attachments/assets/4e747ece-b084-49ad-a8d6-5dfe623ae597)|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 19 01 41](https://github.com/user-attachments/assets/50391302-4c83-4aa3-a96b-6056bba891ec)|
|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 19 48 19](https://github.com/user-attachments/assets/576691b3-6b84-41cf-87f4-0cf52fc405d4)|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 19 05 33](https://github.com/user-attachments/assets/4bb60ca6-beb3-471e-bc71-38a18fc9c0f1)|
|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 19 48 55](https://github.com/user-attachments/assets/baf456fb-aa61-455b-9c20-a01a6a979cb5)|![Simulator Screenshot - iPad mini (A17 Pro) - 2024-12-05 at 19 05 56](https://github.com/user-attachments/assets/0b7fe954-a72f-407a-bb41-0f47253c9448)|

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[iOS] [FIXED] - Keyboard events are converted to window coordinate space
[iOS] [FIXED] - Improve detached keyboard detection, support Stage Manager on iOS

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

Test Plan: See screenshots above.

Reviewed By: yungsters

Differential Revision: D67337314

Pulled By: cipolleschi

fbshipit-source-id: abe872ac8c83336f316917074f72cdb23a39caab
2025-01-27 06:57:02 -08:00
Riccardo Cipolleschi 4141560afc Call cocoapods passing the RCT_IGNORE_PODS_DEPRECATION flag (#48967)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48967

This change updates the core-cli-utils package to call `pod install` by passing the `RCT_IGNORE_PODS_DEPRECATION` flag.

## Changelog:
[iOS][Changed] - Ignore deprecation warning when calling pod install through core-cli-utils

Reviewed By: cortinico

Differential Revision: D68704956

fbshipit-source-id: 5ce56e3ec8c5718f6403f8871bebf6aceeeb407b
2025-01-27 06:52:35 -08:00
Riccardo Cipolleschi cc1e8d1523 Move running codegen to core-cli-utils (#48965)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48965

Running codegen should not be a Cocoapods responsibilities, but it should be something that runs before Cocoapods to ensure that the code is already in the right place.

This change moves the invocation of Codegen to the react-native's core-cli-utils so that frameworks can integrate better with it.

It should also make it easier to migrate away from Cocoapods.

## Changelog:
[iOS][Changed] - Invoke Codegen as part of the Core-cli-utils package

Reviewed By: cortinico

Differential Revision: D68706136

fbshipit-source-id: 548c9ffad62bc561fcc948babaf75de5dad82f86
2025-01-27 06:52:35 -08:00
Riccardo Cipolleschi 2527d29a96 Update Gemfile (#48966)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48966

In our previous fix for concurrent-ruby, we have been a bit too strict. Version 1.3.4 is a valid and working version. The broken version is 1.3.5.

## Changelog:
[iOS][Changed] - Fix Gemfile versions

Reviewed By: cortinico

Differential Revision: D68706060

fbshipit-source-id: 8ab7a4df0eb83a82603729ff8460e64908ddc465
2025-01-27 06:52:35 -08:00
Riccardo Cipolleschi f15094ef88 Stop running Codegen on Pod install when a flag is passed (#48961)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48961

One of Cocoapods responsibility is to run Codegen while creating the Xcode workspace. Moving away from Cocoapods, this is a step we need to move to a different place.

This change let us to disable running codegen at cocoapods time when we pass the `RCT_SKIP_CODEGEN=1` or when we pass the `RCT_IGNORE_PODS_DEPRECATION=1` flag calling pod install.

When calling `pod install` with `RCT_IGNORE_PODS_DEPRECATION` we are either:
* using one of the Scripts provided by Expo or by the Community CLI
*or*
* we are preparing the project using the legacy mode and, therefore, we want to keep running codegen.

## Changelog
[iOS][Changed] - Stop running codegen when running pod install

Reviewed By: cortinico

Differential Revision: D68704604

fbshipit-source-id: 252e90544886c3dbfd7eff38c344dd4784a0af38
2025-01-27 06:52:35 -08:00
Riccardo Cipolleschi e3def00d7a Warn users when calling pod install (#48960)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48960

We are moving away from Cocoapods toward alternative solution.

We are adding this deprecation message to help inform our users that this change is happening.

Part of the Cocoapods tasks will be moved to an alternative script that will be invoked by Expo and by the Community CLI. The warning message tells the users what to do as an alternative to `pod install`.

## Changelog:
[iOS][Deprecated] - deprecate calling `pod install` directly

Reviewed By: cortinico

Differential Revision: D68704127

fbshipit-source-id: df93008afc055254d0c0da09566c84af99248310
2025-01-27 06:52:35 -08:00
Iwo Plaza bdc23fa2b4 Migrate files in Libraries/Interaction to use export syntax (#48933)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48933

## Motivation
Modernising the react-native codebase to allow for ingestion by modern Flow tooling

## This diff
- Updates files in Libraries/Interaction to use `export` syntax
- Appends `.default` to requires of the changed files.
- Updates the public API snapshot (intented breaking change)

Changelog:
[General][Breaking] - Files inside `Libraries/Interaction` use `export` syntax, which requires the addition of `.default` when imported with the CJS `require` syntax.

Reviewed By: huntie

Differential Revision: D68629953

fbshipit-source-id: 526b18d9b64c4b27b6e3198a9725075fa11e345a
2025-01-27 06:32:58 -08:00
Samuel Susla 0f0344984f ship useOptimisedViewPreallocationOnAndroid everywhere and remove gating (#48903)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48903

changelog: [internal]

Reviewed By: rubennorte

Differential Revision: D68490542

fbshipit-source-id: f743e9c82328c5f06b431cffe77f9a28608535b9
2025-01-27 06:26:35 -08:00
Edmond Chui 46e86dca87 Update tests to support new didOpen delegate fn
Summary:
Changelog: [General][Fixed] Update tests to support new `didOpen` delegate fn

Add support for the new `didOpen` delegate function in tests.

To follow up separately: the borked tear down sequence when these two tests are ran together (they pass when ran individually)

```
buck2 test @//fbobjc/mode/buck2/ios-tests fbsource//xplat/js/react-native-github/packages/react-native/ReactCommon/jsinspector-modern:testsAppleMac -- ReactInstanceIntegrationTest RuntimeTargetDebuggerSessionObserverTest
```

Reviewed By: hoxyq

Differential Revision: D68632974

fbshipit-source-id: 59da6d9e2d09f2c7e219c1902dd6f9b8ddfee9dc
2025-01-27 05:53:15 -08:00
Mateo Guzmán 53d94c3abe Migrate com.facebook.react.modules.network.OkHttpClientFactory to Kotlin (#48945)
Summary:
Migrate com.facebook.react.modules.network.OkHttpClientFactory to Kotlin

## Changelog:

[INTERNAL] - Migrate com.facebook.react.modules.network.OkHttpClientFactory to Kotlin

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

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

Reviewed By: cortinico

Differential Revision: D68705783

Pulled By: arushikesarwani94

fbshipit-source-id: 9c2cc2927eae50d0dce91384bf945a8c795c0bbd
2025-01-27 04:48:22 -08:00
Samuel Susla 1257122a02 introduce Fantom.flushAllNativeEvents (#48943)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48943

changelog: [internal]

A new helper function on Fantom flushAllNativeEvents, which will flush all pending native events.

Reviewed By: javache

Differential Revision: D68566753

fbshipit-source-id: 6cb19416e39807b9b381ff068cea5c2458101174
2025-01-27 04:42:44 -08:00
Samuel Susla aa5760837c introduce Fantom.scrollTo (#48907)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48907

changelog: [internal]

Introduce new function `Fantom.scrollTo`, which will fake a scroll to particular position.
Calling the method will call onScroll event using codepath that iOS uses. It will also set C++ state so the new scroll position is observable from JavaScript.

Reviewed By: javache

Differential Revision: D68554703

fbshipit-source-id: 2fc71e96836a03ec343053ceed85764c4bc2f5c7
2025-01-25 14:58:28 -08:00
Samuel Susla 84b8e6a531 unify Fantom calling convention to Fantom.foo (#48924)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48924

changelog: [internal]

All other Fantom tests are using Fantom.foo style instead of `foo`. Let's unify codebase on this.

Reviewed By: christophpurrer

Differential Revision: D68552829

fbshipit-source-id: eeefc449b1f33161b3583dd68b08f83455d1a959
2025-01-25 14:58:28 -08:00
David Vacca e44b2fa973 Migrate ReactBridge to kotlin (#48904)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48904

Migrate ReactBridge to kotlin

changelog: [internal] internal

Reviewed By: tdn120, cortinico

Differential Revision: D68540709

fbshipit-source-id: 35a6d19f940dabdecbe7b7f835953d9f07f7222b
2025-01-24 16:17:58 -08:00
Pieter De Baets 73968dc778 Cleanup initEagerTurboModulesOnNativeModulesQueueAndroid flag (#48917)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48917

Cleaning up this flag which has already been rolled out

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D68622852

fbshipit-source-id: 5767515d02ce9804976a1363532e1e626aeae0d8
2025-01-24 10:57:41 -08:00
Pieter De Baets 7f62ff6b02 Cleanup completeReactInstanceCreationOnBgThreadOnAndroid and useImmediateExecutorInAndroidBridgeless flags (#48916)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48916

Cleaning up this feature flag since we no longer require this gating. This was already fulled rulled out as default.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D68621578

fbshipit-source-id: 3fd3ad007b8beb8e2525ffa7b4da372be1dbbd94
2025-01-24 10:57:41 -08:00
Tim Yung b186d8f9b8 Animated: Hoist Non-Lifecycle Logic from useAnimatedPropsLifecycle (#48877)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48877

This is a minor refactor to hoist logic that is not actually specific to the `AnimatedProps` lifecycle out of the hook named `useAnimatedPropsLifecycle`.

This will make it easier to iterate on the implementation of `useAnimatedPropsLifecycle` using a feature flag in a subsequent diff.

This has no behavior change.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D68516034

fbshipit-source-id: 2cd6d9b0f2a5c0ada10cf01c8c14ed5510fbf25a
2025-01-24 10:48:44 -08:00
Nicola Corti 54e0b69e7e Stable API - Make AnimatedNodeWithUpdateableConfig internal (#48900)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48900

I've verified that this interface is not used externally, so I'm making it internal.
https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Apvinis%2Freact-native---investigation+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+repo%3Amolangning%2Freversing-discord+com.facebook.react.animated.AnimatedNodeWithUpdateableConfig+

Changelog:
[Android] [Removed] - Stable API - Make `AnimatedNodeWithUpdateableConfig` internal as it was not used in OSS

Reviewed By: tdn120, mdvacca

Differential Revision: D68562055

fbshipit-source-id: 0f06c22dc096efabce9fb937f099775effbff3f6
2025-01-24 10:22:23 -08:00
David Vacca 2fa0494bc4 Internalize ReactNativeFeatureFlags generated accessor classes (#48909)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48909

Internalize ReactNativeFeatureFlags generated accessor classes

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D68579670

fbshipit-source-id: 63606793e2a63f1901c7de2cb40e68c27193259d
2025-01-24 10:15:58 -08:00
David Vacca c0ad6a4cd5 Internalize ReactNativeFeatureFlags Accessor interfaces & Classes (#48910)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48910

Internalize ReactNativeFeatureFlags Accessor interfaces & Classes

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D68579453

fbshipit-source-id: 9549221b47e93a9c8a3161c3914ece849f7f9a52
2025-01-24 10:15:58 -08:00
Nicola Corti c495a8ab1b Remove unused AndroidUnicodeUtils. (#48919)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48919

I suspect this class is unused and we should not be building it.
The same `AndroidUnicodeUtils.java` is provided by facebook/hermes instead.

Changelog:
[Internal] [Changed] -

Reviewed By: tdn120, mdvacca

Differential Revision: D68623307

fbshipit-source-id: 0a290d31e3b1103947a9dd3c46821958be9223e7
2025-01-24 10:03:04 -08:00
Iwo Plaza 52ffda7e55 Migrate Libraries/Utilities/*.js to use export syntax. (#48665)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48665

## Motivation
Modernising the react-native codebase to allow for ingestion by modern Flow tooling

## This diff
- Updates files in Libraries/Utilities to use `export` syntax
  - `export default` for qualified objects, many `export` statements for collections (determined by how it's imported)
- Appends `.default` to requires of the changed files.
- Updates Jest mocks of the `Platform` module, which happened to touch a lot of test files.
- Updates the public API snapshot (intented breaking change)

Changelog:
[General][Breaking] - Files inside `Libraries/Utilities` use `export` syntax, which requires the addition of `.default` when imported with the CJS `require` syntax.

Reviewed By: huntie

Differential Revision: D68152910

fbshipit-source-id: 07f3a0957f1dbaf44f53974c6f28b273558406eb
2025-01-24 09:17:55 -08:00
Iwo Plaza 1be7e1a95f Migrate Libraries/Text, Libraries/Share and Libraries/Settings to use export syntax (#48901)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48901

## Motivation
Modernising the react-native codebase to allow for ingestion by modern Flow tooling.

## This diff
- Updates files in `Libraries/Text`, `Libraries/Share` and `Libraries/Settings` to use `export` syntax.
- Appends `.default` to requires of the changed files.
- Updates test files.
- Updates the public API snapshot *(intented breaking change)*

Changelog:
[General][Breaking] - Files inside `Libraries/Text`, `Libraries/Share` and `Libraries/Settings` use `export` syntax, which requires the addition of `.default` when imported with the CJS `require` syntax.

Reviewed By: huntie

Differential Revision: D68562844

fbshipit-source-id: bd71a341e33d3629121aa61549139c4b1cd62c3f
2025-01-24 08:49:15 -08:00
Ruslan Lesiutin b578647980 Use custom tracks for measures (#48926)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48926

# Changelog: [Internal]

Leverage [`devtools` field](https://developer.chrome.com/docs/devtools/performance/extension#devtools_object) inside [`detail` object](https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure#detail) to make extension tracks work.

Right now we are only specifying track name, later we could use many more fields:
```
interface ExtensionTrackEntryPayload {
  dataType?: "track-entry"; // Defaults to "track-entry"
  color?: DevToolsColor;    // Defaults to "primary"
  track: string;            // Required: Name of the custom track
  trackGroup?: string;      // Optional: Group for organizing tracks
  properties?: [string, string][]; // Key-value pairs for detailed view
  tooltipText?: string;     // Short description for tooltip
}
```

In the next few diffs I will extend the spec of the local implementation for `performance.measure` and `performance.mark` to get this propagated correctly.

Reviewed By: huntie

Differential Revision: D68624603

fbshipit-source-id: 99a5d233ee1dbcd690ad8a6802ca993071f63f2c
2025-01-24 08:41:48 -08:00
Ruslan Lesiutin 2e5fa4e35d Migrate to Inspector trace (#48923)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48923

# Changelog: [Internal]

Starting from this diff, React Native will emit inspector traces, the ones that will have the same UI as if it was recorded in a browser.

We are going to fake it by sending "TracingStartedInPage" event. For a corresponding logic on Chrome DevTools Frontend side, see [this](https://github.com/ChromeDevTools/devtools-frontend/blob/192673131cf3e6e0bcdb4a97bd0bd39c75f1b3c2/front_end/models/trace/handlers/MetaHandler.ts#L68-L80) as a starting point.

Because of this, custom tracks are now grouped under "Timings" track, although with a better color scheme:
- We no longer need the logic for placing tracks under arbitrary thread ids to have them grouped.
- The real support for extension tracks (custom tracks for Performance panel) will be added in the next diff.

Reviewed By: huntie

Differential Revision: D68439734

fbshipit-source-id: 8e5c525a71578375904edc6d473308eb710b5867
2025-01-24 08:41:48 -08:00
Ruslan Lesiutin 4b7906bc15 Switch from single Complete event to a pair of Async Nestable events (#48906)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48906

# Changelog: [Internal]

It looks like on `Chrome` side, Complete events (`ph="X"`) are only used for Renderer-related events.

For user-land events with duration (non-instant events), there is a [set of supported types](https://github.com/ChromeDevTools/devtools-frontend/blob/99a9104ae974f8caa63927e356800f6762cdbf25/front_end/models/trace/types/TraceEvents.ts#L62-L65), which don't include `"X"`.

Later, pair of such events will form a [performance measure event](https://github.com/ChromeDevTools/devtools-frontend/blob/99a9104ae974f8caa63927e356800f6762cdbf25/front_end/models/trace/types/TraceEvents.ts#L2256-L2258).

Reviewed By: huntie

Differential Revision: D68564754

fbshipit-source-id: dac87ab06c47925a70e03f43f0628364217a06a2
2025-01-24 08:41:48 -08:00
Vitali Zaidman d85294b953 fix ignoring of temp local project settings for RNTester
Summary: Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D68625659

fbshipit-source-id: b5ce8ff04b5bb678b5fd19bc6fa5d1c5451df3a9
2025-01-24 07:53:32 -08:00
Andrew Datsenko 1b050b571e Upgrade undici to 5.28.5 (#48898)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48898

Changelog: [Internal]

GitHub has identified a security vulnerability in a package dependency defined in the repository, facebook/react-native.

Package name: undici
Affected versions: >= 4.5.0, < 5.28.5
Fixed in version: 5.28.5
Severity: MODERATE

Identifiers
GHSA-c76h-2ccp-4975
CVE-2025-22150

References
https://github.com/nodejs/undici/security/advisories/GHSA-c76h-2ccp-4975
https://nvd.nist.gov/vuln/detail/CVE-2025-22150
https://github.com/nodejs/undici/commit/711e20772764c29f6622ddc937c63b6eefdf07d0
https://github.com/nodejs/undici/commit/c2d78cd19fe4f4c621424491e26ce299e65e934a
https://github.com/nodejs/undici/commit/c3acc6050b781b827d80c86cbbab34f14458d385
https://hackerone.com/reports/2913312
https://blog.securityevaluators.com/hacking-the-javascript-lottery-80cc437e3b7f
https://github.com/nodejs/undici/blob/8b06b8250907d92fead664b3368f1d2aa27c1f35/lib/web/fetch/body.js#L113
https://github.com/advisories/GHSA-c76h-2ccp-4975

Reviewed By: NickGerleman

Differential Revision: D68561080

fbshipit-source-id: 7aa71e959ac38f3e0f49d8503a471f60d2f44c5d
2025-01-24 07:06:10 -08:00
Samuel Susla 70fa456ddc remove explicit calls to root.destroy (#48927)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48927

changelog: [internal]

Remove explicit calls to root.destroy() in favour of automated system that will call it and check for memory leaks.

Reviewed By: rubennorte

Differential Revision: D68624917

fbshipit-source-id: 44be1dee9a56ec31bea5a9eefdda086a4cb4248f
2025-01-24 07:03:27 -08:00
Iwo Plaza e5818d92a8 Migrate files in Libraries/Core to export syntax (#48889)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48889

## Motivation
Modernising the react-native codebase to allow for ingestion by modern Flow tooling.

## This diff
- Updates files in `Libraries/Core` to use `export` syntax
  - `export default` for qualified objects, many `export` statements for collections
- Appends `.default` to requires of the changed files.
- Changed `* as ExceptionsManager` to `ExceptionsManager` in import statements throughout product code.
- Updates test files.
- Updates the public API snapshot (intented breaking change)

Changelog:
[General][Breaking] - Files inside `Libraries/Core` use `export` syntax, which requires the addition of `.default` when imported with the CJS `require` syntax.
[General][Breaking] - `Libraries/Core/ExceptionsManager` now exports a default `ExceptionsManager` object, and `SyntheticError` as a secondary export.

Reviewed By: huntie

Differential Revision: D68553694

fbshipit-source-id: 51c9a404b2762cb1cdb5f56cae3a683ccdfffc7f
2025-01-24 05:43:28 -08:00
Dawid Małecki d2adb976ab Replace $FlowFixMe in WebSocketInterceptor callbacks (#48702)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48702

Changelog:
[General][Changed] - Improved types in WebSockertInterceptor callbacks

Reviewed By: cortinico

Differential Revision: D68210857

fbshipit-source-id: 4f2a47be6f96e26db25edbaffcbe97b76ffbdc33
2025-01-24 04:51:43 -08:00
Rubén Norte 348b917c58 Move methods to access internals of DOM nodes to a separate module (#48854)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48854

Changelog: [internal]

Moves the internals to access instance handle and shadow node from public instances from `ReadOnlyNode` to `NodeInternals` so it's more obvious when people are reaching into internal APIs/state.

Reviewed By: javache

Differential Revision: D67654404

fbshipit-source-id: 1063bc9451eeacb79af34614df3be02466f93fa3
2025-01-24 04:42:45 -08:00
Ruslan Lesiutin ad67f8099b add optional id field (#48897)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48897

# Changelog: [Internal]

Adds optional `id` field to Trace Event spec. This field will be required once we are going to emit trace with real custom tracks.

For custom tracks, we would need to emit pair of trace events:
1. Begin Event with type `b`.
2. End Event with type `e`.

They are [matched](https://github.com/ChromeDevTools/devtools-frontend/blob/99a9104ae974f8caa63927e356800f6762cdbf25/front_end/models/trace/helpers/Trace.ts#L261-L294) by Chrome DevTools frontend by `id` and `name` fields.

Reviewed By: huntie

Differential Revision: D68559862

fbshipit-source-id: 732ae52691e31213f9c63474905eb7c1b12adb8c
2025-01-24 04:38:18 -08:00
Ruslan Lesiutin df4d9d1cce Split stopTracingAndCollectEvents (#48795)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48795

# Changelog: [Internal]

Splitting `PerformanceTracer::stopTracingAndCollectEvents()` into 2 separate methods.

Once we add logic for starting and stopping tracing on `InstanceAgent`:
- We would need to stop tracing everywhere synchronously
- Populate data sources in `PerformanceTracer`, like JavaScript samples
- Collect all events from different data sources in one payload via `PerformanceTracer::collectEvents()`

Reviewed By: huntie

Differential Revision: D68331485

fbshipit-source-id: 0d6b21a522d841f7f734e2fad2e0fc533097fdee
2025-01-24 04:27:55 -08:00
Jorge Cabiedes Acosta 6c6e0a9085 Fix anti-aliasing on older Android devices
Summary:
On older Android versions clipping doesn't have anti-aliasing by default which means that clipping with no border will always make the background not have anti-aliasing.

This is fixed by default on new Background and Border drawables since rendering logic is separated

Moving the clipping logic so it only runs when we have a border.

https://github.com/facebook/react-native/issues/41226

Changelog: [Android] [Fixed] - Fixed anti-aliasing not showing on older Android versions

Reviewed By: javache

Differential Revision: D68279400

fbshipit-source-id: e2383c71bd1ca89f66f42630b3712bb4cc5cd7ac
2025-01-23 20:52:48 -08:00
Joe Vilches 1b710a0cb2 Back out "Allow text links to be navigatable via keyboard by default"
Summary:
This was causing links to not ellipsize and be scrollable. Gonna revert while I see if I can workaround

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D68596950

fbshipit-source-id: 432a059d0b10acbb45d34e0c98763680d280937b
2025-01-23 19:19:13 -08:00
David Vacca 5ea7594b5c Fully rollout enableDeletionOfUnmountedViews feature flag (#48872)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48872

enableDeletionOfUnmountedViews feature flag has been enabled for 4 months with no errors on production, also it's been enabled in OSS since 0.76.
This diff removes the feature flag and fully rollout this fix

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: sammy-SC

Differential Revision: D68511227

fbshipit-source-id: a42481c57aaab2e8c45b952af5e044bf60740df3
2025-01-23 17:38:38 -08:00
Nick Gerleman fae6edb65c Support parsing hsl() and hsla() functions (#48843)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48843

Adds support for hsl() and hsla() funtions. This supports more modern syntax options than normalize-color, like number components, optional alpha, and fills in missing support for angle units. The underlying math was lifted pretty much directly from normalize-color though.

An aside, std::remainder for these is not guaranteed to be constexpr, but Clang is still okay with rgb function parsing to be contexpr because we never try to evaluate non-constexpr function?

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D68473990

fbshipit-source-id: 2a71d8367b22f9d1ba6a66598d40ef2683847704
2025-01-23 16:19:48 -08:00
Nick Gerleman 91add1e4e0 Remove redundant check in CSSRatio (#48842)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48842

This is a result of inlining isinf previously but we can never be negative infinity because we can never be less than zero.

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D68474836

fbshipit-source-id: bfce78c4bd269ff2afac99c03250ede676ee1029
2025-01-23 16:19:48 -08:00
Nick Gerleman a4b112cb0b Do not consume delimeter when not consuming component value (#48841)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48841

Right now during parsing we can ask for a next component value, with a delimeter, and even if we don't have a component value to consume, we will consume the delimeter.

This is kind of awkward since e.g. trailing comma can be consumed, then we think syntax is valid. Let's try changing this.

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D68474739

fbshipit-source-id: 47a942681bc8472ca28470eba821d4d95306ae5d
2025-01-23 16:19:48 -08:00
Nick Gerleman 5b3d8d3410 More spec compliant rgb function parsing (#48839)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48839

In the last diff I mixed and matched `<legacy-rgb-syntax>` and `<modern-rgb-syntax>` a bit to keep compatiblity with `normalze-color`.

Spec noncompliant values have only been allowed since https://github.com/facebook/react-native/pull/34600 with the main issue being that legacy syntax rgb functions are allowed to use the `/` based alpha syntax, and commas can be mixed with whitespace. This seems like an exceedingly rare real-world scenario (there are currently zero usages of slash syntax in RKJSModules validated by `rgb\([^\)]*/`), so I'm going to instead just follow the spec for more sanity.

Another bit that I missed was that modern RGB functions allow individual components to be `<percentage>` or `<number>` compared to legacy functions which only allow the full function to accept one or the other (`normalize-color` doesn't support `<percentage>` at all), so I fixed that as well.

I started sharing a little bit more of the logic here, to make things more readable when adding more functions.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D68468275

fbshipit-source-id: f1dfab51b91a3f64436c2559daa3d1e8891db889
2025-01-23 16:19:48 -08:00
Nick Gerleman 24393c7dde Add CSSDelimeter::OptionalWhitespace and CSSDelimeter::CommaOrWhitespaceOrSolidus (#48828)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48828

1. Rename `CSSComponentValueDelimeter` to `CSSDelimeter` bc the names are getting way too long.
2. Make the distinction between `Whitespace` and `OptionalWhitespace`. Note that for property values, and function blocks, the value parser will already remove trailing/leading whitespace, but it's weird that whitespace unlike others was not required to be present
3. Add `CSSDelimeter::CommaOrWhitespaceOrSolidus` for simpler parsing in the common pattern of alpha values, and move CSSColor function parsing to use that

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D68461968

fbshipit-source-id: 388056e47dfe6ca6003b44e82e00fe416706330b
2025-01-23 16:19:48 -08:00