Summary:
We have changed the release schedule but haven't updated docs yet. This is a small PR that aims to fix it where applicable.
Likely to be cherry-picked to 0.40 branch since its the new one following that system.
Differential Revision: D4266155
Pulled By: mkonicek
fbshipit-source-id: 952af7a0f35a3d984aeadb6efe02f0990830ed8b
Summary:
Let's continue to bring Flow goodness to the codebase, as it will facilitate future refactorings.
I fixed a few of the typing issues by changing the local logic at times, but in a way that should not cause any difference globally.
Reviewed By: cpojer
Differential Revision: D4265347
fbshipit-source-id: a2a7afd7d93cf00ba58e8c9879a9bb6d5bf30358
Summary:
**Motivation**
When running `react-native-git-upgrade` with an unknown version, the error message isn't very helpful
**Test Plan**
- Publish the `master` branch to Sinopia
- Run `react-native-git-upgrade 0.666.0` inside a RN project
- Error message is `SyntaxError: Unexpected end of JSON input`
- Publish this branch to Sinopia
- Run `react-native-git-upgrade 0.666.0` inside a RN project
- Error message should be `Error: The specified version of React Native 0.666.0 doesn't exist.
Re-run the react-native-git-upgrade command with an existing version,
for example: "react-native-git-upgrade 0.38.0",
or without arguments to upgrade to the latest: "react-native-git-upgrade".`
Closes https://github.com/facebook/react-native/pull/11264
Differential Revision: D4265553
Pulled By: mkonicek
fbshipit-source-id: 8597eb09cc3397bfa6d2205a9b3bb30acfad530f
Summary:
6554ad5983 broke assets on windows, this fixes it and add a test to avoid regressions.
Ideally we'd run all the Dependency graph tests on both posix and win32 filesystems but that would probably require doing some sort of factory function to create the tests because I don't think we want to duplicate every test (file is big enough already :)). So for now I just copied that one test and changed the paths manually.
**Test plan**
Run the new test without the fix -> fails
Run the new test with the fix -> succeeds
Closes https://github.com/facebook/react-native/pull/11254
Differential Revision: D4265157
Pulled By: cpojer
fbshipit-source-id: 511470276bd950c2943e94c2dce6840df0fe6d69
Summary:
**Motivation**
If the project is using yarn to manage its dependencies, we should be running 'yarn add' to upgrade the React Native dependency, rather than 'npm install'.
**Test plan (required)**
Running in a project that's in a bad state:
Error: react-native version in "package.json" (0.29.2) doesn't match the installed version in "node_modules" (0.38.0).
Try running "yarn" to fix this.
Removed yarn.lock file, ran again:
Error: react-native version in "package.json" (0.29.2) doesn't match the installed version in "node_modules" (0.38.0).
Try running "npm install" to fix this.
Running inside a folder that doesn't contain a `package.json` file:
Error: Unable to find "/Users/mkonicek/Zero29App/package.json" or "/Users/mkonicek/Zero29App/node_modules/react-native/package.json". Make sure you ran "yarn" and that you are inside a React Native project.
Removed yarn.lock file, ran again:
Error: Unable to find "/Users/mkonicek/Zero29App/package.json" or "/Users/
Closes https://github.com/facebook/react-native/pull/11225
Differential Revision: D4261102
Pulled By: mkonicek
fbshipit-source-id: b44ae91fe46f2c81b14616ca2868cc171692c895
Summary:
Fixes#10433
The code didn't account for the fact that cancelLoad is set by two different threads. It gets set on the URL request queue when the request completes successfully and it gets set on the UI queue during cancelation. This oversight lead to a couple of different kinds of crashes.
1. Attempt to invoke a nil function -- We check that cancelLoad is non-nil and on the next line we call it. However, cancelLoad could have been set to nil by the other thread between the time it was verified to be non-nil and the time it was called. Consequently, the program will attempt to call nil and crash.
2. Block deallocated while it's executing -- Suppose cancelLoad points to a block, it is verified to be non-nil, and it is successfully invoked. In the middle of executing the block, cancelLoad, the last reference to the block, is set to nil. This causes the block to be deallocated and its captured values to be freed. However, the block continues executing and the next time it attempts to use a captured value
Closes https://github.com/facebook/react-native/pull/11145
Differential Revision: D4261499
Pulled By: javache
fbshipit-source-id: 46424c6dd8cfa085cef32d945308de07798040bc
Summary:
**Motivation**
This morning I was trying to test on iPhone 7 with iOS 10 so I booted that device and ran "react-native run-ios" expecting it to notice I had a simulator running and install my app to it. Instead it switched my device to the iPhone 6s iOS 9.2. After digging it was found that run-ios did not handle multiple versions of iOS being installed very well when it came to checking for the booted device. This PR resolves that.
**Test plan (required)**
Tests were added for the situation of multiple iOS versions being installed and a slight change to the code was completed to make the new tests pass and continue to keep the old tests passing.
Closes https://github.com/facebook/react-native/pull/10558
Differential Revision: D4163616
Pulled By: hramos
fbshipit-source-id: 26b44fb73ef402ce252e7a754036279e15359170
Summary:
**Motivation**
As NoelBroda pointed out in https://github.com/facebook/react-native/pull/11104 and https://github.com/facebook/react-native/pull/11123, NPM often produces an unmet peerDependency when upgrading React Native. It causes a failure when running "npm install" with NPM2.
During the git-upgrade, we have to take care of the `react` peerDep: this PR checks if the installed `react` package matches the `react` peerDep of the new `react-native` version. If so, R & RN are upgraded at the same time (in the same `npm install`).
**Test plan**
- Publish `react-native-git-upgrade` to Sinopia,
- Run `react-native-git-upgrade` inside a RN project with version < 0.37,
- Verify that no "unmet peer dependency" warning is displayed
- Open the `package.json` and verify that both R & RN have been updated
Closes https://github.com/facebook/react-native/pull/11226
Differential Revision: D4258007
Pulled By: mkonicek
fbshipit-source-id: cff466d4710807d97fc6161f47bb974097b75261
Summary:
*First PR to React Native.*
After performing a clean install of macOS Sierra on my machine I tried to get RN set up again and noticed that the link provided for installing Java (required by Android Studio) pointed to the [wrong location](https://www.java.com/en/download/mac_download.jsp). After some time researching I found the right package required by Android Studio [here](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html).
I tried looking for a more general link (as this points to the JDK version 8 and has a weird path: _jdk8-downloads-2133151.html_ - Sadly this was the best I could find.
I also looked through listed issues to try and find a previous attempt to fix this error but couldn't find any references, sorry if I missed anything.
**TL;DR:** JDK download link is incorrect, PR updates it to the correct one.
Closes https://github.com/facebook/react-native/pull/11201
Differential Revision: D4253304
Pulled By: hramos
fbshipit-source-id: be8ffe059bf60f5d7aa1876e5581b270187864c2
Summary:
I was running RN 0.31 on ArchLinux (kernel 4.7), and "react-native start"
was refusing to run on the default (and sometimes required, as I have
noticed) port. I tried executing the suggested lsof command, but that did not
work. Somewhere I found the lsof command I include in this commit, and that
worked (it was a node.js process). So I'm including it, since I found it
helpful.
Closes https://github.com/facebook/react-native/pull/9402
Reviewed By: lacker
Differential Revision: D4144400
Pulled By: hramos
fbshipit-source-id: 6203549455555efc59b7bab0a3ec23957d80b956
Summary:
This PR fixes#11096.
I don't know enough the ReactAndroid's source code so I don't know if this is correct but I hope it is.
In a recent commit (d4b8ae7a8a), the `dispatchUpdates` method now returns a boolean to dispatch or not the `onLayout` event. This works well but if the content is unchanged, the line `nativeViewHierarchyOptimizer.handleUpdateLayout(this);` is never called. I don't know if it was intended but it was this which introduces my issue. I called this again even if the content didn't change. This was the behaviour before 0.38 so I guess I didn't break anything.
**Test plan (required)**
I tested my pretty big app with this fix and every screen is ok.
Closes https://github.com/facebook/react-native/pull/11222
Differential Revision: D4252101
Pulled By: astreet
fbshipit-source-id: 551559234631ac37245a854d81ba568f0ddb02dd
Summary: Removes the `shouldThrowOnUnresolvedErrors` option, as now it is only ever `() => true`
Reviewed By: davidaurelio
Differential Revision: D4237711
fbshipit-source-id: 9460f0f0c50dc0d08d17cb7bdeb995825f7051f3
Summary:
Just some small changes that made the core easier for me to understand as I went through it.
**Test plan (required)**
$ cd react-native
# "Install globally" without using Sinopia :)
$ cp -r react-native-git-upgrade /usr/local/lib/node_modules/
$ cd ~
$ react-native init Zero29App --version=0.29.2
$ cd Zero29App
Made a small change in `MainApplication.java` to introduce a conflict with the new template.
$ git init && git add . && git commit -m "Initial commit"
$ react-native-git-upgrade
Worked, printed the conflicting file. Output: http://pastie.org/10972793
$ git reset --hard
$ react-native-git-upgrade --verbose
Worked, printed the conflicting file. Output: http://pastie.org/10972796
In both cases (with and without --verbose) the output of `git st` was http://pastie.org/10972795
Closes https://github.com/facebook/react-native/pull/11197
Differential Revision: D4251008
Pulled By: mkonicek
fbshipit-source-id: c5bbbeaf996cb5cb46cccc12fd1da7634cc23520
Summary:
This kills fastfs in favor of Jest's hasteFS. It gets rid of a ton of code, including the mocking code in ResolutionRequest which we don't need any more. Next step after this is to rewrite HasteMap, ModuleCache, Module/Package. We are getting closer to a nicer and faster world! :)
Here is what I did:
* Use Jest's HasteFS instead of fastfs. A fresh instance is received every time something changes on the FS.
* HasteFS is not shared with everything any more. Only one reference is kept in DependencyGraph and there are a few smaller functions that are passed around (getClosestPackage and dirExists). Note: `dirExists` now does fs access instead of an offline check. This sucks but stat calls aren't slow and aren't going to be a bottleneck in ResolutionRequest, I promise! When it is time to tackle a ResolutionRequest rewrite with jest-resolve, this will go away. "It gets worse before it gets better" :) The ModuleGraph equivalent does *not* do fs access and retains the previous way of doing things because we shouldn't do online fs access there.
* Add flow annotations to ResolutionRequest. This required a few tiny hacks for now because of ModuleGraph's duck typing. I'll get rid of this soon.
* Updated ModuleGraph to work with the new code, also created a mock HasteFS instance there.
* I fixed a few tiny mock issues for `fs` to make the tests work; I had to add one tiny little internal update to `dgraph._hasteFS._files` because the file watching in the tests isn't real. It is instrumented through some function calls, therefore the hasteFS instance doesn't get automatically updated. One way to solve this is to add `JestHasteMap.emit('change', …)` for testing but I didn't want to cut a Jest release just for that. #movefast
(Note: I will likely land this in 1.5 weeks from now after my vacation and I have yet to fully test all the product flows. Please give me feedback so I can make sure this is solid!)
Reviewed By: davidaurelio
Differential Revision: D4204082
fbshipit-source-id: d6dc9fcb77ac224df4554a59f0fce241c01b0512
Summary:
This change suppresses access checking during reflection which makes reflection faster by decreasing its overhead.
**Test plan (required)**
My team uses this change in our app.
Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/11204
Differential Revision: D4250790
Pulled By: astreet
fbshipit-source-id: 0ee2f40dcadccc695980fcae14fafe1050acb52f
Summary:
Suppose that the user is scrolled to the bottom of a ScrollView. Next, the ScrollView's content is edited such that the height of the content changes and the current scroll position is larger than the new height of the content. Consequently, the user sees a blank ScrollView. As soon as the user interacts with the ScrollView, the ScrollView will jump to its max scroll position.
This change improves this scenario by ensuring that the user is never staring at a blank ScrollView when the ScrollView has content in it. It does this by moving the ScrollView to its max scroll position when the scroll position after an edit is larger than the max scroll position of the ScrollView.
Here are some pictures to illustrate how this PR improves the scenario described above:
![image](https://cloud.githubusercontent.com/assets/199935/20408839/0e731774-accc-11e6-9f0a-3d77198645e9.png)
![image](https://cloud.githubusercontent.com/assets/199935/20408844/12877bb6-accc-11e6-8fe2-1c1bb26569cc.png)
**Test plan (require
Closes https://github.com/facebook/react-native/pull/11000
Differential Revision: D4250792
Pulled By: astreet
fbshipit-source-id: 940fff6282ad29c796726f68b4519cbdabbfe554
Summary: Adds utilities needed for bundle creation: `completeModuleWrapper` appends numeric IDs for the module itself and its dependencies to a module wrapped. `createGetModuleId` returns a function that returns sequential numeric IDs for strings, and is idempotent.
Reviewed By: cpojer
Differential Revision: D4240334
fbshipit-source-id: c165482ebcf0e81ebb83ba6ff634de095ffb6bf0
Summary: When building, we will process modules in a special way, *not* polyfillys. We will also add more types of (virtual) files that are not modules. That’s why a “type” property makes more sense.
Reviewed By: cpojer
Differential Revision: D4244583
fbshipit-source-id: 92a0b4a0a2026d0b97ba88034483a6ce4e0c1ebb
Summary:
The logic in `ModuleGraph/Graph` allowed the callback to be invoked twice, if two invocations of `resolve` call back with errors asynchronously.
This fixes that problem by always calling `queue.kill()` on the asynchronous queue, and only invoke the main callback from the `drain` and `error` queue callbacks.
Reviewed By: jeanlauliac
Differential Revision: D4236797
fbshipit-source-id: c30da7bf7707e13b11270bb2c6117997fd35b029
Summary:
Fix an issue when running Jest unit tests due to a missing mock for StatusBarManger.
**More info:**
In one of my files I have:
```
export const STATUS_BAR_HEIGHT = (StatusBar.currentHeight || 0);
```
When I run the tests it gives this error, which seems to be because StatusBarManager is undefined (https://github.com/facebook/react-native/blob/master/Libraries/Components/StatusBar/StatusBar.js#L20)
```
TypeError: Cannot read property 'HEIGHT' of undefined
at Object.<anonymous> (node_modules/react-native/Libraries/Components/StatusBar/StatusBar.js:395:1823)
at Object.StatusBar (node_modules/react-native/Libraries/react-native/react-native.js:55:24)
```
**Test plan (required)**
Verify that with this change tests that use StatusBar pass.
Closes https://github.com/facebook/react-native/pull/11198
Differential Revision: D4246367
Pulled By: cpojer
fbshipit-source-id: ee9406d2566688d235a11cab8f24b0583698e93a
Summary:
**Motivation**
On Exponent we load fonts dynamically and assign their native names by appending a session id, so that fonts from one Exponent "experience" do not clash with each other. So, before sending the `fontFamily` to native, we want to change it to the Exponent-scoped `fontFamily`.
Example:
```js
// Before rendering your app
StyleSheet.setStyleAttributePreprocessor('fontFamily', _processFontFamily);
function _processFontFamily(name) {
// Pass system fonts through
if (!name || Constants.systemFonts.indexOf(name) >= 0) {
return name;
}
if (!Font.isLoaded(name)) {
if (__DEV__) {
console.error(`${name} is not a system font and has not been loaded through Exponent.Font.loadAsync. If you intended to use a system font, make sure you typed the name correctly and that it is supported by the current operating system. If this is a custom font, be sure to load it with Exponent.Font.loadAsync`);
} else {
return 'system';
}
}
return `ExponentFont-
Closes https://github.com/facebook/react-native/pull/11138
Differential Revision: D4245518
Pulled By: mkonicek
fbshipit-source-id: bd2452b1129d6675aa7b88e41351f8bb61fa20a3
Summary:
**Description**
In the same vein as https://github.com/facebook/react-native/pull/11198, this adds a mock for the native module `AppState`.
**Test plan**
Create a component that uses `AppState`, e.g.
```jsx
import React, { Component } from 'react';
import { AppState } from 'react-native';
class TestComponent extends Component {
componentDidMount() {
AppState.addEventListener('change', this.stateChangeListener);
}
}
```
Closes https://github.com/facebook/react-native/pull/11199
Differential Revision: D4246668
Pulled By: cpojer
fbshipit-source-id: e3a73a98963a0e152a70aba78ef3461b86da0f6c
Summary:
This fixes a cryptic bug to appear when you try to use scrollResponderZoomTo in Android.
before this PR it would break with a `Error: TaskQueue: Error with task : invariant requires an error message argument` because the invariant() was not properly used..
Also, instead of detecting the platform, I think it's better practice to duck type.
Closes https://github.com/facebook/react-native/pull/11186
Differential Revision: D4246674
fbshipit-source-id: 47002a85d8252e5abbd1cd9ecef3d7676fa8615a
Summary:
ReactAndroid/build.gradle downloads a number of ad-hoc dependencies from the internet such as boost, JSC headers, and folly. Having the build depend on the internet is problematic. For example, if the site hosting the JSC headers was to go down, then CI builds would start failing.
This change introduces the environment variable REACT_NATIVE_DEPENDENCIES which refers to a path. Developers can pre-download all of the ad-hoc dependencies into that path and then the build process will grab the dependencies from that local path rather than trying to download them from the internet. This solution is in the spirit of the existing REACT_NATIVE_BOOST_PATH hook.
**Test plan (required)**
This change is used by my team's app.
Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/11195
Differential Revision: D4247080
Pulled By: mkonicek
fbshipit-source-id: 7c4350339c8d509a829e258d8f1bf320ff8eef64