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

322 Коммитов

Автор SHA1 Сообщение Дата
Riccardo Cipolleschi b1b2b8baaf Update podspecs with the right search paths
Summary:
Update podspecs with the right search paths to include the required framework by every module.

## Changelog:
[iOS][Changed] - Update search paths to support `use_frameworks!` with Fabric

Reviewed By: sammy-SC, dmytrorykun

Differential Revision: D43089372

fbshipit-source-id: 4bbfc4b98bd289d66ce4015429d581856d9c05b3
2023-02-20 11:50:10 -08:00
Samuel Susla 60f381a8b9 Fix a crash when reloading the JS bundle
Summary:
changelog: [iOS][Fixed] Fix a crash when reloading JS bundle

Do not crash if self is nil.

Reviewed By: blakef

Differential Revision: D43352039

fbshipit-source-id: dd53677ca152d4021e43ed8d0f1b51c071ca3365
2023-02-17 14:50:53 -08:00
szymonrybczak f72f8daeaf feat: add invoking dev menu on iOS by pressing `d` in terminal (#36115)
Summary:
Inspired by tido64's comment https://github.com/react-native-community/cli/issues/1820#issuecomment-1424270890 I'm adding missing implementation on iOS for invoking dev menu by pressing `d` in terminal while metro is launched.

## Changelog

[IOS][ADDED] - Add invoking dev menu on iOS by pressing `d` in terminal.

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

Test Plan:
Press `d` in terminal while metro is launched - dev menu should appear.

https://user-images.githubusercontent.com/63900941/217936561-deea1390-221e-4f32-bbc4-e6fcfdf2a992.mp4

Reviewed By: rshest

Differential Revision: D43185001

Pulled By: javache

fbshipit-source-id: daa7af3b24b1b9f10d1a1ef8db8d9af816e912ea
2023-02-14 04:33:39 -08:00
Nick Gerleman 6d1667cf86 Back out "Add Appearance.setColorScheme support"
Summary:
See https://github.com/facebook/react-native/pull/35989#discussion_r1101016329

Changelog:
[General][Fixed] - Back out "Add Appearance.setColorScheme support"

Reviewed By: jacdebug

Differential Revision: D43148056

fbshipit-source-id: 823ab8276207f243b788ce7757839a3e95bdbe07
2023-02-09 00:54:42 -08:00
Birkir Gudjonsson 0a4dcb0309 Add Appearance.setColorScheme support (#35989)
Summary:
Both Android and iOS allow you to set application specific user interface style, which is useful for applications that support both light and dark mode.

With the newly added `Appearance.setColorScheme`, you can natively manage the application's user interface style rather than keeping that preference in JavaScript. The benefit is that native dialogs like alert, keyboard, action sheets and more will also be affected by this change.

Implemented using Android X [AppCompatDelegate.setDefaultNightMode](https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setDefaultNightMode(int)) and iOS 13+ [overrideUserInterfaceStyle](https://developer.apple.com/documentation/uikit/uiview/3238086-overrideuserinterfacestyle?language=objc)

## Changelog

[GENERAL] [ADDED] - Added `setColorScheme` to `Appearance` module

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

Test Plan:
This is a void function so testing is rather limited.

```tsx
// Lets assume a given device is set to **dark** mode.

Appearance.getColorScheme(); // `dark`

// Set the app's user interface to `light`
Appearance.setColorScheme('light');

Appearance.getColorScheme(); // `light`

// Set the app's user interface to `unspecified`
Appearance.setColorScheme(null);

Appearance.getColorScheme() // `dark`
 ```

Reviewed By: NickGerleman

Differential Revision: D42801094

Pulled By: jacdebug

fbshipit-source-id: ede810fe9ee98f313fd3fbbb16b60c84ef8c7204
2023-02-07 06:23:39 -08:00
Riccardo Cipolleschi da270d038c Restore Dynamic framework with JSC in the Old Architecture
Summary:
I discovered that 0.69 and 0.70 could run React Native as Dynamic framework with JSC and starting from 0.71 that's not possible anymore.
This diff restore that possibility.

## Changelog
[iOS][Fixed] - Add Back dynamic framework support for the old architecture

Reviewed By: cortinico

Differential Revision: D42829137

fbshipit-source-id: 848672f714d8bab133e42f5e3b80202b350d5261
2023-01-30 04:25:26 -08:00
Sheikh Jamir Alam f3155d0f80 Update RCTDevMenu.mm (#35910)
Summary:
Fixed typo with the word "running" in 2 places when failing to open Flipper.

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

Changelog:
[Internal] [Changed] - Fix typo with the word "running" when failing to open Flipper

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

Reviewed By: christophpurrer

Differential Revision: D42641042

Pulled By: sshic

fbshipit-source-id: acebb26ab921e98235c4f8e8535fa89be2ffa8cd
2023-01-23 05:04:03 -08:00
Christoph Purrer e7dcad2ba1 Remove UIKit import from RCTDevLoadingView.h (#35843)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35843

See: https://github.com/microsoft/react-native-macos/issues/1604

Changelog:
[iOS][Fixed]: Remove UIKit import from RCTDevLoadingView.h

Reviewed By: cipolleschi

Differential Revision: D42529787

fbshipit-source-id: 2a63574794a5c962a17b49fa46a146b1252a0445
2023-01-17 02:57:51 -08:00
abing 0c53420a7a Fix RCTAlertController not showing when using SceneDelegate on iOS 13.0+ (#35716)
Summary:
On iOS 13.0+, app may use SceneDelegate for multiple windows support or CarPlay support. RCTAlertController can't find the correct root vc in such scene based apps.

## Changelog

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

Pick one each for the category and type tags:

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

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[iOS] [Fixed] - Fix RCTAlertController not showing when using SceneDelegate on iOS 13.0+.

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

Reviewed By: cipolleschi

Differential Revision: D42253653

Pulled By: makovkastar

fbshipit-source-id: ae4e833abca2af7af8028f3af9bd8d3f60ebd392
2023-01-04 11:40:34 -08:00
Liam Xu 2217ea4136 Repair when RCTRedBoxGetEnabled is false , inoperative in RCTExceptio… (#35576)
Summary:
Repair when RCTRedBoxGetEnabled is false , the red box will still be on display,It resolve that I send test-pack to QA with Xcode Archive on DEBUG env.

## Changelog
[General] [Changed] - Append RCTRedBoxGetEnabled() in RCTExceptionsManager.mm

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

Test Plan: Xcode Archive on DEBUG env, the red box will be not on display.

Reviewed By: cipolleschi

Differential Revision: D41809649

Pulled By: skinsshark

fbshipit-source-id: 7d6be3479decf369c415f6a08dec9611b1441b1d
2023-01-04 09:23:38 -08:00
admirsaheta 79e603c5ab Null Exception Handling | Input Validation - RCTAlertController - RCTDevLoadingView (#35689)
Summary:
Enhancing native iOS modules and preventing crashes inside the RCTAlertController

## Changelog
[iOS][Fixed] - Handle properly a `nil` `keyWindows` in the AlertController

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

Pick one each for the category and type tags:

[IOS] [SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

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

Reviewed By: cipolleschi

Differential Revision: D42179169

Pulled By: ryancat

fbshipit-source-id: 05a6788f610db1d222e3c10b3c774c75edaf55f5
2023-01-03 13:53:42 -08:00
Michael Anthony Leon de28f9b8ea Include sampling profiler & inspector behind a compile-time flag
Summary:
Changelog:
[iOS][Changed] - Create a new compile time flag to enable remote sample profiling.

Reviewed By: cortinico

Differential Revision: D41554133

fbshipit-source-id: 00a7f9f6c9f09d72afee070c1cc6187aa3d0ddb1
2022-12-08 14:57:29 -08:00
Christoph Purrer 022e22cbd4 Replace folly::Optional with std::optional (#35436)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35436

Using std::optional as react-native has been using C++17 for quite some time

changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D41415031

fbshipit-source-id: d786647f64b4f90cf75409109830ae0885460c17
2022-11-28 02:08:12 -08:00
Richard Howell 88d1825c73 remove -weak_framework (#89233)
Summary:
X-link: https://github.com/pytorch/pytorch/pull/89233

The `-weak_framework` flag is no longer necessary, Buck will weakly link frameworks depending on the `target_sdk_version` of the binary being linked.

Reviewed By: ebgraham, malfet

Differential Revision: D41348639

fbshipit-source-id: 47992282ba030294b2304c550d49df13e24e9c79
2022-11-18 08:23:55 -08:00
Riccardo Cipolleschi da27c78075 Configure BlobModule as proper TurboModule
Summary:
This change puts back D40716048 (279cfec55f) but in the right way, i.e. modifying the script that should generate those changes.

## Changelog
[iOS][Added] - Make the blobs proper TM

Reviewed By: dmytrorykun

Differential Revision: D41312160

fbshipit-source-id: 38850a63eb8d66ffd179743b4948a23340c8782e
2022-11-16 10:10:06 -08:00
Christoph Purrer 19d65a2baf Update .podspec license information (#35245)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35245

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D41084913

fbshipit-source-id: a4ba31a19ffe515aa4e7c5a6e273a8cc4b6bc42d
2022-11-07 09:52:52 -08:00
Robert Balicki 6152763398 Buck, etc. changes that enable persisted, sync settings for DevTools (#35163)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35163

# What

This diff contains all the changes from D40333083 (0fac9817df) (aka https://github.com/facebook/react-native/pull/34964), **except** the change to `setUpReactDevTools.js`, which actually uses the new files.

# Why

* We want to ship the Buck, C++, etc. changes before the JavaScript changes that depend on those files.
* Otherwise, apps can fail at startup with the message:
```
`TurboModuleRegistry.getEnforcing(...): '${name}' could not be found. ` +
      'Verify that a module by this name is registered in the native binary.',
```
* Note that this only occurs if you are using a previously-built version of the C++, Obj C, etc. files in RN, but a more recent version of the JavaScript files. If you are building from matching sources, this does not occur.
* After a few days, we can land the JS files.

## Changelog

Changelog
[General][Added] Add, but don't use, DevTools Settings Manager.

Reviewed By: NickGerleman

Differential Revision: D40873390

fbshipit-source-id: c7bac6ae65f85666b8616443db278ebb175b691b
2022-11-07 07:40:21 -08:00
Dmitry Rykun bbd432e999 feat: make RCTBlobManager TurboModule-compatible (#35188)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35188

This diff reverts D40716048 (279cfec55f) (https://github.com/facebook/react-native/pull/35047) which breaks RCTImageLoader.
https://pxl.cl/2jKrM
Those files are auto-generated and are not supposed to be edited manually.
Changelog: [iOS] [Fixed] - https://github.com/facebook/react-native/pull/35047 reverted.

Reviewed By: cipolleschi

Differential Revision: D40979350

fbshipit-source-id: ef92cf05636cba818151d4184e0275a3aab56cff
2022-11-03 08:52:34 -07:00
Ruslan Lesiutin 4de2aaba50 refactor(AsyncStorage): move iOS files from react-native-github
Summary:
## Changelog:
[iOS][Removed] - Removed AsyncStorage module

Reviewed By: lunaleaps

Differential Revision: D40283712

fbshipit-source-id: 5e74c71915c2fbba4363e3fc917555039069038e
2022-10-31 14:39:19 -07:00
Andre 279cfec55f feat: make RCTBlobManager TurboModule-compatible (#35047)
Summary:
Currently, RCTBlobManager (the native module for Blob support) cannot be loaded on iOS when the new architecture is enabled.

## Changelog

[General] [Added] - `BlobModule` to `RCTCoreModulesClassProvider`

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

Test Plan:
The snippet below can be used to test Blob support with the new architecture enabled.

```
// App.tsx
import { useEffect } from 'react';
import { View } from 'react-native';
function uriToBlob(uri: any) {
  return new Promise((resolve, reject) => {
    const xhr = new XMLHttpRequest();
    xhr.responseType = 'blob';
    xhr.onload = () => {
      const blob = xhr.response;
      resolve(blob);
    };
    xhr.onerror = err => {
      reject(err);
    };
    xhr.open('GET', uri);
    xhr.send();
  });
}

export default function App() {
  useEffect(() => {
    uriToBlob('https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png');
  });
  return <View />;
}

```

Related issue: https://github.com/facebook/react-native/issues/35042

Reviewed By: NickGerleman

Differential Revision: D40716048

Pulled By: cipolleschi

fbshipit-source-id: 17643d230fa7ea83baee363d137d51f87818baa8
2022-10-26 19:59:28 -07:00
Nick Gerleman 51d14b9dbd Revert D40333083: Support persisted settings in Android + iOS
Differential Revision:
D40333083 (0fac9817df)

Original commit changeset: f3816e3bd7de

Original Phabricator Diff: D40333083 (0fac9817df)

fbshipit-source-id: 1a52a06b057c4c0ea6e3e4c3315ba73a883e3579
2022-10-26 12:28:44 -07:00
Robert Balicki 0fac9817df Support persisted settings in Android + iOS (#34964)
Summary:
* Add a DevToolsSettingsManager, which has android and iOS variants, which uses a new TM (Android) or takes advantage of the Settings TM (iOS) to get/set console patch settings
* This is backed by either the existing Settings module (iOS) or a new Java TM, which uses the SharedPreferences AP

## Testing

Manual testing

## Changelog

[General] [Added] - Add DevToolsSettingsManager

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

Test Plan: * Extensive manual testing

Reviewed By: NickGerleman

Differential Revision: D40333083

Pulled By: rbalicki2

fbshipit-source-id: f3816e3bd7dea3086f6f2269c3a099af14aebb3b
2022-10-25 21:01:25 -07:00
Riccardo Cipolleschi 52d37aa403 Back out "add oncall annotation for BUCK files in xplat based on supermodule information - /home/s2shi/tmp/xplat_buck_oncall/xplat_buck_batch10" (#35064)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35064

Original commit changeset: 0fb0db845c04

Original Phabricator Diff: D40610875 (d941940b4c)

Open source is using BUCK 1 which does not seem to have the `oncall` directive.

Backing it out because it is breaking the external CI.

## Changelog
[internal]

Reviewed By: cortinico

Differential Revision: D40635873

fbshipit-source-id: 79ebd4db0972520fcca6ccb8c1725657a8ef7949
2022-10-24 10:44:39 -07:00
Jonathan Keljo e69e6f4014 supermodule:xplat/default/public.react_native.infra
Reviewed By: javache

Differential Revision: D40376280

fbshipit-source-id: d76e692fd8a571614729d0fb15ebde8895d3de28
2022-10-23 15:55:13 -07:00
Stanley Shi d941940b4c add oncall annotation for BUCK files in xplat based on supermodule information - /home/s2shi/tmp/xplat_buck_oncall/xplat_buck_batch10
Differential Revision: D40610875

fbshipit-source-id: 0fb0db845c041265faf0a06877d05ffbb55ba648
2022-10-21 22:39:18 -07:00
Héctor Ramos a68c418082 Do not build JSI in React-jsi when Hermes is enabled, resolve JSI ODR violation (#35038)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35038

React-jsi provides JSI to allow React Native to interface with JavaScriptCore.
The hermes-engine Pod provides a second copy of JSI, as Hermes is built and linked statically with JSI.
This second copy of JSI would lead to an [ODR Violation](https://en.cppreference.com/w/cpp/language/definition).

To resolve this, when Hermes is enabled:
- React-hermes and hermes-engine are installed.
- React-jsc is not installed.
- React-jsi continues to be installed.
- React-jsi will not build JSI.
- React-jsi will declare a dependency on hermes-engine.

The result is that the JSI dependency for React Native is satisfied by hermes-engine, and there is no duplicate JSI library in the project.

When Hermes is disabled:
- React-jsi and React-jsc are installed.
- React-hermes and hermes-engine are not installed.
- React-jsi will build JSI.

Changelog:
[iOS][Changed] Resolve JSI ODR violation, make hermes-engine the JSI provider when Hermes is enabled

Reviewed By: cipolleschi

Differential Revision: D40334913

fbshipit-source-id: 409407a193a35cbd21b0e8778537b3627e4c54a2
2022-10-20 14:14:23 -07:00
Héctor Ramos 6b129d81ed CocoaPods: Split React-jsc out of React-jsi (#35031)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35031

The React-jsi Pod was serving two purposes: building JSI, and configuring JavaScriptCore as the JS engine.

By splitting the React-jsi Pod into React-jsi and React-jsi, we can start working towards de-coupling the JSI dependency from any particular JS engine.

Pods that depended on React-jsi, now depend on React-jsi and React-jsc.
One exception to this is React-hermes, which is only installed when Hermes is enabled, and thus does not require JavaScriptCore.
Upcoming commits should take care of removing the React-jsc dependency when Hermes is enabled, but it is out of scope for this commit.

Changelog:
[iOS][Changed] - The JSC Runtime is now provided by the React-jsc Pod instead of React-jsi. Libraries that declared a dependency on React-jsi in order to specifically create a JSC runtime (`makeJSCRuntime()`) will need to add React-jsc to their dependencies.

Reviewed By: dmytrorykun

Differential Revision: D40442603

fbshipit-source-id: b9b21146b9deb401f80cfef76a87c9867754a953
2022-10-20 14:14:23 -07:00
Chenglin Liu b33961d7a0 Add link group label to talkios deps
Summary: Currently, link groups depend on supermodules to generate. To continue supporting link groups while allowing us to migrate off supermodules, we'll add a talkios_link_group label on all talkios targets to persist the current hierarchical information.

Reviewed By: jkeljo

Differential Revision: D40268252

fbshipit-source-id: 9211add120448e95f892d36a85583c700b2ec9a0
2022-10-11 14:24:40 -07:00
evanbacon 5933b6a3ba Use monospace font for RCTRedBox.mm message (#34780)
Summary:
The format is crunching spaces:

![Simulator Screen Shot - iPhone 14 Pro Max - 2022-09-24 at 16 25 33](https://user-images.githubusercontent.com/9664363/192119593-30d5c82f-9f8c-465d-af29-6914d4111351.png)

Now it preserves the space and makes the error look a little less scary:

![Simulator Screen Shot - iPhone 14 Pro Max - 2022-09-24 at 16 25 02](https://user-images.githubusercontent.com/9664363/192119603-8214a38b-6511-413b-b999-5d2739cd0293.png)

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[iOS] [Fixed] - RedBox title font by using a monospace font on iOS +13.

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

Test Plan: See pictures. You can repro by applying changes and starting a project with a misc `>` character. The first load triggers the error message.

Reviewed By: cipolleschi

Differential Revision: D39798262

Pulled By: robhogan

fbshipit-source-id: d836e50f3e95865a6482accf4aea5b0e6cf24995
2022-09-27 04:51:52 -07:00
Chenglin Liu 065db683a2 add link group label to fbios deps
Summary:
Currently, fbios link groups depend on supermodules to generate. To continue supporting
link groups while allowing us to migrate off supermodules, we'll add a `fbios_link_group` label on all fbios targets to persist the current hierarchical information.

Reviewed By: jkeljo

Differential Revision: D39543862

fbshipit-source-id: 2abe5b3ee883e77336076d88436a1c84139b5a97
2022-09-22 22:52:22 -07:00
Luna Wei ab5f26bf02 Back out "Fix `Alert` not showing in an app using `UIScene`"
Summary:
Changelog: [Internal] - Revert https://github.com/facebook/react-native/pull/34562

re: [iOS] [Fixed] - Fix Alert not showing in an app using UIScene

Reviewed By: alsun2001

Differential Revision: D39591113

fbshipit-source-id: ba707c11b3fb97eb3a6fee32e57b92403aa8b3d8
2022-09-17 07:05:37 -07:00
Paige Sun 5745c1df26 Modularlize RCTConstants.h - Move Bridge-only constants into a separate file
Summary:
Changelog: [Internal] Move Bridge-only constants into a separate file

- Move Bridge only constants from RCTBridge.h into  RCTBridgeConstants.h.
- Move shared constants from RCTBridge.h into RCTConstants.h.

This way, new architecture does not need to import RCTBridge.h just for the constants.

Reviewed By: sammy-SC

Differential Revision: D39085713

fbshipit-source-id: 40177cbed72a326b40ec448c98751d1dd3464504
2022-09-08 19:56:22 -07:00
Tommy Nguyen 153aedce41 Fix `Alert` not showing in an app using `UIScene` (#34562)
Summary:
In an app using `UIScene`, `Alert` no longer pops up because the window
that gets created are not attached to a scene.

## Changelog

[iOS] [Fixed] - Fix `Alert` not showing in an app using `UIScene`

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

Test Plan: Use the test plan in https://github.com/facebook/react-native/issues/29295. This should not regress that fix.

Reviewed By: cipolleschi

Differential Revision: D39276976

Pulled By: lunaleaps

fbshipit-source-id: e48e985ed4abec77d6f01a6c17292d664ed88f13
2022-09-08 12:54:08 -07:00
Lulu Wu b6bf1fd373 Reland D38460203
Summary:
D38460203 (e6ef0836c1) was reverted because it broke OSS, the root cause is that OSS doesn't have MapBuffer module.

Fixed the issue in this diff by moving MapBuffer usage to fb internal class (FBReactModule) and will re-land.

Changelog:
[iOS][Changed] Replace Folly with MapBuffer for passing js error data

Reviewed By: sammy-SC

Differential Revision: D39210957

fbshipit-source-id: dda0e8c55dbd13bc96310e10a3b09ea53978e8bc
2022-09-07 14:41:45 -07:00
Lulu Wu 31b4a92aa9 Revert D38460203: Migrate JS error handler to MapBuffer
Differential Revision:
D38460203 (e6ef0836c1)

Original commit changeset: 98f6243e31da

Original Phabricator Diff: D38460203 (e6ef0836c1)

fbshipit-source-id: 540a48c807cea7f2898f261b82010da729f3421e
2022-08-26 03:52:57 -07:00
Vojtech Novak 18542b6ef5 fix: RCTAlertController's UserInterfaceStyle to follow root window (#34218)
Summary:
The motivation of this PR is for the Alert to follow the same style override (`overrideUserInterfaceStyle` being light/dark) as the one used by the root window (`UIApplication.sharedApplication.delegate.window`).

This is something that has worked previously because `RCTPResentedViewController()` was used to present the Alert (the behavior has changed in f319ff321c). With the former approach, the alert would "inherit" the `userInterfaceStyle` of the view controller it was presented within (and that one, in turn, would "inherit" from `UIApplication.sharedApplication.delegate.window`).

With the current approach, the "style inheritance" does not work with the view controller being created [here](f3db6cc527/React/CoreModules/RCTAlertController.m (L24)).

Because this viewcontroller instance does not have where to "inherit" the styling from, the styling might be different from the rest of the app. This PR fixes that.

## Changelog

[iOS] [Fixed] - fix: RCTAlertController's UserInterfaceStyle to follow root window

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

Test Plan:
Instead of

```
self.overrideUserInterfaceStyle = UIApplication.sharedApplication.delegate.window.overrideUserInterfaceStyle;
```

you can do

```
self.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
```

and observe the result. So if the override is set, it'll manifest itself. If it's not set, the value of `UIApplication.sharedApplication.delegate.window.overrideUserInterfaceStyle` will be `UIUserInterfaceStyleUnspecified`, and it'll have no effect.

<details>
  <summary>screenshot</summary>

![Simulator Screen Shot - iPhone 11 - 2022-07-18 at 21 40 06](https://user-images.githubusercontent.com/1566403/179616673-d0e48e07-50b5-41a1-afb7-0aa8f7ec37b5.png)
</details>

Reviewed By: dmitryrykun

Differential Revision: D38660799

Pulled By: cipolleschi

fbshipit-source-id: c979266900e27be7a4732bdb6e9a496906534931
2022-08-25 11:09:10 -07:00
Gabriel Donadel Dall'Agnol be7c50fefd feat: Add support for "Prefer Cross-Fade Transitions" into AccessibilityInfo (#34406)
Summary:
This PR adds `prefersCrossFadeTransitions()` to AccessibilityInfo in order to add support for "Prefer Cross-Fade Transitions", exposing the iOS settings option as proposed here https://github.com/react-native-community/discussions-and-proposals/issues/452.
I believe this would be especially helpful for solving https://github.com/facebook/react-native/issues/31484

#### TODO
- [ ]  Submit react-native-web PR updating AccessibilityInfo documentation.

## Changelog

[iOS] [Added] - Add support for "Prefer Cross-Fade Transitions" into AccessibilityInfo

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

Test Plan:
**On iOS 14+**

1.  Access Settings > "General" > "Accessibility" > "Reduce Motion", enable "Reduce Motion" then enable "Prefer Cross-Fade Transitions".
2. Open the RNTester app and navigate to the Accessibility page

https://user-images.githubusercontent.com/11707729/154588402-7d050858-3c2d-4d86-9585-928b8c66941b.mov

Reviewed By: cipolleschi

Differential Revision: D38711316

Pulled By: makovkastar

fbshipit-source-id: b9965cd4285f1aa0f1fa927080370a22329c2f62
2022-08-25 10:45:15 -07:00
Lulu Wu e6ef0836c1 Migrate JS error handler to MapBuffer
Summary:
Changelog:
[iOS][Changed] Replace Folly with MapBuffer for passing js error data

Reviewed By: sammy-SC

Differential Revision: D38460203

fbshipit-source-id: 98f6243e31da42cc601727545b331392300cee20
2022-08-25 08:55:25 -07:00
Christoph Purrer 8b174a57c8 Possible fix for convertIdToFollyDynamic crash in RCTBaseTextInputView and RCTEventDispatcher
Summary:
A crash encountered in react-native-macOS is very similar to one fixed by https://github.com/microsoft/react-native-macos/pull/489#discussion_r451789471 (see discussion), and it's possible this `replacement` string also suffers from sharing the same backing store as the attributed string (maybe only when the range encompasses the entire string?) and therefore should be copied as well.

Changelog:
[iOS][Fixed] - Possible fix for convertIdToFollyDynamic crash in RCTBaseTextInputView and RCTEventDispatcher

Reviewed By: sammy-SC

Differential Revision: D38064551

fbshipit-source-id: 9c15f2a980155ab3cbb3fde79fcb93b24ee2091a
2022-07-25 18:14:46 -07:00
Robbie Coomber 000bbe8013 Add support for "preferred" AlertButton (#32538)
Summary:
Currently, with the Alert API on iOS, the only way to bold one of the buttons is by setting the style to "cancel". This has the side-effect of moving it to the left. The underlying UIKit API has a way of setting a "preferred" button, which does not have this negative side-effect, so this PR wires this up.

See preferredAction on UIAlertController https://developer.apple.com/documentation/uikit/uialertcontroller/

Docs PR: https://github.com/facebook/react-native-website/pull/2839

## Changelog

[iOS] [Added] - Support setting an Alert button as "preferred", to emphasize it without needing to set it as a "cancel" button.

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

Test Plan:
I ran the RNTesterPods app and added an example. It has a button styled with "preferred" and another with "cancel", to demonstrate that the "preferred" button takes emphasis over the "cancel" button.

![Simulator Screen Shot - iPhone 11 - 2021-11-04 at 09 48 35](https://user-images.githubusercontent.com/2056078/140292801-df880c43-c330-40df-b8e4-c1476c1645d6.png)

Luna:
* Also tested this on Catalyst
{F754959632}

Reviewed By: sammy-SC

Differential Revision: D34357811

Pulled By: lunaleaps

fbshipit-source-id: 3d860702c49cb219f950904ae0b9fabef03b5588
2022-07-22 15:41:32 -07:00
Paige Sun 674609757b Minor: Rename RCTNotAllowedInAppWideFabric to RCTNotAllowedInFabricWithoutLegacy
Summary:
Changelog: [Internal][iOS] Minor: Rename RCTNotAllowedInAppWideFabric to RCTNotAllowedInFabricWithoutLegacy

`RCTNewArchitectureValidationPlaceholder(RCTNotAllowedInBridgeless` is to track Bridge APIs that are okay in Fabric but not in Bridgeless.

`RCTNewArchitectureValidationPlaceholder(RCTNotAllowedInFabricWithoutLegacy` is to track legacy APIs that should not exist if the app was using Fabric **without any legacy architecture**. e.g. RCTBridgeModule, legacy interop view components.

Reviewed By: fkgozali

Differential Revision: D37659105

fbshipit-source-id: aee4e083820e83a8dac19eb3b5efc49b37d90039
2022-07-08 15:07:55 -07:00
lbaldy 7d42106d4c prevent from publishing dimensions change event when app changes state (#34014)
Summary:
This fix solves a problem very well evaluated [here](https://github.com/Expensify/App/issues/2727) as well as this [one](https://github.com/facebook/react-native/issues/29290).

The issue is that when the app goes to background, in landscape mode, the RCTDeviceInfo code triggers an orientation change event that did not physically happen. Due to that, we get swapped values returned when going back to the app.

I debugged the react-native code, and to me it seems that react native publishes the orientation change event one extra time when switching the state of the app to 'inactive'. Here is what is happening:

1. iPad is in landscape.
2. We move the app to inactive state.
3. Native Code queues portrait orientation change (no such change happened physically), and immediately after it triggers landscape change (same as we had in point 1).
4. We restore the app to active state.
5. The app receives two queued orientation change events, one after another.
6. The quick transition between portrait and landscape happens even though it never went back to portrait.

Fresh `react-native init` app repro case can be found here: https://github.com/lbaldy/issue-34014-repro

Video presenting the issue (recorded while working on: https://github.com/Expensify/App/issues/2727 ): https://www.youtube.com/watch?v=nFDOml9M8w4

## 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] [Fixed] - Fix the way the orientation events are published, to avoid false publish on orientation change when app changes state to inactive

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

Test Plan:
### Test Preparation

1. Make sure you have a working version of E/App.
2. Open App/src/components/withWindowDimensions.js and update the constructor by changing this line:

`this.onDimensionChange = _.debounce(this.onDimensionChange.bind(this), 100);`

to

`this.onDimensionChange = this.onDimensionChange.bind(this);`

3. Open the NewExpensify.xcodeproj in xCode.
4. Open the RCTDeviceInfo.mm file and replace it's contents with the file from this PR.
5. Select your device of choice (I suggest starting with iPad mini) and run the app though xCode.
6. From this point you can move to the test scenarios described below.

### iPad Mini tests:

Reproduction + Fix test video (Test 1): https://youtu.be/jyzoNHLYHPo
Reproduction + Fix test video (Test 2): https://youtu.be/CLimE-Fba-g

**Test 1:**
1. Launch app in portrait, open chat - no sidebar visible.
7. Switch to landscape - sidebar shows.
8. Put app to background.
9. Put app back to foreground - make sure the side menu doesn't flicker.

**Test 2:**
1. Launch app in portrait, open chat - no sidebar visible.
2. Switch to landscape - sidebar shows.
3. Put app to background. Switch orientation back to portrait.
4. Put app back to foreground - make sure the side menu hides again as it should be in portrait.

### iPad Pro tests:

Reproduction + Fix test video (Test 3, Test 4): https://youtu.be/EJkUUQCiLRg

iPad mini test 1 applies.

Scenario 2 does not as the screen is too wide in both orientations and iPad pro shows sidebar always.

**Test 3:**

1.  launch the app.
2. Make sure you're in landscape mode.
3. See split screen with some other app. Make sure the side bar is visible.
4. Play with the size of the view, resize it a bit. When the view shrinks it should hide the sidebar, when it grows it should show it.
10. Move the app to background and back to foreground, please observe there are no flickers.

**Test 4:**

1.  Launch the app.
2. Make sure you're in landscape mode.
3. Make the multitasking view and make Expensify app a slide over app.
4. Move back to fullscreen/split screen. Make sure the menu is shown accordingly
5. Move the app to background and back to foreground, please observe there are no flickers.

### iPhone:

Non reg with and without the fix video: https://youtu.be/kuv9in8vtbk

Please perform standard smoke tests on transformation changes.

Reviewed By: cipolleschi

Differential Revision: D37239891

Pulled By: jacdebug

fbshipit-source-id: e6090153820e921dcfb0d823e0377abd25225bdf
2022-06-28 08:56:25 -07:00
Lulu Wu 0646551d76 Remove "Early" in Js error reporting function
Summary:
We will use this error reporting pipeline for all js errors not only early js errors, so remove all "early" prefixes.

Changelog:
[General][Changed] - Remove "Early" in Js error reporting pipeline

Reviewed By: fkgozali

Differential Revision: D37379339

fbshipit-source-id: d44772818ead977a164c8632c081863851046be6
2022-06-27 09:22:08 -07:00
Luis Santana 68f3a42fc7 bump RTC-Folly to 2021.07.22 (#33841)
Summary:
Bumping RTC-Folly version used to address CVE-2022-24440.

## 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][Security] - Bump RTC-Folly to 2021-07-22

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

Reviewed By: Andjeliko, philIip

Differential Revision: D36425598

Pulled By: cortinico

fbshipit-source-id: d38c5f020dbecf794b10f12ed2da30e1825071af
2022-06-21 12:36:43 -07:00
Ramanpreet Nara 8dded42b68 Make ScrollView sticky headers work w/o dispatching RCTEventEmitter.receiveEvent
Summary:
# Context
ScrollView sticky headers rely on this bit of code to work:

```
AnimatedImplementation.attachNativeEvent(
  this._scrollViewRef,
  'onScroll',
  [{nativeEvent: {contentOffset: {y: this._scrollAnimatedValue}}}],
);
```

What this code means:

When the ScrollView host component receives the "onScroll" event, assign event.nativeEvent.contentOffSet.y to the this._scrollAnimatedValue AnimatedValue.

How this subscription mechanism is set up:

NativeAnimatedTurboModule subscribes to events dispatched by RCTEventDispatcher sendEvent. Then, whenever RCTEventEmitter sendEvent executes, NativeAnimatedTurboModule also updates the AnimatedValue for that event.

# Problem
Previously, in bridgeless, we started dispatching RCTScrollView via the RCTEventDispatcher sendEvent to update the AnimatedValue for ScrollView. This meant that we started dispatching the onScroll event to JavaScript via RCTEventEmitter.receiveEvent JSModule, which isn't supported in the Fabric renderer.

With this diff, we dialed back that solution. Instead of (1) notifying NativeAnimatedTurboModule and (2) sending the onScroll event to JavaScript, we're only doing (1) (i.e: notifying NativeAnimatedTurboModule).

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D37257719

fbshipit-source-id: 7dea3cf8b9ae78f6b0fd40414b8f224d43367a5a
2022-06-21 07:36:01 -07:00
luoxuhai 47bd78f64f Added userInterfaceStyle to Alert to override user interface style for iOS 13+ (#33553)
Summary:
Support to override Alert interface style to match your app. For example, You want to change the style on the alert.

## 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] [Added] - Add userInterfaceStyle to Alert to override user interface style for iOS 13+

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

Test Plan:
**`userInterfaceStyle: 'light'`:**
<img width="320" src="https://user-images.githubusercontent.com/37284154/161358408-50dbf0a5-ae46-458e-a075-8595cce1b046.png"  />

**`userInterfaceStyle: 'dark'`:**
<img width="320" src="https://user-images.githubusercontent.com/37284154/161358326-bc54effb-1635-43df-97e0-522328713259.PNG"  />

Reviewed By: philIip

Differential Revision: D35371697

Pulled By: ryancat

fbshipit-source-id: 597c1a97ca94571abada2b5fb97cb2adcb5337f5
2022-06-08 18:28:16 -07:00
Paige Sun 4e6c5992b7 Don't display Paper surface from Logbox if Bridge is invalid
Summary: [RN][iOS] Changelog: [Internal][Fix] Minor fix: Don't display a legacy surface from Logbox if Bridge is invalid

Reviewed By: RSNara

Differential Revision: D36268234

fbshipit-source-id: 227f465fb1fc2953b5d6813485ed6750b1d3dea3
2022-05-10 16:25:47 -07:00
Paige Sun f9922a3f46 Fix AppState by removing guard for bridge, since it doesn't use bridge
Summary:
Changelog: [Internal][iOS] Fix AppState in Bridgeless mode by removing guard for bridge, since it doesn't use bridge

AppState doesn't use bridge because RCTAppState subclasses RCTEventEmitter, which calls `_callableJSModules invokeModule` in both Bridge and Bridgeless mode to send events to JS.

Reviewed By: fkgozali

Differential Revision: D35988515

fbshipit-source-id: fb19f0f2df5b270f0ef57637930f94686e39a9a1
2022-05-01 13:36:09 -07:00
Vincent Riemer 6855f7405c Ensure LogBox uses UIWindowScene API for opening its view
Summary: Changelog: [iOS][Internal] Fix: Ensure LogBox uses UIWindowScene API for multi-window Mac Catalyst Apps

Reviewed By: arhelmus

Differential Revision: D35825513

fbshipit-source-id: 3dc5db7c84d2abf7cf4a3ffb3512de723a32f72d
2022-04-25 10:39:26 -07:00
Lulu Wu 30051b2c41 Remove usage of std::string in EarlyJsErrorHandler
Summary:
This would fix test errors caused by including <string> in non-C++ compatible files.

Changelog:
[General][Changed] - Remove usage of std::string in EarlyJsErrorHandler.

Reviewed By: RSNara

Differential Revision: D35645334

fbshipit-source-id: 7f04d2c66d53dc1eef63367de1a64ed9273898f5
2022-04-25 07:48:49 -07:00