react-native-update 10.44.0 → 10.46.0
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/android/jni/Android.mk +0 -1
- 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/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +10 -1
- package/android/src/main/java/cn/reactnative/modules/update/ErrorCodes.java +24 -0
- package/android/src/main/java/cn/reactnative/modules/update/StateSerialRunner.java +2 -1
- package/android/src/main/java/cn/reactnative/modules/update/UiThreadRunner.java +2 -1
- package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +19 -4
- package/android/src/main/java/cn/reactnative/modules/update/UpdateEventEmitter.java +13 -1
- package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +15 -15
- package/cpp/patch_core/error_codes.h +43 -0
- package/cpp/patch_core/patch_core.cpp +16 -1
- package/cpp/patch_core/patch_core.h +6 -0
- package/cpp/patch_core/tests/patch_core_test.cpp +77 -0
- package/harmony/pushy/src/main/cpp/pushy.cpp +1 -93
- package/harmony/pushy/src/main/ets/DownloadTask.ts +13 -10
- package/harmony/pushy/src/main/ets/NativePatchCore.ts +0 -4
- package/harmony/pushy/src/main/ets/UpdateContext.ts +20 -2
- package/harmony/pushy.har +0 -0
- package/ios/RCTPushy/RCTPushy.mm +223 -132
- package/ios/RCTPushy/RCTPushyDownloader.mm +22 -1
- package/package.json +7 -3
- package/src/client.ts +151 -53
- package/src/context.ts +21 -7
- package/src/core.ts +8 -2
- package/src/endpoint.ts +4 -2
- package/src/error.ts +68 -0
- package/src/index.ts +10 -1
- package/src/locales/en.ts +5 -1
- package/src/locales/zh.ts +3 -1
- package/src/provider.tsx +101 -54
- package/src/type.ts +6 -0
- package/src/utils.ts +56 -16
- package/android/jni/DownloadTask.c +0 -56
- package/android/jni/cn_reactnative_modules_update_DownloadTask.h +0 -21
|
@@ -69,7 +69,7 @@ const FILE_COPY_BUFFER_SIZE = 64 * 1024;
|
|
|
69
69
|
|
|
70
70
|
export class DownloadTask {
|
|
71
71
|
private context: common.Context;
|
|
72
|
-
private hash
|
|
72
|
+
private hash = '';
|
|
73
73
|
private eventHub: EventHub;
|
|
74
74
|
|
|
75
75
|
constructor(context: common.Context) {
|
|
@@ -244,7 +244,7 @@ export class DownloadTask {
|
|
|
244
244
|
bundleOutputPath: outputFile,
|
|
245
245
|
enableMerge: false,
|
|
246
246
|
});
|
|
247
|
-
} catch (error) {
|
|
247
|
+
} catch (error: any) {
|
|
248
248
|
error.message = `Failed to process bundle patch: ${error.message}`;
|
|
249
249
|
throw error;
|
|
250
250
|
} finally {
|
|
@@ -395,17 +395,18 @@ export class DownloadTask {
|
|
|
395
395
|
fileIo.OpenMode.CREATE | fileIo.OpenMode.READ_WRITE,
|
|
396
396
|
);
|
|
397
397
|
|
|
398
|
-
httpRequest.on('headersReceive', (header:
|
|
398
|
+
httpRequest.on('headersReceive', (header: Object) => {
|
|
399
399
|
if (!header) {
|
|
400
400
|
return;
|
|
401
401
|
}
|
|
402
|
-
const
|
|
402
|
+
const headers = header as Record<string, string>;
|
|
403
|
+
const lengthKey = Object.keys(headers).find(
|
|
403
404
|
key => key.toLowerCase() === 'content-length',
|
|
404
405
|
);
|
|
405
406
|
if (!lengthKey) {
|
|
406
407
|
return;
|
|
407
408
|
}
|
|
408
|
-
const length = parseInt(
|
|
409
|
+
const length = parseInt(headers[lengthKey], 10);
|
|
409
410
|
if (!Number.isNaN(length)) {
|
|
410
411
|
contentLength = length;
|
|
411
412
|
}
|
|
@@ -606,9 +607,11 @@ export class DownloadTask {
|
|
|
606
607
|
}
|
|
607
608
|
|
|
608
609
|
if (currentFrom.startsWith('resources/base/media/')) {
|
|
610
|
+
// Strip only the final extension: 'icon.round.png' -> 'icon.round',
|
|
611
|
+
// not 'icon' (getMediaByName expects the full resource name).
|
|
609
612
|
const mediaName = currentFrom
|
|
610
613
|
.replace('resources/base/media/', '')
|
|
611
|
-
.
|
|
614
|
+
.replace(/\.[^.]+$/, '');
|
|
612
615
|
const mediaBuffer = await resourceManager.getMediaByName(mediaName);
|
|
613
616
|
const parentDirs = [
|
|
614
617
|
...new Set(
|
|
@@ -649,7 +652,7 @@ export class DownloadTask {
|
|
|
649
652
|
}
|
|
650
653
|
}
|
|
651
654
|
}
|
|
652
|
-
} catch (error) {
|
|
655
|
+
} catch (error: any) {
|
|
653
656
|
error.message =
|
|
654
657
|
'Copy from resource failed:' +
|
|
655
658
|
currentFrom +
|
|
@@ -670,7 +673,7 @@ export class DownloadTask {
|
|
|
670
673
|
params.originHash || '',
|
|
671
674
|
3,
|
|
672
675
|
);
|
|
673
|
-
} catch (error) {
|
|
676
|
+
} catch (error: any) {
|
|
674
677
|
error.message = 'Cleanup failed:' + error.message;
|
|
675
678
|
console.error(error);
|
|
676
679
|
throw error;
|
|
@@ -698,7 +701,7 @@ export class DownloadTask {
|
|
|
698
701
|
default:
|
|
699
702
|
throw Error(`Unknown task type: ${params.type}`);
|
|
700
703
|
}
|
|
701
|
-
} catch (error) {
|
|
704
|
+
} catch (error: any) {
|
|
702
705
|
console.error('Task execution failed:', error.message);
|
|
703
706
|
if (params.type !== DownloadTaskParams.TASK_TYPE_CLEANUP) {
|
|
704
707
|
try {
|
|
@@ -707,7 +710,7 @@ export class DownloadTask {
|
|
|
707
710
|
} else {
|
|
708
711
|
await this.removeDirectory(params.unzipDirectory);
|
|
709
712
|
}
|
|
710
|
-
} catch (cleanupError) {
|
|
713
|
+
} catch (cleanupError: any) {
|
|
711
714
|
console.error('Cleanup after error failed:', cleanupError.message);
|
|
712
715
|
}
|
|
713
716
|
}
|
|
@@ -50,10 +50,6 @@ export interface FileSourcePatchRequest {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
interface NativePatchCoreBindings {
|
|
53
|
-
hdiffPatch(
|
|
54
|
-
origin: Uint8Array,
|
|
55
|
-
patch: Uint8Array,
|
|
56
|
-
): ArrayBuffer | Uint8Array;
|
|
57
53
|
syncStateWithBinaryVersion(
|
|
58
54
|
packageVersion: string,
|
|
59
55
|
buildTime: string,
|
|
@@ -468,13 +468,22 @@ export class UpdateContext {
|
|
|
468
468
|
public getBundleUrl() {
|
|
469
469
|
UpdateContext.isUsingBundleUrl = true;
|
|
470
470
|
this.trace('getBundleUrl:enter');
|
|
471
|
+
const stateBeforeLaunch = this.getStateSnapshot();
|
|
471
472
|
const launchState = NativePatchCore.runStateCore(
|
|
472
473
|
STATE_OP_RESOLVE_LAUNCH,
|
|
473
|
-
|
|
474
|
+
stateBeforeLaunch,
|
|
474
475
|
'',
|
|
475
476
|
UpdateContext.ignoreRollback,
|
|
476
477
|
true,
|
|
477
478
|
);
|
|
479
|
+
if (launchState.didRollback) {
|
|
480
|
+
// The crash-protection rollback: the new version never called
|
|
481
|
+
// markSuccess. Keep this visible in release logs.
|
|
482
|
+
console.error(
|
|
483
|
+
`Version ${stateBeforeLaunch.currentVersion} was not marked as successful,` +
|
|
484
|
+
` rolled back to ${launchState.currentVersion}`,
|
|
485
|
+
);
|
|
486
|
+
}
|
|
478
487
|
if (launchState.didRollback || launchState.consumedFirstTime) {
|
|
479
488
|
this.persistState(launchState, {
|
|
480
489
|
markFirstLoadMarker: launchState.consumedFirstTime,
|
|
@@ -490,7 +499,12 @@ export class UpdateContext {
|
|
|
490
499
|
);
|
|
491
500
|
|
|
492
501
|
let version = launchState.loadVersion || '';
|
|
493
|
-
|
|
502
|
+
// Guard the rollback chain against cycles: a corrupted state returning an
|
|
503
|
+
// already-visited version would otherwise spin this loop forever during
|
|
504
|
+
// startup (Android has the same guard).
|
|
505
|
+
const visitedVersions = new Set<string>();
|
|
506
|
+
while (version && !visitedVersions.has(version)) {
|
|
507
|
+
visitedVersions.add(version);
|
|
494
508
|
const bundleFile = this.getBundlePath(version);
|
|
495
509
|
try {
|
|
496
510
|
if (!fileIo.accessSync(bundleFile)) {
|
|
@@ -514,7 +528,11 @@ export class UpdateContext {
|
|
|
514
528
|
}
|
|
515
529
|
|
|
516
530
|
private rollBack(): string {
|
|
531
|
+
const stateBefore = this.getStateSnapshot();
|
|
517
532
|
const nextState = this.runStateOperation(STATE_OP_ROLLBACK);
|
|
533
|
+
console.error(
|
|
534
|
+
`Rolling back version ${stateBefore.currentVersion} to ${nextState.currentVersion}`,
|
|
535
|
+
);
|
|
518
536
|
return nextState.currentVersion || '';
|
|
519
537
|
}
|
|
520
538
|
|
package/harmony/pushy.har
CHANGED
|
Binary file
|