Skip to content

Commit 61cae56

Browse files
author
soliury
committed
update to rn v0.18.1
1 parent aaee5b0 commit 61cae56

14 files changed

Lines changed: 186 additions & 114 deletions

File tree

.flowconfig

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,38 @@
77
# Some modules have their own node_modules with overlap
88
.*/node_modules/node-haste/.*
99

10-
# Ignore react-tools where there are overlaps, but don't ignore anything that
11-
# react-native relies on
12-
.*/node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js
13-
.*/node_modules/react-tools/src/browser/eventPlugins/ResponderEventPlugin.js
14-
.*/node_modules/react-tools/src/browser/ui/React.js
15-
.*/node_modules/react-tools/src/core/ReactInstanceHandles.js
16-
.*/node_modules/react-tools/src/event/EventPropagators.js
10+
# Ugh
11+
.*/node_modules/babel.*
12+
.*/node_modules/babylon.*
13+
.*/node_modules/invariant.*
14+
15+
# Ignore react and fbjs where there are overlaps, but don't ignore
16+
# anything that react-native relies on
17+
.*/node_modules/fbjs/lib/Map.js
18+
.*/node_modules/fbjs/lib/Promise.js
19+
.*/node_modules/fbjs/lib/fetch.js
20+
.*/node_modules/fbjs/lib/ExecutionEnvironment.js
21+
.*/node_modules/fbjs/lib/isEmpty.js
22+
.*/node_modules/fbjs/lib/crc32.js
23+
.*/node_modules/fbjs/lib/ErrorUtils.js
24+
25+
# Flow has a built-in definition for the 'react' module which we prefer to use
26+
# over the currently-untyped source
27+
.*/node_modules/react/react.js
28+
.*/node_modules/react/lib/React.js
29+
.*/node_modules/react/lib/ReactDOM.js
1730

1831
# Ignore commoner tests
19-
.*/node_modules/react-tools/node_modules/commoner/test/.*
32+
.*/node_modules/commoner/test/.*
2033

2134
# See https://github.com/facebook/flow/issues/442
2235
.*/react-tools/node_modules/commoner/lib/reader.js
2336

2437
# Ignore jest
25-
.*/react-native/node_modules/jest-cli/.*
38+
.*/node_modules/jest-cli/.*
39+
40+
# Ignore Website
41+
.*/website/.*
2642

2743
[include]
2844

@@ -31,3 +47,19 @@ node_modules/react-native/Libraries/react-native/react-native-interface.js
3147

3248
[options]
3349
module.system=haste
50+
51+
munge_underscores=true
52+
53+
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
54+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.png$' -> 'RelativeImageStub'
55+
56+
suppress_type=$FlowIssue
57+
suppress_type=$FlowFixMe
58+
suppress_type=$FixMe
59+
60+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-0]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
61+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-0]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
62+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
63+
64+
[version]
65+
0.20.1

.gitignore

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,13 @@ DerivedData
2222
*.xcuserstate
2323
project.xcworkspace
2424

25+
# Android/IJ
26+
#
27+
.idea
28+
.gradle
29+
local.properties
30+
2531
# node.js
2632
#
2733
node_modules/
2834
npm-debug.log
29-
30-
.idea
31-
32-
app/mocks/user.js
33-
34-
react-packager-cache**
35-
.rnplay
36-
tmp
37-
iOS/main.jsbundle
38-
test.js
39-
40-

.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

android/app/build.gradle

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
apply plugin: "com.android.application"
22

3+
import com.android.build.OutputFile
4+
35
/**
46
* The react.gradle file registers two tasks: bundleDebugJsAndAssets and bundleReleaseJsAndAssets.
57
* These basically call `react-native bundle` with the correct arguments during the Android build
@@ -49,6 +51,22 @@ apply plugin: "com.android.application"
4951

5052
apply from: "react.gradle"
5153

54+
/**
55+
* Set this to true to create three separate APKs instead of one:
56+
* - A universal APK that works on all devices
57+
* - An APK that only works on ARM devices
58+
* - An APK that only works on x86 devices
59+
* The advantage is the size of the APK is reduced by about 4MB.
60+
* Upload all the APKs to the Play Store and people will download
61+
* the correct one based on the CPU architecture of their device.
62+
*/
63+
def enableSeparateBuildPerCPUArchitecture = false
64+
65+
/**
66+
* Run Proguard to shrink the Java bytecode in release builds.
67+
*/
68+
def enableProguardInReleaseBuilds = false
69+
5270
android {
5371
compileSdkVersion 23
5472
buildToolsVersion "23.0.1"
@@ -63,16 +81,37 @@ android {
6381
abiFilters "armeabi-v7a", "x86"
6482
}
6583
}
84+
splits {
85+
abi {
86+
enable enableSeparateBuildPerCPUArchitecture
87+
universalApk true
88+
reset()
89+
include "armeabi-v7a", "x86"
90+
}
91+
}
6692
buildTypes {
6793
release {
68-
minifyEnabled false // Set this to true to enable Proguard
94+
minifyEnabled enableProguardInReleaseBuilds
6995
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
7096
}
7197
}
98+
// applicationVariants are e.g. debug, release
99+
applicationVariants.all { variant ->
100+
variant.outputs.each { output ->
101+
// For each separate APK per architecture, set a unique version code as described here:
102+
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
103+
def versionCodes = ["armeabi-v7a":1, "x86":2]
104+
def abi = output.getFilter(OutputFile.ABI)
105+
if (abi != null) { // null for the universal-debug, universal-release variants
106+
output.versionCodeOverride =
107+
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
108+
}
109+
}
110+
}
72111
}
73112

74113
dependencies {
75114
compile fileTree(dir: "libs", include: ["*.jar"])
76115
compile "com.android.support:appcompat-v7:23.0.1"
77-
compile "com.facebook.react:react-native:0.16.+"
116+
compile "com.facebook.react:react-native:0.18.+"
78117
}

android/app/proguard-rules.pro

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@
4040

4141
-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
4242
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
43+
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
4344
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; }
4445
-keepclassmembers class * { @com.facebook.react.uimanager.ReactProp <methods>; }
4546
-keepclassmembers class * { @com.facebook.react.uimanager.ReactPropGroup <methods>; }
4647

48+
-dontwarn com.facebook.react.**
49+
4750
# okhttp
4851

4952
-keepattributes Signature
@@ -58,3 +61,7 @@
5861
-dontwarn java.nio.file.*
5962
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
6063
-dontwarn okio.**
64+
65+
# stetho
66+
67+
-dontwarn com.facebook.stetho.**

android/app/react.gradle

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,33 @@ task bundleReleaseJsAndAssets(type: Exec) {
7474
enabled config.bundleInRelease ?: true
7575
}
7676

77+
void runBefore(String dependentTaskName, Task task) {
78+
Task dependentTask = tasks.findByPath(dependentTaskName);
79+
if (dependentTask != null) {
80+
dependentTask.dependsOn task
81+
}
82+
}
83+
7784
gradle.projectsEvaluated {
85+
7886
// hook bundleDebugJsAndAssets into the android build process
87+
7988
bundleDebugJsAndAssets.dependsOn mergeDebugResources
8089
bundleDebugJsAndAssets.dependsOn mergeDebugAssets
81-
processDebugResources.dependsOn bundleDebugJsAndAssets
90+
91+
runBefore('processArmeabi-v7aDebugResources', bundleDebugJsAndAssets)
92+
runBefore('processX86DebugResources', bundleDebugJsAndAssets)
93+
runBefore('processUniversalDebugResources', bundleDebugJsAndAssets)
94+
runBefore('processDebugResources', bundleDebugJsAndAssets)
8295

8396
// hook bundleReleaseJsAndAssets into the android build process
97+
8498
bundleReleaseJsAndAssets.dependsOn mergeReleaseResources
8599
bundleReleaseJsAndAssets.dependsOn mergeReleaseAssets
86-
processReleaseResources.dependsOn bundleReleaseJsAndAssets
100+
101+
runBefore('processArmeabi-v7aReleaseResources', bundleReleaseJsAndAssets)
102+
runBefore('processX86ReleaseResources', bundleReleaseJsAndAssets)
103+
runBefore('processUniversalReleaseResources', bundleReleaseJsAndAssets)
104+
runBefore('processReleaseResources', bundleReleaseJsAndAssets)
105+
87106
}
Lines changed: 24 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,39 @@
11
package com.noder;
22

3-
import android.app.Activity;
4-
import android.os.Bundle;
5-
import android.view.KeyEvent;
6-
7-
import com.facebook.react.LifecycleState;
8-
import com.facebook.react.ReactInstanceManager;
9-
import com.facebook.react.ReactRootView;
10-
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
3+
import com.facebook.react.ReactActivity;
4+
import com.facebook.react.ReactPackage;
115
import com.facebook.react.shell.MainReactPackage;
12-
import com.facebook.soloader.SoLoader;
13-
14-
public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
15-
16-
private ReactInstanceManager mReactInstanceManager;
17-
private ReactRootView mReactRootView;
18-
19-
@Override
20-
protected void onCreate(Bundle savedInstanceState) {
21-
super.onCreate(savedInstanceState);
22-
mReactRootView = new ReactRootView(this);
23-
24-
mReactInstanceManager = ReactInstanceManager.builder()
25-
.setApplication(getApplication())
26-
.setBundleAssetName("index.android.bundle")
27-
.setJSMainModuleName("index.android")
28-
.addPackage(new MainReactPackage())
29-
.setUseDeveloperSupport(BuildConfig.DEBUG)
30-
.setInitialLifecycleState(LifecycleState.RESUMED)
31-
.build();
326

33-
mReactRootView.startReactApplication(mReactInstanceManager, "noder", null);
7+
import java.util.Arrays;
8+
import java.util.List;
349

35-
setContentView(mReactRootView);
36-
}
10+
public class MainActivity extends ReactActivity {
3711

12+
/**
13+
* Returns the name of the main component registered from JavaScript.
14+
* This is used to schedule rendering of the component.
15+
*/
3816
@Override
39-
public boolean onKeyUp(int keyCode, KeyEvent event) {
40-
if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) {
41-
mReactInstanceManager.showDevOptionsDialog();
42-
return true;
43-
}
44-
return super.onKeyUp(keyCode, event);
17+
protected String getMainComponentName() {
18+
return "noder";
4519
}
4620

21+
/**
22+
* Returns whether dev mode should be enabled.
23+
* This enables e.g. the dev menu.
24+
*/
4725
@Override
48-
public void onBackPressed() {
49-
if (mReactInstanceManager != null) {
50-
mReactInstanceManager.onBackPressed();
51-
} else {
52-
super.onBackPressed();
53-
}
26+
protected boolean getUseDeveloperSupport() {
27+
return BuildConfig.DEBUG;
5428
}
5529

30+
/**
31+
* A list of packages used by the app. If the app uses additional views
32+
* or modules besides the default ones, add more packages here.
33+
*/
5634
@Override
57-
public void invokeDefaultOnBackPressed() {
58-
super.onBackPressed();
59-
}
60-
61-
@Override
62-
protected void onPause() {
63-
super.onPause();
64-
65-
if (mReactInstanceManager != null) {
66-
mReactInstanceManager.onPause();
67-
}
68-
}
69-
70-
@Override
71-
protected void onResume() {
72-
super.onResume();
73-
74-
if (mReactInstanceManager != null) {
75-
mReactInstanceManager.onResume(this, this);
76-
}
35+
protected List<ReactPackage> getPackages() {
36+
return Arrays.<ReactPackage>asList(
37+
new MainReactPackage());
7738
}
7839
}

android/build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,5 @@ allprojects {
1616
repositories {
1717
mavenLocal()
1818
jcenter()
19-
jcenter {
20-
url "http://dl.bintray.com/mkonicek/maven"
21-
}
2219
}
2320
}

gulpFile.coffee

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,30 @@ devIp = require 'dev-ip'
88
child_process = require 'child_process'
99

1010
appDelegateSrc = './ios/noder/AppDelegate.m'
11-
port = 8080
11+
port = 8081
1212

1313

1414
gulp.task 'replace', ->
15-
ip = devIp()[0]
16-
reg = ///
15+
ip = devIp()[0]
16+
reg = ///
1717
jsCodeLocation\s=\s
1818
\[NSURL\sURLWithString:
1919
@"http:.*\n
2020
///g
21-
# ip = 'localhost'
22-
gulp.src appDelegateSrc
23-
.pipe replace reg, "jsCodeLocation = [NSURL URLWithString:@\"http://#{ip}:#{port}/index.ios.bundle\"];\n"
24-
.pipe gulp.dest './ios/noder'
21+
# ip = 'localhost'
22+
gulp.src appDelegateSrc
23+
.pipe replace reg, "jsCodeLocation = [NSURL URLWithString:@\"http://#{ip}:#{port}/index.ios.bundle\"];\n"
24+
.pipe gulp.dest './ios/noder'
2525

2626

2727
gulp.task 'package', (cb)->
28-
cmd = "./node_modules/react-native/packager/packager.sh"
29-
start = child_process.spawn cmd, ['--port', port]
30-
start.stdout.on 'data', (data)->
31-
gutil.log data.toString()
32-
start.stderr.on 'data', (data)->
33-
gutil.log data.toString()
28+
cmd = "react-native"
29+
start = child_process.spawn cmd, ['start', '--port', port]
30+
start.stdout.on 'data', (data)->
31+
gutil.log data.toString()
32+
start.stderr.on 'data', (data)->
33+
gutil.log data.toString()
3434

3535

3636
gulp.task 'start', ->
37-
runSequence 'replace', 'package'
37+
runSequence 'replace', 'package'

0 commit comments

Comments
 (0)