react-native-update 10.58.1 → 10.59.1
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-CN.md +7 -0
- package/README.md +8 -0
- package/android/build.gradle +46 -14
- package/android/jni/Android.mk +2 -1
- package/android/lib/arm64-v8a/librnpushy.so +0 -0
- package/android/lib/armeabi-v7a/librnpushy.so +0 -0
- package/android/lib/x86/librnpushy.so +0 -0
- package/android/lib/x86_64/librnpushy.so +0 -0
- package/android/src/main/java/cn/reactnative/modules/update/ApkInstaller.java +6 -6
- package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateResult.java → BundlePreparationResult.java} +6 -6
- package/android/src/main/java/cn/reactnative/modules/update/BundledResourceCopier.java +4 -4
- package/android/src/main/java/cn/reactnative/modules/update/{CrashRescue.java → CrashHold.java} +12 -12
- package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +28 -24
- package/android/src/main/java/cn/reactnative/modules/update/ErrorCodes.java +2 -1
- package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateFlow.java → FlowBridge.java} +6 -6
- package/android/src/main/java/cn/reactnative/modules/update/HttpUtils.java +6 -3
- package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateCore.java → NativeCore.java} +4 -4
- package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateConfig.java → PushyConfiguration.java} +13 -8
- package/android/src/main/java/cn/reactnative/modules/update/{PushyNativeUpdate.java → PushyRuntime.java} +15 -15
- package/android/src/main/java/cn/reactnative/modules/update/ReactReloadManager.java +7 -7
- package/android/src/main/java/cn/reactnative/modules/update/StateSerialRunner.java +1 -1
- package/android/src/main/java/cn/reactnative/modules/update/{NativeCheckOrchestrator.java → SyncCoordinator.java} +107 -103
- package/android/src/main/java/cn/reactnative/modules/update/Texts.java +28 -0
- package/android/src/main/java/cn/reactnative/modules/update/UiThreadRunner.java +1 -1
- package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +29 -29
- package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +12 -9
- package/cpp/patch_core/archive_limits.h +5 -0
- package/cpp/patch_core/archive_patch_core.cpp +26 -19
- package/cpp/patch_core/archive_patch_core.h +17 -8
- package/cpp/patch_core/digest.h +6 -1
- package/cpp/patch_core/error_codes.h +8 -1
- package/cpp/patch_core/hbc_transform.h +5 -0
- package/cpp/patch_core/hbc_transform_wire.h +5 -0
- package/cpp/patch_core/install_record.h +5 -0
- package/cpp/patch_core/jni_natives.h +27 -0
- package/cpp/patch_core/jni_registration.cpp +103 -0
- package/cpp/patch_core/obscured_text.h +44 -0
- package/cpp/patch_core/patch_core.cpp +13 -13
- package/cpp/patch_core/patch_core.h +11 -6
- package/cpp/patch_core/patch_core_android.cpp +10 -10
- package/cpp/patch_core/state_core.h +5 -0
- package/cpp/patch_core/state_ops.h +5 -0
- package/cpp/patch_core/update_core_android.cpp +23 -22
- package/cpp/update_flow_core/flow_json.h +6 -1
- package/cpp/update_flow_core/update_flow_core.cpp +35 -18
- package/cpp/update_flow_core/update_flow_core.h +13 -8
- package/cpp/update_flow_core/update_flow_jni.cpp +11 -13
- package/harmony/pushy/src/main/cpp/CMakeLists.txt +8 -8
- package/harmony/pushy/src/main/cpp/pushy.cpp +33 -33
- package/harmony/pushy/src/main/ets/ArchiveLimits.ts +15 -15
- package/harmony/pushy/src/main/ets/{NativeUpdateResult.ts → BundlePreparationResult.ts} +6 -6
- package/harmony/pushy/src/main/ets/DownloadTask.ts +60 -60
- package/harmony/pushy/src/main/ets/ErrorCodes.ts +13 -11
- package/harmony/pushy/src/main/ets/InstallRecord.ts +4 -4
- package/harmony/pushy/src/main/ets/NativePatchCore.ts +9 -9
- package/harmony/pushy/src/main/ets/PathUtils.ts +2 -2
- package/harmony/pushy/src/main/ets/{NativeUpdateConfig.ts → PushyConfiguration.ts} +12 -10
- package/harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets +8 -8
- package/harmony/pushy/src/main/ets/PushyTurboModule.ts +42 -41
- package/harmony/pushy/src/main/ets/{NativeCheckOrchestrator.ts → SyncCoordinator.ts} +71 -70
- package/harmony/pushy/src/main/ets/Texts.ts +28 -0
- package/harmony/pushy/src/main/ets/UpdateContext.ts +32 -31
- package/harmony/pushy.har +0 -0
- package/ios/RCTPushy/RCTPushy.h +8 -8
- package/ios/RCTPushy/RCTPushy.mm +155 -147
- package/ios/RCTPushy/RCTPushyConfiguration.h +13 -0
- package/ios/RCTPushy/{RCTPushyNativeConfig.mm → RCTPushyConfiguration.mm} +34 -7
- package/package.json +1 -1
- package/react-native-update.podspec +15 -3
- package/android/lib/arm64-v8a/librnupdate.so +0 -0
- package/android/lib/armeabi-v7a/librnupdate.so +0 -0
- package/android/lib/x86/librnupdate.so +0 -0
- package/android/lib/x86_64/librnupdate.so +0 -0
- package/ios/RCTPushy/RCTPushyNativeConfig.h +0 -5
|
@@ -10,9 +10,9 @@ import { UpdateContext } from './UpdateContext';
|
|
|
10
10
|
import { EventHub } from './EventHub';
|
|
11
11
|
import {
|
|
12
12
|
KEY_CONFIG,
|
|
13
|
-
|
|
13
|
+
recordJsRound,
|
|
14
14
|
KEY_RESP_CACHE,
|
|
15
|
-
} from './
|
|
15
|
+
} from './SyncCoordinator';
|
|
16
16
|
import {
|
|
17
17
|
ERROR_FILE_OPERATION_FAILED,
|
|
18
18
|
ERROR_INVALID_HASH_INFO,
|
|
@@ -22,10 +22,11 @@ import {
|
|
|
22
22
|
ERROR_RESTART_FAILED,
|
|
23
23
|
ERROR_SWITCH_VERSION_FAILED,
|
|
24
24
|
ERROR_UNSUPPORTED_PLATFORM,
|
|
25
|
-
|
|
25
|
+
createPushyError,
|
|
26
26
|
getErrorMessage,
|
|
27
|
-
|
|
27
|
+
toPushyError,
|
|
28
28
|
} from './ErrorCodes';
|
|
29
|
+
import { DEVTOOLS_RESTART_EVENT, DEVTOOLS_RESTART_REASON, STORAGE_DIR_NAME } from './Texts';
|
|
29
30
|
|
|
30
31
|
export { getErrorMessage } from './ErrorCodes';
|
|
31
32
|
|
|
@@ -41,13 +42,13 @@ interface RestartableApplicationContext {
|
|
|
41
42
|
restartApp?: (want: RestartWant) => void;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
interface
|
|
45
|
+
interface RestartEventEmitter {
|
|
45
46
|
emit(event: string, payload: Object): void;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
// RNOH 的 devToolsController 不在公开的 UITurboModuleContext 类型里。
|
|
49
50
|
interface DevToolsControllerHolder {
|
|
50
|
-
devToolsController?: { eventEmitter:
|
|
51
|
+
devToolsController?: { eventEmitter: RestartEventEmitter };
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
export function validateHashInfo(info: string): void {
|
|
@@ -59,7 +60,7 @@ export function validateHashInfo(info: string): void {
|
|
|
59
60
|
valid = false;
|
|
60
61
|
}
|
|
61
62
|
if (!valid) {
|
|
62
|
-
throw
|
|
63
|
+
throw createPushyError(ERROR_INVALID_HASH_INFO, 'invalid json string');
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -96,7 +97,7 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
96
97
|
|
|
97
98
|
private requireHash(hash: string, methodName: string): string {
|
|
98
99
|
if (!hash) {
|
|
99
|
-
throw
|
|
100
|
+
throw createPushyError(
|
|
100
101
|
ERROR_INVALID_OPTIONS,
|
|
101
102
|
`${methodName}: empty hash`,
|
|
102
103
|
);
|
|
@@ -104,11 +105,11 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
104
105
|
return hash;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
private
|
|
108
|
+
private softRestart(): void {
|
|
108
109
|
const holder = this.ctx as unknown as DevToolsControllerHolder;
|
|
109
110
|
const devToolsController = holder.devToolsController;
|
|
110
111
|
if (devToolsController) {
|
|
111
|
-
devToolsController.eventEmitter.emit(
|
|
112
|
+
devToolsController.eventEmitter.emit(DEVTOOLS_RESTART_EVENT, { reason: DEVTOOLS_RESTART_REASON });
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
|
|
@@ -146,10 +147,10 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
146
147
|
|
|
147
148
|
private async reloadBridge(): Promise<void> {
|
|
148
149
|
if (this.ctx.isDebugModeEnabled) {
|
|
149
|
-
logger.debug(TAG, '
|
|
150
|
-
this.
|
|
150
|
+
logger.debug(TAG, 'restart via devToolsController (debug mode)');
|
|
151
|
+
this.softRestart();
|
|
151
152
|
} else {
|
|
152
|
-
logger.debug(TAG, '
|
|
153
|
+
logger.debug(TAG, 'restart via restartAbility (release mode)');
|
|
153
154
|
// If the process truly restarts, this timer dies with it. It only fires
|
|
154
155
|
// when the app is still alive after 1.5s — i.e. restartApp resolved but
|
|
155
156
|
// was silently suppressed (HarmonyOS rate-limits restarts within a few
|
|
@@ -157,16 +158,16 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
157
158
|
// soft reload must take over. So the timer is NOT cleared on the success
|
|
158
159
|
// path, only in the catch branch where the soft reload runs immediately.
|
|
159
160
|
const fallbackTimer = setTimeout(() => {
|
|
160
|
-
logger.warn(TAG, 'restartAbility did not restart the app within 1.5s, triggering soft
|
|
161
|
-
this.
|
|
161
|
+
logger.warn(TAG, 'restartAbility did not restart the app within 1.5s, triggering soft restart fallback');
|
|
162
|
+
this.softRestart();
|
|
162
163
|
}, 1500);
|
|
163
164
|
|
|
164
165
|
try {
|
|
165
166
|
await this.restartAbility();
|
|
166
167
|
} catch (error) {
|
|
167
168
|
clearTimeout(fallbackTimer);
|
|
168
|
-
logger.error(TAG, `restartAbility failed: ${getErrorMessage(error)}, triggering soft
|
|
169
|
-
this.
|
|
169
|
+
logger.error(TAG, `restartAbility failed: ${getErrorMessage(error)}, triggering soft restart fallback`);
|
|
170
|
+
this.softRestart();
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
}
|
|
@@ -193,7 +194,7 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
193
194
|
}
|
|
194
195
|
|
|
195
196
|
const result = {
|
|
196
|
-
downloadRootDir: `${this.mUiCtx.filesDir}
|
|
197
|
+
downloadRootDir: `${this.mUiCtx.filesDir}/${STORAGE_DIR_NAME}`,
|
|
197
198
|
currentVersionInfo,
|
|
198
199
|
currentBundleSha256,
|
|
199
200
|
packageVersion,
|
|
@@ -232,7 +233,7 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
232
233
|
try {
|
|
233
234
|
await this.context.setKv(`hash_${hash}`, info);
|
|
234
235
|
} catch (error) {
|
|
235
|
-
throw
|
|
236
|
+
throw toPushyError(error, ERROR_FILE_OPERATION_FAILED);
|
|
236
237
|
}
|
|
237
238
|
}
|
|
238
239
|
|
|
@@ -253,7 +254,7 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
253
254
|
try {
|
|
254
255
|
await this.context.setKv('uuid', uuid);
|
|
255
256
|
} catch (error) {
|
|
256
|
-
throw
|
|
257
|
+
throw toPushyError(error, ERROR_FILE_OPERATION_FAILED);
|
|
257
258
|
}
|
|
258
259
|
}
|
|
259
260
|
|
|
@@ -267,7 +268,7 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
267
268
|
try {
|
|
268
269
|
JSON.parse(config);
|
|
269
270
|
} catch (e) {
|
|
270
|
-
throw
|
|
271
|
+
throw createPushyError(
|
|
271
272
|
ERROR_INVALID_OPTIONS,
|
|
272
273
|
`syncNativeConfig: config is not valid JSON: ${getErrorMessage(e)}`,
|
|
273
274
|
);
|
|
@@ -275,7 +276,7 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
275
276
|
try {
|
|
276
277
|
await this.context.setNativeConfig(config);
|
|
277
278
|
} catch (error) {
|
|
278
|
-
throw
|
|
279
|
+
throw toPushyError(error, ERROR_FILE_OPERATION_FAILED);
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
282
|
|
|
@@ -283,12 +284,12 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
283
284
|
async markJsCheckCompleted(config: string): Promise<void> {
|
|
284
285
|
logger.debug(TAG, ',call markJsCheckCompleted');
|
|
285
286
|
if (typeof config !== 'string' || config.length === 0) {
|
|
286
|
-
throw
|
|
287
|
+
throw createPushyError(
|
|
287
288
|
ERROR_INVALID_OPTIONS,
|
|
288
289
|
'config must be a non-empty string',
|
|
289
290
|
);
|
|
290
291
|
}
|
|
291
|
-
|
|
292
|
+
recordJsRound(config);
|
|
292
293
|
}
|
|
293
294
|
|
|
294
295
|
// 原生冷启动检测落盘的原始响应缓存,JS 侧新鲜期内直接复用免二次请求
|
|
@@ -299,22 +300,22 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
299
300
|
}
|
|
300
301
|
|
|
301
302
|
async reloadUpdate(options: { hash: string }): Promise<void> {
|
|
302
|
-
logger.debug(TAG, ',call
|
|
303
|
-
const hash = this.requireHash(options.hash, '
|
|
303
|
+
logger.debug(TAG, ',call switch and restart');
|
|
304
|
+
const hash = this.requireHash(options.hash, 'switch and restart');
|
|
304
305
|
|
|
305
306
|
// 切换必须真正落盘(switchVersion 内 await flush)后才重启:重启会立刻
|
|
306
307
|
// 杀进程,未落盘的切换就是"重启回旧 bundle"。
|
|
307
308
|
try {
|
|
308
309
|
await this.context.switchVersion(hash);
|
|
309
310
|
} catch (error) {
|
|
310
|
-
logger.error(TAG, `
|
|
311
|
-
throw
|
|
311
|
+
logger.error(TAG, `switch failed: ${getErrorMessage(error)}`);
|
|
312
|
+
throw toPushyError(error, ERROR_SWITCH_VERSION_FAILED);
|
|
312
313
|
}
|
|
313
314
|
try {
|
|
314
315
|
await this.reloadBridge();
|
|
315
316
|
} catch (error) {
|
|
316
|
-
logger.error(TAG, `
|
|
317
|
-
throw
|
|
317
|
+
logger.error(TAG, `restart failed: ${getErrorMessage(error)}`);
|
|
318
|
+
throw toPushyError(error, ERROR_RESTART_FAILED);
|
|
318
319
|
}
|
|
319
320
|
}
|
|
320
321
|
|
|
@@ -324,19 +325,19 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
324
325
|
await this.reloadBridge();
|
|
325
326
|
} catch (error) {
|
|
326
327
|
logger.error(TAG, `restartApp failed: ${getErrorMessage(error)}`);
|
|
327
|
-
throw
|
|
328
|
+
throw toPushyError(error, ERROR_RESTART_FAILED);
|
|
328
329
|
}
|
|
329
330
|
}
|
|
330
331
|
|
|
331
332
|
async setNeedUpdate(options: { hash: string }): Promise<void> {
|
|
332
|
-
logger.debug(TAG, ',call
|
|
333
|
-
const hash = this.requireHash(options.hash, '
|
|
333
|
+
logger.debug(TAG, ',call select for next launch');
|
|
334
|
+
const hash = this.requireHash(options.hash, 'select for next launch');
|
|
334
335
|
|
|
335
336
|
try {
|
|
336
337
|
await this.context.switchVersion(hash);
|
|
337
338
|
} catch (error) {
|
|
338
|
-
logger.error(TAG, `
|
|
339
|
-
throw
|
|
339
|
+
logger.error(TAG, `select for next launch failed: ${getErrorMessage(error)}`);
|
|
340
|
+
throw toPushyError(error, ERROR_SWITCH_VERSION_FAILED);
|
|
340
341
|
}
|
|
341
342
|
}
|
|
342
343
|
|
|
@@ -346,7 +347,7 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
346
347
|
await this.context.markSuccess();
|
|
347
348
|
} catch (error) {
|
|
348
349
|
logger.error(TAG, `markSuccess failed: ${getErrorMessage(error)}`);
|
|
349
|
-
throw
|
|
350
|
+
throw toPushyError(error, ERROR_MARK_SUCCESS_FAILED);
|
|
350
351
|
}
|
|
351
352
|
}
|
|
352
353
|
|
|
@@ -367,7 +368,7 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
367
368
|
await this.context.resetToPackagedBundle();
|
|
368
369
|
} catch (error) {
|
|
369
370
|
logger.error(TAG, `resetToPackagedBundle failed: ${getErrorMessage(error)}`);
|
|
370
|
-
throw
|
|
371
|
+
throw toPushyError(error, ERROR_RESET_FAILED);
|
|
371
372
|
}
|
|
372
373
|
}
|
|
373
374
|
|
|
@@ -376,7 +377,7 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
376
377
|
hash: string;
|
|
377
378
|
originHash: string;
|
|
378
379
|
}): Promise<void> {
|
|
379
|
-
logger.debug(TAG, ',call
|
|
380
|
+
logger.debug(TAG, ',call fetch ppk delta');
|
|
380
381
|
return this.context.downloadPatchFromPpk(
|
|
381
382
|
options.updateUrl,
|
|
382
383
|
options.hash,
|
|
@@ -388,7 +389,7 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
388
389
|
updateUrl: string;
|
|
389
390
|
hash: string;
|
|
390
391
|
}): Promise<void> {
|
|
391
|
-
logger.debug(TAG, ',call
|
|
392
|
+
logger.debug(TAG, ',call fetch package delta');
|
|
392
393
|
return this.context.downloadPatchFromPackage(
|
|
393
394
|
options.updateUrl,
|
|
394
395
|
options.hash,
|
|
@@ -399,7 +400,7 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
399
400
|
updateUrl: string;
|
|
400
401
|
hash: string;
|
|
401
402
|
}): Promise<void> {
|
|
402
|
-
logger.debug(TAG, ',call
|
|
403
|
+
logger.debug(TAG, ',call fetch full package');
|
|
403
404
|
return this.context.downloadFullUpdate(options.updateUrl, options.hash);
|
|
404
405
|
}
|
|
405
406
|
|
|
@@ -409,7 +410,7 @@ export class PushyTurboModule extends UITurboModule {
|
|
|
409
410
|
hash: string;
|
|
410
411
|
}): Promise<void> {
|
|
411
412
|
logger.debug(TAG, ',call downloadAndInstallApk');
|
|
412
|
-
throw
|
|
413
|
+
throw createPushyError(
|
|
413
414
|
ERROR_UNSUPPORTED_PLATFORM,
|
|
414
415
|
'downloadAndInstallApk is only supported on Android',
|
|
415
416
|
);
|