Compare commits

...
254 Commits
Author SHA1 Message Date
Konstantin Raev 2efd99ab64 [0.26.3] Bump version numbers 2016-06-01 18:55:55 +02:00
Konstantin Raev f9fff0e26a Made react installed via reac-native init strict to unbreak 15.1.0 2016-06-01 18:55:44 +02:00
Martin Konicek 23b1ed4570 [0.26.2] Bump version numbers 2016-05-24 16:31:47 +01:00
David Aurelio 17026c3728 Respect original enumerability/writability when polyfilling globals
Summary:
Reuses the original property descriptor when overwriting / polyfilling globals to ensure enumerability and writability are the same
Closes https://github.com/facebook/react-native/pull/7704

Differential Revision: D3338119

Pulled By: davidaurelio

fbshipit-source-id: ab456324a3346cd3ec8b2c3e3a2378408c92087c
2016-05-24 16:30:59 +01:00
Konstantin Raev af819a8f8f Fixed nvm for travis CI
Summary:
NVM started failing on Travis
Closes https://github.com/facebook/react-native/pull/7411

Differential Revision: D3265199

fb-gh-sync-id: 6c80210cafb0ec6510073ce913a36eb7edcac2c6
fbshipit-source-id: 6c80210cafb0ec6510073ce913a36eb7edcac2c6
2016-05-23 12:25:23 +01:00
Mike Grabowski 8714c9bc9e [0.26.1] Bump version numbers 2016-05-22 00:58:37 +02:00
Martín Bigio 01d6dd5033 Avoid clearing out factory on DEV mode
Summary:
grabbou pointed out this issue.

We recently started cleaning out the factory function after module are required to save some memory. This broke HMR on some edge cases because sometimes the factory function may need to be re-executed. This PR just wraps the optimization into `__DEV__` to make sure we don't use it while developing.
Closes https://github.com/facebook/react-native/pull/7568

Differential Revision: D3305120

Pulled By: martinbigio

fbshipit-source-id: 741cffbb327d118f0bd0ec34dc1af53d4f94880e
2016-05-21 23:30:59 +02:00
Martín Bigio f5b79fdbf9 Reset hasError flag after HMR request
Summary:
This got broken recently. As a result of this, when a module throws while being required, either by regular load or hot reload, the module object is marked as `hasError`. Form that point all subsequent HMR updates will fail because it will think the module failed while executing the factory but the failure could have been on an old run of an old factory.

The fix is very simple: just reset `hasError` to false when accepting a module.
Closes https://github.com/facebook/react-native/pull/7567

Differential Revision: D3310685

fbshipit-source-id: 2f0b48ab7432b7c221d0c88a019a28969a8862b2
2016-05-21 23:30:27 +02:00
Joe Noon 9cc5cf525d cherry-pick 0e997c6eab: (#7665)
fixes a bug where NavigationPropTypes.SceneRenderer was a plain object
2016-05-20 18:08:07 -07:00
Konstantin Raev 7b54b8e06b [0.26.0] Bump version numbers 2016-05-18 23:15:38 +01:00
Konstantin Raev 65259d1c4f Made npm deployment to be independent of git tags cache
Current implementation of publish-npm script is not flexible in CircleCI because it does not update local tags.
This script fetches tags from origin allowing to republish tags e.g. v0.26.0 even if Circle cached it from another build.
2016-05-18 23:14:29 +01:00
Konstantin Raev 34c034298d [0.26.1] Bump version numbers 2016-05-18 21:09:01 +01:00
Konstantin Raev 08f6b2e549 disabled more flow 2016-05-18 20:20:54 +01:00
Konstantin Raev 673b4609f3 disabled flow check in e2e because it started to crash in CI 2016-05-18 19:53:53 +01:00
Mike Grabowski 72220a33d3 [0.26.0] Bump version numbers 2016-05-18 18:08:32 +02:00
Mike Grabowski 01c506f132 Update upgrade command with 0.26 breaking changes
Summary:
Generally it feels that at some point we will just integrate `rnpm upgrade` directly here, but this is a super temporary quick workaround for the people upgrading to 0.26. We might want to change it later to 0.27 and update this message in case we have any other stuff to upgrade.

![screen shot 2016-05-18 at 14 28 47](https://cloud.githubusercontent.com/assets/2464966/15358460/df3b1b66-1d04-11e6-825c-fa18fa96ee6e.png)

It is supposed to work for 0.26.0, 0.26.1 and all the others up to 0.27.
Closes https://github.com/facebook/react-native/pull/7614

Differential Revision: D3316420

fbshipit-source-id: 3861b4228ee878464e18ba3de1f3e0c12d5f30d1
2016-05-18 18:08:11 +02:00
Mike Grabowski b47831d2db Merge branch '0.26-stable' of github.com:facebook/react-native into 0.26-stable 2016-05-18 13:37:43 +02:00
Nick Lockwood 5a6863e2e6 Added explicit init to observer modules
Summary:
Modules which call JS methods directly, or use `sendDeviceEventWithName:`, can trigger effects in JS without ever being referenced from the JS code. This breaks some assumptions in my earlier diff about when modules can be lazily loaded.

Pending a better solution, I've put explicit `init` methods in these modules to ensure they are eagerly initialized (the downside to this is that they'll still be initialized even if they are never used).

Reviewed By: javache

Differential Revision: D3258232

fb-gh-sync-id: f925bc2e5339c1fbfcc244d4613062c5ab848fc2
fbshipit-source-id: f925bc2e5339c1fbfcc244d4613062c5ab848fc2
2016-05-18 12:56:19 +02:00
Andy Street 791434ae84 Update "This shouldn't be possible. Congratulations." error message
Summary: Apparently this *is* possible. Congratulations to me.

Reviewed By: nicklockwood

Differential Revision: D3281361

fbshipit-source-id: 53c6ab83d959aa8a77880f4f772a7a7d7ccf4950
2016-05-18 12:56:08 +02:00
Ben Alpert ce7b1aabb4 Fix Android picker controlling
Reviewed By: mkonicek

Differential Revision: D3261602

fb-gh-sync-id: da67d28420c5d855d672b481deeb92fa8b5d017c
fbshipit-source-id: da67d28420c5d855d672b481deeb92fa8b5d017c
2016-05-18 12:55:56 +02:00
Christine Abernathy 2a236534cd Display platform-specific examples
Summary:
Rebased https://github.com/facebook/react-native/pull/7048

Sending a new PR to check that tests pass.

After adding simulator examples, it appears that some don't show up, ex:
http://facebook.github.io/react-native/docs/text.html#content

This is due to the fact that these examples are split into two platform-specific files. For this reason, the example code isn't being shown. The examples are also missing for TextInput.

**Test plan**

`cd website; npm install; npm start`

![screen shot 2016-05-05 at 12 25 41 pm](https://cloud.githubusercontent.com/assets/346214/15042571/08ee77e8-12bd-11e6-98a6-967dc5fefa07.png)

![screen shot 2016-05-05 at 12 25 20 pm](https://cloud.githubusercontent.com/assets/346214/15042573/119778f4-12bd-11e6-8cdd-fbf217223d45.png)

![screen shot 2016-05-05 at 12 25 35 pm](https://cloud.githubusercontent.com/assets/346214/15042570/071ae992-12bd-11e6-9cf6-5aaba5e7fa17.png)
Closes https://github.com/facebook/react-native/pull/7406

Differential Revision: D3264567

Pulled By: mkonicek

fb-gh-sync-id: cfb73eaed56a7b5c6c84ce313e113393d152e9a1
fbshipit-source-id: cfb73eaed56a7b5c6c84ce313e113393d152e9a1
2016-05-18 12:55:44 +02:00
Christopher Chedeau 99e40b1430 Add link to the survey at the bottom of the page
Summary:
![simulator screen shot may 11 2016 3 03 14 pm](https://cloud.githubusercontent.com/assets/197597/15198889/3374abe6-178f-11e6-95e5-378004ea45aa.png)

<img width="1333" alt="screen shot 2016-05-11 at 3 03 25 pm" src="https://cloud.githubusercontent.com/assets/197597/15198886/2e545a8a-178f-11e6-8fd1-975ca700e49b.png">
Closes https://github.com/facebook/react-native/pull/7524

Reviewed By: JoelMarcey

Differential Revision: D3293684

Pulled By: vjeux

fbshipit-source-id: c0e7d138040eae49c6b7f7398de8d50f0ed2f564
2016-05-12 15:44:27 -07:00
Joel Marcey 89a3894928 Revert "Add docs survey link to site header"
This reverts commit 8ac9718895.

Didn't work on mobile. Coming up with a better way, anyway.
2016-05-11 21:33:44 -07:00
Joel Marcey 8ac9718895 Add docs survey link to site header
Summary:
**Test plan**

Tested locally to see link in header bar and that it takes you to survey.

![screenshot 2016-05-11 08 21 11](https://cloud.githubusercontent.com/assets/3757713/15186299/593fd4f6-1751-11e6-847f-ea73ce4e2809.png)
Closes https://github.com/facebook/react-native/pull/7514

Differential Revision: D3287859

fbshipit-source-id: 48dfdbae74622330f192d5763c5e47025f1887b1
2016-05-11 12:21:47 -07:00
Joel Marcey 13fb5e830c Getting Started Cleanup
Summary:
1. Remove note about upgrading Homebrew packages. That was kind of noisy.
2. Use local images instead of those stored on Akamai.
3. Add wording for modifying test project about actually opening a file.
4. Add note about keeping initial defaults for Android Studio install in tact.

Tested site locally. Images and new wording appeared as expected.
Closes https://github.com/facebook/react-native/pull/7477

Reviewed By: vjeux

Differential Revision: D3281639

Pulled By: JoelMarcey

fbshipit-source-id: ca956d97293ac3793431cb54f3560ee3e52c0dce
2016-05-10 12:50:07 -07:00
Nurym Kudaibergen 0bc5ed2650 Updated Babel supported transformations link
Summary:
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:

(You can skip this if you're fixing a typo or adding an app to the Showcase.)

Explain the **motivation** for making this change. What existing problem does the pull request solve?

Prefer **small pull requests**. These are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.

**Test plan (required)**

Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.

Make sure tests pass on both Travis and Circle CI.

**Code formatting**

Look around. Match the style of the rest of the codebase. See also the simple [style guide](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#style-guide).

For more info, see the ["Pull Requests" section of our "Contributing" guidelines](https://github.com/facebook/react-native/blob/mas
Closes https://github.com/facebook/react-native/pull/7485

Differential Revision: D3281418

Pulled By: vjeux

fbshipit-source-id: 287b66f1ed9690bf488cf646f8eaf02e2956caa5
2016-05-10 12:50:01 -07:00
Will Fong d8ff7f2d8e Add troubleshooting and modification for linux
Summary:
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:

(You can skip this if you're fixing a typo or adding an app to the Showcase.)

Explain the **motivation** for making this change. What existing problem does the pull request solve?

Prefer **small pull requests**. These are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.

**Test plan (required)**

Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.

Make sure tests pass on both Travis and Circle CI.

**Code formatting**

Look around. Match the style of the rest of the codebase. See also the simple [style guide](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#style-guide).

For more info, see the ["Pull Requests" section of our "Contributing" guidelines](https://github.com/facebook/react-native/blob/mas
Closes https://github.com/facebook/react-native/pull/7471

Differential Revision: D3276360

Pulled By: JoelMarcey

fb-gh-sync-id: 30edd7086a3c4b88695dc91af76ef56d43306ce9
fbshipit-source-id: 30edd7086a3c4b88695dc91af76ef56d43306ce9
2016-05-10 12:49:56 -07:00
Atif Mansoor 02f7ef0458 Fix bug on GettingStarted.md page when clicking nav buttons in FF
Summary:
Hi,
The [commit](https://github.com/facebook/react-native/commit/156d3ed7a290a7d0576c7e6d2b3fc03681d71ee9?_pjax=%23js-repo-pjax-container) by JoelMarcey is much appreciated.  However, when you click on the nav buttons in Firefox (v46.0.1, I'm on El-Capitan), it will switch the content but also navigate you to the React-Native homepage.  This doesn't happen in Chrome, so that's how it probably slipped through.
I propose these changes to fix that.

**Test plan**
Tested locally on FF and Chrome on El-Capitan
Closes https://github.com/facebook/react-native/pull/7435

Differential Revision: D3276285

Pulled By: vjeux

fb-gh-sync-id: c9a14059e609297fe273d02fe6c0a5f98ec7060c
fbshipit-source-id: c9a14059e609297fe273d02fe6c0a5f98ec7060c
2016-05-10 12:49:49 -07:00
Will Fong 874dafcee9 Fix typo (.bash instead of .bashrc)
Summary: Closes https://github.com/facebook/react-native/pull/7464

Differential Revision: D3275748

fb-gh-sync-id: a59e6f54425906c4018f122174a86d80afa021eb
fbshipit-source-id: a59e6f54425906c4018f122174a86d80afa021eb
2016-05-10 12:49:44 -07:00
MIYOKAWA, Nobuyoshi 17f9d4d246 replace XCode to Xcode.
Summary:
Fixing very trivial typos.  'XCode' should be 'Xcode'.
Closes https://github.com/facebook/react-native/pull/7451

Differential Revision: D3275295

fb-gh-sync-id: 440972364229ca980e5211277baa342a20ac5d94
fbshipit-source-id: 440972364229ca980e5211277baa342a20ac5d94
2016-05-10 12:49:38 -07:00
Joel Marcey 6997817e10 Refactor getting started navigation and information based on platform
Summary:
This simplifies the Quick Start section of the React Native documentation into
two pages. A Getting Started and a Tutorial.

The Getting Started page uses some CSS and Javascript magic (thanks vjeux for
the initial infra for this!!) to allow selection between platforms and have
instructions for Getting Started with React Native be shown according to the
selection -- all within the same page, realtime. A much cleaner interface.

I have made a pretty large presentation and information overhaul for each
platform as well. For example, requiring Android Studio for Android
development to make the Android SDK and build tools installation easier.
I added more screenshots to the Android sections since they are more complicated
than the more straightforward iOS. Screenshots for Android for Windows, Linux and
iOS are available now.

Some of the other pages such as `GettingStartedOnLinux` are now obsolete and deleted.

** Test Plan **

Tested locally and navigation works.
Closes https://github.com/facebook/react-native/pull/7418

Differential Revision: D3268621

Pulled By: vjeux

fb-gh-sync-id: 65f9181c9f959fadeffd254efddc5b64816eb1f4
fbshipit-source-id: 65f9181c9f959fadeffd254efddc5b64816eb1f4
2016-05-06 07:35:07 -07:00
Mike Grabowski dd6df71678 [0.26.0-rc] Bump version numbers 2016-05-04 15:07:38 +02:00
Lim Chee Aun aebf4db45a Update HackerWeb in showcase
Summary:
Tiny little update: adding another blog post link on [how I build the Android app](http://cheeaun.com/blog/2016/05/building-hackerweb-android/).
Closes https://github.com/facebook/react-native/pull/7331

Differential Revision: D3258039

fb-gh-sync-id: f33a0b77f32cf18377741e0771db4189479350f3
fbshipit-source-id: f33a0b77f32cf18377741e0771db4189479350f3
2016-05-04 05:41:25 -07:00
Konstantin Raev ec5016ad8f Fixed path to regenerator-runtime
Summary:
Since 0.8.43 regenerator has regenerator-runtime dependency.
Fixes one js test in trunk
Closes https://github.com/facebook/react-native/pull/7351

Reviewed By: davidaurelio

Differential Revision: D3252699

Pulled By: bestander

fb-gh-sync-id: cedb122eb8e9f3a5e40a5313482bc2282511c71e
fbshipit-source-id: cedb122eb8e9f3a5e40a5313482bc2282511c71e
2016-05-04 05:19:31 -07:00
David Aurelio 46d98e1d68 remove support for process.platform
Reviewed By: javache

Differential Revision: D3252666

fb-gh-sync-id: af0e4987c34f43ec2472cbdf52fc112b81050513
fbshipit-source-id: af0e4987c34f43ec2472cbdf52fc112b81050513
2016-05-04 02:51:26 -07:00
Krzysztof Magiera 6c80f886ae Fix setValue to work properly on natively driven nodes
Summary:
This change fixes an issue with calling `setValue` for natively driven nodes. As of now an attempt to call this method from JS would trigger an error "Attempting to run JS driven animation on animated". That is because for natively animated nodes we don't allow for `setNativeProps` to be executed and method `_flush` is now responsible for triggering that call. To fix the issue we add extra flag to `_updateValue` method that indicates if we should be "flushing" updated values using `setNativeProps` and we pass an appropriate value depending on the status of the node (native/non-native). Note that in animation callback we always pass `true` - that is because natively driven animations will never call into that callback.

**Test Plan**
Run JS tests: `npm test Libraries/Animated/src/__tests__/AnimatedNative-test.js`
Closes https://github.com/facebook/react-native/pull/7138

Differential Revision: D3257696

fb-gh-sync-id: 13ec26bc36b56b3208f4279a95532bbe60551087
fbshipit-source-id: 13ec26bc36b56b3208f4279a95532bbe60551087
2016-05-04 02:48:22 -07:00
jsdevel d4cc5b53c7 Setting current working directory for dev server.
Summary:
* This allows `react-native` to work for users on fedora.
* `react-native run-android` was failing because the launch packager script was unable to find packager.sh (see `source` in `man bash`).
* This change sets cwd for the dev server when run with `run-android`.
Closes https://github.com/facebook/react-native/pull/7316

Differential Revision: D3255866

fb-gh-sync-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637
fbshipit-source-id: 88f6b18f7c61636ce8fecef77f7f4e60b1d9a637
2016-05-04 02:45:29 -07:00
Thierry DEN HARTOG 80fc98cd61 Add new application "Chemin de Fer de Provence"
Summary: Closes https://github.com/facebook/react-native/pull/7357

Differential Revision: D3258040

fb-gh-sync-id: 65580e81d293ddf2e371879b85ab32fe4edfeee1
fbshipit-source-id: 65580e81d293ddf2e371879b85ab32fe4edfeee1
2016-05-04 02:13:28 -07:00
Damien Varron 048775c34b add damusnet to React Native GitHub Issue Task Force
Summary: Closes https://github.com/facebook/react-native/pull/7354

Differential Revision: D3257999

fb-gh-sync-id: 102d761d3aac50a8bcef82bcd1ce5919a5681dbf
fbshipit-source-id: 102d761d3aac50a8bcef82bcd1ce5919a5681dbf
2016-05-04 01:08:21 -07:00
Griffin Smith 5723915eaa Remove all null values for request headers
Summary:
NSMutableURLRequest appears to be running `[headerValue count]` on every value of the NSDictionary that `allHTTPHeaderFields` is set to, meaning that any `null` values passed to headers in an XHR throw an exception.  This differs from the implementation of XHR in browsers, which just ignore any `null` values for headers.

PR doesn't currently include tests, happy to add those if this is something you'd consider merging
Closes https://github.com/facebook/react-native/pull/6903

Differential Revision: D3256727

fb-gh-sync-id: 58e8db9c86a1fe7fbd95cba7dcf916957d179e0c
fbshipit-source-id: 58e8db9c86a1fe7fbd95cba7dcf916957d179e0c
2016-05-03 23:42:26 -07:00
Caio Hamamura 9ca8c09d62 Removed repeated "To"
Summary:
Just a simple word repetition fix in docs.
Closes https://github.com/facebook/react-native/pull/7352

Differential Revision: D3257587

fb-gh-sync-id: a54f38f3bbed9b50cb9c1f8a35d5718bad3deb33
fbshipit-source-id: a54f38f3bbed9b50cb9c1f8a35d5718bad3deb33
2016-05-03 21:55:24 -07:00
Anshul Agarwal 60ee25c554 Correct activity request code
Summary:
Change activity request code to IMAGE_PICKER_REQUEST in currentActivity.startActivityForResult(chooserIntent, IMAGE_PICKER_REQUEST);
Closes https://github.com/facebook/react-native/pull/7347

Differential Revision: D3257586

fb-gh-sync-id: fc92fb0bd3a66371fac22234b8a8b693a23fbf24
fbshipit-source-id: fc92fb0bd3a66371fac22234b8a8b693a23fbf24
2016-05-03 21:50:27 -07:00
Srikanth K Hari bf8b5499bb android websocket: include cookies with request
Summary:
Previously cookie headers weren't sending on websocket connection requests for android.
This commit fixes the issue.
Closes https://github.com/facebook/react-native/pull/6851

Differential Revision: D3257466

fb-gh-sync-id: 4225d11c8c6efd09493ef938a65f024dcbaff749
fbshipit-source-id: 4225d11c8c6efd09493ef938a65f024dcbaff749
2016-05-03 21:12:29 -07:00
James Ide 861dfb5d71 Update Exponent logo and links
Summary: Closes https://github.com/facebook/react-native/pull/7371

Differential Revision: D3257406

fb-gh-sync-id: 45d8800e84c19444ab0b2f24311b019e377fc776
fbshipit-source-id: 45d8800e84c19444ab0b2f24311b019e377fc776
2016-05-03 21:08:20 -07:00
Digeff 785cc07589 Change the Debug Menu string from Debug/Stop JS Remotely to Debug/Stop Remote JS
Summary:
Changed debug menu string as requested in: https://github.com/facebook/react-native/pull/5683 by ide and matthewwithanm

![image](https://cloud.githubusercontent.com/assets/14098140/14967128/ab9ca244-106a-11e6-9168-c8e36285dfb1.png)
Closes https://github.com/facebook/react-native/pull/7334

Differential Revision: D3256730

fb-gh-sync-id: 0265d684ef2e216956a0d0a1bdb5295c58126853
fbshipit-source-id: 0265d684ef2e216956a0d0a1bdb5295c58126853
2016-05-03 20:47:23 -07:00
Chris Hopman 24fe8b7e92 Move xplat bridge core to OSS
Reviewed By: mhorowitz

Differential Revision: D3237829

fb-gh-sync-id: 348c7d1e2810400c1259e3d99c2d026da4a39816
fbshipit-source-id: 348c7d1e2810400c1259e3d99c2d026da4a39816
2016-05-03 19:30:48 -07:00
Spencer Ahrens 1d802da7d2 Fix JSWatchdog reset
Reviewed By: ericvicenti

Differential Revision: D3249690

fb-gh-sync-id: 00221d7b3a669b0feb2061b5f6e703339c147172
fbshipit-source-id: 00221d7b3a669b0feb2061b5f6e703339c147172
2016-05-03 19:20:26 -07:00
David Aurelio ee5a1deb0b @ignore-signedsource [react-native-packager] use a single require implementation
Reviewed By: javache, bestander

Differential Revision: D3252718

fb-gh-sync-id: bfd85acc28dd6e2df72a3227743514cb6f8c32f1
fbshipit-source-id: bfd85acc28dd6e2df72a3227743514cb6f8c32f1
2016-05-03 15:19:17 -07:00
Konstantin Raev 1fb8643cb6 Fixes NPE in setFontWeight method
Summary:
We have a crash in prod t11090540, urgent fix same way as in setFontStyle
Closes https://github.com/facebook/react-native/pull/7362

Reviewed By: foghina

Differential Revision: D3254158

Pulled By: dmmiller

fb-gh-sync-id: a497d0d4d0e4df9284e328ebb14fee74ba2f899b
fbshipit-source-id: a497d0d4d0e4df9284e328ebb14fee74ba2f899b
2016-05-03 14:38:18 -07:00
Eric Vicenti bb39a2e9da Reduce extra rendering in NavigationCard
Summary: This adds a new SceneView with a shouldComponentUpdate policy of only re-rendering when the scene's state changes. This allows avoidance of extra re-renders. Results in a much smoother back-swipe gesture because we no longer re-render scenes as we transition from gesture to animation.

Reviewed By: hedgerwang

Differential Revision: D3219545

fb-gh-sync-id: 7c04e0e4ebb40d1e57ef7af11e2e54adf4f52aa0
fbshipit-source-id: 7c04e0e4ebb40d1e57ef7af11e2e54adf4f52aa0
2016-05-03 13:31:18 -07:00
Dave Miller 20d53b1f23 Have Modal dismiss Dialog when the ReactInstance goes away
Reviewed By: angelahess

Differential Revision: D3252808

fb-gh-sync-id: 1f3085412f409581f161cf2151b251e818851d84
fbshipit-source-id: 1f3085412f409581f161cf2151b251e818851d84
2016-05-03 13:29:29 -07:00
Charles Dick 0a7a228fbb Fix crash in adsmanager login by nolonger assuming only one react context exists at once
Reviewed By: lexs

Differential Revision: D3252624

fb-gh-sync-id: e1d1c914be4e0caab953478f12441b440bd1f894
fbshipit-source-id: e1d1c914be4e0caab953478f12441b440bd1f894
2016-05-03 13:28:23 -07:00
Nick Lockwood 34ec6a91a9 Move setBridge: off main thread
Summary:
Previously, if a module implemented `setBridge:` we assumed that it needs to be initialised on the main thread. This assumption was not really warranted however, and it was a barrier to deferring module initialization.

This diff tweaks the rules so that only modules that override `init` or `constantsToExport**` are assumed to require main thread initialization, and others can be created lazily when they are first used.

WARNING: this will be a breaking change to any 3rd party modules that are assuming `setBridge:` is called on the main thread. Those modules should be rewritten to move any code that requires the main thread into `init` or `constantsToExport` instead.

`**` We will also be examining whether `constantsToExport` can be done lazily, but for now any module that uses it will still be created eagerly when the bridge starts up.

Reviewed By: javache

Differential Revision: D3240682

fb-gh-sync-id: 48f309e3158bbccb52141032baf70def3e609371
fbshipit-source-id: 48f309e3158bbccb52141032baf70def3e609371
2016-05-03 09:09:21 -07:00
Yedidya Kennard 55c8158c44 Corrected bug that put the UTI instead of mimeType in retrieved assets
Summary:
This pull request corrects a bug  found in `RCTAssetsLibraryRequestHandler` which used the asset UTI as the mimeType.

The code for finding the mimeType is based on the implementation used in `RCTImageLoader` and `RCTImageUtils`.
Closes https://github.com/facebook/react-native/pull/7349

Differential Revision: D3252796

Pulled By: nicklockwood

fb-gh-sync-id: b9303a99333e4744dfe23045f4a2755307305772
fbshipit-source-id: b9303a99333e4744dfe23045f4a2755307305772
2016-05-03 08:53:34 -07:00
Kelvin Sherlock 46ba1532fd babel-preset - transform-es2015-constants was replaced by check-es2015-constants.
Summary:
The babel plugin transform-es2015-constants was replaced by check-es2015-constants.

References:

T2970
rBW0a3b3b03dbcfc8d1e809a0eaf6270eec8de80763
T3053

This patch updates the babel preset to use check-es2015-constants which should be more future-proof and will receive bug fixes.
Closes https://github.com/facebook/react-native/pull/6943

Reviewed By: davidaurelio

Differential Revision: D3189222

Pulled By: bestander

fb-gh-sync-id: a5ec23e297e1d3591d51641dd567049f4310b107
fbshipit-source-id: a5ec23e297e1d3591d51641dd567049f4310b107
2016-05-03 06:43:27 -07:00
Konstantin Raev 1b9b3ba58c Stabilise tests in SandCastle and prepare for OSS
Reviewed By: mkonicek

Differential Revision: D3244884

fb-gh-sync-id: d96dddca65175a90ee70aeb1c7530cea04860f61
fbshipit-source-id: d96dddca65175a90ee70aeb1c7530cea04860f61
2016-05-03 06:04:46 -07:00
Urban Cvek 50c2467905 Enable setting color of text and images on unselected tabs
Summary:
Hi,
This PR Solves this issue #3083.
This PR solves the problem of default color on TabBar being always grey. Which looks great if the barTintColor is unchanged. However if we set the barTintColor to something else (like blue in example) text and icons become quite unreadable.
![simulator screen shot 27 apr 2016 21 58 40](https://cloud.githubusercontent.com/assets/12081272/14866402/e51c7120-0cc3-11e6-9570-097b686c160f.png)

Commit (c206417) - Enable setting color of unselected tabs
Solves this issue with a prop (unselectedTintColor) on TabBarIOS to which you just pass a color like you can for barTintColor and tintColor.
This leaves us with a result that is on second picture. Notice the color of text on tabs.
![simulator screen shot 27 apr 2016 21 59 06](https://cloud.githubusercontent.com/assets/12081272/14866419/f77aa7e2-0cc3-11e6-8c90-33209009bc09.png)

Or change it to yellow for demonstrating purposes
![simulator screen shot 27 apr 2016 21 59 13](https://cloud.githubusercontent.com/assets/1208
Closes https://github.com/facebook/react-native/pull/7264

Differential Revision: D3240924

Pulled By: nicklockwood

fb-gh-sync-id: 14a0de28abd064756320b7a74f128c255caa6b12
fbshipit-source-id: 14a0de28abd064756320b7a74f128c255caa6b12
2016-05-03 05:40:29 -07:00
Simon Friis Vindum 3e181b85b0 Change "paste" to "type"
Summary:
* Copy-pasting into a terminal _can_ be dangerous. [See this](https://thejh.net/misc/website-terminal-copy-paste). Thus I've changed "paste" to "type". People are probably going to do this anyway but there is not need to suggest copy-pasting `sudo`commands.
* `sudo` is not required to do a global npm install (of course you can do it). Thus I've removed the "sudo" for the flow install command. This is consistent with the general getting started page where `sudo` isn't used in front of `npm install -g` either.
Closes https://github.com/facebook/react-native/pull/7330

Differential Revision: D3252286

fb-gh-sync-id: 7d4580b6bf828e4a833e02365045f3bb9276cfef
fbshipit-source-id: 7d4580b6bf828e4a833e02365045f3bb9276cfef
2016-05-03 01:34:16 -07:00
Hedger Wang 8ac03077c9 better way to manage pointerEvents for NavigationCard.
Reviewed By: fkgozali

Differential Revision: D3250602

fb-gh-sync-id: 6b20d283f8854d0e137800c37595fc014a78e338
fbshipit-source-id: 6b20d283f8854d0e137800c37595fc014a78e338
2016-05-02 19:17:24 -07:00
Jason Prado 79c5322233 Reverted commit D3205106
Summary:
THis addresses the issue as reported at
https://github.com/facebook/react-native/issues/6732

Use a higher order component `NavigationPointerEventsContainer` to manager the
prop `pointerEvents` for `NavigationCard`.

The idea is that the scene's content should not be interactive while the scene is
transitioning.

Reviewed By: ericvicenti

Differential Revision: D3205106

fb-gh-sync-id: db7172941155f34447495199d2c029f5c7e75f30
fbshipit-source-id: db7172941155f34447495199d2c029f5c7e75f30
2016-05-02 14:22:30 -07:00
Hedger Wang 5966ccbcad better way to manage pointerEvents for NavigationCard.
Summary:
THis addresses the issue as reported at
https://github.com/facebook/react-native/issues/6732

Use a higher order component `NavigationPointerEventsContainer` to manager the
prop `pointerEvents` for `NavigationCard`.

The idea is that the scene's content should not be interactive while the scene is
transitioning.

Reviewed By: ericvicenti

Differential Revision: D3205106

fb-gh-sync-id: c0fd22e8c8b83a5952351c5a3a302b2fca5ba5de
fbshipit-source-id: c0fd22e8c8b83a5952351c5a3a302b2fca5ba5de
2016-05-02 12:57:23 -07:00
Mark Oswald bb06536616 call bundle with reset-cache true as default from standard project
Summary:
addition to #7297

When called from an upstarting app, the bundling process should always be called with a cleared cache. That avoids possible problems with cached files.
Closes https://github.com/facebook/react-native/pull/7324

Differential Revision: D3247420

fb-gh-sync-id: 503ad39cb36455512ccea1af7618e89a80942f0c
fbshipit-source-id: 503ad39cb36455512ccea1af7618e89a80942f0c
2016-05-02 08:03:19 -07:00
Damien Brugne 8f295f16b1 Add donut.me chat apps to showcase
Summary:
Adding donut.me chat iOS/Android apps to showcase.
Closes https://github.com/facebook/react-native/pull/7326

Differential Revision: D3247330

fb-gh-sync-id: e90cb89fd673461b15b5389ff180640dff1f0606
fbshipit-source-id: e90cb89fd673461b15b5389ff180640dff1f0606
2016-05-02 04:23:25 -07:00
SangYeob Bono Yu 94a2a9dcde Change app name
Summary: Closes https://github.com/facebook/react-native/pull/7321

Differential Revision: D3247327

fb-gh-sync-id: a9c5a69179724b377e95e0e82861795dab3c8db3
fbshipit-source-id: a9c5a69179724b377e95e0e82861795dab3c8db3
2016-05-02 04:13:19 -07:00
Joshua Pinter 449a81264b Add keys to hash as you need them.
Summary:
Just showing a hash of values is misleading. Makes the user think you can just pass in the values without the keys.
Closes https://github.com/facebook/react-native/pull/7310

Differential Revision: D3245834

fb-gh-sync-id: 39220ed7720e3ff402f2c2ba8bebdefb96bfa203
fbshipit-source-id: 39220ed7720e3ff402f2c2ba8bebdefb96bfa203
2016-04-30 20:40:28 -07:00
Joshua Pinter 4bbd64931b Indicate width and height params are being passed to onContentSizeChange.
Summary:
I had to do a little trial and error to find this out. Would be helpful to have it in the docs.

I'm not sure if there's a standard wording or format you prefer for indicating handler function params.
Closes https://github.com/facebook/react-native/pull/7312

Differential Revision: D3245838

fb-gh-sync-id: 89433c036f7287d9efb69605180734dbc4df4df3
fbshipit-source-id: 89433c036f7287d9efb69605180734dbc4df4df3
2016-04-30 18:28:22 -07:00
Sawyer Hood 9425bcff8f Updated a warning string in upgrade.js
Summary:
I inserted an 'in' in the warning message that is displayed when the user's package.json file doesn't have a valid version number for react native.

Test plan
---------------
-run upgrade.js on a project with an invalid version number.
Closes https://github.com/facebook/react-native/pull/7314

Differential Revision: D3245839

fb-gh-sync-id: e38f3be0884d8c75f9610faced85d5c81c24a49e
fbshipit-source-id: e38f3be0884d8c75f9610faced85d5c81c24a49e
2016-04-30 18:21:17 -07:00
Janic Duplessis f8f9362c05 Reverted commit D3242754
Summary:
This separates the babel config of the local-cli and the packager from the one used by the transforms of the packager since it doesn't run in the same environment and the local-cli/packager doesn't require react specific transforms and runs in node 4 so we can also avoid some es2015 transforms that node already supports.

I had to move the code in cli.js so it can still run in node 0.12 that doesn't support `const` since it is no longer transformed.

**Test plan**
Run the local-cli on node 0.12 and there should be a message saying that it requires at least node 4.
Run the local-cli on node 4 and 5 and everything should work the same as before.

I was also hoping for some perf gains but there was nothing noticeable. I did benchmark the babel-register call and it stayed pretty much the same. As for runtime performance it can help if there are optimisations for es2015 features in node.
Closes https://github.com/facebook/react-native/pull/6155

Differential Revision: D3242754

Pulled By: eczarny

fb-gh-sync-id: 6cd349e284b7d92a1b2cc8b5c0e26adbfb0d9a2f
fbshipit-source-id: 6cd349e284b7d92a1b2cc8b5c0e26adbfb0d9a2f
2016-04-30 16:54:31 -07:00
Janic Duplessis 19429f79b2 Use a separate babel config for the local-cli and the packager
Summary:
This separates the babel config of the local-cli and the packager from the one used by the transforms of the packager since it doesn't run in the same environment and the local-cli/packager doesn't require react specific transforms and runs in node 4 so we can also avoid some es2015 transforms that node already supports.

I had to move the code in cli.js so it can still run in node 0.12 that doesn't support `const` since it is no longer transformed.

**Test plan**
Run the local-cli on node 0.12 and there should be a message saying that it requires at least node 4.
Run the local-cli on node 4 and 5 and everything should work the same as before.

I was also hoping for some perf gains but there was nothing noticeable. I did benchmark the babel-register call and it stayed pretty much the same. As for runtime performance it can help if there are optimisations for es2015 features in node.
Closes https://github.com/facebook/react-native/pull/6155

Differential Revision: D3242754

Pulled By: davidaurelio

fb-gh-sync-id: 02880c841c10562d5f107e1c975d668e55cc619f
fbshipit-source-id: 02880c841c10562d5f107e1c975d668e55cc619f
2016-04-30 16:25:24 -07:00
Zeeshan Mughal 69d5ddd349 Showcase: Add Trump Blocker
Summary: Closes https://github.com/facebook/react-native/pull/6944

Differential Revision: D3245656

fb-gh-sync-id: bab7f4d0dfba1c628e6be8a0b9f369d9f1ef8f70
fbshipit-source-id: bab7f4d0dfba1c628e6be8a0b9f369d9f1ef8f70
2016-04-30 14:40:21 -07:00
Sebastian Markbage ba8878d12c Update react package to stable release
Summary:
react-native is about to do a branch cut for the next stable release. We want
this version to use a stable release of react so we released one.

This should be the same as the previous alpha. The is mostly changes to DOM / testing and not RN:

https://github.com/facebook/react/commits/15.0.2-dev

AFAIK there are no behavior changes to RN.

I had to add ReactPropTransferer from downstream since this moved out of React Core and into www.

Reviewed By: zpao

Differential Revision: D3245046

fb-gh-sync-id: 7e460315699fd5bff36d89751ce94edb75dd4733
fbshipit-source-id: 7e460315699fd5bff36d89751ce94edb75dd4733
2016-04-30 11:58:32 -07:00
Spencer Ahrens 2c3576a50a Refactor connection/list stuff
Reviewed By: devknoll

Differential Revision: D3233991

fb-gh-sync-id: bd10dd2856da6b8fb3bac7a8ec3a7e34eeb58f80
fbshipit-source-id: bd10dd2856da6b8fb3bac7a8ec3a7e34eeb58f80
2016-04-30 10:28:55 -07:00
David Aurelio 34dd17cae5 Add encoding/hash signature to JS files
Reviewed By: tadeuzagallo

Differential Revision: D3241028

fb-gh-sync-id: 737ae64cf3a3f4f121076dbfe933d5fe71e07817
fbshipit-source-id: 737ae64cf3a3f4f121076dbfe933d5fe71e07817
2016-04-30 09:44:23 -07:00
Alessandro Nadalin 8d3d8b3440 Update the PR template
Summary:
Added a link to the contributing.md -- there's a bunch of stuff there that's not mentioned in this template.
Closes https://github.com/facebook/react-native/pull/6899

Differential Revision: D3245105

fb-gh-sync-id: 4d462dded04cf83afdd9b6dddcbc45aa7ecd7cd9
fbshipit-source-id: 4d462dded04cf83afdd9b6dddcbc45aa7ecd7cd9
2016-04-29 21:15:25 -07:00
Dale Jefferson d3fe668e97 Add Calor - Field Pro to the showcase
Summary:
The Calor Field Pro app is an Enterprise React Native iPad application and is not available on the app store, so I link to our website has been provided.
Closes https://github.com/facebook/react-native/pull/7090

Differential Revision: D3245081

fb-gh-sync-id: 9a4d5c581514933b45fcbf8823aec61587cfaaa0
fbshipit-source-id: 9a4d5c581514933b45fcbf8823aec61587cfaaa0
2016-04-29 21:12:25 -07:00
Igor Avramovic 850ce649d4 Render top back and back button on search results
Differential Revision: D3238568

fb-gh-sync-id: d28eee4cefb88a4b43fd3c16357de3443aec6bc5
fbshipit-source-id: d28eee4cefb88a4b43fd3c16357de3443aec6bc5
2016-04-29 17:59:22 -07:00
Konstantin Raev 0c590b325d Revert "fix border style without borderRadius"
Summary:
Subj broke ObjC snapshot tests

This reverts commit 58876d5a03.
Closes https://github.com/facebook/react-native/pull/7303

Differential Revision: D3243670

fb-gh-sync-id: acef6bc7a50b0fa7dc112b88407644e8226d6f85
fbshipit-source-id: acef6bc7a50b0fa7dc112b88407644e8226d6f85
2016-04-29 16:37:23 -07:00
Janic Duplessis 169cfb5a52 Remove the need for allowTopLevelThis in transform-es2015-modules-commonjs
Summary:
This make the transform behave closer to the standard for modules.

This removes the few places that a top level this was used to refer to the global space. It also clean up the usage of `GLOBAL` to use `global` instead as this is what is used everywhere else in the code base. We still define `GLOBAL` for compatibility with other modules.

**Test plan**
Clear the packager cache to make sure the transforms run again. (node ./local-cli/cli.js start --reset-cache).
Run the Movies example (UIExplorer is broken atm) and make sure there are no errors.
Closes https://github.com/facebook/react-native/pull/6255

Differential Revision: D3037227

Pulled By: mkonicek

fb-gh-sync-id: bcf1350ae7a6e92c77d3a87fc9d6e42eb93cb9b9
fbshipit-source-id: bcf1350ae7a6e92c77d3a87fc9d6e42eb93cb9b9
2016-04-29 16:15:34 -07:00
Sebastian Markbage 373537b281 Deprecate transformMatrix and decomposedMatrix
Summary:
transformMatrix only worked on iOS and there is an equivalent API that (mostly)
works cross platform.

decomposedMatrix could technically be passed on Android but it wasn't document and explicitly flagged as not working.

My goal is to deprecate both uses and then the only supported API is the `transform: [{ matrix: ... }]` form.

The only difference is that on Android the matrix gets decomposed.

Currently there is some special cased magic that renames transform -> transformMatrix or decomposedMatrix depending on platform.

https://github.com/facebook/react/blob/master/src/renderers/native/ReactNative/ReactNativeAttributePayload.js#L50

Therefore I'm adding an alias for both native platforms called just "transform".

Next I'll swap over the JS to always target the name "transform". The only difference is how the value is marshalled over the bridge in processTransform.

To do this, I have to clean up a few callers. Mostly that's just swapping to the new API.

For buildInterpolator this is a bit trickier but this fixes it for all our use cases (which is only the Navigator in AdsManager).

Reviewed By: vjeux

Differential Revision: D3239960

fb-gh-sync-id: 838edb6644c6cdd0716834f712042f226ff3136f
fbshipit-source-id: 838edb6644c6cdd0716834f712042f226ff3136f
2016-04-29 14:19:25 -07:00
Jeff Morrison 7e9720f0ae Deploy Flow 0.24.0 to fbsource
Reviewed By: gabelevi

Differential Revision: D3241183

fb-gh-sync-id: a40da6d4d30abf720d0f95d76be803d669fc92c3
fbshipit-source-id: a40da6d4d30abf720d0f95d76be803d669fc92c3
2016-04-29 13:43:27 -07:00
Satyajit Sahoo 06b2d9c4fd Import from React in JavaScriptEnvironment
Summary:
cc sebmarkbage
Closes https://github.com/facebook/react-native/pull/7300

Differential Revision: D3241837

Pulled By: sebmarkbage

fb-gh-sync-id: 48491192ba215d402ebbe4c77124dc75c6f0e0b8
fbshipit-source-id: 48491192ba215d402ebbe4c77124dc75c6f0e0b8
2016-04-29 11:49:24 -07:00
Ronak Patel edf5d85be0 Passing current activity while creating react instance manager
Reviewed By: astreet

Differential Revision: D3236602

fb-gh-sync-id: efbac8f0d8c770f2edf6fb447498e650302d98c7
fbshipit-source-id: efbac8f0d8c770f2edf6fb447498e650302d98c7
2016-04-29 11:46:23 -07:00
Mark Oswald 90f9f48498 add reset-cache command to bundle
Summary:
Currently the `react-native bundle` has no option to reset the file cache. For example changing the .babelrc has no effect on the bundling process. `react-native start` has it already implemented, so this is just a small addition.

**Test plan (required)**

the issue:

- `react-native init` a new project
- run `react-native bundle` (should work as expected)
- create `.babelrc` with empty object ```{}```
- rerun `react-native bundle`
- should fail now with `Unexptected token` (no babel plugins configured)
 - if not failing, your cache already hit (clear $TMPDIR to get the error)
- delete .babelrc and rerun `bundle`
- still failing, but it should went back to normal
- delete your $TMPDIR contents
- works again

The option `--reset-cache` should fix that
Closes https://github.com/facebook/react-native/pull/7297

Differential Revision: D3241259

Pulled By: davidaurelio

fb-gh-sync-id: 0ed5b58aa1f021d72021f4c80fbc57d2e7e8181f
fbshipit-source-id: 0ed5b58aa1f021d72021f4c80fbc57d2e7e8181f
2016-04-29 10:38:29 -07:00
David Aurelio cccb8db175 Unify source map approach for RA bundles on iOS/Android
Reviewed By: javache

Differential Revision: D3229780

fb-gh-sync-id: a3148d7626b32a2e6803ae8c35ac75025a992a32
fbshipit-source-id: a3148d7626b32a2e6803ae8c35ac75025a992a32
2016-04-29 10:16:22 -07:00
Spencer Ahrens 6cae8b7c02 Optimize WindowedListView
Summary:
Reduce re-renders by only looking at `props.data` that we're actually going to render and tracking if `this._rowFrames`
is dirty.

Differential Revision: D3195163

fb-gh-sync-id: 1e17ab410a312a37d4a93b84ea51ca32c3ede839
fbshipit-source-id: 1e17ab410a312a37d4a93b84ea51ca32c3ede839
2016-04-29 10:15:29 -07:00
Shawn Wilsher 856f9e9fed Add --version to local-cli/cli.js
Summary:
[Buck](https://buckbuild.com) has a concept of a versioned tool.  In order to
properly use RN with Buck, the `cli.js` script should return the proper version
when passed `--version`.

Reviewed By: astreet

Differential Revision: D3197207

fb-gh-sync-id: 12ea35587cf492eb89d7dd102e93bdd26bc813c0
fbshipit-source-id: 12ea35587cf492eb89d7dd102e93bdd26bc813c0
2016-04-29 09:25:32 -07:00
Dave Miller 850befa3cd Remove unused code
Reviewed By: davidaurelio

Differential Revision: D3240927

fb-gh-sync-id: b9ecb5269026314905a22eae3b32fd546574c5ef
fbshipit-source-id: b9ecb5269026314905a22eae3b32fd546574c5ef
2016-04-29 08:48:19 -07:00
Erem Zeit 2b191bfab7 Update docs for creating an android native view
Summary:
Doc changes only.  Updating example code to reflect the new requirements discussed in this [issue](https://github.com/facebook/react-native/issues/4605).

In short, in the JS code that registers your new native view, you need to explicitly include the `propTypes` that come default for views or else you get an error.
Closes https://github.com/facebook/react-native/pull/7281

Differential Revision: D3240654

Pulled By: mkonicek

fb-gh-sync-id: f7571ce7435c5b241a17af2822e7e350ce3186cb
fbshipit-source-id: f7571ce7435c5b241a17af2822e7e350ce3186cb
2016-04-29 08:16:23 -07:00
Kudo Chien 708443e50c Add biideal app to showcase
Summary:
Add biideal app to showcase which is my first RN app.
Closes https://github.com/facebook/react-native/pull/7263

Differential Revision: D3240862

Pulled By: mkonicek

fb-gh-sync-id: ba76bc19382f22f03516c02c4e01d48c53ee70f4
fbshipit-source-id: ba76bc19382f22f03516c02c4e01d48c53ee70f4
2016-04-29 07:37:20 -07:00
Charles Dick 24b2990467 Capture heap from the dev menu
Reviewed By: foghina

Differential Revision: D3229856

fb-gh-sync-id: c6321cfb309c93572a51bba625d63246a75f0254
fbshipit-source-id: c6321cfb309c93572a51bba625d63246a75f0254
2016-04-29 07:35:22 -07:00
alvaromb 84e696867b Added badge icon number and alert action
Summary:
Added support for setting an optional badge icon number and alert action when using local notifications.
Closes https://github.com/facebook/react-native/pull/2931

Differential Revision: D3212448

Pulled By: mkonicek

fb-gh-sync-id: 063efcdd259b2a43f39812f57a71e8489ab33653
fbshipit-source-id: 063efcdd259b2a43f39812f57a71e8489ab33653
2016-04-29 05:37:27 -07:00
Martin Konicek 12caa363a1 Remove 'react-native link'
Summary:
`react-native link` was an early experiment, [rnpm](https://github.com/rnpm/rnpm) does this much better. After merging this PR we should merge rnpm so that `react-native link` works again :)

grabbou Kureev Just making some space here :)

This reverts 4e5a2bc079.

**Test Plan**

e2e tests on Travis and CircleCI
Closes https://github.com/facebook/react-native/pull/7290

Differential Revision: D3240702

Pulled By: mkonicek

fb-gh-sync-id: 6aac83fac599ba3db0dd0a7ac48653ebabd93491
fbshipit-source-id: 6aac83fac599ba3db0dd0a7ac48653ebabd93491
2016-04-29 05:27:28 -07:00
Jagdeep Nagpal 3d0d426d46 Renamed --flavor to --variant
Summary:
This small update to runAndroid.js which renames --flavor to --variant.
~~`react-native run-android --flavor=staging`~~

~~doesn't work as it needs build type as well~~

~~so at present it needs to be like this~~

~~`react-native run-android --flavor=stagingDebug`~~

~~it looks messy, instead if we want to use the original spec then Debug must be concatenated to the end all the time as run-android was speced to trigger only debug builds~~
Closes https://github.com/facebook/react-native/pull/7036

Differential Revision: D3240692

Pulled By: mkonicek

fb-gh-sync-id: ef4570797b53ac8f76d0b86a263916ac5bdb0581
fbshipit-source-id: ef4570797b53ac8f76d0b86a263916ac5bdb0581
2016-04-29 05:18:24 -07:00
Jean Regisser 0045e07928 Updated iOS native UI component events documentation
Summary:
Documentation on iOS about triggering events from native components was outdated.

Let me know what you think.
Closes https://github.com/facebook/react-native/pull/6739

Differential Revision: D3240665

Pulled By: mkonicek

fb-gh-sync-id: f62d52bebd58aae6f93388734338ef74ae536ec5
fbshipit-source-id: f62d52bebd58aae6f93388734338ef74ae536ec5
2016-04-29 05:11:59 -07:00
Konstantin Raev f99786cc89 Made SandCastle run the same Instrumentation Tests that are open sourced and are running on CI
Reviewed By: mkonicek

Differential Revision: D3229774

fb-gh-sync-id: 48239e8898eb011ad767bf102aa65025351363c6
fbshipit-source-id: 48239e8898eb011ad767bf102aa65025351363c6
2016-04-29 05:11:59 -07:00
Sokovikov 58876d5a03 fix border style without borderRadius
Summary:
closes #6721 closes #3159
before(without borderRadius)
![bug](https://cloud.githubusercontent.com/assets/1488195/14235087/fcf79f8a-f9eb-11e5-9d44-7ab1d131be24.jpg)

after
![fix](https://cloud.githubusercontent.com/assets/1488195/14235067/8cf128b4-f9eb-11e5-8170-ad3a146d6104.jpg)
Closes https://github.com/facebook/react-native/pull/6789

Differential Revision: D3240657

Pulled By: mkonicek

fb-gh-sync-id: 4eb8f72d7278d880297fb73653ef530719af3d5b
fbshipit-source-id: 4eb8f72d7278d880297fb73653ef530719af3d5b
2016-04-29 04:53:29 -07:00
David Aurelio 8375778496 Upgrade node-haste to 2.10.1
Reviewed By: bestander

Differential Revision: D3238180

fb-gh-sync-id: 06d62a5855864301a5480e349cfec2c0a2d5b79f
fbshipit-source-id: 06d62a5855864301a5480e349cfec2c0a2d5b79f
2016-04-29 04:44:32 -07:00
Janic Duplessis 891b87e7fb Launch the packager with react-native run-android on Windows
Summary:
Adds support for launching the packager in a new window on Windows.

**Test plan (required)**

Tested that the packager is launched in a completely independent process. This means that exiting the `react-native run-android` command should not close the packager window and it should exit properly when completed even if the packager window is still opened. Pretty much made sure it behaves exactly like on mac.

Also tested that an error in the packager will not close the window immediately to show the error stack trace.
Closes https://github.com/facebook/react-native/pull/7129

Differential Revision: D3240628

Pulled By: mkonicek

fb-gh-sync-id: 007582250536481d2b2376f9a201f8f415fc1080
fbshipit-source-id: 007582250536481d2b2376f9a201f8f415fc1080
2016-04-29 04:14:22 -07:00
Dave Miller 3a5457cd7c Add support for setChildren
Summary: This adds support for UIManager.setChildren on Android like D2757388 added for iOS.

Reviewed By: andreicoman11

Differential Revision: D3235369

fb-gh-sync-id: b538556ec4abdb606f9be26d1b74734046bca0cd
fbshipit-source-id: b538556ec4abdb606f9be26d1b74734046bca0cd
2016-04-29 04:03:24 -07:00
Kudo Chien 3f0207d7b5 Fix textShadowOffset error without width or height
Summary:
textShadowOffset design is `ReactPropTypes.shape({width: ReactPropTypes.number, height: ReactPropTypes.number})`, so either width or height is optional.
Unfortunately, in Android implementation, it is my bad not handling optional case and lead to an exception.
Thanks kohver for reporting [this issue](https://github.com/facebook/react-native/pull/4975#issuecomment-213006641)

**Test plan (required)**

*Before this fix*
1. Modify TextExample.android.js to `<Text style={{fontSize: 20, textShadowOffset: {height: 10}, textShadowRadius: 1, textShadowColor: '#00cccc'}}>` which really raise a redbox.

*After this fix*
1. Test original TextExample.android.js textShadowOffset works well.
2. Modify TextExample.android.js to `<Text style={{fontSize: 20, textShadowOffset: {height: 10}, textShadowRadius: 1, textShadowColor: '#00cccc'}}>` which works well without redbox.
Closes https://github.com/facebook/react-native/pull/7119

Differential Revision: D3240607

Pulled By: mkonicek

fb-gh-sync-id: b13221ae1586594890b0f4aa644ace7c0d5d6c58
fbshipit-source-id: b13221ae1586594890b0f4aa644ace7c0d5d6c58
2016-04-29 03:50:29 -07:00
Joshua Pinter 5e5cbda682 Show default activeOpacity value in docs.
Summary:
Useful to know what the default value without having to dig into the library code.
Closes https://github.com/facebook/react-native/pull/7247

Differential Revision: D3228728

Pulled By: mkonicek

fb-gh-sync-id: 433ca41d5395bbfb0c4887641a9e8b99c87b5e2b
fbshipit-source-id: 433ca41d5395bbfb0c4887641a9e8b99c87b5e2b
2016-04-29 03:45:26 -07:00
Alex Ledak cea37b460f Add 'New Music' app to showcase
Summary: Closes https://github.com/facebook/react-native/pull/7285

Differential Revision: D3240438

fb-gh-sync-id: 02304618215c46197fa5d7547ffdb950502bcf28
fbshipit-source-id: 02304618215c46197fa5d7547ffdb950502bcf28
2016-04-29 01:18:29 -07:00
Jesse Sessler 2bb1c263db Modal Animation Types
Summary:
Currently the Modal component uses the slide up / down animation for presenting and hiding the Modal with no options. This PR gives users a choice to use a fade in / out animation or the current slide animation (slide is the default). Android and iOS.

![](http://g.recordit.co/nfJSg487Ox.gif)  ![](http://g.recordit.co/QHGDuUFbPy.gif)

I've updated the UIExplorer and documentation.

![image](https://cloud.githubusercontent.com/assets/4265163/14743130/0bd8282c-086e-11e6-93eb-3d344431337d.png)

Thanks!
Closes https://github.com/facebook/react-native/pull/7156

Differential Revision: D3237809

Pulled By: javache

fb-gh-sync-id: 813e56ada8b19990dc5018527dc3a81b2c8b349a
fbshipit-source-id: 813e56ada8b19990dc5018527dc3a81b2c8b349a
2016-04-28 16:00:32 -07:00
Philipp von Weitershausen b5f14ea8f1 Make XMLHttpRequest and XMLHttpRequest.upload proper EventTargets
Summary:
So far, XHR only supports a few `onfoo` event handlers, not the entier `EventTarget` interface (`addEventListener`, `removeEventListener`). It also doesn't support the `upload` object on Android -- for no good reason. Even if we don't send any events there yet, there's no reason we have to break consuming code that wants to register an event handler there. This PR rectifies all that.

Fortunately, adding proper `EventTarget` support is very easy thanks to `event-target-shim`. We already use it in our WebSocket implementation. It transparently handles the `addEventListener('foo', ...)` as well as `onfoo` APIs, so when you dispatch an event on the event target, the right handlers will be invoked. The event object is wrapped so that `event.target` is set properly. Basically, it's a super easy way to make us conform to the spec.

Also added a bit of polish here and there, using ES2015 class property goodness to consolidate a lot of Flow property definitions with the corresponding property initializers.

**T
Closes https://github.com/facebook/react-native/pull/7017

Reviewed By: fkgozali

Differential Revision: D3202021

Pulled By: martinbigio

fb-gh-sync-id: 2b007682074356c75c774fab337672918b6c4355
fbshipit-source-id: 2b007682074356c75c774fab337672918b6c4355
2016-04-28 15:59:26 -07:00
Michael Ortiz 13acd7ed7e Reverted commit D3234404
Summary:
**Motivation**: Arc drawing has been broken on Android for some time. dgladkov submitted a PR, which ended up having a bug and was never merged. This PR should fix that bug as well as provide screenshots to prove it works.

**Reproducing the Bug:** dgladkov made a simple test app which helps to illustrate the bug. The repo can be found [here](https://github.com/dgladkov/RNArtArcDrawingBug). The demo app illustrates that on iOS, wedges are drawn correctly, but Android only draws full circles. [Direct Link to iOS Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/ios.png). [Direct Link to Android Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/android.png).

**Proof The Bug is Fixed:** [Here is a direct link to Android After pic.](http://i.imgur.com/9dTU2Xn.png) You can see the wedges match the iOS Before screenshot.

**What went wrong:** dgladkov's solution relied on Java's modulus, which in fact, implements modulus in a non-standard way. Modulus should a
Closes https://github.com/facebook/react-native/pull/7049

Differential Revision: D3234404

Pulled By: spicyj

fb-gh-sync-id: 6b85eb42389da6c344ec9723c7f81f61473246b0
fbshipit-source-id: 6b85eb42389da6c344ec9723c7f81f61473246b0
2016-04-28 15:48:26 -07:00
Pieter De Baets 26d0ce929f Error handling for concrete JS executor
Reviewed By: adamjernst

Differential Revision: D3235189

fb-gh-sync-id: a6d545a6b0b388c52305e2936371776d579460cd
fbshipit-source-id: a6d545a6b0b388c52305e2936371776d579460cd
2016-04-28 13:42:30 -07:00
Bruno Barbieri 41e89b4129 fontFamily, fontStyle and fontWeight support for TextInput
Summary:
fontFamily, fontWeight and fontStyle properties are being ignored for TextInput.

There's an additional issue that happens when you add secureTextEntry={true}  it overrides the current font preferences (because it defaults to monospace) so we have to reapply it.
Master right now:

![screen shot 2016-03-21 at 6 21 05 pm](https://cloud.githubusercontent.com/assets/1247834/13936110/c25ffea8-ef91-11e5-8d71-1b0a55184e24.png)

Demo after the fix:

![5ux4bpjfwh](https://cloud.githubusercontent.com/assets/1247834/13935865/0f2ca8be-ef90-11e5-82c7-d5a2dd33b70e.gif)
Closes https://github.com/facebook/react-native/pull/6564

Differential Revision: D3081623

Pulled By: bestander

fb-gh-sync-id: 329cac6755b5a0dd549e546768f39efa7b7f4daa
fbshipit-source-id: 329cac6755b5a0dd549e546768f39efa7b7f4daa
2016-04-28 13:22:22 -07:00
Jean Regisser 037e9ba945 Fixed unable to open red box stack frame in editor when running on iOS device
Summary:
Hi,

I noticed touching stack frames from the red box when running from an iOS device wouldn't open my editor (was working fine from the simulator).
Here's a fix.

Let me know if everything looks correct.

Thanks,
Closes https://github.com/facebook/react-native/pull/7088

Differential Revision: D3235102

Pulled By: javache

fb-gh-sync-id: 06e6c3f9164e987ea9bf71d16fe360dc37036c8d
fbshipit-source-id: 06e6c3f9164e987ea9bf71d16fe360dc37036c8d
2016-04-28 11:39:18 -07:00
David Aurelio e6bafca39e Improve constant inlining, add process.platform
Reviewed By: bestander

Differential Revision: D3235716

fb-gh-sync-id: f9019ec0042827e409fa84ba74f4c426ccad1519
fbshipit-source-id: f9019ec0042827e409fa84ba74f4c426ccad1519
2016-04-28 11:23:21 -07:00
Nathan Spaun 4e05d00f0d Prefetch images in Group mall and reactions icons
Reviewed By: ericvicenti

Differential Revision: D3227821

fb-gh-sync-id: b7a8c3e6e82604b98ec0d25eaab0c3b4c95bd683
fbshipit-source-id: b7a8c3e6e82604b98ec0d25eaab0c3b4c95bd683
2016-04-28 11:12:21 -07:00
Nick Lockwood 8cfa6b6ea6 Deprecated customDirectEventTypes, and removed from RCTScrollViewManager
Summary: Using customDirectEventTypes or customBubblingEventTypes causes a viewmanager to be initialized at app start. This diff deprecates those methods and removes their usage from RCTScrollViewManager.

Reviewed By: majak

Differential Revision: D3218973

fb-gh-sync-id: 295bef3be9623b49b0cdcbf8a56e10d9b28126d9
fbshipit-source-id: 295bef3be9623b49b0cdcbf8a56e10d9b28126d9
2016-04-28 07:44:19 -07:00
Pieter De Baets b2c8281316 Remove ImmediateImplementation, always use globals
Summary: We always define these globals in InitializeJavaScriptAppEngine, so the fallback mechanism here is never required as far as I can tell.

Reviewed By: davidaurelio

Differential Revision: D3235061

fb-gh-sync-id: 92007f87c84073e32bfa946df8ee81083f6842ec
fbshipit-source-id: 92007f87c84073e32bfa946df8ee81083f6842ec
2016-04-28 07:06:20 -07:00
Pieter De Baets c7eb47fd8c Enable console.debug
Summary: Apparently what we're using for console.trace is not really the same as what Chrome does (we don't log a stacktrace). Add `console.debug` with the same functionality as `console.trace`, just so we don't crash between browser and local execution.

Reviewed By: davidaurelio

Differential Revision: D3235053

fb-gh-sync-id: 4bed17ac8aa4c8c100f15cf0aabbc25101c913c1
fbshipit-source-id: 4bed17ac8aa4c8c100f15cf0aabbc25101c913c1
2016-04-28 07:02:29 -07:00
Pieter De Baets e195bf9495 Fix RCTJavaScriptContextCreatedNotification
Summary: The notification was previously sent from a block that only existed if RCT_DEV. This makes us always send this notification.

Reviewed By: majak

Differential Revision: D3235070

fb-gh-sync-id: bf3488d439bc2253fd12cbb10f670f54bb37eb6e
fbshipit-source-id: bf3488d439bc2253fd12cbb10f670f54bb37eb6e
2016-04-28 06:59:21 -07:00
David Aurelio e3c18c3990 Upgrade to node-haste@2.10.0 and allow to specify extra node modules
Summary: This upgrades to node-haste@2.10.0 and allows to expose folders as additional node modules from rn-cli.config.js

Reviewed By: bestander

Differential Revision: D3232595

fb-gh-sync-id: dffca66fec55a79a2b3af1d6ec1b8799b2bbcf59
fbshipit-source-id: dffca66fec55a79a2b3af1d6ec1b8799b2bbcf59
2016-04-28 06:33:27 -07:00
Pieter De Baets feda8ce2ee Clean up RCTEventDispatcher code
Reviewed By: majak

Differential Revision: D3175583

fb-gh-sync-id: c751c9dc79edfd9cb6073a2ff5dd743a03334bc4
fbshipit-source-id: c751c9dc79edfd9cb6073a2ff5dd743a03334bc4
2016-04-28 05:48:21 -07:00
Charles Dick f6d9a9097f Add heap snapshot to fbandroid JSC
Reviewed By: michalgr

Differential Revision: D3168026

fb-gh-sync-id: 123c9caa1ae7792cfa93590de4832b76c8178edb
fbshipit-source-id: 123c9caa1ae7792cfa93590de4832b76c8178edb
2016-04-28 05:31:19 -07:00
David Aurelio 8c1b773e4d Show columns in redboxes
Reviewed By: foghina

Differential Revision: D3229814

fb-gh-sync-id: 0e1c3692e0780287d5e31dbd24fa3145eb0882ec
fbshipit-source-id: 0e1c3692e0780287d5e31dbd24fa3145eb0882ec
2016-04-28 03:58:23 -07:00
Thomas Leplus f323b02eff Fix ClassCastException
Summary: Closes https://github.com/facebook/react-native/pull/7225

Differential Revision: D3234878

Pulled By: dmmiller

fb-gh-sync-id: 00f36f3c45e3492026729175e393812879149773
fbshipit-source-id: 00f36f3c45e3492026729175e393812879149773
2016-04-28 03:19:19 -07:00
Michael Ortiz 1af47603cf Fix ReactNativeART arc drawing on Android
Summary:
**Motivation**: Arc drawing has been broken on Android for some time. dgladkov submitted a PR, which ended up having a bug and was never merged. This PR should fix that bug as well as provide screenshots to prove it works.

**Reproducing the Bug:** dgladkov made a simple test app which helps to illustrate the bug. The repo can be found [here](https://github.com/dgladkov/RNArtArcDrawingBug). The demo app illustrates that on iOS, wedges are drawn correctly, but Android only draws full circles. [Direct Link to iOS Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/ios.png). [Direct Link to Android Before](https://github.com/dgladkov/RNArtArcDrawingBug/blob/master/images/android.png).

**Proof The Bug is Fixed:** [Here is a direct link to Android After pic.](http://i.imgur.com/9dTU2Xn.png) You can see the wedges match the iOS Before screenshot.

**What went wrong:** dgladkov's solution relied on Java's modulus, which in fact, implements modulus in a non-standard way. Modulus should a
Closes https://github.com/facebook/react-native/pull/7049

Differential Revision: D3234404

Pulled By: spicyj

fb-gh-sync-id: 4974b818dc49d9d16f2483c49b462c459a8bb479
fbshipit-source-id: 4974b818dc49d9d16f2483c49b462c459a8bb479
2016-04-27 22:18:27 -07:00
Christoph Pojer d363b1f2e2 Update Jest APIs on fbsource
Reviewed By: javache

Differential Revision: D3229435

fb-gh-sync-id: b0e252d69e1f399a946fca6e98ef62ff44c2ef9c
fbshipit-source-id: b0e252d69e1f399a946fca6e98ef62ff44c2ef9c
2016-04-27 19:16:32 -07:00
Howard Yeh 192ab663b7 Fix 302 ImageLoader caching problem on iOS
Summary:
+ Fixes https://github.com/facebook/react-native/issues/5616
+ Bug RNPlay Demo: https://rnplay.org/apps/Eg2goQ

Test demo loads a Tumblr avatar image using a URL that 301 to a CDN. Try to edit and save the file to trigger image reloads.

The 302 image request succeeds the first time:

<img width="318" alt="screen shot 2016-04-27 at 9 37 03 am" src="https://cloud.githubusercontent.com/assets/50120/14860038/b2c04e8a-0c5b-11e6-9edf-78309048368b.png">

But it fails for subsequent loads. You should see:

<img width="307" alt="screen shot 2016-04-27 at 9 37 22 am" src="https://cloud.githubusercontent.com/assets/50120/14860048/b756e170-0c5b-11e6-9031-8f3cca8f2994.png">

+ The first image is a 302, only succeeds to load the first time.
+ The second image in the column adds a nonce as request parameter to render caching ineffective (but still a 302), and the problem doesn't occur.
+ The last image is the canonical url location (200).

Although NSURLSession hand
Closes https://github.com/facebook/react-native/pull/7262

Differential Revision: D3231702

Pulled By: javache

fb-gh-sync-id: 364fcf9819188c63310768411d49e6431b2a01d3
fbshipit-source-id: 364fcf9819188c63310768411d49e6431b2a01d3
2016-04-27 14:40:30 -07:00
Philipp von Weitershausen 8891f22f88 Fix WebSocket compatibility with event-target-shim ^1.0.5
Summary:
event-target-shim versions before 1.1.0 do not support taking an array for `EventTarget`. react-native requires `^1.0.5`, so this fixes compatibility with those earlier versions.

**Test Plan:** ran WebSocket UIExplorer example with earlier version of event-target-shim.
Closes https://github.com/facebook/react-native/pull/7261

Differential Revision: D3230881

Pulled By: martinbigio

fb-gh-sync-id: 6a22d58841a4b401a200fece64d13a70043fb09a
fbshipit-source-id: 6a22d58841a4b401a200fece64d13a70043fb09a
2016-04-27 12:26:23 -07:00
Dave Miller 57c40d9a6f Fix crash caused by accessibility being turned on and using a Modal
Summary: When the ModalHostView is added as a child of whatever view holds it, if accessibility is turned on, Android will walk up to the root and then walk all children of the child and verify that they are indeed children of the root.  Since ModalHostView actually adds its children to a new ReactDialogViewGroup which has the Dialog as a parent, there is a disagreement about the tree deep in the bowels of View when it performs that walk.  The trick is to stop from adding the children of the ModalHostView when walking for accessibility.  The accessibility of those children views are properly handled by the hosting Dialog.

Reviewed By: andreicoman11

Differential Revision: D3230033

fb-gh-sync-id: 1e5ac334c996b1d5f50c75ded60805d8b871477a
fbshipit-source-id: 1e5ac334c996b1d5f50c75ded60805d8b871477a
2016-04-27 10:16:25 -07:00
Alexander Blom 9a3a082225 Make polyfills and globals lazy
Summary:
This avoids requiring things that may never be used at all by the application such as WebSocket or Geolocation. It also stops us from asking for native modules
before we actually start the application enabling us to potentially be more lazy in the future.

Reviewed By: davidaurelio

Differential Revision: D3212802

fb-gh-sync-id: 70cf0d1a85f39fedc47758e5eb5df789a511bc9b
fbshipit-source-id: 70cf0d1a85f39fedc47758e5eb5df789a511bc9b
2016-04-27 09:57:20 -07:00
Nick Lockwood 9547a98a68 Fixed deadlock during app startup
Summary:
Now that we support initializing the bridge off the main thread, some of the assumptions in the bridge setup process are no longer safe.

In particular we were assuming that the JS executor and injected modules could always be synchronously initialized within bridge init, but that is only safe if those modules don't need to be set up on the main thread.

The setup for those modules was sync-dispatching to the main thread if bridge init happened on a background thread, and this lead to a deadlock under certain circumstances.

Reviewed By: javache

Differential Revision: D3224162

fb-gh-sync-id: 7319b70f541a46ef932cfe4f776e7e192f3ce1e8
fbshipit-source-id: 7319b70f541a46ef932cfe4f776e7e192f3ce1e8
2016-04-27 09:09:23 -07:00
Andy Street 6a2603745e Fix build break of react native exopackage apps
Reviewed By: lexs

Differential Revision: D3229733

fb-gh-sync-id: e74a2d4fbbdf019f898f87a05bdbd31b4e233463
fbshipit-source-id: e74a2d4fbbdf019f898f87a05bdbd31b4e233463
2016-04-27 08:02:24 -07:00
Andy Street 50d8d46733 Add ability to expose sync hooks from Java to JS
Summary:
This only works for the new cxx bridge (hopefully open sourcing soon!).

This diff allows Java native modules to expose synchronous hooks to JS via the ReactSyncHook annotation. The methods will appear in JS on the native module object (e.g. you would do `require('UIManager').mySyncHook('foo');`) which allows us to enforce that required native modules are installed at build time. In order to support remote debugging, both the args and return type must be JSON serializable (so that we can go back across to the device to resolve synchronous hooks).

Follow ups will be integration tests, adding support for return types besides void, and adding support for remote debugging.

Reviewed By: mhorowitz

Differential Revision: D3218794

fb-gh-sync-id: 7e3366a8254276f5a55eb806287419287ca9182b
fbshipit-source-id: 7e3366a8254276f5a55eb806287419287ca9182b
2016-04-27 07:51:28 -07:00
Pieter De Baets 171c7230b1 Simplify message passing in JSC-executor
Reviewed By: tadeuzagallo

Differential Revision: D3179792

fb-gh-sync-id: 96b7c91209ccac745e0f64def0095efd6b1184ed
fbshipit-source-id: 96b7c91209ccac745e0f64def0095efd6b1184ed
2016-04-27 06:35:27 -07:00
Felix Oghina fb76154b42 handle null args array in proxy invocation handler
Reviewed By: astreet

Differential Revision: D3212837

fb-gh-sync-id: 1a66de68cc13758a41514e4bef6808b818b9682e
fbshipit-source-id: 1a66de68cc13758a41514e4bef6808b818b9682e
2016-04-27 02:28:19 -07:00
sunnylqm 131970dc5a Android Support Repository -> Local Maven repository for Support Libr…
Summary: Closes https://github.com/facebook/react-native/pull/7249

Differential Revision: D3229302

fb-gh-sync-id: 83596604c1c1546249babb421898aa5bd9c7e5c1
fbshipit-source-id: 83596604c1c1546249babb421898aa5bd9c7e5c1
2016-04-27 01:29:28 -07:00
Alex Kotliarskyi 8295d27a90 Fix usage of react-native cli inside package.json scripts
Summary:
IIRC we made `wrong-react-native` to warn people in case they installed `react-native` globally (instead of `react-native-cli` what the guide suggests). To do that we added `bin` entry to React Native's `package.json` that points to `local-cli/wrong-react-native.js`

However, this means that if we have a project that uses `react-native` package and has call to `react-native` CLI inside its package.json, npm will execute *local* override (which just prints a confusing in this context error message).

In fact, the template we generate with `react-native init` has `react-native start` as `start` script, which makes it useless. Let's fix it by making `wrong-react-native` script smarter – it can detect that it has been executed from local `node_modules` and run the actual CLI.

cc vjeux ide
Closes https://github.com/facebook/react-native/pull/7243

Differential Revision: D3226645

Pulled By: frantic

fb-gh-sync-id: be094eb0e70e491da4ebefc2abf11cff56c4c5b7
fbshipit-source-id: be094eb0e70e491da4ebefc2abf11cff56c4c5b7
2016-04-26 15:42:35 -07:00
Spencer Ahrens b5d9bf0fb2 merge InteractionManager stuff back into PanResponder
Reviewed By: bestander

Differential Revision: D3224519

fb-gh-sync-id: d041214b68fedfdd6b01aa2b710b02381c29dcfa
fbshipit-source-id: d041214b68fedfdd6b01aa2b710b02381c29dcfa
2016-04-26 13:19:22 -07:00
Steven Luscher dad39eb502 Move Number polyfills into the /polyfills/ directory
Reviewed By: vjeux

Differential Revision: D3223317

fb-gh-sync-id: a49a14f217b27d6542b65c4780c557e73da2443f
fbshipit-source-id: a49a14f217b27d6542b65c4780c557e73da2443f
2016-04-26 11:24:42 -07:00
Konstantin Raev 2eef115161 Revert "Add subviewStyle prop to NavigationHeader"
Summary:
This reverts commit 1dc82a9e5f.

Breaks OSS tests
Closes https://github.com/facebook/react-native/pull/7232

Differential Revision: D3223972

Pulled By: bestander

fb-gh-sync-id: fea7ec4a1c13d328a7bbda9fcd3f201a7007081e
fbshipit-source-id: fea7ec4a1c13d328a7bbda9fcd3f201a7007081e
2016-04-26 06:10:24 -07:00
Nick Lockwood c1aff6b116 Removed exported constants for fixed-size views
Summary: Creating a view instance just to get the default view size is quite expensive, and affects startup time for the bridge as it must be done on the main thread. I've removed these cases and simply hard-coded the sizes in the JS file. This will need to be updated if the view sizes ever change, but in practice that's very unlikely.

Reviewed By: javache

Differential Revision: D3218917

fb-gh-sync-id: 91a21dabb6046c5d4d5d0bec0845415cb3628ec3
fbshipit-source-id: 91a21dabb6046c5d4d5d0bec0845415cb3628ec3
2016-04-26 04:21:39 -07:00
Pavlo Kushnir 036199d3f7 Use std::string in folly::dynamic
Reviewed By: joeg, snarkmaster

Differential Revision: D3189410

fb-gh-sync-id: 9bb9090ca6012ac32ba9fb79041b26ec4888781f
fbshipit-source-id: 9bb9090ca6012ac32ba9fb79041b26ec4888781f
2016-04-26 02:28:30 -07:00
Ben Hoyt 77b3f86d89 Clarify that nested text formatting also works on Android
Summary:
This is a documentation-only change: currently the docs imply that nested text formatting only works on iOS (via `NSAttributedString`). But the code (and my tests!) indicate it also works fine on Android via `SpannableString`, so clarify this in the documentation for the `Text` component.
Closes https://github.com/facebook/react-native/pull/7215

Differential Revision: D3223732

fb-gh-sync-id: 4e796e493ba6c48f05b812a12761ddb3851e06e1
fbshipit-source-id: 4e796e493ba6c48f05b812a12761ddb3851e06e1
2016-04-26 00:58:21 -07:00
Spencer Ahrens 667d278119 Only grab InteractionManager handle in PanResponder, not all touches
Summary:
Previously, `InteractionManager` was baked in at the lowest level to all touches via `ResponderEventPlugin`,
which meant that any time a finger was touching the screen, `InteractionManager` would be locked. This included while
doing 100% native scrolls, and thus would block progress from Relay, Incremental, or anything else scheduling events
through `InteractionManager`.

This diff switches to only bake it into `PanResponder` (and it remains hooked into `Animated` as before) which are the
main two cases where we need 60fps JS execution and want to queue up slower tasks.

This is done with a reusable higher-order-responder `InteractionManager.createResponderClass`.

Depends on FYI https://github.com/facebook/react/pull/6587, https://github.com/facebook/react/pull/6584

Reviewed By: sebmarkbage

Differential Revision: D3210951

fb-gh-sync-id: 682d21ac5cff704673b63d5942a903a3d8912835
fbshipit-source-id: 682d21ac5cff704673b63d5942a903a3d8912835
2016-04-26 00:23:30 -07:00
Steven Luscher c05169d8b7 Add a Number.isNaN polyfill
Reviewed By: sahrens

Differential Revision: D3222299

fb-gh-sync-id: 601283fb0b140bb305181ea381907e62286f7a37
fbshipit-source-id: 601283fb0b140bb305181ea381907e62286f7a37
2016-04-25 23:15:18 -07:00
Sebastian Markbage 6f43d1f2cb Codemod import React from 'react-native'
Reviewed By: spicyj

Differential Revision: D3223162

fb-gh-sync-id: 0b1af846afe17cdf8b2c2ca7f31f1197cde752c0
fbshipit-source-id: 0b1af846afe17cdf8b2c2ca7f31f1197cde752c0
2016-04-25 22:08:46 -07:00
Sebastian Markbage 8e43b24a36 Update React to alpha.3
Summary:
Sync new React fixes.

Includes...

https://github.com/facebook/react/pull/6584
https://github.com/facebook/react/pull/6587
https://github.com/facebook/react/pull/6588
https://github.com/facebook/react/pull/6590

Since this require PanResponder to be restored I also included D3210771 here.

Reviewed By: spicyj

Differential Revision: D3221285

fb-gh-sync-id: cbb6b1dd0fd0443d246957ceb94b6a424c09c24e
fbshipit-source-id: cbb6b1dd0fd0443d246957ceb94b6a424c09c24e
2016-04-25 20:38:26 -07:00
Mike Grabowski edf8888fb9 Platform.select method
Summary:
Kudos to frantic for this amazing idea! Works really well (yet so simple!)

Basically we had a discussion with vjeux and frantic and others in the PR #7033 how to handle platform-specific stylesheets in a similar to F8 app way.

There were quite a few nice ideas there, however that one seems to be the smallest yet the most powerful.

Basically there's a `Platform.select` method that given an object, will select a `obj[Platform.OS]` value.

It works with styles:
`Platform.select({ ios: {}, android: {} })`

with messages:
`<Text>{Platform.select({ ios: 'Check the App Store', android: 'Check Google Play' })}</Text>`

and also works well with components (similar to Wallmart idea of <PlatformSwitch />) - relevant example included in diff.
Closes https://github.com/facebook/react-native/pull/7220

Differential Revision: D3221709

Pulled By: vjeux

fb-gh-sync-id: 0a50071f2dcf2273198bc6e2c36e19bca97d7be9
fbshipit-source-id: 0a50071f2dcf2273198bc6e2c36e19bca97d7be9
2016-04-25 16:32:20 -07:00
Hedger Wang 24f44558f6 Fix initial scenes rendering for NavigationPagerStyleInterpolator
Summary:
The initial layout used to render scenes does not contain the actual
width and height measured and causes the issue as described at
https://github.com/ericvicenti/navigation-rfc/issues/61

The fix is to update the layout and re-render scenes once layout
is modified. Also scenes renderer should also consider the case that
when the layout is not measured yet.

Reviewed By: ericvicenti

Differential Revision: D3203245

fb-gh-sync-id: 4de89b9b43bc993d7c970c831458bd31c094073e
fbshipit-source-id: 4de89b9b43bc993d7c970c831458bd31c094073e
2016-04-25 15:37:38 -07:00
Scott Foggo 50d6de9448 Check if either array is null before diffing
Reviewed By: sebmarkbage

Differential Revision: D3219392

fb-gh-sync-id: fd6ef2e2c2d7b661a06c857b25b007701340e20a
fbshipit-source-id: fd6ef2e2c2d7b661a06c857b25b007701340e20a
2016-04-25 13:28:31 -07:00
Chris Hopman 860b7ddc35 Don't defer dispatching of events while paused
Reviewed By: astreet

Differential Revision: D3186718

fb-gh-sync-id: 888c6e0cc0b52edbbc6b9e0cb285ce1a2d1bf987
fbshipit-source-id: 888c6e0cc0b52edbbc6b9e0cb285ce1a2d1bf987
2016-04-25 12:47:21 -07:00
Dave Miller 8e7ea1179a Fix Popover location in Events
Reviewed By: andreicoman11

Differential Revision: D3219054

fb-gh-sync-id: cc25bd63be284ae7e8232652936a67fd792feabc
fbshipit-source-id: cc25bd63be284ae7e8232652936a67fd792feabc
2016-04-25 10:15:21 -07:00
Christian Meunier 1dc82a9e5f Add subviewStyle prop to NavigationHeader
Summary:
Implements: #7204

Pinging ericvicenti for review.
Closes https://github.com/facebook/react-native/pull/7214

Differential Revision: D3219306

Pulled By: ericvicenti

fb-gh-sync-id: becd1dada2557b7fb2c345bac2098094fa6d2144
fbshipit-source-id: becd1dada2557b7fb2c345bac2098094fa6d2144
2016-04-25 10:12:25 -07:00
Tadeu Zagallo c5307a6e7c Bringing fbsystrace to iOS 8's JSC
Reviewed By: michalgr

Differential Revision: D3163295

fb-gh-sync-id: 3cc2083accc4ba6947efc631f3574412022b1e1f
fbshipit-source-id: 3cc2083accc4ba6947efc631f3574412022b1e1f
2016-04-25 09:45:24 -07:00
Alexander Blom 69c083b27d Add WebView integration example to cookies example
Reviewed By: dmmiller

Differential Revision: D3207659

fb-gh-sync-id: f87d70d53de9a8215bb593502368d16251ebb358
fbshipit-source-id: f87d70d53de9a8215bb593502368d16251ebb358
2016-04-25 09:44:26 -07:00
David Aurelio 61c53d4939 Jest: Un-blacklist React main module
Summary:
testing jest for react 15

Closes #7212
Closes https://github.com/facebook/react-native/pull/7213

Differential Revision: D3219118

fb-gh-sync-id: 6a0fe9f3b404274779e39e037bb88d0e6ce36cfd
fbshipit-source-id: 6a0fe9f3b404274779e39e037bb88d0e6ce36cfd
2016-04-25 09:07:28 -07:00
Konstantin Raev 7d9fe365a7 Fixed e2e tests for HMR
Summary:HMR e2e test red-screened because of the wrong path to react.

**Test plan (required)**

Make sure e2e tests pass
Closes https://github.com/facebook/react-native/pull/7209

Reviewed By: mkonicek

Differential Revision: D3218896

Pulled By: bestander

fb-gh-sync-id: 8c5c4ceda34bd2d273e9de16ed670592d1fde3b9
fbshipit-source-id: 8c5c4ceda34bd2d273e9de16ed670592d1fde3b9
2016-04-25 08:12:30 -07:00
Konstantin Raev a8d2079022 Optimise e2e tests retries
Summary:Implemented smarter retries for e2e tests

E2e tests consist of two expensive and flaky steps: npm installation and tests execution.
Our CI is configured to retry a command 3 times before terminating the test.
In current setup if one of the steps fail the whole test is restarted.

This change adds ad-hoc ability to retry flaky bits of e2e script independently.
This will make tests fail faster when code gets broken while increasing the chances to succeed in case of random false errors.
Closes https://github.com/facebook/react-native/pull/7184

Differential Revision: D3218927

fb-gh-sync-id: 9be8343484bb28aa3601b651db70fc55aa840e61
fbshipit-source-id: 9be8343484bb28aa3601b651db70fc55aa840e61
2016-04-25 07:16:20 -07:00
Konstantin Raev a2ee5bd307 Fixed HMR for React Native Android
Summary:Needs to be published to npm and version be updated in RN
Closes https://github.com/facebook/react-native/pull/7208

Differential Revision: D3218870

Pulled By: davidaurelio

fb-gh-sync-id: 1caac6eb79be16f2e3ed230f413835341c7291dc
fbshipit-source-id: 1caac6eb79be16f2e3ed230f413835341c7291dc
2016-04-25 06:31:25 -07:00
Nick Lockwood 37f4ec6e16 Removed placeholder image logic
Summary: To prevent layout popping, when inserting images inside text we would render a blank placeholder image while the real image was loading. It turns out that this isn't necessary, as we can just specify the size of the image without having an actual image to display.

Reviewed By: javache

Differential Revision: D3212766

fb-gh-sync-id: e98851b32a2d0ae809fc0a4be47e6b77f3b17996
fbshipit-source-id: e98851b32a2d0ae809fc0a4be47e6b77f3b17996
2016-04-25 03:31:19 -07:00
Christoph Pojer 0bf737ff0a Update to 11.0.1
Reviewed By: kassens

Differential Revision: D3183738

fb-gh-sync-id: 07be9e1d60413a6d929b15cd72eeba416a6bfc6d
fbshipit-source-id: 07be9e1d60413a6d929b15cd72eeba416a6bfc6d
2016-04-25 01:16:23 -07:00
Janic Duplessis baa3668160 Add support for delete animation in LayoutAnimation on iOS
Summary:This adds support for delete view animations in LayoutAnimation for iOS. It supports the same properties as the create animation (alpha, scale).

This allows making simple animations when removing a view which is normally hard to do in React since we need to not remove the view node immediately.

**Test plan**
Tested add/removing views in the UIExample explorer with and without setting a LayoutAnimation. Also tested that the completion callback still works properly. Tested that user interation during the animation is properly disabled.

![layout-anim2](https://cloud.githubusercontent.com/assets/2677334/14595471/86fb1654-050d-11e6-8b38-fe45cc2dcd71.gif)

I also plan to work on improving the doc for LayoutAnimation as well as making this PR for android too.
Closes https://github.com/facebook/react-native/pull/6779

Differential Revision: D3215525

Pulled By: sahrens

fb-gh-sync-id: 526120acd371c8d1af433e8f199cfed336183775
fbshipit-source-id: 526120acd371c8d1af433e8f199cfed336183775
2016-04-25 00:19:25 -07:00
Nick Smith ♞ 23918692ac Fix 'React not found' issue
Summary:Fix React not found by importing React.
Closes https://github.com/facebook/react-native/pull/7201

Differential Revision: D3218119

fb-gh-sync-id: 8834df556d8358cfb511dddaf911ac9144c4e1e9
fbshipit-source-id: 8834df556d8358cfb511dddaf911ac9144c4e1e9
2016-04-24 16:27:25 -07:00
Jeff Chien 475f1b5796 Reverted commit D3126513
Summary:Using TouchableNativeFeedback has been a problem for me because the ripples it makes don't follow the child view's border radii so the ripples stick out of the child view's rounded corners. This PR should fix this problem with a minor caveat: this only works for TouchableNativeFeedback.Ripple and not TouchableNativeFeedback.SelectableBackground. I searched how I could apply corner radius to selectableItemBackground and it doesn't seem to be possible (the prevalent advice is to create the ripple manually which is equivalent to using TNF.Ripple in our case), though I could be wrong.

I added [an example to UIExplorer (TouchableExample)](http://i.imgur.com/CHY9xjW.png). This is my first PR to this repo so let me know if something's wrong. Cheers!
Closes https://github.com/facebook/react-native/pull/6515

Differential Revision: D3126513

Pulled By: AaaChiuuu

fb-gh-sync-id: 4a00e7177ee4ffd8dffeca143f4f43f08c99b5a1
fbshipit-source-id: 4a00e7177ee4ffd8dffeca143f4f43f08c99b5a1
2016-04-24 15:45:19 -07:00
Mike Grabowski 02578df4f7 Fallback for textAlign: justify
Summary:Fixes #5408 as per ide and vjeux suggestions here https://github.com/facebook/react-native/issues/529#issuecomment-107328799

Could've been probably done in a single `if` clause, but this is more explicit and leaves potential place for future implementation (if we ever decide to do so)
Closes https://github.com/facebook/react-native/pull/7197

Differential Revision: D3217740

Pulled By: vjeux

fb-gh-sync-id: aa08a5c42e43c1abe17b72a424ee96146f2667f6
fbshipit-source-id: aa08a5c42e43c1abe17b72a424ee96146f2667f6
2016-04-24 11:29:23 -07:00
Mike Grabowski 7102fd079a Document ListView.DataSource #410
Summary:Fixes #410
Closes https://github.com/facebook/react-native/pull/7193

Differential Revision: D3217718

fb-gh-sync-id: c05c9e3d67863c064f8e1102090614c6ba7e3127
fbshipit-source-id: c05c9e3d67863c064f8e1102090614c6ba7e3127
2016-04-24 08:13:21 -07:00
him ➚ 3f1165dfc6 Fix 'Can't find variable: React'
Summary:Border example throws "Can't find variable: React" error.

This simply includes React (using old 'require' syntax to keep syntax consistent)
Closes https://github.com/facebook/react-native/pull/7194

Differential Revision: D3217714

fb-gh-sync-id: 7ba5251cd64a9bfeceff67a2f8f089e25b3d9465
fbshipit-source-id: 7ba5251cd64a9bfeceff67a2f8f089e25b3d9465
2016-04-24 07:13:29 -07:00
Ian MacLeod 7721a24f38 Expose NavigationPropTypes via NavigationExperimental.PropTypes
Summary:Useful for building components that compose navigation components
Closes https://github.com/facebook/react-native/pull/6644

Differential Revision: D3217681

fb-gh-sync-id: 94907fed1692f2dc6603a5fbdf3a032906e3f74d
fbshipit-source-id: 94907fed1692f2dc6603a5fbdf3a032906e3f74d
2016-04-24 04:46:26 -07:00
Allan Jiang 216cbb4065 Add Kiwiship app
Summary:Add Kiwiship app to showcase page.

Kiwiship app is powered purely by RN and currently available on iOS platform.
Closes https://github.com/facebook/react-native/pull/7169

Differential Revision: D3217526

fb-gh-sync-id: beeaa8453cfcb53bd6c4ffab02b7d827798f42e4
fbshipit-source-id: beeaa8453cfcb53bd6c4ffab02b7d827798f42e4
2016-04-23 23:14:22 -07:00
Mike Grabowski 881eda20d2 Update UIExplorer <Text /> example to respect ultralight font
Summary:Fixes #6735

On font sizes smaller than 20, iOS will swap SystemFont to SF version optimised for smaller sizes which does not have ultralight and thin. That results in ultralight and light example to be rendered with the same weight.

Bumping to `20` makes it render differently as per below screenshot https://cloud.githubusercontent.com/assets/2464966/14622260/0789e500-05c9-11e6-920a-8c948a5b79b4.png
Closes https://github.com/facebook/react-native/pull/7044

Differential Revision: D3212565

Pulled By: mkonicek

fb-gh-sync-id: 5ffad136c7f4126c271366640c89673f30a99218
fbshipit-source-id: 5ffad136c7f4126c271366640c89673f30a99218
2016-04-23 18:24:23 -07:00
Mike Grabowski f022681a1e Implement Text onLongPress
Summary:Fixes #5855

Tested with `UIExplorer`, first <Text> is the `onPress`, second is the `onLongPress`.
Closes https://github.com/facebook/react-native/pull/7099

Differential Revision: D3212436

Pulled By: mkonicek

fb-gh-sync-id: 0a1cbcd4eaf39ad4fe67d861c3be2e042e1acb27
fbshipit-source-id: 0a1cbcd4eaf39ad4fe67d861c3be2e042e1acb27
2016-04-23 18:14:20 -07:00
Konstantin Raev ea8f584184 fixed website generation code (refer some API that is now in React codebase)
Summary:vjeux spicyj this fixes website generation because these API are now in React.

I would refer React file but it seems fragile because it is a thirdparty dependency now.
How do we document thirdparty API?
Closes https://github.com/facebook/react-native/pull/7163

Differential Revision: D3216771

fb-gh-sync-id: b0653a0bbe0f84dc509f74d185f494ac343405a8
fbshipit-source-id: b0653a0bbe0f84dc509f74d185f494ac343405a8
2016-04-23 07:57:24 -07:00
James Ide f5130c8073 Exit with the error status code from xcodebuild
Summary:See https://github.com/supermarin/xcpretty#usage -- xcpretty will suppress xcodebuild's status code so we need to add `&& exit ${PIPESTATUS[0]}`.
Closes https://github.com/facebook/react-native/pull/7172

Differential Revision: D3216731

fb-gh-sync-id: 942fd213105cc365d1d9a9c4d146441c044dd506
fbshipit-source-id: 942fd213105cc365d1d9a9c4d146441c044dd506
2016-04-23 04:19:22 -07:00
Krzysztof Magiera dd244f5530 Support for Animated.interpolate
Summary:This change adds native animated support for Animated.interpolate

Animated.interpolate allows for defining nodes that outputs an interpolated value of their input node based on the interpolation node configuration. For now native animated implementation only supports a linear interpolation for a given input and output ranges (ranges can consists of multiple segments). Native interpolation node is compatible with the JS implementation with the exception that not all attributes that can be used in JS are supported. Before we migrate interpolation node from JS->native we verify that only supported props are used.

**Test Plan**
Run JS tests: `npm test Libraries/Animated/src/__tests__/AnimatedNative-test.js`
Run java tests: `buck test ReactAndroid/src/test/java/com/facebook/react/animated`
Closes https://github.com/facebook/react-native/pull/7141

Differential Revision: D3216546

fb-gh-sync-id: 29876e33956615c6370ca4d332abe048f8dba5b8
fbshipit-source-id: 29876e33956615c6370ca4d332abe048f8dba5b8
2016-04-23 02:37:28 -07:00
Konstantin Raev a31e87b3f2 temporarily disable broken OSS CI tests to save CI capacity
Summary:Fix progress tracking via t10955118
Closes https://github.com/facebook/react-native/pull/7162

Differential Revision: D3216683

fb-gh-sync-id: 100de7a245bb7e7de741d96f3f0a7d4871b97311
fbshipit-source-id: 100de7a245bb7e7de741d96f3f0a7d4871b97311
2016-04-23 02:01:19 -07:00
James Ide 6fac6db4d4 Use xcodebuild and delete "Framework Search Paths" for Xcode 7.3 to un-stall the tests
Summary:The Obj-C tests were stalling when we updated TravisCI to use the OS X image with Xcode 7.3 and iOS 9.3.

On my own MBP with Xcode 7.3 the tests stall as well. Running `./scripts/objc-test.sh` prints out a warning near the end, which says `ld` couldn't find a Frameworks folder under the iPhoneSimulator9.3 SDK directory. Indeed, this directory doesn't exist on my computer. When creating a brand new project with unit tests and UI tests, both test targets don't specify "Framework Search Paths" so I don't think we need to specify it anymore.
Closes https://github.com/facebook/react-native/pull/7168

Differential Revision: D3216524

fb-gh-sync-id: 3097bda98d78289ecdba86801bcd461f3311ac47
fbshipit-source-id: 3097bda98d78289ecdba86801bcd461f3311ac47
2016-04-22 23:04:19 -07:00
Spencer Ahrens 09a34f4d0f Integrate RelayConnection with RNFeed
Reviewed By: ericvicenti

Differential Revision: D2750242

fb-gh-sync-id: fa72d67f554823128bf62786b34e5b9592dc7c89
fbshipit-source-id: fa72d67f554823128bf62786b34e5b9592dc7c89
2016-04-22 22:48:18 -07:00
Sebastian Markbage 248879f5a3 Fix react-native.js.flow
Summary:We no longer forward React onto this object. We only forward the ReactNative
module onto it.

We also deprecated the addons so they'll all warn. We'll remove it
completely soon.
Closes https://github.com/facebook/react-native/pull/7136

Reviewed By: gabelevi

Differential Revision: D3211809

Pulled By: sebmarkbage

fb-gh-sync-id: 77aaa909dca5e2522cfaa7b4ca361fabc614be58
fbshipit-source-id: 77aaa909dca5e2522cfaa7b4ca361fabc614be58
2016-04-22 18:02:28 -07:00
Rui Chen 862136a398 Revert the suspicious text input change for now
Reviewed By: nickholub

Differential Revision: D3213682

fb-gh-sync-id: 5b3090864c4c50f307de22493c9a7a8cb4687621
fbshipit-source-id: 5b3090864c4c50f307de22493c9a7a8cb4687621
2016-04-22 17:34:28 -07:00
Alexey Lang 8aa82d3b33 Add flag "-lc++" for all checked-in projects
Reviewed By: bestander

Differential Revision: D3214654

fb-gh-sync-id: cb07b439156ab5ff1f909f69c766c09da2a027c6
fbshipit-source-id: cb07b439156ab5ff1f909f69c766c09da2a027c6
2016-04-22 16:23:18 -07:00
Alexander Micklewright 3881694892 Fix a bug in asset server when using relative project roots
Summary:This PR fixes a bug where when using relative roots for the packager server, asset paths would be deemed invalid by the recently introduced security check. Resolving the root to an absolute path fixes that problem.

I'd be happy to write a regression test for this but I had a hard time setting up a mock file system with relative paths. If it is required, some help would be appreciated...
Closes https://github.com/facebook/react-native/pull/7161

Differential Revision: D3214840

fb-gh-sync-id: 08e13fb9f94a98206fd2d090f74a8b63ba2bf80f
fbshipit-source-id: 08e13fb9f94a98206fd2d090f74a8b63ba2bf80f
2016-04-22 16:06:21 -07:00
Omar Carpinteyro 4b907d2312 Adding new app NTH on Showcases
Summary:My update is to the app showcase on the react native website, adding my :NTH iOS app (in alphabetical order). :NTH App can test the equations of the CSS Selectors.

:NTH App: https://itunes.apple.com/us/app/nth/id1102663176?mt=8
Showcase: https://facebook.github.io/react-native/showcase.html
Closes https://github.com/facebook/react-native/pull/7042

Differential Revision: D3212549

Pulled By: mkonicek

fb-gh-sync-id: f19866f1d2ac53fb7f1295ff5155db2d690bb9b4
fbshipit-source-id: f19866f1d2ac53fb7f1295ff5155db2d690bb9b4
2016-04-22 11:52:27 -07:00
Felix Oghina ed7d13bf57 Backed out D3190875
Reviewed By: astreet

Differential Revision: D3212319

fb-gh-sync-id: 2b93bf83c2e7f687ad1762a199c9a150862395ff
fbshipit-source-id: 2b93bf83c2e7f687ad1762a199c9a150862395ff
2016-04-22 11:24:40 -07:00
Felix Oghina 7946160733 refactor BugReporting to use RCTDeviceEventEmitter
Reviewed By: sahrens

Differential Revision: D3212300

fb-gh-sync-id: 3a61d620320dd1c0254bf3b836601d5bbfbc4c0d
fbshipit-source-id: 3a61d620320dd1c0254bf3b836601d5bbfbc4c0d
2016-04-22 11:24:40 -07:00
Mike Grabowski cbdf026628 Fix/spaces in showcase
Summary:There's space missing:
<img width="126" alt="screen shot 2016-04-22 at 09 30 54" src="https://cloud.githubusercontent.com/assets/2464966/14734757/f037e25c-086c-11e6-8ac7-70251103ce42.png">

After:
<img width="135" alt="screen shot 2016-04-22 at 09 31 12" src="https://cloud.githubusercontent.com/assets/2464966/14734762/f9537428-086c-11e6-9109-473be6e778c9.png">
Closes https://github.com/facebook/react-native/pull/7142

Differential Revision: D3212913

Pulled By: mkonicek

fb-gh-sync-id: 2a5bbe600093c08d672b0e156a4af56004c18115
fbshipit-source-id: 2a5bbe600093c08d672b0e156a4af56004c18115
2016-04-22 11:09:26 -07:00
Labeeb Panampullan 446d7b7c17 Fixed array bounds error in MapView
Summary: fixed a case where MapView could crash due to a race condition

Differential Revision: D3207304

fb-gh-sync-id: a63918d160258d76fce5d56994100a63f4c5fb68
fbshipit-source-id: a63918d160258d76fce5d56994100a63f4c5fb68
2016-04-22 10:59:29 -07:00
Mike Grabowski 7192984c13 Update Debugging.md
Summary:Fixes #7131

I believe it's easier if we just link to this file so it's less confusing what to edit actually. I was originally thinking about linking to specific line, but that will be hard to keep in sync.
Closes https://github.com/facebook/react-native/pull/7139

Differential Revision: D3212912

Pulled By: mkonicek

fb-gh-sync-id: 4f272d8bc922b273b961707d9ebf18a3efda31be
fbshipit-source-id: 4f272d8bc922b273b961707d9ebf18a3efda31be
2016-04-22 10:54:21 -07:00
Alexey Lang 5b090dd52c Add .mm to React.podspec
Reviewed By: javache

Differential Revision: D3212710

fb-gh-sync-id: 1ab4a3d5943e154b1662b638d8c7c4b9c6ad2476
fbshipit-source-id: 1ab4a3d5943e154b1662b638d8c7c4b9c6ad2476
2016-04-22 10:16:46 -07:00
Pieter De Baets 09f1e8293a Prevent measuring text in RCTShadowText child nodes
Summary: We only measure text at the root node, we shouldn't be trying to build a text storage later on for tree lower in the shadow node tree.

Reviewed By: nicklockwood

Differential Revision: D3212614

fb-gh-sync-id: 574fa7f2c029ca9ad2d5fabe7bbb148157f85ca7
fbshipit-source-id: 574fa7f2c029ca9ad2d5fabe7bbb148157f85ca7
2016-04-22 10:14:29 -07:00
Radek Czemerys dfd1c7dd6a Making sinopia setup easier for the user
Summary:Simply installing `sinopia` does not create a config file (or even a
directory when it should be placed). Running `sinopia` for the first time
generates a default config file so it?s easier for the user to
configure it properly.
Closes https://github.com/facebook/react-native/pull/7146

Differential Revision: D3212613

Pulled By: mkonicek

fb-gh-sync-id: e1a2bbd8311a93b4d8a230902dd8031c85a205c3
fbshipit-source-id: e1a2bbd8311a93b4d8a230902dd8031c85a205c3
2016-04-22 09:26:24 -07:00
Eyal Eizenberg 994745efbe Added Samanage to the showcase
Summary:Added the Samanage iOS React Native app to the showcase.
Closes https://github.com/facebook/react-native/pull/7112

Differential Revision: D3212588

Pulled By: mkonicek

fb-gh-sync-id: 79bf7faf31ac9f2129d19a39f3131b6df381360a
fbshipit-source-id: 79bf7faf31ac9f2129d19a39f3131b6df381360a
2016-04-22 09:18:21 -07:00
Tanguy Antoine ab2113c324 Update PushNotificationIOS documentation
Summary:* add sample for localNotification listener
Closes https://github.com/facebook/react-native/pull/7114

Differential Revision: D3212587

Pulled By: mkonicek

fb-gh-sync-id: 1251a5563cf4254c4de491d45aafe8d1c24aeb0f
fbshipit-source-id: 1251a5563cf4254c4de491d45aafe8d1c24aeb0f
2016-04-22 09:16:21 -07:00
Jeff Chien e438954938 Modify TouchableNativeFeedback (Ripple) to follow borderRadius
Summary:Using TouchableNativeFeedback has been a problem for me because the ripples it makes don't follow the child view's border radii so the ripples stick out of the child view's rounded corners. This PR should fix this problem with a minor caveat: this only works for TouchableNativeFeedback.Ripple and not TouchableNativeFeedback.SelectableBackground. I searched how I could apply corner radius to selectableItemBackground and it doesn't seem to be possible (the prevalent advice is to create the ripple manually which is equivalent to using TNF.Ripple in our case), though I could be wrong.

I added [an example to UIExplorer (TouchableExample)](http://i.imgur.com/CHY9xjW.png). This is my first PR to this repo so let me know if something's wrong. Cheers!
Closes https://github.com/facebook/react-native/pull/6515

Differential Revision: D3126513

Pulled By: mkonicek

fb-gh-sync-id: 1d3e92243abf9706132ae47c485d9e04a9b47d81
fbshipit-source-id: 1d3e92243abf9706132ae47c485d9e04a9b47d81
2016-04-22 09:07:50 -07:00
Raul Ascencio 44d36f7c5f removing xterm from linux spawn
Summary:Simply removing the xterm spawn from android packager, since you can archive exactly the same results using the standard shell 😄
Closes https://github.com/facebook/react-native/pull/7077

Differential Revision: D3212548

Pulled By: mkonicek

fb-gh-sync-id: 8cc03d2708614f64e1394ca738e5de0ba631deb9
fbshipit-source-id: 8cc03d2708614f64e1394ca738e5de0ba631deb9
2016-04-22 09:01:22 -07:00
Alexey Lang db34d72d3c Fix OSS tests
Reviewed By: bestander

Differential Revision: D3212520

fb-gh-sync-id: 9c54c0dbfdfa4a7c133851b9262e8b6716ac7336
fbshipit-source-id: 9c54c0dbfdfa4a7c133851b9262e8b6716ac7336
2016-04-22 08:40:28 -07:00
Andrew Gray 774296b263 Implemented stopLoading
Summary:**Motivation:** In my app, I'm using a WebView that loads content from my mobile site.  What I want to do is when a user presses a link on the loaded page, I want to stop the WebView's request, hijack the URL and open the URL in a new WebView, pushed to the top of the navigator stack.  To me, this gives the overall app a more native feel, instead of implementing a rudimentary navbar on the main WebView to go back.

**Attempted Workarounds:** I've attempted to get similar functionality by capturing the onNavigationStateChange event in the WebView, and then within calling goBack + pushing the new view to the navigator stack.  From a functionality standpoint, this works.  However, from a UI standpoint, the user can clearly see the webview change states to a new page + go back before having the new view pushed on top of their nav stack.
Closes https://github.com/facebook/react-native/pull/6886

Differential Revision: D3212447

Pulled By: mkonicek

fb-gh-sync-id: 05911e583d9ba54ddbd54a772153c80ed227731e
fbshipit-source-id: 05911e583d9ba54ddbd54a772153c80ed227731e
2016-04-22 08:15:25 -07:00
Alexey Lang 32a89493fb Fix leaked cookieMap in RCTJSCExecutor
Reviewed By: javache

Differential Revision: D3207245

fb-gh-sync-id: 1263974e2f94175cd4bf190cec446b88b5273aca
fbshipit-source-id: 1263974e2f94175cd4bf190cec446b88b5273aca
2016-04-22 06:44:26 -07:00
Pieter De Baets 8b1726bdad Improve error handling in require-unbundle
Reviewed By: davidaurelio

Differential Revision: D3207450

fb-gh-sync-id: 35247c265e35976dcee9fca4215403efa604479e
fbshipit-source-id: 35247c265e35976dcee9fca4215403efa604479e
2016-04-22 06:18:26 -07:00
Mike Grabowski 9bae30f8b5 Add cla command
Summary:Hey,

Adding a `cla` command to bot so that we can ping users that forgot about it more conveniently. I am not really sure if that's everything we have to do in order for the bot to use it - but just wanted to give it a go.

Differential Revision: D3212234

fb-gh-sync-id: 5f75f88694b21b883e7da2af41d4e389fb828839
fbshipit-source-id: 5f75f88694b21b883e7da2af41d4e389fb828839
2016-04-22 04:24:24 -07:00
Mike Grabowski a963f91021 Document how to disable YellowBox
Summary:As mentioned in #7121 by javache, this can already be disabled. Might be useful if users upgrade to 0.25 and want to hide warnings about wrong React imported (something they can't really control until community upgrades).

This should be mentioned in the release notes once it's merged.
Closes https://github.com/facebook/react-native/pull/7140

Differential Revision: D3212212

fb-gh-sync-id: 7a7afa2b7925e16d6ebfd20f4fe26d1cb9d603e5
fbshipit-source-id: 7a7afa2b7925e16d6ebfd20f4fe26d1cb9d603e5
2016-04-22 04:13:29 -07:00
Dan Caspi fcac6e081d Support for WITH_JSC_MEMORY_PRESSURE in iOS 8's JSC.
Reviewed By: lexs

Differential Revision: D3162471

fb-gh-sync-id: 1fb1584ccfa507c5697958ce8837f637fa8a301c
fbshipit-source-id: 1fb1584ccfa507c5697958ce8837f637fa8a301c
2016-04-22 00:45:25 -07:00
Krzysztof Magiera cd11738819 Support for stopping animations that run on UI thread.
Summary:This change extends animated native module API with `stopAnimation` method that is responsible for interrupting actively running animation as a reslut of a JS call. In order for the `stopAnimation` to understand `animationId` argument I also had to add `animationId` to `startAnimation` method. As JS thread runs in parallel to the thread which executes the animation there is a chance that JS may call `stopAnimation` after the animation has finished. Because of that we are not doing any checks on the `animationId` parameter passed to `stopAnimation` in native and if the animation does not exists in the registry we ignore that call.

**Test Plan**
Run JS tests: `npm test Libraries/Animated/src/__tests__/AnimatedNative-test.js`
Run java tests: `buck test ReactAndroid/src/test/java/com/facebook/react/animated`
Closes https://github.com/facebook/react-native/pull/7058

Differential Revision: D3211906

fb-gh-sync-id: 3761509651de36a550b00d33e2a631c379d3900f
fbshipit-source-id: 3761509651de36a550b00d33e2a631c379d3900f
2016-04-22 00:02:25 -07:00
Christopher Dro 63adb48dc4 Add Zack Story 'rt2zz'
Summary:/cc rt2zz
Closes https://github.com/facebook/react-native/pull/7000

Differential Revision: D3184798

fb-gh-sync-id: b1f4eab40db7c753f7e3773502852bf9a0d05861
fbshipit-source-id: b1f4eab40db7c753f7e3773502852bf9a0d05861
2016-04-21 22:44:24 -07:00
glevi@fb.com 91d4a093ea Fix or suppress errors in react-native
Reviewed By: jeffmo

Differential Revision: D3209973

fb-gh-sync-id: bdc9b4afc0b187b1b16fa6bfb1c34adb4089ab81
fbshipit-source-id: bdc9b4afc0b187b1b16fa6bfb1c34adb4089ab81
2016-04-21 19:47:24 -07:00
Angela Hess 5a93877673 Add ability to disable scroll on android ViewPager
Summary: Similar to ScrollView, adds ability to set scrollEnabled={false}, which prevents dragging. Paging is still possible by updating initialPage.

Reviewed By: AaaChiuuu

Differential Revision: D3209743

fb-gh-sync-id: ce4140323a03f2257a9bb310c7285418b01abae7
fbshipit-source-id: ce4140323a03f2257a9bb310c7285418b01abae7
2016-04-21 19:43:27 -07:00
Lim Chee Aun a0f6704d44 Update HackerWeb in showcase
Summary:Add Android app and blog post link.
Closes https://github.com/facebook/react-native/pull/7128

Differential Revision: D3211037

fb-gh-sync-id: 3d310d7f21f181755b6c473263433a157837cfc9
fbshipit-source-id: 3d310d7f21f181755b6c473263433a157837cfc9
2016-04-21 19:04:23 -07:00
Dan Caspi c6c72ddad4 Set RNFeed to use iOS 8's JSC. Working but missing features.
Reviewed By: lexs

Differential Revision: D3162414

fb-gh-sync-id: d7eb65969486eddd623501e5eaa07f957088a846
fbshipit-source-id: d7eb65969486eddd623501e5eaa07f957088a846
2016-04-21 19:00:30 -07:00
Ben Alpert 9be37ca60e Update to 15.0.2-alpha.2
Reviewed By: zpao

Differential Revision: D3210045

fb-gh-sync-id: 6a1862c8f5f1f759e002cc9663719cb55723c342
fbshipit-source-id: 6a1862c8f5f1f759e002cc9663719cb55723c342
2016-04-21 17:25:29 -07:00
Spencer Ahrens 47dff23fe4 Change "Hide/Show" Inspector to "Toggle"
Summary:The JS and native state can get out of sync if you reload JS while inspecting, so don't even bother trying on
native.

Reviewed By: lexs

Differential Revision: D3203020

fb-gh-sync-id: a3b7294bb0c28c0508f508be53d3ef895a7195b0
fbshipit-source-id: a3b7294bb0c28c0508f508be53d3ef895a7195b0
2016-04-21 16:57:20 -07:00
Ben Nham 91dcc9ac8e Fix autocomplete in rich-text editing mode for CJK text input
Summary:This fixes autocomplete for CJK text input by making sure that the `<Text>` nodes that JS controls to produce attributed text matches the text view's attributed text as much as possible. This is done by giving the disconnected `<Text>` child the same style as the `<TextInput>` parent.

This works because `-[RKTextView performPendingTextUpdate]` avoids setting the attributedText property on textView if the JS attributedText and textView attributedText are equal. This is important because setting attributedText on a text view clears the autocomplete state (markedText property) on a text view, breaking autocomplete for multistage input styles like CJK with a phonetic keyboard.

Reviewed By: nicklockwood

Differential Revision: D3207513

fb-gh-sync-id: 02e582ea5f15191974f15a65ebc1820401715f8d
fbshipit-source-id: 02e582ea5f15191974f15a65ebc1820401715f8d
2016-04-21 12:10:25 -07:00
Sebastian Markbage 47a470a97c Move React Core Integration to a Dependency
Summary:Adding the react native renderer dependency and various fixes to support React 15.

Don't use dispatchID for touchableHandleResponderGrant

This callback argument was removed because "IDs" no longer exist. Instead, we'll
use the tag from the event target.

The corresponding PR on React Core is: https://github.com/facebook/react/pull/6338

Reviewed By: spicyj

Differential Revision: D3159788

fb-gh-sync-id: 60e5cd2aa0af69d83fcdac3dfde0a85a748cb7b9
fbshipit-source-id: 60e5cd2aa0af69d83fcdac3dfde0a85a748cb7b9
2016-04-21 09:28:23 -07:00
Alexey Lang 033e7c80bf Support the bytecode cache for FBReactKit
Reviewed By: javache

Differential Revision: D3174040

fb-gh-sync-id: 8d1c43a55ec8764e5b51f13663613b0f7a4a581e
fbshipit-source-id: 8d1c43a55ec8764e5b51f13663613b0f7a4a581e
2016-04-21 08:59:43 -07:00
Pieter De Baets 2b69ec2589 Provide initial size to Modal
Reviewed By: majak

Differential Revision: D3202211

fb-gh-sync-id: 83a1d3d52df0dc68483639393ab64fd6f1281cb3
fbshipit-source-id: 83a1d3d52df0dc68483639393ab64fd6f1281cb3
2016-04-21 08:57:19 -07:00
Mike Grabowski 0de8962e16 Do not make RCTDevLoadingView a keyWindow
Summary:Hey,

I have been going through some UIAlert related issues in the repo trying to fix them, and one of the steps to start reproducing them was to put `Alert.alert()` call right inside `componentDidMount`.

However, I've started noticing strange bugs as long as I didn't set 1second timeout.

Started digging in deeper, and I've noticed the `UIAlert` gets attached to the `RCTWindow()` mainViewController.

However - since RCTDevLoadingView adds a `keyWindow`, that is the window that will be returned at the time of the call and the window `UIAlert` will be attached to.

To visualise that better - you can take a look at these two frames when app is being loaded:
<img width="371" alt="screen shot 2016-04-20 at 22 02 45" src="https://cloud.githubusercontent.com/assets/2464966/14688596/ae8d292c-0743-11e6-8aeb-e45da391b5b5.png">
<img width="371" alt="screen shot 2016-04-20 at 22 02 58" src="https://cloud.githubusercontent.com/assets/2464966/14688599/b30798e8-0743-11e6-951a-463fe7324c56.png">

AFAIK we do
Closes https://github.com/facebook/react-native/pull/7098

Differential Revision: D3207395

Pulled By: javache

fb-gh-sync-id: f8dca063573ac6f2a0ec497138b2ed0a7b27788b
fbshipit-source-id: f8dca063573ac6f2a0ec497138b2ed0a7b27788b
2016-04-21 07:02:27 -07:00
David Aurelio d8b87b232d Allow for falsy module exports
Reviewed By: javache

Differential Revision: D3207353

fb-gh-sync-id: 3e23eb9cc9facea7993ce684f87ff4b7b0003a1c
fbshipit-source-id: 3e23eb9cc9facea7993ce684f87ff4b7b0003a1c
2016-04-21 06:49:20 -07:00
Martin Konicek bc32e06e56 Add an option to load the Boost library from the filesystem
Summary:Building React Native for Android from source the first time is quite slow. A large part of the time is spent downloading the Boost C++ library. If the code is already present on the system, there's no need to download it.
**Test plan**

CircleCI tests on this pull request. The env variable is not defined on CircleCI so this pull request should have no effect.
Closes https://github.com/facebook/react-native/pull/7116

Differential Revision: D3207397

Pulled By: mkonicek

fb-gh-sync-id: 3454947f6c90fda0d8d2cbb17a1af518e45b47fd
fbshipit-source-id: 3454947f6c90fda0d8d2cbb17a1af518e45b47fd
2016-04-21 06:48:22 -07:00
Alexander Kotliarskyi ec25a6b3f4 Add F8 app to showcase
Summary: Closes https://github.com/facebook/react-native/pull/7104

Differential Revision: D3207372

Pulled By: mkonicek

fb-gh-sync-id: bbfb51a9b16a50fd99adfb4e9cd8372ad2021f1d
fbshipit-source-id: bbfb51a9b16a50fd99adfb4e9cd8372ad2021f1d
2016-04-21 06:47:34 -07:00
Martin Konicek cfa45be2fc Support non-standard path of Android Support Repository
Summary:This is needed in cases when the Android Support Repository is on a non-standard path.

**Test plan (required)**

CircleCI tests on this pull request.
Closes https://github.com/facebook/react-native/pull/7096

Differential Revision: D3207267

Pulled By: mkonicek

fb-gh-sync-id: 7539407f485341352faadc3b07d2c1459e0527f5
fbshipit-source-id: 7539407f485341352faadc3b07d2c1459e0527f5
2016-04-21 05:13:34 -07:00
Viktor Eriksson 8b314726e9 Option to not store credentials in file
Summary:**Motivation:** I don't like storing credentials in config files and a safer solution is to store them in the Keychain Access app.

Therefore I added a link that describes how one may go about to store the passwords in the Keychain Access app in OSX instead.

Found a [stackoverflow post](http://stackoverflow.com/a/24480579/1836121) but it wasn't very detailed so I decided to write it up myself. I understand if you have some policy against external links to blogs and I guess we could link to the stackoverflow explanation then instead.
Closes https://github.com/facebook/react-native/pull/7089

Differential Revision: D3207215

fb-gh-sync-id: 8011b55efe41ec6d54ad665e0e6a79cb9d806779
fbshipit-source-id: 8011b55efe41ec6d54ad665e0e6a79cb9d806779
2016-04-21 04:08:23 -07:00
Nick Lockwood 362738a776 Fixed some issues with zero fontSizeMultiplier causing RCTSHadowText measure function to return an infinite height
Summary:The default value for fontSizeMultiplier was zero. Although this was usually overriden with the correct value (typically 1.0), it sometimes wasn't resulting in a divide-by-zero in the text height calculation.

This diff corrects that bug by setting 1.0 as the default, and guarding against zero values being set.

I also fixed some suspicious logic that seemed to assume the result of BOOL && CGFloat would be 0 or the CGFloat value, which is true in JS but not in C (it would always be 0 or 1).

Reviewed By: javache

Differential Revision: D3179196

fb-gh-sync-id: cc09b104c9087fc1a2f45d8d3f70af221c2ad823
fbshipit-source-id: cc09b104c9087fc1a2f45d8d3f70af221c2ad823
2016-04-21 03:57:18 -07:00
Spencer Ahrens 99705440a0 Fix some warnings.
Reviewed By: AaaChiuuu

Differential Revision: D3206005

fb-gh-sync-id: 88c0cec6b88479fac747a7ef6a677df30c282089
fbshipit-source-id: 88c0cec6b88479fac747a7ef6a677df30c282089
2016-04-20 20:45:22 -07:00
Mike Grabowski 9d7b537dd4 Mention native code in Linking docs
Summary:Fixes #5925
Closes https://github.com/facebook/react-native/pull/7101

Differential Revision: D3206134

fb-gh-sync-id: e65ae97c32685d6acc08be2019dd2da902e01bc9
fbshipit-source-id: e65ae97c32685d6acc08be2019dd2da902e01bc9
2016-04-20 19:23:19 -07:00
Janic Duplessis 51310b0669 Bump babel-preset-react-native version
Summary:To include a missing part of the fix to HMR on Windows that was done in 0.25rc. See https://github.com/facebook/react-native/commit/c61100d0ceb4b71c86f01f35d7464d2d8a02b342. Will need to also publish to npm.

cc ide grabbou
Closes https://github.com/facebook/react-native/pull/7076

Differential Revision: D3199977

fb-gh-sync-id: b97da3c91d3723eaa40f63550e053d224689d517
fbshipit-source-id: b97da3c91d3723eaa40f63550e053d224689d517
2016-04-20 18:14:21 -07:00
Horcrux 4e5c85b6bb [ART]fix stroke bug
Summary:Fix a stroke bug.
Stroke path will be coverd by fill layer.
Fix it by stroke path after fill is done
Closes https://github.com/facebook/react-native/pull/7092

Differential Revision: D3203188

Pulled By: spicyj

fb-gh-sync-id: 9b950372822da4dc520552c0c31aa3435750a0a3
fbshipit-source-id: 9b950372822da4dc520552c0c31aa3435750a0a3
2016-04-20 12:50:29 -07:00
Martin Kralik 85f7569ce6 fix incorrect layout for modal
Summary:We had an issue where a rendered modal would not end up using the full screen size, but a size computed based on its initial content.
Which is a small spinner in case of RelayContainer. So rarely we would end up with cut off view like this:
{F60650629}

This diff fixes this behavior by wrapping the content in another view. That makes the modal's wrapping VC's view resize just once when it's initially created. (Resize for the wrapping VC's view happened previously when the modal's content resized, which got us in the bad state.)

Reviewed By: javache

Differential Revision: D3202299

fb-gh-sync-id: 7c4dc1dbb27654292d07aef5916aa31df5cd4302
fbshipit-source-id: 7c4dc1dbb27654292d07aef5916aa31df5cd4302
2016-04-20 11:20:26 -07:00
Martin Kralik eff673572e pass flexiblity to shadowrootview on its creation
Reviewed By: javache

Differential Revision: D3177404

fb-gh-sync-id: 2116628461e37e9f1d1b3cbc6d6560675cadee7e
fbshipit-source-id: 2116628461e37e9f1d1b3cbc6d6560675cadee7e
2016-04-20 10:53:21 -07:00
Pieter De Baets 5cdfe0f4b1 Report JSC errors as JS exceptions
Summary:When JSC throws an error on startup (e.g. a SyntaxError) or when invoking a method that is not caught by RCTExceptionsManager, we previously just reported is a native error, with a (useless) native stack trace in the redbox. This changes that behaviour to report a JS stacktrace.

The same issue was previously reported here: https://github.com/facebook/react-native/pull/5677

Reviewed By: majak

Differential Revision: D3037387

fb-gh-sync-id: 06f8333e0eb50dcef0b26284754262301b8a5f08
fbshipit-source-id: 06f8333e0eb50dcef0b26284754262301b8a5f08
2016-04-20 09:13:29 -07:00
Philipp von Weitershausen ed930b4710 Add support for sending binary data in websockets
Summary:This is a reprise of #6327, but with iOS 7.0 compatibility and less `package.json` changes.

**Test Plan:** Load WebSocketExample in UIExplorer app and start websocket test server script (both provided in #6889) and test sending binary data on both iOS and Android
Closes https://github.com/facebook/react-native/pull/6961

Differential Revision: D3202022

Pulled By: mkonicek

fb-gh-sync-id: 38843d0a9c0172971c5c70a5139ded04042b280a
fbshipit-source-id: 38843d0a9c0172971c5c70a5139ded04042b280a
2016-04-20 08:53:25 -07:00
Spencer Ahrens ad15b74aae cleanup and open source JS BugReporting module
Summary:This is just the JS part of a bug reporting module that can be used with a pure JS flow or a native reporting
flow. It's handy for grabbing data from a bunch of random components, like the ids of the rows that are visible in a
list view at the time the bug is reported, or a description of the current navigation stack.

It's initialized in `AppRegistry` so it's always ready to go and bug reports will always include the universal
`runApplication` info, but won't actually do anything by default unless `collectExtraData` is called.

Note: some apps may call `runApplication` multiple times if they have multiple react native root views. This will just
overwrite the source so it will just report the most recently mounted one.

Reviewed By: foghina

Differential Revision: D3200203

fb-gh-sync-id: 8ed45fc9b289e8d9c50d3c85926213bd245d3ecc
fbshipit-source-id: 8ed45fc9b289e8d9c50d3c85926213bd245d3ecc
2016-04-20 08:09:07 -07:00
Dave Miller eb21b25e2d Fix Popover.android to bubble events correctly
Reviewed By: andreicoman11, fkgozali

Differential Revision: D3197104

fb-gh-sync-id: 882f85175f87200b7aef1ca4204d6dfb6c4c4c69
fbshipit-source-id: 882f85175f87200b7aef1ca4204d6dfb6c4c4c69
2016-04-20 00:59:27 -07:00
Hedger Wang 6731de7b45 Fix NavigationView.
Reviewed By: ericvicenti

Differential Revision: D3200293

fb-gh-sync-id: 3ffc7053b11f926461c45e19651d07295ca3ae72
fbshipit-source-id: 3ffc7053b11f926461c45e19651d07295ca3ae72
2016-04-19 19:56:21 -07:00
Mike Grabowski 91a52421d4 Strip shebang when present in JS files
Summary:Fixes #7034
Closes https://github.com/facebook/react-native/pull/7073

Differential Revision: D3199816

fb-gh-sync-id: 2099dd1f81b030933794be6a592a697cec3627d0
fbshipit-source-id: 2099dd1f81b030933794be6a592a697cec3627d0
2016-04-19 18:09:22 -07:00
Elliot Lynde 7e515f8d4a Wait longer for debugger proxy
Reviewed By: yuzhi

Differential Revision: D3198412

fb-gh-sync-id: fe11f74b2a019accc24b08162746ce4793a49b90
fbshipit-source-id: fe11f74b2a019accc24b08162746ce4793a49b90
2016-04-19 17:13:25 -07:00
Hedger Wang 81c62c5f41 Fix initial scenes rendering.
Summary:The initial layout used to render scenes does not contain the actual
width and height measured and causes the issue as described at
https://github.com/ericvicenti/navigation-rfc/issues/61

The fix is to update the layout and re-render scenes once layout
is modified. Also scenes renderer should also consider the case that
when the layout is not measured yet.

Reviewed By: ericvicenti

Differential Revision: D3162143

fb-gh-sync-id: 197574329d3849cad2a21e07e1bd5e800f74c3ea
fbshipit-source-id: 197574329d3849cad2a21e07e1bd5e800f74c3ea
2016-04-19 15:57:20 -07:00
Spencer Ahrens ecae44aaae Fix potential "Should never unset includeInLayout" invariant
Reviewed By: devknoll

Differential Revision: D3194174

fb-gh-sync-id: 67d065ea90f8416a5fc7e3651c68350f895f9639
fbshipit-source-id: 67d065ea90f8416a5fc7e3651c68350f895f9639
2016-04-19 13:55:26 -07:00
Krzysztof Magiera ec5dfbf8c7 Support for Animated.multiply node
Summary:This change adds native animated support for Animated.multiply nodes.

Animated.multiply allows for defining nodes that would output a product of values of the input nodes.

**Test Plan**
Run JS tests: `npm test Libraries/Animated/src/__tests__/AnimatedNative-test.js`
Run java tests: `buck test ReactAndroid/src/test/java/com/facebook/react/animated`
Closes https://github.com/facebook/react-native/pull/7071

Differential Revision: D3197663

fb-gh-sync-id: 35f64244a2482c487a81e5e7cd08f3c0e56d9b78
fbshipit-source-id: 35f64244a2482c487a81e5e7cd08f3c0e56d9b78
2016-04-19 13:20:20 -07:00
Pieter De Baets 3e2a3ca466 Move RCTJSCExecutorTests to ReactKitBenchmarks
Reviewed By: jspahrsummers

Differential Revision: D3192966

fb-gh-sync-id: 2c0caef1217545a131396326546d610e345db597
fbshipit-source-id: 2c0caef1217545a131396326546d610e345db597
2016-04-19 11:37:28 -07:00
Pavlo Tkach dbac1d891a Update showcase.js
Summary:Added new app in showcase.js
Closes https://github.com/facebook/react-native/pull/6912

Differential Revision: D3196473

fb-gh-sync-id: 8c06763907e5bf998c0f0edd832fd1f032ece35c
fbshipit-source-id: 8c06763907e5bf998c0f0edd832fd1f032ece35c
2016-04-19 09:20:24 -07:00
Tadeu Zagallo 887c275bcf Free modules' factories after caching module
Summary:The require functions will keep the generate bytecode + lexical environment in
memory unnecessarily, since we can be sure that it will be executed at most once

Reviewed By: davidaurelio

Differential Revision: D3168257

fb-gh-sync-id: 038e1bc08abea94ee52d0390b6aced5fb652f493
fbshipit-source-id: 038e1bc08abea94ee52d0390b6aced5fb652f493
2016-04-19 08:13:24 -07:00
Dave Miller 551c154261 Remove RKModal and Portal
Reviewed By: andreicoman11

Differential Revision: D3192529

fb-gh-sync-id: 4ea5d9d3e3b4f435e86a5dba4ddb7812f8d00fbc
fbshipit-source-id: 4ea5d9d3e3b4f435e86a5dba4ddb7812f8d00fbc
2016-04-19 07:42:29 -07:00
Thom Dixon d586daad51 Fix red screen due to ref being undefined in PullRefreshViewAndroid
Summary:This fixes the error
`undefined is not an object (evaluating 'this.refs[NATIVE_REF].setNativeProps')`, which seems to occur when the refresh fails (in our case due to CORS).

![screen shot 2016-03-16 at 12 23 52](https://cloud.githubusercontent.com/assets/461514/13826121/1f8b0aaa-eb73-11e5-81e3-b2c60e536bf0.png)
Closes https://github.com/facebook/react-native/pull/6489

Differential Revision: D3172217

fb-gh-sync-id: 5ba3b2653685888f5358ef32b01b441757eff7c8
fbshipit-source-id: 5ba3b2653685888f5358ef32b01b441757eff7c8
2016-04-19 06:58:22 -07:00
MikePodgorniy d72f151bfc Add Emoji Poetry to showcase.js
Summary:Emoji Poetry app for showcase page
Closes https://github.com/facebook/react-native/pull/6879

Differential Revision: D3196123

fb-gh-sync-id: f9db698c64c7d9077ce359f28d6dd10ff49f7d8b
fbshipit-source-id: f9db698c64c7d9077ce359f28d6dd10ff49f7d8b
2016-04-19 06:52:22 -07:00
Konstantin Raev a5e50de1a7 fixed website deployment condition logic
Summary:Rookie mistake I made.

**Test plan (required)**

See that https://circleci.com/gh/facebook/react-native/5462 succeeds deploying the website correctly.
Closes https://github.com/facebook/react-native/pull/7063

Differential Revision: D3196198

fb-gh-sync-id: 14fdc94fad0b1e5ff74cc90bb89d2bd1bf29bfa3
fbshipit-source-id: 14fdc94fad0b1e5ff74cc90bb89d2bd1bf29bfa3
2016-04-19 06:43:23 -07:00
anback 1d9c7a47fd added veckopengen app to showcase js
Summary:added app to website/showcase.js that is built with React Native.
Closes https://github.com/facebook/react-native/pull/7018

Differential Revision: D3196127

Pulled By: mkonicek

fb-gh-sync-id: e4f29f00eaf2f8cd1eab53fe83822c6480baa511
fbshipit-source-id: e4f29f00eaf2f8cd1eab53fe83822c6480baa511
2016-04-19 05:30:19 -07:00
Joshua Sierles 1c6d815a88 Use latest simulator by not specifying the OS version
Summary:Appetize asked for this so they can better support us, since they will usually have more simulators available for the latest versions.
Closes https://github.com/facebook/react-native/pull/7061

Differential Revision: D3196110

Pulled By: mkonicek

fb-gh-sync-id: 2406ab6e1ee352f0148957e851d7f483a2182f90
fbshipit-source-id: 2406ab6e1ee352f0148957e851d7f483a2182f90
2016-04-19 05:16:20 -07:00
Mike Grabowski 5e27ff2b27 Updates to release notes
Summary:Quite a few updates, some of them were mainly styling ones (please tell me to either revert them or update if they do not match the style guide!).

Clarified test steps and improved release scripts so that they are easier to read.

I have also removed a note about tags and CircleCi pushing a release since that's already done for us by a `update-oss-version`.

Another update is that we now mention steps to check that are printed by `test-manual-e2e.sh` as I have noticed they were recently updated, so better to just clarify they are printed out.
Closes https://github.com/facebook/react-native/pull/7041

Differential Revision: D3196122

Pulled By: mkonicek

fb-gh-sync-id: d3f87e6340ef3cddd4719902a05231072f05a287
fbshipit-source-id: d3f87e6340ef3cddd4719902a05231072f05a287
2016-04-19 05:12:20 -07:00
Mike Grabowski d9349a7b79 Update imports in generated projects
Summary:Fixes warnings when React API is used by requiring 'react-native'.
Closes https://github.com/facebook/react-native/pull/7060

Differential Revision: D3196109

Pulled By: mkonicek

fb-gh-sync-id: b47afc138cd7909ad53c0d67a65e3a124b87134b
fbshipit-source-id: b47afc138cd7909ad53c0d67a65e3a124b87134b
2016-04-19 05:11:27 -07:00
Nick Lockwood 546d140ec7 Fix array bounds crash in MapView
Summary: Under some circumstances, the calloutIndex might be > number of callout views, (possibly due to a race condition?). This prevents that from crashing.

Reviewed By: tadeuzagallo

Differential Revision: D3196010

fb-gh-sync-id: 6485e64c682937431cb8598d7f3f42e8d37eeff1
fbshipit-source-id: 6485e64c682937431cb8598d7f3f42e8d37eeff1
2016-04-19 05:03:22 -07:00
Leland Richardson e9398c7926 Whitelist the 'pdf' extension in the packager
Summary:The WebView component in iOS currently does not support displaying PDFs without providing a remote URI or manually including the assets in the xcodeproj itself. This is because the packager has not whitelisted the 'pdf' extension.

I've gone ahead and whitelisted the 'pdf extension according to the recommendation by nicklockwood

GH comment: https://github.com/facebook/react-native/issues/1846#issuecomment-199302488
Closes https://github.com/facebook/react-native/pull/7004

Differential Revision: D3196019

Pulled By: nicklockwood

fb-gh-sync-id: 10a86a9232095f98f277506141de0b8af5b21ab4
fbshipit-source-id: 10a86a9232095f98f277506141de0b8af5b21ab4
2016-04-19 03:52:27 -07:00
Krzysztof Magiera b5375bdc09 Support for Animated.add
Summary:This change adds suport native animated support for Animated.add.

Animated.add lets you declare node that outputs a sum of it input nodes.

**Test Plan**
Play with the following playground app: https://gist.github.com/39de37faf07480fcd7d1
Run JS tests: `npm test Libraries/Animated/src/__tests__/AnimatedNative-test.js`
Run java tests: `buck test ReactAndroid/src/test/java/com/facebook/react/animated`
Closes https://github.com/facebook/react-native/pull/6641

Differential Revision: D3195963

fb-gh-sync-id: bb1e1a36821a0e071ad0e7d0fa99ce0d6b088b0a
fbshipit-source-id: bb1e1a36821a0e071ad0e7d0fa99ce0d6b088b0a
2016-04-19 02:58:21 -07:00
Angela Hess 64d5da7754 Replace opacity console error with warning
Summary: This error message is remarkably aggressive relative to the severity of the issue, particularly since the pattern in question is used / necessary throughout the codebase. Animated ReactART components with set opacities trigger this error, and opacity coming from the style prop is not respected.

Reviewed By: sahrens

Differential Revision: D3177554

fb-gh-sync-id: 96061d5ff526177814996b28e4394e6649839582
fbshipit-source-id: 96061d5ff526177814996b28e4394e6649839582
2016-04-18 18:53:20 -07:00
TETRA2000 978fa488ec add space between words
Summary: Closes https://github.com/facebook/react-native/pull/7045

Differential Revision: D3194558

fb-gh-sync-id: 57691d4d54bbe2bdce6abf885b6aa0f341f12644
fbshipit-source-id: 57691d4d54bbe2bdce6abf885b6aa0f341f12644
2016-04-18 18:29:23 -07:00
Philipp von Weitershausen ebb44d202b Clean up and simplify WebSocket implementation on the JS side
Summary:- Get rid of no longer necessary WebSocket.js v WebSocketBase.js split
- Use `EventTarget(list, of, events)` as base class to auto-generate `oneventname` getters/setters that get invoked along with other event handlers
- Type annotation `any` considered harmful, especially when we can easily spell out the actual type
- Throw in some `const` goodness for free

**Test Plan:** Launch UIExplorer example app, supplied `websocket_test_server` script, and try different combinations of sending and receiving text and binary data on both iOS and Android.
Closes https://github.com/facebook/react-native/pull/6889

Differential Revision: D3184835

Pulled By: mkonicek

fb-gh-sync-id: f21707f4e97aa5a79847f5157e0a9f132a1a01cd
fbshipit-source-id: f21707f4e97aa5a79847f5157e0a9f132a1a01cd
2016-04-18 15:43:25 -07:00
John Doe 0fa48c00a9 Adding helium to showcase.js
Summary:Show my app : Helium

Helium is an app where people can discover the best of what others are up to in their free time .
Closes https://github.com/facebook/react-native/pull/7035

Differential Revision: D3191805

Pulled By: mkonicek

fb-gh-sync-id: 03117821a6bce1924415b68df9ad8a2770acb930
fbshipit-source-id: 03117821a6bce1924415b68df9ad8a2770acb930
2016-04-18 11:50:26 -07:00
Micha? Gregorczyk fd35ddcc65 Store lock file in persistent directory.
Reviewed By: tadeuzagallo

Differential Revision: D3190827

fb-gh-sync-id: 42dd65bccd7c248989475f68c81061079e3601a4
fbshipit-source-id: 42dd65bccd7c248989475f68c81061079e3601a4
2016-04-18 11:45:39 -07:00
Mike Grabowski 1bee3467ad Update releasing guide
Summary:This is WIP as I am going through release steps. Submitting few ideas.

List:
- NDK is actually needed in the first step for the e2e scripts to run.
Closes https://github.com/facebook/react-native/pull/7038

Differential Revision: D3191761

Pulled By: mkonicek

fb-gh-sync-id: e6bd51b3c339ed430086f4e21a3b3e6c3864f06f
fbshipit-source-id: e6bd51b3c339ed430086f4e21a3b3e6c3864f06f
2016-04-18 11:35:24 -07:00
Martin Konicek 5bb6926e40 Simplify manual testing steps when doing the release
Summary:Quite a few of these steps are now tested automatically on Android thanks to bestander.

**Test plan**

Just visual inspection of the code :)
Closes https://github.com/facebook/react-native/pull/7037

Differential Revision: D3191678

fb-gh-sync-id: 54702a772c5c149bdd3f05d6f4ca257bc6f27090
fbshipit-source-id: 54702a772c5c149bdd3f05d6f4ca257bc6f27090
2016-04-18 11:32:28 -07:00
Philipp von Weitershausen 20cae51a8f Add support for receiving binary type data (ArrayBuffer)
Summary:This brings the same functionality that's already present on iOS, introduced in #4483, to Android: convert binary payloads to base64 strings and send them to JS land that way, where they'll be turned into an ArrayBuffer.

**Test Plan:** Used test server from #6889 (in `--binary` mode) to send some binary data to the Android UIExplorer example (also from #6889). Verified it's received correctly as `ArrayBuffer`.
Closes https://github.com/facebook/react-native/pull/6868

Differential Revision: D3184797

Pulled By: mkonicek

fb-gh-sync-id: e78c640c43b3e41a75ddba79acc04e5eaab5667d
fbshipit-source-id: e78c640c43b3e41a75ddba79acc04e5eaab5667d
2016-04-18 11:12:28 -07:00
Felix Oghina a3ef44b4ba throw IllegalArgumentException instead of AssertionError when JS module is not found
Reviewed By: astreet

Differential Revision: D3190875

fb-gh-sync-id: ac34872d8d36247a8bb28bdfbf985ebcdadd4e33
fbshipit-source-id: ac34872d8d36247a8bb28bdfbf985ebcdadd4e33
2016-04-18 10:01:19 -07:00
447 changed files with 11001 additions and 7148 deletions
+4 -6
View File
@@ -15,8 +15,6 @@
# Ignore react and fbjs where there are overlaps, but don't ignore
# anything that react-native relies on
.*/node_modules/fbjs/lib/Map.js
.*/node_modules/fbjs/lib/fetch.js
.*/node_modules/fbjs/lib/ExecutionEnvironment.js
.*/node_modules/fbjs/lib/ErrorUtils.js
# Flow has a built-in definition for the 'react' module which we prefer to use
@@ -81,15 +79,15 @@ esproposal.class_instance_fields=enable
munge_underscores=true
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\)$' -> 'RelativeImageStub'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-3]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-3]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
[version]
0.23.0
0.24.0
+3 -4
View File
@@ -3,13 +3,12 @@ language: objective-c
osx_image: xcode7.3
install:
- brew update
- brew reinstall nvm xctool
- mkdir -p /Users/travis/build/facebook/.nvm
- export NVM_DIR="/Users/travis/build/facebook/.nvm"
- brew install nvm
- source $(brew --prefix nvm)/nvm.sh
# testing with npm@2 for diversity, Circle tests with npm@3
- nvm install 4.4.0
- nvm install 4.4.3
- rm -Rf "${TMPDIR}/jest_preprocess_cache"
- npm config set spin=false
- npm config set progress=false
@@ -17,7 +16,7 @@ install:
script:
- if [[ "$TEST_TYPE" = objc ]]; then travis_retry ./scripts/objc-test.sh; fi
- if [[ "$TEST_TYPE" = e2e-objc ]]; then travis_retry node ./scripts/run-ci-e2e-tests.js --ios --js; fi
- if [[ "$TEST_TYPE" = e2e-objc ]]; then node ./scripts/run-ci-e2e-tests.js --ios --js --retries 3; fi
- if [[ "$TEST_TYPE" = js ]]; then npm run flow check; fi
- if [[ "$TEST_TYPE" = js ]]; then npm test -- --maxWorkers=1; fi
+8 -2
View File
@@ -267,7 +267,10 @@
INFOPLIST_FILE = "$(SRCROOT)/2048/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = 2048;
};
@@ -285,7 +288,10 @@
INFOPLIST_FILE = "$(SRCROOT)/2048/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = 2048;
};
-3
View File
@@ -45,9 +45,6 @@ var MovieCell = React.createClass({
onShowUnderlay={this.props.onHighlight}
onHideUnderlay={this.props.onUnhighlight}>
<View style={styles.row}>
{/* $FlowIssue #7363964 - There's a bug in Flow where you cannot
* omit a property or set it to undefined if it's inside a shape,
* even if it isn't required */}
<Image
source={getImageSource(this.props.movie, 'det')}
style={styles.cellImage}
-3
View File
@@ -34,9 +34,6 @@ var MovieScreen = React.createClass({
return (
<ScrollView contentContainerStyle={styles.contentContainer}>
<View style={styles.mainSection}>
{/* $FlowIssue #7363964 - There's a bug in Flow where you cannot
* omit a property or set it to undefined if it's inside a shape,
* even if it isn't required */}
<Image
source={getImageSource(this.props.movie, 'det')}
style={styles.detailsImage}
@@ -357,7 +357,10 @@
INFOPLIST_FILE = "$(SRCROOT)/Movies/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Movies;
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../Libraries/**";
@@ -376,7 +379,10 @@
INFOPLIST_FILE = "$(SRCROOT)/Movies/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Movies;
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../Libraries/**";
@@ -3,7 +3,7 @@
*/
'use strict';
jest.dontMock('../getImageSource');
jest.unmock('../getImageSource');
var getImageSource = require('../getImageSource');
@@ -327,7 +327,10 @@
INFOPLIST_FILE = "$(SRCROOT)/TicTacToe/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = TicTacToe;
};
@@ -345,7 +348,10 @@
INFOPLIST_FILE = "$(SRCROOT)/TicTacToe/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = TicTacToe;
};
+1
View File
@@ -13,6 +13,7 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var {
StyleSheet,
+1
View File
@@ -13,6 +13,7 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var {
Image,
@@ -0,0 +1,171 @@
/**
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @flow
*/
'use strict';
const React = require('react');
const ReactNative = require('react-native');
const {
LayoutAnimation,
StyleSheet,
Text,
View,
TouchableOpacity,
} = ReactNative;
const AddRemoveExample = React.createClass({
getInitialState() {
return {
views: [],
};
},
componentWillUpdate() {
LayoutAnimation.easeInEaseOut();
},
_onPressAddView() {
this.setState((state) => ({views: [...state.views, {}]}));
},
_onPressRemoveView() {
this.setState((state) => ({views: state.views.slice(0, -1)}));
},
render() {
const views = this.state.views.map((view, i) =>
<View key={i} style={styles.view}>
<Text>{i}</Text>
</View>
);
return (
<View style={styles.container}>
<TouchableOpacity onPress={this._onPressAddView}>
<View style={styles.button}>
<Text>Add view</Text>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={this._onPressRemoveView}>
<View style={styles.button}>
<Text>Remove view</Text>
</View>
</TouchableOpacity>
<View style={styles.viewContainer}>
{views}
</View>
</View>
);
},
});
const GreenSquare = () =>
<View style={styles.greenSquare}>
<Text>Green square</Text>
</View>;
const BlueSquare = () =>
<View style={styles.blueSquare}>
<Text>Blue square</Text>
</View>;
const CrossFadeExample = React.createClass({
getInitialState() {
return {
toggled: false,
};
},
_onPressToggle() {
LayoutAnimation.easeInEaseOut();
this.setState((state) => ({toggled: !state.toggled}));
},
render() {
return (
<View style={styles.container}>
<TouchableOpacity onPress={this._onPressToggle}>
<View style={styles.button}>
<Text>Toggle</Text>
</View>
</TouchableOpacity>
<View style={styles.viewContainer}>
{
this.state.toggled ?
<GreenSquare /> :
<BlueSquare />
}
</View>
</View>
);
},
});
const styles = StyleSheet.create({
container: {
flex: 1,
},
button: {
borderRadius: 5,
backgroundColor: '#eeeeee',
padding: 10,
marginBottom: 10,
},
buttonText: {
fontSize: 16,
},
viewContainer: {
flex: 1,
flexDirection: 'row',
flexWrap: 'wrap',
},
view: {
height: 54,
width: 54,
backgroundColor: 'red',
margin: 8,
alignItems: 'center',
justifyContent: 'center',
},
greenSquare: {
width: 150,
height: 150,
backgroundColor: 'green',
alignItems: 'center',
justifyContent: 'center',
},
blueSquare: {
width: 150,
height: 150,
backgroundColor: 'blue',
alignItems: 'center',
justifyContent: 'center',
},
});
exports.title = 'Layout Animation';
exports.description = 'Layout animation';
exports.examples = [{
title: 'Add and remove views',
render(): ReactElement {
return <AddRemoveExample />;
},
}, {
title: 'Cross fade views',
render(): ReactElement {
return <CrossFadeExample />;
},
}];
+18 -8
View File
@@ -66,7 +66,7 @@ var Button = React.createClass({
var ModalExample = React.createClass({
getInitialState() {
return {
animated: true,
animationType: 'none',
modalVisible: false,
transparent: false,
};
@@ -76,8 +76,8 @@ var ModalExample = React.createClass({
this.setState({modalVisible: visible});
},
_toggleAnimated() {
this.setState({animated: !this.state.animated});
_setAnimationType(type) {
this.setState({animationType: type});
},
_toggleTransparent() {
@@ -91,18 +91,21 @@ var ModalExample = React.createClass({
var innerContainerTransparentStyle = this.state.transparent
? {backgroundColor: '#fff', padding: 20}
: null;
var activeButtonStyle = {
backgroundColor: '#ddd'
};
return (
<View>
<Modal
animated={this.state.animated}
animationType={this.state.animationType}
transparent={this.state.transparent}
visible={this.state.modalVisible}
onRequestClose={() => {this._setModalVisible(false)}}
>
<View style={[styles.container, modalBackgroundStyle]}>
<View style={[styles.innerContainer, innerContainerTransparentStyle]}>
<Text>This modal was presented {this.state.animated ? 'with' : 'without'} animation.</Text>
<Text>This modal was presented {this.state.animationType === 'none' ? 'without' : 'with'} animation.</Text>
<Button
onPress={this._setModalVisible.bind(this, false)}
style={styles.modalButton}>
@@ -111,10 +114,17 @@ var ModalExample = React.createClass({
</View>
</View>
</Modal>
<View style={styles.row}>
<Text style={styles.rowTitle}>Animated</Text>
<Switch value={this.state.animated} onValueChange={this._toggleAnimated} />
<Text style={styles.rowTitle}>Animation Type</Text>
<Button onPress={this._setAnimationType.bind(this, 'none')} style={this.state.animationType === 'none' ? activeButtonStyle : {}}>
none
</Button>
<Button onPress={this._setAnimationType.bind(this, 'slide')} style={this.state.animationType === 'slide' ? activeButtonStyle : {}}>
slide
</Button>
<Button onPress={this._setAnimationType.bind(this, 'fade')} style={this.state.animationType === 'fade' ? activeButtonStyle : {}}>
fade
</Button>
</View>
<View style={styles.row}>
@@ -43,11 +43,17 @@ var Button = React.createClass({
class NotificationExample extends React.Component {
componentWillMount() {
// Add listener for push notifications
PushNotificationIOS.addEventListener('notification', this._onNotification);
// Add listener for local notifications
PushNotificationIOS.addEventListener('localNotification', this._onLocalNotification);
}
componentWillUnmount() {
// Remove listener for push notifications
PushNotificationIOS.removeEventListener('notification', this._onNotification);
// Remove listener for local notifications
PushNotificationIOS.removeEventListener('localNotification', this._onLocalNotification);
}
render() {
@@ -57,6 +63,11 @@ class NotificationExample extends React.Component {
onPress={this._sendNotification}
label="Send fake notification"
/>
<Button
onPress={this._sendLocalNotification}
label="Send fake local notification"
/>
</View>
);
}
@@ -72,9 +83,31 @@ class NotificationExample extends React.Component {
});
}
_sendLocalNotification() {
require('RCTDeviceEventEmitter').emit('localNotificationReceived', {
aps: {
alert: 'Sample local notification',
badge: '+1',
sound: 'default',
category: 'REACT_NATIVE'
},
});
}
_onNotification(notification) {
AlertIOS.alert(
'Notification Received',
'Push Notification Received',
'Alert message: ' + notification.getMessage(),
[{
text: 'Dismiss',
onPress: null,
}]
);
}
_onLocalNotification(notification){
AlertIOS.alert(
'Local Notification Received',
'Alert message: ' + notification.getMessage(),
[{
text: 'Dismiss',
+2
View File
@@ -54,6 +54,7 @@ var TabBarExample = React.createClass({
render: function() {
return (
<TabBarIOS
unselectedTintColor="yellow"
tintColor="white"
barTintColor="darkslateblue">
<TabBarIOS.Item
@@ -81,6 +82,7 @@ var TabBarExample = React.createClass({
</TabBarIOS.Item>
<TabBarIOS.Item
icon={require('./flux.png')}
renderAsOriginal
title="More"
selected={this.state.selectedTab === 'greenTab'}
onPress={() => {
+5 -5
View File
@@ -155,19 +155,19 @@ exports.examples = [
render: function() {
return (
<View>
<Text style={{fontWeight: '100'}}>
<Text style={{fontSize: 20, fontWeight: '100'}}>
Move fast and be ultralight
</Text>
<Text style={{fontWeight: '200'}}>
<Text style={{fontSize: 20, fontWeight: '200'}}>
Move fast and be light
</Text>
<Text style={{fontWeight: 'normal'}}>
<Text style={{fontSize: 20, fontWeight: 'normal'}}>
Move fast and be normal
</Text>
<Text style={{fontWeight: 'bold'}}>
<Text style={{fontSize: 20, fontWeight: 'bold'}}>
Move fast and be bold
</Text>
<Text style={{fontWeight: '900'}}>
<Text style={{fontSize: 20, fontWeight: '900'}}>
Move fast and be ultrabold
</Text>
</View>
@@ -407,6 +407,31 @@ exports.examples = [
);
}
},
{
title: 'fontFamily, fontWeight and fontStyle',
render: function() {
return (
<View>
<TextInput
style={[styles.singleLine, {fontFamily: 'sans-serif'}]}
placeholder="Custom fonts like Sans-Serif are supported"
/>
<TextInput
style={[styles.singleLine, {fontFamily: 'sans-serif', fontWeight: 'bold'}]}
placeholder="Sans-Serif bold"
/>
<TextInput
style={[styles.singleLine, {fontFamily: 'sans-serif', fontStyle: 'italic'}]}
placeholder="Sans-Serif italic"
/>
<TextInput
style={[styles.singleLine, {fontFamily: 'serif'}]}
placeholder="Serif"
/>
</View>
);
}
},
{
title: 'Passwords',
render: function() {
@@ -955,10 +955,6 @@
004D28A61AAF61C70097A701 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
HEADER_SEARCH_PATHS = (
"$(inherited)",
@@ -972,12 +968,6 @@
"$(inherited)",
"$(PROJECT_DIR)/UIExplorerUnitTests",
);
OTHER_LDFLAGS = (
"$(inherited)",
"-framework",
XCTest,
"-ObjC",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
@@ -986,10 +976,6 @@
004D28A71AAF61C70097A701 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../../React/**",
@@ -1002,12 +988,6 @@
"$(inherited)",
"$(PROJECT_DIR)/UIExplorerUnitTests",
);
OTHER_LDFLAGS = (
"$(inherited)",
"-framework",
XCTest,
"-ObjC",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
@@ -1027,7 +1007,6 @@
INFOPLIST_FILE = "$(SRCROOT)/UIExplorer/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited)";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.react.uiapp;
PRODUCT_NAME = UIExplorer;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -1053,7 +1032,6 @@
INFOPLIST_FILE = "$(SRCROOT)/UIExplorer/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited)";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = com.facebook.react.uiapp;
PRODUCT_NAME = UIExplorer;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -1071,10 +1049,6 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_NO_COMMON_BLOCKS = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
@@ -1083,12 +1057,6 @@
INFOPLIST_FILE = UIExplorerIntegrationTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
"-framework",
XCTest,
"-ObjC",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.React.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UIExplorer.app/UIExplorer";
@@ -1101,20 +1069,10 @@
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = UIExplorerIntegrationTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
"-framework",
XCTest,
"-ObjC",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.React.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UIExplorer.app/UIExplorer";
@@ -1178,6 +1136,10 @@
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
SDKROOT = iphoneos;
WARNING_CFLAGS = (
"-Wextra",
@@ -1236,6 +1198,10 @@
);
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
WARNING_CFLAGS = (
+18 -16
View File
@@ -1,4 +1,11 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -15,26 +22,21 @@
*/
'use strict';
const ListView = require('ListView');
const React = require('react');
const ReactNative = require('react-native');
const StyleSheet = require('StyleSheet');
const Text = require('Text');
const TextInput = require('TextInput');
const NavigationContainer = require('NavigationContainer');
const TouchableHighlight = require('TouchableHighlight');
const View = require('View');
const UIExplorerActions = require('./UIExplorerActions');
const {
ListView,
NavigationExperimental,
StyleSheet,
Text,
TextInput,
TouchableHighlight,
View,
} = ReactNative;
const createExamplePage = require('./createExamplePage');
const {
Container: NavigationContainer,
} = NavigationExperimental;
import type {
UIExplorerExample,
} from './UIExplorerList.ios'
} from './UIExplorerList.ios';
const ds = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2,
@@ -154,7 +156,7 @@ class UIExplorerExampleList extends React.Component {
}
_handleRowPress(exampleKey: string): void {
this.props.onNavigate(UIExplorerActions.ExampleAction(exampleKey))
this.props.onNavigate(UIExplorerActions.ExampleAction(exampleKey));
}
}
@@ -167,7 +169,7 @@ function makeRenderable(example: any): ReactClass<any> {
UIExplorerExampleList = NavigationContainer.create(UIExplorerExampleList);
UIExplorerExampleList.makeRenderable = makeRenderable;
var styles = StyleSheet.create({
const styles = StyleSheet.create({
listContainer: {
flex: 1,
},
Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 KiB

After

Width:  |  Height:  |  Size: 364 KiB

+10 -2
View File
@@ -40,8 +40,8 @@ var ComponentExamples: Array<UIExplorerExample> = [
module: require('./ModalExample'),
},
{
key: 'PickerAndroidExample',
module: require('./PickerAndroidExample'),
key: 'PickerExample',
module: require('./PickerExample'),
},
{
key: 'ProgressBarAndroidExample',
@@ -138,6 +138,10 @@ const APIExamples = [
key: 'LinkingExample',
module: require('./LinkingExample'),
},
{
key: 'LayoutAnimationExample',
module: require('./LayoutAnimationExample'),
},
{
key: 'LayoutExample',
module: require('./LayoutExample'),
@@ -174,6 +178,10 @@ const APIExamples = [
key: 'VibrationExample',
module: require('./VibrationExample'),
},
{
key: 'WebSocketExample',
module: require('./WebSocketExample'),
},
{
key: 'XHRExample',
module: require('./XHRExample'),
+16
View File
@@ -69,6 +69,10 @@ var ComponentExamples: Array<UIExplorerExample> = [
key: 'NavigatorIOSExample',
module: require('./NavigatorIOSExample'),
},
{
key: 'PickerExample',
module: require('./PickerExample'),
},
{
key: 'PickerIOSExample',
module: require('./PickerIOSExample'),
@@ -144,6 +148,10 @@ var APIExamples: Array<UIExplorerExample> = [
key: 'AdSupportIOSExample',
module: require('./AdSupportIOSExample'),
},
{
key: 'AlertExample',
module: require('./AlertExample').AlertExample,
},
{
key: 'AlertIOSExample',
module: require('./AlertIOSExample'),
@@ -192,6 +200,10 @@ var APIExamples: Array<UIExplorerExample> = [
key: 'ImageEditingExample',
module: require('./ImageEditingExample'),
},
{
key: 'LayoutAnimationExample',
module: require('./LayoutAnimationExample'),
},
{
key: 'LayoutExample',
module: require('./LayoutExample'),
@@ -248,6 +260,10 @@ var APIExamples: Array<UIExplorerExample> = [
key: 'VibrationExample',
module: require('./VibrationExample'),
},
{
key: 'WebSocketExample',
module: require('./WebSocketExample'),
},
{
key: 'XHRExample',
module: require('./XHRExample.ios'),
@@ -133,52 +133,4 @@ RCTAssertEqualSizes(a.size, b.size); \
RCTAssertEqualRects(expected, result);
}
- (void)testPlaceholderImage
{
CGSize size = {45, 22};
CGFloat expectedScale = 1.0;
UIImage *image = RCTGetPlaceholderImage(size, nil);
RCTAssertEqualSizes(size, image.size);
XCTAssertEqual(expectedScale, image.scale);
}
- (void)testPlaceholderNonintegralSize
{
CGSize size = {3.0/2, 7.0/3};
CGFloat expectedScale = 6;
CGSize pixelSize = {
round(size.width * expectedScale),
round(size.height * expectedScale)
};
UIImage *image = RCTGetPlaceholderImage(size, nil);
RCTAssertEqualSizes(size, image.size);
XCTAssertEqual(pixelSize.width, CGImageGetWidth(image.CGImage));
XCTAssertEqual(pixelSize.height, CGImageGetHeight(image.CGImage));
XCTAssertEqual(expectedScale, image.scale);
}
- (void)testPlaceholderSquareImage
{
CGSize size = {333, 333};
CGFloat expectedScale = 1.0/333;
CGSize pixelSize = {1, 1};
UIImage *image = RCTGetPlaceholderImage(size, nil);
RCTAssertEqualSizes(size, image.size);
XCTAssertEqual(pixelSize.width, CGImageGetWidth(image.CGImage));
XCTAssertEqual(pixelSize.height, CGImageGetHeight(image.CGImage));
XCTAssertEqual(expectedScale, image.scale);
}
- (void)testPlaceholderNonsquareImage
{
CGSize size = {640, 480};
CGFloat expectedScale = 1.0/160;
CGSize pixelSize = {4, 3};
UIImage *image = RCTGetPlaceholderImage(size, nil);
RCTAssertEqualSizes(size, image.size);
XCTAssertEqual(pixelSize.width, CGImageGetWidth(image.CGImage));
XCTAssertEqual(pixelSize.height, CGImageGetHeight(image.CGImage));
XCTAssertEqual(expectedScale, image.scale);
}
@end
@@ -19,8 +19,6 @@
#import "RCTJSCExecutor.h"
#import "RCTUtils.h"
#define RUN_PERF_TESTS 0
@interface RCTJSCExecutorTests : XCTestCase
@end
@@ -49,164 +47,4 @@
[_executor invalidate];
}
#if RUN_PERF_TESTS
static uint64_t _get_time_nanoseconds(void)
{
static struct mach_timebase_info tb_info = {0, 0};
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
int ret = mach_timebase_info(&tb_info);
assert(0 == ret);
});
return (mach_absolute_time() * tb_info.numer) / tb_info.denom;
}
- (void)testDeserializationPerf
{
// This test case checks the assumption that deserializing objects from JavaScript
// values one-by-one via ObjC JSC API is slower than using JSON string
// You might want to switch your tests schema to "Release" build configuration
JSContextGroupRef group = JSContextGroupCreate();
JSGlobalContextRef context = JSGlobalContextCreateInGroup(group, NULL);
id message = @[@[@1, @2, @3, @4], @[@{@"a": @1}, @{@"b": @2}], (id)kCFNull];
NSString *code = RCTJSONStringify(message, NULL);
JSStringRef script = JSStringCreateWithCFString((__bridge CFStringRef)code);
JSValueRef error = NULL;
JSValueRef value = JSEvaluateScript(context, script, NULL, NULL, 0, &error);
XCTAssertTrue(error == NULL);
id obj;
uint64_t start = _get_time_nanoseconds();
for (int i = 0; i < 10000; i++) {
JSStringRef jsonJSString = JSValueCreateJSONString(context, value, 0, nil);
NSString *jsonString = (__bridge NSString *)JSStringCopyCFString(kCFAllocatorDefault, jsonJSString);
JSStringRelease(jsonJSString);
obj = RCTJSONParse(jsonString, NULL);
}
NSLog(@"JSON Parse time: %.2fms", (_get_time_nanoseconds() - start) / 1000000.0);
JSStringRelease(script);
JSGlobalContextRelease(context);
JSContextGroupRelease(group);
}
- (void)testJavaScriptCallSpeed
{
/**
* Since we almost don't change the RCTJSCExecutor logic, and this test is
* very likely to become flaky (specially across different devices) leave it
* to be run manually
*
* Previous Values: If you change the executor code, you should update this values
*/
int const runs = 4e5;
int const frequency = 10;
double const threshold = 0.1;
static double const expectedTimes[] = {
0x1.6199943826cf1p+13,
0x1.a3bc0a81551c3p+13,
0x1.d49fbb8602fe3p+13,
0x1.d1f64085ecb7bp+13,
};
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
NSString *script = @" \
var modules = { \
module: { \
method: function () { \
return true; \
} \
} \
}; \
var Bridge = { \
callFunctionReturnFlushedQueue: function(module, method, args) { \
modules[module].apply(modules[module], args); \
} \
}; \
function require(module) { \
return Bridge; \
} \
";
[_executor executeApplicationScript:[script dataUsingEncoding:NSUTF8StringEncoding] sourceURL:[NSURL URLWithString:@"http://localhost:8081/"] onComplete:^(__unused NSError *error) {
NSMutableArray *params = [NSMutableArray new];
id data = @1;
for (int i = 0; i < 4; i++) {
double samples[runs / frequency];
int size = runs / frequency;
double total = 0;
for (int j = 0; j < runs; j++) {
@autoreleasepool {
double start = _get_time_nanoseconds();
[_executor callFunctionOnModule:@"module"
method:@"method"
arguments:params
callback:^(__unused id json, __unused NSError *unused) {
}];
double run = _get_time_nanoseconds() - start;
if ((j % frequency) == frequency - 1) { // Warmup
total += run;
samples[j/frequency] = run;
}
}
}
double mean = total / size;
double variance = 0;
for (int j = 0; j < size; j++) {
variance += pow(samples[j] - mean, 2);
}
variance /= size;
double standardDeviation = sqrt(variance);
double marginOfError = standardDeviation * 1.645;
double lower = mean - marginOfError;
double upper = mean + marginOfError;
int s = 0;
total = 0;
for (int j = 0; j < size; j++) {
double v = samples[j];
if (v >= lower && v <= upper) {
samples[s++] = v;
total += v;
}
}
mean = total / s;
lower = mean * (1.0 - threshold);
upper = mean * (1.0 + threshold);
double expected = expectedTimes[i];
NSLog(@"Previous: %lf, New: %f -> %a", expected, mean, mean);
if (upper < expected) {
NSLog(@"You made JS calls with %d argument(s) %.2lf%% faster :) - Remember to update the tests with the new value: %a",
i, (1 - (double)mean / expected) * 100, mean);
}
XCTAssertTrue(lower < expected, @"You made JS calls with %d argument(s) %.2lf%% slower :( - If that's *really* necessary, update the tests with the new value: %a",
i, ((double)mean / expected - 1) * 100, mean);
[params addObject:data];
}
dispatch_semaphore_signal(semaphore);
}];
while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW)) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:[NSDate dateWithTimeIntervalSinceNow:10]];
}
}
#endif
@end
@@ -221,10 +221,16 @@ RCT_EXPORT_MODULE()
- (void)testCustomSetBridgeModuleInitializedAtBridgeStartup
{
RUN_RUNLOOP_WHILE(!_customSetBridgeModuleNotificationSent);
XCTAssertFalse(_customSetBridgeModuleNotificationSent);
__block RCTTestCustomSetBridgeModule *module;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
module = [_bridge moduleForClass:[RCTTestCustomSetBridgeModule class]];
});
RUN_RUNLOOP_WHILE(!module);
XCTAssertTrue(_customSetBridgeModuleNotificationSent);
RCTTestCustomSetBridgeModule *module = [_bridge moduleForClass:[RCTTestCustomSetBridgeModule class]];
XCTAssertTrue(module.setBridgeOnMainThread);
XCTAssertFalse(module.setBridgeOnMainThread);
XCTAssertEqual(module.bridge, _bridge.batchedBridge);
XCTAssertNotNil(module.methodQueue);
}
+286
View File
@@ -0,0 +1,286 @@
/**
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @flow
*/
'use strict';
/* eslint-env browser */
const React = require('react');
const ReactNative = require('react-native');
const {
PixelRatio,
StyleSheet,
Text,
TextInput,
TouchableOpacity,
View,
} = ReactNative;
const DEFAULT_WS_URL = 'ws://localhost:5555/';
const WS_EVENTS = [
'close',
'error',
'message',
'open',
];
const WS_STATES = [
/* 0 */ 'CONNECTING',
/* 1 */ 'OPEN',
/* 2 */ 'CLOSING',
/* 3 */ 'CLOSED',
];
class Button extends React.Component {
render(): ReactElement {
const label = <Text style={styles.buttonLabel}>{this.props.label}</Text>;
if (this.props.disabled) {
return (
<View style={[styles.button, styles.disabledButton]}>
{label}
</View>
);
}
return (
<TouchableOpacity
onPress={this.props.onPress}
style={styles.button}>
{label}
</TouchableOpacity>
);
}
}
class Row extends React.Component {
render(): ReactElement {
return (
<View style={styles.row}>
<Text>{this.props.label}</Text>
<Text>{this.props.value}</Text>
</View>
);
}
}
function showValue(value) {
if (value === undefined || value === null) {
return '(no value)';
}
console.log('typeof Uint8Array', typeof Uint8Array);
if (typeof ArrayBuffer !== 'undefined' &&
typeof Uint8Array !== 'undefined' &&
value instanceof ArrayBuffer) {
return `ArrayBuffer {${Array.from(new Uint8Array(value))}}`;
}
return value;
}
type State = {
url: string;
socket: ?WebSocket;
socketState: ?number;
lastSocketEvent: ?string;
lastMessage: ?string | ?ArrayBuffer;
outgoingMessage: string;
};
class WebSocketExample extends React.Component<any, any, State> {
static title = 'WebSocket';
static description = 'WebSocket API';
state: State = {
url: DEFAULT_WS_URL,
socket: null,
socketState: null,
lastSocketEvent: null,
lastMessage: null,
outgoingMessage: '',
};
_connect = () => {
const socket = new WebSocket(this.state.url);
WS_EVENTS.forEach(ev => socket.addEventListener(ev, this._onSocketEvent));
this.setState({
socket,
socketState: socket.readyState,
});
};
_disconnect = () => {
if (!this.state.socket) {
return;
}
this.state.socket.close();
};
// Ideally this would be a MessageEvent, but Flow's definition
// doesn't inherit from Event, so it's 'any' for now.
// See https://github.com/facebook/flow/issues/1654.
_onSocketEvent = (event: any) => {
const state: any = {
socketState: event.target.readyState,
lastSocketEvent: event.type,
};
if (event.type === 'message') {
state.lastMessage = event.data;
}
this.setState(state);
};
_sendText = () => {
if (!this.state.socket) {
return;
}
this.state.socket.send(this.state.outgoingMessage);
this.setState({outgoingMessage: ''});
};
_sendBinary = () => {
if (!this.state.socket ||
typeof ArrayBuffer === 'undefined' ||
typeof Uint8Array === 'undefined') {
return;
}
const {outgoingMessage} = this.state;
const buffer = new Uint8Array(outgoingMessage.length);
for (let i = 0; i < outgoingMessage.length; i++) {
buffer[i] = outgoingMessage.charCodeAt(i);
}
this.state.socket.send(buffer);
this.setState({outgoingMessage: ''});
};
render(): ReactElement {
const socketState = WS_STATES[this.state.socketState || -1];
const canConnect =
!this.state.socket ||
this.state.socket.readyState >= WebSocket.CLOSING;
const canSend = !!this.state.socket;
return (
<View style={styles.container}>
<View style={styles.note}>
<Text>Pro tip:</Text>
<Text style={styles.monospace}>
node Examples/UIExplorer/websocket_test_server.js
</Text>
<Text>
{' in the '}
<Text style={styles.monospace}>react-native</Text>
{' directory starts a test server.'}
</Text>
</View>
<Row
label="Current WebSocket state"
value={showValue(socketState)}
/>
<Row
label="Last WebSocket event"
value={showValue(this.state.lastSocketEvent)}
/>
<Row
label="Last message received"
value={showValue(this.state.lastMessage)}
/>
<TextInput
style={styles.textInput}
autoCorrect={false}
placeholder="Server URL..."
onChangeText={(url) => this.setState({url})}
value={this.state.url}
/>
<Button
onPress={this._connect}
label="Connect"
disabled={!canConnect}
/>
<Button
onPress={this._disconnect}
label="Disconnect"
disabled={canConnect}
/>
<TextInput
style={styles.textInput}
autoCorrect={false}
placeholder="Type message here..."
onChangeText={(outgoingMessage) => this.setState({outgoingMessage})}
value={this.state.outgoingMessage}
/>
<View style={styles.buttonRow}>
<Button
onPress={this._sendText}
label="Send as text"
disabled={!canSend}
/>
<Button
onPress={this._sendBinary}
label="Send as binary"
disabled={!canSend}
/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
note: {
padding: 8,
margin: 4,
backgroundColor: 'white',
},
monospace: {
fontFamily: 'courier',
fontSize: 11,
},
row: {
height: 40,
padding: 4,
backgroundColor: 'white',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
borderBottomWidth: 1 / PixelRatio.get(),
borderColor: 'grey',
},
button: {
margin: 8,
padding: 8,
borderRadius: 4,
backgroundColor: 'blue',
alignSelf: 'center',
},
disabledButton: {
opacity: 0.5,
},
buttonLabel: {
color: 'white',
},
buttonRow: {
flexDirection: 'row',
justifyContent: 'center',
},
textInput: {
height: 40,
backgroundColor: 'white',
margin: 8,
padding: 8,
},
});
module.exports = WebSocketExample;
+20
View File
@@ -22,6 +22,7 @@ var {
Text,
TouchableHighlight,
View,
WebView,
} = ReactNative;
var RCTNetworking = require('RCTNetworking');
@@ -45,6 +46,7 @@ class XHRExampleCookies extends React.Component {
var url = `https://${domain}/cookies/set?a=${a}&b=${b}`;
fetch(url).then((response) => {
this.setStatus(`Cookies a=${a}, b=${b} set`);
this.refreshWebview();
});
this.setState({
@@ -59,6 +61,7 @@ class XHRExampleCookies extends React.Component {
return response.json();
}).then((data) => {
this.setStatus(`Got cookies ${JSON.stringify(data.cookies)} from server`);
this.refreshWebview();
});
this.setStatus('Getting cookies...');
@@ -67,9 +70,14 @@ class XHRExampleCookies extends React.Component {
clearCookies() {
RCTNetworking.clearCookies((cleared) => {
this.setStatus('Cookies cleared, had cookies=' + cleared);
this.refreshWebview();
});
}
refreshWebview() {
this.refs.webview.reload();
}
setStatus(status: string) {
this.setState({status});
}
@@ -113,6 +121,18 @@ class XHRExampleCookies extends React.Component {
</View>
</TouchableHighlight>
<Text>{this.state.status}</Text>
<TouchableHighlight
style={styles.wrapper}
onPress={this.refreshWebview.bind(this)}>
<View style={styles.button}>
<Text>Refresh Webview</Text>
</View>
</TouchableHighlight>
<WebView
ref="webview"
source={{uri: 'http://httpbin.org/cookies'}}
style={{height: 100}}
/>
</View>
);
}
@@ -0,0 +1,43 @@
/**
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @flow
*/
'use strict';
/* eslint-env node */
const WebSocket = require('ws');
console.log(`\
Test server for WebSocketExample
This will send each incoming message right back to the other side.a
Restart with the '--binary' command line flag to have it respond with an
ArrayBuffer instead of a string.
`);
const respondWithBinary = process.argv.indexOf('--binary') !== -1;
const server = new WebSocket.Server({port: 5555});
server.on('connection', (ws) => {
ws.on('message', (message) => {
console.log('Received message:', message);
if (respondWithBinary) {
message = new Buffer(message);
}
ws.send(message);
});
console.log('Incoming connection!');
ws.send('Why hello there!');
});
@@ -10,7 +10,7 @@
*/
'use strict';
require('regenerator/runtime');
require('regenerator-runtime/runtime');
var React = require('react');
var ReactNative = require('react-native');
+1 -1
View File
@@ -23,7 +23,7 @@ var merge = require('merge');
// Diff Helpers
function arrayDiffer(a, b) {
if (a == null) {
if (a == null || b == null) {
return true;
}
if (a.length !== b.length) {
@@ -82,7 +82,7 @@ type AnimationConfig = {
class Animation {
__active: bool;
__isInteraction: bool;
__nativeTag: number;
__nativeId: number;
__onEnd: ?EndCallback;
start(
fromValue: number,
@@ -91,7 +91,11 @@ class Animation {
previousAnimation: ?Animation,
animatedValue: AnimatedValue
): void {}
stop(): void {}
stop(): void {
if (this.__nativeId) {
NativeAnimatedAPI.stopAnimation(this.__nativeId);
}
}
_getNativeAnimationConfig(): any {
// Subclasses that have corresponding animation implementation done in native
// should override this method
@@ -105,9 +109,9 @@ class Animation {
}
__startNativeAnimation(animatedValue: AnimatedValue): void {
animatedValue.__makeNative();
this.__nativeTag = NativeAnimatedHelper.generateNewAnimationTag();
this.__nativeId = NativeAnimatedHelper.generateNewAnimationId();
NativeAnimatedAPI.startAnimatingNode(
this.__nativeTag,
this.__nativeId,
animatedValue.__getNativeTag(),
this._getNativeAnimationConfig(),
this.__debouncedOnEnd.bind(this)
@@ -311,6 +315,7 @@ class TimingAnimation extends Animation {
}
stop(): void {
super.stop();
this.__active = false;
clearTimeout(this._timeout);
window.cancelAnimationFrame(this._animationFrame);
@@ -381,6 +386,7 @@ class DecayAnimation extends Animation {
}
stop(): void {
super.stop();
this.__active = false;
window.cancelAnimationFrame(this._animationFrame);
this.__debouncedOnEnd({finished: false});
@@ -595,6 +601,7 @@ class SpringAnimation extends Animation {
}
stop(): void {
super.stop();
this.__active = false;
window.cancelAnimationFrame(this._animationFrame);
this.__debouncedOnEnd({finished: false});
@@ -645,7 +652,7 @@ class AnimatedValue extends AnimatedWithChildren {
this._animation.stop();
this._animation = null;
}
this._updateValue(value);
this._updateValue(value, !this.__isNative /* don't perform a flush for natively driven values */);
if (this.__isNative) {
NativeAnimatedAPI.setAnimatedNodeValue(this.__getNativeTag(), value);
}
@@ -705,7 +712,7 @@ class AnimatedValue extends AnimatedWithChildren {
* 0-10.
*/
interpolate(config: InterpolationConfigType): AnimatedInterpolation {
return new AnimatedInterpolation(this, Interpolation.create(config));
return new AnimatedInterpolation(this, config);
}
/**
@@ -723,7 +730,9 @@ class AnimatedValue extends AnimatedWithChildren {
animation.start(
this._value,
(value) => {
this._updateValue(value);
// Natively driven animations will never call into that callback, therefore we can always pass `flush = true`
// to allow the updated value to propagate to native with `setNativeProps`
this._updateValue(value, true /* flush */);
},
(result) => {
this._animation = null;
@@ -753,9 +762,11 @@ class AnimatedValue extends AnimatedWithChildren {
this._tracking = tracking;
}
_updateValue(value: number): void {
_updateValue(value: number, flush: bool): void {
this._value = value;
_flush(this);
if (flush) {
_flush(this);
}
for (var key in this._listeners) {
this._listeners[key]({value: this.__getValue()});
}
@@ -912,12 +923,14 @@ class AnimatedValueXY extends AnimatedWithChildren {
class AnimatedInterpolation extends AnimatedWithChildren {
_parent: Animated;
_config: InterpolationConfigType;
_interpolation: (input: number) => number | string;
constructor(parent: Animated, interpolation: (input: number) => number | string) {
constructor(parent: Animated, config: InterpolationConfigType) {
super();
this._parent = parent;
this._interpolation = interpolation;
this._config = config;
this._interpolation = Interpolation.create(config);
}
__getValue(): number | string {
@@ -930,7 +943,7 @@ class AnimatedInterpolation extends AnimatedWithChildren {
}
interpolate(config: InterpolationConfigType): AnimatedInterpolation {
return new AnimatedInterpolation(this, Interpolation.create(config));
return new AnimatedInterpolation(this, config);
}
__attach(): void {
@@ -939,6 +952,15 @@ class AnimatedInterpolation extends AnimatedWithChildren {
__detach(): void {
this._parent.__removeChild(this);
super.__detach();
}
__getNativeConfig(): any {
NativeAnimatedHelper.validateInterpolation(this._config);
return {
...this._config,
type: 'interpolation',
};
}
}
@@ -952,12 +974,18 @@ class AnimatedAddition extends AnimatedWithChildren {
this._b = typeof b === 'number' ? new AnimatedValue(b) : b;
}
__makeNative() {
this._a.__makeNative();
this._b.__makeNative();
super.__makeNative();
}
__getValue(): number {
return this._a.__getValue() + this._b.__getValue();
}
interpolate(config: InterpolationConfigType): AnimatedInterpolation {
return new AnimatedInterpolation(this, Interpolation.create(config));
return new AnimatedInterpolation(this, config);
}
__attach(): void {
@@ -968,6 +996,14 @@ class AnimatedAddition extends AnimatedWithChildren {
__detach(): void {
this._a.__removeChild(this);
this._b.__removeChild(this);
super.__detach();
}
__getNativeConfig(): any {
return {
type: 'addition',
input: [this._a.__getNativeTag(), this._b.__getNativeTag()],
};
}
}
@@ -981,12 +1017,18 @@ class AnimatedMultiplication extends AnimatedWithChildren {
this._b = typeof b === 'number' ? new AnimatedValue(b) : b;
}
__makeNative() {
super.__makeNative();
this._a.__makeNative();
this._b.__makeNative();
}
__getValue(): number {
return this._a.__getValue() * this._b.__getValue();
}
interpolate(config: InterpolationConfigType): AnimatedInterpolation {
return new AnimatedInterpolation(this, Interpolation.create(config));
return new AnimatedInterpolation(this, config);
}
__attach(): void {
@@ -997,6 +1039,14 @@ class AnimatedMultiplication extends AnimatedWithChildren {
__detach(): void {
this._a.__removeChild(this);
this._b.__removeChild(this);
super.__detach();
}
__getNativeConfig(): any {
return {
type: 'multiplication',
input: [this._a.__getNativeTag(), this._b.__getNativeTag()],
};
}
}
@@ -1015,7 +1065,7 @@ class AnimatedModulo extends AnimatedWithChildren {
}
interpolate(config: InterpolationConfigType): AnimatedInterpolation {
return new AnimatedInterpolation(this, Interpolation.create(config));
return new AnimatedInterpolation(this, config);
}
__attach(): void {
@@ -1394,7 +1444,7 @@ function createAnimatedComponent(Component: any): any {
for (var key in ViewStylePropTypes) {
if (!Component.propTypes[key] && props[key] !== undefined) {
console.error(
console.warn(
'You are setting the style `{ ' + key + ': ... }` as a prop. You ' +
'should nest it in a style object. ' +
'E.g. `{ style: { ' + key + ': ... } }`'
+23 -6
View File
@@ -16,7 +16,7 @@ var NativeAnimatedModule = require('NativeModules').NativeAnimatedModule;
var invariant = require('fbjs/lib/invariant');
var __nativeAnimatedNodeTagCount = 1; /* used for animated nodes */
var __nativeAnimationTagCount = 1; /* used for started animations */
var __nativeAnimationIdCount = 1; /* used for started animations */
type EndResult = {finished: bool};
type EndCallback = (result: EndResult) => void;
@@ -38,9 +38,13 @@ var API = {
assertNativeAnimatedModule();
NativeAnimatedModule.disconnectAnimatedNodes(parentTag, childTag);
},
startAnimatingNode: function(animationTag: number, nodeTag: number, config: Object, endCallback: EndCallback): void {
startAnimatingNode: function(animationId: number, nodeTag: number, config: Object, endCallback: EndCallback): void {
assertNativeAnimatedModule();
NativeAnimatedModule.startAnimatingNode(nodeTag, config, endCallback);
NativeAnimatedModule.startAnimatingNode(animationId, nodeTag, config, endCallback);
},
stopAnimation: function(animationId: number) {
assertNativeAnimatedModule();
NativeAnimatedModule.stopAnimation(animationId);
},
setAnimatedNodeValue: function(nodeTag: number, value: number): void {
assertNativeAnimatedModule();
@@ -97,12 +101,24 @@ function validateStyles(styles: Object): void {
}
}
function validateInterpolation(config: Object): void {
var SUPPORTED_INTERPOLATION_PARAMS = {
inputRange: true,
outputRange: true,
};
for (var key in config) {
if (!SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(key)) {
throw new Error(`Interpolation property '${key}' is not supported by native animated module`);
}
}
}
function generateNewNodeTag(): number {
return __nativeAnimatedNodeTagCount++;
}
function generateNewAnimationTag(): number {
return __nativeAnimationTagCount++;
function generateNewAnimationId(): number {
return __nativeAnimationIdCount++;
}
function assertNativeAnimatedModule(): void {
@@ -113,7 +129,8 @@ module.exports = {
API,
validateProps,
validateStyles,
validateInterpolation,
generateNewNodeTag,
generateNewAnimationTag,
generateNewAnimationId,
assertNativeAnimatedModule,
};
@@ -9,7 +9,7 @@
'use strict';
jest
.autoMockOff()
.disableAutomock()
.setMock('Text', {})
.setMock('View', {})
.setMock('Image', {})
@@ -22,7 +22,7 @@ describe('Animated', () => {
it('works end to end', () => {
var anim = new Animated.Value(0);
var callback = jest.genMockFunction();
var callback = jest.fn();
var node = new Animated.__PropsOnlyForTests({
style: {
@@ -75,7 +75,7 @@ describe('Animated', () => {
it('does not detach on updates', () => {
var anim = new Animated.Value(0);
anim.__detach = jest.genMockFunction();
anim.__detach = jest.fn();
var c = new Animated.View();
c.props = {
@@ -101,11 +101,11 @@ describe('Animated', () => {
it('stops animation when detached', () => {
// jest environment doesn't have cancelAnimationFrame :(
if (!window.cancelAnimationFrame) {
window.cancelAnimationFrame = jest.genMockFunction();
window.cancelAnimationFrame = jest.fn();
}
var anim = new Animated.Value(0);
var callback = jest.genMockFunction();
var callback = jest.fn();
var c = new Animated.View();
c.props = {
@@ -125,14 +125,14 @@ describe('Animated', () => {
it('triggers callback when spring is at rest', () => {
var anim = new Animated.Value(0);
var callback = jest.genMockFunction();
var callback = jest.fn();
Animated.spring(anim, {toValue: 0, velocity: 0}).start(callback);
expect(callback).toBeCalled();
});
it('send toValue when a spring stops', () => {
var anim = new Animated.Value(0);
var listener = jest.genMockFunction();
var listener = jest.fn();
anim.addListener(listener);
Animated.spring(anim, {toValue: 15}).start();
jest.runAllTimers();
@@ -148,15 +148,15 @@ describe('Animated', () => {
describe('Animated Sequence', () => {
it('works with an empty sequence', () => {
var cb = jest.genMockFunction();
var cb = jest.fn();
Animated.sequence([]).start(cb);
expect(cb).toBeCalledWith({finished: true});
});
it('sequences well', () => {
var anim1 = {start: jest.genMockFunction()};
var anim2 = {start: jest.genMockFunction()};
var cb = jest.genMockFunction();
var anim1 = {start: jest.fn()};
var anim2 = {start: jest.fn()};
var cb = jest.fn();
var seq = Animated.sequence([anim1, anim2]);
@@ -179,9 +179,9 @@ describe('Animated Sequence', () => {
});
it('supports interrupting sequence', () => {
var anim1 = {start: jest.genMockFunction()};
var anim2 = {start: jest.genMockFunction()};
var cb = jest.genMockFunction();
var anim1 = {start: jest.fn()};
var anim2 = {start: jest.fn()};
var cb = jest.fn();
Animated.sequence([anim1, anim2]).start(cb);
@@ -193,9 +193,9 @@ describe('Animated Sequence', () => {
});
it('supports stopping sequence', () => {
var anim1 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
var anim2 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
var cb = jest.genMockFunction();
var anim1 = {start: jest.fn(), stop: jest.fn()};
var anim2 = {start: jest.fn(), stop: jest.fn()};
var cb = jest.fn();
var seq = Animated.sequence([anim1, anim2]);
seq.start(cb);
@@ -215,14 +215,14 @@ describe('Animated Sequence', () => {
describe('Animated Parallel', () => {
it('works with an empty parallel', () => {
var cb = jest.genMockFunction();
var cb = jest.fn();
Animated.parallel([]).start(cb);
expect(cb).toBeCalledWith({finished: true});
});
it('works with an empty element in array', () => {
var anim1 = {start: jest.genMockFunction()};
var cb = jest.genMockFunction();
var anim1 = {start: jest.fn()};
var cb = jest.fn();
Animated.parallel([null, anim1]).start(cb);
expect(anim1.start).toBeCalled();
@@ -232,9 +232,9 @@ describe('Animated Parallel', () => {
});
it('parellelizes well', () => {
var anim1 = {start: jest.genMockFunction()};
var anim2 = {start: jest.genMockFunction()};
var cb = jest.genMockFunction();
var anim1 = {start: jest.fn()};
var anim2 = {start: jest.fn()};
var cb = jest.fn();
var par = Animated.parallel([anim1, anim2]);
@@ -255,9 +255,9 @@ describe('Animated Parallel', () => {
});
it('supports stopping parallel', () => {
var anim1 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
var anim2 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
var cb = jest.genMockFunction();
var anim1 = {start: jest.fn(), stop: jest.fn()};
var anim2 = {start: jest.fn(), stop: jest.fn()};
var cb = jest.fn();
var seq = Animated.parallel([anim1, anim2]);
seq.start(cb);
@@ -276,10 +276,10 @@ describe('Animated Parallel', () => {
it('does not call stop more than once when stopping', () => {
var anim1 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
var anim2 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
var anim3 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
var cb = jest.genMockFunction();
var anim1 = {start: jest.fn(), stop: jest.fn()};
var anim2 = {start: jest.fn(), stop: jest.fn()};
var anim3 = {start: jest.fn(), stop: jest.fn()};
var cb = jest.fn();
var seq = Animated.parallel([anim1, anim2, anim3]);
seq.start(cb);
@@ -306,8 +306,8 @@ describe('Animated Parallel', () => {
describe('Animated delays', () => {
it('should call anim after delay in sequence', () => {
var anim = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
var cb = jest.genMockFunction();
var anim = {start: jest.fn(), stop: jest.fn()};
var cb = jest.fn();
Animated.sequence([
Animated.delay(1000),
anim,
@@ -319,7 +319,7 @@ describe('Animated delays', () => {
expect(cb).toBeCalledWith({finished: true});
});
it('should run stagger to end', () => {
var cb = jest.genMockFunction();
var cb = jest.fn();
Animated.stagger(1000, [
Animated.delay(1000),
Animated.delay(1000),
@@ -341,7 +341,7 @@ describe('Animated Events', () => {
});
it('should call listeners', () => {
var value = new Animated.Value(0);
var listener = jest.genMockFunction();
var listener = jest.fn();
var handler = Animated.event(
[{foo: value}],
{listener},
@@ -366,14 +366,14 @@ describe('Animated Interactions', () => {
});
afterEach(()=> {
jest.dontMock('InteractionManager');
jest.unmock('InteractionManager');
});
it('registers an interaction by default', () => {
InteractionManager.createInteractionHandle.mockReturnValue(777);
var value = new Animated.Value(0);
var callback = jest.genMockFunction();
var callback = jest.fn();
Animated.timing(value, {
toValue: 100,
duration: 100,
@@ -387,7 +387,7 @@ describe('Animated Interactions', () => {
it('does not register an interaction when specified', () => {
var value = new Animated.Value(0);
var callback = jest.genMockFunction();
var callback = jest.fn();
Animated.timing(value, {
toValue: 100,
duration: 100,
@@ -451,7 +451,7 @@ describe('Animated Vectors', () => {
it('should animate vectors', () => {
var vec = new Animated.ValueXY();
var callback = jest.genMockFunction();
var callback = jest.fn();
var node = new Animated.__PropsOnlyForTests({
style: {
@@ -536,7 +536,7 @@ describe('Animated Vectors', () => {
describe('Animated Listeners', () => {
it('should get updates', () => {
var value1 = new Animated.Value(0);
var listener = jest.genMockFunction();
var listener = jest.fn();
var id = value1.addListener(listener);
value1.setValue(42);
expect(listener.mock.calls.length).toBe(1);
@@ -554,7 +554,7 @@ describe('Animated Listeners', () => {
it('should removeAll', () => {
var value1 = new Animated.Value(0);
var listener = jest.genMockFunction();
var listener = jest.fn();
[1,2,3,4].forEach(() => value1.addListener(listener));
value1.setValue(42);
expect(listener.mock.calls.length).toBe(4);
@@ -9,7 +9,7 @@
'use strict';
jest
.autoMockOff()
.disableAutomock()
.setMock('Text', {})
.setMock('View', {})
.setMock('Image', {})
@@ -24,18 +24,19 @@ describe('Animated', () => {
beforeEach(() => {
var nativeAnimatedModule = require('NativeModules').NativeAnimatedModule;
nativeAnimatedModule.createAnimatedNode = jest.genMockFunction();
nativeAnimatedModule.connectAnimatedNodes = jest.genMockFunction();
nativeAnimatedModule.disconnectAnimatedNodes = jest.genMockFunction();
nativeAnimatedModule.startAnimatingNode = jest.genMockFunction();
nativeAnimatedModule.setAnimatedNodeValue = jest.genMockFunction();
nativeAnimatedModule.connectAnimatedNodeToView = jest.genMockFunction();
nativeAnimatedModule.disconnectAnimatedNodeFromView = jest.genMockFunction();
nativeAnimatedModule.dropAnimatedNode = jest.genMockFunction();
nativeAnimatedModule.createAnimatedNode = jest.fn();
nativeAnimatedModule.connectAnimatedNodes = jest.fn();
nativeAnimatedModule.disconnectAnimatedNodes = jest.fn();
nativeAnimatedModule.startAnimatingNode = jest.fn();
nativeAnimatedModule.stopAnimation = jest.fn();
nativeAnimatedModule.setAnimatedNodeValue = jest.fn();
nativeAnimatedModule.connectAnimatedNodeToView = jest.fn();
nativeAnimatedModule.disconnectAnimatedNodeFromView = jest.fn();
nativeAnimatedModule.dropAnimatedNode = jest.fn();
// jest environment doesn't have cancelAnimationFrame :(
if (!window.cancelAnimationFrame) {
window.cancelAnimationFrame = jest.genMockFunction();
window.cancelAnimationFrame = jest.fn();
}
});
@@ -59,6 +60,7 @@ describe('Animated', () => {
expect(nativeAnimatedModule.connectAnimatedNodes.mock.calls.length).toBe(2);
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
jasmine.any(Number),
jasmine.any(Number),
{type: 'frames', frames: jasmine.any(Array), toValue: jasmine.any(Number)},
jasmine.any(Function)
@@ -90,12 +92,114 @@ describe('Animated', () => {
.toBeCalledWith(jasmine.any(Number), { type: 'props', props: { style: jasmine.any(Number) }});
});
it('sends a valid graph description for Animated.add nodes', () => {
var first = new Animated.Value(1);
var second = new Animated.Value(2);
var c = new Animated.View();
c.props = {
style: {
opacity: Animated.add(first, second),
},
};
c.componentWillMount();
Animated.timing(first, {toValue: 2, duration: 1000, useNativeDriver: true}).start();
Animated.timing(second, {toValue: 3, duration: 1000, useNativeDriver: true}).start();
var nativeAnimatedModule = require('NativeModules').NativeAnimatedModule;
expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(jasmine.any(Number), { type: 'addition', input: jasmine.any(Array) });
var additionCalls = nativeAnimatedModule.createAnimatedNode.mock.calls.filter(
(call) => call[1].type === 'addition'
);
expect(additionCalls.length).toBe(1);
var additionCall = additionCalls[0];
var additionNodeTag = additionCall[0];
var additionConnectionCalls = nativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
(call) => call[1] === additionNodeTag
);
expect(additionConnectionCalls.length).toBe(2);
expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(additionCall[1].input[0], { type: 'value', value: 1 });
expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(additionCall[1].input[1], { type: 'value', value: 2 });
});
it('sends a valid graph description for Animated.multiply nodes', () => {
var first = new Animated.Value(2);
var second = new Animated.Value(1);
var c = new Animated.View();
c.props = {
style: {
opacity: Animated.multiply(first, second),
},
};
c.componentWillMount();
Animated.timing(first, {toValue: 5, duration: 1000, useNativeDriver: true}).start();
Animated.timing(second, {toValue: -1, duration: 1000, useNativeDriver: true}).start();
var nativeAnimatedModule = require('NativeModules').NativeAnimatedModule;
expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(jasmine.any(Number), { type: 'multiplication', input: jasmine.any(Array) });
var multiplicationCalls = nativeAnimatedModule.createAnimatedNode.mock.calls.filter(
(call) => call[1].type === 'multiplication'
);
expect(multiplicationCalls.length).toBe(1);
var multiplicationCall = multiplicationCalls[0];
var multiplicationNodeTag = multiplicationCall[0];
var multiplicationConnectionCalls = nativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
(call) => call[1] === multiplicationNodeTag
);
expect(multiplicationConnectionCalls.length).toBe(2);
expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(multiplicationCall[1].input[0], { type: 'value', value: 2 });
expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(multiplicationCall[1].input[1], { type: 'value', value: 1 });
});
it('sends a valid graph description for interpolate() nodes', () => {
var node = new Animated.Value(10);
var c = new Animated.View();
c.props = {
style: {
opacity: node.interpolate({
inputRange: [10, 20],
outputRange: [0, 1],
}),
},
};
c.componentWillMount();
Animated.timing(node, {toValue: 20, duration: 1000, useNativeDriver: true}).start();
var nativeAnimatedModule = require('NativeModules').NativeAnimatedModule;
expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(jasmine.any(Number), { type: 'value', value: 10 });
expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(jasmine.any(Number), {
type: 'interpolation',
inputRange: [10, 20],
outputRange: [0, 1],
});
var interpolationNodeTag = nativeAnimatedModule.createAnimatedNode.mock.calls.find(
(call) => call[1].type === 'interpolation'
)[0];
var valueNodeTag = nativeAnimatedModule.createAnimatedNode.mock.calls.find(
(call) => call[1].type === 'value'
)[0];
expect(nativeAnimatedModule.connectAnimatedNodes).toBeCalledWith(valueNodeTag, interpolationNodeTag);
});
it('sends a valid timing animation description', () => {
var anim = new Animated.Value(0);
Animated.timing(anim, {toValue: 10, duration: 1000, useNativeDriver: true}).start();
var nativeAnimatedModule = require('NativeModules').NativeAnimatedModule;
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
jasmine.any(Number),
jasmine.any(Number),
{type: 'frames', frames: jasmine.any(Array), toValue: jasmine.any(Number)},
jasmine.any(Function)
@@ -106,10 +210,27 @@ describe('Animated', () => {
var anim = new Animated.Value(0);
Animated.timing(anim, {toValue: 10, duration: 1000, useNativeDriver: true}).start();
anim.setValue(5);
var c = new Animated.View();
c.props = {
style: {
opacity: anim,
},
};
c.componentWillMount();
// We expect `setValue` not to propagate down to `setNativeProps`, otherwise it may try to access `setNativeProps`
// via component refs table that we override here.
c.refs = {
node: {
setNativeProps: jest.genMockFunction(),
},
};
anim.setValue(0.5);
var nativeAnimatedModule = require('NativeModules').NativeAnimatedModule;
expect(nativeAnimatedModule.setAnimatedNodeValue).toBeCalledWith(jasmine.any(Number), 5);
expect(nativeAnimatedModule.setAnimatedNodeValue).toBeCalledWith(jasmine.any(Number), 0.5);
expect(c.refs.node.setNativeProps.mock.calls.length).toBe(0);
});
it('doesn\'t call into native API if useNativeDriver is set to false', () => {
@@ -179,6 +300,25 @@ describe('Animated', () => {
expect(animation.start).toThrowError(/left/);
});
it('fails for unsupported interpolation parameters', () => {
var anim = new Animated.Value(0);
var c = new Animated.View();
c.props = {
style: {
opacity: anim.interpolate({
inputRange: [0, 100],
outputRange: [0, 1],
extrapolate: 'clamp',
}),
},
};
c.componentWillMount();
var animation = Animated.timing(anim, {toValue: 100, duration: 50, useNativeDriver: true});
expect(animation.start).toThrowError(/extrapolate/);
});
it('works for any `static` props and styles', () => {
// Passing "unsupported" props should work just fine as long as they are not animated
var anim = new Animated.Value(0);
@@ -201,4 +341,22 @@ describe('Animated', () => {
.toBeCalledWith(jasmine.any(Number), { type: 'props', props: { style: jasmine.any(Number) }});
});
it('send stopAnimation command to native', () => {
var value = new Animated.Value(0);
var animation = Animated.timing(value, {toValue: 10, duration: 50, useNativeDriver: true});
var nativeAnimatedModule = require('NativeModules').NativeAnimatedModule;
animation.start();
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
jasmine.any(Number),
jasmine.any(Number),
{type: 'frames', frames: jasmine.any(Array), toValue: jasmine.any(Number)},
jasmine.any(Function)
);
var animationId = nativeAnimatedModule.startAnimatingNode.mock.calls[0][0];
animation.stop();
expect(nativeAnimatedModule.stopAnimation).toBeCalledWith(animationId);
});
});
@@ -8,7 +8,7 @@
*/
'use strict';
jest.dontMock('Easing');
jest.unmock('Easing');
var Easing = require('Easing');
describe('Easing', () => {
@@ -9,9 +9,9 @@
'use strict';
jest
.dontMock('Interpolation')
.dontMock('Easing')
.dontMock('normalizeColor');
.unmock('Interpolation')
.unmock('Easing')
.unmock('normalizeColor');
var Interpolation = require('Interpolation');
var Easing = require('Easing');
@@ -1,6 +1,6 @@
/* eslint-disable */
jest.dontMock('bezier');
jest.unmock('bezier');
var bezier = require('bezier');
var identity = function (x) { return x; };
+7 -3
View File
@@ -12,6 +12,7 @@
'use strict';
var BatchedBridge = require('BatchedBridge');
var BugReporting = require('BugReporting');
var ReactNative = require('ReactNative');
var invariant = require('fbjs/lib/invariant');
@@ -24,6 +25,7 @@ if (__DEV__) {
}
var runnables = {};
var runCount = 1;
type ComponentProvider = () => ReactClass<any>;
@@ -79,13 +81,15 @@ var AppRegistry = {
},
runApplication: function(appKey: string, appParameters: any): void {
console.log(
const msg =
'Running application "' + appKey + '" with appParams: ' +
JSON.stringify(appParameters) + '. ' +
'__DEV__ === ' + String(__DEV__) +
', development-level warning are ' + (__DEV__ ? 'ON' : 'OFF') +
', performance optimizations are ' + (__DEV__ ? 'OFF' : 'ON')
);
', performance optimizations are ' + (__DEV__ ? 'OFF' : 'ON');
console.log(msg);
BugReporting.init();
BugReporting.addSource('AppRegistry.runApplication' + runCount++, () => msg);
invariant(
runnables[appKey] && runnables[appKey].run,
'Application ' + appKey + ' has not been registered. This ' +
+1
View File
@@ -24,6 +24,7 @@ const JSTimersExecution = require('JSTimersExecution');
BatchedBridge.registerCallableModule('Systrace', Systrace);
BatchedBridge.registerCallableModule('JSTimersExecution', JSTimersExecution);
BatchedBridge.registerCallableModule('HeapCapture', require('HeapCapture'));
if (__DEV__) {
BatchedBridge.registerCallableModule('HMRClient', require('HMRClient'));
@@ -13,6 +13,7 @@
const BatchedBridge = require('BatchedBridge');
const RemoteModules = BatchedBridge.RemoteModules;
const Platform = require('Platform');
function normalizePrefix(moduleName: string): string {
return moduleName.replace(/^(RCT|RK)/, '');
@@ -65,51 +66,53 @@ Object.keys(RemoteModules).forEach((moduleName) => {
* the call sites accessing NativeModules.UIManager directly have
* been removed #9344445
*/
const UIManager = NativeModules.UIManager;
UIManager && Object.keys(UIManager).forEach(viewName => {
const viewConfig = UIManager[viewName];
if (viewConfig.Manager) {
let constants;
/* $FlowFixMe - nice try. Flow doesn't like getters */
Object.defineProperty(viewConfig, 'Constants', {
configurable: true,
enumerable: true,
get: () => {
if (constants) {
if (Platform.OS === 'ios') {
const UIManager = NativeModules.UIManager;
UIManager && Object.keys(UIManager).forEach(viewName => {
const viewConfig = UIManager[viewName];
if (viewConfig.Manager) {
let constants;
/* $FlowFixMe - nice try. Flow doesn't like getters */
Object.defineProperty(viewConfig, 'Constants', {
configurable: true,
enumerable: true,
get: () => {
if (constants) {
return constants;
}
constants = {};
const viewManager = NativeModules[normalizePrefix(viewConfig.Manager)];
viewManager && Object.keys(viewManager).forEach(key => {
const value = viewManager[key];
if (typeof value !== 'function') {
constants[key] = value;
}
});
return constants;
}
constants = {};
const viewManager = NativeModules[normalizePrefix(viewConfig.Manager)];
viewManager && Object.keys(viewManager).forEach(key => {
const value = viewManager[key];
if (typeof value !== 'function') {
constants[key] = value;
},
});
let commands;
/* $FlowFixMe - nice try. Flow doesn't like getters */
Object.defineProperty(viewConfig, 'Commands', {
configurable: true,
enumerable: true,
get: () => {
if (commands) {
return commands;
}
});
return constants;
},
});
let commands;
/* $FlowFixMe - nice try. Flow doesn't like getters */
Object.defineProperty(viewConfig, 'Commands', {
configurable: true,
enumerable: true,
get: () => {
if (commands) {
commands = {};
const viewManager = NativeModules[normalizePrefix(viewConfig.Manager)];
viewManager && Object.keys(viewManager).forEach((key, index) => {
const value = viewManager[key];
if (typeof value === 'function') {
commands[key] = index;
}
});
return commands;
}
commands = {};
const viewManager = NativeModules[normalizePrefix(viewConfig.Manager)];
viewManager && Object.keys(viewManager).forEach((key, index) => {
const value = viewManager[key];
if (typeof value === 'function') {
commands[key] = index;
}
});
return commands;
},
});
}
});
},
});
}
});
}
module.exports = NativeModules;
@@ -10,21 +10,19 @@ var NativeModules = {
}),
},
Timing: {
createTimer: jest.genMockFunction(),
deleteTimer: jest.genMockFunction(),
createTimer: jest.fn(),
deleteTimer: jest.fn(),
},
GraphPhotoUpload: {
upload: jest.genMockFunction(),
upload: jest.fn(),
},
FacebookSDK: {
login: jest.genMockFunction(),
logout: jest.genMockFunction(),
queryGraphPath: jest.genMockFunction().mockImpl(
(path, method, params, callback) => callback()
),
login: jest.fn(),
logout: jest.fn(),
queryGraphPath: jest.fn((path, method, params, callback) => callback()),
},
DataManager: {
queryData: jest.genMockFunction(),
queryData: jest.fn(),
},
UIManager: {
customBubblingEventTypes: {},
@@ -38,10 +36,10 @@ var NativeModules = {
},
},
AsyncLocalStorage: {
getItem: jest.genMockFunction(),
setItem: jest.genMockFunction(),
removeItem: jest.genMockFunction(),
clear: jest.genMockFunction(),
getItem: jest.fn(),
setItem: jest.fn(),
removeItem: jest.fn(),
clear: jest.fn(),
},
SourceCode: {
scriptURL: null,
@@ -52,10 +50,10 @@ var NativeModules = {
},
ModalFullscreenViewManager: {},
AlertManager: {
alertWithArgs: jest.genMockFunction(),
alertWithArgs: jest.fn(),
},
Clipboard: {
setString: jest.genMockFunction(),
setString: jest.fn(),
},
};
+78
View File
@@ -0,0 +1,78 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule BugReporting
* @flow
*/
'use strict';
const BugReportingNativeModule = require('NativeModules').BugReporting;
const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
import type {EmitterSubscription} from 'EventEmitter';
type ExtraData = { [key: string]: string };
type SourceCallback = () => string;
/**
* A simple class for collecting bug report data. Components can add sources that will be queried when a bug report
* is created via `collectExtraData`. For example, a list component might add a source that provides the list of rows
* that are currently visible on screen. Components should also remember to call `remove()` on the object that is
* returned by `addSource` when they are unmounted.
*/
class BugReporting {
static _sources: Map<string, SourceCallback> = new Map();
static _subscription: EmitterSubscription = null;
/**
* `init` is called in `AppRegistry.runApplication`, so you shouldn't have to worry about it.
*/
static init() {
if (!BugReporting._subscription) {
BugReporting._subscription = RCTDeviceEventEmitter
.addListener('collectBugExtraData', BugReporting.collectExtraData, null);
}
}
/**
* Maps a string key to a simple callback that should return a string payload to be attached
* to a bug report. Source callbacks are called when `collectExtraData` is called.
*
* Returns an object to remove the source when the component unmounts.
*
* Conflicts trample with a warning.
*/
static addSource(key: string, callback: SourceCallback): {remove: () => void} {
if (BugReporting._sources.has(key)) {
console.warn(`BugReporting.addSource called multiple times for same key '${key}'`);
}
BugReporting._sources.set(key, callback);
return {remove: () => { BugReporting._sources.delete(key); }};
}
/**
* This can be called from a native bug reporting flow, or from JS code.
*
* If available, this will call `NativeModules.BugReporting.setExtraData(extraData)`
* after collecting `extraData`.
*/
static collectExtraData(): ExtraData {
const extraData: ExtraData = {};
for (const [key, callback] of BugReporting._sources) {
extraData[key] = callback();
}
console.log('BugReporting extraData:', extraData);
BugReportingNativeModule &&
BugReportingNativeModule.setExtraData &&
BugReportingNativeModule.setExtraData(extraData);
return extraData;
}
}
module.exports = BugReporting;
@@ -11,6 +11,7 @@
#import <AssetsLibrary/AssetsLibrary.h>
#import <libkern/OSAtomic.h>
#import <MobileCoreServices/MobileCoreServices.h>
#import "RCTBridge.h"
#import "RCTUtils.h"
@@ -53,10 +54,13 @@ RCT_EXPORT_MODULE()
ALAssetRepresentation *representation = [asset defaultRepresentation];
NSInteger length = (NSInteger)representation.size;
CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass((__bridge CFStringRef _Nonnull)(representation.UTI), kUTTagClassMIMEType);
NSURLResponse *response =
[[NSURLResponse alloc] initWithURL:request.URL
MIMEType:representation.UTI
MIMEType:(__bridge NSString *)(MIMEType)
expectedContentLength:length
textEncodingName:nil];
@@ -16,7 +16,6 @@
var NativeMethodsMixin = require('NativeMethodsMixin');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var RCTDatePickerIOSConsts = require('UIManager').RCTDatePicker.Constants;
var StyleSheet = require('StyleSheet');
var View = require('View');
@@ -142,8 +141,8 @@ var DatePickerIOS = React.createClass({
var styles = StyleSheet.create({
datePickerIOS: {
height: RCTDatePickerIOSConsts.ComponentHeight,
width: RCTDatePickerIOSConsts.ComponentWidth,
height: 216,
width: 320,
},
});
+1
View File
@@ -351,6 +351,7 @@ const MapView = React.createClass({
}
var viewIndex = children.length;
children.push(React.cloneElement(view, {
// $FlowFixMe - An array of styles should be fine
style: [styles.annotationView, view.props.style || {}]
}));
}
@@ -52,7 +52,11 @@ var PickerAndroid = React.createClass({
},
getInitialState: function() {
return this._stateFromProps(this.props);
var state = this._stateFromProps(this.props);
return {
...state,
initialSelectedIndex: state.selectedIndex,
};
},
componentWillReceiveProps: function(nextProps) {
@@ -87,7 +91,7 @@ var PickerAndroid = React.createClass({
mode: this.props.mode,
onSelect: this._onChange,
prompt: this.props.prompt,
selected: this.state.selectedIndex,
selected: this.state.initialSelectedIndex,
testID: this.props.testID,
style: [styles.pickerAndroid, this.props.style],
};
@@ -105,15 +109,24 @@ var PickerAndroid = React.createClass({
this.props.onValueChange(null, position);
}
}
this._lastNativePosition = event.nativeEvent.position;
this.forceUpdate();
},
componentDidMount: function() {
this._lastNativePosition = this.state.initialSelectedIndex;
},
componentDidUpdate: function() {
// The picker is a controlled component. This means we expect the
// on*Change handlers to be in charge of updating our
// `selectedValue` prop. That way they can also
// disallow/undo/mutate the selection of certain values. In other
// words, the embedder of this component should be the source of
// truth, not the native component.
if (this.refs[REF_PICKER] && this.state.selectedIndex !== event.nativeEvent.position) {
if (this.refs[REF_PICKER] && this.state.selectedIndex !== this._lastNativePosition) {
this.refs[REF_PICKER].setNativeProps({selected: this.state.selectedIndex});
this._lastNativePosition = this.state.selectedIndex;
}
},
});
@@ -15,7 +15,6 @@
var NativeMethodsMixin = require('NativeMethodsMixin');
var React = require('React');
var ReactChildren = require('ReactChildren');
var RCTPickerIOSConsts = require('NativeModules').UIManager.RCTPicker.Constants;
var StyleSheet = require('StyleSheet');
var StyleSheetPropType = require('StyleSheetPropType');
var TextStylePropTypes = require('TextStylePropTypes');
@@ -108,7 +107,7 @@ var styles = StyleSheet.create({
// The picker will conform to whatever width is given, but we do
// have to set the component's height explicitly on the
// surrounding view to ensure it gets rendered.
height: RCTPickerIOSConsts.ComponentHeight,
height: 216,
},
});
@@ -13,7 +13,6 @@
var Image = require('Image');
var NativeMethodsMixin = require('NativeMethodsMixin');
var NativeModules = require('NativeModules');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var StyleSheet = require('StyleSheet');
@@ -72,7 +71,7 @@ var ProgressViewIOS = React.createClass({
var styles = StyleSheet.create({
progressView: {
height: NativeModules.ProgressViewManager.ComponentHeight
height: 2,
},
});
-4
View File
@@ -14,7 +14,6 @@
var Dimensions = require('Dimensions');
var Platform = require('Platform');
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
var React = require('React');
var ReactNative = require('ReactNative');
var Subscribable = require('Subscribable');
var TextInputState = require('TextInputState');
@@ -23,9 +22,6 @@ var UIManager = require('UIManager');
var { ScrollViewManager } = require('NativeModules');
var invariant = require('fbjs/lib/invariant');
var warning = require('fbjs/lib/warning');
import type ReactComponent from 'ReactComponent';
/**
* Mixin that can be integrated in order to handle scrolling that plays well
@@ -5,7 +5,6 @@
*/
'use strict';
var NativeMethodsMixin = require('NativeMethodsMixin');
var React = require('React');
var ScrollResponder = require('ScrollResponder');
var ScrollView = require('ScrollView');
+20 -5
View File
@@ -63,7 +63,7 @@ var ScrollView = React.createClass({
automaticallyAdjustContentInsets: PropTypes.bool,
/**
* The amount by which the scroll view content is inset from the edges
* of the scroll view. Defaults to `{0, 0, 0, 0}`.
* of the scroll view. Defaults to `{top: 0, left: 0, bottom: 0, right: 0}`.
* @platform ios
*/
contentInset: EdgeInsetsPropType,
@@ -210,8 +210,11 @@ var ScrollView = React.createClass({
*/
onScrollAnimationEnd: PropTypes.func,
/**
* Called when scrollable content view of the ScrollView changes. It's
* implemented using onLayout handler attached to the content container
* Called when scrollable content view of the ScrollView changes.
*
* Handler function is passed the content width and content height as parameters: `(contentWidth, contentHeight)`
*
* It's implemented using onLayout handler attached to the content container
* which this ScrollView renders.
*/
onContentSizeChange: PropTypes.func,
@@ -563,7 +566,11 @@ var styles = StyleSheet.create({
});
if (Platform.OS === 'android') {
var nativeOnlyProps = { nativeOnly : { 'sendMomentumEvents' : true } };
var nativeOnlyProps = {
nativeOnly: {
sendMomentumEvents: true,
}
};
var AndroidScrollView = requireNativeComponent('RCTScrollView', ScrollView, nativeOnlyProps);
var AndroidHorizontalScrollView = requireNativeComponent(
'AndroidHorizontalScrollView',
@@ -571,7 +578,15 @@ if (Platform.OS === 'android') {
nativeOnlyProps
);
} else if (Platform.OS === 'ios') {
var RCTScrollView = requireNativeComponent('RCTScrollView', ScrollView);
var nativeOnlyProps = {
nativeOnly: {
onMomentumScrollBegin: true,
onMomentumScrollEnd : true,
onScrollBeginDrag: true,
onScrollEndDrag: true,
}
};
var RCTScrollView = requireNativeComponent('RCTScrollView', ScrollView, nativeOnlyProps);
}
module.exports = ScrollView;
@@ -12,7 +12,6 @@
'use strict';
var NativeMethodsMixin = require('NativeMethodsMixin');
var NativeModules = require('NativeModules');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var StyleSheet = require('StyleSheet');
@@ -120,7 +119,7 @@ var SegmentedControlIOS = React.createClass({
var styles = StyleSheet.create({
segmentedControl: {
height: NativeModules.SegmentedControlManager.ComponentHeight
height: 28,
},
});
@@ -27,6 +27,10 @@ var TabBarIOS = React.createClass({
propTypes: {
...View.propTypes,
style: View.propTypes.style,
/**
* Color of text on unselected tabs
*/
unselectedTintColor: ColorPropType,
/**
* Color of the currently selected tab icon
*/
@@ -45,6 +49,7 @@ var TabBarIOS = React.createClass({
return (
<RCTTabBar
style={[styles.tabGroup, this.props.style]}
unselectedTintColor={this.props.unselectedTintColor}
tintColor={this.props.tintColor}
barTintColor={this.props.barTintColor}
translucent={this.props.translucent !== false}>
@@ -62,6 +62,11 @@ var TabBarItemIOS = React.createClass({
* component to set selected={true}.
*/
onPress: React.PropTypes.func,
/**
* If set to true it renders the image as original,
* it defaults to being displayed as a template
*/
renderAsOriginal: React.PropTypes.bool,
/**
* It specifies whether the children are visible or not. If you see a
* blank content, you probably forgot to add a selected one.
+2 -2
View File
@@ -443,8 +443,8 @@ var TextInput = React.createClass({
!(props.value && childCount),
'Cannot specify both value and children.'
);
if (childCount > 1) {
children = <Text>{children}</Text>;
if (childCount >= 1) {
children = <Text style={props.style}>{children}</Text>;
}
if (props.inputView) {
children = [children, props.inputView];
+2 -5
View File
@@ -360,10 +360,10 @@ var TouchableMixin = {
/**
* Place as callback for a DOM element's `onResponderGrant` event.
* @param {SyntheticEvent} e Synthetic event from event system.
* @param {string} dispatchID ID of node that e was dispatched to.
*
*/
touchableHandleResponderGrant: function(e, dispatchID) {
touchableHandleResponderGrant: function(e) {
var dispatchID = e.currentTarget;
// Since e is used in a callback invoked on another event loop
// (as in setTimeout etc), we need to call e.persist() on the
// event to make sure it doesn't get reused in the event object pool.
@@ -756,8 +756,5 @@ var Touchable = {
);
}
};
if (Touchable.TOUCH_TARGET_DEBUG) {
console.warn('Touchable.TOUCH_TARGET_DEBUG is enabled');
}
module.exports = Touchable;
@@ -55,7 +55,7 @@ var TouchableOpacity = React.createClass({
...TouchableWithoutFeedback.propTypes,
/**
* Determines what the opacity of the wrapped view should be when touch is
* active.
* active. Defaults to 0.2.
*/
activeOpacity: React.PropTypes.number,
},
@@ -123,6 +123,12 @@ var ViewPagerAndroid = React.createClass({
'none', // default
'on-drag',
]),
/**
* When false, the content does not scroll.
* The default value is true.
*/
scrollEnabled: React.PropTypes.bool,
},
componentDidMount: function() {
@@ -264,6 +264,14 @@ var WebView = React.createClass({
);
},
stopLoading: function() {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
UIManager.RCTWebView.Commands.stopLoading,
null
);
},
/**
* We return an event with a bunch of fields including:
* url, title, loading, canGoBack, canGoForward
@@ -362,6 +362,14 @@ var WebView = React.createClass({
);
},
stopLoading: function() {
UIManager.dispatchViewManagerCommand(
this.getWebViewHandle(),
UIManager.RCTWebView.Commands.stopLoading,
null
);
},
/**
* We return an event with a bunch of fields including:
* url, title, loading, canGoBack, canGoForward
@@ -56,10 +56,10 @@ var DEFAULT_SCROLL_CALLBACK_THROTTLE = 50;
/**
* ListView - A core component designed for efficient display of vertically
* scrolling lists of changing data. The minimal API is to create a
* `ListView.DataSource`, populate it with a simple array of data blobs, and
* instantiate a `ListView` component with that data source and a `renderRow`
* callback which takes a blob from the data array and returns a renderable
* component.
* [`ListView.DataSource`](docs/listviewdatasource.html), populate it with a simple
* array of data blobs, and instantiate a `ListView` component with that data
* source and a `renderRow` callback which takes a blob from the data array and
* returns a renderable component.
*
* Minimal example:
*
@@ -117,7 +117,9 @@ var ListView = React.createClass({
*/
propTypes: {
...ScrollView.propTypes,
/**
* An instance of [ListView.DataSource](docs/listviewdatasource.html) to use
*/
dataSource: PropTypes.instanceOf(ListViewDataSource).isRequired,
/**
* (sectionID, rowID, adjacentRowHighlighted) => renderable
@@ -38,6 +38,7 @@ const NavigationCardStackStyleInterpolator = require('NavigationCardStackStyleIn
const NavigationContainer = require('NavigationContainer');
const NavigationPagerPanResponder = require('NavigationPagerPanResponder');
const NavigationPagerStyleInterpolator = require('NavigationPagerStyleInterpolator');
const NavigationPointerEventsContainer = require('NavigationPointerEventsContainer');
const NavigationPropTypes = require('NavigationPropTypes');
const React = require('React');
const ReactComponentWithPureRenderMixin = require('ReactComponentWithPureRenderMixin');
@@ -50,20 +51,39 @@ import type {
NavigationSceneRendererProps,
} from 'NavigationTypeDefinition';
type SceneViewProps = {
sceneRenderer: NavigationSceneRenderer,
sceneRendererProps: NavigationSceneRendererProps,
};
type Props = NavigationSceneRendererProps & {
style: any,
onComponentRef: (ref: any) => void,
panHandlers: ?NavigationPanPanHandlers,
pointerEvents: string,
renderScene: NavigationSceneRenderer,
style: any,
};
const {PropTypes} = React;
const propTypes = {
...NavigationPropTypes.SceneRenderer,
style: PropTypes.any,
panHandlers: NavigationPropTypes.panHandlers,
renderScene: PropTypes.func.isRequired,
};
class SceneView extends React.Component<any, SceneViewProps, any> {
static propTypes = {
sceneRenderer: PropTypes.func.isRequired,
sceneRendererProps: NavigationPropTypes.SceneRenderer,
};
shouldComponentUpdate(nextProps: SceneViewProps, nextState: any): boolean {
return (
nextProps.sceneRendererProps.scene.navigationState !==
this.props.sceneRendererProps.scene.navigationState
);
}
render(): ?ReactElement {
return this.props.sceneRenderer(this.props.sceneRendererProps);
}
}
/**
* Component that renders the scene as card for the <NavigationCardStack />.
@@ -71,6 +91,15 @@ const propTypes = {
class NavigationCard extends React.Component<any, Props, any> {
props: Props;
static propTypes = {
...NavigationPropTypes.SceneRendererProps,
onComponentRef: PropTypes.func.isRequired,
panHandlers: NavigationPropTypes.panHandlers,
pointerEvents: PropTypes.string.isRequired,
renderScene: PropTypes.func.isRequired,
style: PropTypes.any,
};
shouldComponentUpdate(nextProps: Props, nextState: any): boolean {
return ReactComponentWithPureRenderMixin.shouldComponentUpdate.call(
this,
@@ -82,50 +111,35 @@ class NavigationCard extends React.Component<any, Props, any> {
render(): ReactElement {
const {
panHandlers,
pointerEvents,
renderScene,
style,
...props, /* NavigationSceneRendererProps */
} = this.props;
let viewStyle = null;
if (style === undefined) {
// fall back to default style.
viewStyle = NavigationCardStackStyleInterpolator.forHorizontal(props);
} else {
viewStyle = style;
}
const viewStyle = style === undefined ?
NavigationCardStackStyleInterpolator.forHorizontal(props) :
style;
const {
navigationState,
scene,
} = props;
const interactive = navigationState.index === scene.index && !scene.isStale;
const pointerEvents = interactive ? 'auto' : 'none';
let viewPanHandlers = null;
if (interactive) {
if (panHandlers === undefined) {
// fall back to default pan handlers.
viewPanHandlers = NavigationCardStackPanResponder.forHorizontal(props);
} else {
viewPanHandlers = panHandlers;
}
}
const viewPanHandlers = panHandlers === undefined ?
NavigationCardStackPanResponder.forHorizontal(props) :
panHandlers;
return (
<Animated.View
{...viewPanHandlers}
pointerEvents={pointerEvents}
ref={this.props.onComponentRef}
style={[styles.main, viewStyle]}>
{renderScene(props)}
<SceneView
sceneRenderer={renderScene}
sceneRendererProps={props}
/>
</Animated.View>
);
}
}
NavigationCard.propTypes = propTypes;
const styles = StyleSheet.create({
main: {
backgroundColor: '#E9E9EF',
@@ -141,13 +155,13 @@ const styles = StyleSheet.create({
},
});
const NavigationCardContainer = NavigationContainer.create(NavigationCard);
NavigationCard = NavigationPointerEventsContainer.create(NavigationCard);
NavigationCard = NavigationContainer.create(NavigationCard);
// Export these buil-in interaction modules.
NavigationCardContainer.CardStackPanResponder = NavigationCardStackPanResponder;
NavigationCardContainer.CardStackStyleInterpolator = NavigationCardStackStyleInterpolator;
NavigationCardContainer.PagerPanResponder = NavigationPagerPanResponder;
NavigationCardContainer.PagerStyleInterpolator = NavigationPagerStyleInterpolator;
NavigationCard.CardStackPanResponder = NavigationCardStackPanResponder;
NavigationCard.CardStackStyleInterpolator = NavigationCardStackStyleInterpolator;
NavigationCard.PagerPanResponder = NavigationPagerPanResponder;
NavigationCard.PagerStyleInterpolator = NavigationPagerStyleInterpolator;
module.exports = NavigationCardContainer;
module.exports = NavigationCard;
@@ -64,6 +64,11 @@ type Props = {
renderScene: NavigationSceneRenderer,
};
type DefaultProps = {
direction: NavigationGestureDirection,
renderOverlay: ?NavigationSceneRenderer,
};
/**
* A controlled navigation view that renders a stack of cards.
*
@@ -78,7 +83,7 @@ type Props = {
* +-+ |
* +------------+
*/
class NavigationCardStack extends React.Component {
class NavigationCardStack extends React.Component<DefaultProps, Props, void> {
_renderScene : NavigationSceneRenderer;
static propTypes = {
@@ -88,7 +93,7 @@ class NavigationCardStack extends React.Component {
renderScene: PropTypes.func.isRequired,
};
static defaultProps = {
static defaultProps: DefaultProps = {
direction: Directions.HORIZONTAL,
renderOverlay: emptyFunction.thatReturnsNull,
};
@@ -101,7 +106,7 @@ class NavigationCardStack extends React.Component {
this._renderScene = this._renderScene.bind(this);
}
shouldComponentUpdate(nextProps: Object, nextState: Object): boolean {
shouldComponentUpdate(nextProps: Object, nextState: void): boolean {
return ReactComponentWithPureRenderMixin.shouldComponentUpdate.call(
this,
nextProps,
@@ -115,6 +120,7 @@ class NavigationCardStack extends React.Component {
navigationState={this.props.navigationState}
renderOverlay={this.props.renderOverlay}
renderScene={this._renderScene}
// $FlowFixMe - style should be declared
style={[styles.animatedView, this.props.style]}
/>
);
@@ -51,6 +51,28 @@ import type {
* +------------+
*/
/**
* Render the initial style when the initial layout isn't measured yet.
*/
function forInitial(props: NavigationSceneRendererProps): Object {
const {
navigationState,
scene,
} = props;
const focused = navigationState.index === scene.index;
const opacity = focused ? 1 : 0;
// If not focused, move the scene to the far away.
const translate = focused ? 0 : 1000000;
return {
opacity,
transform: [
{ translateX: translate },
{ translateY: translate },
],
};
}
function forHorizontal(props: NavigationSceneRendererProps): Object {
const {
layout,
@@ -58,6 +80,10 @@ function forHorizontal(props: NavigationSceneRendererProps): Object {
scene,
} = props;
if (!layout.isMeasured) {
return forInitial(props);
}
const index = scene.index;
const inputRange = [index - 1, index, index + 1];
const width = layout.initWidth;
@@ -95,6 +121,10 @@ function forVertical(props: NavigationSceneRendererProps): Object {
scene,
} = props;
if (!layout.isMeasured) {
return forInitial(props);
}
const index = scene.index;
const inputRange = [index - 1, index, index + 1];
const height = layout.initHeight;
@@ -95,7 +95,7 @@ class NavigationHeader extends React.Component<DefaultProps, Props, any> {
};
static propTypes = {
...NavigationPropTypes.SceneRenderer,
...NavigationPropTypes.SceneRendererProps,
renderLeftComponent: PropTypes.func,
renderRightComponent: PropTypes.func,
renderTitleComponent: PropTypes.func,
@@ -244,10 +244,10 @@ const styles = StyleSheet.create({
},
});
NavigationHeader = NavigationContainer.create(NavigationHeader);
const NavigationHeaderContainer = NavigationContainer.create(NavigationHeader);
NavigationHeader.HEIGHT = APPBAR_HEIGHT + STATUSBAR_HEIGHT;
NavigationHeader.Title = NavigationHeaderTitle;
NavigationHeader.BackButton = NavigationHeaderBackButton;
NavigationHeaderContainer.HEIGHT = APPBAR_HEIGHT + STATUSBAR_HEIGHT;
NavigationHeaderContainer.Title = NavigationHeaderTitle;
NavigationHeaderContainer.BackButton = NavigationHeaderBackButton;
module.exports = NavigationHeader;
module.exports = NavigationHeaderContainer;
@@ -51,6 +51,29 @@ import type {
* +-------------+-------------+-------------+
*/
/**
* Render the initial style when the initial layout isn't measured yet.
*/
function forInitial(props: NavigationSceneRendererProps): Object {
const {
navigationState,
scene,
} = props;
const focused = navigationState.index === scene.index;
const opacity = focused ? 1 : 0;
// If not focused, move the scene to the far away.
const dir = scene.index > navigationState.index ? 1 : -1;
const translate = focused ? 0 : (1000000 * dir);
return {
opacity,
transform: [
{ translateX: translate },
{ translateY: translate },
],
};
}
function forHorizontal(props: NavigationSceneRendererProps): Object {
const {
layout,
@@ -58,6 +81,10 @@ function forHorizontal(props: NavigationSceneRendererProps): Object {
scene,
} = props;
if (!layout.isMeasured) {
return forInitial(props);
}
const index = scene.index;
const inputRange = [index - 1, index, index + 1];
@@ -0,0 +1,158 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* Facebook, Inc. ("Facebook") owns all right, title and interest, including
* all intellectual property and other proprietary rights, in and to the React
* Native CustomComponents software (the "Software"). Subject to your
* compliance with these terms, you are hereby granted a non-exclusive,
* worldwide, royalty-free copyright license to (1) use and copy the Software;
* and (2) reproduce and distribute the Software as part of your own software
* ("Your Software"). Facebook reserves all rights not expressly granted to
* you in this license agreement.
*
* THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED.
* IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR
* EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @providesModule NavigationPointerEventsContainer
* @flow
*/
'use strict';
const React = require('React');
const NavigationAnimatedValueSubscription = require('NavigationAnimatedValueSubscription');
const invariant = require('fbjs/lib/invariant');
import type {
NavigationSceneRendererProps,
} from 'NavigationTypeDefinition';
type Props = NavigationSceneRendererProps;
const MIN_POSITION_OFFSET = 0.01;
/**
* Create a higher-order component that automatically computes the
* `pointerEvents` property for a component whenever navigation position
* changes.
*/
function create(
Component: ReactClass<any>,
): ReactClass {
class Container extends React.Component<any, Props, any> {
_component: any;
_onComponentRef: (view: any) => void;
_onPositionChange: (data: {value: number}) => void;
_pointerEvents: string;
_positionListener: ?NavigationAnimatedValueSubscription;
props: Props;
constructor(props: Props, context: any) {
super(props, context);
this._pointerEvents = this._computePointerEvents();
}
componentWillMount(): void {
this._onPositionChange = this._onPositionChange.bind(this);
this._onComponentRef = this._onComponentRef.bind(this);
}
componentDidMount(): void {
this._bindPosition(this.props);
}
componentWillUnmount(): void {
this._positionListener && this._positionListener.remove();
}
componentWillReceiveProps(nextProps: Props): void {
this._bindPosition(nextProps);
}
render(): ReactElement {
this._pointerEvents = this._computePointerEvents();
return (
<Component
{...this.props}
pointerEvents={this._pointerEvents}
onComponentRef={this._onComponentRef}
/>
);
}
_onComponentRef(component: any): void {
this._component = component;
if (component) {
invariant(
typeof component.setNativeProps === 'function',
'component must implement method `setNativeProps`',
);
}
}
_bindPosition(props: NavigationSceneRendererProps): void {
this._positionListener && this._positionListener.remove();
this._positionListener = new NavigationAnimatedValueSubscription(
props.position,
this._onPositionChange,
);
}
_onPositionChange(): void {
if (this._component) {
const pointerEvents = this._computePointerEvents();
if (this._pointerEvents !== pointerEvents) {
this._pointerEvents = pointerEvents;
this._component.setNativeProps({pointerEvents});
}
}
}
_computePointerEvents(): string {
const {
navigationState,
position,
scene,
} = this.props;
if (scene.isStale || navigationState.index !== scene.index) {
// The scene isn't focused.
return scene.index > navigationState.index ?
'box-only' :
'none';
}
const offset = position.__getAnimatedValue() - navigationState.index;
if (Math.abs(offset) > MIN_POSITION_OFFSET) {
// The positon is still away from scene's index.
// Scene's children should not receive touches until the position
// is close enough to scene's index.
return 'box-only';
}
return 'auto';
}
}
return Container;
}
module.exports = {
create,
};
@@ -29,7 +29,7 @@
*/
'use strict';
jest.dontMock('NavigationLegacyNavigatorRouteStack');
jest.unmock('NavigationLegacyNavigatorRouteStack');
const NavigationLegacyNavigatorRouteStack = require('NavigationLegacyNavigatorRouteStack');
@@ -25,7 +25,7 @@
'use strict';
jest
.autoMockOff()
.disableAutomock()
.mock('ErrorUtils');
var NavigationContext = require('NavigationContext');
@@ -26,8 +26,8 @@
'use strict';
jest
.dontMock('NavigationEvent')
.dontMock('fbjs/lib/invariant');
.unmock('NavigationEvent')
.unmock('fbjs/lib/invariant');
var NavigationEvent = require('NavigationEvent');
@@ -25,12 +25,12 @@
'use strict';
jest
.dontMock('EmitterSubscription')
.dontMock('EventSubscription')
.dontMock('EventEmitter')
.dontMock('EventSubscriptionVendor')
.dontMock('NavigationEvent')
.dontMock('NavigationEventEmitter');
.unmock('EmitterSubscription')
.unmock('EventSubscription')
.unmock('EventEmitter')
.unmock('EventSubscriptionVendor')
.unmock('NavigationEvent')
.unmock('NavigationEventEmitter');
var NavigationEventEmitter = require('NavigationEventEmitter');
@@ -26,7 +26,7 @@
jest
.autoMockOff()
.disableAutomock()
.mock('ErrorUtils');
var NavigationRouteStack = require('NavigationRouteStack');
@@ -5,9 +5,9 @@
'use strict';
jest
.dontMock('NavigationTreeNode')
.dontMock('fbjs/lib/invariant')
.dontMock('immutable');
.unmock('NavigationTreeNode')
.unmock('fbjs/lib/invariant')
.unmock('immutable');
var NavigationTreeNode = require('NavigationTreeNode');
@@ -16,28 +16,8 @@
'use strict';
var BatchedBridge = require('BatchedBridge');
var DebugComponentOwnershipModule = require('NativeModules').DebugComponentOwnershipModule;
var InspectorUtils = require('InspectorUtils');
var ReactNativeTagHandles = require('ReactNativeTagHandles');
function componentToString(component) {
return component.getName ? component.getName() : 'Unknown';
}
function getRootTagForTag(tag: number): ?number {
var rootNodeID = ReactNativeTagHandles.tagToRootNodeID[tag];
if (!rootNodeID) {
return null;
}
var rootID = ReactNativeTagHandles.getNativeTopRootIDFromNodeID(rootNodeID);
if (!rootID) {
return null;
}
return ReactNativeTagHandles.rootNodeIDToTag[rootID];
}
var RCTDebugComponentOwnership = {
/**
* Asynchronously returns the owner hierarchy as an array of strings. Request id is
* passed along to the native module so that the native module can identify the
@@ -46,12 +26,10 @@ var RCTDebugComponentOwnership = {
* Example returned owner hierarchy: ['RootView', 'Dialog', 'TitleView', 'Text']
*/
getOwnerHierarchy: function(requestID: number, tag: number) {
var rootTag = getRootTagForTag(tag);
var instance = InspectorUtils.findInstanceByNativeTag(rootTag, tag);
var ownerHierarchy = instance ?
InspectorUtils.getOwnerHierarchy(instance).map(componentToString) :
null;
DebugComponentOwnershipModule.receiveOwnershipHierarchy(requestID, tag, ownerHierarchy);
// Consider cleaning up these unused modules in a separate diff.
throw new Error(
'This seems to be unused. Will disable until it is needed again.'
);
},
};
+19 -4
View File
@@ -64,12 +64,27 @@ function setupDevtools() {
console.error('Failed to eval: ' + e.message);
return;
}
// This is breaking encapsulation of the React package. Move plz.
var ReactNativeComponentTree = require('ReactNativeComponentTree');
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
CurrentOwner: require('ReactCurrentOwner'),
InstanceHandles: require('ReactInstanceHandles'),
ComponentTree: {
getClosestInstanceFromNode: function (node) {
return ReactNativeComponentTree.getClosestInstanceFromNode(node);
},
getNodeFromInstance: function (inst) {
// inst is an internal instance (but could be a composite)
while (inst._renderedComponent) {
inst = inst._renderedComponent;
}
if (inst) {
return ReactNativeComponentTree.getNodeFromInstance(inst);
} else {
return null;
}
}
},
Mount: require('ReactNativeMount'),
Reconciler: require('ReactReconciler'),
TextComponent: require('ReactNativeTextComponent'),
Reconciler: require('ReactReconciler')
});
ws.onmessage = handleMessage;
}
+18 -12
View File
@@ -87,18 +87,31 @@ export type Props = {
* Tags instances and associated tasks for easier debugging.
*/
name: string;
children: any;
children?: any;
};
class Incremental extends React.Component {
type DefaultProps = {
name: string,
};
type State = {
doIncrementalRender: boolean,
};
class Incremental extends React.Component<DefaultProps, Props, State> {
props: Props;
state: {
doIncrementalRender: boolean;
};
state: State;
context: Context;
_incrementId: number;
_mounted: boolean;
_rendered: boolean;
static defaultProps = {
name: '',
};
static contextTypes = {
incrementalGroup: React.PropTypes.object,
incrementalGroupEnabled: React.PropTypes.bool,
};
constructor(props: Props, context: Context) {
super(props, context);
this._mounted = false;
@@ -159,13 +172,6 @@ class Incremental extends React.Component {
this._mounted = false;
}
}
Incremental.defaultProps = {
name: '',
};
Incremental.contextTypes = {
incrementalGroup: React.PropTypes.object,
incrementalGroupEnabled: React.PropTypes.bool,
};
export type Context = {
incrementalGroupEnabled: boolean;
+18 -16
View File
@@ -31,16 +31,29 @@ import type {Context} from 'Incremental';
*/
type Props = {
name: string;
disabled: boolean;
onDone: () => void;
onLayout: (event: Object) => void;
style: mixed;
children: any;
disabled?: boolean;
onDone?: () => void;
onLayout?: (event: Object) => void;
style?: mixed;
children?: any;
}
class IncrementalPresenter extends React.Component {
props: Props;
context: Context;
_isDone: boolean;
static propTypes = {
name: React.PropTypes.string,
disabled: React.PropTypes.bool,
onDone: React.PropTypes.func,
onLayout: React.PropTypes.func,
style: View.propTypes.style,
};
static contextTypes = {
incrementalGroup: React.PropTypes.object,
incrementalGroupEnabled: React.PropTypes.bool,
};
constructor(props: Props, context: Context) {
super(props, context);
this._isDone = false;
@@ -80,16 +93,5 @@ class IncrementalPresenter extends React.Component {
);
}
}
IncrementalPresenter.propTypes = {
name: React.PropTypes.string,
disabled: React.PropTypes.bool,
onDone: React.PropTypes.func,
onLayout: React.PropTypes.func,
style: View.propTypes.style,
};
IncrementalPresenter.contextTypes = {
incrementalGroup: React.PropTypes.object,
incrementalGroupEnabled: React.PropTypes.bool,
};
module.exports = IncrementalPresenter;
+77 -48
View File
@@ -83,13 +83,13 @@ type Props = {
* A simple array of data blobs that are passed to the renderRow function in
* order. Note there is no dataSource like in the standard `ListView`.
*/
data: Array<mixed>;
data: Array<any>;
/**
* Takes a data blob from the `data` array prop plus some meta info and should
* return a row.
*/
renderRow: (
data: mixed, sectionIdx: number, rowIdx: number, key: string
data: any, sectionIdx: number, rowIdx: number, key?: string
) => ?ReactElement;
/**
* Rendered when the list is scrolled faster than rows can be rendered.
@@ -140,7 +140,7 @@ type Props = {
/**
* Used to log perf events for async row rendering.
*/
asyncRowPerfEventName: ?string;
asyncRowPerfEventName?: string;
/**
* A function that returns the scrollable component in which the list rows
* are rendered. Defaults to returning a ScrollView with the given props.
@@ -158,30 +158,28 @@ type Props = {
* Called when rows will be mounted/unmounted. Mounted rows always form a contiguous block so it is expressed as a
* range of start plus count.
*/
onMountedRowsWillChange: (firstIdx: number, count: number) => void;
onMountedRowsWillChange?: (firstIdx: number, count: number) => void;
/**
* Change this when you want to make sure the WindowedListView will re-render, for example when the result of
* `renderScrollComponent` might change. It will be compared in `shouldComponentUpdate`.
*/
shouldUpdateToken?: string;
};
const defaultProps = {
enableDangerousRecycling: false,
initialNumToRender: 10,
maxNumToRender: 30,
numToRenderAhead: 10,
viewablePercentThreshold: 50,
renderScrollComponent: (props) => <ScrollView {...props} />,
disableIncrementalRendering: false,
recomputeRowsBatchingPeriod: 100,
type State = {
boundaryIndicatorHeight?: number;
firstRow: number;
lastRow: number;
};
class WindowedListView extends React.Component {
props: Props;
state: {
boundaryIndicatorHeight?: number;
firstRow: number;
lastRow: number;
firstVisible: number;
lastVisible: number;
};
state: State;
_firstVisible: number = -1;
_lastVisible: number = -1;
_scrollOffsetY: number = 0;
_frameHeight: number = 0;
_rowFrames: Array<Object> = [];
_rowFramesDirty: boolean = false;
_hasCalledOnEndReached: bool = false;
_willComputeRowsToRender: bool = false;
_timeoutHandle: number = 0;
@@ -189,6 +187,18 @@ class WindowedListView extends React.Component {
_viewableRows: Array<number> = [];
_cellsInProgress: Set<number> = new Set();
_scrollRef: ?Object;
static defaultProps = {
enableDangerousRecycling: false,
initialNumToRender: 10,
maxNumToRender: 30,
numToRenderAhead: 10,
viewablePercentThreshold: 50,
renderScrollComponent: (props) => <ScrollView {...props} />,
disableIncrementalRendering: false,
recomputeRowsBatchingPeriod: 100,
};
constructor(props: Props) {
super(props);
invariant(
@@ -197,10 +207,7 @@ class WindowedListView extends React.Component {
);
this.state = {
firstRow: 0,
lastRow:
Math.min(this.props.data.length, this.props.initialNumToRender) - 1,
firstVisible: -1,
lastVisible: -1,
lastRow: Math.min(this.props.data.length, this.props.initialNumToRender) - 1,
};
}
getScrollResponder(): ?ReactComponent {
@@ -208,6 +215,27 @@ class WindowedListView extends React.Component {
this._scrollRef.getScrollResponder &&
this._scrollRef.getScrollResponder();
}
shouldComponentUpdate(newProps: Props, newState: State): boolean {
if (newState !== this.state) {
return true;
}
for (const key in newProps) {
if (key !== 'data' && newProps[key] !== this.props[key]) {
return true;
}
}
const newDataSubset = newProps.data.slice(newState.firstRow, newState.lastRow + 1);
const prevDataSubset = this.props.data.slice(this.state.firstRow, this.state.lastRow + 1);
if (newDataSubset.length !== prevDataSubset.length) {
return true;
}
for (let idx = 0; idx < newDataSubset.length; idx++) {
if (newDataSubset[idx] !== prevDataSubset[idx]) {
return true;
}
}
return false;
}
componentWillReceiveProps(newProps: Object) {
// This has to happen immediately otherwise we could crash, e.g. if the data
// array has gotten shorter.
@@ -245,10 +273,11 @@ class WindowedListView extends React.Component {
const layoutPrev = this._rowFrames[rowIndex] || {};
console.log(
'record layout for row: ',
{i: rowIndex, h: layout.height, y: layout.y, hp: layoutPrev.height, yp: layoutPrev.y}
{i: rowIndex, h: layout.height, y: layout.y, x: layout.x, hp: layoutPrev.height, yp: layoutPrev.y}
);
}
this._rowFrames[rowIndex] = {...layout, offscreenLayoutDone: true};
this._rowFramesDirty = true;
if (this._cellsInProgress.size === 0) {
this._enqueueComputeRowsToRender();
}
@@ -293,11 +322,10 @@ class WindowedListView extends React.Component {
_computeRowsToRender(props: Object): void {
const totalRows = props.data.length;
if (totalRows === 0) {
this._updateVisibleRows(-1, -1);
this.setState({
firstRow: 0,
lastRow: -1,
firstVisible: -1,
lastVisible: -1,
});
return;
}
@@ -372,29 +400,28 @@ class WindowedListView extends React.Component {
this._hasCalledOnEndReached = this.state.lastRow === lastRow;
}
}
if (this.state.firstRow !== firstRow || this.state.lastRow !== lastRow) {
this.props.onMountedRowsWillChange && this.props.onMountedRowsWillChange(firstRow, lastRow - firstRow + 1);
console.log('WLV: row render range changed:', {firstRow, lastRow});
const rowsShouldChange = firstRow !== this.state.firstRow || lastRow !== this.state.lastRow;
if (this._rowFramesDirty || rowsShouldChange) {
if (rowsShouldChange) {
this.props.onMountedRowsWillChange && this.props.onMountedRowsWillChange(firstRow, lastRow - firstRow + 1);
console.log('WLV: row render range will change:', {firstRow, lastRow});
}
this._rowFramesDirty = false;
this.setState({firstRow, lastRow});
}
this.setState({firstRow, lastRow});
}
_updateVisibleRows(newFirstVisible: number, newLastVisible: number) {
if (this.state.firstVisible !== newFirstVisible ||
this.state.lastVisible !== newLastVisible) {
if (this.props.onVisibleRowsChanged) {
this.props.onVisibleRowsChanged(
newFirstVisible,
newLastVisible - newFirstVisible + 1);
if (this.props.onVisibleRowsChanged) {
if (this._firstVisible !== newFirstVisible ||
this._lastVisible !== newLastVisible) {
this.props.onVisibleRowsChanged(newFirstVisible, newLastVisible - newFirstVisible + 1);
}
this.setState({
firstVisible: newFirstVisible,
lastVisible: newLastVisible,
});
}
this._firstVisible = newFirstVisible;
this._lastVisible = newLastVisible;
}
render(): ReactElement {
const firstRow = this.state.firstRow;
const lastRow = this.state.lastRow;
const {firstRow, lastRow} = this.state;
const rowFrames = this._rowFrames;
const rows = [];
let spacerHeight = 0;
@@ -496,7 +523,6 @@ class WindowedListView extends React.Component {
);
}
}
WindowedListView.defaultProps = defaultProps;
// performance testing id, unique for each component mount cycle
let g_perf_update_id = 0;
@@ -531,7 +557,7 @@ type CellProps = {
* Updates the parent with the latest layout. Only called when incremental rendering is done and triggers the parent
* to re-render this row with includeInLayout true.
*/
onNewLayout: (params: {rowIndex: number, layout: ?Object}) => void;
onNewLayout: (params: {rowIndex: number, layout: Object}) => void;
/**
* Used to track when rendering is in progress so the parent can avoid wastedful re-renders that are just going to be
* invalidated once the cell finishes.
@@ -549,12 +575,16 @@ class CellRenderer extends React.Component {
_lastLayout: ?Object = null;
_perfUpdateID: number = 0;
_asyncCookie: any;
_includeInLayoutLatch: boolean = false;
componentWillMount() {
if (this.props.asyncRowPerfEventName) {
this._perfUpdateID = g_perf_update_id++;
this._asyncCookie = Systrace.beginAsyncEvent(this.props.asyncRowPerfEventName + this._perfUpdateID);
console.log(`perf_asynctest_${this.props.asyncRowPerfEventName}_start ${this._perfUpdateID} ${Date.now()}`);
}
if (this.props.includeInLayout) {
this._includeInLayoutLatch = true;
}
this.props.onProgressChange({rowIndex: this.props.rowIndex, inProgress: true});
}
_onLayout = (e) => {
@@ -598,9 +628,8 @@ class CellRenderer extends React.Component {
componentWillReceiveProps(newProps) {
if (newProps.includeInLayout && !this.props.includeInLayout) {
invariant(this._offscreenRenderDone, 'Should never try to add to layout before render done');
this._includeInLayoutLatch = true; // Once we render in layout, make sure it sticks.
this.refs.container.setNativeProps({style: styles.include});
} else {
invariant(!(this.props.includeInLayout && !newProps.includeInLayout), 'Should never unset includeInLayout');
}
}
shouldComponentUpdate(newProps) {
@@ -615,7 +644,7 @@ class CellRenderer extends React.Component {
Row: {this.props.rowIndex}
</Text>;
}
const style = this.props.includeInLayout ? styles.include : styles.remove;
const style = (this._includeInLayoutLatch || this.props.includeInLayout) ? styles.include : styles.remove;
return (
<IncrementalGroup onDone={this._onOffscreenRenderDone} name={`CellRenderer_${this.props.rowIndex}`}>
<View
+18 -1
View File
@@ -371,7 +371,24 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image,
// Check for cached response before reloading
// TODO: move URL cache out of RCTImageLoader into its own module
NSCachedURLResponse *cachedResponse = [_URLCache cachedResponseForRequest:request];
if (cachedResponse) {
while (cachedResponse) {
if ([cachedResponse.response isKindOfClass:[NSHTTPURLResponse class]]) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)cachedResponse.response;
if (httpResponse.statusCode == 301 || httpResponse.statusCode == 302) {
NSString *location = httpResponse.allHeaderFields[@"Location"];
if (location == nil) {
completionHandler(RCTErrorWithMessage(@"Image redirect without location"), nil);
return;
}
NSURL *redirectURL = [NSURL URLWithString: location];
request = [NSURLRequest requestWithURL: redirectURL];
cachedResponse = [_URLCache cachedResponseForRequest:request];
continue;
}
}
processResponse(cachedResponse.response, cachedResponse.data, nil);
return;
}
-7
View File
@@ -93,11 +93,4 @@ RCT_EXTERN UIImage *__nullable RCTTransformImage(UIImage *image,
*/
RCT_EXTERN BOOL RCTImageHasAlpha(CGImageRef image);
/**
* Create a solid placeholder image of the specified size and color to display
* while loading an image. If color is not specified, image will be transparent.
*/
RCT_EXTERN UIImage *__nullable RCTGetPlaceholderImage(CGSize size,
UIColor *__nullable color);
NS_ASSUME_NONNULL_END
-45
View File
@@ -16,8 +16,6 @@
#import "RCTLog.h"
#import "RCTUtils.h"
static const CGFloat RCTThresholdValue = 0.0001;
static CGFloat RCTCeilValue(CGFloat value, CGFloat scale)
{
return ceil(value * scale) / scale;
@@ -337,46 +335,3 @@ BOOL RCTImageHasAlpha(CGImageRef image)
return YES;
}
}
UIImage *__nullable RCTGetPlaceholderImage(CGSize size,
UIColor *__nullable color)
{
if (size.width <= 0 || size.height <= 0) {
return nil;
}
// If dimensions are nonintegral, increase scale
CGFloat scale = 1;
if (size.width - floor(size.width) > RCTThresholdValue) {
scale *= round(1.0 / (size.width - floor(size.width)));
}
if (size.height - floor(size.height) > RCTThresholdValue) {
scale *= round(1.0 / (size.height - floor(size.height)));
}
// Use Euclid's algorithm to find the greatest common divisor
// between the specified placeholder width and height;
NSInteger a = size.width * scale;
NSInteger b = size.height * scale;
while (a != 0) {
NSInteger c = a;
a = b % a;
b = c;
}
// Divide the placeholder image scale by the GCD we found above. This allows
// us to save memory by creating the smallest possible placeholder image
// with the correct aspect ratio, then scaling it up at display time.
scale /= b;
// Fill image with specified color
CGFloat alpha = CGColorGetAlpha(color.CGColor);
UIGraphicsBeginImageContextWithOptions(size, ABS(1.0 - alpha) < RCTThresholdValue, scale);
if (alpha > 0) {
[color setFill];
UIRectFill((CGRect){CGPointZero, size});
}
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
-4
View File
@@ -52,10 +52,6 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
RCTZeroIfNaN(self.height),
};
if (!_image) {
_image = RCTGetPlaceholderImage(imageSize, nil);
}
__weak RCTShadowVirtualImage *weakSelf = self;
_cancellationBlock = [_bridge.imageLoader loadImageWithTag:_source.imageURL.absoluteString
size:imageSize
@@ -9,10 +9,10 @@
'use strict';
jest
.dontMock('AssetRegistry')
.dontMock('AssetSourceResolver')
.dontMock('../resolveAssetSource')
.dontMock('../../../local-cli/bundle/assetPathUtils');
.unmock('AssetRegistry')
.unmock('AssetSourceResolver')
.unmock('../resolveAssetSource')
.unmock('../../../local-cli/bundle/assetPathUtils');
var AssetRegistry = require('AssetRegistry');
var Platform = require('Platform');
+25 -4
View File
@@ -9,6 +9,9 @@
* @providesModule Inspector
* @flow
*/
/* eslint-disable dot-notation, no-dimensions-get-window */
'use strict';
var Dimensions = require('Dimensions');
@@ -16,7 +19,6 @@ var InspectorOverlay = require('InspectorOverlay');
var InspectorPanel = require('InspectorPanel');
var InspectorUtils = require('InspectorUtils');
var React = require('React');
var ReactNative = require('ReactNative');
var StyleSheet = require('StyleSheet');
var Touchable = require('Touchable');
var UIManager = require('NativeModules').UIManager;
@@ -28,6 +30,23 @@ if (window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
}
class Inspector extends React.Component {
props: {
inspectedViewTag: ?number,
rootTag: ?number,
onRequestRerenderApp: (callback: (tag: ?number) => void) => void
};
state: {
devtoolsAgent: ?Object,
hierarchy: any,
panelPos: string,
inspecting: bool,
selection: ?number,
perfing: bool,
inspected: any,
inspectedViewTag: any,
};
_subs: ?Array<() => void>;
constructor(props: Object) {
@@ -35,17 +54,19 @@ class Inspector extends React.Component {
this.state = {
devtoolsAgent: null,
hierarchy: null,
panelPos: 'bottom',
inspecting: true,
perfing: false,
inspected: null,
selection: null,
inspectedViewTag: this.props.inspectedViewTag,
};
}
componentDidMount() {
if (window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
this.attachToDevtools = this.attachToDevtools.bind(this);
(this : any).attachToDevtools = this.attachToDevtools.bind(this);
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.on('react-devtools', this.attachToDevtools);
// if devtools is already started
if (window.__REACT_DEVTOOLS_GLOBAL_HOOK__.reactDevtoolsAgent) {
@@ -107,8 +128,8 @@ class Inspector extends React.Component {
var instance = this.state.hierarchy[i];
// if we inspect a stateless component we can't use the getPublicInstance method
// therefore we use the internal _instance property directly.
var publicInstance = instance._instance || {};
UIManager.measure(ReactNative.findNodeHandle(instance), (x, y, width, height, left, top) => {
var publicInstance = instance['_instance'] || {};
UIManager.measure(instance.getNativeNode(), (x, y, width, height, left, top) => {
this.setState({
inspected: {
frame: {left, top, width, height},
+2 -35
View File
@@ -10,10 +10,7 @@
*/
'use strict';
var ReactInstanceHandles = require('ReactInstanceHandles');
var ReactInstanceMap = require('ReactInstanceMap');
var ReactNativeMount = require('ReactNativeMount');
var ReactNativeTagHandles = require('ReactNativeTagHandles');
var ReactNativeComponentTree = require('ReactNativeComponentTree');
function traverseOwnerTreeUp(hierarchy, instance) {
if (instance) {
@@ -22,38 +19,8 @@ function traverseOwnerTreeUp(hierarchy, instance) {
}
}
function findInstance(component, targetID) {
if (targetID === findRootNodeID(component)) {
return component;
}
if (component._renderedComponent) {
return findInstance(component._renderedComponent, targetID);
} else {
for (var key in component._renderedChildren) {
var child = component._renderedChildren[key];
if (ReactInstanceHandles.isAncestorIDOf(findRootNodeID(child), targetID)) {
var instance = findInstance(child, targetID);
if (instance) {
return instance;
}
}
}
}
}
function findRootNodeID(component) {
var internalInstance = ReactInstanceMap.get(component);
return internalInstance ? internalInstance._rootNodeID : component._rootNodeID;
}
function findInstanceByNativeTag(rootTag, nativeTag) {
var containerID = ReactNativeTagHandles.tagToRootNodeID[rootTag];
var rootInstance = ReactNativeMount._instancesByContainerID[containerID];
var targetID = ReactNativeTagHandles.tagToRootNodeID[nativeTag];
if (!targetID) {
return undefined;
}
return findInstance(rootInstance, targetID);
return ReactNativeComponentTree.getInstanceFromNode(nativeTag);
}
function getOwnerHierarchy(instance) {
@@ -26,6 +26,7 @@ import type {Task} from 'TaskQueue';
const _emitter = new EventEmitter();
const DEBUG_DELAY = 0;
const DEBUG = false;
/**
* InteractionManager allows long-running work to be scheduled after any
@@ -100,6 +101,7 @@ var InteractionManager = {
* Notify manager that an interaction has started.
*/
createInteractionHandle(): Handle {
DEBUG && console.log('create interaction handle');
_scheduleUpdate();
var handle = ++_inc;
_addInteractionSet.add(handle);
@@ -110,6 +112,7 @@ var InteractionManager = {
* Notify manager that an interaction has completed.
*/
clearInteractionHandle(handle: Handle) {
DEBUG && console.log('clear interaction handle');
invariant(
!!handle,
'Must provide a handle to clear.'
+3 -1
View File
@@ -39,6 +39,7 @@ const JSEventLoopWatchdog = {
totalStallTime = 0;
stallCount = 0;
longestStall = 0;
lastInterval = performanceNow();
},
addHandler: function(handler: Handler) {
handlers.push(handler);
@@ -49,7 +50,7 @@ const JSEventLoopWatchdog = {
return;
}
installed = true;
let lastInterval = performanceNow();
lastInterval = performanceNow();
function iteration() {
const now = performanceNow();
const busyTime = now - lastInterval;
@@ -80,6 +81,7 @@ let installed = false;
let totalStallTime = 0;
let stallCount = 0;
let longestStall = 0;
let lastInterval = 0;
const handlers: Array<Handler> = [];
module.exports = JSEventLoopWatchdog;
@@ -1,27 +1,34 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule PanResponder
*/
"use strict";
'use strict';
var TouchHistoryMath = require('TouchHistoryMath');
const InteractionManager = require('./InteractionManager');
const TouchHistoryMath = require('TouchHistoryMath');
var currentCentroidXOfTouchesChangedAfter =
TouchHistoryMath.currentCentroidXOfTouchesChangedAfter;
var currentCentroidYOfTouchesChangedAfter =
TouchHistoryMath.currentCentroidYOfTouchesChangedAfter;
var previousCentroidXOfTouchesChangedAfter =
TouchHistoryMath.previousCentroidXOfTouchesChangedAfter;
var previousCentroidYOfTouchesChangedAfter =
TouchHistoryMath.previousCentroidYOfTouchesChangedAfter;
var currentCentroidX = TouchHistoryMath.currentCentroidX;
var currentCentroidY = TouchHistoryMath.currentCentroidY;
const currentCentroidXOfTouchesChangedAfter = TouchHistoryMath.currentCentroidXOfTouchesChangedAfter;
const currentCentroidYOfTouchesChangedAfter = TouchHistoryMath.currentCentroidYOfTouchesChangedAfter;
const previousCentroidXOfTouchesChangedAfter = TouchHistoryMath.previousCentroidXOfTouchesChangedAfter;
const previousCentroidYOfTouchesChangedAfter = TouchHistoryMath.previousCentroidYOfTouchesChangedAfter;
const currentCentroidX = TouchHistoryMath.currentCentroidX;
const currentCentroidY = TouchHistoryMath.currentCentroidY;
/**
* `PanResponder` reconciles several touches into a single gesture. It makes
* single-touch gestures resilient to extra touches, and can be used to
* recognize simple multi-touch gestures.
*
* By default, `PanResponder` holds an `InteractionManager handle to block
* long-running JS events from interrupting active gestures.
*
* It provides a predictable wrapper of the responder handlers provided by the
* [gesture responder system](docs/gesture-responder-system.html).
* For each handler, it provides a new `gestureState` object alongside the
@@ -112,7 +119,7 @@ var currentCentroidY = TouchHistoryMath.currentCentroidY;
* [PanResponder example in UIExplorer](https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/PanResponderExample.js)
*/
var PanResponder = {
const PanResponder = {
/**
*
@@ -177,7 +184,7 @@ var PanResponder = {
* - vx/vy: Velocity.
*/
_initializeGestureState: function(gestureState) {
_initializeGestureState: function (gestureState) {
gestureState.moveX = 0;
gestureState.moveY = 0;
gestureState.x0 = 0;
@@ -215,27 +222,20 @@ var PanResponder = {
* typical responder callback pattern (without using `PanResponder`), but
* avoids more dispatches than necessary.
*/
_updateGestureStateOnMove: function(gestureState, touchHistory) {
_updateGestureStateOnMove: function (gestureState, touchHistory) {
gestureState.numberActiveTouches = touchHistory.numberActiveTouches;
gestureState.moveX = currentCentroidXOfTouchesChangedAfter(
touchHistory,
gestureState._accountsForMovesUpTo
);
gestureState.moveY = currentCentroidYOfTouchesChangedAfter(
touchHistory,
gestureState._accountsForMovesUpTo
);
var movedAfter = gestureState._accountsForMovesUpTo;
var prevX = previousCentroidXOfTouchesChangedAfter(touchHistory, movedAfter);
var x = currentCentroidXOfTouchesChangedAfter(touchHistory, movedAfter);
var prevY = previousCentroidYOfTouchesChangedAfter(touchHistory, movedAfter);
var y = currentCentroidYOfTouchesChangedAfter(touchHistory, movedAfter);
var nextDX = gestureState.dx + (x - prevX);
var nextDY = gestureState.dy + (y - prevY);
gestureState.moveX = currentCentroidXOfTouchesChangedAfter(touchHistory, gestureState._accountsForMovesUpTo);
gestureState.moveY = currentCentroidYOfTouchesChangedAfter(touchHistory, gestureState._accountsForMovesUpTo);
const movedAfter = gestureState._accountsForMovesUpTo;
const prevX = previousCentroidXOfTouchesChangedAfter(touchHistory, movedAfter);
const x = currentCentroidXOfTouchesChangedAfter(touchHistory, movedAfter);
const prevY = previousCentroidYOfTouchesChangedAfter(touchHistory, movedAfter);
const y = currentCentroidYOfTouchesChangedAfter(touchHistory, movedAfter);
const nextDX = gestureState.dx + (x - prevX);
const nextDY = gestureState.dy + (y - prevY);
// TODO: This must be filtered intelligently.
var dt =
(touchHistory.mostRecentTimeStamp - gestureState._accountsForMovesUpTo);
const dt = touchHistory.mostRecentTimeStamp - gestureState._accountsForMovesUpTo;
gestureState.vx = (nextDX - gestureState.dx) / dt;
gestureState.vy = (nextDY - gestureState.dy) / dt;
@@ -276,22 +276,27 @@ var PanResponder = {
* accordingly. (numberActiveTouches) may not be totally accurate unless you
* are the responder.
*/
create: function(config) {
var gestureState = {
create: function (config) {
const interactionState = {
handle: (null: ?number),
};
const gestureState = {
// Useful for debugging
stateID: Math.random(),
};
PanResponder._initializeGestureState(gestureState);
var panHandlers = {
onStartShouldSetResponder: function(e) {
return config.onStartShouldSetPanResponder === undefined ? false :
const panHandlers = {
onStartShouldSetResponder: function (e) {
return config.onStartShouldSetPanResponder === undefined ?
false :
config.onStartShouldSetPanResponder(e, gestureState);
},
onMoveShouldSetResponder: function(e) {
return config.onMoveShouldSetPanResponder === undefined ? false :
onMoveShouldSetResponder: function (e) {
return config.onMoveShouldSetPanResponder === undefined ?
false :
config.onMoveShouldSetPanResponder(e, gestureState);
},
onStartShouldSetResponderCapture: function(e) {
onStartShouldSetResponderCapture: function (e) {
// TODO: Actually, we should reinitialize the state any time
// touches.length increases from 0 active to > 0 active.
if (e.nativeEvent.touches.length === 1) {
@@ -299,11 +304,12 @@ var PanResponder = {
}
gestureState.numberActiveTouches = e.touchHistory.numberActiveTouches;
return config.onStartShouldSetPanResponderCapture !== undefined ?
config.onStartShouldSetPanResponderCapture(e, gestureState) : false;
config.onStartShouldSetPanResponderCapture(e, gestureState) :
false;
},
onMoveShouldSetResponderCapture: function(e) {
var touchHistory = e.touchHistory;
onMoveShouldSetResponderCapture: function (e) {
const touchHistory = e.touchHistory;
// Responder system incorrectly dispatches should* to current responder
// Filter out any touch moves past the first one - we would have
// already processed multi-touch geometry during the first event.
@@ -312,37 +318,46 @@ var PanResponder = {
}
PanResponder._updateGestureStateOnMove(gestureState, touchHistory);
return config.onMoveShouldSetPanResponderCapture ?
config.onMoveShouldSetPanResponderCapture(e, gestureState) : false;
config.onMoveShouldSetPanResponderCapture(e, gestureState) :
false;
},
onResponderGrant: function(e) {
onResponderGrant: function (e) {
if (!interactionState.handle) {
interactionState.handle = InteractionManager.createInteractionHandle();
}
gestureState.x0 = currentCentroidX(e.touchHistory);
gestureState.y0 = currentCentroidY(e.touchHistory);
gestureState.dx = 0;
gestureState.dy = 0;
config.onPanResponderGrant && config.onPanResponderGrant(e, gestureState);
if (config.onPanResponderGrant) {
config.onPanResponderGrant(e, gestureState);
}
// TODO: t7467124 investigate if this can be removed
return config.onShouldBlockNativeResponder === undefined ? true :
return config.onShouldBlockNativeResponder === undefined ?
true :
config.onShouldBlockNativeResponder();
},
onResponderReject: function(e) {
config.onPanResponderReject && config.onPanResponderReject(e, gestureState);
onResponderReject: function (e) {
clearInteractionHandle(interactionState, config.onPanResponderReject, e, gestureState);
},
onResponderRelease: function(e) {
config.onPanResponderRelease && config.onPanResponderRelease(e, gestureState);
onResponderRelease: function (e) {
clearInteractionHandle(interactionState, config.onPanResponderRelease, e, gestureState);
PanResponder._initializeGestureState(gestureState);
},
onResponderStart: function(e) {
var touchHistory = e.touchHistory;
onResponderStart: function (e) {
const touchHistory = e.touchHistory;
gestureState.numberActiveTouches = touchHistory.numberActiveTouches;
config.onPanResponderStart && config.onPanResponderStart(e, gestureState);
if (config.onPanResponderStart) {
config.onPanResponderStart(e, gestureState);
}
},
onResponderMove: function(e) {
var touchHistory = e.touchHistory;
onResponderMove: function (e) {
const touchHistory = e.touchHistory;
// Guard against the dispatch of two touch moves when there are two
// simultaneously changed touches.
if (gestureState._accountsForMovesUpTo === touchHistory.mostRecentTimeStamp) {
@@ -351,28 +366,45 @@ var PanResponder = {
// Filter out any touch moves past the first one - we would have
// already processed multi-touch geometry during the first event.
PanResponder._updateGestureStateOnMove(gestureState, touchHistory);
config.onPanResponderMove && config.onPanResponderMove(e, gestureState);
if (config.onPanResponderMove) {
config.onPanResponderMove(e, gestureState);
}
},
onResponderEnd: function(e) {
var touchHistory = e.touchHistory;
onResponderEnd: function (e) {
const touchHistory = e.touchHistory;
gestureState.numberActiveTouches = touchHistory.numberActiveTouches;
config.onPanResponderEnd && config.onPanResponderEnd(e, gestureState);
clearInteractionHandle(interactionState, config.onPanResponderEnd, e, gestureState);
},
onResponderTerminate: function(e) {
config.onPanResponderTerminate &&
config.onPanResponderTerminate(e, gestureState);
onResponderTerminate: function (e) {
clearInteractionHandle(interactionState, config.onPanResponderTerminate, e, gestureState);
PanResponder._initializeGestureState(gestureState);
},
onResponderTerminationRequest: function(e) {
return config.onPanResponderTerminationRequest === undefined ? true :
onResponderTerminationRequest: function (e) {
return config.onPanResponderTerminationRequest === undefined ?
true :
config.onPanResponderTerminationRequest(e, gestureState);
},
}
};
return {panHandlers: panHandlers};
},
return { panHandlers: panHandlers };
}
};
function clearInteractionHandle(
interactionState: {handle: ?number},
callback: Function,
event: Object,
gestureState: Object
) {
if (interactionState.handle) {
InteractionManager.clearInteractionHandle(interactionState.handle);
interactionState.handle = null;
}
if (callback) {
callback(event, gestureState);
}
}
module.exports = PanResponder;
@@ -5,7 +5,7 @@
'use strict';
jest
.autoMockOff()
.disableAutomock()
.mock('ErrorUtils')
.mock('BatchedBridge');
@@ -22,8 +22,8 @@ describe('InteractionManager', () => {
jest.resetModuleRegistry();
InteractionManager = require('InteractionManager');
interactionStart = jest.genMockFunction();
interactionComplete = jest.genMockFunction();
interactionStart = jest.fn();
interactionComplete = jest.fn();
InteractionManager.addListener(
InteractionManager.Events.interactionStart,
@@ -84,7 +84,7 @@ describe('InteractionManager', () => {
});
it('runs tasks asynchronously when there are interactions', () => {
var task = jest.genMockFunction();
var task = jest.fn();
InteractionManager.runAfterInteractions(task);
expect(task).not.toBeCalled();
@@ -93,7 +93,7 @@ describe('InteractionManager', () => {
});
it('runs tasks when interactions complete', () => {
var task = jest.genMockFunction();
var task = jest.fn();
var handle = InteractionManager.createInteractionHandle();
InteractionManager.runAfterInteractions(task);
@@ -106,8 +106,8 @@ describe('InteractionManager', () => {
});
it('does not run tasks twice', () => {
var task1 = jest.genMockFunction();
var task2 = jest.genMockFunction();
var task1 = jest.fn();
var task2 = jest.fn();
InteractionManager.runAfterInteractions(task1);
jest.runAllTimers();
@@ -118,10 +118,10 @@ describe('InteractionManager', () => {
});
it('runs tasks added while processing previous tasks', () => {
var task1 = jest.genMockFunction().mockImplementation(() => {
var task1 = jest.fn(() => {
InteractionManager.runAfterInteractions(task2);
});
var task2 = jest.genMockFunction();
var task2 = jest.fn();
InteractionManager.runAfterInteractions(task1);
expect(task2).not.toBeCalled();
@@ -138,7 +138,7 @@ describe('promise tasks', () => {
let BatchedBridge;
let sequenceId;
function createSequenceTask(expectedSequenceId) {
return jest.genMockFunction().mockImplementation(() => {
return jest.fn(() => {
expect(++sequenceId).toBe(expectedSequenceId);
});
}
@@ -151,7 +151,7 @@ describe('promise tasks', () => {
it('should run a basic promise task', () => {
const task1 = jest.genMockFunction().mockImplementation(() => {
const task1 = jest.fn(() => {
expect(++sequenceId).toBe(1);
return new Promise(resolve => resolve());
});
@@ -161,14 +161,14 @@ describe('promise tasks', () => {
});
it('should handle nested promises', () => {
const task1 = jest.genMockFunction().mockImplementation(() => {
const task1 = jest.fn(() => {
expect(++sequenceId).toBe(1);
return new Promise(resolve => {
InteractionManager.runAfterInteractions({gen: task2, name: 'gen2'})
.then(resolve);
});
});
const task2 = jest.genMockFunction().mockImplementation(() => {
const task2 = jest.fn(() => {
expect(++sequenceId).toBe(2);
return new Promise(resolve => resolve());
});
@@ -180,7 +180,7 @@ describe('promise tasks', () => {
it('should pause promise tasks during interactions then resume', () => {
const task1 = createSequenceTask(1);
const task2 = jest.genMockFunction().mockImplementation(() => {
const task2 = jest.fn(() => {
expect(++sequenceId).toBe(2);
return new Promise(resolve => {
setTimeout(() => {
@@ -238,7 +238,7 @@ describe('promise tasks', () => {
const bigAsyncTest = () => {
const task1 = createSequenceTask(1);
const task2 = jest.genMockFunction().mockImplementation(() => {
const task2 = jest.fn(() => {
expect(++sequenceId).toBe(2);
return new Promise(resolve => {
InteractionManager.runAfterInteractions(task3);
@@ -249,7 +249,7 @@ describe('promise tasks', () => {
});
});
const task3 = createSequenceTask(3);
const task4 = jest.genMockFunction().mockImplementation(() => {
const task4 = jest.fn(() => {
expect(++sequenceId).toBe(4);
return new Promise(resolve => {
InteractionManager.runAfterInteractions(task5).then(resolve);
@@ -1,9 +1,15 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
'use strict';
jest.dontMock('InteractionMixin');
jest.unmock('InteractionMixin');
describe('InteractionMixin', () => {
var InteractionManager;
@@ -19,9 +25,8 @@ describe('InteractionMixin', () => {
});
it('should start interactions', () => {
var timeout = 123;
component.createInteractionHandle(timeout);
expect(InteractionManager.createInteractionHandle).toBeCalled(timeout);
component.createInteractionHandle();
expect(InteractionManager.createInteractionHandle).toBeCalled();
});
it('should end interactions', () => {
@@ -31,7 +36,7 @@ describe('InteractionMixin', () => {
});
it('should schedule tasks', () => {
var task = jest.genMockFunction();
var task = jest.fn();
component.runAfterInteractions(task);
expect(InteractionManager.runAfterInteractions).toBeCalledWith(task);
});
@@ -4,7 +4,7 @@
'use strict';
jest.dontMock('TaskQueue');
jest.unmock('TaskQueue');
function expectToBeCalledOnce(fn) {
expect(fn.mock.calls.length).toBe(1);
@@ -23,13 +23,13 @@ describe('TaskQueue', () => {
let onMoreTasks;
let sequenceId;
function createSequenceTask(expectedSequenceId) {
return jest.genMockFunction().mockImplementation(() => {
return jest.fn(() => {
expect(++sequenceId).toBe(expectedSequenceId);
});
}
beforeEach(() => {
jest.resetModuleRegistry();
onMoreTasks = jest.genMockFunction();
onMoreTasks = jest.fn();
const TaskQueue = require('TaskQueue');
taskQueue = new TaskQueue({onMoreTasks});
sequenceId = 0;
@@ -45,7 +45,7 @@ describe('TaskQueue', () => {
});
it('should handle blocking promise task', () => {
const task1 = jest.genMockFunction().mockImplementation(() => {
const task1 = jest.fn(() => {
return new Promise(resolve => {
setTimeout(() => {
expect(++sequenceId).toBe(1);
@@ -71,7 +71,7 @@ describe('TaskQueue', () => {
});
it('should handle nested simple tasks', () => {
const task1 = jest.genMockFunction().mockImplementation(() => {
const task1 = jest.fn(() => {
expect(++sequenceId).toBe(1);
taskQueue.enqueue({run: task3, name: 'run3'});
});
@@ -88,7 +88,7 @@ describe('TaskQueue', () => {
});
it('should handle nested promises', () => {
const task1 = jest.genMockFunction().mockImplementation(() => {
const task1 = jest.fn(() => {
return new Promise(resolve => {
setTimeout(() => {
expect(++sequenceId).toBe(1);
@@ -97,7 +97,7 @@ describe('TaskQueue', () => {
}, 1);
});
});
const task2 = jest.genMockFunction().mockImplementation(() => {
const task2 = jest.fn(() => {
return new Promise(resolve => {
setTimeout(() => {
expect(++sequenceId).toBe(2);
@@ -22,14 +22,14 @@
/* eslint strict: 0 */
/* globals GLOBAL: true, window: true */
require('regenerator/runtime');
require('regenerator-runtime/runtime');
if (typeof GLOBAL === 'undefined') {
global.GLOBAL = this;
global.GLOBAL = global;
}
if (typeof window === 'undefined') {
global.window = GLOBAL;
global.window = global;
}
function setUpConsole() {
@@ -53,27 +53,57 @@ function setUpConsole() {
* For more info on that particular case, see:
* https://github.com/facebook/react-native/issues/934
*/
function polyfillGlobal(name, newValue, scope = GLOBAL) {
var descriptor = Object.getOwnPropertyDescriptor(scope, name) || {
// jest for some bad reasons runs the polyfill code multiple times. In jest
// environment, XmlHttpRequest doesn't exist so getOwnPropertyDescriptor
// returns undefined and defineProperty default for writable is false.
// Therefore, the second time it runs, defineProperty will fatal :(
writable: true,
};
if (scope[name] !== undefined) {
var backupName = `original${name[0].toUpperCase()}${name.substr(1)}`;
function polyfillGlobal(name, newValue, scope = global) {
const descriptor = Object.getOwnPropertyDescriptor(scope, name);
if (descriptor) {
const backupName = `original${name[0].toUpperCase()}${name.substr(1)}`;
Object.defineProperty(scope, backupName, {...descriptor, value: scope[name]});
}
Object.defineProperty(scope, name, {...descriptor, value: newValue});
const {enumerable, writable} = descriptor || {};
// jest for some bad reasons runs the polyfill code multiple times. In jest
// environment, XmlHttpRequest doesn't exist so getOwnPropertyDescriptor
// returns undefined and defineProperty default for writable is false.
// Therefore, the second time it runs, defineProperty will fatal :(
Object.defineProperty(scope, name, {
configurable: true,
enumerable: enumerable !== false,
writable: writable !== false,
value: newValue,
});
}
function polyfillLazyGlobal(name, valueFn, scope = global) {
const descriptor = getPropertyDescriptor(scope, name);
if (descriptor) {
const backupName = `original${name[0].toUpperCase()}${name.substr(1)}`;
Object.defineProperty(scope, backupName, descriptor);
}
const {enumerable, writable} = descriptor || {};
Object.defineProperty(scope, name, {
configurable: true,
enumerable: enumerable !== false,
get() {
return (this[name] = valueFn());
},
set(value) {
Object.defineProperty(this, name, {
configurable: true,
enumerable: enumerable !== false,
writable: writable !== false,
value,
});
}
});
}
/**
* Polyfill a module if it is not already defined in `scope`.
*/
function polyfillIfNeeded(name, polyfill, scope = GLOBAL, descriptor = {}) {
function polyfillIfNeeded(name, polyfill, scope = global, descriptor = {}) {
if (scope[name] === undefined) {
Object.defineProperty(scope, name, {...descriptor, value: polyfill});
}
@@ -104,23 +134,22 @@ function setUpErrorHandler() {
* unexplainably dropped timing signals.
*/
function setUpTimers() {
var JSTimers = require('JSTimers');
GLOBAL.setTimeout = JSTimers.setTimeout;
GLOBAL.setInterval = JSTimers.setInterval;
GLOBAL.setImmediate = JSTimers.setImmediate;
GLOBAL.clearTimeout = JSTimers.clearTimeout;
GLOBAL.clearInterval = JSTimers.clearInterval;
GLOBAL.clearImmediate = JSTimers.clearImmediate;
GLOBAL.cancelAnimationFrame = JSTimers.clearInterval;
GLOBAL.requestAnimationFrame = function(cb) {
/*requestAnimationFrame() { [native code] };*/ // Trick scroller library
return JSTimers.requestAnimationFrame(cb); // into thinking it's native
const defineLazyTimer = (name) => {
polyfillLazyGlobal(name, () => require('JSTimers')[name]);
};
defineLazyTimer('setTimeout');
defineLazyTimer('setInterval');
defineLazyTimer('setImmediate');
defineLazyTimer('clearTimeout');
defineLazyTimer('clearInterval');
defineLazyTimer('clearImmediate');
defineLazyTimer('requestAnimationFrame');
defineLazyTimer('cancelAnimationFrame');
}
function setUpAlert() {
if (!GLOBAL.alert) {
GLOBAL.alert = function(text) {
if (!global.alert) {
global.alert = function(text) {
// Require Alert on demand. Requiring it too early can lead to issues
// with things like Platform not being fully initialized.
require('Alert').alert('Alert', '' + text);
@@ -131,42 +160,43 @@ function setUpAlert() {
function setUpPromise() {
// The native Promise implementation throws the following error:
// ERROR: Event loop not supported.
GLOBAL.Promise = require('Promise');
polyfillLazyGlobal('Promise', () => require('Promise'));
}
function setUpXHR() {
// The native XMLHttpRequest in Chrome dev tools is CORS aware and won't
// let you fetch anything from the internet
polyfillGlobal('XMLHttpRequest', require('XMLHttpRequest'));
polyfillGlobal('FormData', require('FormData'));
polyfillLazyGlobal('XMLHttpRequest', () => require('XMLHttpRequest'));
polyfillLazyGlobal('FormData', () => require('FormData'));
var fetchPolyfill = require('fetch');
polyfillGlobal('fetch', fetchPolyfill.fetch);
polyfillGlobal('Headers', fetchPolyfill.Headers);
polyfillGlobal('Request', fetchPolyfill.Request);
polyfillGlobal('Response', fetchPolyfill.Response);
polyfillLazyGlobal('fetch', () => require('fetch').fetch);
polyfillLazyGlobal('Headers', () => require('fetch').Headers);
polyfillLazyGlobal('Request', () => require('fetch').Request);
polyfillLazyGlobal('Response', () => require('fetch').Response);
}
function setUpGeolocation() {
polyfillIfNeeded('navigator', {}, GLOBAL, {
polyfillIfNeeded('navigator', {}, global, {
writable: true,
enumerable: true,
configurable: true,
});
polyfillGlobal('geolocation', require('Geolocation'), GLOBAL.navigator);
polyfillLazyGlobal('geolocation', () => require('Geolocation'), global.navigator);
}
function setUpMapAndSet() {
// We can't make these lazy as Map checks the global.Map to see if it's
// available but in our case it'll be a lazy getter.
polyfillGlobal('Map', require('Map'));
polyfillGlobal('Set', require('Set'));
}
function setUpProduct() {
Object.defineProperty(GLOBAL.navigator, 'product', {value: 'ReactNative'});
Object.defineProperty(global.navigator, 'product', {value: 'ReactNative'});
}
function setUpWebSockets() {
polyfillGlobal('WebSocket', require('WebSocket'));
polyfillLazyGlobal('WebSocket', () => require('WebSocket'));
}
function setUpProfile() {
@@ -176,20 +206,14 @@ function setUpProfile() {
}
}
function setUpProcessEnv() {
GLOBAL.process = GLOBAL.process || {};
GLOBAL.process.env = GLOBAL.process.env || {};
if (!GLOBAL.process.env.NODE_ENV) {
GLOBAL.process.env.NODE_ENV = __DEV__ ? 'development' : 'production';
function setUpProcess() {
global.process = global.process || {};
global.process.env = global.process.env || {};
if (!global.process.env.NODE_ENV) {
global.process.env.NODE_ENV = __DEV__ ? 'development' : 'production';
}
}
function setUpNumber() {
polyfillIfNeeded('EPSILON', Math.pow(2, -52), Number);
polyfillIfNeeded('MAX_SAFE_INTEGER', Math.pow(2, 53) - 1, Number);
polyfillIfNeeded('MIN_SAFE_INTEGER', -(Math.pow(2, 53) - 1), Number);
}
function setUpDevTools() {
// not when debugging in chrome
if (__DEV__) { // TODO(9123099) Strip `__DEV__ &&`
@@ -200,7 +224,17 @@ function setUpDevTools() {
}
}
setUpProcessEnv();
function getPropertyDescriptor(object, name) {
while (object) {
const descriptor = Object.getOwnPropertyDescriptor(object, name);
if (descriptor) {
return descriptor;
}
object = Object.getPrototypeOf(object);
}
}
setUpProcess();
setUpConsole();
setUpTimers();
setUpAlert();
@@ -212,7 +246,6 @@ setUpMapAndSet();
setUpProduct();
setUpWebSockets();
setUpProfile();
setUpNumber();
setUpDevTools();
// Just to make sure the JS gets packaged up. Wait until the JS environment has
@@ -9,7 +9,7 @@
'use strict';
jest.autoMockOff();
jest.disableAutomock();
var parseErrorStack = require('parseErrorStack');
@@ -86,6 +86,10 @@ function create(duration: number, type, creationProp): Config {
update: {
type,
},
delete: {
type,
property: creationProp,
},
};
}
@@ -106,6 +110,10 @@ var Presets = {
type: Types.spring,
springDamping: 0.4,
},
delete: {
type: Types.linear,
property: Properties.opacity,
},
},
};
+3 -1
View File
@@ -49,7 +49,9 @@ const DEVICE_NOTIF_EVENT = 'openURL';
* NOTE: For instructions on how to add support for deep linking on Android,
* refer [Enabling Deep Links for App Content - Add Intent Filters for Your Deep Links](http://developer.android.com/training/app-indexing/deep-linking.html#adding-filters).
*
* NOTE: For iOS, in case you also want to listen to incoming app links during your app's
* NOTE: On iOS you'll need to link `RCTLinking` to your project by following
* the steps described [here](docs/linking-libraries-ios.html#manual-linking).
* In case you also want to listen to incoming app links during your app's
* execution you'll need to add the following lines to you `*AppDelegate.m`:
*
* ```
+7
View File
@@ -21,6 +21,13 @@ NSString *const RCTOpenURLNotification = @"RCTOpenURLNotification";
RCT_EXPORT_MODULE()
- (instancetype)init
{
// We're only overriding this to ensure the module gets created at startup
// TODO (t11106126): Remove once we have more declarative control over module setup.
return [super init];
}
- (void)setBridge:(RCTBridge *)bridge
{
_bridge = bridge;
+46 -25
View File
@@ -11,14 +11,15 @@
*/
'use strict';
var Platform = require('Platform');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var StyleSheet = require('StyleSheet');
var View = require('View');
const Platform = require('Platform');
const PropTypes = require('ReactPropTypes');
const React = require('React');
const StyleSheet = require('StyleSheet');
const View = require('View');
const deprecatedPropType = require('deprecatedPropType');
var requireNativeComponent = require('requireNativeComponent');
var RCTModalHostView = requireNativeComponent('RCTModalHostView', null);
const requireNativeComponent = require('requireNativeComponent');
const RCTModalHostView = requireNativeComponent('RCTModalHostView', null);
/**
* A Modal component covers the native view (e.g. UIViewController, Activity)
@@ -34,43 +35,63 @@ var RCTModalHostView = requireNativeComponent('RCTModalHostView', null);
* configureScene property.
*/
class Modal extends React.Component {
static propTypes = {
animated: deprecatedPropType(
PropTypes.bool,
'Use the `animationType` prop instead.'
),
animationType: PropTypes.oneOf(['none', 'slide', 'fade']),
transparent: PropTypes.bool,
visible: PropTypes.bool,
onRequestClose: Platform.OS === 'android' ? PropTypes.func.isRequired : PropTypes.func,
onShow: PropTypes.func,
};
static defaultProps = {
visible: true,
};
render(): ?ReactElement {
if (this.props.visible === false) {
return null;
}
if (this.props.transparent) {
var containerBackgroundColor = {backgroundColor: 'transparent'};
const containerBackgroundColor = {
backgroundColor: this.props.transparent ? 'transparent' : 'white',
};
let animationType = this.props.animationType;
if (!animationType) {
// manually setting default prop here to keep support for the deprecated 'animated' prop
animationType = 'none';
if (this.props.animated) {
animationType = 'slide';
}
}
return (
<RCTModalHostView
animated={this.props.animated}
animationType={animationType}
transparent={this.props.transparent}
onRequestClose={this.props.onRequestClose}
onShow={this.props.onShow}
style={styles.modal}>
style={styles.modal}
onStartShouldSetResponder={this._shouldSetResponder}
>
<View style={[styles.container, containerBackgroundColor]}>
{this.props.children}
</View>
</RCTModalHostView>
);
}
// We don't want any responder events bubbling out of the modal.
_shouldSetResponder(): boolean {
return true;
}
}
Modal.propTypes = {
animated: PropTypes.bool,
transparent: PropTypes.bool,
visible: PropTypes.bool,
onRequestClose: Platform.OS === 'android' ? PropTypes.func.isRequired : PropTypes.func,
onShow: PropTypes.func,
};
Modal.defaultProps = {
visible: true,
};
var styles = StyleSheet.create({
const styles = StyleSheet.create({
modal: {
position: 'absolute',
},
@@ -81,4 +102,4 @@ var styles = StyleSheet.create({
}
});
module.exports = Modal;
module.exports = Modal;
@@ -39,6 +39,7 @@ type Props = {
};
type State = {
layout: NavigationLayout,
position: NavigationAnimatedValue,
scenes: Array<NavigationScene>,
};
@@ -61,7 +62,6 @@ function applyDefaultAnimation(
class NavigationAnimatedView
extends React.Component<any, Props, State> {
_layout: NavigationLayout;
_onLayout: (event: any) => void;
_onProgressChange: (data: {value: number}) => void;
_positionListener: any;
@@ -84,14 +84,18 @@ class NavigationAnimatedView
constructor(props: Props, context: any) {
super(props, context);
this._layout = {
initWidth: 0,
initHeight: 0,
width: new Animated.Value(0),
// The initial layout isn't measured. Measured layout will be only available
// when the component is mounted.
const layout = {
height: new Animated.Value(0),
initHeight: 0,
initWidth: 0,
isMeasured: false,
width: new Animated.Value(0),
};
this.state = {
layout,
position: new Animated.Value(this.props.navigationState.index),
scenes: NavigationScenesReducer([], this.props.navigationState),
};
@@ -180,7 +184,7 @@ class NavigationAnimatedView
} = this.state;
return renderScene({
layout: this._layout,
layout: this.state.layout,
navigationState,
onNavigate,
position,
@@ -203,7 +207,7 @@ class NavigationAnimatedView
} = this.state;
return renderOverlay({
layout: this._layout,
layout: this.state.layout,
navigationState,
onNavigate,
position,
@@ -218,15 +222,16 @@ class NavigationAnimatedView
const {height, width} = event.nativeEvent.layout;
const layout = {
...this._layout,
...this.state.layout,
initHeight: height,
initWidth: width,
isMeasured: true,
};
this._layout = layout;
layout.height.setValue(height);
layout.width.setValue(width);
this.setState({ layout });
}
}
@@ -16,7 +16,7 @@ var NavigationRootContainer = require('NavigationRootContainer');
function createNavigationContainer(
Component: ReactClass<any>,
): ReactClass {
): ReactClass & Object {
class NavigationComponent extends React.Component {
render() {
return (

Some files were not shown because too many files have changed in this diff Show More