Commit Graph

38536 Commits

Author SHA1 Message Date
Riccardo Cipolleschi f7977387f4 Update classification of Fixed (#48561)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48561

The changelog for 0.77 needs some love as there are some entry that are incorrectly classified.

In this diff I took care of fixing the `Fixed` entries.

We need to go through all the other classes of entries.

## Changelog:
[Internal] - Refine 0.77 changelog

Reviewed By: cortinico

Differential Revision: D67972217

fbshipit-source-id: 343dd5a4e8a6cd6d6806447063594ba466db3b1e
2025-01-09 07:11:57 -08:00
Riccardo Cipolleschi efb2aa0d5b Update classification of Deprecated (#48562)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48562

The changelog for 0.77 needs some love as there are some entry that are incorrectly classified.

In this diff I took care of fixing the `Changed` entries.

We need to go through all the other classes of entries.

## Changelog:
[Internal] - Refine 0.77 changelog

Reviewed By: cortinico

Differential Revision: D67941153

fbshipit-source-id: 59bc5a8a37242a1a5dc17baa4d85d0e18df35d46
2025-01-09 07:11:57 -08:00
Riccardo Cipolleschi 36daa41c26 Update classification of Changed (#48563)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48563

The changelog for 0.77 needs some love as there are some entry that are incorrectly classified.

In this diff I took care of fixing the `Changed` entries.

We need to go through all the other classes of entries.

## Changelog:
[Internal] - Refine 0.77 changelog

Reviewed By: cortinico

Differential Revision: D67941107

fbshipit-source-id: 2352c901810587a0d4d5ccbbaa09960f03999378
2025-01-09 07:11:57 -08:00
Riccardo Cipolleschi 16b047968f Update classification of Added (#48564)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48564

The changelog for 0.77 needs some love as there are some entry that are incorrectly classified.

In this diff I took care of fixing the `Added` entries.

We need to go through all the other classes of entries.

## Changelog:
[Internal] - Refine 0.77 changelog

Reviewed By: cortinico

Differential Revision: D67940751

fbshipit-source-id: 345bd0e4e9564a1d8d16418f31ee6a917f27b202
2025-01-09 07:11:57 -08:00
Riccardo Cipolleschi d9af80f471 Update classification of RCs (#48565)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48565

The changelog for 0.77 needs some love as there are some entry that are incorrectly classified.

In this diff I took care of fixing the entries in the RCs.

We need to go through all the other classes of entries.

## Changelog:
[Internal] - Refine 0.77 changelog

Reviewed By: cortinico

Differential Revision: D67940292

fbshipit-source-id: 3373d2f2879c7137ad93b4b53672a0f8e322776f
2025-01-09 07:11:57 -08:00
Riccardo Cipolleschi cdc8c9db09 Start fixing changelog for 0.77 (#48528)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48528

The changelog for 0.77 needs some love as there are some entry that are incorrectly classified.

In this diff I took care of fixing the `Breaking Changes` and the `Removed` entries.

We need to go through all the other classes of entries.

## Changelog:
[Internal] - Refine 0.77 changelog

Reviewed By: robhogan, cortinico

Differential Revision: D67937294

fbshipit-source-id: 18278abae4680a9dab3f46e41c1b7f7f8a7ad367
2025-01-09 07:11:57 -08:00
Riccardo Cipolleschi 85745f3551 Add Changelog for 0.76.6 (#48566)
Summary:
Add changelog for 0.76.6

## Changelog:
[Internal] - Add Changelog for 0.76.6

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

Test Plan: N/A

Reviewed By: cortinico

Differential Revision: D67973501

Pulled By: cipolleschi

fbshipit-source-id: a3c5c78620dfd7bb1c917dfc33d98801abe0a373
2025-01-09 06:51:53 -08:00
Samuel Susla 1cbcea49bf write fantom tests percentage based width and height (#48560)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48560

changelog: [internal]

add tests for width and height and margin style. Covering percentage-based dimensions and invalid inputs.

The test coverage is needed to make removal of folly::tryTo safe.

Reviewed By: rubennorte

Differential Revision: D67942139

fbshipit-source-id: c1e517dfb102eea892c998cf6ff4190fa69cdfa7
2025-01-09 06:09:36 -08:00
Rubén Norte e7a37c1b5f Move assets for feature flags docs to a __docs__ directory (#48555)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48555

Changelog: [internal]

Small move to align with the existing convention.

Add `README.md` file for feature flags in JS directory, to link to canonical docs.

Reviewed By: huntie

Differential Revision: D67897751

fbshipit-source-id: d5091ab4537701ee5cfdf29ebd0fe79e858e3134
2025-01-09 05:31:19 -08:00
Rubén Norte f1cbf25c09 Extract common logic in ErrorHandlers to a shared method (#48366)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48366

Changelog: [internal]

Just removing some unnecessary duplication from this file.

Reviewed By: christophpurrer

Differential Revision: D67407220

fbshipit-source-id: 2f3e1ac4dddb7f8ede75175242e4b37e628196a0
2025-01-09 04:35:08 -08:00
Nicola Corti 1282361573 Silence the eden info output from react-native-codegen (#48540)
Summary:
We currently see this error message on console:
![Screenshot 2025-01-08 at 19 09 47](https://github.com/user-attachments/assets/3b384772-9abc-40a5-83b3-9b4ccce85f4a)

This will silence it by piping stderr to /dev/null

## Changelog:

[INTERNAL] - Silence the `eden info` output from react-native-codegen

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

Test Plan: CI

Reviewed By: robhogan

Differential Revision: D67948411

Pulled By: cortinico

fbshipit-source-id: f805634a65713f4f9bc2dce6d781664e7564bc96
2025-01-09 04:01:29 -08:00
Rubén Norte 742e14d47f Add a few more tests to ReactNativeElement (#48428)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48428

Changelog: [internal]

Adding a few more tests for `ReactNativeElement` for symmetry with future tests for when it implements `EventTarget`.

Reviewed By: javache

Differential Revision: D67738147

fbshipit-source-id: 04c8f3539fefd15f7c778986eb9e39f2c2386b6a
2025-01-09 03:45:27 -08:00
Nicola Corti 5e6478954c Gradle to 8.12 (#48539)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48539

This keeps our Gradle version up to date ahead of the branch cut for 0.78.
https://docs.gradle.org/current/release-notes.html

Changelog:
[Android] [Changed] - Bump Gradle to 8.12

Reviewed By: NickGerleman

Differential Revision: D67946619

fbshipit-source-id: 0b5ea8d9543ca565ea8b3bdd48e5fc711f832ce8
2025-01-09 03:10:02 -08:00
David Vacca cfec590f6a Defining constant'types for API stability (#48546)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48546

Defining constant'types for API stability

changelog: [internal] internal

Reviewed By: shwanton

Differential Revision: D67953794

fbshipit-source-id: 7f833d1999340a6a4073f3eb303251c52d9d6fc6
2025-01-08 16:15:58 -08:00
David Vacca a79a1123c9 Internalize RootViewManager (#48545)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48545

RootViewManager is meant to be used by the internals of React Native, ther are no external usages. I'm internalizing it

changelog: [internal] internal

Reviewed By: christophpurrer

Differential Revision: D67952865

fbshipit-source-id: 4c7f7de01c4de7ae00f62bd4f5b49e0082ec3f2b
2025-01-08 16:15:58 -08:00
Peter Abbondanzo dc5535cf88 Improve documentation for AssetSourceResolver (#48532)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48532

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D67942309

fbshipit-source-id: 0f3901bfcd58863adf6dc8466bb5d587438e0d2c
2025-01-08 14:54:17 -08:00
Peter Abbondanzo 6feb90bb29 Replace custom XmlFormat with Fresco built-in (#48533)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48533

Replaces the custom `XmlFormat` introduced in https://github.com/facebook/react-native/pull/46711 with the built-in support from Fresco. Fresco utilizes a very similar approach to load binary XML files and offers the XML format as part of its built-in `DefaultImageFormats`

Changelog:
[Android][Changed] - Replaced custom XML decoder with Fresco's built-in decoder

Reviewed By: NickGerleman

Differential Revision: D66553842

fbshipit-source-id: 096e60140f893d461be1cdb48e250749e58bbb4c
2025-01-08 14:54:17 -08:00
Peter Abbondanzo 819b5c2c8d Bump Fresco to 3.6.0 (#48542)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48542

Updates Fresco from 3.5.0 to 3.6.0. Picks up a few new features and bug fixes for XML drawables, including a required fix that [automatically supplies the XML drawable factory to Fresco's PipelineDraweeControllerBuilder](https://github.com/facebook/fresco/commit/e6b052610aab461601cfabc00f7240758a415878). Without this change, we cannot switch from RN's custom XmlFormat to Fresco's built-in format

Changelog:
[Android][Changed] - Update Fresco to 3.6.0

Reviewed By: NickGerleman, rshest

Differential Revision: D67950225

fbshipit-source-id: 9afd87565a5f069493c9c5ef87977cbd6d7cf3d4
2025-01-08 14:54:17 -08:00
Peter Abbondanzo 218815959b xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewAccessibilityDelegate.java (#48530)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48530

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D67912326

fbshipit-source-id: b03be79dfbf3bf8d92b11eb6228ecc36282b29cf
2025-01-08 14:46:01 -08:00
David Vacca 843588ffe5 Refactor PointerEvents strings as constants (#48537)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48537

Refactor PointerEvents strings as constants

changelog: [internal] internal

Reviewed By: shwanton

Differential Revision: D67924567

fbshipit-source-id: 7d9976d293cef3eeedbbb72abd20d8f877b768d0
2025-01-08 11:37:47 -08:00
David Vacca e4ec22de9d Delete POSITION_SPACING_TYPES from ViewProps (#48536)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48536

POSITION_SPACING_TYPES is not being used, let's delete it

changelog: [internal] internal

Reviewed By: christophpurrer

Differential Revision: D67924569

fbshipit-source-id: 6cc4b0537032f4a4b54dbd728ca52ba216fd6cee
2025-01-08 11:37:47 -08:00
David Vacca c17e6ce0f0 Delete ON_LAYOUT constant (#48535)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48535

ON_LAYOUT is not being used, lets delete it

changelog: [internal] internal

Reviewed By: christophpurrer

Differential Revision: D67924570

fbshipit-source-id: b5522317c943c07f8617508c0345b18a6f31ce7e
2025-01-08 11:37:47 -08:00
David Vacca 98b413416c Delete unused constants in ViewProps (#48534)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48534

IS_ATTACHMENT is unused, let's delete it

changelog: [internal] internal

Reviewed By: christophpurrer

Differential Revision: D67924566

fbshipit-source-id: 49718f4ce667abe919a314a853dbd7853bfe1292
2025-01-08 11:37:47 -08:00
Nick Gerleman f7a5db3c06 Fix TextMeasureCacheKey Throwing Out Some LayoutConstraints (#48525)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48525

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

`TextMeasureCacheKey` hash and equality functions only incorporates the maximum width constraint. I'm guessing this was an attempt at an optimization, but it can lead to incorrect results in pretty trivial cases. E.g. if Yoga knows a definite size of `Text` in one dimension,  and measures via `YGMeasureModeExactly`, we can have a minimum size corresponding specific to the style in which the text was laid out.

Changelog:
[General][Fixed] - Fix TextMeasureCacheKey Throwing Out Some LayoutConstraints

Reviewed By: christophpurrer

Differential Revision: D67922414

fbshipit-source-id: 0ee0220059fc4e4645b1684c42a0587fe728bedd
2025-01-08 10:33:25 -08:00
Tim Yung 85e58f334e Prettier: Cleanup eslint-plugin-prettier Dependency (#48524)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48524

I've confirmed that we are no longer using `eslint-plugin-prettier` in Metro or React Native. This removes it from the package dependencies.

Changelog:
[Internal]

Reviewed By: huntie

Differential Revision: D67920511

fbshipit-source-id: 9c8036ccfb94d974d344d861942c076dc2b70125
2025-01-08 09:42:59 -08:00
Tim Yung 6d67d6a7f6 Animated: Optimize onUserDrivenAnimationEnded Deopt (#48511)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48511

{D60499583} added a new`onUserDrivenAnimationEnded` listener that requires `AnimatedValue` instances to have up-to-date values reported by `onAnimatedValueUpdate` (if native driver is in use).

Previously, the only way to ensure `onAnimatedValueUpdate` events were always fired to update JavaScript values in `AnimatedValue` instance was to attach a listener — even an empty one. This is exactly what D60499583 did: it traverses `props` for `AnimatedNode` instances and attaches listeners to them.

However, this is really inefficient and makes the code extra convoluted. Instead, this diff changes `AnimatedValue` so that it always subscribes to changes in `__attach`, and then it cleans up the extraneous props traversal and "empty listener" logic.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D67872307

fbshipit-source-id: e7d7e486bbfd9ef03e2dd9f201089e2f68b2dbb2
2025-01-08 09:03:17 -08:00
Sam Zhou abf0384434 Deploy 0.258.1 to xplat
Summary: Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D67927891

fbshipit-source-id: ac9c7bd87e9f1e2fecdbd7141cd0e5c5a62c7ce6
2025-01-08 08:47:41 -08:00
Pieter De Baets a62230a54d Merge copies of GuardedFrameCallback (#48529)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48529

These classes are identical and we already have a dependency on :uimanager in fabric.

Looking at OSS, I found no usages of `fabric.GuardedFrameCallback`.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D67913226

fbshipit-source-id: 97d7a9b45b877b98e9549c71135bd9b21386d78c
2025-01-08 07:40:32 -08:00
Peter Abbondanzo ec72af403c Mark string props as nullable in scrollview managers (#48520)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48520

Both `ReactScrollViewHelper.parseSnapToAlignment` and `ReactScrollViewHelper.parseOverScrollMode` accept a nullable string. This is a precursor to migrating these files to Kotlin (since they're already marked as nullsafe). The prop itself is a nullable string so this should be reflected in the native types as well

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D67911553

fbshipit-source-id: aabe55c2dc65a933b170d76b89f62f25493ab0ee
2025-01-07 15:13:34 -08:00
Oskar Kwaśniewski 8b0af4542e fix(iOS): enable/disable keyboard shortcuts only on iOS (#48518)
Summary:
This PR guards code that enables/disables keyboard shortcuts only on iOS (iPadOS included).

![CleanShot 2025-01-07 at 14 49 36@2x](https://github.com/user-attachments/assets/cba4e19c-5a52-4874-94cf-a3e18112c8a3)

## Changelog:

[IOS] [FIXED] - enable/disable keyboard shortcuts only on iOS

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

Test Plan: CI Green

Reviewed By: rshest

Differential Revision: D67900442

Pulled By: javache

fbshipit-source-id: 249a7c3124d02d2c30303d218e2b26e987ae1f0f
2025-01-07 13:21:19 -08:00
Tim Yung 38c46fe865 Animated: Lower onAnimatedValueUpdate to AnimatedValue (#48514)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48514

Currently, `AnimatedNode` implements logic to start listening to updates on the current native node if a listener is added.

However, the `startListeningToAnimatedNodeValue` native module method only supports native tags for instances of `AnimatedValue`, which is a subclass of `AnimatedNode`. In fact…

* On Android, [`startListeningToAnimatedNodeValue`](https://fburl.com/code/bdsl4sro) throws if the node is not an instance of `ValueAnimatedNode`.
* On iOS, [`startListeningToAnimatedNodeValue`](https://fburl.com/code/hlpk1rzk) does nothing if node is not an instance of `RCTValueAnimatedNode`.

As such, this refactors `AnimatedNode` to never manage this subscription for native nodes. Instead, the logic is moved into the `AnimatedValue` subclass, ensuring that we never accidentally try to `startListeningToAnimatedNodeValue` with non-`AnimatedValue` native tags.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D67884973

fbshipit-source-id: 5601efd8c29104a991301eabd97ddb88fd03c4a3
2025-01-07 10:05:15 -08:00
Tim Yung d3c5f6d1df Animated: Add Missing super.__attach() Calls (#48513)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48513

While refactoring `Animated`, I noticed that many subclasses of `AnimatedNode` override `__attach` without invoking the superclass method, even though we do this for `__detach`.

In order to minimize surprise (e.g. if someone were to add logic into `AnimatedNode.prototype.__attach`), this diff updates all method overrides to invoke `super.__attach()`.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D67884975

fbshipit-source-id: f3a5456cf944d4d70ba1cfe7c44897c110e5fc7e
2025-01-07 10:05:15 -08:00
Pieter De Baets 3f6fc32a5c Fix nullability of ViewManagerDelegate
Summary:
Some of these parameters were incorrectly marked as nullable during the Kotlin migration

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D67091825

fbshipit-source-id: c660164e41ba7d47f1d1d3dc28a01b79b7c8cb03
2025-01-07 09:52:55 -08:00
Rob Hogan 7a58f1f5bf Add changelog for 0.77.0-rc.6 (#48508)
Summary:
Changelog for 0.77.0-rc.6

## Changelog:

[Internal]

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

Test Plan: N/A

Reviewed By: christophpurrer

Differential Revision: D67866154

Pulled By: robhogan

fbshipit-source-id: a64f2aa83abe31bbc8d9e1a2ac47e00bba55c389
2025-01-07 08:45:34 -08:00
Pieter De Baets afd77d52ed Rename SurfaceRegistryBinding to AppRegistryBinding (#48337)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48337

`SurfaceRegistryBinding` refers to a forked `SurfaceRegistry` we had for a while in bridgeless but which was merged back into `AppRegistry`. Align the native name as well to make it explicit that all this class does is call into `AppRegistry`.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D67342499

fbshipit-source-id: 797d8080611cb2576a2052999c2bf46d2eea9f72
2025-01-07 07:40:40 -08:00
Pieter De Baets dbb75e36dc Always use AppRegistry globals in SurfaceRegistryBinding (#48336)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48336

`RN$AppRegistry` and `RN$stopSurface` are always set on the init path, regardless of bridgeless or not, so we can remove the fallback path and cleanup this code.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D67342498

fbshipit-source-id: db47e52fee5075f11258364d82474579d2bb21f4
2025-01-07 07:40:40 -08:00
Pieter De Baets 65bda54232 Remove getInspectorDataForInstance (#48335)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48335

This API was never adopted or implemented on iOS, and is not compatible with bridgeless.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D67342500

fbshipit-source-id: a6740514d0347c0f497e1aa2f850328cc4607d24
2025-01-07 07:40:40 -08:00
Alex Hunt eda29f0a56 Remove legacy InspectorPackagerConnection (#48506)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48506

Cleanup after the original experiment removal in D57730921, and having launched Fusebox for a full release cycle.

- This was previously opened as D58017460 and reverted in D58132473 ([see comment](https://www.internalfb.com/diff/D58017460?transaction_fbid=980942997022731)).

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D67858259

fbshipit-source-id: f4b29247dd4c310cc1f6b6f45688756d7b925a5e
2025-01-07 05:48:00 -08:00
Blake Friedman a8cf53fcd1 Add messaging to phabricator (#48470)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48470

This introduces:
- `validate_rn_cpp_api`: run a shell script that fails if the user changes the C++ API.  Importantly it produces an artifact with details to share with the user: `message`.
- `message` has to be extracted from `stdout`, which **get_user_message** does if the `validate_rn_cpp_api` action is not successful (**warning**).
- The then users `comment_to_signalhub` to share this as a warning to the user (until we're confident this entire stack is very stable, at which time we'll block).

The provides 2 classes of warning:
1. vanilla you've change the API,
2. you've change the API and haven't included the correct changelog.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D67776215

fbshipit-source-id: 4ac7451c8ecef62ba968710ec41804ba42153976
2025-01-07 03:41:42 -08:00
Parsa Nasirimehr d22dbb5c51 chore(Android): Migrate Hermes Instruments to Kotlin (#48378)
Summary:
Time to migrate some of Hermes's instruments. I see that HermesMemoryDumper(`react/hermes/instrumentation/HermesMemoryDumper.h`) implements the interface on C++, ~but not sure if i need to update the `getId` call to just `id` (same with `getInternalStorage`) or if the interop between Kotlin and Java applies to these things as well. cortinico Any thoughts on your side would be appreciated.
HermesSamplingProfiler just became an object, since it was a singleton and a static anyway.
Here is what HermesMemoryDumper.h looks like:
<img width="1840" alt="Screenshot 2024-12-24 at 10 03 00" src="https://github.com/user-attachments/assets/d18e378a-9b23-47a9-83c9-402d29aeaa5f" />~
*Updated*: I ended up making them match the function signature on Cxx, because even if it does have that implicit behavior, doesn't feel right to tap into it like this.

## Changelog:

[INTERNAL] [FIXED] - Migrate HermesMemoryDumper and HermesSamplingProfiler to Kotlin

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

Test Plan:
`/gradlew test`:
<img width="1840" alt="Screenshot 2024-12-24 at 09 54 29" src="https://github.com/user-attachments/assets/1b23fb6f-9da8-42e4-a348-7da868df77c1" />

Reviewed By: cortinico

Differential Revision: D67657481

Pulled By: philIip

fbshipit-source-id: 4fb5e003789d51d464d0cca5800704ea51324b69
2025-01-07 00:49:59 -08:00
generatedunixname89002005232357 cd40e4e387 Revert D67868219 (#48512)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48512

This diff reverts D67868219
Breaking OTA Compatibility Check https://fburl.com/onedetection/m0hqsvjp

[General][Changed] - Revert: Mark intersectionRect required in NativeIntersectionObserverEntry to reflect native logic.

Reviewed By: lunaleaps

Differential Revision: D67882016

fbshipit-source-id: 8cff299ee823f8ef06fe96667e832b68be45666d
2025-01-06 22:28:51 -08:00
Christoph Purrer 65c6a0a941 Add getSurfaceProps helper method to SurfaceManager (#48487)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48487

[Changelog] [Internal] - Add getSurfaceProps helper method to SurfaceManager

When reload a reactHost we need to know which surface properties have been applied when starting the surface. This adds a utility function for that.

Reviewed By: rshest

Differential Revision: D67822459

fbshipit-source-id: 6d1f182514ed6e7ae8e31d3e1ca052c93bac2843
2025-01-06 21:49:49 -08:00
Christoph Purrer 44525aaf8b Add isSurfaceRunning / getRunningSurfaces util functions to SurfaceManager (#48484)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48484

[Changelog] [Internal] - Add isSurfaceRunning / getRunningSurfaces util functions to SurfaceManager

This exposes convience getter methods to data already stored in SurfaceManager

Reviewed By: rshest

Differential Revision: D67814092

fbshipit-source-id: af5e9df3b380d5efc0c11627a0d9a56796526639
2025-01-06 18:51:46 -08:00
Eli White 25c673e357 Fixing schema types for component command params of Arrays (#48476)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48476

Command param array types were generating invalid schemas due to untyped parser code. The invalid schemas occurred for any alias type, including custom objects and basics like Int32. This was also inconsistent between Flow and TypeScript.

We already had one component utilizing this issue, so this just codifies that support into the schema so it reflects reality. This is only a partial solution. The more full solution would be to fully encode the custom types in the schemas like we do for Native Modules.

# More Information:

Tl;dr, DebuggingOverlay is abusing a FlowFixMe in codegen commands.

## The problem:

The [CodegenSchema](https://www.internalfb.com/code/fbsource/[d3ab2f79b377]/xplat/js/react-native-github/packages/react-native-codegen/src/CodegenSchema.js?lines=220) should be the source of truth for anything that can be in the schema. If something is in the schema that isn't allowed by the types, that's a bug. We have a bug. I'm adding compat-check support for components and it's blowing up on prod schemas because DebuggingOverlay causes an invalid schema.

## The details:

Support for Arrays as arguments in commands was added to the Codegen in D51866557. [Code Pointer](https://fburl.com/code/8yy1rm0p)

The intention appears to be to support arrays of primitives. There is a TODO for supporting complex types.

```
interface NativeCommands {
  +addOverlays: (
    viewRef: React.ElementRef<NativeType>,
    overlayColorsReadOnly: $ReadOnlyArray<string>,
  )
}
```

This support was added to TypeScript in D52046165 where it types the allowed Array arguments to be only

```
{
    readonly type: 'ArrayTypeAnnotation';
    readonly elementType:
    | Int32TypeAnnotation
    | DoubleTypeAnnotation
    | FloatTypeAnnotation
    | BooleanTypeAnnotation
    | StringTypeAnnotation
  };
```

However, because the Parsers are treating the input type as `any`, it isn't safe to pass through an input value into the schema as Flow won't catch mismatches.

The Flow parser just passes it through:

```
{
    type: 'ArrayTypeAnnotation',
    elementType: {
    // TODO: T172453752 support complex type annotation for array element
    type: paramValue.typeParameters.params[0].type,
}
```

Whereas the TypeScript parser has the more correct behavior of validating the inputs and returning specific outputs. Unfortunately, the return type is also typed here as $FlowFixMe, losing most of the benefits.

```
function getPrimitiveTypeAnnotation(type: string): $FlowFixMe {
  switch (type) {
    case 'Int32':
      return {
        type: 'Int32TypeAnnotation',
      };
    case 'Double':
      return {
        type: 'DoubleTypeAnnotation',
      };
    case 'Float':
      return {
        type: 'FloatTypeAnnotation',
      };
    case 'TSBooleanKeyword':
      return {
        type: 'BooleanTypeAnnotation',
      };
    case 'Stringish':
    case 'TSStringKeyword':
      return {
        type: 'StringTypeAnnotation',
      };
    default:
      throw new Error(`Unknown primitive type "${type}"`);
  }
}
```

[DebuggingOverlay](https://fburl.com/code/zfe3ipq7) is abusing this gap in the Flow parser by sticking an Array of Objects in.

```
export type ElementRectangle = {
  x: number,
  y: number,
  width: number,
  height: number,
};

...
  +highlightElements: (
    viewRef: React.ElementRef<DebuggingOverlayNativeComponentType>,
    elements: $ReadOnlyArray<ElementRectangle>,
  ) => void;
...
```

This isn't allowed in the schema, but it seems to fall through the holes of the flow parser and generators.

The resulting schema from Flow is this. Note the GenericTypeAnnotation which isn't allowed to be in the schema.

```
{
    "name": "highlightElements",
    "optional": false,
    "typeAnnotation": {
    "type": "FunctionTypeAnnotation",
    "params": [
        {
            "name": "elements",
            "optional": false,
            "typeAnnotation": {
                "type": "ArrayTypeAnnotation",
                "elementType": {
                    "type": "GenericTypeAnnotation"
                }
            }
        }
    ],
    "returnTypeAnnotation": {
        "type": "VoidTypeAnnotation"
    }
},
```

The TypeScript parser fails with `Error: Unsupported type annotation: GenericTypeAnnotation`.

The generators don't seem to check beyond the ArrayTypeAnnotation so they fall through to generating generic arrays.

```
// ios
elements:(const NSArray *)elements

// android
ReadableArray locations
```

## So how do I fix this?

I think there are a couple of different options here. The key problem is that the Schema types need to represent reality of what can be in the schema.

1. We revert DebuggingOverlay to not use features that aren't supported (I assume nobody would be happy with this, but the change shouldn't have been made in the first place)
2. **(This is the approach taken in this diff)** We add MixedTypeAnnotation to the allowed types in Command arrays and have it generate that and add official support for that to the TypeScript parser as well. That is probably the quickest and easiest approach. It leaves the same type unsafety we have today on the native side.
3. NativeModules seem to have a lot more complex type safety here. They persist the alias type in the schema so that the CompatCheck can check them on changes. And then in C++ they generate structs and RCTConvert functions although for Java and ObjC it looks like they just use the same untyped native code. The matching approach here would be to add `aliasMap` and the whole data to the schema for commands, use that for the compat check, and still generate the same unsafe native code.

```
export type ObjectAlias = {|
  x: number,
  y: number,
|};

export interface Spec extends TurboModule {
  +getAlias: (a: ObjectAlias) => string;
}
```

stores the ObjectAlias in the schema

```
{
  "aliasMap": {
    "ObjectAlias": {
      "type": "ObjectTypeAnnotation",
      "properties": [
        {
          "name": "x",
          "optional": false,
          "typeAnnotation": {
            "type": "NumberTypeAnnotation"
          }
        },
        {
          "name": "y",
          "optional": false,
          "typeAnnotation": {
            "type": "NumberTypeAnnotation"
          }
        },
      ]
    }
  },
  "spec": {
    "methods": [
      {
        "name": "getAlias",
        "optional": false,
        "typeAnnotation": {
          "type": "FunctionTypeAnnotation",
          "returnTypeAnnotation": {
            "type": "StringTypeAnnotation"
          },
          "params": [
            {
              "name": "a",
              "optional": false,
              "typeAnnotation": {
                "type": "TypeAliasTypeAnnotation",
                "name": "ObjectAlias"
              }
            }
          ]
        }
      }
    ]
  }
}
```

and then generates the appropriate structs on the native side and generates [this](https://www.internalfb.com/code/fbsource/[d3ab2f79b377]/xplat/js/react-native-github/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap?lines=818)

```

Reviewed By: hoxyq

Differential Revision: D67806838

fbshipit-source-id: 31f20455c816fdb6b1a86f8f9d0f6f7d0a452754
2025-01-06 18:42:37 -08:00
Eli White c748b44183 Add command type to CompleteTypeAnnotation (#48475)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48475

This will be needed for the compat-check.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D67806831

fbshipit-source-id: b660c9557cafbfa2e713e85a0fd2bdc9edabf537
2025-01-06 18:42:37 -08:00
Eli White 825492b199 Separate component array types and command array types (#48474)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48474

The previous definition said that you could put prop types into commands, which definitely isn't allowed.

For example, the schema would have allowed `WithDefault` types.

```
interface NativeCommands {
  +methodInt: (viewRef: React.ElementRef<NativeType>, a: WithDefault<string, 'hi'>) => void;
}
```

This change separates out the things that are allowed in commands from what's allowed in props.

Commands should be very similar to what's allowed in native modules, but it isn't exact enough to be able to merge those.

## Changelog:
[General][Breaking] - Codegen: Separate component array types and command array types

Reviewed By: cipolleschi

Differential Revision: D67806818

fbshipit-source-id: 58e504fe2e2e5efa612e836b18af22a167e7ae2f
2025-01-06 18:42:37 -08:00
Eli White c91cfd1ec1 Simplify CompleteTypeAnnotation (#48473)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48473

This is such a simpler approach lol.

I'll need this later for when I want to pass in arrays or objects of these types to the compat check

Changelog: [internal]

Reviewed By: cipolleschi

Differential Revision: D67806812

fbshipit-source-id: 5cc361815fea901098d2931ba78293693ecc0a35
2025-01-06 18:42:37 -08:00
Eli White 02c6790842 Make CompleteType contain module and component reserved names (#48477)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48477

Over the years of copying and moving and renaming types through CodegenSchema, this type ended up in the Command params, although the Command parser doesn't allow it.

I made this change to a fixture:

{F1974104959}

and got this error

```
 FAIL  xplat/js/react-native-github/packages/react-native-codegen/src/parsers/flow/components/__tests__/component-parser-test.js
  ● RN Codegen Flow Parser › can generate fixture COMMANDS_DEFINED_WITH_ALL_TYPES

    Unsupported param type for method "scrollTo", param "speed". Found UnionTypeAnnotation

      127 |       default:
      128 |         (type: empty);
    > 129 |         throw new Error(
          |               ^
      130 |           `Unsupported param type for method "${name}", param "${paramName}". Found ${type}`,
      131 |         );
      132 |     }
```

Also, a default value for enum an argument of a Command doesn't make sense anyways.

Commands should probably have support for enums and string literal unions, but that's out of scope here.

Still need to add to this vec\concat on www: https://www.internalfb.com/code/www/[ebfa58f888a6064e17879934d447f59bcc2b6951]/flib/intern/sandcastle/react_native/ota_steps/SandcastleOTACompatibilityCheckReportingStep.php?lines=62

Changelog: [internal]

Reviewed By: cipolleschi

Differential Revision: D67806808

fbshipit-source-id: f0f31cca30abbf61f569933ea7c49cf6bfd18a3f
2025-01-06 18:42:37 -08:00
Christoph Purrer c8552519b3 Make SurfaceManager const correct (#48485)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48485

[Changelog] [Internal] - Make SurfaceManager const correct

This marks methods which don't modify member props as `const` and others as non `const`.

The current API signature is misleading as `const` methods do alter `mutable` members

Reviewed By: rshest

Differential Revision: D67820439

fbshipit-source-id: 6a991bd7ccbd464c2390e33e0c29b136892d65e0
2025-01-06 14:41:39 -08:00
Luna Wei 8681fc2ab2 Remove optionality of intersectionRect
Summary:
Changelog:
[General][Changed] - Mark `intersectionRect` required in `NativeIntersectionObserverEntry` to reflect native logic.

Reviewed By: rubennorte

Differential Revision: D67868219

fbshipit-source-id: cdc15908c0cf687b13d1424a59ee1e2383811ab3
2025-01-06 13:30:10 -08:00