Summary: All integration with Bridge was removed from RCTFabricSurface, now it's Surface's responsibility to start and stop JS app and register the ShadowTree in the Scheduler.
Reviewed By: mdvacca
Differential Revision: D9931317
fbshipit-source-id: 55a682f0afb1c542a904e1a8570029e4690967cc
Summary:
RCT_DEBUG is always defined - it is just rather 0 or 1 so
```#ifndef RCT_DEBUG is always true```
Pull Request resolved: https://github.com/facebook/react-native/pull/21232
Differential Revision: D9982316
Pulled By: hramos
fbshipit-source-id: 5408bfcf95a6ed2beae38217a6ad1ee43950857d
Summary: WKWebViews aren't available on Apple TV. When I landed [the WKWebView stack](https://our.intern.facebook.com/intern/diff/D9362001/), I inadvertently broke the RNTester osTV build. This diff fixes it.
Reviewed By: shergin
Differential Revision: D9844322
fbshipit-source-id: 6de0fbfd13aba38cca7530c9fb486c7cde0afc82
Summary: This change drops the year from the copyright headers and the LICENSE file.
Reviewed By: yungsters
Differential Revision: D9727774
fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
Summary:
Instead of asking existing modules to implement `+allowJSIBinding`, introduce a temporary "empty" protocol so modules can just adopt it for migration purpose.
Eventually this protocol may just go away.
Modules need to adopt both `RCTBridgeModule` and `RCTJSINativeModule` for time being for backward compatibility.
p.s. the entire system isn't enabled yet, this is just some of the pre-reqs for NativeModule improvements.
Reviewed By: mmmulani
Differential Revision: D9762913
fbshipit-source-id: 470f640f11a5991e5cfa9c48a1931da660ebfcd2
Summary:
To be able to test out new approach for NativeModules, introduce a simple runtime flag to enable the new system (doesn't exist yet). In addition, each module should declare a static `+ (BOOL)allowJSIBinding` in the objc class to be considered for the new approach. Doing so skips the processing of the module during bridge startup.
Note: this doesn't do anything special for `- (NSArray *)extraModulesForBridge:(RCTBridge *)bridge` impl yet.
Differential Revision: D9554296
fbshipit-source-id: 3508db6589e9f72367f62aa7ca15fce3d3adda72
Summary:
[RFC] WIP: Way to register RCT_MODULE in Plugin2.0 instead of +load
This seemed like the simplest way to do this to register in the existing
didNotFindModule callback so that we don't have to touch any opensource code.
NOTE: The new version of this fixes the problems with dylibs, but not the -ObjC flag removal. This seems like the right call to avoid users having to implement c-functions to return their classes; instead we used objc_getClass.
Reviewed By: dshahidehpour
Differential Revision: D9112719
fbshipit-source-id: cf8df97d7c443cafa0e06a1e61bdf2612944ed87
Summary:
@public
We can't dynamically link `WebKit` because doing so will impact cold start of all our Apps.
This diff includes a few changes:
1. Weakly link the `WebKit` framework in the `ReactInternal` library, so that the compiler doesn't die when it encounters a WebKit symbol.
2. Undo dynamic linking of WebKit in Catalyst.
3. Undo dynamic linking of WebKit in AdsManager
4. Before the first `WKWebView` is instantiated, dynamically load the `WebKit` framework.
The end result of these changes is that WebKit will be loaded only when it's going to be used.
Reviewed By: mmmulani
Differential Revision: D6564328
fbshipit-source-id: a45a44e774d0c61c1fb578a6fa3d16bb08f68ac9
Summary:
When text is rendered in `WKWebView` WebKit component, the component itself can detect things like phone numbers, flight numbers, links, etc. and render them with additional functionality.
For example, when the text `apple.com` is detected, if the `link` data detector type is enabled, the web view will actually render a link that takes the user to the Apple home page.
In this diff, I implement the `dataDetectorTypes` prop. The data detector types supported are:
1. phoneNumber
1. link
1. address
1. calendarEvent
1. trackingNumber
1. flightNumber
1. lookupSuggestion
These enums are documented in the [[ https://developer.apple.com/documentation/webkit/wkdatadetectortypes | WKDataDetectorTypes docs ]].
Reviewed By: shergin
Differential Revision: D6392546
fbshipit-source-id: 4dd373f0ac52f898163cd959eeef6672e55b42a6
Summary:
@public
I'm surprised this hasn't caused an issue earlier.
RCTTouchHandler is hooked up to RCTSurfaceView which itself contains a rootView. Thus when this calculation happens, a root view is never found.
We can't assign to the root view since it created and destroyed frequently, so it makes the most sense to look for the RCTSurfaceView here and treat it as a root view.
Reviewed By: fkgozali
Differential Revision: D9296840
fbshipit-source-id: ba5320583201f9d5c0176847cc6e6087b6a6459b
Summary:
Calls abort() in cases where malloc returns NULL.
Checking the return value from malloc is good practice and is
required to pass a [Veracode security scan](https://www.veracode.com/). This will let
developers who are required to submit their software to Veracode
use React Native.
Pull Request resolved: https://github.com/facebook/react-native/pull/20173
Differential Revision: D9235096
Pulled By: hramos
fbshipit-source-id: 9fdc97f9e84f8d4d91ae59242093907f7a81d286
Summary:
@public
We are moving away from using `RCTBridge` instance in public APIs to enable us using more performance solutions in the future.
This change also fixes "SwipeBack issue" caused by RCTSurfaceHostingProxyRootView returning nil bridge.
Reviewed By: mdvacca
Differential Revision: D9094625
fbshipit-source-id: 6bde3c54773e75ca4c0b6fd908da9d7235b5c3be
Summary: This fixes an error that shows up when building with Xcode 10 beta 5.
Reviewed By: fkgozali, dinhviethoa
Differential Revision: D9086574
fbshipit-source-id: 1d70049eafd20a85d482dca101980c71935d838e
Summary: This array can be modified while it's being iterated, so we need to take a copy. I also found another crash and guarded against it.
Reviewed By: fkgozali
Differential Revision: D8955708
fbshipit-source-id: 76250bc5d451776e74505733c0f3c14e555fb576
Summary:
<!--
Required: Write your motivation here.
If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
-->
On a relatively stock / default setup of RN on iOS you'll see the warning "Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?" pop up on every launch. This change resolves that issue.
Fixes#14806 .
This supersedes PR #19794 .
Try a fresh project by following the RN iOS tutorial, and observe that there are no more warnings after making this change.
[IOS] [MINOR] [CxxBridge] - Fix "Class RCTCxxModule was not exported"
Closes https://github.com/facebook/react-native/pull/19880
Differential Revision: D8653809
Pulled By: hramos
fbshipit-source-id: c48529c2d74ddd40a90bc0e06e405078e25b72e3
Summary:
All public header files can be included from Obj-C and Swift, except RCTSurfaceSizeMeasureMode.h which contains C++ code.
Change is trivial and can be validated by review.
None.
[IOS][BUGFIX][{RCTSurfaceSizeMeasureMode.h}] - fix use of C++ syntax in an header file that could be included from Obj-C and Swift
Closes https://github.com/facebook/react-native/pull/18730
Differential Revision: D7550290
Pulled By: shergin
fbshipit-source-id: 3835e2c57697a067ff94afdaeaca06bce132ef66
Summary: Callback blocks are frequently held onto by modules, e.g. for animation the `RCTFrameAnimation` holds onto its callback method. This causes a bunch of retain cycles since the module will be strongly held onto by the bridge.
Reviewed By: Megra
Differential Revision: D7492136
fbshipit-source-id: 708e61ffe7bf0dcffaebc056ab861b9023ffc1df
Summary:
The base class already implements `intrinsicContentSize` (and it's a bit more complicated that that).
(Not sure if this change anything visible.)
Reviewed By: fkgozali
Differential Revision: D7343567
fbshipit-source-id: 86f86715b0dacc3c2230289a13926f0520540089
Summary: The RCTRootView default needs to be translated during init of RCTSurfaceHostingView correctly.
Reviewed By: shergin
Differential Revision: D7327918
fbshipit-source-id: 67a2a42b554782b37a032cc0470d794554cc1e5a
Summary: It is sometimes useful to report soft/fatal errors from C++ (native) to the same RCTExceptionsManager that is already handling JS exceptions. `ICxxExceptionManager` is an approach to provide such access, which impl provided for ObjC++.
Reviewed By: shergin
Differential Revision: D7224944
fbshipit-source-id: 8c607226b67851d46f4c787f5b6e6c8cb6a1afea
Summary:
Clarifies how to get a reference to RCTBridge from a Swift RCTBridgeModule.
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.
You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html
Happy contributing!
-->
In writing native modules for Swift, I have run into issues where the documentation applies only to Objective-C and does not supply adequate information for how one might accomplish something in Swift.
This is a good example, where the `synthesize` method simply does not apply to Swift code.
[IOS][ENHANCEMENT][Base/RCTBridgeModule.h] Add documentation for Swift usage.
<!--
Help reviewers and the release process by writing your own release notes
**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**
CATEGORY
[----------] TYPE
[ CLI ] [-------------] LOCATION
[ DOCS ] [ BREAKING ] [-------------]
[ GENERAL ] [ BUGFIX ] [-{Component}-]
[ INTERNAL ] [ ENHANCEMENT ] [ {File} ]
[ IOS ] [ FEATURE ] [ {Directory} ] |-----------|
[ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} |
[----------] [-------------] [-------------] |-----------|
[CATEGORY] [TYPE] [LOCATION] - MESSAGE
EXAMPLES:
[IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
[ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
[CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
[DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
[GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
[INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Closes https://github.com/facebook/react-native/pull/18231
Differential Revision: D7262850
Pulled By: hramos
fbshipit-source-id: c6babb3edd786be8571eb49258d594f2fb99141d
Summary:
There are a few important states that didn't reset correctly when reloading JS:
* the RCTSurfaceStage was stuck at all bits enabled, hence no further stage change happened (even though the state "reset" to `RCTSurfaceStageBridgeDidLoad`)
* the RCTSurfaceView didn't get recreated, because the _view ivar was never cleared
* similarly, the _touchHandler ivar attached to the _view was never re-setup --> all touches after JS reload were dropped before this diff
Reviewed By: mmmulani
Differential Revision: D7178038
fbshipit-source-id: ba49bc205f8bf43842471b7ab748cef8549ea212
Summary: When reloading JS during development, surface needs to make sure the root view gets re-registered before attempting to remount it. This fixes redbox on JS reload.
Reviewed By: shergin
Differential Revision: D7170416
fbshipit-source-id: c84b999d2cdc35cb9e26feef2a1e1a7ce35cfa70
Summary:
`RCTJavaScriptWillStartLoadingNotification` is being posted when starting the bridge, not when starting to execute JS code.
Here, we add `RCTJavaScriptWillStartExecutingNotification`, and in post it before executing JS with `RCTCxxBridge`.
Reviewed By: fromcelticpark
Differential Revision: D7153659
fbshipit-source-id: 902075308d54a47bef43b6f57edf2e624f621ceb
Summary:
To help with migration from direct usages of RCTRootView to RCTSurfaceHostingView, RCTSurfaceHostingProxyRootView is added, which is simply a custom impl of RCTSurfaceHostingView, but will all RCTRootView APIs preserved. This makes it easy to do a drop-in replacement in native callsites:
```
// before:
RCTRootView *rootView = [[RCTRootView alloc] init...];
// after:
RCTRootView *rootView = (RCTRootView *)[[RCTSurfaceHostingProxyRootView alloc] init...];
```
Reviewed By: shergin
Differential Revision: D7141696
fbshipit-source-id: db8c447749eaa896efaa37774a9babef132128eb
Summary:
Add RCTGetReactNativeVersion() to expose version in native code. Right now, version is exposed internally to RN using a MACRO constant. This exposes a symbol (function) that can be called to retrieve the React Native version in iOS.
Also exposed RCTVersion.h as a public header in the React project so it is available to developers.
The motivation behind this is for https://github.com/wix/detox —we need to know what RN version the user has, if any, so we can properly handle support and abstract differences.
Ran bump-oss-version.js to ensure the template is applied properly. Also compiled the project to make sure nothing is broken.
[IOS] [ENHANCEMENT] [RCTVersion.h] - Expose version as a compile-time symbol for native queries
<!--
Help reviewers and the release process by writing your own release notes
**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**
CATEGORY
[----------] TYPE
[ CLI ] [-------------] LOCATION
[ DOCS ] [ BREAKING ] [-------------]
[ GENERAL ] [ BUGFIX ] [-{Component}-]
[ INTERNAL ] [ ENHANCEMENT ] [ {File} ]
[ IOS ] [ FEATURE ] [ {Directory} ] |-----------|
[ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} |
[----------] [-------------] [-------------] |-----------|
[CATEGORY] [TYPE] [LOCATION] - MESSAGE
EXAMPLES:
[IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
[ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
[CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
[DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
[GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
[INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Closes https://github.com/facebook/react-native/pull/18136
Differential Revision: D7141076
Pulled By: hramos
fbshipit-source-id: 18a92b8c60d7b43fa0ed22597ea46a35cff73c56
Summary:
So, all initial operations can now be done synchronously (and on the main thread).
To do so, instancitate `RCTSurface` object and call `synchronouslyWaitForStage:timeout:` method like that:
RCTSurface *surface = [[RCTSurface alloc] initWithBridge:... moduleName:... initialProperties:...];
BOOL success = [surface synchronouslyWaitForStage:RCTSurfaceStageSurfaceDidInitialMounting timeout:timeout];
or
RCTSurfaceHostingView *surfaceHostingView = [[RCTSurfaceHostingView alloc] initWithBridge:... moduleName:... initialProperties:...];
BOOL success = [surfaceHostingView.surface synchronouslyWaitForStage:RCTSurfaceStageSurfaceDidInitialMounting timeout:timeout];
Reviewed By: fkgozali
Differential Revision: D7014178
fbshipit-source-id: c3c13904a3587ff2a222fa71623c40c8f30bc8af
Summary:
See the comment in code.
If we on the main thread on registering time, we can/will break sequentiality of registering and mounting processes doing registration asynchronously.
We need this to make sync mouting eventually possible.
Reviewed By: fkgozali
Differential Revision: D7014176
fbshipit-source-id: 110ad5e5d86e3422eac15c3b1bdb29ae04acd7e6
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.
find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.
Reviewed By: TheSavior, yungsters
Differential Revision: D7007050
fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
Summary:
This is reimagining of interoperability layer between Yoga and ShadowViews (at least in Yoga -> RN part).
Goals:
* Make it clear and easy.
* Make clear separation between "what layout what", now parent always layout children, noone layout itself.
* Make possible to interleave Yoga layout with custom imperative layout (may be used in SafeAreaView, Text, Modal, InputAccessoryView and so on).
Reviewed By: mmmulani
Differential Revision: D6863654
fbshipit-source-id: 5a6a933874f121d46f744aab99a31ae42ddd4a1b
Summary:
I've talked to several major community users, and they're all ok with deleting this
code. There's several doc fixes which will make it easier for third
party developers which should land about the same time this will.
Also buried along with it is RCTJSCExecutor.
Reviewed By: javache
Differential Revision: D6880781
fbshipit-source-id: b4cb1143def6fd23a96290e478fa728adbedacd3
Summary:
Trivial.
Special thanks to janicduplessis
Created from Diffusion's 'Open in Editor' feature.
Reviewed By: fkgozali
Differential Revision: D6863932
fbshipit-source-id: d40a30271adc5c8d47149ab920e2ac11158ab756
Summary:
This makes RCTTouchHandler follow the same logic when sending touch event
coordinates as `UIManager.measure`.
This is important as UIManager.measure is used in `Touchable.js` aka the mother
of all touch events in RN.
In particular, this will make touch events correctly handled for places where RN is embedded into other screens.
Reviewed By: shergin
Differential Revision: D6838102
fbshipit-source-id: 70cad52606ea931cb637d8aa2d4845818eea0647