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

2874 Коммитов

Автор SHA1 Сообщение Дата
Ramanpreet Nara 777e603075 Separate PushNotification from ReactInternal
Summary:
PushNotificationiOS wasn't used by anything in ReactInternal, so I just removed it from the target.

## Codemod
Everywhere we required `ReactInternal`, we now also require `RCTPushNotification`:
```
> xbgr -f 'BUCK$' 'ReactInternal"' -l | xargs -I {} sed -i '' $'s|ReactInternal",|ReactInternal",\"fbsource//xplat/js:RCTPushNotification",|g' $HOME/{}
> xbgr -f 'BUCK$' 'ReactInternalApple"' -l | xargs -I {} sed -i '' $'s|ReactInternalApple",|ReactInternalApple",\"fbsource//xplat/js:RCTPushNotificationApple",|g' $HOME/{}
> arc f
```

Changelog:
[Internal] - Separate RCTPushNotification from ReactInternal

Reviewed By: PeteTheHeat

Differential Revision: D18363643

fbshipit-source-id: b8d123f40741c6d200dc9e736e64e885c2572e15
2019-11-08 14:14:46 -08:00
Ramanpreet Nara d73ae1baa3 Make RCTWebSocketModule TurboModule-compatible
Summary:
Changelog:
[iOS][Added] - Make RCTWebSocketModule TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D18353766

fbshipit-source-id: fde0f6593dd203ab3dcb8f9cf40012ba4761d6ba
2019-11-08 14:14:46 -08:00
Ramanpreet Nara 525703de5b Separate RCTLinking from ReactInternal
Summary:
None of the code inside `ReactInternal` depended on the `RCTLinkingManager` NativeModule. So I extracted `RCTLinking` into its own BUCK target. This will make it easier to make `RCTLinkingManager` TurboModule-compatible.

## Codemod
Everywhere we required `ReactInternal`, we now also require `RCTLinking`:
```
> xbgr -f 'BUCK$' 'ReactInternal"' -l | xargs -I {} sed -i '' $'s|ReactInternal",|ReactInternal",\"fbsource//xplat/js:RCTLinking",|g' $HOME/{}
> xbgr -f 'BUCK$' 'ReactInternalApple"' -l | xargs -I {} sed -i '' $'s|ReactInternalApple",|ReactInternalApple",\"fbsource//xplat/js:RCTLinkingApple",|g' $HOME/{}
> arc f
```

Changelog:
[Internal] - Separate RCTLinking from ReactInternal

Reviewed By: fkgozali

Differential Revision: D18314747

fbshipit-source-id: d9b5f536a6e93a0aca8721801a2ee5d446e0d4a6
2019-11-08 14:14:45 -08:00
Valentin Shergin 5db27077cb Fixed a race in RCTDevSettings
Summary:
The diff moves an invocation of `_synchronizeAllSettings` from the constructor to `setBridge`. The side-effects of `_synchronizeAllSettings` rely on a bridge not being nil, so we need to ensure that the bridge is assigned to the instance before calling `_synchronizeAllSettings`.
Before the fix, enabling JavaScript debugger caused a stale and opening many copies of a debugger in Chrome.

Changelog: [Internal] Fixed race and possible stale in RCTDevSettings

Reviewed By: RSNara

Differential Revision: D18379596

fbshipit-source-id: 9f64b9bc5426720948113de61bc9ccc8c39193b4
2019-11-07 14:20:18 -08:00
Samuel Susla a0ccd899e3 Add support for commands to interop layer
Summary:
Interop layer can now forward commands to paper components.

Changelog: [internal]

Reviewed By: shergin

Differential Revision: D18285766

fbshipit-source-id: 33fe071c3000569d52fedcbcdeccc354dfe277d9
2019-11-07 08:19:51 -08:00
Valentin Shergin 5b19464b81 Fabric: <UnimplementedView>, a new way to react on missing component
Summary:
This implement new <UnimplementedView> (only for iOS for now) that relies on the new "reactive component registration" functionality.
The `UnimplementedView` component is the perfect example of that. It's simple and uniquely required some constraints that we want to implement: the same component class registered several times with different handles and names.

This change serves two needs:
1. Providing an example of how that functionality can be used in more complex cases.
2. That will allow removing some `UnimplementedView`-specific code from the core (and very hot pathes of the system) and make them `noexcept`. That will eventually allow removing some public APIs from RawValue (constructing from folly::dynamic) that currently impose some implementation details and probably prevent us from making it slightly faster. There are only two consumers of this API, this is one of them.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D17211913

fbshipit-source-id: df1a1ac1a36289ef79904d509d38ee8b3f5588fb
2019-11-06 22:21:31 -08:00
Valentin Shergin b642677a97 Fabric: Removing `ComponentDescriptorProviderRegistry::remove()`
Summary:
This diff removes `ComponentDescriptorProviderRegistry::remove()` and two derivative interfaces.
First, we don't use that and there is no concrete idea why we would need to use that. Those were originally built only for symmetry with limited knowledge about what exactly we need.
Second, those methods are actually dangerous and probably must not be supported by design. Removing a ComponentDescriptorProvider destroys already registered `ComponentDescriptor`s, and at the same time we might have ShadowNodes referring to that (which will cause a crash), and there is no reasonable way to check for the existence of those nodes.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18285497

fbshipit-source-id: b461e38b923c217a256e1155689311397a994feb
2019-11-06 14:43:41 -08:00
Peter Argany 18e3303cd4 Ensure RCTDisplayLink and RCTTurboModuleManager are cleaned up properly [3/N]
Summary: Changelog: [Internal][Fixed] Ensure RCTDisplayLink and RCTTurboModuleManager are dealloc-ed correctly,

Reviewed By: RSNara

Differential Revision: D18283011

fbshipit-source-id: 981b02b7f9a94b8b8c3ad4233df353925b7a4fa4
2019-11-06 14:20:56 -08:00
Ramanpreet Nara 40c588e0de Fix invariant violation on launch
Summary:
Revert some changes from D18148890 as they broke loading of RN surfaces with following error
``Invariant Violation: Expected HMRClient.setup() call at startup`

Changelog: [internal]

Reviewed By: mmmulani

Differential Revision: D18324764

fbshipit-source-id: f1b4af630f8330444f70a4d93be2b53f6d8e31c2
2019-11-06 04:22:45 -08:00
Samuel Susla c6b16ecc41 Interop: move event interceptor lifecycle into separate class
Summary:
In next diff Coordinator will have get more responsibilities therefore it's better to separate the concerns to different class

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D18304834

fbshipit-source-id: 168a68969ed9da5772895f2da87e5273dccbaf30
2019-11-05 12:33:06 -08:00
Radek Czemerys e1d03b4cc0 Reverts "Timing: Fixes timer when app get into background (#24649)" (#27073)
Summary:
This PR reverts commit 338298417f that is causing https://github.com/facebook/react-native/issues/26696 #26995.
> app would be closed immediately after going to background on iOS 13.1/13.2 and was investigated by minhtc https://github.com/facebook/react-native/issues/26696#issuecomment-548056694. The commit that is being reverted is apparently causing the app to be closed immediately. This has to be reverted in master separately as the file differs there.

Similar PR for 0.61. branch https://github.com/facebook/react-native/pull/27065

## Changelog

[iOS] [Fixed] - Fix apps crashing on iOS 13.x when running timer in the background
Pull Request resolved: https://github.com/facebook/react-native/pull/27073

Test Plan: Try [this](338298417f (commitcomment-35745287)) snippet on iOS 13.1/13.2, the app should not crash anymore

Differential Revision: D18323679

Pulled By: cpojer

fbshipit-source-id: 3af7036a0e1d3811924e581c649b16e5a4667e83
2019-11-05 03:32:55 -08:00
Samuel Susla 254f0e4c01 Use generated interface for commands in Switch component
Summary:
Use codegened native commands in Switch

changelog: [internal]

Reviewed By: TheSavior

Differential Revision: D18266849

fbshipit-source-id: a2de0e7342619c437f6d34f8dbf413f2f2888548
2019-11-05 02:12:11 -08:00
Valentin Shergin 89add2582d Fabric: Collecting mounting time inside `MountingTelemetry`
Summary:
Now we also collect mounting time inside MountingTelemetry.
We will use it soon.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D18285826

fbshipit-source-id: 512fc62c210a111614b0defb0d76cbd6228fe89f
2019-11-04 18:21:13 -08:00
Ramanpreet Nara 3beb8341fd Make RCTTVNavigationEventEmitter TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RCTTVNavigationEventEmitter TurboModule-compatible

Reviewed By: shergin

Differential Revision: D18142252

fbshipit-source-id: c633a5a0abd9e980346379921b34219228153348
2019-11-04 16:07:24 -08:00
Ramanpreet Nara 7e5de4e241 Make RedBox TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RedBox TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D18142255

fbshipit-source-id: 2d130aca93a88ac7c983ce0e4848955ffb0be518
2019-11-04 16:07:23 -08:00
Ramanpreet Nara fe3ae9dce8 Make RCTDevMenu and RCTDevSettings TurboModule-compatible
Summary:
Changelog:
[iOS][Added] - Make RCTDevMenu and RCTDevSettings TurboModule-compatible

Reviewed By: shergin

Differential Revision: D18148890

fbshipit-source-id: bd4f0b2797e299cd963e34fa47044a9e1232efe0
2019-11-04 16:07:23 -08:00
Samuel Susla 1cfa1e6fa2 Remove -Wno-unguarded-availability from ReactInternal
Summary:
This will allow us to catch cases where we use iOS 10-only APIs on iOS 9

Changelog: [Internal]

Reviewed By: TheSavior, mmmulani

Differential Revision: D18275225

fbshipit-source-id: dc9c515415208db40750be997173ce5bd6eb494f
2019-11-04 12:03:10 -08:00
Peter Argany dc3b5ad275 Remove unneeded NSNotification center removeObserver
Summary:
A very common pattern I've seen in RN codebase:

     - (instancetype) init {
        [[NSNotificationCenter defaultCenter] addObserver:self ...]
      }

    - (void) dealloc {
       [[NSNotificationCenter defaultCenter] removeObserver:self ...]
     }

From Apple:

https://developer.apple.com/documentation/foundation/nsnotificationcenter/1413994-removeobserver?language=objc

> If your app targets iOS 9.0 and later or macOS 10.11 and later, you don't need to unregister an observer in its dealloc method.

RN targets iOS9+

Changelog: [Internal][Cleanup] Remove unneeded NSNotification center removeObserver

Reviewed By: shergin

Differential Revision: D18264235

fbshipit-source-id: 684e5f5555cec96b055b13cd83daaeb393f4fac9
2019-11-04 10:19:30 -08:00
Ramanpreet Nara 38678f75b4 Fix podspecs
Summary:
I kept on running `USE_FRAMEWORKS=1 update-pods && open RNTesterPods.xcworkspace` and adding missing dependencies until `RNTesterPods` started compiling without failure.

**Note:** I made sure to only commit the podfile changes from `update-pods`, **without** `USE_FRAMEWORKS=1`.

Changelog:
[iOS][Fixed] - Fix all RN Podspecs

Reviewed By: fkgozali

Differential Revision: D18284535

fbshipit-source-id: 44d288ae0e52dd2cbbe26bebe7df73ce05644b5d
2019-11-01 19:34:46 -07:00
Ramanpreet Nara 809d01095e Make RCTPerfMonitor TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RCTPerfMonitor TurboModule-compatible

Reviewed By: shergin

Differential Revision: D18145947

fbshipit-source-id: df2f0d60a4924f094cc4ec311b6bf570fb9fb7e1
2019-11-01 12:06:21 -07:00
Ramanpreet Nara 7233ae4f11 Make RCTAppState TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RCTAppState TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D18142253

fbshipit-source-id: 5bd8afa6e3ee98f92aac3b2ebdfe63b9f7afc775
2019-11-01 12:06:21 -07:00
Ramanpreet Nara 6481a124da Make RCTKeyboardObserver TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RCTKeyboardObserver TurboModule-compatible

Reviewed By: shergin

Differential Revision: D18130902

fbshipit-source-id: 79dff2aeede7cb2485d48597a1f80e546c107e7a
2019-11-01 12:06:20 -07:00
Ramanpreet Nara dc12676e3a Make RCTStatusBarManager TurboModule-compatible
Summary:
See title.

Changelog:
[iOS][Added] - Make RCTStatusBarManager TurboModule-compatible

Reviewed By: shergin

Differential Revision: D18130374

fbshipit-source-id: 3ec226bcff17e47ffd9eba05e32c1eb68d6135b2
2019-11-01 12:06:20 -07:00
Valentin Shergin 41cf6da074 Fabric: Implementation of `RCTMountingTransactionObserving` protocol
Summary:
This diff finally uses all facilities from the previous diffs to build an implementation of  `RCTMountingTransactionObserving` protocol which does *not* require using expensive Objective-C runtime features.

In the coming diffs, we will see how it can/should be used.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18217101

fbshipit-source-id: 34f411dcb527dc81570c2f2833ce13b40e1450db
2019-11-01 09:38:25 -07:00
Valentin Shergin 20a0f224ba Fabric: Introducing `RCTMountingTransactionObserving` protocol
Summary:
See the comment in RCTMountingTransactionObserving first.

I think we have to add this to the iOS mounting layer to be able reasonably easy implement things like:

* MovableNavigationBar: seems, currently we don't handle the situation when the container was mounted first and the nested scroll view second.
* TTI component: It does not have access to telemetry.

The protocol is meant to replace `RCTSurfacePresenterObserver`.

Changelog: [Internal] Fabric-specific change.

Reviewed By: mdvacca

Differential Revision: D16270107

fbshipit-source-id: 2d4bdb7d0092cc214cc433fc633e41e58f6677df
2019-11-01 09:38:25 -07:00
Valentin Shergin c583822504 Fabric: Introducing `RCTComponentViewClassDescriptor`
Summary:
RCTComponentViewClassDescriptor is a pretty much the same as RCTComponentViewDescriptor but for *classes*. RCTComponentViewFactory uses a map of those data structures to create RCTComponentViewDescriptor instances (which reflects the same properties) efficiently.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18217103

fbshipit-source-id: ab7ab6b0712048d0085b61a3604b284b1fb5a68b
2019-11-01 09:38:25 -07:00
Valentin Shergin 93ded152d9 Fabric: Introducing `RCTComponentViewDescriptor`
Summary:
This diff introduces RCTComponentViewDescriptor - the container for a view and associated with this view properties which mounting infra uses for bookkeeping (and recycling) views.
The previous implementation used raw Objective-C pointers to `UIView`s to store and manipulate them. The new way has a bunch of advantages:
* It allows using high-performant C++ data collections for storing views and their properties (in future diffs).
* The new approach allows us to avoid hacks around NSMapTable (such as ` [_registry setObject:componentView forKey:(__bridge id)(void *)tag];`) that were needed because NSMapTable wasn't designed for our use-case.
* Dealing with `RCTComponentViewDescriptor` which stores a pointer to a view sometimes is actually more efficient than dealing with those pointers themselfs because we can deal with `const &` to a descriptor which does not require a ref-counter bump.
* A new approach is much more flexible, it allows us to store additional data alongside view instances which we will use in coming diffs.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18217102

fbshipit-source-id: 063e6c7df794a2e1fd690c194fb31ad6833eaba7
2019-11-01 09:38:24 -07:00
Valentin Shergin 8a1937ace6 Fabric: `RCTComponentViewRegistry::findComponentViewWithTag` was split into two methods
Summary:
In addition to already exiting method `componentViewByTag`, this diff adds a new one `findComponentViewWithTag` which does pretty much the same thing but returns `nil` in a case when it cannot find a view with a given tag. The first method now returns a non-nullable object, whereas the second (new) one return nullable.

We need this to explicitly designate call-sites that are resilient to such kind of errors, where such errors are expected because of still-existing consistency problems (because of some legacy implementation approaches).
At the same time, for the call-sites where a missing view situation is unrecoverable, we should throw early and stop paying for nullability overhead.
In the future diffs, we will change the internal implementation of the registry where the price for dealing with nullability will be actually meaningful.

This is the first diff on the road to an implementation of `RCTMountingTransactionObserving` protocol.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18217099

fbshipit-source-id: dc50033ecadd43c43c5a65fed62649a1a7acf2b5
2019-11-01 09:38:24 -07:00
Valentin Shergin 746e697038 Fabric: Removing `RCTComponentViewRegistry::tagByComponentView`
Summary:
This method has no any usages.

Changelog: [Internal] Fabric-specific, internal change.

Reviewed By: sammy-SC

Differential Revision: D18217100

fbshipit-source-id: 7aabd9e83413c2a1040bdd6c1510d6e4a4c6446a
2019-11-01 09:38:24 -07:00
Tim Yung 548aad4ff1 RN: Delete Apple TV Props
Summary:
With tvOS (Apple TV) now residing in a separately maintained fork, this removes the residual props from React Native. This only includes the JavaScript changes. The Objective-C changes will come later.

Specifically, the following props have been removed:

- `isTVSelectable`
- `tvParallaxProperties`
- `tvParallaxShiftDistanceX`
- `tvParallaxShiftDistanceY`
- `tvParallaxTiltAngle`
- `tvParallaxMagnification`

Note that `hasTVPreferredFocus` is still being used by Android TV, so it remains.

Changelog:
[Removed] Apple TV View Props

Reviewed By: TheSavior

Differential Revision: D18266278

fbshipit-source-id: 9d1448bf2f434a74e6eb23c70d3a37971e406768
2019-11-01 08:49:26 -07:00
Valentin Shergin 1a520e7b5a Fabric: Fixing a typo in RCTSurfacePresenterBridgeAdapter
Summary:
Shameful copy-pasta error.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18220281

fbshipit-source-id: 96a6babc2abb654b0fc8463d151307fe9ef97037
2019-10-31 21:41:11 -07:00
Samuel Susla a82ebeb6f3 Fabric: Use padding instead of size for SafeAreaView
Summary:
Use padding instead of setting size of SafeAreaView, this should make it more consistent with Paper component.

changelog: [internal]

Reviewed By: shergin

Differential Revision: D18225793

fbshipit-source-id: 08dccbdae0e4f7a7847501a06e17d4c26473462a
2019-10-31 21:25:37 -07:00
Samuel Susla cd1abb3bca Fabric: Fix order of arguments in RCTEdgeInsetsFromUIEdgeInsets
Summary:
Order of arguments for `RectangleEdges` was incorrect

changelog: [internal]

Reviewed By: shergin

Differential Revision: D18231825

fbshipit-source-id: 188d7af405ce801437ff67999a8f7dae77ae03c0
2019-10-31 21:25:37 -07:00
Rick Hanlon 6b783b4fb0 LogBox - Don't show native redbox for JS errors
Summary:
This diff switches the exception manager over to the reportException native module function on iOS and adds a new field `extraData.showRedbox` as a temporary hack to control hiding/showing native redboxes for LogBox.

Once LogBox is rolled out we'll remove this field, so we're hacking it into the available unused and untyped extraData bag, which will simplify gutting it in the future.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D18212047

fbshipit-source-id: f14e31d90359b7d455a73c2368ce010c28364a5c
2019-10-31 16:26:42 -07:00
Samuel Susla fbfce92e97 Use ReactTag to map events to component view
Summary:
Use `reactTag` instead of address of `UIView` to map events from paper components to Fabric.

changelog: [internal]

Reviewed By: shergin

Differential Revision: D17954974

fbshipit-source-id: 0d8bf748e58f4cb6769e107bc7fd0e66b93d8f12
2019-10-31 14:42:47 -07:00
Samuel Susla 03fd80c937 Refactor RCTLegacyViewInteropComponentView
Summary:
Simplify logic in `RCTLegacyViewManagerInteropComponentView` by caching views that are mounted and unmounted and applying it in finalise.

changelog: [internal]

Reviewed By: shergin

Differential Revision: D17954975

fbshipit-source-id: 11c8ec9e6eabb8a838a83f5fc2428912f4ec9523
2019-10-31 14:42:47 -07:00
Samuel Susla 19f58f4935 Add FBGroupsLandingView to LegacyViewManagerInterop whitelist
Summary:
Allow components outside of React-Native core to be registered with LegacyViewManagerInterop

changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D17912238

fbshipit-source-id: 67a9109c427c5e3efb8ebb6c6f8c13c2931461a3
2019-10-31 14:42:47 -07:00
Peter Argany 2a13f12106 Re-implement reload reason [7/n]
Summary:
This diff adds back RN reload reason, which was removed earlier in the stack. cc/Rick

For callsites which already had a reason, I kept the string exactly the same. For callsites which didn't have a reason, I made up something reasonable.

Changelog: [Internal][Fixed] Re-implemented bridge reload reason text.

Reviewed By: RSNara

Differential Revision: D18074478

fbshipit-source-id: 64a3cd7718674a7ba7228a80e34791ce9f153f9f
2019-10-30 12:23:25 -07:00
Peter Argany 5ca0df64a1 Deprecate RCTBridgeWillReloadNotification [3/n]
Summary:
`RCTBridgeWillReloadNotification` has one job: whenever bridge reloads - trigger a reload in `RCTSurfacePresenter`.

Diff 1/2 deprecated bridge reloading APIs, and replaced them with `RCTReloadCommand`. Use that in `RCTSurfacePresenter` instead .

Changelog: [iOS][Deprecate] Deprecate RCTBridgeWillReloadNotification

Reviewed By: shergin

Differential Revision: D17880926

fbshipit-source-id: 00adc4d56d11d40ab371d81bb17a05609c184769
2019-10-30 12:23:24 -07:00
Peter Argany d98cd7d3a1 Migrate bridge reload to RCTReloadCommand [2/n]
Summary:
Motivation described in diff 1/N.

This diff replaces calls to `[bridge reload]` with calls to `RCTReloadCommand`. This shouldn't have any change in behaviour since RCTBridge listens to RCTReloadCommand and calls `[bridge reload]` [here](https://fburl.com/diffusion/kemzkrei).

It will allow us to customize who listens and reacts to RN lifecycle.

Changelog: [Internal][Changed] - Migrated [bridge reload] calls to RCTReloadCommand

Reviewed By: shergin

Differential Revision: D17880909

fbshipit-source-id: 80b26c6badd4b216656fed6dd04554e9877f4bb7
2019-10-30 12:23:24 -07:00
Peter Argany ffe2306164 Deprecate bridge reload API [1/n]
Summary:
Testing the waters with an idea for unifying RN lifecycle with/without bridge.

### Motivation/Background

RN bridge is being reloaded from [several different places](https://fburl.com/codesearch/ae3zeatt). When this happens, the bridge does a bunch of things:
1. Post `RCTBridgeWillReloadNotification` (RCTSurfacePresenter listens to this and reloads)
2. Invalidate batched bridge, which does:
    a. invalidate display link
    b. post `RCTBridgeWillInvalidateModules/RCTBridgeDidInvalidateModules` (TurboModuleManager listens to this and reloads modules)
    c. clear js thread state
    d. clear some local caches
3. Set up (reload bundle and batched bridge)

In a bridgeless world, there isn't one thing which owns all these peices of infra, and can reload them.

### Plan

Use `RCTReloadCommand` to handle reloads. This light class previously only handled CMD+R. The new workflow looks like this:
1. Anything which cares about reloads can register itself as a listener. (RCTBridge, RCTSurfacePresenter, TurboModuleManager...)
2. Anything that previously called `bridge reload` now calls `RCTTriggerReloadCommandListeners`.
3. Delete old notifications

### Alternate Plan

Use yet another NSNotification. I like `RCTReloadCommand` better.

### Unknowns

Looks like we log the reason for bridge reloading [here](https://fburl.com/diffusion/lc9jj8la), do we want to save this behaviour? Does anyone look at why bridge is being reloaded cc/Rick? If so, I can add back that functionality to `RCTReloadCommand`.

It should be possible to customize the order/priority of what gets reloaded first. There may be some racy behaviour that I haven't thought about yet.

Changelog: [iOS][Deprecated] Deprecate [bridge reload] API - prefer RCTReloadCommand

Reviewed By: shergin

Differential Revision: D17869635

fbshipit-source-id: 81f39eaa2c3ce08ea1bc6f2193684c2630d81a2d
2019-10-30 12:23:24 -07:00
Andrew Monshizadeh 35b8b06db9 Fix unrecognized selector for iOS 9
Summary:
Refresh control is only available in iOS 10+

> https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol?language=objc

changelog: Fix crash in RCTPullToRefreshViewComponentView on iOS 10

Reviewed By: sammy-SC

Differential Revision: D18201528

fbshipit-source-id: 0dd3dad7cabe08589a597039c1dae44da868e1e5
2019-10-30 11:23:58 -07:00
Adam Foxman fe9cba74fa Expose [RCTBundleURLProvider isPackagerRunning] publicly (#27012)
Summary:
The private API isPackagerRunning is useful. Rather than duplicating it, I am exposing it here so that I can make use of it in future PRs, and so others can do the same.

## Changelog

[iOS] [Changed] - Expose the isPackagerRunning methods on RCTBundleURLProvider
Pull Request resolved: https://github.com/facebook/react-native/pull/27012

Test Plan: This change doesn't impact any runtime code, though it does impact build. I used a vanilla test app (react-native init) and built it using xcode as well as react-native run-ios.

Differential Revision: D18174316

Pulled By: cpojer

fbshipit-source-id: 523d134882303f68a1f69521e31f29d7dbfb666c
2019-10-30 08:36:45 -07:00
Victor Fernandez 7468a6c903 Fix Share dialog not resolving promise when dismissed on iOS (#26842)
Summary:
On iOS the promised returned by `Share.share(content, options)` isn't resolved if the user dismisses the dialog by either pressing "Cancel" or pressing outside the shared dialog. This PR fixes this issue.

This fixes https://github.com/facebook/react-native/issues/26809.

## Changelog

[iOS] [Fixed] - Fix promised returned by `Share.share(content, options)` not resolving if share dialog dismissed
Pull Request resolved: https://github.com/facebook/react-native/pull/26842

Test Plan:
1. on iOS, open a share dialog with:

```typescript
const onShare = async () => {
  const result = await Share.share({ message: 'example message' });
}
```

2. Dismiss the opened share dialog and the returned promised should resolve.

Differential Revision: D18189755

Pulled By: cpojer

fbshipit-source-id: 1269932e9549026afefdaa8478ff7d33bbaeb86f
2019-10-28 16:24:16 -07:00
Dratwas 2f8328dbb0 Remove max depth parameter while measuring layout of shadow view (#26986)
Summary:
Searching for the ancestor view while measuring a shadow view layout relative to the ancestor is limited to `30`. I couldn't find the reason nor commit where it was introduced (because I have no access to internal facebook commits).
I think we should keep looking for an ancestor view until the shadow view has the superview property.

## Changelog

[iOS] [Fixed] - Remove maximum searching depth while measuring layout.
Pull Request resolved: https://github.com/facebook/react-native/pull/26986

Test Plan:
- Tested if RNTester works as expected.
- Tested in app with a lot of nested flatlists where sometimes I was facing this redbox because of the max depth limit.
<img width="297" alt="Screenshot 2019-10-24 at 14 40 11" src="https://user-images.githubusercontent.com/16336501/67486474-6309d380-f66c-11e9-9eab-15e8fb8372a5.png">

Differential Revision: D18175568

Pulled By: shergin

fbshipit-source-id: cd59a18032d10bc6dd5707981e69813810f65b5a
2019-10-28 13:17:09 -07:00
Samuel Susla 4c4948b6e8 Fix unrecognised selector crash on iOS 9
Summary:
Refresh control is only available in iOS 10+

> https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol?language=objc

changelog: Fix crash in `RCTPullToRefreshViewComponentView` on iOS 10

Reviewed By: cpojer

Differential Revision: D18161020

fbshipit-source-id: c789433f132e68fc71c875e1da79bfe4fd799a44
2019-10-28 00:07:19 -07:00
Adam Ernst bdaab3c2e5 Run depslint on fb_plugin_apple_library rules
Summary: Changelog: [Internal]

Differential Revision: D18152380

fbshipit-source-id: f33f6cb2f6baeba0719a91c5189357be33a38f59
2019-10-26 13:47:15 -07:00
Valentin Shergin 34816f4d47 Fabric: Suspending all Fabric screens on bridge invalidation
Summary:
Previously, Fabric (RCTSurfacePresenter) was unaware of the bridge being valid or not. That caused the strange situations where the bridge might be already dead is still running.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D18050888

fbshipit-source-id: 34e3ec4b6991034410a40c041cfdcca36be8d743
2019-10-24 17:45:41 -07:00
Valentin Shergin 7a20964e9d Introducing `RCTBridgeWillBeInvalidatedNotification`
Summary:
This diff introduces a new broadcasting event for Bridge that communicates that the bridge is being invalidated. This notification can be used by interested parties as a signal to start tearing down all bridge-dependant processes.

The biggest difference between the new event and `RCTBridgeWillInvalidateModulesNotification` is that the latter is being called asynchronously on the JavaScript thread, whereas the new one is being called on whatever thread caused the Bridge invalidation (deallocation) *synchronously*. In most cases that happens on the main thread that allows destroying strictly-main-threaded infra (mostly UI) synchronously and avoids races.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D18050889

fbshipit-source-id: 9364c820ea2b0358edf45f0e2b3e16a13d730a9c
2019-10-24 17:45:40 -07:00
Valentin Shergin b3cb27ee9f Fabric: Removing sync block dispatching from `RCTRuntimeExecutorFromBridge`
Summary:
The purpose of RCTRuntimeExecutorFromBridge is to create/implement RuntimeExecutor using some JS queue implemented as part of the Bridge. This diff changes the implementation of this method, specifically:
Removing dispatching a sync block. This causes a deadlock with TM sometimes and should not be generally required.
The implementation does not retain the Bridge anymore.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D17960236

fbshipit-source-id: 0ddea561a6884f066e483d6b0f41ddd1621df73c
2019-10-24 17:45:40 -07:00
Valentin Shergin 32b30074d3 Fabric: Introducing RCTSurfacePresenterBridgeAdapter
Summary:
Yes, this is a pretty big diff; because of the high interconnectedness of the things, I failed to split it apart.

This change does:
Introduces a new class RCTSurfacePresenterBridgeAdapter which decouples all Bridge-related functionality from RCTSurfacePresenter.
The new class allows "replacing" one instance of the bridge with another for a single RCTSurfacePresenter.

This change allows implementing unloading a bridge (e.g. during memory pressure warning) and suspending all RN surfaces with the future possibility of reloading a bridge and resuming surfaces.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D17960239

fbshipit-source-id: 7ae556ed91030f4c5ab187689ce6bd161fabde93
2019-10-24 17:45:40 -07:00
Valentin Shergin 4bdb702b9e Fabric: Generalizing `suspense` and `resume` operations in `RCTSurfacePresenter`
Summary:
We need this for better decoupling RCTSurfacePresenter from Bridge.

Changelog: [Internal] - Changes in RCTSurfacePresenter (Fabric)

Reviewed By: sammy-SC

Differential Revision: D17960237

fbshipit-source-id: e91cd04eab967745c6e5151187eb68ba108f3986
2019-10-24 17:45:39 -07:00
Mehdi Mulani 03acf57b76 Fix use of safeAreaInsets for old versions of iOS
Summary:
This would cause a crash on iOS 9.3 because this method does not exist on UIView on that platform. By wrapping it in an availability check, we provide some safety.

Changelog: [iOS] [Fixed] safeAreaInsets call would crash on older versions of iOS

Reviewed By: fkgozali

Differential Revision: D18118025

fbshipit-source-id: fb7e517b3bcb3e0ba11ae81d8bf8397abc227e04
2019-10-24 10:35:10 -07:00
Kevin Gozali 285d4742a9 iOS: optimize RCTUserInterfaceStyleDidChangeNotification handling
Summary:
* Fabric surface hosting view should emit the same event as RCTRootView
* Before emitting to JS, make sure to check if the color scheme really changed to avoid unnecessary re-render in JS

Changelog: [Internal]

Reviewed By: mdvacca, mmmulani

Differential Revision: D18100700

fbshipit-source-id: 451199beac07cdfb3833131ee429cc151391d8dd
2019-10-23 19:04:36 -07:00
Kevin Gozali 25d94ff34d iOS Allow disabling color scheme preference
Summary:
Some apps may need to disable the automatic dark mode color scheme assignment. This provides such kill switch.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D18088313

fbshipit-source-id: 75abf34e92f8a4a637daa26135adf85965cb9df5
2019-10-23 15:52:45 -07:00
Emily Janzer e7f6210d5d Don't attempt to connect to React devtools every 2s
Summary:
When testing out the NetworkOverlay, I noticed that we were creating a lot of WebSocket connections for localhost:8097. Rick found that this is because we're trying to connect to React devtools every 2 seconds: https://github.com/facebook/react/blob/master/packages/react-devtools-core/src/backend.js#L67 and it appears we create a new WebSocket every time.

Dan suggested that we use opening the dev menu as a trigger for attempting to connect to React devtools. This diff uses RCTNativeAppEventEmitter to emit an event from native when the dev menu/dialog is shown, and listening to that event in JS to attempt to connect to devtools.

I'm also making the change of passing in a websocket instead of just passing in the host + port; this way it will only attempt to connect once on each call to `connectToDevTools` (otherwise, we would attempt to reconnect every 2 seconds as soon as the dev menu is opened, and then the next time the menu is opened we'd so start that *again*, and so on - I could have it keep track of whether it's already connecting and avoid doing it again, but this is easier and should be sufficient, I think).

We should probably also update the suggested troubleshooting tips on the devtools page to reflect this change, so that people don't get confused.

Changelog: [General] [Fixed] Fix issue where we attempt to connect to React devtools every 2 seconds

Reviewed By: mmmulani

Differential Revision: D17919808

fbshipit-source-id: 4658d995c274574d22f2f54ea06d7f29ef2f54dc
2019-10-23 10:30:43 -07:00
Joe Loser ba18ee9b87 Replace folly::make_unique with std::make_unique (#26730)
Summary:
There is a mixed usage of `folly::make_unique` and `std::make_unique`. Soon, `folly::make_unique` may be removed (see [this PR](https://github.com/facebook/folly/pull/1150)). Since `react-native` only supports C++14-compilers and later, switch to always using `std::make_unique`.

## Changelog

[Internal] [Removed] - Replace folly::make_unique with std::make_unique
Pull Request resolved: https://github.com/facebook/react-native/pull/26730

Test Plan:
Running the existing test suite. No change in behavior is expected.

Joshua Gross: buck install -r fb4a, make sure MP Home and forced teardown works okay on android

Reviewed By: shergin

Differential Revision: D18062400

Pulled By: JoshuaGross

fbshipit-source-id: 978ca794c7e972db872a8dcc57c31bdec7451481
2019-10-22 12:21:41 -07:00
Moti Zilberman 468d1a2d2e Render collapsed frames in RedBox
Summary:
Renders frames in RedBox in a greyed-out style when their `collapse` field is set to `true`. This avoids outright hiding information in the stack trace while still drawing attention to frames that are likely to be more meaningful.

Changelog: [General] [Changed] - Render collapsed JavaScript frames in RedBox

Reviewed By: rickhanlonii

Differential Revision: D18039438

fbshipit-source-id: 527588f11c0bff495842be7036cd1293bab65eb9
2019-10-22 11:05:36 -07:00
Ramanpreet Nara d8fda74c24 Move RCTImage NativeModules back to RCTImage
Summary:
In D16805827, I moved `RCTImageLoader`, `RCTImageStoreManager`, and `RCTImageEditingManager` to `CoreModules`. This was necessary to turn `RCTImageLoader` into a TurboModule. However, after D17671288 landed, it's no longer necessary to have OSS NativeModules in `CoreModules`. Therefore, I'm moving these NativeModules back to `RCTImage`.

Changelog: [iOS][Fixed] Move RCTImage NativeModules back to RCTImage

Reviewed By: shergin

Differential Revision: D17921612

fbshipit-source-id: 8ae36d2dc8deaf704313cbe2479bfa011ebcbfbc
2019-10-21 17:15:32 -07:00
Ramanpreet Nara 2b5f4de7eb Make RCTTiming TurboModule-compatible
Summary: Changelog: [iOS][Added] Make RCTTiming TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D17891665

fbshipit-source-id: e0d36ccfb4f3f1d428668836a8b66698d51bdeaf
2019-10-16 19:00:26 -07:00
Emily Janzer f2f4d33a3a Remove unsupported flow types from OSS native module specs
Summary:
Some of our NativeModule type specs aren't compatible with our Android codegen and type safety checks - specifically, we don't support `$ReadOnly` in our type checks, and we don't support map types in the codegen. Removing these from a couple of the OSS type specs so we can enable codegen for these modules (eventually).

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D17882093

fbshipit-source-id: 6e8669e4be775347199b2b5346bd8d40d7620886
2019-10-16 11:14:04 -07:00
Andres Suarez aee88b6843 Tidy up license headers [3/n]
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: yungsters

Differential Revision: D17952693

fbshipit-source-id: 8fcb8e58a2e04e7a3169f4d525bffc00835768e6
2019-10-16 10:06:34 -07:00
Andres Suarez 3b31e69e28 Tidy up license headers [2/n]
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: yungsters

Differential Revision: D17952694

fbshipit-source-id: 17c87de7ebb271fa2ac8d00af72a4d1addef8bd0
2019-10-16 10:06:34 -07:00
Andres Suarez 722feeb02b Tidy up license headers [1/n]
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: yungsters

Differential Revision: D17952695

fbshipit-source-id: 81aa607612ba1357ef7814ef20371335151afe7e
2019-10-16 10:06:33 -07:00
Samuel Susla 0d1b9b5397 Add MaskedView to LegacyViewManagerInterop white list
Summary:
For components to be used with LegacyViewManagerInterop they need to be added to a white list.
This makes it possible to test it out and assure proper functionality.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D17906107

fbshipit-source-id: 60ee99e6b973ba2d6fe804f3c99e492603d3cf8f
2019-10-16 04:26:44 -07:00
Samuel Susla 5327c3ed83 Forward subviews to Paper component from LegacyViewManagerInterop
Summary:
`RCTMaskedView` is simple enough to migrate manually to Fabric and I think we should eventually do it.
However this gives us opportunity to spot shortcomings of `LegacyViewManagerInterop` and address them.

Now `LegacyViewManagerInterop` forwards `mountChildComponent` and `unmountChildComponent` events to Paper component that it is wrapping.

Reviewed By: shergin

Differential Revision: D17905807

fbshipit-source-id: ad36c186d5c5a8ed164e412fa5fdf0042de46348
2019-10-16 04:26:43 -07:00
Andres Suarez e1cfeaddd4 Move non-license comments out of license header
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: cpojer

Differential Revision: D17749100

fbshipit-source-id: edca9c73a065e9fc311109cd6efeb1f75451a55a
2019-10-15 20:12:12 -07:00
Mehdi Mulani fc80a51457 Make RCTRedBox customizable
Summary:
Adds the ability to add extra buttons and renders them along with the other buttons.

Changelog: [iOS] [Added] - RCTRedBox ability to add extra buttons

Reviewed By: PeteTheHeat

Differential Revision: D17935352

fbshipit-source-id: f8fb28653e535cd2c098566afbc639eb5c196228
2019-10-15 20:09:39 -07:00
Mehdi Mulani ef3f80abc1 Refactor RCTRedBox button creation
Summary:
@public
A lot of this code was duplicated, so move it all into one method.
Later in this stack, I will make custom red box buttons which will need to reuse this method.

Changelog: [iOS] [Changed] - Refactor RCTRedBox button creation

Reviewed By: PeteTheHeat

Differential Revision: D17915485

fbshipit-source-id: ede649862556b057779e0267118799c63f0215b8
2019-10-15 20:09:39 -07:00
Janette Cheng 10cc834567 Use fbandroid_labels and fbobjc_labels in xplat targets
Summary:
`xplat` targets add different deps based on what platform the target is being built for.

for anything using `fb_xplat`, we can put all ios supermodules in `fbobjc_labels` and all android sms in `fbandroid_labels`

There's some weirdness with python targets like `thrift_gen` in  `/xplat/mobileconfig/tools/generator/gen-py/BUCK` that don't have platform-specific labels because the except_for list for `fbandroid` doesn't need the `fbsource//` prefix (see changes in `/ios/isolation/infra.mobileconfig.sm`)

Changelog: [Internal]

Reviewed By: shergin, joshleibsly

Differential Revision: D17884952

fbshipit-source-id: e245364cf515b75682990094d24f789d53b1f3f5
2019-10-15 19:32:27 -07:00
Peter Argany 79b573511b Fix RCTNullIfNil macro
Summary:
`RCTNullIfNil()` can return nil in certain scenarios.

Example, given:
`#define RCTNullIfNil(value) (value ?: (id)kCFNull)`
`RCTNullIfNil(nil == nil ? nil : @"lol")`
expanded out
`nil == nil ? nil : @"lol" ?: (id)kCFNull`

`?:` takes precedence, so reduced:
`nil == nil ? nil : @"lol"`
`nil`

Changelog: [iOS] [Fixed] Fixed longstanding bug where RCTNullIfNil() can return nil

Reviewed By: RSNara

Differential Revision: D17943530

fbshipit-source-id: 8c6e3dd2d86cbc8ff1fcbef732674835a312ef26
2019-10-15 18:02:27 -07:00
Valentin Shergin 101f864bcc Fabric: Fixed a crash in RCTImageResponseObserverProxy
Summary:
This fixes the crash, here is why:
When a block refers to `delegate_`, it  actually refers to `this->delegate_`, which means it no retaining happening (there is no way to retain C++ class). That causes a crash when the block overlive the class instance.
Making a local copy of `delegate_` enables proper ARC-powered retaining and prevents the crash.

Changelog: [iOS] [Fixed] - Fixed crash in RCTImageResponseObserverProxy (Fabric)

Reviewed By: sammy-SC

Differential Revision: D17923548

fbshipit-source-id: 71aff44647730a5cc1996928c164d3892884b455
2019-10-15 16:15:11 -07:00
Valentin Shergin dec80fe486 Fabric: Simplifying allocation/storing of RCTImageResponseObserverProxy
Summary: We don't need to have it as `std::unique_ptr`, we can simply store it by value.

Reviewed By: sammy-SC

Differential Revision: D17923551

fbshipit-source-id: e8222834a8dd8f84826e4e89067610cd0a7cac73
2019-10-15 16:15:11 -07:00
Valentin Shergin 01143859ff Fabric: Simplifying RCTImageResponseObserverProxy interface
Summary: There is no reason why RCTImageResponseObserverProxy accepts untyped pointer. This diff fixes that. The call sites now look much cleaner.

Reviewed By: sammy-SC

Differential Revision: D17923552

fbshipit-source-id: b08556e1164b00c9cf2676c0d9b1718ae60b2aca
2019-10-15 16:15:11 -07:00
Valentin Shergin 23564ab44d Fabric: Enforcing `RCTImageResponseDelegate` conformance
Summary: For `RCTSliderComponentView` the conformance to the protocol wasn't enforced. For `RCTImageComponentView` it was in .h file without a need to be exported.

Reviewed By: sammy-SC

Differential Revision: D17923550

fbshipit-source-id: d98b892d24d9079a7109dc7d881c5c5a175fe3bf
2019-10-15 16:15:10 -07:00
Valentin Shergin 14df0b2a78 Fabric: Using `wrapManagedObject` in `RCTImageManager` instead of manual casting
Summary: Hiding casting madness and complexity behind a helper function to avoid bugs and improve maintainability.

Reviewed By: sammy-SC

Differential Revision: D17923549

fbshipit-source-id: 105891d85b0412fa4a17d7ae8a9e156fc1b151fb
2019-10-15 16:15:10 -07:00
Ramanpreet Nara 2b62bd7695 Make RCTAsyncLocalStorage TurboModule-compatible
Summary:
**Note:** This was landed in D17724498 but reverted in D17855088. The revert had nothing to do with this NativeModule.

Changelog: [iOS][Added] Make RCTAsyncLocalStorage TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D17917841

fbshipit-source-id: 0f9dd5f592180d6512ca560007daa531a4da5b59
2019-10-15 09:16:56 -07:00
Ramanpreet Nara da6274ba76 Make RCTAlertManager TurboModule-compatible
Summary:
**Note:** This was landed in D17722913, but reverted in D17855088. The revert had nothing to do with this NativeModule.

Changelog: [iOS][Added] Make RCTAlertManager TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D17917827

fbshipit-source-id: d86ea2cddddd9535d656709296c74aebd6f45793
2019-10-15 09:16:56 -07:00
Samuel Susla be89e4d928 Fix tintColor in SegmentedControlIOS component
Summary:
iOS 13 introduced a new design for `UISegmentedControl` and new APIs to control this. `[UISegmentedControl tintColor]` is now ignored.

We try to maintain backwards compatibility so the appearance is as close as possible to iOS 12.

Changelog:
Fix `tintColor` on SegmentedControlIOS

Reviewed By: shergin

Differential Revision: D17905892

fbshipit-source-id: 964ac64c8543660929c43b427dce4f78094b1255
2019-10-15 08:13:37 -07:00
Valentin Shergin e7ef9921d3 Fabric: Fixing crash in RCTScrollViewComponentView (2nd attempt)
Summary:
Seems a ScrollView sometimes calls the delegate in own destructor; and seems that in some configurations the delegate is also already destroyed at this point. I am not sure if this a bug in UIKit or not, but seems the fix is easy, we just have to clear the ScrollView's delegate on the delegate's deallocation.
This issue is also looks similar:
https://stackoverflow.com/questions/18778691/crash-on-exc-breakpoint-scroll-view/19011871

Changelog: [iOS] [Fixed] - Fixed crash in RCTScrollViewComponentView

Reviewed By: sammy-SC

Differential Revision: D17924429

fbshipit-source-id: 5727bca9f028e28f76f60304c187ee39eb6e1856
2019-10-15 07:43:20 -07:00
Valentin Shergin beae6d6fa0 Revert D17456225: [RN] RCTRefreshControl was renamed to PullToRefreshView (for Paper)
Differential Revision:
D17456225

Original commit changeset: a8db99ddd507

fbshipit-source-id: 3186d76de13cccc21619702a1ad07842a4788b15
2019-10-15 07:11:53 -07:00
Samuel Susla ddbfe24c3b Add SegmentedControl to LegacyViewManagerInterop white list
Summary:
For components to be used with LegacyViewManagerInterop they need to be added to a white list.
This makes it possible to test it out and assure proper functionality.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D17905453

fbshipit-source-id: 4e8e53a1898b38b2c9f01e7fc9e3527bd7004ffb
2019-10-15 03:16:21 -07:00
Samuel Susla 53f003f233 Add ProgressView to LegacyViewManagerInterop white list
Summary:
For components to be used with LegacyViewManagerInterop they need to be added to a white list.
This makes it possible to test it out and assure proper functionality.

Reviewed By: shergin

Differential Revision: D17905413

fbshipit-source-id: f5ab523cca6227e99a7607ca1927005392b1ae36
2019-10-15 03:16:21 -07:00
Valentin Shergin 08d6cb19c4 RCTRefreshControl was renamed to PullToRefreshView (for Paper)
Summary:
The component RCTRefreshControl was renamed to PullToRefreshView (for Paper). Now only old Objective-C class names have the old name, which is okay.

Changelog: [Internal] [Changed] - The internal name of PullToRefresh component was changed from `RCTRefreshControl` to `PullToRefreshView` (No public API changes)

Reviewed By: rickhanlonii

Differential Revision: D17456225

fbshipit-source-id: a8db99ddd507377d8c98b26707a3b9fae483d20c
2019-10-14 20:49:48 -07:00
Sharon Gong baa66f63d8 Announce accessibility state changes happening in the background (#26624)
Summary:
Currently the react native framework doesn't handle the accessibility state changes of the focused item that happen not upon double tapping. Screen reader doesn't get notified when the state of the focused item changes in the background.
To fix this problem, post a layout change notification for every state changes on iOS.
On Android, send a click event whenever state "checked", "selected" or "disabled" changes. In the case that such states changes upon user's clicking, the duplicated click event will be skipped by Talkback.

## Changelog:
[General][Fixed] - Announce accessibility state changes happening in the background
Pull Request resolved: https://github.com/facebook/react-native/pull/26624

Test Plan: Add a nested checkbox example which state changes after a delay in the AccessibilityExample.

Differential Revision: D17903205

Pulled By: cpojer

fbshipit-source-id: 9245ee0b79936cf11b408b52d45c59ba3415b9f9
2019-10-14 00:28:34 -07:00
Samuel Susla ffc7ec992c Add support for ScrollView.onScroll animations
Summary: To enable onScroll animations with Fabric's scrollView on iOS, we dispatch onScroll event to Paper's eventDispatcher as well as to Fabric's one. One we have a proper NativeAnimationDriver in place, we will get rid of this.

Reviewed By: shergin

Differential Revision: D17814260

fbshipit-source-id: f04faf59cdfd4ea5cede513388e30500b4cb2ad5
2019-10-11 06:55:21 -07:00
Samuel Susla 4159e20146 Fix throttling in scroll view
Summary:
Setting minimal throttle to 1/60 causes dropped updates.

Let's take following example

Each frame is 16.666 MS.

Frame1: [________didScroll is called towards end of the frame_]

Frame2: [_didScroll is called towards beginning of the frame_________]

update from Frame 2 doesn't propagate because we set throttle to 16MS thinking that `onScroll` is called for each frame.

If Javascript specified value below 1/60 it is basically asking for every update.

Reviewed By: shergin, mdvacca

Differential Revision: D17829926

fbshipit-source-id: e7b07fd09581cd5053aa27a62cf6f6ddb2193783
2019-10-11 05:44:49 -07:00
Samuel Susla 1ba67fd9a6 Move RCTScrollEvent into separate file
Summary: Move RCTScrollEvent into separate file and export its header.

Reviewed By: shergin

Differential Revision: D17831709

fbshipit-source-id: f4ee4e09147ef5703b85a10238ddb6cdefdf05a5
2019-10-11 04:46:16 -07:00
Ashok Menon df96de78bb Back out D17720575 -- D17724498
Summary: This stack caused FB4A builds to start failing, complaining about `RCTImageApple`.

Reviewed By: RSNara

Differential Revision: D17855088

fbshipit-source-id: 21ecedc3725dde65fab20f414d07b32c3548447c
2019-10-10 09:41:33 -07:00
Valentin Shergin 38e36b7049 Storing RCTBridge weakly inside ContextContainer
Summary: Storing a Bridge introducing an retain cycle, so we need to store that weakly.

Reviewed By: sammy-SC

Differential Revision: D17773698

fbshipit-source-id: 824a83a6086f9ae6efb7c458d833931954c55643
2019-10-09 13:17:42 -07:00
Mehdi Mulani c30f895da5 Allow enabling RCTDevSettings outside of dev mode
Summary: This make RCTDevSettings configurable like RCTRedBox.

Reviewed By: RSNara

Differential Revision: D17798517

fbshipit-source-id: 3717e0aed27b2a6951b402641f589d472f45243e
2019-10-09 12:55:22 -07:00
Ramanpreet Nara 7eb7c84a09 Make RCTAsyncLocalStorage TurboModule-compatible
Summary: See title.

Reviewed By: PeteTheHeat

Differential Revision: D17724498

fbshipit-source-id: 738fdd1e4db3b435029b8300d426cca1242c1587
2019-10-09 12:34:00 -07:00
Ramanpreet Nara 60321a78ad Make RCTAlertManager TurboModule-compatible
Summary: See title.

Reviewed By: PeteTheHeat

Differential Revision: D17722913

fbshipit-source-id: cb78b9ea1bf497d27b19255e48809850e698ba0d
2019-10-09 12:34:00 -07:00
Ramanpreet Nara 3aa8a40659 Move RCTImage NativeModules back to RCTImage
Summary: In D16805827, I moved `RCTImageLoader`, `RCTImageStoreManager`, and `RCTImageEditingManager` to `CoreModules`. This was necessary to turn `RCTImageLoader` into a TurboModule. However, after D17671288 landed, it's no longer necessary to have OSS NativeModules in `CoreModules`. Therefore, I'm moving these NativeModules back to `RCTImage`.

Reviewed By: PeteTheHeat

Differential Revision: D17720575

fbshipit-source-id: 44b07cfa07cbb2b87254132810f86974edc7edab
2019-10-09 12:33:59 -07:00
Mehdi Mulani 2a3fa968b4 Revert D17793693: [RN] Add debug message to RCTShadowView when we insert a subview incorrectly
Differential Revision:
D17793693

Original commit changeset: 848ae658200e

fbshipit-source-id: e59299f596f95e2bea978b07cd7e8f1de345708a
2019-10-09 12:15:13 -07:00
Samuel Susla 1bf2f72abe Add support for commands
Summary: We need commands to work with `LegacyViewManagerInterop`. We will need to rethink this once Fabric has command-execution pipeline in place.

Reviewed By: shergin

Differential Revision: D17787294

fbshipit-source-id: a6b3dbfae41f04e7e7f5bafb1f7b4ad0de0eedc3
2019-10-08 09:05:16 -07:00
Samuel Susla 5dbd62c7ff Add support for events
Summary:
LegacyViewManagerInterop layer can now handle events as well.

We expose `eventInterceptor` from `NSComponentData`, that way we can hook into event dispatching that happens within `NSComponentData`.

Coordinator has a map of `UIView -> reactTag` which it uses to figure out to which component view to forward the event.

New `LegacyViewManagerInteropViewEventEmitter` exposes APIs to send `folly::dynamic` to javascript.

Reviewed By: shergin

Differential Revision: D17765834

fbshipit-source-id: 25e75e445b32c69ec9ab0189c4ab7fba5f8c7b5d
2019-10-08 09:05:15 -07:00
Mehdi Mulani 0a98be65e3 Try to lazily load RCTRedBox
Summary: I made a mistake earlier and somehow prevented RCTRedBox showing up. Not sure why this didn't prevent them from showing up in dev mode.

Reviewed By: RSNara

Differential Revision: D17798516

fbshipit-source-id: 48bf0523124ad3fd96d626281390bbafc62f3390
2019-10-08 07:38:17 -07:00
Ramanpreet Nara 021a63d4da Ensure internal builds don't use plugin stubs
Summary: We generate a stub for plugin system, so that TurboModules can work in OSS. Unless the `RN_DISABLE_OSS_PLUGIN_HEADER` define is seet, TurboModules will use the plugin stub. Therefore, for internal builds, we should set this define.

Reviewed By: fkgozali, mdvacca

Differential Revision: D17789993

fbshipit-source-id: a93735738513457236adb3064b80601053c95dd3
2019-10-07 14:55:39 -07:00
Mehdi Mulani 72c03900d2 Add debug message to RCTShadowView when we insert a subview incorrectly
Summary:
@public
This will provide a more useful error message and hopefully allow us to debug the issue further.

Reviewed By: JoshuaGross

Differential Revision: D17793693

fbshipit-source-id: 848ae658200ea5e3892d8a88888599c1c248c994
2019-10-07 13:37:53 -07:00
Rick Hanlon c71bbb0057 Report logs in dev to server on iOS
Summary:
This diff adds server side logging for all log levels in development (some levels sampled)

There are two new mobile analytic event pipelines (that pipe to scuba table)

- rn_dev_logs ([pigeon](https://our.intern.facebook.com/intern/marauder/event/?name=rn_dev_logs) [scuba](https://fburl.com/scuba/pqxl6mf5))
- rn_dev_logs_sampled ([pigeon](https://our.intern.facebook.com/intern/marauder/event/?name=rn_dev_logs_sampled) [scuba](https://fburl.com/scuba/oqz6b5x3))

Notes:
- All React Native logs from JS and Native on iOS go through this path to be printed to the console, so everything will be caputured even though native errors/warnings do not necessarily show a red/yellow box
- All errors and warnings are logged
- Log level info is sampled

Reviewed By: sammy-SC

Differential Revision: D17789494

fbshipit-source-id: dea6359237dbd91f267949f5185a0c79bb4083b8
2019-10-07 11:44:11 -07:00
Samuel Susla f580409919 Add command to set date on RCTDatePickerManager
Summary: We are moving away from setNativeProps, this adds necessary method on native to leverage commands API

Reviewed By: shergin

Differential Revision: D17787877

fbshipit-source-id: 8f06cdd85c96bce4ea9bb7a8cd5f6c1a1d68b20a
2019-10-07 10:36:37 -07:00
Samuel Susla 62cbdceedd Implement setNativeSelectedIndex command for Picker component
Summary:
This is required so we can switch to using commands instead of `setNativeProps`.
`setNativeProps` are not supported in Fabric, we are moving away from it.

Reviewed By: JoshuaGross

Differential Revision: D17764967

fbshipit-source-id: 16e54ebe1f0c58b80a6491db970a60c01fec8a15
2019-10-07 04:24:08 -07:00
Samuel Susla 07fd3125c8 Migrate MVP SafeAreaView to Fabric
Reviewed By: shergin

Differential Revision: D17736209

fbshipit-source-id: e70c309f2599cdcb8f234d96915546032b71d223
2019-10-04 07:07:36 -07:00
Adam Ernst a45e6a8b5f React Native supermodule
Summary: #nocancel

Reviewed By: fkgozali

Differential Revision: D17747685

fbshipit-source-id: 9bad072d3549959528612c2f0329799853d4b675
2019-10-03 15:43:38 -07:00
Ramanpreet Nara d7864d20d5 Mark plugin function definitions used
Summary: We need to mark the OSS plugin functions with `__attribute__((used))`, so that the compiler doesn't strip them out.

Reviewed By: fkgozali

Differential Revision: D17742818

fbshipit-source-id: df8055286cace850cea21bb6f09eb5ee6b587c0e
2019-10-03 13:06:06 -07:00
Samuel Susla e62a4c7988 Apply props to Paper component
Reviewed By: shergin

Differential Revision: D17710855

fbshipit-source-id: ab6864a22fd8df019b2619c2976876e176e07689
2019-10-03 08:37:29 -07:00
Samuel Susla 3f8221ddd9 Add coordinator class
Summary:
ComponentDescriptor owns a coordinator which is initialised with ViewManager that it represents.

Coordinator is passed to ComponentView through state and ComponentView asks the coordinator for view.

Later, ComponentView will ask coordinator to configure view with specified props.

Reviewed By: shergin

Differential Revision: D17670444

fbshipit-source-id: e920c5c4f033884c4b539ce711286f71c887d896
2019-10-03 08:37:29 -07:00
Samuel Susla 74608ee4ab Stage 1: printing props to screen
Summary:
# LegacyViewManagerInterop is born

LegacyViewManagerInterop is a component that should make it possible for legacy components to work in Fabric, new renderer.
This is just a first stage that prints keys of props to screen together with component name.

Reviewed By: shergin

Differential Revision: D17552827

fbshipit-source-id: c3e062f413727729e6a9b683c60f59f0292cc63b
2019-10-03 08:37:28 -07:00
Samuel Susla a261e6dfb2 Fix recycling of Switch
Reviewed By: shergin

Differential Revision: D17714863

fbshipit-source-id: 8a90a08328f007c782689b4e711d252bd2e22538
2019-10-03 03:59:47 -07:00
Samuel Susla eb08b428b6 Add setValue command to RCTSwitchManager
Reviewed By: shergin

Differential Revision: D17714133

fbshipit-source-id: ccb89be1b763678f44f1271e4d5882afd37ccf65
2019-10-03 03:59:47 -07:00
Mehdi Mulani 12d60c1049 iOS: Allow redbox to be toggled in debug builds
Summary: This adds the option to enable or disable the redbox.

Reviewed By: JoshuaGross

Differential Revision: D17720770

fbshipit-source-id: b9e9c948d53f7f284a48b6bd182dc2da47874d1c
2019-10-02 14:43:32 -07:00
Mehdi Mulani 7da85ef4cc iOS: Change RCTLog red box behaviour to a runtime check
Summary:
This changes RCTLog to look for RCTRedBox at runtime and if so, send a log message to it.
This allows people to add their own redbox customizations that could be present at non-debug time.

Reviewed By: PeteTheHeat

Differential Revision: D17718913

fbshipit-source-id: e4545e112af2ff2ad197a0a82551ae4c6911ece9
2019-10-02 14:43:32 -07:00
Luna Wei ea1e8bbd34 Add queryCache to ImageLoader native module
Summary:
[iOS] [Added] - Add definition for `queryCache` in ImageLoader

This diff is related to moving RCTImageViewManager's commands to a native module, ImageLoader.

Reviewed By: zackargyle, TheSavior

Differential Revision: D17714521

fbshipit-source-id: 722cc17a2ebb03e72d7c080dfc4d0aa6d7440e85
2019-10-02 14:05:12 -07:00
Luna Wei 40667a8147 Add prefetchImage to ImageLoader native module
Summary:
[iOS] [Added] - Add `prefetchImage` to ImageLoader native module.

This diff is related to moving RCTImageViewManager's commands to a native module, ImageLoader.

Reviewed By: zackargyle, TheSavior

Differential Revision: D17714519

fbshipit-source-id: 0a50f640cf0c5668a11dd5d40553c257ebbd9d2b
2019-10-02 14:05:12 -07:00
Luna Wei db20260b03 Add getSizeWithHeaders to ImageLoader turbomodule
Summary:
Define getSizeWithHeaders in ImageLoader native module.

This diff is related to moving RCTImageViewManager's commands to a native module, ImageLoader.
See it's usage here: D17704091

Reviewed By: TheSavior

Differential Revision: D17693907

fbshipit-source-id: 3c2d7b19ac68ead831e780c4ee23e3ed0643be3a
2019-10-02 14:05:12 -07:00
Ramanpreet Nara de20eb7e11 Refactor RCTActionSheetManager to use RCTConvertVecToArray and RCTConvertOptionalVecToArray
Summary: Previously, I introduced methods to convert `facebook::react::LazyVector<T>` to `NSArray*`, but I realized that there are already methods available in `RCTConvertHelpers` that do this for us. So, I'm switching over to using those methods instead.

Reviewed By: fkgozali

Differential Revision: D17716914

fbshipit-source-id: e1ef7636e36b594bc558d7025573082bd2bccab9
2019-10-02 11:06:40 -07:00
Ramanpreet Nara 1d7de28379 Make update-plugins.js script support multiple libraries
Summary:
Some NativeModules belong to their own buck target (separate from `ReactInternal`). We shouldn't move those NativeModules to `CoreModuels`, because that would unnecessarily bloat `CoreModules`.

In this diff, I extended the `update-plugins.js` script to also generate plugin stubs for those additional targets. This way, we can convert those NativeModules to TurboModules without moving them to CoreModules.

Now, in `update-plugins.js`, we have this array:

```
const libraries = [
  {
    name: 'CoreModules',
    outputFiles: {
      ios: ['CoreModulesPlugins.h', 'CoreModulesPlugins.mm'],
      android: [],
    },
    outputPath: {
      ios: `${GITHUB_DIR}/React/CoreModules`,
      android: '',
    },
  },
];
```

To codegen another pair of plugin files for another target, simply insert to this array.

**Note:** We'll have to modify RNTesterTurboModuleProvider, but I can take care of that when I setup RNTester for TurboModules.

Reviewed By: fkgozali

Differential Revision: D17671288

fbshipit-source-id: 412d2e730682f82740241506f241dcfb4d302e99
2019-10-01 11:15:08 -07:00
Ramanpreet Nara 101125f891 Make RCTActionSheetManager TurboModule-compatible
Summary: RCTActionSheetManager is now hooked up to the NativeModule codegen. It's also TurboModule-compatible.

Reviewed By: PeteTheHeat

Differential Revision: D16966007

fbshipit-source-id: 8fdd32cf9fa09ccda9f38513bb0ac9896f8af1b0
2019-09-30 14:32:21 -07:00
Rick Hanlon d0324f693c Move reason to a constant
Summary: Moves the reason to a constant because APPARENTLY this is a best practice in this establishment

Reviewed By: sammy-SC

Differential Revision: D17627819

fbshipit-source-id: 328fad8b7482d0e379a41b5f8c841f71db2bb5ac
2019-09-30 07:03:51 -07:00
Rick Hanlon 2d95668aa8 Add fastRefresh to NativeDevSettings
Summary: This diff adds a method to call whenever a fast refresh happens. Right now this is only useful for reporting.

Reviewed By: cpojer

Differential Revision: D17528033

fbshipit-source-id: 17e82abe7a3e2bab6829de5adecda853fe5335c5
2019-09-30 07:03:51 -07:00
Rick Hanlon 2ccc8fbc28 Add and use reloadWithReason to iOS
Summary:
This diff adds a new reloading method reloadWithReason that allows callers to provide a reason for why a reload was requested.

This reason is useful for understanding why users are reloading, and why Fast Refresh is bailing out to a full reload. I also updated the places we reload with the reasons listed below.

**Standard native reasons:**
- Redbox
- Command
- Global hotkey
- Profiling controls
- Dev menu - reload
- Dev menu - reset to default
- Dev menu - apply changes

**From JavaScript (added in a later diff):**
- Fast Refresh - Unrecoverable
- Fast Refresh - No root boundary
- Fast Refresh - Invalidated boundary
- Fast Refresh - Invalidated root boundary

**Misc reasons and fallback for when a reason is unavailable:**
- Unknown from JS
- Uncategorized from JS
- Unknown from bridge
- Unknown from cxx bridge
- Requested from bridge
- Custom executor class reset

Reviewed By: cpojer

Differential Revision: D17499339

fbshipit-source-id: 12a21ffa05708c9b921d93911f190cdffc5c78d5
2019-09-30 07:03:50 -07:00
Samuel Susla 3f9af02bd5 Call _state.reset in prepareForRecycle
Summary: `_state` should be cleaned up in `prepareForRecycle` as this could potentially cause undesired initial render of the component.

Reviewed By: shergin

Differential Revision: D17628152

fbshipit-source-id: 0116954ab7a5b2f17099db6d9ec47c8568cae8b0
2019-09-30 04:47:25 -07:00
Marc Mulcahy c7aa6dc827 Add onSlidingComplete callbacks when sliders adjusted via a11y (#26600)
Summary:
When sliders are adjusted via accessibility, no onSlidingComplete callback is
generated. This causes problems for components which perform behavior in this
callback, and means that such components don't behave properly when adjusted via
accessibility. For example, if an app hosting a volume control slider only commits the volume change to the hardware on onSlidingComplete, it is impossible for a screen reader user to ever actually adjust the volume.

Ensure that sliders call the onSlidingComplete callback after adjusted via
accessibility.

## Changelog

[General] [Fix] - Add onSlidingComplete callbacks when sliders adjusted via a11y.

[CATEGORY] [TYPE] - Message
Pull Request resolved: https://github.com/facebook/react-native/pull/26600

Test Plan: Prior to this change, using the RNTester slider example with a screen reader, the onSlidingComplete callback tests never shows any callbacks when the slider is adjusted. With this change applied, the callback test will show a number of callbacks corresponding to the number of times the slider was adjusted via the screen reader.

Differential Revision: D17661157

Pulled By: cpojer

fbshipit-source-id: a6eedef099c6c1b571b290c329059ac9b69b53dd
2019-09-29 19:45:06 -07:00
Valentin Shergin ba8b6a77a6 Fabric: Checking an EventEmitter before calling in RCTModalHostViewComponentView
Summary: We need to check if `_eventEmitter` is not nullptr before each call on it.

Reviewed By: sammy-SC

Differential Revision: D17531070

fbshipit-source-id: e9b5608845c10c7c2ef38f43c8deb67dad10fb6f
2019-09-28 15:10:27 -07:00
Valentin Shergin a35a3ec157 Fabric: Fixing a crash in ScrollView on deallocation
Summary:
Seems a ScrollView sometimes calls the delegate in own destructor; and seems that in some configurations the delegate is also already destroyed at this point. I am not sure if this a bug in UIKit or not, but seems the fix is easy, we just have to clear the ScrollView's delegate on the delegate's deallocation.
This issue is also looks similar:
https://stackoverflow.com/questions/18778691/crash-on-exc-breakpoint-scroll-view/19011871

Reviewed By: sammy-SC

Differential Revision: D17531071

fbshipit-source-id: 373ae5270199f3a9099bda8c34b06737446858f1
2019-09-28 15:10:26 -07:00
Luna Wei 06d3031281 Native changes for ImageLoader native module
Summary:
Split changes from D17587836
Native changes for ImageLoader native module

Reviewed By: TheSavior

Differential Revision: D17607364

fbshipit-source-id: 451e24d4cf3c982b64bd6196addacef4cb967d1b
2019-09-26 17:37:38 -07:00
Peter Argany a6a6dbe05c Split up createTimer into two methods, createTimer and createTimerForNextFrame
Summary:
This diff adds nuance to timer creation.  Imagine the following bit of JS:

```
    setTimeout(() => {
      console.log("Timeout")
    }, 0);
    setImmediate(() => {
      setNine("Immediate");
    });
```

In classic RN, `setTimeout` will be called async by the bridge, immediate is implemented in JS, so the ordering of logs will be:

1. Immediate
2. Timeout

In bridgeless RN `setTimeout` is called sync, so the ordering of the logs is:

1. Timeout
2. Immediate

In order to preserve ordering, this diff adds a timer creation method which doesn't immediately invoke it, but waits one frame to do so.

This PR does the same thing for android, and explains the reasoning for preserving behaviour (some products may rely on this behaviour) f054928124

Reviewed By: ejanzer

Differential Revision: D17535639

fbshipit-source-id: 3f734c420a6a95be2ee10e8d6ac48adc79ef1c96
2019-09-25 15:31:26 -07:00
Valentin Shergin 3bc09892c0 Fabric: Enforcing const-correctness around ImageResponseObserverCoordinator
Summary:
`addObserver` and `removeObserver` now accepts const references instead of pointers which indicates the intent (non-nullability and non-owning) clearly. The delegate methods are also marked as `const` to designate the possible concurrent execution (`const` means "thread-safe" here).

All changes are pure syntactical, nothing really changes (besides the fact overall code quality and redability).

Reviewed By: JoshuaGross

Differential Revision: D17535395

fbshipit-source-id: b0c6c872d44fee22e38fd067ccd3320e7231c94a
2019-09-23 15:59:45 -07:00
Ramanpreet Nara f5ab719445 Make RCTClipboard, RCTI18nManager, and RCTSourceCode TurboModule-compatible
Summary: These NativeModules were easy to convert, since no other NativeModules in `React/Modules` depend on them.

Reviewed By: PeteTheHeat

Differential Revision: D16817959

fbshipit-source-id: 1036c2d437e1275776a185bf68c450c6454985df
2019-09-23 15:25:30 -07:00
Oleksandr Padalko 034a7d185f Add new method jsBundleURLForBundleRoot with fallback block to RCTBundleURLProvider
Reviewed By: julian-krzeminski

Differential Revision: D17336324

fbshipit-source-id: b14a08d940ec7594978d3e34f1e833f65d3bd411
2019-09-23 09:26:59 -07:00
Samuel Susla 85575dd8e5 Small adjustment in order of operations in RCTImageComponentView
Summary: Small adjustment to order of operations. In case eventEmitter is nil, we still want to set image to nil.

Reviewed By: shergin

Differential Revision: D17503570

fbshipit-source-id: fd013c60e1188bcf63ff28ff7aad814582a3ae34
2019-09-23 02:50:55 -07:00
Peter Argany 5a81a204c1 Enable setTimeout [4/N]
Summary: The OSS change in this diff allows `RCTDisplayLink` to call out to an observer, even if the `RCTModuleData` isn't well formed. This is the case in bridgeless RN.

Reviewed By: ejanzer

Differential Revision: D17438647

fbshipit-source-id: 00d4d61d9126902180a7a77fc702f4221cf4d779
2019-09-20 18:28:39 -07:00
Peter Argany 3fd920583b Enable metro
Summary: The OSS file touched in this diff is just a styling change.

Reviewed By: ejanzer

Differential Revision: D17400387

fbshipit-source-id: e51884d8942ba01e7da1662ac24429070e53a504
2019-09-20 18:28:38 -07:00
Peter Argany 33e65c6fd4 Create a new Timers class to reuse old RCTTiming Native Module [2/N]
Summary:
Similar to Android Venice impl, I plan to reuse old Timing native module because it's quite complex, and there's not much to gain from re-writing it. When we delete bridge access from it, we can remove any cruft, but IMO it's quite lean already.

The name of this class is a little confusing IMO, I originally had it because it was similar to `Timers.java` but then Emily renamed :p Here's the architecture drawn out:

{F209114665}

If anyone has a better name I'm all ears.

Reviewed By: RSNara

Differential Revision: D17376028

fbshipit-source-id: 066ae0b379cd00538021a1327a4dd63d5a828608
2019-09-20 18:28:38 -07:00
Peter Argany 77c9c95840 Refactor RCTTiming to work without the bridge [1/N]
Summary:
Instead of relying on the bridge to do module setup, allow for regular initialization.

Instead of relying on the bridge to execute timers, allow for a delegate to do the work.

Reviewed By: RSNara

Differential Revision: D17375924

fbshipit-source-id: 83adabf8c962a5d90a4ea623618903cd9fb79a99
2019-09-20 18:28:38 -07:00
Ramanpreet Nara 4c998fd05d Rename JSCallInvoker{,Holder} to CallInvoker{,Holder}
Summary:
## Motivation
The concept behind JSCallInvoker doesn't necessarily have to apply only to the JS thread. On Android, we need to re-use this abstraction to allow execution of async method calls on the NativeModules thread.

Reviewed By: PeteTheHeat

Differential Revision: D17377313

fbshipit-source-id: 3d9075cbfce0b908d800a366947cfd16a3013d1c
2019-09-20 10:52:56 -07:00
Marc Mulcahy 7df3eea1a7 Add accessibilityValueDescription support. (#26169)
Summary:
React Native components need a mechanism to specify their value to assistive technologies. This PR adds the notion of accessibilityValueDescription-- a property which either contains a textual description of a component's value, or for range-based components, such as sliders and progress bars, it contains range information (minimum, current, and maximum).

On iOS, the range-based info if present is converted into a percentage and added to the accessibilityValue property of the UIView. If text is present as part of the accessibilityValueDescription, it is used instead of the range-based information.

On Android, any range-based information in accessibilityValueDescription is exposed in the AccessibilityNodeInfo's RangeInfo. Text which is part of accessibilityValueDescription is appended to the content description.

## Changelog

[GENERAL] [Change] - add accessibilityValuedescription property.
Pull Request resolved: https://github.com/facebook/react-native/pull/26169

Test Plan: Added two new accessibility examples to RNTester, one which uses text and another which uses range-based info in accessibilityValueDescription. Verified that they both behave correctly on both Android and iOS.

Differential Revision: D17444730

Pulled By: cpojer

fbshipit-source-id: 1fb3252a90f88f7cafe1cbf7db08c03f14cc2321
2019-09-18 03:16:42 -07:00
Janic Duplessis cc068b0551 Export the DevSettings module, add `addMenuItem` method (#25848)
Summary:
I wanted to configure the RN dev menu without having to write native code. This is pretty useful in a greenfield app since it avoids having to write a custom native module for both platforms (and might enable the feature for expo too).

This ended up a bit more involved than planned since callbacks can only be called once. I needed to convert the `DevSettings` module to a `NativeEventEmitter` and use events when buttons are clicked. This means creating a JS wrapper for it. Currently it does not export all methods, they can be added in follow ups as needed.

## Changelog

[General] [Added] - Export the DevSettings module, add `addMenuItem` method
Pull Request resolved: https://github.com/facebook/react-native/pull/25848

Test Plan:
Tested in an app using the following code.

```js
if (__DEV__) {
 DevSettings.addMenuItem('Show Dev Screen', () => {
    dispatchNavigationAction(
      NavigationActions.navigate({
        routeName: 'dev',
      }),
    );
  });
}
```

Added an example in RN tester

![devmenu](https://user-images.githubusercontent.com/2677334/62000297-71624680-b0a1-11e9-8403-bc95c4747f0c.gif)

Differential Revision: D17394916

Pulled By: cpojer

fbshipit-source-id: f9d2c548b09821c594189d1436a27b97cf5a5737
2019-09-17 06:38:10 -07:00
Mehdi Mulani 8831cc6ac2 Combine rn_debug_flags and rn_feature_flags
Summary:
@public
Both of these are used for turning BUCK configs and build mode into compiler flags, so we should combine them to avoid confusion on where they are to be used.

Reviewed By: fkgozali

Differential Revision: D17262579

fbshipit-source-id: d145374fd619068f794018d79111720d30f6269c
2019-09-12 13:09:29 -07:00
zhongwuzw 607e258c6a Make surface presenter manage start of surface (#24372)
Summary:
1. Start surface when first run, before, when we first load js bundle, `_startAllSurfaces` would not be called because `bridge == _batchedBridge`.
2. I think this fixes https://github.com/facebook/react-native/issues/23910, so I add the `return` in swizzle method to check.

cc shergin.

## Changelog

[iOS] [Fixed] - Make surface presenter manage start of surface
Pull Request resolved: https://github.com/facebook/react-native/pull/24372

Test Plan: N/A.

Differential Revision: D17337865

Pulled By: shergin

fbshipit-source-id: 2a1e413c006cae74ef6ca4c2b6b5ee8a46434b7f
2019-09-11 21:27:51 -07:00
Valentin Shergin 9490ca66dd Fabric: Small simplification in UIView+ComponentViewProtocol
Summary: Now we use `std::isfinite` instead of a pair of `std::isnan` and `std::isinf` which improves readability.

Reviewed By: sammy-SC

Differential Revision: D17312174

fbshipit-source-id: 76175524de566745962e96e46effe0bce52a09ad
2019-09-11 18:29:22 -07:00
Valentin Shergin fc0b03a0d1 Fabric: Small perfromance optimization in `[RCTViewComponentView updateLayoutMetrics:oldLayoutMetrics:]`
Summary:
Before this change, we reapply all layout props for all newly mounted views (on `insert` instruction), now we use stored `_layoutMetrics` value to apply only changed subset.
This is only available for `RCTViewComponentView` subclasses (where we have an ability to store a previous value), all other implementation of `RCTComponentViewProtocol` will work as usual.

Reviewed By: JoshuaGross, sammy-SC

Differential Revision: D17312175

fbshipit-source-id: b202583c0c58987876d906b748ef3a749f8dad70
2019-09-11 18:29:22 -07:00
Samuel Susla c8ae58880d Migrate ARTSurfaceView to fabric
Summary:
Migrates ARTSurfaceView to Fabric,

This diff only migrates the necessary minimum for RCTVideo component to work. Other ART components are
ARTNode, ARTGroup, ARTRenderable, ARTShape and ARTText.

Reviewed By: mdvacca

Differential Revision: D17181298

fbshipit-source-id: c2656bbcaefde25e37a9e05a64d2691bc2343b67
2019-09-11 08:43:48 -07:00
gaodeng 796b3a1f88 iOS13 status bar has now 3 styles (#26294)
Summary:
iOS13 status bar has now 3 styles
UIStatusBarStyleDefault, UIStatusBarStyleLightContent, UIStatusBarStyleDarkContent

UIStatusBarStyleDefault now acts as an automatic style which will set it’s value dynamically based on the the userinterfacestyle(One of the traits) of the viewcontroller that controls the status bar appearance.

## Changelog

[iOS] [Fixed] - iOS13 new status bar style UIStatusBarStyleDarkContent
Pull Request resolved: https://github.com/facebook/react-native/pull/26294

Differential Revision: D17314054

Pulled By: cpojer

fbshipit-source-id: ea109e729bb551dff314bc00a056860a8febb0e9
2019-09-11 05:13:01 -07:00
Alec Larson 021cbccbf2 fix: use proper timestamp in frameElapsed calculation (#26114)
Summary:
Fix a bug where `CACurrentMediaTime` was being used to calculate the elapsed frame time, even though it's not comparable to `NSDate.timeIntervalSince1970` time.

## Changelog

[iOS] [Fixed] - callIdleCallbacks deadline calculation
Pull Request resolved: https://github.com/facebook/react-native/pull/26114

Test Plan: None

Differential Revision: D17314125

Pulled By: cpojer

fbshipit-source-id: 5061a3954371df2134f0c77dc260228668abe747
2019-09-11 04:54:21 -07:00
Valentin Shergin 83f8d13a99 Fabric: Explicit Scheduler creation and destruction management in RCTSurfacePresenter
Summary: Previously, the `_scheduler` method in `RCTSurfacePresenter` was implemented as a lazy getter. The only problem with that is that Scheduler instance might be (re)created in the middle of the hot-reloading process (e.g. external request to relayout some Surface might trigger that). Since it does not make any sense to create an empty Scheduler during the reloading process, now the Scheduler creation only happens in constructor and right after the VM is reloaded.

Reviewed By: JoshuaGross

Differential Revision: D17299441

fbshipit-source-id: 273451bbb03e8cdf532131adfdf3bc60c34e997e
2019-09-10 21:33:42 -07:00
Moti Zilberman 9a57145f52 Implement RCTExceptionsManager.reportException on iOS
Summary: Implements the new `reportException` method in the iOS version of `ExceptionsManager`.

Reviewed By: sammy-SC

Differential Revision: D17226365

fbshipit-source-id: baa81424399175eaf8fc0835d4df01897e7fa468
2019-09-06 10:13:05 -07:00
Moti Zilberman 850a8352c9 Manage redbox updates by comparing exception IDs
Summary:
Refines the condition for ignoring updates to an already-open redbox on iOS.

Previously we would only update the stack trace if the message string in the update was exactly the same as in the initial redbox. With this diff we rely on the `exceptionId` parameter instead, and only fall back to string comparison if it's omitted (i.e. for non-JS uses of redbox on iOS).

NOTE: `exceptionId` is part of the existing ExceptionsManager API and is already supported on Android.

Reviewed By: sammy-SC

Differential Revision: D17226179

fbshipit-source-id: 5940110bf4e4358a8a1b3477e8d2cf8b224dd9f8
2019-09-06 10:13:05 -07:00
Christoph Nakazawa 90a8e3012c Remove live reloading option from RN iOS
Summary: See previous diff in this stack

Reviewed By: motiz88

Differential Revision: D17156649

fbshipit-source-id: 12bdba248481258b9c6ca001472a41ca19fb4b6f
2019-09-06 03:48:49 -07:00