@bravemobile/react-native-code-push 12.3.0 → 12.3.2
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 +1 -1
- package/android/app/proguard-rules.pro +5 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +32 -8
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +0 -5
- package/expo/plugin/withCodePushAndroid.js +15 -16
- package/ios/CodePush/CodePush.m +23 -2
- package/package.json +11 -28
package/README.md
CHANGED
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
private ** jsBundleLoader;
|
|
26
26
|
}
|
|
27
27
|
# bridgeless
|
|
28
|
+
-keepclassmembers class * extends com.facebook.react.runtime.ReactHostDelegate {
|
|
29
|
+
private ** jsBundleLoader;
|
|
30
|
+
private ** _jsBundleLoader;
|
|
31
|
+
}
|
|
32
|
+
# bridgeless
|
|
28
33
|
-keepclassmembers class com.facebook.react.runtime.ReactHostImpl {
|
|
29
34
|
private final ** mReactHostDelegate; # RN < 0.81
|
|
30
35
|
private final ** reactHostDelegate; # RN 0.81+
|
|
@@ -151,18 +151,31 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
151
151
|
|
|
152
152
|
@OptIn(markerClass = UnstableReactNativeAPI.class)
|
|
153
153
|
private void setJSBundleLoaderBridgeless(ReactHost reactHost, JSBundleLoader latestJSBundleLoader) throws NoSuchFieldException, IllegalAccessException {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
reactHostDelegateField = reactHost.getClass().getDeclaredField("mReactHostDelegate");
|
|
158
|
-
} catch (NoSuchFieldException e) {
|
|
154
|
+
// RN < 0.81
|
|
155
|
+
Field reactHostDelegateField = resolveDeclaredField(reactHost.getClass(), "mReactHostDelegate");
|
|
156
|
+
if (reactHostDelegateField == null) {
|
|
159
157
|
// RN >= 0.81
|
|
160
|
-
reactHostDelegateField = reactHost.getClass()
|
|
158
|
+
reactHostDelegateField = resolveDeclaredField(reactHost.getClass(), "reactHostDelegate");
|
|
159
|
+
}
|
|
160
|
+
if (reactHostDelegateField == null) {
|
|
161
|
+
throw new NoSuchFieldException("Unable to resolve ReactHostDelegate field.");
|
|
161
162
|
}
|
|
163
|
+
|
|
162
164
|
reactHostDelegateField.setAccessible(true);
|
|
163
165
|
ReactHostDelegate reactHostDelegate = (ReactHostDelegate) reactHostDelegateField.get(reactHost);
|
|
164
166
|
assert reactHostDelegate != null;
|
|
165
|
-
|
|
167
|
+
|
|
168
|
+
// Expo ReactHost delegate keeps this mutable backing field specifically
|
|
169
|
+
// so integrations can override the bundle loader at runtime.
|
|
170
|
+
Field jsBundleLoaderField = resolveDeclaredField(reactHostDelegate.getClass(), "_jsBundleLoader");
|
|
171
|
+
if (jsBundleLoaderField == null) {
|
|
172
|
+
// Fallback for non-Expo delegates.
|
|
173
|
+
jsBundleLoaderField = resolveDeclaredField(reactHostDelegate.getClass(), "jsBundleLoader");
|
|
174
|
+
}
|
|
175
|
+
if (jsBundleLoaderField == null) {
|
|
176
|
+
throw new NoSuchFieldException("Unable to resolve JSBundleLoader field.");
|
|
177
|
+
}
|
|
178
|
+
|
|
166
179
|
jsBundleLoaderField.setAccessible(true);
|
|
167
180
|
jsBundleLoaderField.set(reactHostDelegate, latestJSBundleLoader);
|
|
168
181
|
}
|
|
@@ -234,13 +247,24 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
|
|
|
234
247
|
private ReactHost resolveReactHost() {
|
|
235
248
|
ReactDelegate reactDelegate = resolveReactDelegate();
|
|
236
249
|
if (reactDelegate == null) {
|
|
237
|
-
CodePushUtils.log("Unable to resolve ReactDelegate");
|
|
238
250
|
return null;
|
|
239
251
|
}
|
|
240
252
|
|
|
241
253
|
return reactDelegate.getReactHost();
|
|
242
254
|
}
|
|
243
255
|
|
|
256
|
+
private Field resolveDeclaredField(Class<?> targetClass, String fieldName) {
|
|
257
|
+
Class<?> cursor = targetClass;
|
|
258
|
+
while (cursor != null) {
|
|
259
|
+
try {
|
|
260
|
+
return cursor.getDeclaredField(fieldName);
|
|
261
|
+
} catch (NoSuchFieldException ignored) {
|
|
262
|
+
cursor = cursor.getSuperclass();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
|
|
244
268
|
private void restartAppInternal(boolean onlyIfUpdateIsPending) {
|
|
245
269
|
if (this._restartInProgress) {
|
|
246
270
|
CodePushUtils.log("Restart request queued until the current restart is completed");
|
|
@@ -149,11 +149,6 @@ public class CodePushUpdateUtils {
|
|
|
149
149
|
try {
|
|
150
150
|
return CodePushUtils.getStringFromInputStream(context.getAssets().open(CodePushConstants.CODE_PUSH_OLD_HASH_FILE_NAME));
|
|
151
151
|
} catch (IOException ex) {
|
|
152
|
-
if (!isDebugMode) {
|
|
153
|
-
// Only print this message in "Release" mode. In "Debug", we may not have the
|
|
154
|
-
// hash if the build skips bundling the files.
|
|
155
|
-
CodePushUtils.log("Unable to get the hash of the binary's bundled resources - \"codepush.gradle\" may have not been added to the build definition.");
|
|
156
|
-
}
|
|
157
152
|
}
|
|
158
153
|
return null;
|
|
159
154
|
}
|
|
@@ -28,11 +28,9 @@ function androidMainApplicationApplyImplementation(mainApplication, find, add, r
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function addJsBundleFilePathArgument(mainApplication) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const packageListArgumentPattern = /(packageList\s*=\s*\n\s*PackageList\(this\)[\s\S]+?\},?\s*\n)/;
|
|
31
|
+
// Capture packageList block plus optional existing jsBundleFilePath line.
|
|
32
|
+
// This allows us to normalize comma placement before injecting the new argument.
|
|
33
|
+
const packageListArgumentPattern = /(packageList\s*=\s*\n\s*PackageList\(this\)[\s\S]+?\},?\s*\n)(\s*jsBundleFilePath\s*=\s*CodePush\.getJSBundleFile\(\),\s*\n)?/;
|
|
36
34
|
|
|
37
35
|
if (!packageListArgumentPattern.test(mainApplication)) {
|
|
38
36
|
WarningAggregator.addWarningAndroid(
|
|
@@ -47,12 +45,15 @@ function addJsBundleFilePathArgument(mainApplication) {
|
|
|
47
45
|
return mainApplication;
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
return mainApplication.replace(packageListArgumentPattern, (match) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
return mainApplication.replace(packageListArgumentPattern, (match, packageListArgument, existingJsBundleArgument) => {
|
|
49
|
+
const trimmedMatch = packageListArgument.replace(/\s+$/, '');
|
|
50
|
+
// Kotlin call args need a trailing comma before the next named argument.
|
|
51
|
+
const hasTrailingComma = /,\s*$/.test(trimmedMatch);
|
|
52
|
+
const packageListArgumentWithComma = hasTrailingComma ? trimmedMatch : `${trimmedMatch},`;
|
|
53
|
+
const jsBundleArgument = existingJsBundleArgument
|
|
54
|
+
? existingJsBundleArgument.replace(/\s+$/, '')
|
|
55
|
+
: ` ${JS_BUNDLE_FILE_PATH_ARGUMENT},`;
|
|
56
|
+
return `${packageListArgumentWithComma}\n${jsBundleArgument}\n`;
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
59
|
|
|
@@ -64,10 +65,9 @@ const withAndroidMainApplicationDependency = (config) => {
|
|
|
64
65
|
IMPORT_CODE_PUSH,
|
|
65
66
|
);
|
|
66
67
|
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
} else {
|
|
68
|
+
if (action.modResults.contents.includes(RN_082_MARKER)) {
|
|
69
|
+
action.modResults.contents = addJsBundleFilePathArgument(action.modResults.contents);
|
|
70
|
+
} else if (!action.modResults.contents.includes('CodePush.getJSBundleFile()')) {
|
|
71
71
|
// https://github.com/Soomgo-Mobile/react-native-code-push/issues/97
|
|
72
72
|
const isExpoSDK54 = config.sdkVersion?.startsWith('54.') ?? false;
|
|
73
73
|
const addingCode = isExpoSDK54
|
|
@@ -81,7 +81,6 @@ const withAndroidMainApplicationDependency = (config) => {
|
|
|
81
81
|
'object : DefaultReactNativeHost(this) {',
|
|
82
82
|
addingCode,
|
|
83
83
|
);
|
|
84
|
-
}
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
return action;
|
package/ios/CodePush/CodePush.m
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
long long _latestExpectedContentLength;
|
|
33
33
|
long long _latestReceivedConentLength;
|
|
34
34
|
BOOL _didUpdateProgress;
|
|
35
|
+
NSTimeInterval _lastProgressEventTime;
|
|
35
36
|
|
|
36
37
|
BOOL _allowed;
|
|
37
38
|
BOOL _restartInProgress;
|
|
@@ -336,6 +337,18 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
336
337
|
}];
|
|
337
338
|
}
|
|
338
339
|
|
|
340
|
+
- (void)dispatchThrottledDownloadProgressEventWithForce:(BOOL)force
|
|
341
|
+
{
|
|
342
|
+
static const NSTimeInterval interval = 0.05; // 50 ms throttle
|
|
343
|
+
NSTimeInterval now = CFAbsoluteTimeGetCurrent();
|
|
344
|
+
if (!force && _lastProgressEventTime > 0 && (now - _lastProgressEventTime) < interval) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
_lastProgressEventTime = now;
|
|
349
|
+
[self dispatchDownloadProgressEvent];
|
|
350
|
+
}
|
|
351
|
+
|
|
339
352
|
/*
|
|
340
353
|
* This method ensures that the app was packaged with a JS bundle
|
|
341
354
|
* file, and if not, it throws the appropriate exception.
|
|
@@ -377,6 +390,7 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
377
390
|
_allowed = YES;
|
|
378
391
|
_restartInProgress = NO;
|
|
379
392
|
_restartQueue = [NSMutableArray arrayWithCapacity:1];
|
|
393
|
+
_lastProgressEventTime = 0;
|
|
380
394
|
|
|
381
395
|
self = [super init];
|
|
382
396
|
if (self) {
|
|
@@ -723,6 +737,7 @@ RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary*)updatePackage
|
|
|
723
737
|
// progress events every frame if the progress is updated.
|
|
724
738
|
_didUpdateProgress = NO;
|
|
725
739
|
self.paused = NO;
|
|
740
|
+
_lastProgressEventTime = 0;
|
|
726
741
|
}
|
|
727
742
|
|
|
728
743
|
NSString * publicKey = [[CodePushConfig current] publicKey];
|
|
@@ -738,13 +753,19 @@ RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary*)updatePackage
|
|
|
738
753
|
_latestExpectedContentLength = expectedContentLength;
|
|
739
754
|
_latestReceivedConentLength = receivedContentLength;
|
|
740
755
|
_didUpdateProgress = YES;
|
|
756
|
+
// Fabric/TurboModules don't hook RCTFrameUpdateObserver, so _pauseCallback
|
|
757
|
+
// stays nil there and we must emit progress events directly.
|
|
758
|
+
// On the legacy bridge _pauseCallback is set, and didUpdateFrame handles dispatch.
|
|
759
|
+
if (!_pauseCallback) {
|
|
760
|
+
[self dispatchThrottledDownloadProgressEventWithForce:NO];
|
|
761
|
+
}
|
|
741
762
|
|
|
742
763
|
// If the download is completed, stop observing frame
|
|
743
764
|
// updates and synchronously send the last event.
|
|
744
765
|
if (expectedContentLength == receivedContentLength) {
|
|
745
766
|
_didUpdateProgress = NO;
|
|
746
767
|
self.paused = YES;
|
|
747
|
-
[self
|
|
768
|
+
[self dispatchThrottledDownloadProgressEventWithForce:YES];
|
|
748
769
|
}
|
|
749
770
|
}
|
|
750
771
|
// The download completed
|
|
@@ -1115,7 +1136,7 @@ RCT_EXPORT_METHOD(saveStatusReportForRetry:(NSDictionary *)statusReport)
|
|
|
1115
1136
|
return;
|
|
1116
1137
|
}
|
|
1117
1138
|
|
|
1118
|
-
[self
|
|
1139
|
+
[self dispatchThrottledDownloadProgressEventWithForce:YES];
|
|
1119
1140
|
_didUpdateProgress = NO;
|
|
1120
1141
|
}
|
|
1121
1142
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bravemobile/react-native-code-push",
|
|
3
|
-
"version": "12.3.
|
|
3
|
+
"version": "12.3.2",
|
|
4
4
|
"description": "React Native plugin for the CodePush service",
|
|
5
5
|
"main": "src/CodePush.js",
|
|
6
6
|
"react-native": "src/CodePush.js",
|
|
@@ -52,24 +52,18 @@
|
|
|
52
52
|
],
|
|
53
53
|
"scripts": {
|
|
54
54
|
"setup": "npm install --quiet --no-progress",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"test:ios": "npm run build:tests && npm run test:setup:ios && npm run test:fast:ios",
|
|
58
|
-
"test:setup": "mocha --recursive bin/test --android --ios --setup",
|
|
59
|
-
"test:setup:android": "mocha --recursive bin/test --android --setup",
|
|
60
|
-
"test:setup:ios": "mocha --recursive bin/test --ios --setup",
|
|
61
|
-
"test:fast": "mocha --recursive bin/test --android --ios",
|
|
62
|
-
"test:fast:android": "mocha --recursive bin/test --android",
|
|
63
|
-
"test:fast:ios": "mocha --recursive bin/test --ios",
|
|
64
|
-
"test:debugger:android": "mocha --recursive --inspect-brk=0.0.0.0 bin/test --android",
|
|
65
|
-
"test:debugger:ios": "mocha --recursive --inspect-brk=0.0.0.0 bin/test --ios",
|
|
66
|
-
"tslint": "tslint -c tslint.json test/**/*.ts",
|
|
55
|
+
"setup-example-app": "ts-node --project scripts/setupExampleApp/tsconfig.json scripts/setupExampleApp/runSetupExampleApp.ts",
|
|
56
|
+
"setup-expo-example-app": "ts-node --project scripts/setupExampleApp/tsconfig.json scripts/setupExpoExampleApp/runSetupExpoExampleApp.ts",
|
|
67
57
|
"type:cli": "npm run --workspace cli typecheck",
|
|
58
|
+
"type:scripts": "tsc --project scripts/tsconfig.json --noEmit",
|
|
59
|
+
"type:e2e": "tsc --project e2e/tsconfig.json --noEmit",
|
|
60
|
+
"typecheck": "npm run type:cli && npm run type:scripts && npm run type:e2e",
|
|
68
61
|
"build:cli": "npm run --workspace cli clean && npm run --workspace cli build",
|
|
69
62
|
"prepack": "npm run build:cli",
|
|
70
63
|
"publish": "npm publish --access=public",
|
|
71
64
|
"eslint": "eslint --quiet .",
|
|
72
|
-
"jest": "jest src/versioning/* expo/* && npm run --workspace cli test"
|
|
65
|
+
"jest": "jest src/versioning/* expo/* && npm run --workspace cli test",
|
|
66
|
+
"e2e": "ts-node --project e2e/tsconfig.json e2e/run.ts"
|
|
73
67
|
},
|
|
74
68
|
"repository": {
|
|
75
69
|
"type": "git",
|
|
@@ -81,8 +75,8 @@
|
|
|
81
75
|
"semver": "^7.3.5",
|
|
82
76
|
"shelljs": "^0.10.0",
|
|
83
77
|
"xcode": "^3.0.1",
|
|
84
|
-
"
|
|
85
|
-
"
|
|
78
|
+
"yauzl": "^3.2.0",
|
|
79
|
+
"yazl": "^3.3.1"
|
|
86
80
|
},
|
|
87
81
|
"peerDependencies": {
|
|
88
82
|
"expo": ">=50.0.0",
|
|
@@ -98,29 +92,18 @@
|
|
|
98
92
|
"@babel/preset-env": "^7.26.0",
|
|
99
93
|
"@babel/preset-typescript": "^7.27.1",
|
|
100
94
|
"@eslint/js": "^9.13.0",
|
|
101
|
-
"@types/
|
|
102
|
-
"@types/mkdirp": "^1.0.1",
|
|
103
|
-
"@types/mocha": "^9.0.0",
|
|
95
|
+
"@types/express": "^5.0.6",
|
|
104
96
|
"@types/node": "^18.19.129",
|
|
105
|
-
"@types/q": "^1.5.4",
|
|
106
97
|
"@types/semver": "^7.5.8",
|
|
107
98
|
"@types/shelljs": "^0.8.15",
|
|
108
99
|
"@types/yauzl": "^2.10.3",
|
|
109
|
-
"archiver": "latest",
|
|
110
100
|
"babel-jest": "^29.7.0",
|
|
111
|
-
"body-parser": "latest",
|
|
112
|
-
"code-push-plugin-testing-framework": "file:./code-push-plugin-testing-framework",
|
|
113
101
|
"eslint": "^9.13.0",
|
|
114
102
|
"eslint-plugin-react": "^7.37.2",
|
|
115
103
|
"express": "latest",
|
|
116
104
|
"globals": "^15.11.0",
|
|
117
105
|
"jest": "^29.7.0",
|
|
118
|
-
"mkdirp": "latest",
|
|
119
|
-
"mocha": "^9.2.0",
|
|
120
|
-
"q": "^1.5.1",
|
|
121
|
-
"slash": "^3.0.0",
|
|
122
106
|
"ts-node": "^10.9.2",
|
|
123
|
-
"tslint": "^6.1.3",
|
|
124
107
|
"typescript": "5.0.4",
|
|
125
108
|
"typescript-eslint": "^8.11.0"
|
|
126
109
|
},
|