Commit Graph

38536 Commits

Author SHA1 Message Date
Joe Vilches a24a93ee54 Move NodeToString.cpp to benchmark and remove interal usages (#42710)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42710

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

This is no longer going to be built with normal yoga so we are going to switch to a public API

Reviewed By: NickGerleman

Differential Revision: D53141235

fbshipit-source-id: 259270a4cd91ef0dab91cefba9c41953b6340d78
2024-02-02 15:44:23 -08:00
Joe Vilches 7b26848a47 Remove public APIs for YGNodePrint and YGConfigSetPrintTreeFlag (#42688)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42688

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

We are planning on overhauling NodeToString to output JSON instead of HTML for the purposes of better benchmarking and capturing trees in JSON format to benchmark later. This gives us a bit of a headache as we have to revise several build files to ensure this new library works, ensure that it is only included in certain debug builds, and deal with the benchmark <-> internal cross boundary that arises as the benchmark code (which is a separate binary) tries to interact with it.

On top of it all this is really not used at all.

The plan is to rip out this functionality and just put it in a separate binary that one can include if they really want to debug. That means that it cannot exist in the public API, so I am removing it here.

Private internals come next

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D53137544

fbshipit-source-id: 7571d243b914cd9bf09ac2418d9a1b86d1bee64a
2024-02-02 15:44:23 -08:00
Alex Taylor (alta) 64debd9a96 Update hermes-parser and related packages in xplat to 0.19.0 (#42824)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42824

Bump hermes-parser and related packages to [0.19.0](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [internal]

Reviewed By: gkz

Differential Revision: D53359412

fbshipit-source-id: e77c798232006eecb13611fbf01a4cb6d56cc310
2024-02-02 15:02:46 -08:00
Jack Pope 41045a1486 Refactor toJSON (#42828)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42828

Updates to toJSON:
- return object tree instead of formatted snapshot string. Applying the `'react.test.json'` symbol lets Jest do the formatting work for us
- Source props from `pendingProps` on `instanceHandle`. This adds props such as `pointerEvents` and `style` which were present on RTR's snapshots but don't get included in the node's `props` collection
- Render text node as text value, instead of RCTRawText like `<RCTRawText text="Hello" />`

Changelog: [internal]

Reviewed By: kassens

Differential Revision: D53321821

fbshipit-source-id: 033637b9152441c318c9c797aa9223ff15768873
2024-02-02 14:34:43 -08:00
Jack Pope 48ec680b04 Run RNTR against simple product test (#42827)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42827

This is a simple snapshot test using ReactTestRender's toJSON. We have almost the same functionality in RNTR already, so let's see if we can support tests like this.

Merging the new setup and environment with the existing configuration (https://fburl.com/code/s85sma77) still causes issues so here we add unmocking and new setup inline. Added task T177114228 to track following up on this

Note that some formatting is changed and props are dropped on the snapshot. This is resolved with refactor in next diff

Changelog: [internal]

Reviewed By: yungsters

Differential Revision: D53321823

fbshipit-source-id: a20f77c29fefb9172f8a8189bd821dd202b2ff02
2024-02-02 14:34:43 -08:00
Jack Pope bdc88c3fad Allow package to be imported by tests in xplat (#42826)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42826

yungsters debugged the failing test library import and found that we don't yet support package exports. Switching this to main with an index file allows us to import the library in other places.

Changelog: [internal]

Reviewed By: yungsters

Differential Revision: D53240712

fbshipit-source-id: 046a7d1678cbca181e4a4de607a9c0e7490ef047
2024-02-02 14:34:43 -08:00
Christoph Purrer af8c82dace Fix ReactCommon.podspec import for React-logger (#42800)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42800

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D53340183

fbshipit-source-id: badc508c75e9fe79a86430f1fc6b626e8278cb44
2024-02-02 11:01:00 -08:00
Christoph Purrer db46288d1b Bridgeless: Unify legacyModuleProvider setup (#42790)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42790

A tiny bit of refactoring to unify the setup

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D53313332

fbshipit-source-id: 4642f7d1dee8adf821b06c2ed25be09fd5dce098
2024-02-02 10:28:52 -08:00
Moti Zilberman cc34acefab Create HermesRuntimeAgent (#42747)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42747

Changelog: [Internal]

Implements a `RuntimeAgent` (D51231326) for Hermes for the modern CDP backend, based on the `CDPHandler` API that Hermes exposes currently.

## A note on `console`

We unfortunately have to disable `console` interception (D51234334 / equivalently D52971652) because `CDPHandler`'s current implementation is not aligned with the Agent concept:

* Agents are only created once a session has started, but the `console` interceptor needs to be injected at VM startup.
* Agents should not clobber each other's shared state (nor consume excessive resources per Agent), but each `CDPHandler` would install its own independent `console` interceptor if enabled.

We will enable CDP `console` support in the modern backend in future work. This will require either some additional plumbing in RN (e.g. to safely access JSI from an Agent/Target) or some additional work in Hermes.

## Conditional compilation based on `HERMES_ENABLE_DEBUGGER`

`HermesRuntimeAgent.cpp` compiles both with and without `-DHERMES_ENABLE_DEBUGGER`, which is the flag Hermes uses to control the availability of `CDPHandler` (and its containing Buck library).

If the debugger is not enabled, `HermesRuntimeAgent` reduces to a `FallbackRuntimeAgent`. In either case, no Hermes debugger headers leak into `HermesRuntimeAgent.h`, so callers don't need to check `#ifdef HERMES_ENABLE_DEBUGGER`, and the overall CDP backend infra is not gated on whether the Hermes debugger is compiled in.

Reviewed By: huntie

Differential Revision: D51234333

fbshipit-source-id: ccbca443560308c5edba4b9689501d01059fdd94
2024-02-02 10:24:10 -08:00
David Vacca 4e6eba7a2d Mark classes of package fabric as @Nullsafe (#42725)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42725

All these classes are NullSafe, let's mark them as NullSafe(Local) to ensure lint detect errors in the future

changelog: [internal] internal

Reviewed By: NickGerleman

Differential Revision: D53200097

fbshipit-source-id: dad54f5bf03967b5d4126757ab0d5424534af888
2024-02-02 10:22:02 -08:00
David Vacca 239f9bf7eb Mark classes of package devSupport as @Nullsafe (#42723)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42723

All these classes are NullSafe, let's mark them as NullSafe(Local) to ensure lint detect errors in the future

changelog: [internal] internal

Reviewed By: NickGerleman

Differential Revision: D53200099

fbshipit-source-id: a5b244da401fb23c9579728c7261312ab200d623
2024-02-02 10:22:02 -08:00
David Vacca 4c6c57da73 Mark classes of packages command and condif as @Nullsafe (#42724)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42724

All these classes are NullSafe, let's mark them as NullSafe(Local) to ensure lint detect errors in the future

changelog: [internal] internal

Reviewed By: NickGerleman

Differential Revision: D53200100

fbshipit-source-id: e6355af332c601e0d61e698d2fa0506c6a293989
2024-02-02 10:22:02 -08:00
Fabrizio Bertoglio 349d5502d0 Fix TextInput vertical alignment issue when using lineHeight prop on iOS without changing Text baseline (Paper - old arch) (#38359)
Summary:
This PR fixes visual regression introduced with https://github.com/facebook/react-native/pull/37465#issuecomment-1631974927

Adding paragraphStyle.maximumLineHeight to a iOS UITextField displays the text under the UITextField ([ios-screenshot-1][1], [ios-screenshot-2][2], [ios-screenshot-3][3]).

The PR implements the logic from RCTTextShadowView [#postprocessAttributedText](https://github.com/facebook/react-native/blob/9ab27e8895d6934e72ebdc601d169578ab9628f1/packages/react-native/Libraries/Text/Text/RCTTextShadowView.m#L165-L167) in RCTBaseTextInpuShadowView [#uiManagerWillPerformMounting](https://github.com/facebook/react-native/blob/4c944540f732c6055d447ecaf37d5c8f3eec1bc4/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputShadowView.m#L130-L192).

[1]: https://user-images.githubusercontent.com/24992535/238834159-566f7eef-ea2d-4fd4-a519-099b0a12046c.png "ios-screenshot-1"
[2]: https://user-images.githubusercontent.com/24992535/238834184-feb454a9-6504-4832-aec8-989f1d027861.png "ios-screenshot-2"
[3]: https://user-images.githubusercontent.com/24992535/238834283-cf572f94-a641-4790-92bf-bbe43afb1443.png "ios-screenshot-3"

[4]: https://github.com/Expensify/App/assets/24992535/06726b45-7e35-4003-9fcc-50c8d0dff0f6
[5]: https://github.com/Expensify/App/assets/24992535/d9745d29-8863-4170-bcc3-e78fa7e550d2

fixes https://github.com/facebook/react-native/issues/28012 fixes https://github.com/facebook/react-native/issues/33986
Related https://github.com/facebook/react-native/issues/35741 https://github.com/facebook/react-native/issues/31112

## Changelog:

[IOS] [FIXED] - Fix TextInput vertical alignment issue when using lineHeight prop on iOS without changing Text baseline (Paper - old arch)

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

Test Plan: Extensive test included in the PR comments https://github.com/facebook/react-native/pull/37465#issuecomment-1551459879 and https://github.com/Expensify/App/issues/17767#issuecomment-1640032626

Reviewed By: cipolleschi

Differential Revision: D52325261

Pulled By: dmytrorykun

fbshipit-source-id: d072a598bfaafbbffc41005b1fda1795cf3d8ab9
2024-02-02 09:19:28 -08:00
Fabrizio Cucci ac43ee1b92 Convert Button to ESM (#42796)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42796

As per title.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D53308084

fbshipit-source-id: 872f828b8dc019e65cd32549f9633efb6cde18f5
2024-02-02 08:31:39 -08:00
Pieter De Baets 069c244d48 Revert D53330004: Update hermes-parser and related packages in fbsource to 0.19.0
Differential Revision:
D53330004

Original commit changeset: c20ef324ac2a

Original Phabricator Diff: D53330004

fbshipit-source-id: 4953b2ff66fd3d8ad31dae7fa4c72e92ebef6a8c
2024-02-02 05:53:06 -08:00
Max Phillips 184b295a01 Remove takeSnapshot from UIManager TypeScript types (#42779)
Summary:
This PR removes the TypeScript entry for `UIManager.takeSnapshot()`. This function does not appear to be implemented anywhere, and calling it throws `TypeError: _reactNative.UIManager.takeSnapshot is not a function (it is undefined)`.

I think this functionality is still supported by [react-native-view-shot](https://github.com/gre/react-native-view-shot) for anyone who needs it!

## 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
-->
[General] [Removed] - Removed type definition `UIManager.takeSnapshot()`

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

Test Plan: Ran TypeScript checks.

Reviewed By: cipolleschi

Differential Revision: D53307137

Pulled By: NickGerleman

fbshipit-source-id: 2e65c58c77bcde4f36f5065295d15757c519239d
2024-02-02 01:02:59 -08:00
Alex Taylor (alta) 12155c464c Update hermes-parser and related packages in fbsource to 0.19.0 (#42798)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42798

Bump hermes-parser and related packages to [0.19.0](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [internal]

Reviewed By: mvitousek, SamChou19815

Differential Revision: D53330004

fbshipit-source-id: c20ef324ac2a295c3f42fa6bbe1dbbf816146ccb
2024-02-01 19:11:47 -08:00
Michael Lohmann 35f5c3a204 VirtualizedList/FlatList: Stricter typing for onViewableItemsChanged (#42773)
Summary:
The previous typing of FlatList and VirtualizedList did not convey any information on the type of the items passed in to `onViewableItemsChanged`, but instead the type was set to `any`. This PR adds the type information.

I set a default type `any` for thy ViewToken, because the type is exported and not having it would be a breaking change if that type is used. Like this it gracefully falls back to the default behavior of the `any` type.

Notice: I don't know how typing in "flow" works, but the same "issue" seems to be in there as well. Maybe someone with more flow experience can fix that as well:
https://github.com/facebook/react-native/blob/ae42e0202de2c3db489caf63839fced7b52efc5d/packages/virtualized-lists/Lists/ViewabilityHelper.js#L19-L20

## Changelog:

[GENERAL] [FIXED] - Add type information for items of VirtualizedList in `onViewableItemsChanged` signature
[GENERAL] [FIXED] - Add type information for items of FlatList in `onViewableItemsChanged` signature

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

Test Plan:
Without the changes, typecheck of the project was fine, but with the changes applied to the node_modules/react-native copy a type error was found:
```
$ npm run typecheck

> my-project@1.0.0 typecheck
> tsc --skipLibCheck

src/MyComponent.tsx:385:29 - error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'.
  Type 'string | number' is not assignable to type 'number'.
    Type 'string' is not assignable to type 'number'.

385                             viewableItems
                                ~~~~~~~~~~~~~
386                                 .filter(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Reviewed By: rozele

Differential Revision: D53276749

Pulled By: NickGerleman

fbshipit-source-id: 3fa5c65b388a59942c106286ac502a85c583da50
2024-02-01 15:25:10 -08:00
Fabrizio Cucci 07e8ae42be Convert Button to function component (#42795)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42795

As per title.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D53308758

fbshipit-source-id: 7efb2f5c6ac4aad54082a12cdcff13e9445fff58
2024-02-01 14:21:56 -08:00
Fabrizio Cucci ad52791c15 Drop @generate-docs from all components (#42794)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42794

As mentioned also in D53307738, `generate-docs` doesn't seem to be used.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D53308808

fbshipit-source-id: c2504c36d42a508621572a237964ff51cff75e70
2024-02-01 14:21:56 -08:00
Nicola Corti 78f50020ef Back out "Add onUserLeaveHint support to ReactActivityDelegate" (#42791)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42791

Original commit changeset: 491fc062421d

Original Phabricator Diff: D53279501

Reviewed By: mdvacca

Differential Revision: D53321360

fbshipit-source-id: 36ce929250077a9c2919ba7f01d937dc09986ec8
2024-02-01 13:46:38 -08:00
Fabrizio Cucci 107f2f997e Align ActivityIndicator JSDoc to website doc (#42789)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42789

I stumbled upon the JSDoc in the [ActivityIndicator](https://fburl.com/code/aq8ljc86) component and noticed a discrepancy wrt our [website](https://reactnative.dev/docs/activityindicator).

So I looked more and found out that the doc is not really generated from the code (even though there is a confusing `generate-docs`) but actually lives in the react-native-website [codebase](https://github.com/facebook/react-native-website/blob/994cab25b63d4bed57cedfba95f0133537d42ac7/docs/activityindicator.md?plain=1#L6).

Here I'm just aligning the JSDoc to the source of truth (i.e. react-native-website) but this begs the question on whether there is any value in keeping both.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D53307738

fbshipit-source-id: b01691460714687f35f875ec51c310333b667fc8
2024-02-01 11:56:57 -08:00
Moti Zilberman a0b107339c Log warning when debugging an unsupported engine (#42745)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42745

Changelog: [Internal]

Creates the `FallbackRuntimeAgent` class and uses it (as the name would suggest) as a fallback in cases where no other suitable `RuntimeAgent` implementation is available.

`FallbackRuntimeAgent`'s only feature is logging a message explaining that the runtime isn't debuggable. In the final product, users shouldn't get this far into launching the debugger if they're not using a compatible engine like Hermes, but this is a nice touch in case they do. (It's also useful for testing while we're working on landing the actual Hermes integration.)

Reviewed By: huntie

Differential Revision: D51449229

fbshipit-source-id: 3b3455a8b482b33bccbb6cc90083aad15052a3e5
2024-02-01 11:03:41 -08:00
Moti Zilberman 97723efc8d Track domain enable/disable bit in shared state across Agents (#42746)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42746

Changelog: [Internal]

Formally introduces the concept of "session state" to the modern CDP backend, with the simplest possible implementation:

* `PageTargetSession` has a mutable `SessionState` member.
* All agents receive the same `SessionState&` in their constructor (with `SessionState`'s lifetime being the caller's responsibility).
* It's only legal to read/write to `SessionState` on the thread where requests are handled and Agents are created (the "main" thread).
* Agents are expected to play nice and not clobber each other's state in `SessionState`; this is *not* protected with visibility or `const`ness, however.
  * We'll probably want to come up with some API-level mechanism to control this as the complexity of our agents grows.

## Current use case: `<Domain>.enable`

The first use case for session state is to let `PageAgent` manage the `Log.enable` and `Runtime.enable` state for the session. This will allow agents created later in the session (or recreated as part of a reload) to emit Log and Runtime notifications without waiting for additional `enable` messages (that the client is not required to send).

We'll likely want to generalise this design to arbitrary domains in some way (e.g. add a top-level domain router that agents register with explicitly?) but I went with the simplest implementation for our current needs.

NOTE: The CDP spec doesn't state this explicitly, but it's clear from Chrome's behaviour that a `<Domain>.enable` command is intended to be session-scoped and survive reloads.

## Future use case: Instance/Runtime state persistence

The `<Domain>.enable` use case could have been solved with passing *immutable* state to Agents (`const SessionState&`). We make the state mutable in anticipation of `HermesRuntimeAgent` needing to store its own state in the session down the line, which we know is going to be needed in order for breakpoints to survive reloads.

Agents that never need to mutate state SHOULD only store this as a const reference.

Reviewed By: huntie

Differential Revision: D53006916

fbshipit-source-id: a0443c507294faa94efdf25b2f1670129774dc78
2024-02-01 11:03:41 -08:00
Moti Zilberman adec8d303b Create RuntimeAgent interface to handle messages for VM (#42635)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42635

Changelog: [Internal]

Adds a RuntimeAgent interface to the modern CDP backend, plus an `InstanceTargetDelegate::createRuntimeAgent()` method. This allows the RN integration to provide an engine-specific CDP implementation.

This diff includes all the plumbing in Bridge and Bridgeless to route `createRuntimeAgent()` calls to the right place - ending up at `JSExecutor::createRuntimeAgent()` and `JSIRuntimeHolder::createInspectorAgent` respectively - at which point we currently return `nullptr` to signify that JS debugging isn't supported.

## Next steps

In upcoming diffs we'll add concrete implementations of `RuntimeAgent`, and teach both Bridge and Bridgeless to create them as appropriate:

* `HermesRuntimeAgent` for Hermes
* `FallbackRuntimeAgent` for all other JS engines (JSI or not)

We'll also (likely) add assertions to ensure that any JSI runtime that reports itself as "inspectable" (a flag used to control some of the in-app debugging UI) comes with a non-default `createRuntimeAgent()` implementation. We avoid this for now to prevent crashing the modern backend on Hermes.

NOTE: Like the rest of the modern CDP backend, the `RuntimeAgent` API is 100% experimental and subject to change without notice. A *future* version of this API will allow out-of-tree JSI engines to integrate with the modern CDP backend. Either way, it is intended strictly for the use case of integrating with a JS engine, not for adding any other framework-level CDP functionality.

Reviewed By: huntie

Differential Revision: D51231326

fbshipit-source-id: 81e87c5134df73cc4aac0f9d5793a5236b5720d6
2024-02-01 11:03:41 -08:00
Wojciech Dróżdż 3b6c522942 Add onUserLeaveHint support to ReactActivityDelegate (#42741)
Summary:
This PR adds `onUserLeaveHint` support into the `ReactActivityDelegate`. It allows modules to receive an event every time user moves the app into the background. This is slightly different than `onPause` - it's called only when the user intentionally moves the app into the background, e.g. when receiving a call `onPause` should be called but `onUserLeaveHint` shouldn't.

This feature is especially useful for libraries implementing features like Picture in Picture (PiP), where using `onUserLeaveHint` is the [recommended way of auto-entering PiP](https://developer.android.com/develop/ui/views/picture-in-picture#:~:text=You%20might%20want%20to%20include%20logic%20that%20switches%20an%20activity%20into%20PiP%20mode%20instead%20of%20going%20into%20the%20background.%20For%20example%2C%20Google%20Maps%20switches%20to%20PiP%20mode%20if%20the%20user%20presses%20the%20home%20or%20recents%20button%20while%20the%20app%20is%20navigating.%20You%20can%20catch%20this%20case%20by%20overriding%20onUserLeaveHint()%3A) for android < 12.

## Changelog:

[ANDROID] [ADDED] - Added `onUserLeaveHint` support into `ReactActivityDelegate`

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

Test Plan: Tested in the `rn-tester` app - callbacks are correctly called on both old and new architecture.

Reviewed By: javache

Differential Revision: D53279501

Pulled By: cortinico

fbshipit-source-id: 491fc062421da7e05b78dc818b22cd1ee79af791
2024-02-01 09:07:15 -08:00
zhongwuzw aefca27c67 Fixes Android compile failed. (#42787)
Summary:
![image](https://github.com/facebook/react-native/assets/5061845/557c51fd-e675-4d36-b85d-f9367b44dfda)
cc. cortinico

## Changelog:

[ANDROID] [FIXED] - Fixes Android compile failed.

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

Test Plan: N/A

Reviewed By: cipolleschi

Differential Revision: D53312698

Pulled By: cortinico

fbshipit-source-id: 29fdd1957c2310cef9b7aca06b09b5691176ea58
2024-02-01 08:33:15 -08:00
Riccardo Cipolleschi 7c5e4262d4 Fix publishing of React Native with the right version (#42783)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42783

This change will fix the publishing of Nightlies for React Native with the right version

## Changelog:
[Internal] - Update the package.json of react native correctly.

Reviewed By: cortinico, huntie

Differential Revision: D53309082

fbshipit-source-id: 2fa4d4fdf4f984603c6b3d3690fa3c464ee6d030
2024-02-01 07:40:11 -08:00
almouro 02fe2f0e38 Fix featureflags c++ library loading on Android (#42770)
Summary:
On latest `main`, RN Tester was crashing for me just after loading the JS bundle with `java.lang.UnsatisfiedLinkError: dlopen failed: library "libreactfeatureflagsjni.so" not found`

It seems to be named `featureflagsjni` instead in [here](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/CMakeLists.txt#L11)

## Changelog:

No changelog needed

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

Test Plan:
```bash
./gradlew :packages:rn-tester:android:app:installHermesDebug -PreactNativeArchitectures=arm64-v8a
```

Then run the app, the app was crashing before the fix, not crashing now

Reviewed By: javache

Differential Revision: D53268873

Pulled By: cortinico

fbshipit-source-id: f098ca12baadab358f72b1c9d5720123248b8e1a
2024-02-01 06:42:27 -08:00
Alex Hunt 76598de621 Reorganise and document release script entry points (#42774)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42774

Reorganise release scripts so that command entry points are grouped based on execution context, which also reflects dependencies between scripts.

Also:

- Document the current behaviours of these scripts.
- Relocate utils out of the root contents.
- Replace `exec` call to `set-rn-version` script with function import.

NOTE: `yarn trigger-react-native-release` (documented command in release process) is unchanged, since this is aliased from `package.json`.

```
├── releases
│   ├── templates/
│   ├── utils/
│   ├── remove-new-arch-flags.js
│   ├── set-rn-version.js
│   └── update-template-package.js
├── releases-ci
│   ├── prepare-package-for-release.js
│   └── publish-npm.js
└── releases-local
    └── trigger-react-native-release.js
```

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53274341

fbshipit-source-id: eec2befc43e7a47fd821b2e2bcc818ddffbb6cf7
2024-02-01 06:02:17 -08:00
Riccardo Cipolleschi ebb55a780a Fix Template for Bridgeless mode (#42781)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42781

Change in [31cf4c4ead](https://github.com/facebook/react-native/commit/31cf4c4eada59bde62f30e14024719779fc23a91) broke the template for bridgeless as we changed the signature of a method in the header of `RCTAppDelegate`.

This change aligns the API between RCTAppDelegate and the template's AppDelegate

## Changelog:
[iOS][Fixed] - Align the the bundleURL API from `RCTAppDelegate` to template's `AppDelegate`

Reviewed By: cortinico, dmytrorykun

Differential Revision: D53274434

fbshipit-source-id: 25bad702ba05db2e3a6a9449abbda7d8e2fdb8a0
2024-02-01 02:53:52 -08:00
Dmitry Rykun c6c23042a4 iOS Codegen: bring back support for defining external libraries in react-native.config.js (#42771)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42771

This feature was first introduced here https://github.com/facebook/react-native/pull/34580
And then removed here https://github.com/facebook/react-native/pull/41654
The motivation for its removing was that Node resolver should handle all those cases for which `react-native.config.js` was used. But it turns out that it fails for the setup that `react-native-builder-bob` has.
This diff brings back support for defining external libraries in `react-native.config.js`.

Changelog: [iOS][Fixed] - Bring back support for defining external libraries in react-native.config.js

Reviewed By: cipolleschi

Differential Revision: D53267857

fbshipit-source-id: 7625dfe7b4a4651eb60eaec725f94f222a244e30
2024-02-01 02:53:48 -08:00
David Vacca 7b36233ae1 Fix event emits during initial rendering in Fabric (#42777)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42777

During view preallocation eventEmitter information is not being passed to the platform. This causes bugs with emision of events during initial rendering when using the new Fabric Event dispatching system.

e.g. Rendering a TextInput that has 'onFocus' event and also has autoFocus enabled.

The new Fabric Event dispatching system dispatch events earlier (this is expected)

In this diff I'm fixing this issue by ensuring that all preallocated views have an eventEmitter (when its shadowNode has an eventEmitter)

This was actually implemented in the past, but in order to optimize, we run an experiment (D29117957) and it was later deleted.
(D40356386). I didn't find details of the results of the experiment.
We could run another experiment to understand potential negative perf impact of this change, although I believe it's the right thing to do here.

Changelog: [Android][Fixed] Fix delivery of events during initial rendering in new architecture

Reviewed By: sammy-SC

Differential Revision: D53108114

fbshipit-source-id: 0b56b7495db63e4a478f4b34e91f4bcbf452ef92
2024-02-01 00:54:27 -08:00
Nick Gerleman 1170a68755 Delete traitCast and identifier traits (#42748)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42748

React Native has globally enabled RTTI within `rn_xplat_cxx_library`, ahead of RTTI being forced on (regardless of flag) in Android apps (it was previously enabled everywhere but Android, which has caused us no small share of headaches, with public JSI APIs designed around clients using RTTI).

This diff:
1. Mechanically replaces usages of `traitCast` with equivalent calls to `dynamic_cast` or `dynamic_pointer_cast`
    1. These have similar semantics as current iteration of `traitCast`, where we return `nullptr` for pointer form, or throw on invalid cast for reference form.
2. Removes `IdentifierTrait` as a requirement to cast to a ShadowNode
3. Removes the ShadowNode traits used solely as cast identities

This enables consistent usage of `dynamic_cast` (including for user defined ShadowNodes), and also exposes some places where `traitCast` allowed implicit const conversion.

The OSS builds should already have RTTI on, and will be able to use `dynamic_cast` on RN provided types (`traitCast` is not extendable).

Changelog:
[General][Breaking] - Delete traitCast and identifier traits

Reviewed By: sammy-SC

Differential Revision: D53215009

fbshipit-source-id: d20cbf66b725f5565fa5d03332010d87f2b08b61
2024-02-01 00:33:54 -08:00
Nick Gerleman 810c2051ee Fix "swapLeftAndRight" unsafe static_cast (#42721)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42721

If left and right are swapped, this code assumes every yoga layoutable shadownode is a view, and mutates its props as if they were ViewProps. This is not safe, and could lead to memory corruption.

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D53213652

fbshipit-source-id: c43e0f80fdd5889761317c1243ccc0ab392e3443
2024-02-01 00:33:54 -08:00
David Vacca 044b50b53d Re-enable CustomDrawOrder in RN Android (#42719)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42719

The task T175989432 started firing on October 30 2020, which correspond to the landing of D24512203. I believe disabling CustomDrawOrder could be a potential cause of T175989432, that's why in this diff I'm creating an experiment to understand what is the impact (negative or positive) of re-enabling CustomDrawOrder in RN Android

Original diff: D24512203

Changelog: [Internal] internal

Reviewed By: javache

Differential Revision: D53150292

fbshipit-source-id: f0abbc7d175c2cd717ce87bbe69aeaf3db0b0e5c
2024-01-31 23:28:32 -08:00
Luna Wei ebc2831d5b set unified version (#42776)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42776

Changelog: [Internal] set all monorepo packages (including react-native) to one version and update all inter-dependencies (including the template)

Reviewed By: huntie

Differential Revision: D53251917

fbshipit-source-id: 95330ca66dcb7234a3f09752ecc3ed9087ced4bf
2024-01-31 19:32:08 -08:00
Jakub Trzebiatowski 6a8a28b80f CustomStyleSpan: Move the class comment (#42700)
Summary:
`CustomStyleSpan`: Move the class comment (it was misplaced)

## Changelog:

[INTERNAL] [FIXED] - `CustomStyleSpan`: Move the class comment

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

Reviewed By: yungsters

Differential Revision: D53195908

Pulled By: NickGerleman

fbshipit-source-id: f77575e16f76871dcf10d75448282b2166003412
2024-01-31 15:01:22 -08:00
Blake Friedman 9c0fe734fb constrain on github.actor
Summary: Currently rejecting all users, use the [github.actor](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context:~:text=The%20username%20of%20the%20user%20that%20triggered,run%20(github.triggering_actor)%20has%20different%20privileges.)

Reviewed By: hoxyq

Differential Revision: D53275232

fbshipit-source-id: 54bbbdb857db6c642814953832e0ffdc55505deb
2024-01-31 13:12:47 -08:00
Blake Friedman 82e9a5e4f7 Add Github Action to mirror partner's nightly CI results (#42744)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42744

This adds a nightlies-feedback workflow, which our partners can get permission to mirror the results of their nightlies CI workflows.  We do this to use our internal tools that are restricted to Meta owned Github projects.

The benefit to partners is that they can add this step to their workflow:

```
      - if: ${{ success() || failure() }}
        env:
          OUTCOME: ${{ contains(steps.*.conclusion, 'failure') && 'fail' || 'pass' }}
        run: |
          curl -X POST \
               -H "Accept: application/vnd.github.v3+json" \
               -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
               https://api.github.com/repos/facebook/react-native/actions/workflows/nightlies-feedback.yml/dispatches \
               -d "$(printf '{"ref":"main","inputs":{"outcome":"%s","stage":"needs_an_action","link":"http://github.com/some/action","version":"%s"}}' "$OUTCOME" "${{ inputs.version }}" )"

```

### Feedback:
It's complicated, but there are ways to simplify this for our users.  I'd like to prove out that it's valuable first with Expo.

### Limits:

There's certainly a lot of room for improvement, which we could provide with a published action (populate the ref correctly, simplify gathering the outcome, labelling of failing step correctly, etc...).

### Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53229996

fbshipit-source-id: 10e4ba5b5fd85935b1b03aaafa41ef8b96d2faca
2024-01-31 09:49:08 -08:00
generatedunixname89002005325672 7ea7904500 Daily arc lint --take KTFMT (#42772)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42772

Changelog: [Internal]

Reviewed By: bigfootjon

Differential Revision: D53257696

fbshipit-source-id: f384899361215288a3c9578ae22c9f097c4a3201
2024-01-31 09:36:16 -08:00
Riccardo Cipolleschi 68ae8cd5e9 Fix crash in the interop layer when components emits events as soon as are created (#42743)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42743

When working on Mobile Home, we found a component (RNCSafeAreaView) that was going through the interop layer.

The component eits an event as soon as its content view changes, but this is too early: the block that emits the event is still nil at that point in time and that makes the app crash.

There might be other components with similarbehavior, therefore, we are fixing it at the interop layer, setting the props immediately after the component is created.

## Changelog:
[iOS][Fixed] - Immediately set props of Components that goes through the interop layer

Reviewed By: sammy-SC

Differential Revision: D53230471

fbshipit-source-id: 90a19e0e87fea381b348b5a7e723ab8b416b828c
2024-01-31 09:09:36 -08:00
hurali97 ae42e0202d Changelog: 0.71.16 (#42759)
Summary:
## Changelog:

Changelog: [Internal] Generated 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

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

Reviewed By: cortinico

Differential Revision: D53268094

Pulled By: huntie

fbshipit-source-id: a18d513df4614be1b7715c9c69d8de58baac9548
2024-01-31 07:27:06 -08:00
Rubén Norte c7bef93af0 Rename performance.reactNativeStartupTiming as performance.rnStartupTiming (#42762)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42762

This renames `performance.reactNativeStartupTiming` as `performance.rnStartupTiming` to align with the recommended vendor prefix for React Native.

This API is still private, so it's safe to rename.

Changelog: [internal]

Reviewed By: javache

Differential Revision: D53264515

fbshipit-source-id: 6e7a222901071594cac0ca8a0ac78e56e60ab132
2024-01-31 07:16:21 -08:00
Riccardo Cipolleschi 37cb84db96 Fix template jobs, broken for moved file (#42767)
Summary:
Some jobs are failing because we moved a file and we did not update the CI with the new path

## Changelog:
[Internal] - Update path to relocated file in CI

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

Test Plan: CircleCI is green (a part from test_android, fixed by another PR)

Reviewed By: huntie, dmytrorykun

Differential Revision: D53266042

Pulled By: cipolleschi

fbshipit-source-id: 7e611b96c204cdbbf794a731fe0db58cb31657fb
2024-01-31 06:31:46 -08:00
Nicola Corti 123934581b Fix broken test_android on main (#42763)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42763

Fix broken test_android on main

Changelog:
[Internal] [Changed] - Fix broken test_android on main

Reviewed By: cipolleschi

Differential Revision: D53264488

fbshipit-source-id: 58e0f3512878aa424bb6e1f0c930ff6c0769ee43
2024-01-31 05:30:35 -08:00
Alex Hunt b7b55854fe Enable Flow on misc release scripts (#42736)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42736

- Minimally enable Flow in these scripts. This would have caught outdated imports in D53001971 and D53228096.
- Update `publish-npm` script with async `main()` function.
- Also delete leftover `ReactNativeVersion.js.template` file.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D53225162

fbshipit-source-id: 9521291b7c84728e3e05af510ebf3244a9a189e5
2024-01-31 03:36:02 -08:00
zhongwuzw 0bbc311c8a Fixes root view's background color in bridgeless mode (#42739)
Summary:
Fixes root view's background color in bridgeless mode, the top area has white background color when in dark mode.

Before:
![Simulator Screenshot - iPhone 15 - 2024-01-30 at 23 28 48](https://github.com/facebook/react-native/assets/5061845/4359385d-370d-48cf-a58e-e2e9eb871400)

After:
![Simulator Screenshot - iPhone 15 - 2024-01-30 at 23 25 39](https://github.com/facebook/react-native/assets/5061845/5e9d2029-43d2-40c3-b2cb-c8a9ee80a5e1)

## Changelog:

[IOS] [FIXED] - [iOS] Fixes the root view's background color in bridgeless mode

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

Test Plan: Run RNTester and see the top area's background color.

Reviewed By: cortinico

Differential Revision: D53263621

Pulled By: javache

fbshipit-source-id: f18128464c9171ba8e0f6858c0608ce757349d27
2024-01-31 03:25:24 -08:00
ankit-tailor 8fca1c5854 fix: font variant typings (#42760)
Summary:
This PR fixes the typings for `fontVariant` style prop. Flow file has below typings but they were missing in typescript file.

```
  fontVariant?:
  | 'small-caps'
  | 'oldstyle-nums'
  | 'lining-nums'
  | 'tabular-nums'
  | 'common-ligatures'
  | 'no-common-ligatures'
  | 'discretionary-ligatures'
  | 'no-discretionary-ligatures'
  | 'historical-ligatures'
  | 'no-historical-ligatures'
  | 'contextual'
  | 'no-contextual'
  | 'proportional-nums'
  | 'stylistic-one'
  | 'stylistic-two'
  | 'stylistic-three'
  | 'stylistic-four'
  | 'stylistic-five'
  | 'stylistic-six'
  | 'stylistic-seven'
  | 'stylistic-eight'
  | 'stylistic-nine'
  | 'stylistic-ten'
  | 'stylistic-eleven'
  | 'stylistic-twelve'
  | 'stylistic-thirteen'
  | 'stylistic-fourteen'
  | 'stylistic-fifteen'
  | 'stylistic-sixteen'
  | 'stylistic-seventeen'
  | 'stylistic-eighteen'
  | 'stylistic-nineteen'
  | 'stylistic-twenty';
```

## Changelog:

[GENERAL] [ADDED] - Added missing typings for fontVariant style prop.

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

Test Plan: Tested manually.

Reviewed By: cortinico

Differential Revision: D53263569

Pulled By: javache

fbshipit-source-id: b127e0377cf9ceb50d094294d188f87a23038e5b
2024-01-31 03:13:18 -08:00
Kevin Gozali 841e00edaf iOS: RCTImageLoader: use static request counter for request IDs (#42720)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42720

The request ID was used for in-memory request caching purpose only. There wasn't much reason to use the sophisticated monotonic number, so let's just use a static 64-bit unsigned int counter. With the more-or-less unique UUID prefix, this should have an extremely low chance of collision.

Changelog: [Internal]

Reviewed By: philIip, sammy-SC

Differential Revision: D53205641

fbshipit-source-id: e6da12029624058dc877e9cbe2000af4df938870
2024-01-30 23:05:59 -08:00