react-native-update 10.59.2 → 10.60.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/README-CN.md +7 -7
- package/README.md +7 -6
- package/android/build.gradle +25 -33
- package/android/jni/Android.mk +16 -24
- 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/proguard.pro +9 -7
- package/android/src/main/java/cn/reactnative/modules/update/ApkInstaller.java +2 -7
- package/android/src/main/java/cn/reactnative/modules/update/ArchiveLimits.java +23 -6
- package/android/src/main/java/cn/reactnative/modules/update/BundledResourceCopier.java +50 -51
- package/android/src/main/java/cn/reactnative/modules/update/CleanupKeepNames.java +12 -13
- package/android/src/main/java/cn/reactnative/modules/update/CopyGroupResult.java +3 -0
- package/android/src/main/java/cn/reactnative/modules/update/CrashHold.java +22 -30
- package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +181 -332
- package/android/src/main/java/cn/reactnative/modules/update/DownloadTaskParams.java +3 -1
- package/android/src/main/java/cn/reactnative/modules/update/ErrorCodes.java +27 -0
- package/android/src/main/java/cn/reactnative/modules/update/FileOperationException.java +1 -1
- package/android/src/main/java/cn/reactnative/modules/update/FlowBridge.java +32 -8
- package/android/src/main/java/cn/reactnative/modules/update/HttpClients.java +63 -0
- package/android/src/main/java/cn/reactnative/modules/update/HttpUtils.java +0 -11
- package/android/src/main/java/cn/reactnative/modules/update/InstallRecord.java +66 -116
- package/android/src/main/java/cn/reactnative/modules/update/NativeCore.java +9 -1
- package/android/src/main/java/cn/reactnative/modules/update/PatchFailedException.java +1 -1
- package/android/src/main/java/cn/reactnative/modules/update/PushyRuntime.java +32 -60
- package/android/src/main/java/cn/reactnative/modules/update/ReactReloadManager.java +8 -23
- package/android/src/main/java/cn/reactnative/modules/update/SafeZipFile.java +42 -80
- package/android/src/main/java/cn/reactnative/modules/update/StateSerialRunner.java +22 -39
- package/android/src/main/java/cn/reactnative/modules/update/SyncCoordinator.java +176 -299
- package/android/src/main/java/cn/reactnative/modules/update/Threads.java +35 -0
- package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +242 -174
- package/android/src/main/java/cn/reactnative/modules/update/UpdateEventEmitter.java +1 -1
- package/android/src/main/java/cn/reactnative/modules/update/UpdateFileUtils.java +75 -17
- package/android/src/main/java/cn/reactnative/modules/update/{UpdateModuleImpl.java → UpdateModule.java} +113 -95
- package/android/src/main/java/cn/reactnative/modules/update/UpdatePackage.java +16 -19
- package/android/src/oldarch/cn/reactnative/modules/update/NativePushySpec.java +69 -0
- package/cpp/android_jni/archive_limits_jni.cpp +83 -0
- package/cpp/android_jni/install_record_jni.cpp +89 -0
- package/cpp/android_jni/jni_log.h +31 -0
- package/cpp/android_jni/jni_natives.h +40 -0
- package/cpp/android_jni/jni_registration.cpp +133 -0
- package/cpp/android_jni/jni_util.h +160 -0
- package/cpp/android_jni/update_core_android.cpp +450 -0
- package/cpp/android_jni/update_flow_jni.cpp +133 -0
- package/{android/jni → cpp/hpatch}/hpatch.c +5 -5
- package/{android/jni → cpp/hpatch}/hpatch.h +4 -1
- package/cpp/patch_core/archive_limits.cpp +194 -0
- package/cpp/patch_core/archive_limits.h +99 -10
- package/cpp/patch_core/archive_patch_core.cpp +96 -12
- package/cpp/patch_core/archive_patch_core.h +49 -0
- package/cpp/patch_core/digest.h +5 -4
- package/cpp/patch_core/error_codes.h +5 -3
- package/cpp/patch_core/install_record.cpp +430 -0
- package/cpp/patch_core/install_record.h +163 -9
- package/cpp/patch_core/patch_core.cpp +62 -16
- package/cpp/patch_core/patch_core.h +27 -7
- package/cpp/patch_core/patch_manifest.cpp +201 -0
- package/cpp/patch_core/patch_manifest.h +74 -0
- package/cpp/patch_core/state_ops.h +3 -3
- package/cpp/update_flow_core/flow_json.cpp +82 -8
- package/cpp/update_flow_core/flow_json.h +21 -0
- package/cpp/update_flow_core/native_config.cpp +456 -0
- package/cpp/update_flow_core/native_config.h +84 -0
- package/cpp/update_flow_core/native_round.cpp +326 -0
- package/cpp/update_flow_core/native_round.h +90 -0
- package/cpp/update_flow_core/update_flow_core.h +2 -2
- package/harmony/hvigor-plugin.ts +11 -19
- package/harmony/pushy/src/main/cpp/CMakeLists.txt +17 -26
- package/harmony/pushy/src/main/cpp/PushyPackage.h +2 -2
- package/harmony/pushy/src/main/cpp/PushyTurboModule.cpp +55 -94
- package/harmony/pushy/src/main/cpp/pushy.cpp +694 -517
- package/harmony/pushy/src/main/ets/ArchiveLimits.ts +48 -72
- package/harmony/pushy/src/main/ets/DownloadTask.ts +164 -404
- package/harmony/pushy/src/main/ets/DownloadTaskParams.ts +1 -3
- package/harmony/pushy/src/main/ets/ErrorCodes.ts +1 -14
- package/harmony/pushy/src/main/ets/EventHub.ts +1 -1
- package/harmony/pushy/src/main/ets/InstallRecord.ts +52 -151
- package/harmony/pushy/src/main/ets/Logger.ts +20 -34
- package/harmony/pushy/src/main/ets/NativePatchCore.ts +116 -42
- package/harmony/pushy/src/main/ets/PushyConfiguration.ts +8 -85
- package/harmony/pushy/src/main/ets/PushyTurboModule.ts +11 -25
- package/harmony/pushy/src/main/ets/SaveFile.ts +99 -18
- package/harmony/pushy/src/main/ets/SyncCoordinator.ts +136 -335
- package/harmony/pushy/src/main/ets/Texts.ts +0 -4
- package/harmony/pushy/src/main/ets/UpdateContext.ts +106 -119
- package/harmony/pushy.har +0 -0
- package/ios/RCTPushy/RCTPushy+Launch.mm +185 -0
- package/ios/RCTPushy/RCTPushy.h +12 -0
- package/ios/RCTPushy/RCTPushy.mm +87 -2634
- package/ios/RCTPushy/RCTPushyCommon.h +34 -0
- package/ios/RCTPushy/RCTPushyConfiguration.h +0 -8
- package/ios/RCTPushy/RCTPushyConfiguration.mm +40 -121
- package/ios/RCTPushy/RCTPushyDownloader.mm +40 -37
- package/ios/RCTPushy/RCTPushyInstallRecord.mm +61 -0
- package/ios/RCTPushy/RCTPushyInstaller.mm +689 -0
- package/ios/RCTPushy/RCTPushyInternal.h +144 -0
- package/ios/RCTPushy/RCTPushyOrchestrator.mm +1001 -0
- package/ios/RCTPushy/RCTPushyState.mm +314 -0
- package/package.json +25 -23
- package/react-native-update.podspec +73 -82
- package/src/client.ts +361 -451
- package/src/context.ts +1 -1
- package/src/core.ts +35 -8
- package/src/endpoint.ts +0 -2
- package/src/error.ts +13 -32
- package/src/i18n.ts +18 -83
- package/src/locales/en.ts +0 -4
- package/src/locales/zh.ts +0 -4
- package/src/provider.tsx +60 -53
- package/src/telemetry.ts +0 -13
- package/src/type.ts +0 -15
- package/src/updateFlowCore.ts +116 -10
- package/src/utils.ts +49 -42
- package/android/src/main/java/cn/reactnative/modules/update/ArchivePatchPlanResult.java +0 -6
- package/android/src/main/java/cn/reactnative/modules/update/PushyConfiguration.java +0 -104
- package/android/src/main/java/cn/reactnative/modules/update/UiThreadRunner.java +0 -37
- package/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java +0 -121
- package/android/src/oldarch/cn/reactnative/modules/update/UpdateModule.java +0 -125
- package/cpp/patch_core/jni_natives.h +0 -27
- package/cpp/patch_core/jni_registration.cpp +0 -103
- package/cpp/patch_core/jni_util.h +0 -60
- package/cpp/patch_core/patch_core_android.cpp +0 -97
- package/cpp/patch_core/update_core_android.cpp +0 -485
- package/cpp/update_flow_core/update_flow_jni.cpp +0 -150
|
@@ -4,51 +4,64 @@ import {
|
|
|
4
4
|
ERROR_FILE_OPERATION_FAILED,
|
|
5
5
|
ERROR_DELTA_FAILED,
|
|
6
6
|
createPushyError,
|
|
7
|
+
getErrorMessage,
|
|
7
8
|
} from './ErrorCodes';
|
|
8
|
-
import
|
|
9
|
+
import NativePatchCore from './NativePatchCore';
|
|
9
10
|
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
11
|
+
// 解压资源上限的计数规则(条目数、单条/总解压量、压缩比、保留名、符号链接、
|
|
12
|
+
// 未知长度下载的磁盘探测计划)只在 cpp/patch_core/archive_limits.h 里实现,
|
|
13
|
+
// 三端共用(这里经 NAPI)。下面只镜像本端仍需自己比较的常量,
|
|
14
|
+
// scripts/check-constant-parity.js 断言与头文件一致。
|
|
13
15
|
export const MAX_ARCHIVE_BYTES = 512 * 1024 * 1024;
|
|
14
|
-
export const MAX_TOTAL_UNCOMPRESSED_BYTES = 2048 * 1024 * 1024;
|
|
15
|
-
export const MAX_ENTRY_BYTES = 512 * 1024 * 1024;
|
|
16
|
-
export const MAX_ENTRIES = 20000;
|
|
17
|
-
export const MAX_COMPRESSION_RATIO = 100;
|
|
18
|
-
export const RATIO_CHECK_MIN_BYTES = 1 * 1024 * 1024;
|
|
19
16
|
export const MAX_MANIFEST_BYTES = 16 * 1024 * 1024;
|
|
20
17
|
export const FREE_DISK_MARGIN_BYTES = 64 * 1024 * 1024;
|
|
21
|
-
export const UNKNOWN_LENGTH_FREE_SPACE_PROBE_BYTES = 8 * 1024 * 1024;
|
|
22
18
|
|
|
23
19
|
/**
|
|
24
|
-
*
|
|
25
|
-
* zlib
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
20
|
+
* 解压前的整包校验(zlib.getOriginalSize 给出的归档解压后总字节数):总解压
|
|
21
|
+
* 量上限与整包压缩比(archive_limits::CheckUncompressedSize)。鸿蒙的 zlib
|
|
22
|
+
* 只提供整包解压量与整包解压,拿不到条目的压缩尺寸,逐条压缩比无从查起;
|
|
23
|
+
* 20MB 归档 100:1 的 2GB 载荷在解压前就被挡下,解压后 checkExtractedDirectory
|
|
24
|
+
* 再逐条核对。
|
|
29
25
|
*/
|
|
30
26
|
export function checkUncompressedSize(
|
|
31
27
|
archiveBytes: number,
|
|
32
28
|
uncompressedBytes: number,
|
|
33
29
|
): void {
|
|
34
|
-
|
|
30
|
+
const reason = NativePatchCore.checkUncompressedSize(
|
|
31
|
+
archiveBytes,
|
|
32
|
+
uncompressedBytes,
|
|
33
|
+
);
|
|
34
|
+
if (reason !== undefined) {
|
|
35
|
+
throw createPushyError(ERROR_DELTA_FAILED, reason);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 解压量取不到时拒绝的专属错误细节:与"超限"拒绝区分开,日志与遥测里一眼
|
|
40
|
+
// 可辨(典型原因:设备 zlib 不认该归档格式/归档损坏)。不做任何放行回退。
|
|
41
|
+
export const ORIGINAL_SIZE_UNAVAILABLE = 'archive expansion size unavailable';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* zlib.getOriginalSize 的结果校验。failure 非 undefined 表示调用本身抛错
|
|
45
|
+
* (其消息);否则校验返回值必须是有限非负数。任何一种都拒绝归档:不知道
|
|
46
|
+
* 展开量就放行,等于允许一个 20MB 的归档在解压后的统计跑到之前先写满磁盘。
|
|
47
|
+
*/
|
|
48
|
+
export function checkOriginalSize(
|
|
49
|
+
size: number | undefined,
|
|
50
|
+
failure?: string,
|
|
51
|
+
): number {
|
|
52
|
+
if (failure !== undefined) {
|
|
35
53
|
throw createPushyError(
|
|
36
54
|
ERROR_DELTA_FAILED,
|
|
37
|
-
|
|
38
|
-
`(${uncompressedBytes})`,
|
|
55
|
+
`${ORIGINAL_SIZE_UNAVAILABLE}: getOriginalSize failed: ${failure}`,
|
|
39
56
|
);
|
|
40
57
|
}
|
|
41
|
-
if (
|
|
42
|
-
uncompressedBytes > RATIO_CHECK_MIN_BYTES &&
|
|
43
|
-
archiveBytes > 0 &&
|
|
44
|
-
uncompressedBytes > archiveBytes * MAX_COMPRESSION_RATIO
|
|
45
|
-
) {
|
|
58
|
+
if (typeof size !== 'number' || !Number.isFinite(size) || size < 0) {
|
|
46
59
|
throw createPushyError(
|
|
47
60
|
ERROR_DELTA_FAILED,
|
|
48
|
-
|
|
49
|
-
`(${uncompressedBytes}/${archiveBytes})`,
|
|
61
|
+
`${ORIGINAL_SIZE_UNAVAILABLE}: getOriginalSize returned ${String(size)}`,
|
|
50
62
|
);
|
|
51
63
|
}
|
|
64
|
+
return size;
|
|
52
65
|
}
|
|
53
66
|
|
|
54
67
|
/**
|
|
@@ -85,55 +98,18 @@ export async function ensureFreeSpace(
|
|
|
85
98
|
}
|
|
86
99
|
}
|
|
87
100
|
|
|
88
|
-
export interface DirectoryMeasure {
|
|
89
|
-
entries: number;
|
|
90
|
-
bytes: number;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
101
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
102
|
+
* 解压后在 native 工作线程逐条核对刚解压的目录(archive_limits::
|
|
103
|
+
* CheckExtractedDirectory):条目数、单条大小、总字节数与整包压缩比,拒绝
|
|
104
|
+
* 任意深度的 `.pushy-` 保留条目(完成记录只能由 SDK 写)与符号链接。
|
|
96
105
|
*/
|
|
97
|
-
export async function
|
|
106
|
+
export async function checkExtractedDirectory(
|
|
98
107
|
directory: string,
|
|
99
|
-
|
|
100
|
-
): Promise<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
if (isReservedEntryName(name)) {
|
|
106
|
-
throw createPushyError(
|
|
107
|
-
ERROR_DELTA_FAILED,
|
|
108
|
-
`archive contains reserved entry ${name}`,
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
const path = `${directory}/${name}`;
|
|
112
|
-
const stat = await fileIo.stat(path);
|
|
113
|
-
acc.entries += 1;
|
|
114
|
-
if (acc.entries > MAX_ENTRIES) {
|
|
115
|
-
throw createPushyError(
|
|
116
|
-
ERROR_DELTA_FAILED,
|
|
117
|
-
`archive has too many entries (> ${MAX_ENTRIES})`,
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
if (stat.isDirectory()) {
|
|
121
|
-
await measureExtractedDirectory(path, acc);
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
if (stat.size > MAX_ENTRY_BYTES) {
|
|
125
|
-
throw createPushyError(
|
|
126
|
-
ERROR_DELTA_FAILED,
|
|
127
|
-
`archive entry too large: ${name} (${stat.size} bytes)`,
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
acc.bytes += stat.size;
|
|
131
|
-
if (acc.bytes > MAX_TOTAL_UNCOMPRESSED_BYTES) {
|
|
132
|
-
throw createPushyError(
|
|
133
|
-
ERROR_DELTA_FAILED,
|
|
134
|
-
`archive expands beyond ${MAX_TOTAL_UNCOMPRESSED_BYTES} bytes`,
|
|
135
|
-
);
|
|
136
|
-
}
|
|
108
|
+
archiveBytes: number,
|
|
109
|
+
): Promise<void> {
|
|
110
|
+
try {
|
|
111
|
+
await NativePatchCore.checkExtractedDirectory(directory, archiveBytes);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
throw createPushyError(ERROR_DELTA_FAILED, getErrorMessage(e));
|
|
137
114
|
}
|
|
138
|
-
return acc;
|
|
139
115
|
}
|