Commit Graph

766 Commits

Author SHA1 Message Date
Pieter De Baets 12ab236629 Fix references to deprecated assets in separate bundles
Reviewed By: sahrens

Differential Revision: D5346879

fbshipit-source-id: 9d1008765514006deef2182e61f42a7247ea9a85
2017-06-30 07:00:12 -07:00
Alex Dvornikov 2f193b9bc1 Allow RCTModuleData to explicitly opt out from performing its set up on the main queue
Reviewed By: javache

Differential Revision: D5328995

fbshipit-source-id: 6ef6c260a01ee3b088665b13587ff25b84b51771
2017-06-28 06:16:54 -07:00
Mehdi Mulani dbd7a4e3a1 Revert D5197885 to unbreak Internal App
Reviewed By: shergin

Differential Revision: D5312189

fbshipit-source-id: 07f6944994068638703611db9522b1861f1688e2
2017-06-23 13:05:49 -07:00
Pieter De Baets d795fa1b2c Update native references to JSTimers
Reviewed By: AaaChiuuu

Differential Revision: D5294997

fbshipit-source-id: 3003d56f744af0c35b1ffef7bdd71617d4f948c3
2017-06-22 09:52:33 -07:00
Valentin Shergin d0ad6ad413 Removed support of mysterious "deprecated" scale in RCTImageSource
Reviewed By: fkgozali

Differential Revision: D5197885

fbshipit-source-id: 06b7ee0ed71e07f1db1db053fbbd5f9834d56586
2017-06-20 17:16:43 -07:00
Jonathan Ballerano eaac3b57ee Add a type cast to RCT_ENUM_CONVERTER for C++ compatibility
Summary:
C++ doesn't provide an implicit cast to an enum value from the enum's backing type. When a `.mm` file calls `RCT_ENUM_CONVERTER`, we end up with the following compiler error:
> Error: cannot initialize return object of type `<TypeName>` with an rvalue of type `NSInteger`

Since `RCT_ENUM_CONVERTER` is a macro, this error will appear whenever we try to expand the macro in a C++ context.

The project compiles and runs as expected when this additional cast is added 😃
Closes https://github.com/facebook/react-native/pull/14408

Reviewed By: javache

Differential Revision: D5215584

Pulled By: jballer

fbshipit-source-id: 7f4464afd7cd9dc9a014f646278bae20731f08ba
2017-06-15 19:07:21 -07:00
Alex Dvornikov c143313a20 Make RCTSamplingProfilerPackagerMethod not depend on RCTBridge
Reviewed By: javache

Differential Revision: D5245899

fbshipit-source-id: a99de4cbf0ddd9c8ee98cbbf438f8930a57e917c
2017-06-15 12:07:34 -07:00
Pieter De Baets c25f356675 Avoid crash when accessing jsContextRef without an executor
Reviewed By: adamjernst

Differential Revision: D5237039

fbshipit-source-id: 6a86da90605b896093e0ef99b0fcf079bf9854bf
2017-06-14 05:32:27 -07:00
Stephen Bird f1284b8231 Add message to remind user to enable wifi
Summary:
Our iOS devs frequently turn off wifi and forget to turn it back on. This message should remind them that they need wifi to connect. Often they waste several minutes due to this problem.

I'm not sure if there's a test plan to apply here. Any suggestions?
Closes https://github.com/facebook/react-native/pull/13551

Differential Revision: D5149231

Pulled By: hramos

fbshipit-source-id: 0afc71024f10f802ac1a50435fb57fc10a02c819
2017-05-30 20:49:48 -07:00
makadaw 5e97be8b1c Fix data race on read/write _instance variable in ModuleData class
Summary:
Thanks for submitting a PR! Please read these instructions carefully:

- [ ] Explain the **motivation** for making this change.
- [ ] Provide a **test plan** demonstrating that the code is solid.
- [ ] Match the **code formatting** of the rest of the codebase.
- [ ] Target the `master` branch, NOT a "stable" branch.

What existing problem does the pull request solve?
XCode  [Thread Sanitizer](https://clang.llvm.org/docs/ThreadSanitizer.html) find race condition while read/write `_instance` variable in RCTModuleData class. A bridge can check `hasInstance` method while instance writes.

All tests passed on my device.
These changes remove data race, you can turn it in scheme configuration ![](https://www.shinobicontrols.com/wp-content/uploads/2016/08/Enable_Sanitizer.png)
Closes https://github.com/facebook/react-native/pull/13757

Differential Revision: D4994041

Pulled By: javache

fbshipit-source-id: 631cd59bbcbde193937d8baf8358ff6868717a2e
2017-05-24 13:01:00 -07:00
Valentin Shergin 2a984326b0 Introducing `RCTAssertUIManagerQueue()`
Reviewed By: javache

Differential Revision: D4868564

fbshipit-source-id: b9b9f6cf8f31495bb0e82fb60b2402dde460ddb8
2017-05-08 12:52:09 -07:00
Marc Horowitz dd45e7e1c4 Switch default bridge to CxxBridge
Reviewed By: javache

Differential Revision: D4981911

fbshipit-source-id: 49900a0e86d13045aa8930a865b073e1dec35e93
2017-05-03 14:52:56 -07:00
Valentin Shergin 18e0f84349 Use just `_bridge` instead of `batchedBridge` when actual bridge is already batched one
Reviewed By: javache

Differential Revision: D4989251

fbshipit-source-id: 939b54459d14e9bddd60be82787c2ca4d116200c
2017-05-03 11:16:31 -07:00
Alexey Lang 1c07658a1e Log RCTPLTTI for Warm Start
Reviewed By: javache

Differential Revision: D4962773

fbshipit-source-id: d01f8fe0d4e2f1e7453df03f9a15482f2f065a13
2017-05-03 09:30:54 -07:00
Alex Dvornikov d1fb892715 Clean up after recent RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD changes
Reviewed By: javache

Differential Revision: D4969636

fbshipit-source-id: 49785dcf02e6544a313d82ccb26839ac2302c7d9
2017-04-28 05:35:41 -07:00
Pieter De Baets 96d13b663b Avoid presenting on view controller that's being dismissed
Summary:
Mitigates the issue in https://github.com/facebook/react-native/issues/10471, by not trying to present
a modal or alert view if the presenting view controller is already being dismissed.

Reviewed By: shergin

Differential Revision: D4962169

fbshipit-source-id: 593e3f21096458651d16677a3e030552f809bf02
2017-04-28 03:30:38 -07:00
Alex Dvornikov db0c22192c Added support for synchronous methods in native modules on iOS
Reviewed By: javache

Differential Revision: D4947556

fbshipit-source-id: 0ef73dc5d741201e59fef1fc048809afc65c75b5
2017-04-27 12:03:30 -07:00
Valentin Shergin 91be5bfc86 Do not warn if `touch.force` is NaN
Reviewed By: jingc

Differential Revision: D4956972

fbshipit-source-id: e0d4d55e4e7ee352a8fc88a4cfd43dc3cabc9c48
2017-04-26 15:16:16 -07:00
Valentin Shergin e7c6a4c038 Fixed crash caused by NaN values in RCTTouchEvent
Summary:
React Native uses JSON to marshal the data across the bridge.
And because of this we have to avoid using NaN and INF values in events and other pieces of data that suppose to be transfered to/from JS side.
(We also don't want to introduce additional wrapping/escaping semantics for perfomance reasons.)
So, we have to gate all particular cases where there is a possibility of NaN or INF values, and replace these value with something meaningful for each particular case.
We are using `0` as NaN substitution here because:
 * NaN in touch event is super rare case;
 * Conversion to `0` is fast;
 * `0` is okay value for product code in most cases;
 * In all cases `0` is decent analog to "undefined position on screen" for touch event;
 * Nobody will explicitly handle NaN case in product code, just because it is super rare case and actually indicates that something else went wrong.

Reviewed By: javache

Differential Revision: D4918669

fbshipit-source-id: e95fa29e59dcdc40b57519e307b74c1f293da188
2017-04-21 11:30:57 -07:00
Pieter De Baets 59378f71db Immediately trigger renderApplication from RCTRootView init
Reviewed By: fkgozali

Differential Revision: D4849610

fbshipit-source-id: 291a9bcdf0efe47d83130fe2675f3ef04a3f085b
2017-04-21 07:04:57 -07:00
wenzhao.yin 47f834a76d fix RCTMultipartDataTask Memory leaks
Summary:
In the Docs of `NSURLSession` ,

>IMPORTANT

>The session object keeps a strong reference to the delegate until your app exits or explicitly >invalidates the session. If you do not invalidate the session, your app leaks memory until it exits.

The RCTMultipartDataTask will cause memory leaks, it will make `RCTBatchedBridge` and ` RCTMultipartDataTask` will not release.

So call `[session finishTasksAndInvalidate];` at the end of `startTask` function.
Closes https://github.com/facebook/react-native/pull/12673

Reviewed By: shergin

Differential Revision: D4896497

Pulled By: javache

fbshipit-source-id: eb5f8761f67ad33a7de081a68a9a7e1d4329bfc0
2017-04-20 03:45:25 -07:00
Andrew Tokarev 460e77d47d Fixing Race condition that happens with _wasBatchActive
Summary:
Issue Fix: #13485

Yet another race condition that was found by XCode's Thread Sanitizer.
Happens because wasBatchActive is read/write from multiple threads at the same time

- opened UIExplorer and see it works
- npm run test pass
- tested on own project as well

Signed CLA
Closes https://github.com/facebook/react-native/pull/13505

Differential Revision: D4906096

Pulled By: javache

fbshipit-source-id: 5d4329aafcfe9491ce0188fa1e2dd71e09b31031
2017-04-19 03:00:53 -07:00
Kevin Cooper e443b7379e More verbose error messages for iOS
Summary:
Output the reason for the error when failing to load source code. This was a big help when trying to diagnose https://github.com/facebook/react-native/issues/13299.

~~Unfortunately there still seems to be no way to get the offending line number (because `loadError.userInfo[RCTJSStackTraceKey]` is empty), but this is good enough.~~

Before:

```
[warn][tid:com.facebook.react.JavaScript][RCTBatchedBridge.m:510] Failed to execute source code. Unhandled JS Exception: SyntaxError
```

After:

```
[warn][tid:com.facebook.react.JavaScript][RCTJSCErrorHandling.mm:30] Couldn't get stack trace for http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:81886
[warn][tid:com.facebook.react.JavaScript][RCTBatchedBridge.m:510] Failed to execute source code. Unhandled JS Exception: SyntaxError Unexpected keyword 'var'
```
Closes https://github.com/facebook/react-native/pull/13561

Differential Revision: D4908501

Pulled By: javache

fbshipit-source-id: a316dc70739b917b3cc690309d0ff37a8bb5d412
2017-04-18 14:19:13 -07:00
Valentin Shergin ca6e0b37cf `reactRespondsToTouch:` was removed
Summary:
* It complicates Touch Handling mechanism.
* The same functionality can be (and should be) implemented via overriding standard `hitTest:` method.
* It was marked as deprecated a while ago.

Reviewed By: mmmulani

Differential Revision: D4667776

fbshipit-source-id: 2e047c3308563a2849ea351a242270f0800fead2
2017-04-10 12:32:31 -07:00
Pieter De Baets 2336ac299c Improve constant extraction from RCTNativeModule
Reviewed By: dcaspi

Differential Revision: D4829671

fbshipit-source-id: 6b1cef1d31c7d8981c6f1e304d3742e885f8a83b
2017-04-08 15:18:08 -07:00
Pieter De Baets 5767b98f4d Add JSC utility header to RCTBridge
Reviewed By: shergin

Differential Revision: D4823509

fbshipit-source-id: 79c96d3bc183d89a5dec7da06b0a0a710d8c7dea
2017-04-07 11:16:59 -07:00
Pieter De Baets 76b93e1253 Add block-based initializer for RCTModuleData
Reviewed By: shergin

Differential Revision: D4821772

fbshipit-source-id: 2cd35ec6726b6fe1494a92966ade5aa0b86e769b
2017-04-07 11:16:59 -07:00
Alex Dvornikov b3872e807d Check that RCTDidInitializeModuleNotification is being called with the correct bridge
Reviewed By: javache

Differential Revision: D4800110

fbshipit-source-id: acc8bc512ed17a84abeac74afb91db51ab4c5043
2017-04-06 00:46:05 -07:00
Alex Dvornikov 37c1678421 Report JS errors in debug console
Reviewed By: javache

Differential Revision: D4835405

fbshipit-source-id: d10658d1b885048ea3495388450208bb0e29ee5b
2017-04-05 19:51:03 -07:00
Shruti Malugu edbb48c67a Replacing all instances of [UIApplication sharedApplication] wi…
Summary:
…th RCTSharedApplication()

Thanks for submitting a PR! Please read these instructions carefully:

- [ ] Explain the **motivation** for making this change.
          Using React Native latest version with Cocoapods 1.2.0 causes the following error inside iOS app extensions

> /react-native/React/Modules/RCTAccessibilityManager.m:67:70: ‘sharedApplication’ is unavailable: not available on iOS (App Extension) — Use view controller based solutions where appropriate instead.

Moving the use of [UIApplication sharedApplication] to RCTSharedApplication() which is safe on app extension

- [ ] Provide a **test plan** demonstrating that the code is solid.
        I am not sure how to test such that all the features which touch the modified code are tested.

- [ ] Match the **code formatting** of the rest of the codebase.
- [ ] Target the `master` branch, NOT a "stable" branch.

What existing problem does the pull request solve?
    Using React Native latest v
Closes https://github.com/facebook/react-native/pull/13227

Differential Revision: D4816338

Pulled By: javache

fbshipit-source-id: e3e3c77882990ad1817b0b633521cff52571ecd0
2017-04-01 03:34:41 -07:00
Ben Roth 9075fe0618 Fix crash in `RCTJSStackFrame::stackFrameWithDictionary:`
Summary:
Motivation: When logging to RCTRedBox, if any of the stack frames lacks a line number or a column, the application will crash with `[NSNull integerValue]: unrecognized selector sent to instance`.
Closes https://github.com/facebook/react-native/pull/13242

Differential Revision: D4812185

Pulled By: hramos

fbshipit-source-id: 4b1c3c38f67cf59034a383c95d4280d1b6380300
2017-03-31 13:32:47 -07:00
Pieter De Baets e12e57eb77 Move bindKeys to RCTBridge setUp
Reviewed By: shergin

Differential Revision: D4794788

fbshipit-source-id: 0839829f4ed010bf2fb2574092a8f68f4c95341a
2017-03-31 05:31:26 -07:00
Pieter De Baets f6754348be Merge RCTPlatform.isTesting and RCTRunningInTestEnvironment
Reviewed By: fkgozali

Differential Revision: D4802834

fbshipit-source-id: 76bb98877f2fc427c01806b192d8dc71489a1c4a
2017-03-30 10:02:35 -07:00
Pieter De Baets 5af30382d5 Improve fbsystrace support
Reviewed By: mhorowitz

Differential Revision: D4756318

fbshipit-source-id: 7811f680a7ad044b5ae028ee9b2fed5f46ce2a63
2017-03-30 06:53:16 -07:00
Pieter De Baets 9d377e98a0 Fix warnings in React.xcodeproj
Summary:
Various fixes of xcode projects and cleaning up some warnings
Closes https://github.com/facebook/react-native/pull/13109

Differential Revision: D4762652

Pulled By: lacker

fbshipit-source-id: b452976a58962439de4adecc8e703264af40cb38
2017-03-23 11:36:17 -07:00
Marc Horowitz ba149d7277 Tease apart React and RCTBatchedBridge targets
Reviewed By: javache

Differential Revision: D4679655

fbshipit-source-id: 8123488c2d50dd7cc2329b5131e99998fe1f1e2f
2017-03-21 18:31:23 -07:00
Marc Horowitz d9ac00735c Make the choice of bridge based on an optional delegate method
Reviewed By: javache

Differential Revision: D4679644

fbshipit-source-id: f53e554e283fdb0b59c41623e690fd1a21e03a57
2017-03-21 18:31:23 -07:00
Jeff Thomas 439889262c RCTLocalAssetImageLoader: Add searching shipped frameworks beyond mainBundle
Reviewed By: javache

Differential Revision: D4715608

fbshipit-source-id: 5cb2febf543e2ff6e30d0c6d8737de9a2cce2383
2017-03-20 12:00:44 -07:00
Valentin Shergin b53d76efb7 Better TextInput: RCTUITextView was decoupled in separate file and now handles placeholder feature
Reviewed By: mmmulani

Differential Revision: D4663151

fbshipit-source-id: ce57ca4bebf4676df2ae5e586a1b175ec2aac760
2017-03-20 00:02:58 -07:00
Valentin Shergin d272334186 RCTRootView is now has empty autoresizing mask by default
Summary: `autoresizingMask` is supposed to be set outside self class, this is UIKit convention.

Reviewed By: mmmulani

Differential Revision: D4697098

fbshipit-source-id: 7e0aa5d3032184de980b3cecafebbc4ce8ef9ada
2017-03-19 22:01:56 -07:00
Ashwin Bharambe f48b54bf62 Expose RCTImageLocalAssetURL as a utility
Reviewed By: javache

Differential Revision: D4696627

fbshipit-source-id: 56d3e59983f524dfd5021835734b9b34203e20f2
2017-03-17 17:02:06 -07:00
Valentin Shergin 98798a06ae More accurate implementation of `RCTRootView`'s `sizeThatFits:`
Reviewed By: mmmulani

Differential Revision: D4672788

fbshipit-source-id: 780487f2264916349e32785808a93ed6f957e471
2017-03-13 13:30:31 -07:00
Valentin Shergin 264d60b979 Setting `availableSize` for `RCTRootShadowView` on earlier stage
Summary:
Moving setting `availableSize` for `RCTRootShadowView` on earlier stage allows to prevent situations where `availableSize` is not specified yet, but Yoga layout is already happening.
Because `availableSize` equals {infinity, infinity} by default (in this case), Yoga returns a lot of nodes with infinit metrics, which confises UIKit.

Reviewed By: mmmulani

Differential Revision: D4672170

fbshipit-source-id: f9d8c84799dcbdb6b9230ddef6284d84df268833
2017-03-08 19:00:14 -08:00
Mehdi Mulani 0a06250d24 Add build-time check that module methods are exported correctly
Summary:
This prevents someone from only putting `RCT_EXPORT_METHOD(...)` around some of the arguments to a method and generally causing confusion. Yes, before this diff it would still compile correctly if you did something like:

```
RCT_EXPORT_METHOD(lol:(NSNumber *)lol)
blah:(id)blah
{
  NSLog(@"%@ %@", lol, blah);
}
```

Reviewed By: fkgozali

Differential Revision: D4660019

fbshipit-source-id: 1829a47e5c8d5e8ce93edca2ac7efd7e2bfdf840
2017-03-07 10:45:36 -08:00
Emil Sjolander 4d69f4b2d1 Add display:none support to react native
Summary:
This diff adds display:none support to React Native. This enables hiding components which still calling their render method and keeping them within the state of your application. This enables preserving state in a component even though the component is not visible. Previously this was often implemented by rendering a component off screen as a work around. See below playground for usage.

```
class Playground extends React.Component {
  render() {
    return (
      <View style={{width: '100%', height: '100%', flexDirection: 'row', backgroundColor: 'white'}}>
        <View style={{width: 100, height: 100, display: 'none', backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, backgroundColor: 'blue'}}/>
      </View>
    );
  }
}
```

Reviewed By: astreet

Differential Revision: D4611771

fbshipit-source-id: 0dbe0494d989df42994ab9ad5125d47f3233cc5a
2017-03-01 09:16:05 -08:00
Emil Sjolander 31f848a5fa Expose alignContent to react native
Summary:
This diff adds alignContent (https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) support to React Native. This enables aligning the lines of multi-line content. See below playground for example usage.

```
class Playground extends React.Component {
  render() {
    return (
      <View style={{width: '100%', height: '100%', flexDirection: 'row', backgroundColor: 'white', flexWrap: 'wrap', alignContent: 'space-between'}}>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
      </View>
    );
  }
}
```

Reviewed By: astreet

Differential Revision: D4611803

fbshipit-source-id: ae7f6b4b7e9f4bc78d2502da948214294aad4dd2
2017-03-01 09:16:05 -08:00
Emil Sjolander cc275557be Add margin auto support to react native
Summary:
This diff adds margin:auto (https://drafts.csswg.org/css-flexbox-1/#auto-margins) support to React Native. This enables layout not previously supported without inserting empty 'spacer' views. See below Playground for usage.

```
class Playground extends React.Component {
  render() {
    return (
      <View style={{width: '100%', height: '100%', flexDirection: 'row', backgroundColor: 'white'}}>
        <View style={{width: 100, height: 100, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 'auto', backgroundColor: 'blue'}}/>
      </View>
    );
  }
}
```

Reviewed By: astreet

Differential Revision: D4611753

fbshipit-source-id: e78335565c193f7fb263129a638b444715ba5ab0
2017-03-01 09:16:05 -08:00
Eloy Durán 19caaba1d5 Fixes current CI failures and allows tree shaking of native dev support code.
Summary:
* The dev support code moved into a `DevSupport` subspec, meaning that only if the subspec is specified in the user’s Podfile will the packager client, dev menu, etc be included. This is mainly done through checks for header availability.

  It also improves the weird situation where you had to specify the `RCTWebSocket` subspec if you wanted to be able to use the packager client during development.

* I removed hardcoding the release version in the podspec on release, because the podspec still relies on `package.json` when evaluating, so there’s no real point in not also getting the version number from there. This should remove any requirement to perform maintenance of the OSS release script regarding the podspec.
Closes https://github.com/facebook/react-native/pull/12602

Differential Revision: D4621021

Pulled By: ericvicenti

fbshipit-source-id: 6c208371fc40ea607809a6ab05dd3714ed9980cf
2017-02-27 14:04:58 -08:00
Valentin Shergin e7cc1bcbba RCTRootView's `intrinsicSize` property was deprecated in favour of `intrinsicContentSize`
Summary:
Nothing actually changed except the deprecation.
Existed `intrinsicSize` was already implemented as `intrinsicContentSize` and this change only removes redundancy.
Moreover, we do not need `rootViewDidChangeIntrinsicSize` delegate method anymore; this is now mentioned in its description.

Depends on D4577890

Reviewed By: mmmulani

Differential Revision: D4589344

fbshipit-source-id: 16ed62cbf6bf72678bd7f7c11d4812c5aa36c743
2017-02-27 14:04:58 -08:00
Valentin Shergin 9dccff0eda Better support of UIKit layout stuff for RCTRootView an co.
Summary:
Now RCTRootView is much more reliable citizen of UIKit, it got:
 * Implemented `sizeThatFits:`;
 * Implemented `instrinsicContentSize`;
 * Notifying superview via `setNeedsLayout` about changed size.

All it make possible painless integration of ReactNative-powered widgets inside existing native apps.

Reviewed By: javache

Differential Revision: D4577890

fbshipit-source-id: 9897cb002c9d658a97fd436240c2ac947ba2084b
2017-02-27 14:04:58 -08:00
Pieter De Baets dba133a291 Merge AndroidConstants and IOSConstants into PlatformConstants
Reviewed By: AaaChiuuu

Differential Revision: D4597790

fbshipit-source-id: 0a54598d6e9cadb75efff4ac17c13899d6785f9b
2017-02-22 15:01:11 -08:00
Ashok Menon 1635c02e92 Simplifying Struct definition.
Summary:
Since we are reading from a file, we should make sure this struct is packed, just in case we change it down the line and the compiler decides it might want to introduce padding, we're now protected against that.

There was also a discussion about the fact that people might use `ptr += sizeof(BundleHeader)` as an idiom in their code, which would currently be incorrect, if padding was introduced at the end of the file. Actually, it remains incorrect to do that now, because a RAM bundle header is a different size to a BC Bundle header. If people are properly testing their code, they should spot this pretty quickly, because it will always be an incorrect thing to do with a RAM bundle, so this isn't as bad as previously thought: where the code only succeeds when the compiler deigns to not pad the struct at the end.

This diff also cleans up how headers are initialised. `BundleHeader` has a constructor that explicitly zero-initialises it so we can rely on the default initializer to do the right thing now.

Reviewed By: mhorowitz

Differential Revision: D4572032

fbshipit-source-id: 7dc50cfa9438dfdfb9f842dc39d8f15334813c63
2017-02-20 04:30:19 -08:00
Valentin Shergin c02c78a681 Splitting `RCTRootView.m`, decoupling RCTRootContentView
Reviewed By: javache

Differential Revision: D4570067

fbshipit-source-id: 91305d0c175af135ce2f22d7992bee68c13da80e
2017-02-19 23:19:47 -08:00
Valentin Shergin ba170ec78c Simplifying mess with RCTRootViewSizeFlexibility
Summary:
Now things look much more clear, I hope.
This diff:
 * Introduces new property of `RCTRootShadowView` `availableSize` which represents exactly what we transmit to layout engine;
 * Illuminates conflict between logical `availableSize` and explicitly specified size of DOM node (current `size`);
 * Splits overcomplicated `setSize:forView:` method into two unrelated ones;
 * Changes actual values of `RCTRootViewSizeFlexibility` enum constants for simpler usage;
 * Completely removes `sizeFlexibility` concept from `RCTRootShadowView` (in favor of special values of `availableSize`);
 * Makes the code clearer finally.

This is beginning of big effort to improve `RCTRootView` and co.

Reviewed By: mmmulani

Differential Revision: D4562834

fbshipit-source-id: f5baaf2859ea430d44645a6b5d35f222f15a668e
2017-02-19 23:19:47 -08:00
Alexey Lang ba029becbe Support QuickPerformanceLogger.js in CxxBridge
Reviewed By: javache

Differential Revision: D4573567

fbshipit-source-id: 3ef9da38fb178cf4c1400b4a991a9e85f3ec3755
2017-02-17 06:00:54 -08:00
Pieter De Baets a2000d1200 Replace valueForKey with subscript access in RCTJavascriptLoader
Reviewed By: shergin

Differential Revision: D4559391

fbshipit-source-id: 44cb4900f93f2ac60dae3a461ed5344e1af08f3b
2017-02-15 03:45:55 -08:00
David Hart 67f6b32409 Rename YGUnitPixel to YGPoint...
Summary:
...to reflect the modern world we live in with dynamic DPI platforms :)
Closes https://github.com/facebook/yoga/pull/375

Reviewed By: dshahidehpour

Differential Revision: D4528518

Pulled By: emilsjolander

fbshipit-source-id: e422bd4ae148e02c598a7b484a6adfa8c0e1e0c9
2017-02-14 14:31:31 -08:00
Valentin Shergin ec673d0771 Added support of `direction` style property
Summary: Now layout direction (LTR or LTR) can be specified not only for whole app but also for view subtree via `direction` style property.

Reviewed By: mmmulani

Differential Revision: D4510206

fbshipit-source-id: 4e56c5886b6e42f2343165eb76be897e681c5ba4
2017-02-06 21:00:16 -08:00
Valentin Shergin 233015c93e `[-RCTUIManager setFrame:forView:]` was replaced with `[-RCTUIManager setSize:forView:]`
Reviewed By: fkgozali

Differential Revision: D4511712

fbshipit-source-id: 5c51d573bf638cb9b55d5f03b9f1882dc6129510
2017-02-06 11:01:11 -08:00
rh389 9d6d8a24eb RCTConvert: Deprecated NSStringArray typedef
Summary:
Eliminates a build warning related to the use of the deprecated `NSStringArray` typedef.

This fix was more complex than I'd anticipated because `NSStringArray` was also being used as part of a macro-generated selector name, and in two different ways for debug/release. I've added a macro which allows the selector name to be specified explicitly, thus generally allowing for converters which return arrays of templated types.

There's an argument for ditching `RCT_JSON_ARRAY_CONVERTER` in favour of `RCT_JSON_ARRAY_CONVERTER_NAMED` as they're both private, but `RCT_ARRAY_CONVERTER` is in the public API so we'd at least need to retain that. There are also arguments for ditching the use of the macro for the nested array case(s) - since afaik this is the only one at the moment. Feedback appreciated :)

Tested with the `UIExplorer` unit tests and by diffing the preprocessor output of `RCTConvert.m` in both release and debug configs, verifying that they're identical apart from that `NSStringArray` is replaced by
Closes https://github.com/facebook/react-native/pull/11799

Differential Revision: D4441197

fbshipit-source-id: 7535ebe6f8ad4566df742e805b0a64530d1b269f
2017-01-27 13:43:27 -08:00
Martin Konicek 9dee696ed8 Add scrollToEnd to ScrollView and ListView
Summary:
**Motivation**

A basic task of making a React Native ScrollView or ListView scroll to the bottom is currently very hard to accomplish:
- https://github.com/facebook/react-native/issues/8003
- https://github.com/facebook/react-native/issues/913
- http://stackoverflow.com/questions/29829375/how-to-scroll-to-bottom-in-react-native-listview

**NOTE:** If you're building something like a chat app where you want a ListView to keep scrolling to the bottom at all times, it's easiest to use the [react-native-invertible-scrollview](https://github.com/exponent/react-native-invertible-scroll-view) component rather calling `scrollToEnd` manually when layout changes. The invertible-scrollview uses a clever trick to invert the direction of the ScrollView.

This pull request adds a `scrollToEnd` method which scrolls to the bottom if the ScrollView is vertical, to the right if the ScrollView is horizontal.

The implementation is based on this SO answer:
http://stackoverflow.com/questions/952412/uiscrollview-scrol
Closes https://github.com/facebook/react-native/pull/12088

Differential Revision: D4474974

Pulled By: mkonicek

fbshipit-source-id: 6ecf8b3435f47dd3a31e2fd5be6859062711c233
2017-01-27 10:13:29 -08:00
Ryan Gomba 7e869b9d0a Drive any numerical prop via NativeAnimated
Summary:
In theory, we should be able to animate any non-layout property, including custom ones. While there is still work to be done on the native side to fully enable this, we should start by dropping the prop whitelist.
Closes https://github.com/facebook/react-native/pull/10658

Differential Revision: D4379031

Pulled By: ericvicenti

fbshipit-source-id: fe9c30ea101e93a8b260d7d09a909fafbb82fee6
2017-01-26 18:28:53 -08:00
Valentin Shergin 64041669ee The warning 'cannot calculate shadow efficiently' is not a warning anymore
Reviewed By: fkgozali, yungsters

Differential Revision: D4445304

fbshipit-source-id: 3a37150ae2beaf44b505dc36b575b7d44619e071
2017-01-25 12:28:50 -08:00
Pieter De Baets 7412340175 Fix passThroughTouches
Reviewed By: mmmulani

Differential Revision: D4438390

fbshipit-source-id: 4e1ec4eaf80ffb48ac7b65ed092402c51d9227d3
2017-01-23 11:28:51 -08:00
Mehdi Mulani 81c33b542d Switch out DISABLE_YELLOW_BOX for IS_TESTING
Summary: Switch to using IS_TESTING on the Platform module. While IS_TESTING has to be explicitly set in the test harness, this makes it more usable and stops people from relying on brittle variables in the (larger) environment.

Reviewed By: fkgozali

Differential Revision: D4423661

fbshipit-source-id: 27a80867778b9374bcba67b69f9c93d32c0a74b0
2017-01-18 12:28:42 -08:00
Peter Salanki 52d8851fc8 Cache policy control for image source
Summary:
In the context of an app an image exists in three resolutions on the server: `thumb` (30px) `feed` (300px) `full` (900px). When looking at an individual item a user can come either from the feed, via a permalink or from other parts of the app. This allows a situation where the `feed` image might or might not already be loaded somewhere in the app. In the detail view I want to render `thumb` with a blur (to quickly display something), then the `feed` image if it exists to have something decent to display until `full` loads. However it is quite a waste to load the `feed` image if it isn't already in cache, and will slow down the time until `full` is loaded. It is possible to track the navigation from feed->detail and that the `feed` image has actually completed loading by the feed component however as component hierarchies grow this turns into quite a lot of prop passing and bad separation of concerns.

NSURLRequests accepts a [Cache Policy](https://developer.apple.com/reference/fo
Closes https://github.com/facebook/react-native/pull/10844

Differential Revision: D4425959

Pulled By: lacker

fbshipit-source-id: 679835439c761a2fc894f56eb6d744c036cf0b49
2017-01-17 17:13:31 -08:00
Neil Sarkar 302d42da7f Remove deprecated method 'RCTExecuteOnMainThread'
Summary:
**Motivation**

This finishes the job of #11817, removing the previously deprecated method. See https://github.com/facebook/react-native/issues/11736 for more context.

**Test plan**

There were no tests for this method, and I searched the whole project to make sure we weren't relying on it anywhere.
Closes https://github.com/facebook/react-native/pull/11854

Differential Revision: D4421671

Pulled By: javache

fbshipit-source-id: 67e0db8d3c594ad3ccd6ccdae08f8ce49ddb8a34
2017-01-16 15:13:36 -08:00
Valentin Shergin 930010ec91 RCTTouchHandler doesn't delay any touches anymore
Reviewed By: mmmulani

Differential Revision: D4418211

fbshipit-source-id: 07fdd81d975c6b65477e599e2dcb604b64556e9e
2017-01-13 17:43:35 -08:00
Rob Hogan 9e1e52f312 Mark __unused completion block args
Summary:
Catching a couple more build warnings introduced by b50f55026a since https://github.com/facebook/react-native/pull/11797.

Edit: and one more introduced by c68a708621

Tested the build with UIExplorer.
Closes https://github.com/facebook/react-native/pull/11865

Differential Revision: D4415630

fbshipit-source-id: 1384d56770eea8665ede8bd9abe06cf34cd14b33
2017-01-13 12:43:31 -08:00
Pieter De Baets a94418fdd3 Show redbox when no bundle is present
Reviewed By: shergin

Differential Revision: D4405409

fbshipit-source-id: 847fc559121dcde844f1ee3c6d02206e9e27803b
2017-01-13 03:43:35 -08:00
Valentin Shergin c68a708621 New way to handle simultaneously active gesture recognizers in RCTTouchHandler
Reviewed By: majak

Differential Revision: D4385209

fbshipit-source-id: 22746dd93e378a4d9e5feca66bc84c357afb6f36
2017-01-12 12:13:28 -08:00
rh389 4844225eed JavaScriptLoader BCBundle version check
Summary:
Currently a build warning is thrown by `if (header.BCVersion != runtimeBCVersion) ...` because `runtimeBCVersion` is signed, apparently because `-1` is used to mean that the runtime has no support for bytecode bundles.

This PR splits out the error case of the runtime not supporting BC bundles from the case of a version mismatch.

Tested as much as I could by building and running `UIExplorer` - I haven't attempted to use real bytecode bundles.
Closes https://github.com/facebook/react-native/pull/11806

Differential Revision: D4408608

fbshipit-source-id: a1d868bb2064588e6a20827692629a46b6ba1e74
2017-01-11 22:28:43 -08:00
Emil Sjolander 3f49e743be Add percentage support to react native
Summary:
Adds support for percentage value in react native.

syntax: property: 100 | property | '100%'

supported properties:
padding
margin
width
height
minWidth
minHeight
maxWidth
maxHeight
flexBasis

```
class Playground extends React.Component {
  render() {
    return (
      <View style={{backgroundColor: 'white', padding: 10, paddingTop: 30, height: '100%'}}>
        <Text>
          If you want to quickly test out something,
          open the Playground.js file and start coding.
        </Text>
        <View style={{backgroundColor: 'red', height: 50, width: 50}}/>
        <View style={{backgroundColor: 'blue', height: '50%', width: '50%'}}/>
      </View>
    );
  }
}
```

Reviewed By: astreet

Differential Revision: D4376549

fbshipit-source-id: c41d68a7555396f95d063a7527ee081773ac56dc
2017-01-11 03:58:37 -08:00
Neil Sarkar 00d5674474 Remove deprecation warning for RCTExecuteOnMainThread
Summary:
As per janicduplessis recommendation, provide a new synchronous method to replace the necessary synchronous calls and use a warning in the comments (and method name).

**Motivation**

There are currently a number of XCode warnings that show up in a fresh 0.40 install of a react native project. While the project can still be run, this contributes negatively to the development experience -- valid warnings may be ignored and new ones may be added as per https://en.wikipedia.org/wiki/Broken_windows_theory

This addresses one of the warnings, by providing the functionality of a deprecated method in two specific cases where we can't avoid doing synchronous work on the main queue. See https://github.com/facebook/react-native/issues/11736 for more context.

**Test plan (required)**

I ran a project that relied on screen size and it didn't crash...happy to do more involved testing if someone can share better methodology.
Closes https://github.com/facebook/react-native/pull/11817

Differential Revision: D4402911

fbshipit-source-id: 9fd8b3f50d34984b765fe22b1f4512e103ba55a9
2017-01-10 23:13:33 -08:00
Dan Caspi b50f55026a Adding support in the new RN bridge on iOS
Differential Revision: D4393955

fbshipit-source-id: e5f3fb6773908678773a5dd4fdea568bcc200336
2017-01-10 11:28:44 -08:00
Valentin Shergin 47f18bdb17 Nobody outside RCTTouchHandler should treat it as UIGestureRecognizer subclass
Reviewed By: mmmulani

Differential Revision: D4387821

fbshipit-source-id: 8060772a5de669eeaca159ceac13b995d7518a1b
2017-01-09 00:13:33 -08:00
Emil Sjolander 976abf87f2 Add baseline alignment support
Summary:
Add baseline alignment support to react native.

{F65372439}

```
class Playground extends React.Component {
  render() {
    return (
      <View style={{padding: 30, flexDirection: 'row', alignItems: 'baseline'}}>
        <View style={{width: 30, height: 10, backgroundColor: 'red'}}/>
        <View style={{width: 30, height: 20, backgroundColor: 'green'}}/>
        <View style={{width: 30, height: 30, backgroundColor: 'blue'}}/>
      </View>
    );
  }
}
```

Reviewed By: javache

Differential Revision: D4385099

fbshipit-source-id: d7caa6e4c086c4a62e24ef1d5db9c805c470ef2a
2017-01-08 04:43:31 -08:00
Valentin Shergin 482c73de86 More accurate touch bookkeeping in RCTTouchHandler
Reviewed By: javache

Differential Revision: D4381374

fbshipit-source-id: d959381617eda93658d519e7a3c565093eb9fae8
2017-01-04 14:43:40 -08:00
Dave Lee 7123618aa8 Fix comparison between NSNumber* and int
Summary:
Strangely comparing a pointer with zero will only be a clang warning when compiling with `-Wpedantic`, so this incorrect comparison is silently allowed.

**Test plan**

Compiles with `-Wpedantic`.
Closes https://github.com/facebook/react-native/pull/11709

Differential Revision: D4377512

Pulled By: ericvicenti

fbshipit-source-id: 483cf1f41d3f539c452d542ad2155c4c4b41616d
2017-01-03 10:28:29 -08:00
Pieter De Baets c92ad5f6ae Apple TV support 4: support for input (tvOS focus engine)
Reviewed By: shergin

Differential Revision: D4333546

fbshipit-source-id: 8655070e81dbb62a80ab1f00a43ef6c2d9654618
2016-12-19 06:28:40 -08:00
Theo Yaung 4a6f2ec44a Fail-Fast on Redundant Callback Invokes
Reviewed By: javache

Differential Revision: D4295268

fbshipit-source-id: 1258ffbc02bcf7d7199348c7df8fcd744bb9963f
2016-12-08 13:43:38 -08:00
Adam Ernst cfb8b19126 Expose more of RCTWebSocketObserver
Reviewed By: javache

Differential Revision: D4297162

fbshipit-source-id: 97032ccf3dc6bd259ca0fa2883eff45c0c49347f
2016-12-08 07:44:38 -08:00
Adam Ernst 587606987f Rename and merge files for RCTWebSocketObserver protocol
Summary: No need to have two files; merge it into one and give it an appropriate name.

Reviewed By: javache

Differential Revision: D4296716

fbshipit-source-id: 904d13c23bb8d403b8efcb60f9a4aa5df5b08972
2016-12-08 07:44:37 -08:00
Adam Ernst 2b0c4591e2 Rename RCTWebSocketManager file to reflect its new contents
Reviewed By: javache

Differential Revision: D4296615

fbshipit-source-id: a48da3f0550398cb59478c7405fe971f9246910f
2016-12-08 07:44:37 -08:00
Adam Ernst d0c3e98d1d Eliminate RCTWebSocketManager
Summary: This singleton was unnecessary and can be implemented with a single `static` in `RCTDevMenu`. In another diff, I will rename `RCTWebSocketManager.{h,m}` to reflect the only class that remains.

Reviewed By: javache

Differential Revision: D4296551

fbshipit-source-id: 653971dfb31de5b0a161b531eed82a067f536ce3
2016-12-08 07:44:37 -08:00
Adam Ernst 2ca6138852 Start exposing RCTWebSocketObserver using a protocol
Reviewed By: javache

Differential Revision: D4296387

fbshipit-source-id: 33f92c36168dcb18356d0ccdaf902a84634d94b7
2016-12-08 07:44:37 -08:00
Adam Ernst ac489858f8 Clean up RCTWebSocketProxyDelegate a bit
Reviewed By: javache

Differential Revision: D4296294

fbshipit-source-id: b31e522c21ec490fdf98711655e5e8df22b32a12
2016-12-08 07:44:37 -08:00
Adam Ernst 617eb309a1 Refactor reload command in React Native
Summary: Introduces an API to register a weakly-held listener for the reload (Cmd+R) command. This allows external infrastructure to hook into the reload command before the `RCTBridge` object is even created.

Reviewed By: javache

Differential Revision: D4286980

fbshipit-source-id: 51012fb8cbeb433dc880d9d98d847b07fdbb4c4f
2016-12-07 20:13:22 -08:00
Pieter De Baets 286a1b2e5e Remove deprecated RCTReloadNotification
Reviewed By: adamjernst

Differential Revision: D4294180

fbshipit-source-id: 6837597df2a798661c993c6f63ec430989954de6
2016-12-07 16:28:33 -08:00
Emil Sjolander 7f8c2985a8 Rename directories
Reviewed By: gkassabli

Differential Revision: D4284681

fbshipit-source-id: f0c6855c2c6e4389b7867f48f72cbb697830fc5a
2016-12-07 05:14:12 -08:00
Emil Sjolander 85ac5fc354 Rename C api
Differential Revision: D4259190

fbshipit-source-id: 26c8b356ca464d4304f5f9dc4192bff10cea2dc9
2016-12-03 04:44:10 -08:00
Emil Sjolander 779508c0ba Rename enums
Differential Revision: D4244360

fbshipit-source-id: c9fcbdd231098c9ff230a6055676bbc7cbd11001
2016-12-02 05:58:45 -08:00
Pieter De Baets f2a46b17d4 Replace RCTJSCWrapper with JSCWrapper from ReactCommon
Reviewed By: mhorowitz

Differential Revision: D4204516

fbshipit-source-id: 6bcb122daf2848035dfae404ee7a2e9aca0f8087
2016-11-23 11:43:48 -08:00
Pieter De Baets e1577df1fd Move all header imports to "<React/..>"
Summary:
To make React Native play nicely with our internal build infrastructure we need to properly namespace all of our header includes.

Where previously you could do `#import "RCTBridge.h"`, you must now write this as `#import <React/RCTBridge.h>`. If your xcode project still has a custom header include path, both variants will likely continue to work, but for new projects, we're defaulting the header include path to `$(BUILT_PRODUCTS_DIR)/usr/local/include`, where the React and CSSLayout targets will copy a subset of headers too. To make Xcode copy headers phase work properly, you may need to add React as an explicit dependency to your app's scheme and disable "parallelize build".

Reviewed By: mmmulani

Differential Revision: D4213120

fbshipit-source-id: 84a32a4b250c27699e6795f43584f13d594a9a82
2016-11-23 07:58:39 -08:00
David Aurelio 5db7484e8d Move `ScriptTag` and `RCTJSModulesUnbundle` to `cxxreact`
Reviewed By: javache

Differential Revision: D4213662

fbshipit-source-id: fc2ec9717c24fe77bb022a48777049f88173ebeb
2016-11-23 06:43:50 -08:00
Janic Duplessis b49e7afe47 Dispatch native handled events to JS
Summary:
When native events where handled they were not sent to JS as an optimization but this caused some issues. One of the major one is touches are not handled properly inside a ScrollView with an Animated.event because it doesn't receive scroll events so it can't cancel the touch if the user scrolled.
Closes https://github.com/facebook/react-native/pull/10981

Differential Revision: D4226403

Pulled By: astreet

fbshipit-source-id: 41278d3ed4b684af142d9e273b11b974eb679879
2016-11-23 05:43:35 -08:00
Pieter De Baets cb3e575deb Allow bridge delegate to specify whether to use custom JSC wrapper
Reviewed By: mhorowitz

Differential Revision: D4197657

fbshipit-source-id: 09e050f802b41c9a7016456c25381018b2123553
2016-11-23 03:58:41 -08:00
Pieter De Baets 7c91f894ba Fix CSSLayout import hack, update podspec
Summary: Correct header import paths, update podspec so we point at the copy in ReactCommon (and can eventually remove the copy under React)

Reviewed By: astreet

Differential Revision: D4204501

fbshipit-source-id: e979a010092f025b2cdc289e1e5f22fc7b65a8d1
2016-11-21 09:13:36 -08:00
Pieter De Baets bcac6e7d39 Cleanup RCTSourceCode
Reviewed By: mmmulani

Differential Revision: D4124428

fbshipit-source-id: 0db5bfd5897c37c11374fe90516ac7aeb2ae5d53
2016-11-18 05:13:31 -08:00
Dan Caspi 42d14bef04 Enforcing semi-colon consistency between dev and release modes when calling RCTLog*
Summary:
The various RCTLog macros (`RCTLogWarn`, `RCTLogError`, etc..) are based on the `_RCTLog` macro, which, in its expanded form, has a semi-colon in DEV mode (i.e., when `RCTLOG_ENABLED` is set to 1), and doesn't have one when `RCTLOG_ENABLED` is set to 0.
This could lead to a situation where code will compile in DEV but will fail to compile for prod.
Fixing this by removing the semicolon from the DEV version (as should).

Reviewed By: javache

Differential Revision: D4189133

fbshipit-source-id: 54cb4e2c96d1e48d9df88464aa58b13af432c2bd
2016-11-16 07:28:32 -08:00