@bravemobile/react-native-code-push 12.3.1 → 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 CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ### 🚀 New Architecture support
10
10
 
11
- Supports React Native 0.74 ~ 0.83.
11
+ Supports React Native 0.74 ~ 0.84.
12
12
 
13
13
  > [!NOTE]
14
14
  > If you are using React Native 0.76 or lower, please use version `12.0.2` of this library.
@@ -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
- Field reactHostDelegateField;
155
- try {
156
- // RN < 0.81
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().getDeclaredField("reactHostDelegate");
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
- Field jsBundleLoaderField = reactHostDelegate.getClass().getDeclaredField("jsBundleLoader");
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
- if (mainApplication.includes(JS_BUNDLE_FILE_PATH_ARGUMENT)) {
32
- return mainApplication;
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
- if (match.includes('jsBundleFilePath')) {
52
- return match;
53
- }
54
-
55
- return `${match} ${JS_BUNDLE_FILE_PATH_ARGUMENT},\n`;
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 (!action.modResults.contents.includes('CodePush.getJSBundleFile()')) {
68
- if (action.modResults.contents.includes(RN_082_MARKER)) {
69
- action.modResults.contents = addJsBundleFilePathArgument(action.modResults.contents);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bravemobile/react-native-code-push",
3
- "version": "12.3.1",
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
- "test": "npm run build:tests && npm run test:setup && npm run test:fast",
56
- "test:android": "npm run build:tests && npm run test:setup:android && npm run test:fast:android",
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
- "yazl": "^3.3.1",
85
- "yauzl": "^3.2.0"
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/assert": "^1.5.2",
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
  },