Browse Source

Merge pull request #277 from DanielZlotin/master

Update react-native to 0.31.0
DanielZlotin 8 years ago
parent
commit
b018fe0a8d

+ 8
- 8
android/app/src/main/java/com/reactnativenavigation/NavigationApplication.java View File

@@ -4,19 +4,22 @@ import android.app.Application;
4 4
 import android.os.Handler;
5 5
 import android.support.annotation.Nullable;
6 6
 
7
+import com.facebook.react.ReactApplication;
8
+import com.facebook.react.ReactNativeHost;
7 9
 import com.facebook.react.ReactPackage;
8 10
 import com.facebook.react.bridge.ReactContext;
9 11
 import com.facebook.react.bridge.WritableMap;
10 12
 import com.reactnativenavigation.react.NavigationReactGateway;
11 13
 import com.reactnativenavigation.react.ReactGateway;
14
+import com.reactnativenavigation.react.ReactGatewayHost;
12 15
 
13 16
 import java.util.List;
14 17
 
15
-public abstract class NavigationApplication extends Application {
18
+public abstract class NavigationApplication extends Application implements ReactApplication {
16 19
 
17 20
     public static NavigationApplication instance;
18 21
 
19
-    private ReactGateway reactGateway;
22
+    private ReactGatewayHost reactGateway;
20 23
     private Handler handler;
21 24
 
22 25
     @Override
@@ -51,12 +54,9 @@ public abstract class NavigationApplication extends Application {
51 54
         // nothing
52 55
     }
53 56
 
54
-    public String getJsEntryFileName() {
55
-        return "index.android";
56
-    }
57
-
58
-    public String getBundleAssetName() {
59
-        return "index.android.bundle";
57
+    @Override
58
+    public ReactNativeHost getReactNativeHost() {
59
+        return reactGateway;
60 60
     }
61 61
 
62 62
     public abstract boolean isDebug();

+ 25
- 41
android/app/src/main/java/com/reactnativenavigation/react/NavigationReactGateway.java View File

@@ -3,7 +3,6 @@ package com.reactnativenavigation.react;
3 3
 import android.app.Activity;
4 4
 import android.content.Intent;
5 5
 
6
-import com.facebook.react.LifecycleState;
7 6
 import com.facebook.react.ReactInstanceManager;
8 7
 import com.facebook.react.ReactPackage;
9 8
 import com.facebook.react.bridge.ReactContext;
@@ -16,66 +15,54 @@ import com.reactnativenavigation.bridge.NavigationReactPackage;
16 15
 import java.util.ArrayList;
17 16
 import java.util.List;
18 17
 
19
-public class NavigationReactGateway implements ReactGateway, ReactInstanceManager.ReactInstanceEventListener {
18
+public class NavigationReactGateway extends ReactGatewayHost implements ReactInstanceManager.ReactInstanceEventListener {
20 19
 
21 20
     private OnJsDevReloadListener onJsDevReloadListener;
22
-    private ReactInstanceManager reactInstanceManager;
23 21
     private NavigationReactEventEmitter reactEventEmitter;
24 22
 
25 23
     public NavigationReactGateway() {
26
-        reactInstanceManager = createReactInstanceManager();
24
+        super(NavigationApplication.instance);
27 25
     }
28 26
 
29 27
     @Override
30 28
     public void startReactContextOnceInBackgroundAndExecuteJS() {
31
-        if (reactInstanceManager == null) {
32
-            reactInstanceManager = createReactInstanceManager();
33
-        }
34
-
35
-        if (!reactInstanceManager.hasStartedCreatingInitialContext()) {
36
-            reactInstanceManager.createReactContextInBackground();
37
-        }
29
+        getReactInstanceManager().createReactContextInBackground();
38 30
     }
39 31
 
40 32
     public boolean isInitialized() {
41
-        return reactInstanceManager != null && reactInstanceManager.getCurrentReactContext() != null;
33
+        return hasInstance() && getReactInstanceManager().getCurrentReactContext() != null;
42 34
     }
43 35
 
44 36
     public ReactContext getReactContext() {
45
-        return reactInstanceManager.getCurrentReactContext();
37
+        return getReactInstanceManager().getCurrentReactContext();
46 38
     }
47 39
 
48 40
     public NavigationReactEventEmitter getReactEventEmitter() {
49 41
         return reactEventEmitter;
50 42
     }
51 43
 
52
-    public ReactInstanceManager getReactInstanceManager() {
53
-        return reactInstanceManager;
54
-    }
55
-
56 44
     public void onBackPressed() {
57
-        reactInstanceManager.onBackPressed();
45
+        getReactInstanceManager().onBackPressed();
58 46
     }
59 47
 
60 48
     public void onDestroyApp() {
61
-        reactInstanceManager.onHostDestroy();
62
-        reactInstanceManager.destroy();
63
-        reactInstanceManager.removeReactInstanceEventListener(this);
64
-        reactInstanceManager = null;
49
+        getReactInstanceManager().onHostDestroy();
50
+        getReactInstanceManager().removeReactInstanceEventListener(this);
51
+        clear();
65 52
     }
66 53
 
67 54
     public void onPauseActivity() {
68
-        reactInstanceManager.onHostPause();
55
+        getReactInstanceManager().onHostPause();
69 56
         onJsDevReloadListener = null;
70 57
     }
71 58
 
72 59
     public void onResumeActivity(Activity activity, DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler, OnJsDevReloadListener onJsDevReloadListener) {
73 60
         this.onJsDevReloadListener = onJsDevReloadListener;
74
-        reactInstanceManager.onHostResume(activity, defaultHardwareBackBtnHandler);
61
+        getReactInstanceManager().onHostResume(activity, defaultHardwareBackBtnHandler);
75 62
     }
76 63
 
77 64
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
78
-        reactInstanceManager.onActivityResult(requestCode, resultCode, data);
65
+        getReactInstanceManager().onActivityResult(requestCode, resultCode, data);
79 66
     }
80 67
 
81 68
     private void replaceJsDevReloadListener(ReactInstanceManager manager) {
@@ -88,29 +75,26 @@ public class NavigationReactGateway implements ReactGateway, ReactInstanceManage
88 75
         }).replace();
89 76
     }
90 77
 
91
-    private ReactInstanceManager createReactInstanceManager() {
92
-        ReactInstanceManager.Builder builder = ReactInstanceManager.builder()
93
-                .setApplication(NavigationApplication.instance)
94
-                .setJSMainModuleName(NavigationApplication.instance.getJsEntryFileName())
95
-                .setBundleAssetName(NavigationApplication.instance.getBundleAssetName())
96
-                .setUseDeveloperSupport(NavigationApplication.instance.isDebug())
97
-                .setInitialLifecycleState(LifecycleState.BEFORE_RESUME);
98
-
99
-        for (ReactPackage reactPackage : createReactPackages()) {
100
-            builder.addPackage(reactPackage);
101
-        }
102
-
103
-        ReactInstanceManager manager = builder.build();
104
-
78
+    @Override
79
+    protected ReactInstanceManager createReactInstanceManager() {
80
+        ReactInstanceManager manager = super.createReactInstanceManager();
105 81
         if (NavigationApplication.instance.isDebug()) {
106 82
             replaceJsDevReloadListener(manager);
107 83
         }
108
-
109 84
         manager.addReactInstanceEventListener(this);
110
-
111 85
         return manager;
112 86
     }
113 87
 
88
+    @Override
89
+    protected boolean getUseDeveloperSupport() {
90
+        return NavigationApplication.instance.isDebug();
91
+    }
92
+
93
+    @Override
94
+    protected List<ReactPackage> getPackages() {
95
+        return createReactPackages();
96
+    }
97
+
114 98
     private List<ReactPackage> createReactPackages() {
115 99
         List<ReactPackage> list = new ArrayList<>();
116 100
         list.add(new MainReactPackage());

+ 11
- 0
android/app/src/main/java/com/reactnativenavigation/react/ReactGatewayHost.java View File

@@ -0,0 +1,11 @@
1
+package com.reactnativenavigation.react;
2
+
3
+import android.app.Application;
4
+
5
+import com.facebook.react.ReactNativeHost;
6
+
7
+public abstract class ReactGatewayHost extends ReactNativeHost implements ReactGateway {
8
+    protected ReactGatewayHost(Application application) {
9
+        super(application);
10
+    }
11
+}

+ 23
- 61
example-redux/.flowconfig View File

@@ -1,70 +1,28 @@
1 1
 [ignore]
2 2
 
3 3
 # We fork some components by platform.
4
-.*/*.web.js
5 4
 .*/*.android.js
6 5
 
7
-# Some modules have their own node_modules with overlap
8
-.*/node_modules/node-haste/.*
9
-
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/fetch.js
19
-.*/node_modules/fbjs/lib/ExecutionEnvironment.js
20
-.*/node_modules/fbjs/lib/ErrorUtils.js
21
-
22
-# Flow has a built-in definition for the 'react' module which we prefer to use
23
-# over the currently-untyped source
24
-.*/node_modules/react/react.js
25
-.*/node_modules/react/lib/React.js
26
-.*/node_modules/react/lib/ReactDOM.js
27
-
28
-.*/__mocks__/.*
29
-.*/__tests__/.*
30
-
31
-.*/commoner/test/source/widget/share.js
32
-
33
-# Ignore commoner tests
34
-.*/node_modules/commoner/test/.*
35
-
36
-# See https://github.com/facebook/flow/issues/442
37
-.*/react-tools/node_modules/commoner/lib/reader.js
6
+# Ignore templates with `@flow` in header
7
+.*/local-cli/generator.*
38 8
 
39
-# Ignore jest
40
-.*/node_modules/jest-cli/.*
9
+# Ignore malformed json
10
+.*/node_modules/y18n/test/.*\.json
41 11
 
42
-# Ignore Website
43
-.*/website/.*
12
+# Ignore the website subdir
13
+<PROJECT_ROOT>/website/.*
44 14
 
45
-# Ignore generators
46
-.*/local-cli/generator.*
15
+# Ignore BUCK generated dirs
16
+<PROJECT_ROOT>/\.buckd/
47 17
 
48
-# Ignore BUCK generated folders
49
-.*\.buckd/
50
-
51
-.*/node_modules/is-my-json-valid/test/.*\.json
52
-.*/node_modules/iconv-lite/encodings/tables/.*\.json
53
-.*/node_modules/y18n/test/.*\.json
54
-.*/node_modules/spdx-license-ids/spdx-license-ids.json
55
-.*/node_modules/spdx-exceptions/index.json
56
-.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json
57
-.*/node_modules/resolve/lib/core.json
58
-.*/node_modules/jsonparse/samplejson/.*\.json
59
-.*/node_modules/json5/test/.*\.json
60
-.*/node_modules/ua-parser-js/test/.*\.json
61
-.*/node_modules/builtin-modules/builtin-modules.json
62
-.*/node_modules/binary-extensions/binary-extensions.json
63
-.*/node_modules/url-regex/tlds.json
64
-.*/node_modules/joi/.*\.json
65
-.*/node_modules/isemail/.*\.json
66
-.*/node_modules/tr46/.*\.json
18
+# Ignore unexpected extra @providesModule
19
+.*/node_modules/commoner/test/source/widget/share.js
67 20
 
21
+# Ignore duplicate module providers
22
+# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
23
+.*/Libraries/react-native/React.js
24
+.*/Libraries/react-native/ReactNative.js
25
+.*/node_modules/jest-runtime/build/__tests__/.*
68 26
 
69 27
 [include]
70 28
 
@@ -79,18 +37,22 @@ module.system=haste
79 37
 esproposal.class_static_fields=enable
80 38
 esproposal.class_instance_fields=enable
81 39
 
40
+experimental.strict_type_args=true
41
+
82 42
 munge_underscores=true
83 43
 
84 44
 module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
85
-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'
45
+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'
86 46
 
87 47
 suppress_type=$FlowIssue
88 48
 suppress_type=$FlowFixMe
89 49
 suppress_type=$FixMe
90 50
 
91
-suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-3]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
92
-suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-3]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
51
+suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-9]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
52
+suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-9]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
93 53
 suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
94 54
 
55
+unsafe.enable_getters_and_setters=true
56
+
95 57
 [version]
96
-0.23.0
58
+^0.29.0

+ 1
- 1
example-redux/android/app/BUCK View File

@@ -5,7 +5,7 @@ import re
5 5
 # - install Buck
6 6
 # - `npm start` - to start the packager
7 7
 # - `cd android`
8
-# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US`
8
+# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
9 9
 # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
10 10
 # - `buck install -r android/app` - compile, install and run application
11 11
 #

+ 7
- 6
example-redux/android/app/build.gradle View File

@@ -55,7 +55,13 @@ import com.android.build.OutputFile
55 55
  *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
56 56
  *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
57 57
  *   // for example, you might want to remove it from here.
58
- *   inputExcludes: ["android/**", "ios/**"]
58
+ *   inputExcludes: ["android/**", "ios/**"],
59
+ *
60
+ *   // override which node gets called and with what additional arguments
61
+ *   nodeExecutableAndArgs: ["node"]
62
+ *
63
+ *   // supply additional arguments to the packager
64
+ *   extraPackagerArgs: []
59 65
  * ]
60 66
  */
61 67
 
@@ -125,7 +131,6 @@ dependencies {
125 131
     compile "com.facebook.react:react-native:+"  // From node_modules
126 132
     debugCompile project(path: ':react-native-navigation', configuration: 'libraryDebug')
127 133
     releaseCompile project(path: ':react-native-navigation', configuration: 'libraryRelease')
128
-//    compile project(':react-native-navigation')
129 134
 }
130 135
 
131 136
 // Run this once to be able to run the application with BUCK
@@ -134,7 +139,3 @@ task copyDownloadableDepsToLibs(type: Copy) {
134 139
   from configurations.compile
135 140
   into 'libs'
136 141
 }
137
-
138
-task runDebug(dependsOn: ['assembleDebug', 'installDebug']) << {
139
-    println 'FINISHED'
140
-}

+ 6
- 3
example-redux/android/app/proguard-rules.pro View File

@@ -26,11 +26,14 @@
26 26
 # See http://sourceforge.net/p/proguard/bugs/466/
27 27
 -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
28 28
 -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
29
+-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
29 30
 
30 31
 # Do not strip any method/class that is annotated with @DoNotStrip
31 32
 -keep @com.facebook.proguard.annotations.DoNotStrip class *
33
+-keep @com.facebook.common.internal.DoNotStrip class *
32 34
 -keepclassmembers class * {
33 35
     @com.facebook.proguard.annotations.DoNotStrip *;
36
+    @com.facebook.common.internal.DoNotStrip *;
34 37
 }
35 38
 
36 39
 -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
@@ -51,9 +54,9 @@
51 54
 
52 55
 -keepattributes Signature
53 56
 -keepattributes *Annotation*
54
--keep class com.squareup.okhttp.** { *; }
55
--keep interface com.squareup.okhttp.** { *; }
56
--dontwarn com.squareup.okhttp.**
57
+-keep class okhttp3.** { *; }
58
+-keep interface okhttp3.** { *; }
59
+-dontwarn okhttp3.**
57 60
 
58 61
 # okio
59 62
 

+ 1
- 1
example-redux/android/app/src/main/AndroidManifest.xml View File

@@ -4,7 +4,7 @@
4 4
     <uses-permission android:name="android.permission.INTERNET" />
5 5
 
6 6
     <application
7
-        android:name=".App"
7
+        android:name=".MainApplication"
8 8
         android:allowBackup="true"
9 9
         android:icon="@mipmap/ic_launcher"
10 10
         android:label="@string/app_name"

example-redux/android/app/src/main/java/com/exampleredux/App.java → example-redux/android/app/src/main/java/com/exampleredux/MainApplication.java View File

@@ -1,22 +1,23 @@
1 1
 package com.exampleredux;
2 2
 
3
-import android.support.annotation.NonNull;
3
+import android.support.annotation.Nullable;
4 4
 
5 5
 import com.facebook.react.ReactPackage;
6 6
 import com.reactnativenavigation.NavigationApplication;
7 7
 
8
-import java.util.Collections;
9 8
 import java.util.List;
10 9
 
11
-public class App extends NavigationApplication {
10
+public class MainApplication extends NavigationApplication {
11
+
12
+
12 13
     @Override
13 14
     public boolean isDebug() {
14 15
         return BuildConfig.DEBUG;
15 16
     }
16 17
 
17
-    @NonNull
18
+    @Nullable
18 19
     @Override
19 20
     public List<ReactPackage> createAdditionalReactPackages() {
20
-        return Collections.emptyList();
21
+        return null;
21 22
     }
22 23
 }

+ 1
- 1
example-redux/android/build.gradle View File

@@ -18,7 +18,7 @@ allprojects {
18 18
         jcenter()
19 19
         maven {
20 20
             // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
21
-            url "$projectDir/../../node_modules/react-native/android"
21
+            url "$rootDir/../node_modules/react-native/android"
22 22
         }
23 23
     }
24 24
 }

+ 1
- 1
example-redux/android/gradle/wrapper/gradle-wrapper.properties View File

@@ -1,4 +1,4 @@
1
-#Tue Aug 16 15:10:42 IDT 2016
1
+#Sun Aug 28 15:34:43 IDT 2016
2 2
 distributionBase=GRADLE_USER_HOME
3 3
 distributionPath=wrapper/dists
4 4
 zipStoreBase=GRADLE_USER_HOME

+ 3
- 3
example-redux/package.json View File

@@ -7,13 +7,13 @@
7 7
     "install:android": "pushd android && ./gradlew installDebug && popd"
8 8
   },
9 9
   "dependencies": {
10
-    "react-native": "0.25.1",
11
-    "react": "0.14.5",
10
+    "react-native-navigation": "file:../",
11
+    "react-native": "0.31.0",
12
+    "react": "15.2.1",
12 13
     "react-redux": "^4.0.6",
13 14
     "redux": "^3.0.5",
14 15
     "redux-thunk": "^1.0.3",
15 16
     "seamless-immutable": "^5.0.1",
16
-    "react-native-navigation": "file:../",
17 17
     "babel-preset-react-native-stage-0": "*"
18 18
   }
19 19
 }

+ 4
- 4
package.json View File

@@ -26,8 +26,8 @@
26 26
     "release": "npm version prerelease && npm publish --tag next && npm view react-native-navigation dist-tags && git push"
27 27
   },
28 28
   "peerDependencies": {
29
-    "react-native": ">=0.25.1",
30
-    "react": ">=0.14.5"
29
+    "react-native": ">=0.31.0",
30
+    "react": ">=15.2.1"
31 31
   },
32 32
   "dependencies": {
33 33
     "react-native-controllers": "^2.0.0",
@@ -38,8 +38,8 @@
38 38
     "react-redux": "*"
39 39
   },
40 40
   "devDependencies": {
41
-    "react-native": "0.25.1",
42
-    "react": "0.14.5",
41
+    "react-native": "0.31.0",
42
+    "react": "15.2.1",
43 43
     "app-root-path": "^1.0.0",
44 44
     "babel-cli": "^6.8.0",
45 45
     "babel-core": "^6.8.0",