@bravemobile/react-native-code-push 12.1.2 → 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 +3 -0
- package/android/app/proguard-rules.pro +2 -5
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +24 -11
- package/cli/commands/initCommand/initAndroid.ts +1 -1
- package/cli/dist/commands/initCommand/initAndroid.js +1 -1
- package/expo/plugin/withCodePushAndroid.js +12 -3
- package/package.json +2 -2
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) {
|
|
@@ -44,7 +44,7 @@ export function modifyMainApplicationKt(mainApplicationContent: string) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
function addJsBundleFilePathArgument(mainApplicationContent: string) {
|
|
47
|
-
const packageListArgumentPattern = /(packageList\s*=\s*\n\s*PackageList\(this\)[\s\S]+?\}
|
|
47
|
+
const packageListArgumentPattern = /(packageList\s*=\s*\n\s*PackageList\(this\)[\s\S]+?\},?\s*\n)/;
|
|
48
48
|
|
|
49
49
|
if (!packageListArgumentPattern.test(mainApplicationContent)) {
|
|
50
50
|
console.log('log: Could not find packageList argument while updating MainApplication.kt.');
|
|
@@ -34,7 +34,7 @@ export function modifyMainApplicationKt(mainApplicationContent) {
|
|
|
34
34
|
throw new Error('Unsupported MainApplication.kt structure.');
|
|
35
35
|
}
|
|
36
36
|
function addJsBundleFilePathArgument(mainApplicationContent) {
|
|
37
|
-
const packageListArgumentPattern = /(packageList\s*=\s*\n\s*PackageList\(this\)[\s\S]+?\}
|
|
37
|
+
const packageListArgumentPattern = /(packageList\s*=\s*\n\s*PackageList\(this\)[\s\S]+?\},?\s*\n)/;
|
|
38
38
|
if (!packageListArgumentPattern.test(mainApplicationContent)) {
|
|
39
39
|
console.log('log: Could not find packageList argument while updating MainApplication.kt.');
|
|
40
40
|
return mainApplicationContent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { withMainApplication, WarningAggregator } = require('expo/config-plugins');
|
|
2
2
|
|
|
3
3
|
const IMPORT_CODE_PUSH = 'import com.microsoft.codepush.react.CodePush';
|
|
4
|
-
const RN_082_MARKER = '
|
|
4
|
+
const RN_082_MARKER = 'ExpoReactHostFactory.getDefaultReactHost(';
|
|
5
5
|
const JS_BUNDLE_FILE_PATH_ARGUMENT = 'jsBundleFilePath = CodePush.getJSBundleFile()';
|
|
6
6
|
|
|
7
7
|
function androidMainApplicationApplyImplementation(mainApplication, find, add, reverse = false) {
|
|
@@ -32,7 +32,7 @@ function addJsBundleFilePathArgument(mainApplication) {
|
|
|
32
32
|
return mainApplication;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const packageListArgumentPattern = /(packageList\s*=\s*\n\s*PackageList\(this\)[\s\S]+?\}
|
|
35
|
+
const packageListArgumentPattern = /(packageList\s*=\s*\n\s*PackageList\(this\)[\s\S]+?\},?\s*\n)/;
|
|
36
36
|
|
|
37
37
|
if (!packageListArgumentPattern.test(mainApplication)) {
|
|
38
38
|
WarningAggregator.addWarningAndroid(
|
|
@@ -68,10 +68,19 @@ const withAndroidMainApplicationDependency = (config) => {
|
|
|
68
68
|
if (action.modResults.contents.includes(RN_082_MARKER)) {
|
|
69
69
|
action.modResults.contents = addJsBundleFilePathArgument(action.modResults.contents);
|
|
70
70
|
} else {
|
|
71
|
+
// https://github.com/Soomgo-Mobile/react-native-code-push/issues/97
|
|
72
|
+
const isExpoSDK54 = config.sdkVersion?.startsWith('54.') ?? false;
|
|
73
|
+
const addingCode = isExpoSDK54
|
|
74
|
+
? ' override fun getJSBundleFile(): String {\n' +
|
|
75
|
+
' CodePush.getInstance(applicationContext, BuildConfig.DEBUG)\n' +
|
|
76
|
+
' return CodePush.getJSBundleFile()\n' +
|
|
77
|
+
' }\n'
|
|
78
|
+
: ' override fun getJSBundleFile(): String = CodePush.getJSBundleFile()\n';
|
|
71
79
|
action.modResults.contents = androidMainApplicationApplyImplementation(
|
|
72
80
|
action.modResults.contents,
|
|
73
81
|
'object : DefaultReactNativeHost(this) {',
|
|
74
|
-
|
|
82
|
+
addingCode,
|
|
83
|
+
);
|
|
75
84
|
}
|
|
76
85
|
}
|
|
77
86
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bravemobile/react-native-code-push",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.5",
|
|
4
4
|
"description": "React Native plugin for the CodePush service",
|
|
5
5
|
"main": "src/CodePush.js",
|
|
6
6
|
"react-native": "src/CodePush.js",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"prepack": "npm run build:cli",
|
|
70
70
|
"publish": "npm publish --access=public",
|
|
71
71
|
"eslint": "eslint --quiet .",
|
|
72
|
-
"jest": "jest src/versioning/* && npm run --workspace cli test"
|
|
72
|
+
"jest": "jest src/versioning/* expo/* && npm run --workspace cli test"
|
|
73
73
|
},
|
|
74
74
|
"repository": {
|
|
75
75
|
"type": "git",
|