@bravemobile/react-native-code-push 12.1.4 → 12.1.5
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
|
@@ -20,17 +20,14 @@
|
|
|
20
20
|
-keepclassmembers class com.facebook.react.ReactInstanceManager {
|
|
21
21
|
private final ** mBundleLoader;
|
|
22
22
|
}
|
|
23
|
-
-keepclassmembers class com.facebook.react.ReactDelegate {
|
|
24
|
-
private ** mReactHost; # bridgeless
|
|
25
|
-
public void reload(...); # RN 0.74 and above
|
|
26
|
-
}
|
|
27
23
|
# bridgeless
|
|
28
24
|
-keepclassmembers class com.facebook.react.defaults.DefaultReactHostDelegate {
|
|
29
25
|
private ** jsBundleLoader;
|
|
30
26
|
}
|
|
31
27
|
# bridgeless
|
|
32
28
|
-keepclassmembers class com.facebook.react.runtime.ReactHostImpl {
|
|
33
|
-
private final ** mReactHostDelegate;
|
|
29
|
+
private final ** mReactHostDelegate; # RN < 0.81
|
|
30
|
+
private final ** reactHostDelegate; # RN 0.81+
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
# Can't find referenced class org.bouncycastle.**
|
|
@@ -12,8 +12,8 @@ import androidx.annotation.OptIn;
|
|
|
12
12
|
|
|
13
13
|
import com.facebook.react.ReactDelegate;
|
|
14
14
|
import com.facebook.react.ReactHost;
|
|
15
|
-
import com.facebook.react.ReactInstanceManager;
|
|
16
15
|
import com.facebook.react.ReactActivity;
|
|
16
|
+
import com.facebook.react.ReactInstanceManager;
|
|
17
17
|
import com.facebook.react.ReactRootView;
|
|
18
18
|
import com.facebook.react.bridge.Arguments;
|
|
19
19
|
import com.facebook.react.bridge.JSBundleLoader;
|
|
@@ -126,7 +126,9 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
126
126
|
|
|
127
127
|
ReactHost reactHost = resolveReactHost();
|
|
128
128
|
if (reactHost == null) {
|
|
129
|
+
CodePushUtils.log("Unable to resolve ReactHost");
|
|
129
130
|
// Bridge, Old Architecture
|
|
131
|
+
setJSBundleLoaderBridge(latestJSBundleLoader);
|
|
130
132
|
return;
|
|
131
133
|
}
|
|
132
134
|
|
|
@@ -138,11 +140,27 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
142
|
|
|
143
|
+
private void setJSBundleLoaderBridge(JSBundleLoader latestJSBundleLoader) throws NoSuchFieldException, IllegalAccessException {
|
|
144
|
+
ReactDelegate reactDelegate = resolveReactDelegate();
|
|
145
|
+
assert reactDelegate != null;
|
|
146
|
+
ReactInstanceManager instanceManager = reactDelegate.getReactInstanceManager();
|
|
147
|
+
Field bundleLoaderField = instanceManager.getClass().getDeclaredField("mBundleLoader");
|
|
148
|
+
bundleLoaderField.setAccessible(true);
|
|
149
|
+
bundleLoaderField.set(instanceManager, latestJSBundleLoader);
|
|
150
|
+
}
|
|
151
|
+
|
|
141
152
|
@OptIn(markerClass = UnstableReactNativeAPI.class)
|
|
142
153
|
private void setJSBundleLoaderBridgeless(ReactHost reactHost, JSBundleLoader latestJSBundleLoader) throws NoSuchFieldException, IllegalAccessException {
|
|
143
|
-
Field
|
|
144
|
-
|
|
145
|
-
|
|
154
|
+
Field reactHostDelegateField;
|
|
155
|
+
try {
|
|
156
|
+
// RN < 0.81
|
|
157
|
+
reactHostDelegateField = reactHost.getClass().getDeclaredField("mReactHostDelegate");
|
|
158
|
+
} catch (NoSuchFieldException e) {
|
|
159
|
+
// RN >= 0.81
|
|
160
|
+
reactHostDelegateField = reactHost.getClass().getDeclaredField("reactHostDelegate");
|
|
161
|
+
}
|
|
162
|
+
reactHostDelegateField.setAccessible(true);
|
|
163
|
+
ReactHostDelegate reactHostDelegate = (ReactHostDelegate) reactHostDelegateField.get(reactHost);
|
|
146
164
|
assert reactHostDelegate != null;
|
|
147
165
|
Field jsBundleLoaderField = reactHostDelegate.getClass().getDeclaredField("jsBundleLoader");
|
|
148
166
|
jsBundleLoaderField.setAccessible(true);
|
|
@@ -216,16 +234,11 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
216
234
|
private ReactHost resolveReactHost() {
|
|
217
235
|
ReactDelegate reactDelegate = resolveReactDelegate();
|
|
218
236
|
if (reactDelegate == null) {
|
|
237
|
+
CodePushUtils.log("Unable to resolve ReactDelegate");
|
|
219
238
|
return null;
|
|
220
239
|
}
|
|
221
240
|
|
|
222
|
-
|
|
223
|
-
Field reactHostField = reactDelegate.getClass().getDeclaredField("mReactHost");
|
|
224
|
-
reactHostField.setAccessible(true);
|
|
225
|
-
return (ReactHost) reactHostField.get(reactDelegate);
|
|
226
|
-
} catch (Exception e) {
|
|
227
|
-
return null;
|
|
228
|
-
}
|
|
241
|
+
return reactDelegate.getReactHost();
|
|
229
242
|
}
|
|
230
243
|
|
|
231
244
|
private void restartAppInternal(boolean onlyIfUpdateIsPending) {
|