Skip to content

Commit 40742e1

Browse files
committed
fix expo reload
1 parent 598ae1a commit 40742e1

File tree

3 files changed

+36
-37
lines changed

3 files changed

+36
-37
lines changed

android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,13 @@ public void run() {
152152
reactHostDelegateField.setAccessible(true);
153153
Object reactHostDelegate = reactHostDelegateField.get(reactHost);
154154

155+
String bundleFieldName = "jsBundleLoader";
156+
if (reactHostDelegate.getClass().getCanonicalName().equals("expo.modules.ExpoReactHostFactory.ExpoReactHostDelegate")) {
157+
bundleFieldName = "_jsBundleLoader";
158+
}
159+
155160
// Modify the jsBundleLoader field
156-
Field jsBundleLoaderField = reactHostDelegate.getClass().getDeclaredField("jsBundleLoader");
161+
Field jsBundleLoaderField = reactHostDelegate.getClass().getDeclaredField(bundleFieldName);
157162
jsBundleLoaderField.setAccessible(true);
158163
jsBundleLoaderField.set(reactHostDelegate, loader);
159164

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-update",
3-
"version": "10.29.0-beta.2",
3+
"version": "10.29.0",
44
"description": "react-native hot update",
55
"main": "src/index",
66
"scripts": {

src/client.ts

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
import { CheckResult, ClientOptions, ProgressData, EventType } from './type';
2-
import {
3-
assertWeb,
4-
emptyObj,
5-
enhancedFetch,
6-
joinUrls,
7-
log,
8-
noop,
9-
promiseAny,
10-
testUrls,
11-
} from './utils';
121
import {
2+
DeviceEventEmitter,
133
EmitterSubscription,
144
Platform,
15-
DeviceEventEmitter,
165
} from 'react-native';
17-
import { PermissionsAndroid } from './permissions';
186
import {
197
PushyModule,
208
buildTime,
219
cInfo,
22-
pushyNativeEventEmitter,
2310
currentVersion,
11+
getCurrentVersionInfo,
12+
isFirstTime,
13+
isRolledBack,
2414
packageVersion,
15+
pushyNativeEventEmitter,
2516
rolledBackVersion,
2617
setLocalHashInfo,
27-
isFirstTime,
28-
isRolledBack,
29-
getCurrentVersionInfo,
3018
} from './core';
19+
import { PermissionsAndroid } from './permissions';
20+
import { CheckResult, ClientOptions, EventType, ProgressData } from './type';
21+
import {
22+
assertWeb,
23+
emptyObj,
24+
enhancedFetch,
25+
joinUrls,
26+
log,
27+
noop,
28+
promiseAny,
29+
testUrls,
30+
} from './utils';
3131

3232
const SERVER_PRESETS = {
3333
// cn
@@ -395,7 +395,7 @@ export class Pushy {
395395
let lastError: any;
396396
let errorMessages: string[] = [];
397397
const diffUrl = await testUrls(joinUrls(paths, diff));
398-
if (diffUrl) {
398+
if (diffUrl && !__DEV__) {
399399
log('downloading diff');
400400
try {
401401
await PushyModule.downloadPatchFromPpk({
@@ -408,16 +408,12 @@ export class Pushy {
408408
const errorMessage = `diff error: ${e.message}`;
409409
errorMessages.push(errorMessage);
410410
lastError = new Error(errorMessage);
411-
if (__DEV__) {
412-
succeeded = 'diff';
413-
} else {
414-
log(errorMessage);
415-
}
411+
log(errorMessage);
416412
}
417413
}
418414
if (!succeeded) {
419415
const pdiffUrl = await testUrls(joinUrls(paths, pdiff));
420-
if (pdiffUrl) {
416+
if (pdiffUrl && !__DEV__) {
421417
log('downloading pdiff');
422418
try {
423419
await PushyModule.downloadPatchFromPackage({
@@ -429,12 +425,7 @@ export class Pushy {
429425
const errorMessage = `pdiff error: ${e.message}`;
430426
errorMessages.push(errorMessage);
431427
lastError = new Error(errorMessage);
432-
if (__DEV__ && !full) {
433-
succeeded = 'pdiff';
434-
log('当前是开发环境,无法执行增量式热更新。如果需要在开发环境中测试全量热更新,请打开“忽略时间戳”开关再重试。');
435-
} else {
436-
log(errorMessage);
437-
}
428+
log(errorMessage);
438429
}
439430
}
440431
}
@@ -452,12 +443,15 @@ export class Pushy {
452443
const errorMessage = `full patch error: ${e.message}`;
453444
errorMessages.push(errorMessage);
454445
lastError = new Error(errorMessage);
455-
if (__DEV__) {
456-
succeeded = 'full';
457-
} else {
458-
log(errorMessage);
459-
}
446+
log(errorMessage);
460447
}
448+
} else if (__DEV__) {
449+
log(
450+
`当前是开发环境,无法执行增量式热更新,重启不会生效。
451+
如果需要在开发环境中测试可生效的全量热更新(但也会在再次重启后重新连接 metro),
452+
请打开“忽略时间戳”开关再重试。`,
453+
);
454+
succeeded = 'full';
461455
}
462456
}
463457
if (sharedState.progressHandlers[hash]) {

0 commit comments

Comments
 (0)