@bravemobile/react-native-code-push 10.0.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,17 +8,9 @@
8
8
 
9
9
  ### 🚀 New Architecture support
10
10
 
11
- Tested on the React Native template apps
12
-
13
- | RN Version | Old Architecture | New Architecture | New Architecture Bridgeless |
14
- |--------|--------|--------|--------|
15
- | 0.73.11 | ✅ | ✅ | Unsupported |
16
- | 0.74.7 | ✅ | ✅ | ✅ |
17
- | 0.75.5 | ✅ | ✅ | ✅ |
18
- | 0.76.7 | ✅ | ✅ | ✅ |
19
- | 0.77.1 | ✅ | ✅ | ✅ |
20
- | 0.78.0 | ✅ | ✅ | ✅ |
11
+ Supports React Native 0.74 ~ 0.80.
21
12
 
13
+ (Tested on the React Native CLI template apps)
22
14
 
23
15
  ## 🚗 Migration Guide
24
16
 
@@ -24,10 +24,6 @@
24
24
  private ** mReactHost; # bridgeless
25
25
  public void reload(...); # RN 0.74 and above
26
26
  }
27
- # RN 0.74 and above
28
- -keepclassmembers class com.facebook.react.ReactActivity {
29
- public ** getReactDelegate(...);
30
- }
31
27
  # bridgeless
32
28
  -keepclassmembers class com.facebook.react.defaults.DefaultReactHostDelegate {
33
29
  private ** jsBundleLoader;
@@ -6,6 +6,7 @@ import android.os.AsyncTask;
6
6
  import android.os.Handler;
7
7
  import android.os.Looper;
8
8
  import android.view.View;
9
+ import android.view.Choreographer;
9
10
 
10
11
  import androidx.annotation.OptIn;
11
12
 
@@ -25,7 +26,6 @@ import com.facebook.react.bridge.ReactMethod;
25
26
  import com.facebook.react.bridge.ReadableMap;
26
27
  import com.facebook.react.bridge.WritableMap;
27
28
  import com.facebook.react.common.annotations.UnstableReactNativeAPI;
28
- import com.facebook.react.modules.core.ChoreographerCompat;
29
29
  import com.facebook.react.modules.core.DeviceEventManagerModule;
30
30
  import com.facebook.react.modules.core.ReactChoreographer;
31
31
  import com.facebook.react.runtime.ReactHostDelegate;
@@ -99,7 +99,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
99
99
  }
100
100
 
101
101
  private void loadBundleLegacy() {
102
- final Activity currentActivity = getCurrentActivity();
102
+ final Activity currentActivity = getReactApplicationContext().getCurrentActivity();
103
103
  if (currentActivity == null) {
104
104
  // The currentActivity can be null if it is backgrounded / destroyed, so we simply
105
105
  // no-op to prevent any null pointer exceptions.
@@ -128,7 +128,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
128
128
 
129
129
  ReactHost reactHost = resolveReactHost();
130
130
  if (reactHost == null) {
131
- // Bridge, Old Architecture and RN < 0.74 (we support Bridgeless >= 0.74)
131
+ // Bridge, Old Architecture
132
132
  setJSBundleLoaderBridge(instanceManager, latestJSBundleLoader);
133
133
  return;
134
134
  }
@@ -184,29 +184,14 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
184
184
  new Handler(Looper.getMainLooper()).post(new Runnable() {
185
185
  @Override
186
186
  public void run() {
187
- try {
188
- // reload method introduced in RN 0.74 (https://github.com/reactwg/react-native-new-architecture/discussions/174)
189
- // so, we need to check if reload method exists and call it
190
- try {
191
- ReactDelegate reactDelegate = resolveReactDelegate();
192
- if (reactDelegate == null) {
193
- throw new NoSuchMethodException("ReactDelegate doesn't have reload method in RN < 0.74");
194
- }
187
+ ReactDelegate reactDelegate = resolveReactDelegate();
188
+ assert reactDelegate != null;
195
189
 
196
- resetReactRootViews(reactDelegate);
190
+ resetReactRootViews(reactDelegate);
197
191
 
198
- Method reloadMethod = reactDelegate.getClass().getMethod("reload");
199
- reloadMethod.invoke(reactDelegate);
200
- } catch (NoSuchMethodException e) {
201
- // RN < 0.74 calls ReactInstanceManager.recreateReactContextInBackground() directly
202
- instanceManager.recreateReactContextInBackground();
203
- }
204
- mCodePush.initializeUpdateAfterRestart();
205
- } catch (Exception e) {
206
- // The recreation method threw an unknown exception
207
- // so just simply fallback to restarting the Activity (if it exists)
208
- loadBundleLegacy();
209
- }
192
+ reactDelegate.reload();
193
+
194
+ mCodePush.initializeUpdateAfterRestart();
210
195
  }
211
196
  });
212
197
 
@@ -223,7 +208,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
223
208
  // React Native uses the id field to track react tags and will overwrite this field.
224
209
  // If that is fine, explicitly overwrite the id field to View.NO_ID before calling addRootView."
225
210
  private void resetReactRootViews(ReactDelegate reactDelegate) {
226
- ReactActivity currentActivity = (ReactActivity) getCurrentActivity();
211
+ ReactActivity currentActivity = (ReactActivity) getReactApplicationContext().getCurrentActivity();
227
212
  if (currentActivity != null) {
228
213
  ReactRootView reactRootView = reactDelegate.getReactRootView();
229
214
  if (reactRootView != null) {
@@ -242,18 +227,12 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
242
227
  }
243
228
 
244
229
  private ReactDelegate resolveReactDelegate() {
245
- ReactActivity currentActivity = (ReactActivity) getCurrentActivity();
230
+ ReactActivity currentActivity = (ReactActivity) getReactApplicationContext().getCurrentActivity();
246
231
  if (currentActivity == null) {
247
232
  return null;
248
233
  }
249
234
 
250
- try {
251
- Method getReactDelegateMethod = currentActivity.getClass().getMethod("getReactDelegate");
252
- return (ReactDelegate) getReactDelegateMethod.invoke(currentActivity);
253
- } catch (Exception e) {
254
- // RN < 0.74 doesn't have getReactDelegate method
255
- return null;
256
- }
235
+ return currentActivity.getReactDelegate();
257
236
  }
258
237
 
259
238
  private ReactHost resolveReactHost() {
@@ -278,7 +257,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
278
257
  return instanceManager;
279
258
  }
280
259
 
281
- final Activity currentActivity = getCurrentActivity();
260
+ final Activity currentActivity = getReactApplicationContext().getCurrentActivity();
282
261
  if (currentActivity == null) {
283
262
  return null;
284
263
  }
@@ -390,7 +369,7 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
390
369
  getReactApplicationContext().runOnUiQueueThread(new Runnable() {
391
370
  @Override
392
371
  public void run() {
393
- ReactChoreographer.getInstance().postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, new ChoreographerCompat.FrameCallback() {
372
+ ReactChoreographer.getInstance().postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, new Choreographer.FrameCallback() {
394
373
  @Override
395
374
  public void doFrame(long frameTimeNanos) {
396
375
  if (!latestDownloadProgress.isCompleted()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bravemobile/react-native-code-push",
3
- "version": "10.0.0",
3
+ "version": "11.0.0",
4
4
  "description": "React Native plugin for the CodePush service",
5
5
  "main": "CodePush.js",
6
6
  "typings": "typings/react-native-code-push.d.ts",