mirror of
				https://gitcode.com/gh_mirrors/re/react-native-pushy.git
				synced 2025-10-31 21:33:12 +08:00 
			
		
		
		
	fix expo reload
This commit is contained in:
		| @@ -152,8 +152,13 @@ public class UpdateModuleImpl { | |||||||
|                         reactHostDelegateField.setAccessible(true); |                         reactHostDelegateField.setAccessible(true); | ||||||
|                         Object reactHostDelegate = reactHostDelegateField.get(reactHost); |                         Object reactHostDelegate = reactHostDelegateField.get(reactHost); | ||||||
|  |  | ||||||
|  |                         String bundleFieldName = "jsBundleLoader"; | ||||||
|  |                         if (reactHostDelegate.getClass().getCanonicalName().equals("expo.modules.ExpoReactHostFactory.ExpoReactHostDelegate")) { | ||||||
|  |                             bundleFieldName = "_jsBundleLoader"; | ||||||
|  |                         } | ||||||
|  |  | ||||||
|                         // Modify the jsBundleLoader field |                         // Modify the jsBundleLoader field | ||||||
|                         Field jsBundleLoaderField = reactHostDelegate.getClass().getDeclaredField("jsBundleLoader"); |                         Field jsBundleLoaderField = reactHostDelegate.getClass().getDeclaredField(bundleFieldName); | ||||||
|                         jsBundleLoaderField.setAccessible(true); |                         jsBundleLoaderField.setAccessible(true); | ||||||
|                         jsBundleLoaderField.set(reactHostDelegate, loader); |                         jsBundleLoaderField.set(reactHostDelegate, loader); | ||||||
|                          |                          | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "react-native-update", |   "name": "react-native-update", | ||||||
|   "version": "10.29.0-beta.2", |   "version": "10.29.0", | ||||||
|   "description": "react-native hot update", |   "description": "react-native hot update", | ||||||
|   "main": "src/index", |   "main": "src/index", | ||||||
|   "scripts": { |   "scripts": { | ||||||
|   | |||||||
| @@ -1,4 +1,23 @@ | |||||||
| import { CheckResult, ClientOptions, ProgressData, EventType } from './type'; | import { | ||||||
|  |   DeviceEventEmitter, | ||||||
|  |   EmitterSubscription, | ||||||
|  |   Platform, | ||||||
|  | } from 'react-native'; | ||||||
|  | import { | ||||||
|  |   PushyModule, | ||||||
|  |   buildTime, | ||||||
|  |   cInfo, | ||||||
|  |   currentVersion, | ||||||
|  |   getCurrentVersionInfo, | ||||||
|  |   isFirstTime, | ||||||
|  |   isRolledBack, | ||||||
|  |   packageVersion, | ||||||
|  |   pushyNativeEventEmitter, | ||||||
|  |   rolledBackVersion, | ||||||
|  |   setLocalHashInfo, | ||||||
|  | } from './core'; | ||||||
|  | import { PermissionsAndroid } from './permissions'; | ||||||
|  | import { CheckResult, ClientOptions, EventType, ProgressData } from './type'; | ||||||
| import { | import { | ||||||
|   assertWeb, |   assertWeb, | ||||||
|   emptyObj, |   emptyObj, | ||||||
| @@ -9,25 +28,6 @@ import { | |||||||
|   promiseAny, |   promiseAny, | ||||||
|   testUrls, |   testUrls, | ||||||
| } from './utils'; | } from './utils'; | ||||||
| import { |  | ||||||
|   EmitterSubscription, |  | ||||||
|   Platform, |  | ||||||
|   DeviceEventEmitter, |  | ||||||
| } from 'react-native'; |  | ||||||
| import { PermissionsAndroid } from './permissions'; |  | ||||||
| import { |  | ||||||
|   PushyModule, |  | ||||||
|   buildTime, |  | ||||||
|   cInfo, |  | ||||||
|   pushyNativeEventEmitter, |  | ||||||
|   currentVersion, |  | ||||||
|   packageVersion, |  | ||||||
|   rolledBackVersion, |  | ||||||
|   setLocalHashInfo, |  | ||||||
|   isFirstTime, |  | ||||||
|   isRolledBack, |  | ||||||
|   getCurrentVersionInfo, |  | ||||||
| } from './core'; |  | ||||||
|  |  | ||||||
| const SERVER_PRESETS = { | const SERVER_PRESETS = { | ||||||
|   // cn |   // cn | ||||||
| @@ -395,7 +395,7 @@ export class Pushy { | |||||||
|     let lastError: any; |     let lastError: any; | ||||||
|     let errorMessages: string[] = []; |     let errorMessages: string[] = []; | ||||||
|     const diffUrl = await testUrls(joinUrls(paths, diff)); |     const diffUrl = await testUrls(joinUrls(paths, diff)); | ||||||
|     if (diffUrl) { |     if (diffUrl && !__DEV__) { | ||||||
|       log('downloading diff'); |       log('downloading diff'); | ||||||
|       try { |       try { | ||||||
|         await PushyModule.downloadPatchFromPpk({ |         await PushyModule.downloadPatchFromPpk({ | ||||||
| @@ -408,16 +408,12 @@ export class Pushy { | |||||||
|         const errorMessage = `diff error: ${e.message}`; |         const errorMessage = `diff error: ${e.message}`; | ||||||
|         errorMessages.push(errorMessage); |         errorMessages.push(errorMessage); | ||||||
|         lastError = new Error(errorMessage); |         lastError = new Error(errorMessage); | ||||||
|         if (__DEV__) { |         log(errorMessage); | ||||||
|           succeeded = 'diff'; |  | ||||||
|         } else { |  | ||||||
|           log(errorMessage); |  | ||||||
|         } |  | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     if (!succeeded) { |     if (!succeeded) { | ||||||
|       const pdiffUrl = await testUrls(joinUrls(paths, pdiff)); |       const pdiffUrl = await testUrls(joinUrls(paths, pdiff)); | ||||||
|       if (pdiffUrl) { |       if (pdiffUrl && !__DEV__) { | ||||||
|         log('downloading pdiff'); |         log('downloading pdiff'); | ||||||
|         try { |         try { | ||||||
|           await PushyModule.downloadPatchFromPackage({ |           await PushyModule.downloadPatchFromPackage({ | ||||||
| @@ -429,12 +425,7 @@ export class Pushy { | |||||||
|           const errorMessage = `pdiff error: ${e.message}`; |           const errorMessage = `pdiff error: ${e.message}`; | ||||||
|           errorMessages.push(errorMessage); |           errorMessages.push(errorMessage); | ||||||
|           lastError = new Error(errorMessage); |           lastError = new Error(errorMessage); | ||||||
|           if (__DEV__ && !full) { |           log(errorMessage); | ||||||
|             succeeded = 'pdiff'; |  | ||||||
|             log('当前是开发环境,无法执行增量式热更新。如果需要在开发环境中测试全量热更新,请打开“忽略时间戳”开关再重试。'); |  | ||||||
|           } else { |  | ||||||
|             log(errorMessage); |  | ||||||
|           } |  | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
| @@ -452,12 +443,15 @@ export class Pushy { | |||||||
|           const errorMessage = `full patch error: ${e.message}`; |           const errorMessage = `full patch error: ${e.message}`; | ||||||
|           errorMessages.push(errorMessage); |           errorMessages.push(errorMessage); | ||||||
|           lastError = new Error(errorMessage); |           lastError = new Error(errorMessage); | ||||||
|           if (__DEV__) { |           log(errorMessage); | ||||||
|             succeeded = 'full'; |  | ||||||
|           } else { |  | ||||||
|             log(errorMessage); |  | ||||||
|           } |  | ||||||
|         } |         } | ||||||
|  |       } else if (__DEV__) { | ||||||
|  |         log( | ||||||
|  |           `当前是开发环境,无法执行增量式热更新,重启不会生效。 | ||||||
|  |           如果需要在开发环境中测试可生效的全量热更新(但也会在再次重启后重新连接 metro), | ||||||
|  |           请打开“忽略时间戳”开关再重试。`, | ||||||
|  |         ); | ||||||
|  |         succeeded = 'full'; | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     if (sharedState.progressHandlers[hash]) { |     if (sharedState.progressHandlers[hash]) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 sunnylqm
					sunnylqm