react-native-update 10.19.6 → 10.20.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.
@@ -3,7 +3,10 @@ package cn.reactnative.modules.update;
3
3
  import android.app.Activity;
4
4
  import android.content.Context;
5
5
  import android.util.Log;
6
+
7
+ import com.facebook.react.ReactActivity;
6
8
  import com.facebook.react.ReactApplication;
9
+ import com.facebook.react.ReactDelegate;
7
10
  import com.facebook.react.ReactInstanceManager;
8
11
  import com.facebook.react.bridge.JSBundleLoader;
9
12
  import com.facebook.react.bridge.Promise;
@@ -12,16 +15,10 @@ import com.facebook.react.bridge.ReadableMap;
12
15
  import com.facebook.react.bridge.UiThreadUtil;
13
16
  import com.fasterxml.jackson.databind.ObjectMapper;
14
17
 
15
- import org.json.JSONObject;
16
-
17
18
  import java.io.File;
18
19
  import java.io.IOException;
19
20
  import java.lang.reflect.Field;
20
- import java.util.HashMap;
21
21
  import java.util.Map;
22
- import java.util.Optional;
23
- import java.util.regex.Matcher;
24
- import java.util.regex.Pattern;
25
22
 
26
23
  public class UpdateModuleImpl {
27
24
 
@@ -146,13 +143,17 @@ public class UpdateModuleImpl {
146
143
  if (currentActivity == null) {
147
144
  return;
148
145
  }
149
-
150
- currentActivity.runOnUiThread(new Runnable() {
151
- @Override
152
- public void run() {
153
- currentActivity.recreate();
154
- }
155
- });
146
+ try {
147
+ final ReactDelegate reactDelegate = ((ReactActivity) currentActivity).getReactDelegate();
148
+ reactDelegate.reload();
149
+ } catch (Throwable e) {
150
+ currentActivity.runOnUiThread(new Runnable() {
151
+ @Override
152
+ public void run() {
153
+ currentActivity.recreate();
154
+ }
155
+ });
156
+ }
156
157
  }
157
158
  }
158
159
  });
@@ -9,9 +9,6 @@ import com.facebook.react.module.model.ReactModuleInfoProvider;
9
9
  import java.util.HashMap;
10
10
  import java.util.Map;
11
11
 
12
- /**
13
- * Created by tdzl2003 on 3/31/16.
14
- */
15
12
  public class UpdatePackage extends TurboReactPackage {
16
13
  @Nullable
17
14
  @Override
@@ -25,21 +22,24 @@ public class UpdatePackage extends TurboReactPackage {
25
22
 
26
23
  @Override
27
24
  public ReactModuleInfoProvider getReactModuleInfoProvider() {
28
- return () -> {
29
- final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
30
- boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
31
- moduleInfos.put(
32
- UpdateModuleImpl.NAME,
33
- new ReactModuleInfo(
34
- UpdateModuleImpl.NAME,
35
- UpdateModuleImpl.NAME,
36
- false, // canOverrideExistingModule
37
- false, // needsEagerInit
38
- true, // hasConstants
39
- false, // isCxxModule
40
- isTurboModule // isTurboModule
41
- ));
42
- return moduleInfos;
25
+ return new ReactModuleInfoProvider() {
26
+ @Override
27
+ public Map<String, ReactModuleInfo> getReactModuleInfos() {
28
+ final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
29
+ boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
30
+ moduleInfos.put(
31
+ UpdateModuleImpl.NAME,
32
+ new ReactModuleInfo(
33
+ UpdateModuleImpl.NAME,
34
+ UpdateModuleImpl.NAME,
35
+ false, // canOverrideExistingModule
36
+ false, // needsEagerInit
37
+ true, // hasConstants
38
+ false, // isCxxModule
39
+ isTurboModule // isTurboModule
40
+ ));
41
+ return moduleInfos;
42
+ }
43
43
  };
44
44
  }
45
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.19.6",
3
+ "version": "10.20.0",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {