Граф коммитов

24414 Коммитов

Автор SHA1 Сообщение Дата
Héctor Ramos 5ff7f809dc Circle CI: Use curl to download Hermes tarball
Summary:
When downloading Hermes from source on Circle CI, the process will fail because Circle CI macOS machines do not have wget installed.

Since curl can serve the same purpose and it is already part of the installed software on macOS machines, we can use curl in place of wget.

This change ensures Hermes can be built from source on Circle CI jobs.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D35294868

fbshipit-source-id: bb099b603ef64205d45b833882852b2f4d6060ca
2022-04-01 14:42:02 -07:00
Marshall Roch 16397e0d3c Deploy 0.175.0 to xplat
Summary: Changelog: [Internal]

Reviewed By: pieterv

Differential Revision: D35295392

fbshipit-source-id: 7d67c92a387502c14b5367bb9dcda68144a07433
2022-04-01 09:48:13 -07:00
Andrei Shikov 651c4c1b55 Add kotlin stdlib as a dependency for Java targets depending on Kotlin (#33535)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33535

Hack to support Kotlin functions in Buck compilation: adds Kotlin stdlib as a dependency to make sure upstream targets include Kotlin jvm internal classes.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D35284430

fbshipit-source-id: 0d29ad30386514c8df5376d0a6809d3105f0cd0f
2022-04-01 09:33:31 -07:00
Joe Frambach 8650220cf9 Fix ESLint and Typescript-ESLint disagreeing about function spacing (#33453)
Summary:
Fixes https://github.com/facebook/react-native/issues/33452 by replacing deprecated no-spaced-func ESLint rule and adding related TypeScript.

Changelog: [General][Fixed] - Update function spacing linting rules

See https://github.com/facebook/react-native/issues/33452 - Existing function spacing linting should pass as expected.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[CATEGORY] [TYPE] - Message

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

Reviewed By: lunaleaps, cortinico

Differential Revision: D35011944

Pulled By: GijsWeterings

fbshipit-source-id: 441650045d89a01a9114103da0c080643f9cb82c
2022-04-01 06:49:02 -07:00
William Candillon 864a8c11b2 ⬆️ Upgrade package to work with ESLint 8 (#33448)
Summary:
This are the two package upgrade required for this package to run with ESLint 8

## Changelog

[JavaScript] [Changed] `react-native-community/eslint-config` to work with ESLInt 8

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

Test Plan: Try the package with ESLint 8

Reviewed By: yungsters

Differential Revision: D35012075

Pulled By: GijsWeterings

fbshipit-source-id: 7de68c770fb31fe8ec06c805afea9b5f3a7a7294
2022-04-01 06:44:42 -07:00
Héctor Ramos 457dd45552 Remove Hermes Compiler from react-native package (restore nightly jobs)
Summary:
Restore `nightly` jobs to green by removing `hermesc` from `react-native` package.

As a result, when building Hermes from source on developer's machines, the Hermes compiler will need to be built as well.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D35289425

fbshipit-source-id: 2a058f714d670fbb4d0486e7280cab7dd923fc63
2022-04-01 02:41:04 -07:00
Nicola Corti 5dff920177 Template: Specify abiFilters if enableSeparateBuildPerCPUArchitecture is not set.
Summary:
As users can toggle `enableSeparateBuildPerCPUArchitecture` to create a split APK, once that is off, the `-PreactNativeArchitecture` is not correctly considered when building the local module.

This will make sure that, if users have `enableSeparateBuildPerCPUArchitecture` set to `false`, their
app is building the local `app_modules` only for the requested architectures.

Practically, users invoking with `--active-arch-only` might experience a build failure if they have a fully clean environment (would be forced to do a full build before using `--active-arch-only`). This addresses this scenario.

Changelog:
[Android] [Fixed] - Template: Specify abiFilters if enableSeparateBuildPerCPUArchitecture is not set.

Reviewed By: ShikaSD

Differential Revision: D35250700

fbshipit-source-id: 4e555888636cf182495fab2b4a562d93a70b9e66
2022-03-31 11:11:40 -07:00
matinzd d05a5d1551 feat: add getAll function to formdata (#32444)
Summary:
The getAll() method of the [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) interface returns all the values associated with a given key from within a FormData object.

## Changelog

[General] [Added] - Add getAll function to FormData class for getting all parts containing that key. This is also available in web API.

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

Test Plan: New test added in FormData-test.js

Reviewed By: lunaleaps

Differential Revision: D31798633

Pulled By: cortinico

fbshipit-source-id: ef29bb54e930532a671adbe707be8d1a64ff0d82
2022-03-31 07:59:01 -07:00
Rob Hogan 8b81dea74e Upgrade Metro dependencies to 0.70.0
Summary:
Upgrade React Native's direct dependencies on Metro packages from 0.69.1 to 0.70.0.

Metro release notes: https://github.com/facebook/metro/releases/tag/v0.70.0

Changelog:
[Internal]

Reviewed By: motiz88

Differential Revision: D35258405

fbshipit-source-id: f46f28c177f9f7fdaf2e680ab5c6c350cee4308d
2022-03-31 05:45:04 -07:00
Nicola Corti 34628ac12a react-native-gradle-plugin should not depend on react-native-codegen NPM package
Summary:
This adds an unnecessary dependency between two NPM package which can be avoided. See https://github.com/reactwg/react-native-releases/discussions/17#discussioncomment-2452813
for context.

Changelog:
[Internal] [Changed] - react-native-gradle-plugin should not depend on react-native-codegen NPM package

Reviewed By: dmitryrykun

Differential Revision: D35279729

fbshipit-source-id: f18f79809f115f28203ac0a843fafead63528904
2022-03-31 04:33:30 -07:00
Andrei Shikov 2a6a6851ec Rename C++ part of ReadableMapBuffer to JReadableMapBuffer
Summary:
Aligns naming with `JWritableMapBuffer` and other fbjni classes to indicate that it is a JNI binding.

Changelog: [Internal] - Rename C++ part of ReadableMapBuffer to JReadableMapBuffer

Reviewed By: mdvacca

Differential Revision: D35219323

fbshipit-source-id: a7eb644a700a35dc94fa18e4fb3cc68f2cfa3e99
2022-03-30 20:27:23 -07:00
Andrei Shikov 81e4249315 Adapt ReadableMapBuffer to MapBuffer interface
Summary:
Updates `ReadableMapBuffer` to conform to `MapBuffer` interface, to allow interchangeable use of `Readable/WritableMapBuffer` in the code.

Notable changes:
- MapBuffer.Entry getters are now represented as Kotlin properties and appended `Value` suffix (e.g. `entry.getInt()` becomes `entry.getIntValue()` in Java, or `entry.intValue` in Kotlin)
- `ByteBuffer` is imported in constructor instead of on demand. This method doesn't copy the data as the bytes are read directly from native heap, and benchmarking a 500-byte `MapBuffer` shows no difference in import speed.
- Internal logic of `ReadableMapBuffer` uses `UShort` kotlin type for key retrieval, for more correct representation of values.
- Explicit exception throws are replaced with `require` and `check` methods for `IllegalArgumentException` and `IllegalStateException` (default FB conversion).

The change also updates `ReadableMapBuffer` usages to `MapBuffer` interface where possible (virtually everywhere except JNI methods).

Changelog: [Android][Changed] - Adopt `MapBuffer` interface for `ReadableMapBuffer`

Reviewed By: mdvacca

Differential Revision: D35218633

fbshipit-source-id: 515dd974c27b2978ade325b2e1750ab8f068a20a
2022-03-30 20:27:23 -07:00
Andrei Shikov cf6f3b680b MapBuffer interface and JVM -> C++ conversion
Summary:
Creates a `WritableMapBuffer` abstraction to pass data from JVM to C++, similarly to `ReadableMapBuffer`. This part also defines a Kotlin interface for both `Readable/WritableMapBuffer` to allow to use them interchangeably on Java side.

`WritableMapBuffer` is using Android's `SparseArray` which has almost identical structure to `MapBuffer`, with `log(N)` random access and instant sequential access.

To avoid paying the cost of JNI transfer, the data is only transferred when requested by native `JWritableMapBuffer::getMapBuffer`. `WritableMapBuffer` also owns it data, meaning it cannot be "consumed" as `WritableNativeMap`, with C++ usually receiving copy of the data on conversion. This allows to use `WritableMapBuffer` as JVM-only implementation of `MapBuffer` interface as well, e.g. for testing (although Robolectric will still be required due to `SparseArray` used as storage)

Changelog: [Android][Added] - MapBuffer implementation for JVM -> C++ communication

Reviewed By: mdvacca

Differential Revision: D35014011

fbshipit-source-id: 8430212bf6152b966cde8e6f483b4f2dab369e4e
2022-03-30 20:27:23 -07:00
Luna Wei 8adedfeb15 Emit hover pointer events on Android
Summary: Changelog: [Internal] - Add logic to handle hover events, experimental

Reviewed By: vincentriemer

Differential Revision: D35116525

fbshipit-source-id: e47a94b5f04c14caadc08ad37e4d80adc1affc15
2022-03-30 19:12:42 -07:00
Luna Wei 4ce3914727 Add absolute child example to RNTester - W3CPointerEvents
Summary: Changelog: [Internal] Add another example for testing out the pointer events spec

Reviewed By: vincentriemer

Differential Revision: D35116565

fbshipit-source-id: 5f0cfeb871ae55071549c2289782401807f55515
2022-03-30 19:12:42 -07:00
Luna Wei 50070ec7c6 Add W3CPointerEvent example to RNTester Android
Summary:
Changelog: [Internal]
Add an example demonstrating pointer events

Reviewed By: vincentriemer

Differential Revision: D34422438

fbshipit-source-id: da378b4aaae8548f1114c1b23351527db6a6db69
2022-03-30 19:12:42 -07:00
Luna Wei c50e6b52fe Emit non-hover pointer events on Android (#33526)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33526

Changelog: [Internal] Experimental pointer event dispatching on Android: touch pointer support only, hover events to come later.

Reviewed By: vincentriemer

Differential Revision: D34132667

fbshipit-source-id: 6506d43b4ad16e11b10c3cd23e0231428209411f
2022-03-30 19:12:42 -07:00
Chris Olszewski ceae48c0f7 Add pfh labels to targets
Summary:
While it would be better to be able to do all of the ownership metadata at the Buck macro level, that proved to be more work than expected.

This diff adds the corresponding pfh label to all targets in `xplat/js/react-native-github` that have a Supermodule label. Once the migration is complete the Supermodules labels will be able to be removed.

Reviewed By: cortinico

Differential Revision: D35221544

fbshipit-source-id: d87d5e266dfb5e6ee087251dc34dff5db299bbaf
2022-03-30 14:37:03 -07:00
Wei Han 0353852297 fix //xplat/js/react-native-github:codegen_rn_components_schema_rncore (#33518)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33518

Changelog: [Internal]

When building with buck2, `setup_env_vars.sh` cannot be found. exporting setup_env_vars.sh and adding it as a dep to `write_to_json` fixes it.

Reviewed By: d16r

Differential Revision: D35188154

fbshipit-source-id: e1e1be4c83a57e443a181efaf1af3e6c8e6452f9
2022-03-30 14:12:50 -07:00
Andrei Shikov 28064ee0aa Fix changelog titles to fix links to the version
Summary:
tsia

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D35252308

fbshipit-source-id: 1d4c6f0988ae7fea5b30e5733637763a57d91db1
2022-03-30 09:27:54 -07:00
Scott Kyle 087624ccaf Add supportsFromJs and supportsToJs template variables
Summary:
These `constexpr` template variables make it really easy to test for bridging conversion to/from the specified types. The unit tests for this actually uncovered a bug with incompatible casts from lvalue references that was fixed in this diff as well.

Changelog:
Internal

Reviewed By: christophpurrer

Differential Revision: D35105398

fbshipit-source-id: 6e5f16e44ba99b296284970bf32c1f2f47201391
2022-03-30 09:14:39 -07:00
Andrei Shikov 57a90f7ce0 Changelog for 0.68 (#32993)
Summary:
Adds changelog for 0.68

## Changelog

[Internal][Changed] - Add changelog for 0.68

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

Test Plan: N/A

Reviewed By: cortinico

Differential Revision: D35250711

Pulled By: ShikaSD

fbshipit-source-id: a794a35c98a759808f4e70fbf71bd8b5787b5990
2022-03-30 08:26:04 -07:00
Nicola Corti fca8c03b14 Reintroduce missing dependency between configureCMakeDebug and preBuild
Summary:
I've noticed that some builds are sporadically failing as `configureCMake*` is runnign before
`preBuild`. When this happens, some 3rd party library folder won't exist yet and the build will
essentially fail. This is introducing flakyiness that this commit is essentially reducing

Changelog:
[Internal] [Changed] - Reintroduce missing dependency between configureCMakeDebug and preBuild

Reviewed By: ShikaSD

Differential Revision: D35213932

fbshipit-source-id: bfb4173843349ca4c1699d584bf0c915ab7b35cf
2022-03-30 07:22:09 -07:00
Chris Olszewski 75edd288cb Backout feature args
Reviewed By: jkeljo

Differential Revision: D35203884

fbshipit-source-id: 87d50b138aaa3dd16a24b5ff2795910c3644d418
2022-03-30 06:53:44 -07:00
Paige Sun 6031e4ab62 Fix: Add api to disable New Architecture validation reporting, and reset reporting when FBReactModule is recreated
Summary:
Changelog: [iOS][Internal] Add api to disable New  validation reporting

Previously `RCTNewArchitectureValidationSetEnabled` was not set to false once it was set to true when a use is in app-wide Bridgeless mode.
This resulted it being in an incorrect state if a user:
1) Opens RN while in app-wide Bridgeless enabled
2) Logout
3) Re-login as another user without killing the app.

The fix is to set `RCTNewArchitectureValidationSetEnabled(RCTNotAllowedValidationDisabled)` in FBReactModule initialization.

Reviewed By: RSNara

Differential Revision: D35233335

fbshipit-source-id: 82a2c2ed030df5d68267a40b14322e652eb29e96
2022-03-29 18:40:19 -07:00
Paige Sun 37e5fa3a6c Refactor: Migrate Logbox surface initialization to Fabric when available, in Bridge and Bridgeless modes
Summary:
Changelog: [iOS][Internal] Refactor: Migrate Logbox surface initialization to Fabric when available, in Bridge and Bridgeless modes

# Why
This diff main purpose is to add `RCTErrorNewArchitectureValidation(RCTNotAllowedInAppWideFabric)` in `RCTSurface`, to ensure Paper surfaces are never created in FBiOS.

# The Situation
Before this diff, in Bridged Fabric, `[RCTLogbox show]` initializes a Paper `RCTSurface`, [using `[RCTLogBoxView initWithWindow]`](https://github.com/facebook/react-native/blob/main/React/CoreModules/RCTLogBoxView.mm#L46))
In this diff,  in Bridged and Bridgeless Fabric, `[RCTLogbox show]` initializes a Fabric `RCTFabricSurface`.

Before this diff, in Bridgeless Fabric,  RCTLogBox posts a "CreateLogBoxSurface" notification to RCTInstance.
In this diff, the notification hack is replaced by the same `RCTFabricSurface` initialization above.
Behavior is the same.

Reviewed By: RSNara

Differential Revision: D35177311

fbshipit-source-id: 6de418af8a01f914c9a806bb8d74915015f9087a
2022-03-29 18:40:19 -07:00
Paige Sun a3bccdacc0 (Easy) Remove RCTNotAllowedInBridgeless validation for RCTRegisterModule
Summary:
Changelog: [iOS][Internal] Remove RCTNotAllowedInBridgeless validation for RCTRegisterModule

In the TurboModule system, `RCTRegisterModule` gets called for all `RCTBridgeModules` that calls `RCT_EXPORT_MODULE()` and it works fine in Bridgeless mode.

Reviewed By: RSNara

Differential Revision: D35203039

fbshipit-source-id: 8ae2be4487fe21653a7f1628fa92606a7d36d467
2022-03-29 17:27:05 -07:00
Imran Shitta-Bey 68fd1e5508 fix: deadlock when sending events (#33490)
Summary:
In short, if an RCTEventDispatcher observer sends an event on the same thread that the observer was initially on, there will be a deadlock due to `sendEvent` already having the lock active on the `_observers` NSHashTable. An example where this occurred was when we had react-native-gesture-handler trigger an animated event, which then triggered an event on the underlying component being animated as a result of it being an observer on the animation event. Since this all occurred on the main thread, we ended up with a deadlock and the app froze.

To prevent this scenario, I used a `NSRecursiveLock` for _observersLock to be able to dispatch events on the same thread from observers.

joebernard

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fix] - Prevent deadlock when dispatching events from observers on the same thread.

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

Test Plan:
Not sure if there are any tests present for sending events with RCTEventDispatcher already in place, but In regular app usage this solution has proved to be a viable and stable option so far and has prevented the deadlock from occurring.

This would still be thread-safe since we are now allowing the event to be sent through observers on the same thread the initial event was dispatched on. The only issue I could see here is the behavior of sending an event could be changed.

Reviewed By: RSNara

Differential Revision: D35118752

Pulled By: charlesbdudley

fbshipit-source-id: 7e93a8d49841e001b235a437ccca1e072dcc7ab1
2022-03-29 14:04:07 -07:00
fabriziobertoglio1987 7b5b114d57 Making links independently focusable by Talkback (#33215)
Summary:
This issue fixes [32004][23]. The Pull Request was previously published by [blavalla][10] with [31757][24].
>This is a follow-up on [D23553222 (b352e2da81)][18], which made links functional by using [Talkback's Links menu][1]. We don't often use this as the sole access point for links due to it being more difficult for users to navigate to and easy for users to miss if they don't listen to the full description, including the hint text that announces that links are available.
The Implementation of the functionality consists of:

Retrieving the accessibility links and triggering the TalkBack Focus over the Text
1. nested Text components with accessibilityRole link are saved as [ReactClickableSpan][17] instances in Android native [TextView][20] ([more info][19])
1. If the TextView contains any [ClickableSpans][15] (which are [nested Text][14] components with role link), set a view tag and reset the accessibility delegate.
3. Obtain each link description, start, end, and position relative to the parent Text (id) from the Span as an [AccessibilityLink][16]
4. Use the [AccessibilityLink][16]  to display TalkBack focus over the link with the `getVirtualViewAt` method (more [info][13])

Implementing ExploreByTouchHelper to detect touches over links and to display TalkBack rectangle around them.
1. ReactAccessibilityDelegate inherits from [ExploreByTouchHelper][12]
2. If the [ReactTextView][21] has an accessibility delegate, trigger ExploreByTouchHelper method [dispatchHoverEvent][22]
3.  Implements the methods `getVirtualViewAt` and `onPopulateBoundsForVirtualView`.
     The two methods implements the following functionalities  (more [info][13]):
    * detecting the TalkBack onPress/focus on nested Text with accessibilityRole="link"
    * displaying TalkBack rectangle around nested Text with accessibilityRole="link"

## Changelog

[Android] [Added] - Make links independently focusable by Talkback

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

Test Plan:
[1]. User Interacts with links through TalkBack default accessibility menu ([link][1])
[2]. The nested link becomes the next focusable element after the parent element that contains it. ([link][2])
[3]. Testing accessibility examples in pr branch ([link][3])
[4]. Testing accessibility android examples in pr branch ([link][4])
[7]. TalkBack focus moves through links in the correct order from top to bottom (PR Branch with [link.id][25]) ([link to video test][7]) ([discussion][26])
[8]. TalkBack focus does not move through links in the correct order from top to bottom (PR Branch without [link.id][25]) ([link to video test][8]) ([discussion][26])

Test on main branch
[5]. Testing accessibility examples in main branch ([link][5])
[6]. Testing accessibility android examples in main branch ([link][6])

[1]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/9#issuecomment-1045593386
[2]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/9#issuecomment-1045593164
[3]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/9#issuecomment-1054900872
[4]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/9#issuecomment-1054918634
[5]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/9#issuecomment-1054888278
[6]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/9#issuecomment-1054891828
[7]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/9#issuecomment-1060073165
[8]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/9#issuecomment-1060098381

[10]: https://github.com/blavalla "blavalla github profile"
[12]: 1ac46f932e/core/java/com/android/internal/widget/ExploreByTouchHelper.java (L48) "com/android/internal/widget/ExploreByTouchHelper.java#L48"
[13]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/9#issuecomment-1046384200 "explanation of getVirtualViewAt and onPopulateBoundsForVirtualView"
[14]: 1ac46f932e/core/java/android/text/Spannable.java (L3) "core/java/android/text/Spannable.java#L3"
[15]: 561266fc18/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java (L70-L71) "react/views/text/ReactTextViewManager.java#L70-L71"
[16]: 561266fc18/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java (L680-L685) "react/uimanager/ReactAccessibilityDelegate.java#L680-L685"
[17]: 561266fc18/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java (L126-L129) "react/views/text/TextLayoutManager.java#L126-L129"
[18]: b352e2da81
[19]: https://github.com/facebook/react-native/issues/30375#issuecomment-781494859 "explanation on how nested Text are converted to Android Spans"
[20]: 1ac46f932e/core/java/android/widget/TextView.java (L214-L220) "core/java/android/widget/TextView.java#L214-L220"
[21]: 485cf6118b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java (L577) "dispatchHoverEvent in ReactTextView"
[22]: 1ac46f932e/core/java/com/android/internal/widget/ExploreByTouchHelper.java (L120-L138) "dispatchHoverEvent in ExploreByTouchHelper"
[23]: https://github.com/facebook/react-native/issues/32004
[24]: https://github.com/facebook/react-native/pull/31757
[25]: 485cf6118b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java (L648) "setting link.id in the AccessibilityLink constructor"
[26]: 485cf6118b (r820014411) "comment on role of link.id"

Reviewed By: blavalla

Differential Revision: D34687371

Pulled By: philIip

fbshipit-source-id: 8e63c70e9318ad8d27317bd68497705e595dea0f
2022-03-29 13:36:24 -07:00
Paige Sun 6ee70a9cae 5/n Allow CKComponents to embed Fabric surfaces
Summary:
Changelog: [Fabric][iOS] Allow CKComponents to embed Fabric surfaces too.

Previously RCTSurfaceHostingComponent, a CKComponent, could only initialize the legacy RCTSurface. Now it can initialize RCTFabricSurface too, when a RCTSurfacePresenter is passed in.

Reviewed By: RSNara

Differential Revision: D35163595

fbshipit-source-id: e11a9334b0282e0728a38cc1c96de48a694e9e3d
2022-03-29 11:52:49 -07:00
Paige Sun 32fa5d6025 3/n (Easy) Make ComponentKit hosting RN use RCTSurfaceProtocol instead of Paper's RCTSurface
Summary:
Changelog: [iOS][Internal] Refactor: Make ComponentKit hosting ReactNative use RCTSurfaceProtocol instead of Paper's RCTSurface

Replace RCTSurface with id<RCTSurfaceProtocol>, because both RCTFabricSurface and RCTSurface conforms to RCTSurfaceProtocol.

Reviewed By: RSNara

Differential Revision: D35163498

fbshipit-source-id: ba54c9bf5949313cd501bd185975fe96d4770961
2022-03-29 11:52:49 -07:00
Paige Sun 1874c81003 (Easy) 1/n In RCTSurfaceHostingComponent, access ckComponent from main queue to pass assertion
Summary:
Changelog:

Before diff, we always hit assert the `'self.component' must be called on the main thread` assertion whenever we open a surface with a RCTSurfaceHostingComponent (React Native surface inside a CKComponent).

Reviewed By: RSNara

Differential Revision: D35152263

fbshipit-source-id: 1b06ca9d2ae7ca211120b71504e2eeaabaaf3bfd
2022-03-29 11:52:49 -07:00
Paige Sun eeb244a612 (Easy) Rename RCTNotAllowedInFabric to RCTNotAllowedInAppWideFabric
Summary:
Changelog: [iOS][Internal] Rename RCTNotAllowedInFabric to RCTNotAllowedInAppWideFabric

Clarify that methods marked with `RCTNotAllowedInAppWideFabric` are only NOT available when Fabric is app-wide (which is necessary for app-wide Bridgeless mode). These methods may still be called in apps with legacy pre-Fabric surfaces.

Reviewed By: RSNara

Differential Revision: D35194789

fbshipit-source-id: e16fa54d22ea67be995e93f6ff60567a117398be
2022-03-29 11:52:49 -07:00
Lulu Wu 5ffa0b0aa6 Move assertion for intent FbReactFragment's onActivityResult
Summary:
Changelog:
[Android][Changed] - Mark intent as nullable

Reviewed By: rahulraj

Differential Revision: D35058290

fbshipit-source-id: 3025de8b01660358a010c6886893d860ed4573fb
2022-03-29 11:25:37 -07:00
Xin Chen 7e993a7a87 Add more context to systrace for event dispatching
Summary:
Adding more context for event dispatching process in systrace.

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D35208257

fbshipit-source-id: 4a70e15a0074d4a53a895066e6fa1e60a6ebda0d
2022-03-29 10:48:32 -07:00
CodemodService Bot 013232abef Annotate targets with feature xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/BUCK -> xplat/js/react-native...
Summary: ...-github/ReactAndroid/src/main/java/com/facebook/react/modules/debug/BUCK

Reviewed By: jkeljo

Differential Revision: D35178548

fbshipit-source-id: 1c41a7c6df872a7520bc7c1b8ee60fb93aa4abac
2022-03-28 13:31:10 -07:00
CodemodService Bot 590ffad018 Annotate targets with feature xplat/js/react-native-github/ReactCommon/react/renderer/mapbuffer/BUCK -> xplat/js/tools/metro/packages/metro-runtime/src/polyfills/BUCK
Reviewed By: jkeljo

Differential Revision: D35178571

fbshipit-source-id: b8b6fcd49459e37152c02db8c7a6cfed167248a9
2022-03-28 13:22:38 -07:00
CodemodService Bot b6e72c5922 Annotate targets with feature xplat/js/react-native-github/Libraries/RCTRequired/BUCK -> xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK
Reviewed By: jkeljo

Differential Revision: D35178374

fbshipit-source-id: be4ad27928a1b9260a9d6321c9705b30aebe04d6
2022-03-28 13:11:16 -07:00
CodemodService Bot 64b7ac5959 Annotate targets with feature xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/packagerconnection/BUCK -> xplat/js/react-native...
Summary: ...-github/ReactAndroid/src/main/java/com/facebook/react/views/commo

Reviewed By: jkeljo

Differential Revision: D35178656

fbshipit-source-id: bcd09e49f1b4625012ca9372eea9254a0955e9fa
2022-03-28 13:06:37 -07:00
CodemodService Bot 8eddec9ff4 Annotate targets with feature xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/views/drawer/BUCK -> xplat/js/react-native-github/ReactCommon/callinvoker/BUCK
Reviewed By: jkeljo

Differential Revision: D35178416

fbshipit-source-id: 17e4228f6792048edd2e927ed7a3447a977a1183
2022-03-28 13:05:14 -07:00
bang9 d2e8e7d58e Fix FormData to properly handle appended arrays. (#32815)
Summary:
The Array appended to FormData must be transmitted in the form of a string.
However, it is treated as a file object and transmitted, because `typeof Array` is `'object'` too

In network
```js
form.append('array_name', ['a', 'b', 'c'])

// Browser
// Content-Disposition: form-data; name='array_name';
// a,b,c

// ReactNative
// Content-Disposition: form-data; name='array_name';
//
```

## Changelog
[General] [Fixed] - The Array appended to FormData is transmitted as a string

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

Test Plan: Added test case

Reviewed By: lunaleaps

Differential Revision: D33369594

Pulled By: charlesbdudley

fbshipit-source-id: 0b5219a2c9f73cf16665dc417cceb4481428ad4e
2022-03-28 11:53:32 -07:00
Kunal Farmah 1ca2c24930 Logging a soft error when ReactRootView has an id other than -1 instead of crashing the app in hybrid apps. (#33133)
Summary:
As per commit: 4f3b174120 which states that "React Native requires that the RootView id be managed entirely by React Native, and will crash in addRootView/startSurface if the native View id isn't set to NO_ID."

This behaviour can not be guaranteed in **hybrid** apps that have a native android layer over which ReactRootViews are added and the native views need to have ids on them in order to work. **The control of views can jump back and forth between native android and react-native (fabric). As the ReactRootView is added to ViewGroups (or layouts) in Android Fragments and Activities, they contain ids on their views which might get passed down to the reactRootView by features like DataBinding**

Hence this can cause unnecessary crashes at runtime for hybrid apps even when they are not changing the id of the reactRootView object they are adding to their ViewGroups.

Our app is a hybrid app that uses both native android and react-native on different screens and on one such screen that has a Fragment adding a ReactRootView to its FrameLayout to render native android views to render in ReactNative, this crash occurs on pressing the back button as well as on unlocking the screen while staying on the same screen.

The app was running fine on more than a 100 million devices on React Native 0.63.4 but after updating to 0.67.2, that features this commit, it crashes on the very first device it was tested on.

Refer to the issue: https://github.com/facebook/react-native/issues/33121 for more information on the crash

The fragment in which this issues arises is like this:

 ```binding.frameLayout.addView(getReactRootView())```

where getReactRootView() is like this:

```
    private var mReactRootView: ReactRootView? = null
    private var mReactInstanceManager: ReactInstanceManager? = null

    mReactRootView = ReactRootView(context)

        if (activity != null) {
            val application = activity?.application
            if (application is MainApplication) {
                mReactInstanceManager = application.reactInstanceManager
            }
        }

      fun getReactRootView():View?{
         return  mReactRootView
      }
```

So converting this to a soft exception such that pure react-native devs can still see the error while hybrid apps continue to run without crashes.

### Snippet of the change:

```
if (getId() != View.NO_ID) {
        ReactSoftExceptionLogger.logSoftException(
            TAG,
            new IllegalViewOperationException(
              "Trying to attach a ReactRootView with an explicit id already set to ["
                  + getId()
                  + "]. React Native uses the id field to track react tags and will overwrite this"
                  + " field. If that is fine, explicitly overwrite the id field to View.NO_ID."));
    }
```

## Changelog

[GENERAL] [ADDED] - A ReactSoftException log instead of a direct exception being thrown:

```
if (getId() != View.NO_ID) {
        ReactSoftExceptionLogger.logSoftException(
            TAG,
            new IllegalViewOperationException(
              "Trying to attach a ReactRootView with an explicit id already set to ["
                  + getId()
                  + "]. React Native uses the id field to track react tags and will overwrite this"
                  + " field. If that is fine, explicitly overwrite the id field to View.NO_ID."));
    }
```

[GENERAL] [REMOVED]- Directly throwing an exception even when the code is not responsible for this issue:

```
if (getId() != View.NO_ID) {
      throw new IllegalViewOperationException(
          "Trying to attach a ReactRootView with an explicit id already set to ["
              + getId()
              + "]. React Native uses the id field to track react tags and will overwrite this"
              + " field. If that is fine, explicitly overwrite the id field to View.NO_ID.");
    }

```

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

Test Plan:
This crash is hard to reproduce but when it occurs, this is the only way to fix it.
If any app used to crash with this exact error, it will no longer crash but show an error log in Logcat for developers to be informed about the issue.

Reviewed By: ShikaSD

Differential Revision: D34304212

Pulled By: cortinico

fbshipit-source-id: f0eaeef2e905a6e0587df088b43cc49cabda397a
2022-03-28 10:55:22 -07:00
Mike 199ac680c7 build(deps): Bump dependencies version for eslint-plugin (#32800)
Summary:
Add cached yarn deps

Seeing the message below during development, packages are outdated

```
=============

WARNING: You are currently running a version of TypeScript which is not officially supported by typescript-eslint/typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <4.1.0

YOUR TYPESCRIPT VERSION: 4.5.4

Please only submit bug reports when using the officially supported version.

=============
```

Update packages below to "5.8.0" should fix this
- typescript-eslint/eslint-plugin
- typescript-eslint/parser

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General][Changed] - Bump dependencies version for eslint-plugin

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

Test Plan: `yarn lint` with no error

Reviewed By: cortinico, yungsters

Differential Revision: D33331050

Pulled By: charlesbdudley

fbshipit-source-id: 27bf9b9b0536545ebfe4614ed210255df65aa2cd
2022-03-28 10:44:33 -07:00
Krzysztof Magiera 58a2eb7f37 Fix dynamic_cast (RTTI) by adding key function to ShadowNodeWrapper and related classes (#33500)
Summary:
This PR fixes RTTI (run-time type information) for ShadowNodeWrapper and ShadowNodeListWrapper classes, i.e., calls to dynamic_cast and dynamic_pointer_cast that are called via JSI's getHostObject calls.

The fix is simply to add a so-called "key function" in a form of virtual destructor. Key functions needs to be a virtual non-pure and non-inlined functions that points the compiler as to which library contains the vtable/type information for a given class (see https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-vtable and https://developer.android.com/ndk/guides/common-problems#rttiexceptions_not_working_across_library_boundaries)

Without the "key function", calls to dynamic_cast for ShadowNodeWrapper instances won't work across library boundaries because the class will have separate definitions in each separate library, therefore objects created in one of those libraries won't be recognized as the same type by the other library. This has been a problem in reanimated and gesture-handler libraries where we call `object.getHostObject<ShadowNodeWrapper>(rt)` (this is a method from JSI) in order to access ShadowNode instance from a handle we have in JS. I think, this issue is going to be relevant to more libraries that cope with view instances. In this scenario, we have a separate library, say "libreanimated.so" that calls to `getHostObject` which is an inline function that calls `dynamic_cast` for the `ShadowNodeWrapper` class. On the other hand, the instances of `ShadowNodeWrapper` are created by the code from `libreact_render_uimanager.so`. Because of that `dynamic_cast` fails even though it is called on instance of `ShadowNodeWrapper` because the class has separate vtable/type info: one in `libreanimated.so` and one in `libreact_render_uimanager.so` (by "fails" I mean that it actually returns `nullptr`).

This problem has been documented here: https://developer.android.com/ndk/guides/common-problems#rttiexceptions_not_working_across_library_boundaries where the solution is for the class to have a so-called "key function". The key function makes it so that compiler sees that one of the implementation for a given class is missing and therefore can safely assume that a vtable/type info for a given class is embedded into some library we link to.

This change adds a virtual destructor that is declared in the header file but defined in file that gets compiled as a part of `libreact_render_uimanager`. As a result, the compiler only creates one vtable/type info and calls to dynamic_cast works as expected in all libraries for `ShadowNodeWrapper` and `ShadowNodeListWrapper` classes.

This issue would only surface on Android, because on iOS all libraries by default are bundled together via Pods, whereas on Android each library is loaded separately using dynamic loading.

## Changelog

[Fabric][Android specific] - Fix dynamic_cast (RTTI) for ShadowNodeWrapper and similar classes when accessed by third-party libraries.

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

Test Plan:
1. In order to test this you need to add a library that'd include  `<react/renderer/uimanager/primitives.h>` (i.e. use this branch of reanimated library: https://github.com/software-mansion/react-native-reanimated/tree/fabric)
2. After compiling the app inspect libreact_render_uimanager.so and libreanimated.so artifacts with `nm` tool
3. Notice that symbols like `vtable for facebook::react::ShadowNodeWrapper` and `typeinfo for facebook::react::ShadowNodeWrapper` are only present in the former and not in the latter library (before this change you'd see them both)

Reviewed By: ShikaSD

Differential Revision: D35143600

Pulled By: javache

fbshipit-source-id: 5fb25a02365b99a515edc81e5485a77017c56eb8
2022-03-28 05:01:47 -07:00
Vincent Riemer d31d83f410 Update iOS LogBox to render its UIWindow with the key window's UIWindowScene
Summary:
If an RN app is embedded in a Mac Catalyst app that uses the UIWindowScene API to manage multiple windows, LogBox would fail to render because it didn't know which UIWindowScene to render to. This diff fixes that situation by ensuring that the LogBox window gets rendered in the key window's scene.

Changelog:
[iOS][Fixed] - Update iOS LogBox to render its UIWindow with the key window's UIWindowScene

Reviewed By: appden

Differential Revision: D35027831

fbshipit-source-id: e0df5865f95323b03d08d6b1fb3ec912aa9a9167
2022-03-25 13:28:50 -07:00
Danilo Bürger 96c611b5e8 Added Gemfile.lock to git add files when calling update-ruby.sh (#33484)
Summary:
In https://github.com/facebook/react-native/blob/main/scripts/update-ruby.sh#L61

```bash
bundle lock
```

is called which creates a Gemfile.lock in the rn root. This file should be in the git add files list along with the other files that get updated by that script.

## Changelog

[Internal] [Fixed] - Added Gemfile.lock to git add files when calling update-ruby.sh

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

Test Plan: Call update-ruby.sh with or without this patch. Without this patch, the Gemfile.lock will not be staged, with this patch, the Gemfile.lock will be staged.

Reviewed By: GijsWeterings

Differential Revision: D35118250

Pulled By: cortinico

fbshipit-source-id: 80f2c7fad6fbc3f09697988dcc20f7ac94a21473
2022-03-25 08:01:41 -07:00
Riccardo Cipolleschi b5343a6b0d Enable SonarKit and Flipper in React-Core (#33499)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33499

This DIFF turns on the `FB_SONARKIT_ENABLED` flag when installing Flipper ina RN app. The flag is enabled only in Debug config, given that Flipper is installed only in this configuration.

This PR also fixes this issue: https://github.com/facebook/react-native/issues/33497

This PR is required because release 0.67 has the Flag in the app, while release 0.68 moved it in the React-Core pod.
We can't enable the flag at the `React-Core.podspec` level because we should not make assumptions on whether users want flipper or not.

## Changelog
[iOS][Changed] - Enable SonarKit in React-Core when the configuration is `'Debug'`

Reviewed By: cortinico

Differential Revision: D35141506

fbshipit-source-id: 171b7fa8ea7727c633ef963408e86b332c32e9fa
2022-03-25 05:57:50 -07:00
AntoineDoubovetzky 9aab25ec53 (AppState) fix removeEventListener adding another listener when type is blur or focus (#33491)
Summary:
I noticed the `AppState.removeEventListener` was in fact calling `addListener` instead of `removeListener` when type is blur or focus.

I know this method is deprecated but it can't hurt to fix it.

## Changelog

[General] [Fixed] - AppState.removeEventListener correctly removes listener for blur and focus events

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

Test Plan: I've thought about adding a unit test, but it isn't that easy since AppState is mocked and the method is deprecated so I don't think it is worth investing too much for it.

Reviewed By: cortinico

Differential Revision: D35139808

Pulled By: GijsWeterings

fbshipit-source-id: 9d8ba157db3a62ea53759e1246f483182faf12f1
2022-03-25 05:14:06 -07:00
Héctor Ramos 8237ff2ef3 Use Hermes Engine from CocoaPods and fix Circle CI (#33478)
Summary:
Undoing the recent change that enabled Hermes to be built from source by default.
Building Hermes from source now requires the use of the  BUILD_HERMES_SOURCE envvar, again.

To be re-enabled shortly.

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

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D35100459

fbshipit-source-id: ec83fcdf2432c689b0c02f86fbabcc8625975d51
2022-03-25 03:29:53 -07:00
Rick Hanlon 05b0d29e76 React Native sync for revisions 1780659...1159ff6
Summary:
This sync includes the following changes:
- **[3f8990898](https://github.com/facebook/react/commit/3f8990898 )**: Fix test-build-devtools if build was generated by build-for-devtools ([#24088](https://github.com/facebook/react/pull/24088)) //<Sebastian Silbermann>//
- **[577f2de46](https://github.com/facebook/react/commit/577f2de46 )**: enableCacheElement flag ([#24131](https://github.com/facebook/react/pull/24131)) //<David McCabe>//
- **[2e0d86d22](https://github.com/facebook/react/commit/2e0d86d22 )**: Allow updating dehydrated root at lower priority without forcing client render ([#24082](https://github.com/facebook/react/pull/24082)) //<Andrew Clark>//
- **[dbe9e732a](https://github.com/facebook/react/commit/dbe9e732a )**: Avoid conditions where control flow is sufficient ([#24126](https://github.com/facebook/react/pull/24126)) //<Sebastian Markbåge>//
- **[b075f9742](https://github.com/facebook/react/commit/b075f9742 )**: Fix dispatch config type for skipBubbling ([#24109](https://github.com/facebook/react/pull/24109)) //<Luna>//
- **[ef23a9ee8](https://github.com/facebook/react/commit/ef23a9ee8 )**: Flag for text hydration mismatch ([#24107](https://github.com/facebook/react/pull/24107)) //<salazarm>//
- **[0412f0c1a](https://github.com/facebook/react/commit/0412f0c1a )**: add offscreen state node ([#24026](https://github.com/facebook/react/pull/24026)) //<Luna Ruan>//
- **[43eb28339](https://github.com/facebook/react/commit/43eb28339 )**: Add skipBubbling property to dispatch config ([#23366](https://github.com/facebook/react/pull/23366)) //<Luna>//
- **[832e2987e](https://github.com/facebook/react/commit/832e2987e )**: Revert accdientally merged PR ([#24081](https://github.com/facebook/react/pull/24081)) //<Andrew Clark>//
- **[02b65fd8c](https://github.com/facebook/react/commit/02b65fd8c )**: Allow updates at lower pri without forcing client render //<Andrew Clark>//
- **[83b941a51](https://github.com/facebook/react/commit/83b941a51 )**: Add isRootDehydrated function //<Andrew Clark>//
- **[c8e4789e2](https://github.com/facebook/react/commit/c8e4789e2 )**: Pass children to hydration root constructor //<Andrew Clark>//
- **[581f0c42e](https://github.com/facebook/react/commit/581f0c42e )**: [Flight] add support for Lazy components in Flight server ([#24068](https://github.com/facebook/react/pull/24068)) //<Josh Story>//
- **[72a933d28](https://github.com/facebook/react/commit/72a933d28 )**: Gate legacy hidden ([#24047](https://github.com/facebook/react/pull/24047)) //<Sebastian Markbåge>//
- **[b9de50d2f](https://github.com/facebook/react/commit/b9de50d2f )**: Update test to reset modules instead of using private state ([#24055](https://github.com/facebook/react/pull/24055)) //<Sebastian Markbåge>//
- **[c91892ec3](https://github.com/facebook/react/commit/c91892ec3 )**: [Fizz] Don't flush empty segments ([#24054](https://github.com/facebook/react/pull/24054)) //<Sebastian Markbåge>//
- **[d5f1b067c](https://github.com/facebook/react/commit/d5f1b067c )**: [ServerContext] Flight support for ServerContext ([#23244](https://github.com/facebook/react/pull/23244)) //<salazarm>//
- **[6edd55a3f](https://github.com/facebook/react/commit/6edd55a3f )**: Gate unstable_expectedLoadTime on enableCPUSuspense ([#24038](https://github.com/facebook/react/pull/24038)) //<Sebastian Markbåge>//
- **[57799b912](https://github.com/facebook/react/commit/57799b912 )**: Add more feature flag checks ([#24037](https://github.com/facebook/react/pull/24037)) //<Sebastian Markbåge>//
- **[e09518e5b](https://github.com/facebook/react/commit/e09518e5b )**: [Fizz] write chunks to a buffer with no re-use ([#24034](https://github.com/facebook/react/pull/24034)) //<Josh Story>//
- **[14c2be8da](https://github.com/facebook/react/commit/14c2be8da )**: Rename Node SSR Callbacks to onShellReady/onAllReady and Other Fixes ([#24030](https://github.com/facebook/react/pull/24030)) //<Sebastian Markbåge>//
- **[cb1e7b1c6](https://github.com/facebook/react/commit/cb1e7b1c6 )**: Move onCompleteAll to .allReady Promise ([#24025](https://github.com/facebook/react/pull/24025)) //<Sebastian Markbåge>//
- **[566285761](https://github.com/facebook/react/commit/566285761 )**: [Fizz] Export debug function for FB ([#24024](https://github.com/facebook/react/pull/24024)) //<salazarm>//
- **[05c283c3c](https://github.com/facebook/react/commit/05c283c3c )**: Fabric HostComponent as EventEmitter: support add/removeEventListener (unstable only) ([#23386](https://github.com/facebook/react/pull/23386)) //<Joshua Gross>//
- **[08644348b](https://github.com/facebook/react/commit/08644348b )**: Added unit Tests in the ReactART, increasing the code coverage ([#23195](https://github.com/facebook/react/pull/23195)) //<BIKI DAS>//
- **[feefe437f](https://github.com/facebook/react/commit/feefe437f )**: Refactor Cache Code ([#23393](https://github.com/facebook/react/pull/23393)) //<Luna Ruan>//

Changelog:
[General][Changed] - React Native sync for revisions 1780659...1159ff6

jest_e2e[run_all_tests]

Reviewed By: lunaleaps

Differential Revision: D34928167

fbshipit-source-id: 8c386f2be5871981d217ab9a514892ed88eafcfb
2022-03-24 13:38:00 -07:00