Browse Source

Support RN 0.56

This commit also upgrades TypeScript to version 2.9.x
Guy Carmeli 6 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
         reactNative55 {
54
         reactNative55 {
55
             dimension "RNN.reactNativeVersion"
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
 package com.reactnativenavigation.react;
1
 package com.reactnativenavigation.react;
2
 
2
 
3
-import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
4
-
5
 public interface BundleDownloadListenerProvider {
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
 import android.content.IntentFilter;
7
 import android.content.IntentFilter;
8
 import android.view.KeyEvent;
8
 import android.view.KeyEvent;
9
 
9
 
10
-import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
11
 import com.facebook.react.devsupport.interfaces.DevSupportManager;
10
 import com.facebook.react.devsupport.interfaces.DevSupportManager;
12
 import com.reactnativenavigation.utils.UiUtils;
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
     private static final String RELOAD_BROADCAST = "com.reactnativenavigation.broadcast.RELOAD";
14
     private static final String RELOAD_BROADCAST = "com.reactnativenavigation.broadcast.RELOAD";
18
 
15
 
19
     public interface ReloadListener {
16
     public interface ReloadListener {
40
         UiUtils.runOnMainThread(reloadListener::onReload);
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
     public void setReloadListener(ReloadListener listener) {
40
     public void setReloadListener(ReloadListener listener) {
54
         reloadListener = listener;
41
         reloadListener = listener;
55
     }
42
     }

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

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

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

1
 package com.reactnativenavigation.react;
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
     private Runnable onReloadListener = () -> {};
5
     private Runnable onReloadListener = () -> {};
10
 
6
 
12
         this.onReloadListener = onReload;
8
         this.onReloadListener = onReload;
13
     }
9
     }
14
 
10
 
15
-    /**
16
-     * Called on RR and adb reload events
17
-     */
18
     @Override
11
     @Override
19
     public void onReload() {
12
     public void onReload() {
20
         onReloadListener.run();
13
         onReloadListener.run();
21
     }
14
     }
22
 
15
 
23
-    /**
24
-     * Called when the bundle was successfully reloaded
25
-     */
26
     @Override
16
     @Override
27
     public void onSuccess() {
17
     public void onSuccess() {
28
         onReloadListener.run();
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
     public void destroy() {
21
     public void destroy() {
48
         onReloadListener = null;
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

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

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

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

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

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

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

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

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

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

+ 1
- 0
tsconfig.json View File

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

+ 5
- 0
tslint.json View File

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