Browse Source

Support RN 0.56

This commit also upgrades TypeScript to version 2.9.x
Guy Carmeli 5 years ago
parent
commit
390c83ae6a
19 changed files with 295 additions and 48 deletions
  1. 3
    0
      lib/android/app/build.gradle
  2. 1
    3
      lib/android/app/src/main/java/com/reactnativenavigation/react/BundleDownloadListenerProvider.java
  3. 1
    14
      lib/android/app/src/main/java/com/reactnativenavigation/react/JsDevReloadHandler.java
  4. 5
    0
      lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationDevBundleDownloadListener.java
  5. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationReactNativeHost.java
  6. 1
    27
      lib/android/app/src/main/java/com/reactnativenavigation/react/ReloadHandler.java
  7. 0
    0
      lib/android/app/src/reactNative51/java/com/reactnativenavigation/react/DevBundleDownloadListenerAdapter.java
  8. 22
    0
      lib/android/app/src/reactNative51/java/com/reactnativenavigation/react/JsDevReloadHandlerFacade.java
  9. 22
    0
      lib/android/app/src/reactNative51/java/com/reactnativenavigation/react/ReloadHandlerFacade.java
  10. 22
    0
      lib/android/app/src/reactNative55/java/com/reactnativenavigation/react/DevBundleDownloadListenerAdapter.java
  11. 22
    0
      lib/android/app/src/reactNative55/java/com/reactnativenavigation/react/JsDevReloadHandlerFacade.java
  12. 22
    0
      lib/android/app/src/reactNative55/java/com/reactnativenavigation/react/ReloadHandlerFacade.java
  13. 28
    0
      lib/android/app/src/reactNative56/java/com/reactnativenavigation/react/DevBundleDownloadListenerAdapter.java
  14. 28
    0
      lib/android/app/src/reactNative56/java/com/reactnativenavigation/react/JsDevReloadHandlerFacade.java
  15. 25
    0
      lib/android/app/src/reactNative56/java/com/reactnativenavigation/react/ReloadHandlerFacade.java
  16. 83
    0
      lib/android/app/src/reactNative56/java/com/reactnativenavigation/react/SyncUiImplementation.java
  17. 2
    2
      package.json
  18. 1
    0
      tsconfig.json
  19. 5
    0
      tslint.json

+ 3
- 0
lib/android/app/build.gradle View File

@@ -54,6 +54,9 @@ android {
54 54
         reactNative55 {
55 55
             dimension "RNN.reactNativeVersion"
56 56
         }
57
+        reactNative56 {
58
+            dimension "RNN.reactNativeVersion"
59
+        }
57 60
     }
58 61
 }
59 62
 

+ 1
- 3
lib/android/app/src/main/java/com/reactnativenavigation/react/BundleDownloadListenerProvider.java View File

@@ -1,7 +1,5 @@
1 1
 package com.reactnativenavigation.react;
2 2
 
3
-import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
4
-
5 3
 public interface BundleDownloadListenerProvider {
6
-    void setBundleLoaderListener(DevBundleDownloadListener listener);
4
+    void setBundleLoaderListener(NavigationDevBundleDownloadListener listener);
7 5
 }

+ 1
- 14
lib/android/app/src/main/java/com/reactnativenavigation/react/JsDevReloadHandler.java View File

@@ -7,13 +7,10 @@ import android.content.Intent;
7 7
 import android.content.IntentFilter;
8 8
 import android.view.KeyEvent;
9 9
 
10
-import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
11 10
 import com.facebook.react.devsupport.interfaces.DevSupportManager;
12 11
 import com.reactnativenavigation.utils.UiUtils;
13 12
 
14
-import javax.annotation.Nullable;
15
-
16
-public class JsDevReloadHandler implements DevBundleDownloadListener {
13
+public class JsDevReloadHandler extends JsDevReloadHandlerFacade {
17 14
     private static final String RELOAD_BROADCAST = "com.reactnativenavigation.broadcast.RELOAD";
18 15
 
19 16
     public interface ReloadListener {
@@ -40,16 +37,6 @@ public class JsDevReloadHandler implements DevBundleDownloadListener {
40 37
         UiUtils.runOnMainThread(reloadListener::onReload);
41 38
     }
42 39
 
43
-    @Override
44
-    public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
45
-
46
-    }
47
-
48
-    @Override
49
-    public void onFailure(Exception cause) {
50
-
51
-    }
52
-
53 40
     public void setReloadListener(ReloadListener listener) {
54 41
         reloadListener = listener;
55 42
     }

+ 5
- 0
lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationDevBundleDownloadListener.java View File

@@ -0,0 +1,5 @@
1
+package com.reactnativenavigation.react;
2
+
3
+public interface NavigationDevBundleDownloadListener {
4
+    void onSuccess();
5
+}

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationReactNativeHost.java View File

@@ -25,7 +25,7 @@ public class NavigationReactNativeHost extends ReactNativeHost implements Bundle
25 25
 
26 26
     private final boolean isDebug;
27 27
     private final List<ReactPackage> additionalReactPackages;
28
-    private @Nullable DevBundleDownloadListener bundleListener;
28
+    private @Nullable NavigationDevBundleDownloadListener bundleListener;
29 29
     private final DevBundleDownloadListener bundleListenerMediator = new DevBundleDownloadListenerAdapter() {
30 30
         @Override
31 31
         public void onSuccess() {
@@ -48,7 +48,7 @@ public class NavigationReactNativeHost extends ReactNativeHost implements Bundle
48 48
     }
49 49
 
50 50
     @Override
51
-    public void setBundleLoaderListener(DevBundleDownloadListener listener) {
51
+    public void setBundleLoaderListener(NavigationDevBundleDownloadListener listener) {
52 52
         bundleListener = listener;
53 53
     }
54 54
 

+ 1
- 27
lib/android/app/src/main/java/com/reactnativenavigation/react/ReloadHandler.java View File

@@ -1,10 +1,6 @@
1 1
 package com.reactnativenavigation.react;
2 2
 
3
-import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
4
-
5
-import javax.annotation.Nullable;
6
-
7
-public class ReloadHandler implements JsDevReloadHandler.ReloadListener, DevBundleDownloadListener {
3
+public class ReloadHandler extends ReloadHandlerFacade implements JsDevReloadHandler.ReloadListener {
8 4
 
9 5
     private Runnable onReloadListener = () -> {};
10 6
 
@@ -12,38 +8,16 @@ public class ReloadHandler implements JsDevReloadHandler.ReloadListener, DevBund
12 8
         this.onReloadListener = onReload;
13 9
     }
14 10
 
15
-    /**
16
-     * Called on RR and adb reload events
17
-     */
18 11
     @Override
19 12
     public void onReload() {
20 13
         onReloadListener.run();
21 14
     }
22 15
 
23
-    /**
24
-     * Called when the bundle was successfully reloaded
25
-     */
26 16
     @Override
27 17
     public void onSuccess() {
28 18
         onReloadListener.run();
29 19
     }
30 20
 
31
-    /**
32
-     * Bundle progress updates
33
-     */
34
-    @Override
35
-    public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
36
-
37
-    }
38
-
39
-    /**
40
-     * Bundle load failure
41
-     */
42
-    @Override
43
-    public void onFailure(Exception cause) {
44
-
45
-    }
46
-
47 21
     public void destroy() {
48 22
         onReloadListener = null;
49 23
     }

lib/android/app/src/main/java/com/reactnativenavigation/react/DevBundleDownloadListenerAdapter.java → lib/android/app/src/reactNative51/java/com/reactnativenavigation/react/DevBundleDownloadListenerAdapter.java View File


+ 22
- 0
lib/android/app/src/reactNative51/java/com/reactnativenavigation/react/JsDevReloadHandlerFacade.java View File

@@ -0,0 +1,22 @@
1
+package com.reactnativenavigation.react;
2
+
3
+import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
4
+
5
+import javax.annotation.Nullable;
6
+
7
+public class JsDevReloadHandlerFacade implements DevBundleDownloadListener, NavigationDevBundleDownloadListener {
8
+    @Override
9
+    public void onSuccess() {
10
+
11
+    }
12
+
13
+    @Override
14
+    public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
15
+
16
+    }
17
+
18
+    @Override
19
+    public void onFailure(Exception cause) {
20
+
21
+    }
22
+}

+ 22
- 0
lib/android/app/src/reactNative51/java/com/reactnativenavigation/react/ReloadHandlerFacade.java View File

@@ -0,0 +1,22 @@
1
+package com.reactnativenavigation.react;
2
+
3
+import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
4
+
5
+import javax.annotation.Nullable;
6
+
7
+public abstract class ReloadHandlerFacade implements DevBundleDownloadListener {
8
+    @Override
9
+    public void onSuccess() {
10
+
11
+    }
12
+
13
+    @Override
14
+    public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
15
+
16
+    }
17
+
18
+    @Override
19
+    public void onFailure(Exception cause) {
20
+
21
+    }
22
+}

+ 22
- 0
lib/android/app/src/reactNative55/java/com/reactnativenavigation/react/DevBundleDownloadListenerAdapter.java View File

@@ -0,0 +1,22 @@
1
+package com.reactnativenavigation.react;
2
+
3
+import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
4
+
5
+import javax.annotation.Nullable;
6
+
7
+public class DevBundleDownloadListenerAdapter implements DevBundleDownloadListener {
8
+    @Override
9
+    public void onSuccess() {
10
+
11
+    }
12
+
13
+    @Override
14
+    public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
15
+
16
+    }
17
+
18
+    @Override
19
+    public void onFailure(Exception cause) {
20
+
21
+    }
22
+}

+ 22
- 0
lib/android/app/src/reactNative55/java/com/reactnativenavigation/react/JsDevReloadHandlerFacade.java View File

@@ -0,0 +1,22 @@
1
+package com.reactnativenavigation.react;
2
+
3
+import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
4
+
5
+import javax.annotation.Nullable;
6
+
7
+public class JsDevReloadHandlerFacade implements DevBundleDownloadListener, NavigationDevBundleDownloadListener {
8
+    @Override
9
+    public void onSuccess() {
10
+
11
+    }
12
+
13
+    @Override
14
+    public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
15
+
16
+    }
17
+
18
+    @Override
19
+    public void onFailure(Exception cause) {
20
+
21
+    }
22
+}

+ 22
- 0
lib/android/app/src/reactNative55/java/com/reactnativenavigation/react/ReloadHandlerFacade.java View File

@@ -0,0 +1,22 @@
1
+package com.reactnativenavigation.react;
2
+
3
+import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
4
+
5
+import javax.annotation.Nullable;
6
+
7
+public abstract class ReloadHandlerFacade implements DevBundleDownloadListener {
8
+    @Override
9
+    public void onSuccess() {
10
+
11
+    }
12
+
13
+    @Override
14
+    public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
15
+
16
+    }
17
+
18
+    @Override
19
+    public void onFailure(Exception cause) {
20
+
21
+    }
22
+}

+ 28
- 0
lib/android/app/src/reactNative56/java/com/reactnativenavigation/react/DevBundleDownloadListenerAdapter.java View File

@@ -0,0 +1,28 @@
1
+package com.reactnativenavigation.react;
2
+
3
+import com.facebook.react.bridge.NativeDeltaClient;
4
+import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
5
+
6
+import javax.annotation.Nullable;
7
+
8
+public class DevBundleDownloadListenerAdapter implements DevBundleDownloadListener, NavigationDevBundleDownloadListener {
9
+    @Override
10
+    public void onSuccess(@Nullable NativeDeltaClient nativeDeltaClient) {
11
+        onSuccess();
12
+    }
13
+
14
+    @Override
15
+    public void onSuccess() {
16
+
17
+    }
18
+
19
+    @Override
20
+    public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
21
+
22
+    }
23
+
24
+    @Override
25
+    public void onFailure(Exception cause) {
26
+
27
+    }
28
+}

+ 28
- 0
lib/android/app/src/reactNative56/java/com/reactnativenavigation/react/JsDevReloadHandlerFacade.java View File

@@ -0,0 +1,28 @@
1
+package com.reactnativenavigation.react;
2
+
3
+import com.facebook.react.bridge.NativeDeltaClient;
4
+import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
5
+
6
+import javax.annotation.Nullable;
7
+
8
+public class JsDevReloadHandlerFacade implements DevBundleDownloadListener, NavigationDevBundleDownloadListener {
9
+    @Override
10
+    public void onSuccess(@Nullable NativeDeltaClient nativeDeltaClient) {
11
+        onSuccess();
12
+    }
13
+
14
+    @Override
15
+    public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
16
+
17
+    }
18
+
19
+    @Override
20
+    public void onFailure(Exception cause) {
21
+
22
+    }
23
+
24
+    @Override
25
+    public void onSuccess() {
26
+
27
+    }
28
+}

+ 25
- 0
lib/android/app/src/reactNative56/java/com/reactnativenavigation/react/ReloadHandlerFacade.java View File

@@ -0,0 +1,25 @@
1
+package com.reactnativenavigation.react;
2
+
3
+import com.facebook.react.bridge.NativeDeltaClient;
4
+import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
5
+
6
+import javax.annotation.Nullable;
7
+
8
+public abstract class ReloadHandlerFacade implements DevBundleDownloadListener {
9
+    @Override
10
+    public void onSuccess(@Nullable NativeDeltaClient nativeDeltaClient) {
11
+
12
+    }
13
+
14
+    @Override
15
+    public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
16
+
17
+    }
18
+
19
+    @Override
20
+    public void onFailure(Exception cause) {
21
+
22
+    }
23
+
24
+    protected abstract void onSuccess();
25
+}

+ 83
- 0
lib/android/app/src/reactNative56/java/com/reactnativenavigation/react/SyncUiImplementation.java View File

@@ -0,0 +1,83 @@
1
+package com.reactnativenavigation.react;
2
+
3
+import android.support.annotation.Nullable;
4
+
5
+import com.facebook.react.bridge.ReactApplicationContext;
6
+import com.facebook.react.bridge.ReadableArray;
7
+import com.facebook.react.bridge.ReadableMap;
8
+import com.facebook.react.uimanager.ThemedReactContext;
9
+import com.facebook.react.uimanager.UIImplementation;
10
+import com.facebook.react.uimanager.UIImplementationProvider;
11
+import com.facebook.react.uimanager.UIManagerModule;
12
+import com.facebook.react.uimanager.ViewManager;
13
+import com.facebook.react.uimanager.common.MeasureSpecProvider;
14
+import com.facebook.react.uimanager.common.SizeMonitoringFrameLayout;
15
+import com.facebook.react.uimanager.events.EventDispatcher;
16
+
17
+import java.util.List;
18
+
19
+@SuppressWarnings("WeakerAccess")
20
+public class SyncUiImplementation extends UIImplementation {
21
+    private static final Object lock = new Object();
22
+
23
+    public static class Provider extends UIImplementationProvider {
24
+        @Override
25
+        public UIImplementation createUIImplementation(ReactApplicationContext reactContext, List<ViewManager> viewManagerList, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) {
26
+            return new SyncUiImplementation(reactContext, viewManagerList, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs);
27
+        }
28
+
29
+        @Override
30
+        public UIImplementation createUIImplementation(ReactApplicationContext reactContext, UIManagerModule.ViewManagerResolver viewManagerResolver, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) {
31
+            return new SyncUiImplementation(reactContext, viewManagerResolver, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs);
32
+        }
33
+    }
34
+
35
+    public SyncUiImplementation(ReactApplicationContext reactContext, List<ViewManager> viewManagerList, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) {
36
+        super(reactContext, viewManagerList, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs);
37
+    }
38
+
39
+    public SyncUiImplementation(ReactApplicationContext reactContext, UIManagerModule.ViewManagerResolver viewManagerResolver, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) {
40
+        super(reactContext, viewManagerResolver, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs);
41
+    }
42
+
43
+    @Override
44
+    public void manageChildren(
45
+            int viewTag,
46
+            @Nullable ReadableArray moveFrom,
47
+            @Nullable ReadableArray moveTo,
48
+            @Nullable ReadableArray addChildTags,
49
+            @Nullable ReadableArray addAtIndices,
50
+            @Nullable ReadableArray removeFrom) {
51
+        synchronized (lock) {
52
+            super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom);
53
+        }
54
+    }
55
+
56
+    @Override
57
+    public void setChildren(int viewTag, ReadableArray childrenTags) {
58
+        synchronized (lock) {
59
+            super.setChildren(viewTag, childrenTags);
60
+        }
61
+    }
62
+
63
+    @Override
64
+    public void createView(int tag, String className, int rootViewTag, ReadableMap props) {
65
+        synchronized (lock) {
66
+            super.createView(tag, className, rootViewTag, props);
67
+        }
68
+    }
69
+
70
+    @Override
71
+    public void removeRootShadowNode(int rootViewTag) {
72
+        synchronized (lock) {
73
+            super.removeRootShadowNode(rootViewTag);
74
+        }
75
+    }
76
+
77
+    @Override
78
+    public <T extends SizeMonitoringFrameLayout & MeasureSpecProvider> void registerRootView(T rootView, int tag, ThemedReactContext context) {
79
+        synchronized (lock) {
80
+            super.registerRootView(rootView, tag, context);
81
+        }
82
+    }
83
+}

+ 2
- 2
package.json View File

@@ -58,7 +58,7 @@
58 58
     "react-lifecycles-compat": "2.0.0",
59 59
     "hoist-non-react-statics": "2.x.x",
60 60
     "@types/react": "16.x.x",
61
-    "@types/react-native": "0.51.1",
61
+    "@types/react-native": "0.51.x",
62 62
     "@types/lodash": "4.x.x",
63 63
     "@types/prop-types": "15.x.x",
64 64
     "@types/react-test-renderer": "16.x.x",
@@ -76,7 +76,7 @@
76 76
     "semver": "5.x.x",
77 77
     "shell-utils": "1.x.x",
78 78
     "tslint": "5.x.x",
79
-    "typescript": "2.7.x",
79
+    "typescript": "2.9.x",
80 80
     "typedoc": "0.x.x",
81 81
     "handlebars": "4.x.x",
82 82
     "ts-node": "5.x.x"

+ 1
- 0
tsconfig.json View File

@@ -7,6 +7,7 @@
7 7
     "module": "commonjs",
8 8
     "jsx": "react-native",
9 9
     "declaration": true,
10
+    "skipLibCheck": true,
10 11
     "types": [
11 12
       "jest",
12 13
       "lodash",

+ 5
- 0
tslint.json View File

@@ -3,6 +3,11 @@
3 3
   "extends": [
4 4
     "tslint:recommended"
5 5
   ],
6
+  "linterOptions": {
7
+    "exclude": [
8
+      "**/*.test.tsx"
9
+    ]
10
+  },
6 11
   "jsRules": {
7 12
     "no-console": [false],
8 13
     "quotemark": [