react-native-update 10.53.1 → 10.54.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 +31 -31
- package/README.md +31 -31
- package/android/jni/HDiffPatch/.travis.yml +33 -0
- package/android/jni/HDiffPatch/builds/xcode/bestParams.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/hdiffz.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/hdiffz.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/android/jni/HDiffPatch/builds/xcode/hpatchz.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/lz4.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/lzma.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/testHashClash.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/testHashClash.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/android/jni/HDiffPatch/builds/xcode/unitTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/HDiffPatch/builds/xcode/zstd.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/android/jni/lzma/DOC/7zC.txt +187 -0
- package/android/jni/lzma/DOC/7zFormat.txt +469 -0
- package/android/jni/lzma/DOC/Methods.txt +173 -0
- package/android/jni/lzma/DOC/installer.txt +166 -0
- package/android/jni/lzma/DOC/lzma-history.txt +446 -0
- package/android/jni/lzma/DOC/lzma-sdk.txt +357 -0
- package/android/jni/lzma/DOC/lzma-specification.txt +1176 -0
- package/android/jni/lzma/DOC/lzma.txt +328 -0
- package/android/jni/lzma/bin/7zS2.sfx +0 -0
- package/android/jni/lzma/bin/7zS2con.sfx +0 -0
- package/android/jni/lzma/bin/7zSD.sfx +0 -0
- package/android/jni/lzma/bin/7zdec.exe +0 -0
- package/android/jni/lzma/bin/7zr.exe +0 -0
- package/android/jni/lzma/bin/installer/config.txt +5 -0
- package/android/jni/lzma/bin/installer/cr.bat +5 -0
- package/android/jni/lzma/bin/lzma.exe +0 -0
- package/android/jni/lzma/bin/x64/7zr.exe +0 -0
- 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/ArchiveLimits.java +44 -0
- package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +124 -40
- package/android/src/main/java/cn/reactnative/modules/update/InstallRecord.java +125 -0
- package/android/src/main/java/cn/reactnative/modules/update/NativeCheckOrchestrator.java +43 -11
- package/android/src/main/java/cn/reactnative/modules/update/NativeUpdateFlow.java +2 -0
- package/android/src/main/java/cn/reactnative/modules/update/SafeZipFile.java +90 -0
- package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +79 -19
- package/android/src/main/java/cn/reactnative/modules/update/UpdateFileUtils.java +21 -0
- package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +33 -2
- package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleSupport.java +1 -0
- package/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java +5 -0
- package/android/src/oldarch/cn/reactnative/modules/update/UpdateModule.java +5 -0
- package/cpp/patch_core/archive_limits.h +38 -0
- package/cpp/patch_core/install_record.h +36 -0
- package/cpp/update_flow_core/flow_json.h +1 -0
- package/cpp/update_flow_core/update_flow_core.cpp +41 -7
- package/cpp/update_flow_core/update_flow_core.h +9 -0
- package/cpp/update_flow_core/update_flow_jni.cpp +12 -0
- package/harmony/pushy/src/main/cpp/PushyTurboModule.cpp +2 -0
- package/harmony/pushy/src/main/cpp/pushy.cpp +37 -0
- package/harmony/pushy/src/main/ets/ArchiveLimits.ts +83 -0
- package/harmony/pushy/src/main/ets/DownloadTask.ts +126 -30
- package/harmony/pushy/src/main/ets/InstallRecord.ts +129 -0
- package/harmony/pushy/src/main/ets/NativeCheckOrchestrator.ts +24 -2
- package/harmony/pushy/src/main/ets/NativePatchCore.ts +5 -0
- package/harmony/pushy/src/main/ets/PushyTurboModule.ts +12 -0
- package/harmony/pushy/src/main/ets/UpdateContext.ts +78 -15
- package/harmony/pushy.har +0 -0
- package/ios/RCTPushy/RCTPushy.mm +384 -25
- package/ios/RCTPushy/RCTPushyDownloader.mm +32 -0
- package/package.json +25 -2
- package/src/NativePushy.ts +13 -0
- package/src/client.ts +160 -43
- package/src/core.ts +17 -3
- package/src/error.ts +3 -0
- package/src/index.ts +8 -0
- package/src/locales/en.ts +3 -0
- package/src/locales/zh.ts +2 -0
- package/src/metadata.ts +166 -0
- package/src/provider.tsx +52 -17
- package/src/type.ts +22 -0
- package/src/updateFlowCore.ts +95 -4
- package/src/utils.ts +31 -19
- package/.gitmodules +0 -6
- package/BUNDLEHASH_MIGRATION.md +0 -355
- package/NATIVE_CHECKUPDATE_DESIGN.md +0 -539
- package/NATIVE_CHECK_FOLLOWUPS.md +0 -514
- package/android/jni/HDiffPatch/test/_private_searchBestParams.cpp +0 -301
- package/android/jni/HDiffPatch/test/hpatchz_test.cpp +0 -292
- package/android/jni/HDiffPatch/test/testHashClash.cpp +0 -436
- package/android/jni/HDiffPatch/test/unit_test.cpp +0 -417
- package/biome.json +0 -59
- package/cpp/patch_core/tests/fixtures/rawstored.lzma2label.patch.bin +0 -0
- package/cpp/patch_core/tests/fixtures/rawstored.new.bin +0 -0
- package/cpp/patch_core/tests/fixtures/rawstored.old.bin +0 -0
- package/cpp/patch_core/tests/fixtures/v96.hbc +0 -0
- package/cpp/patch_core/tests/fixtures/v96.meta.json +0 -1
- package/cpp/patch_core/tests/fixtures/v96.streampatch.bin +0 -0
- package/cpp/patch_core/tests/fixtures/v96.t.hbc +0 -0
- package/cpp/patch_core/tests/fixtures/v96.tpatch.bin +0 -0
- package/cpp/patch_core/tests/fixtures/v96.tstreampatch.bin +0 -0
- package/cpp/patch_core/tests/fixtures/v96b.hbc +0 -0
- package/cpp/patch_core/tests/fixtures/v98.hbc +0 -0
- package/cpp/patch_core/tests/fixtures/v98.t.hbc +0 -0
- package/cpp/patch_core/tests/fixtures/v98b.hbc +0 -0
- package/cpp/patch_core/tests/fixtures/v98b.t.hbc +0 -0
- package/cpp/patch_core/tests/hbc_transform_test.cpp +0 -384
- package/cpp/patch_core/tests/patch_core_test.cpp +0 -970
- package/cpp/update_flow_core/tests/flow_vectors.json +0 -1401
- package/cpp/update_flow_core/tests/update_flow_core_test.cpp +0 -317
- package/scripts/check-expo-version.js +0 -92
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import preferences from '@ohos.data.preferences';
|
|
2
2
|
import fileIo from '@ohos.file.fs';
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
isInstallComplete,
|
|
5
|
+
readInstallRecord,
|
|
6
|
+
verifyInstallForActivation,
|
|
7
|
+
} from './InstallRecord';
|
|
8
|
+
import { DownloadTask } from './DownloadTask';
|
|
7
9
|
import common from '@ohos.app.ability.common';
|
|
8
10
|
import { DownloadTaskParams } from './DownloadTaskParams';
|
|
9
11
|
import { bundleManager } from '@kit.AbilityKit';
|
|
@@ -201,7 +203,27 @@ export class UpdateContext {
|
|
|
201
203
|
return defaultValue;
|
|
202
204
|
}
|
|
203
205
|
|
|
206
|
+
// >0 while a multi-write commit is open: putSync/deleteSync still apply in
|
|
207
|
+
// memory, the single flush happens when the outermost batch closes. The
|
|
208
|
+
// cold-start round's three writes (hash info, activation, response cache)
|
|
209
|
+
// thus reach disk as one preferences file write, not three.
|
|
210
|
+
private flushBatchDepth = 0;
|
|
211
|
+
|
|
212
|
+
private beginFlushBatch(): void {
|
|
213
|
+
this.flushBatchDepth += 1;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private endFlushBatch(reason: string): void {
|
|
217
|
+
this.flushBatchDepth = Math.max(0, this.flushBatchDepth - 1);
|
|
218
|
+
if (this.flushBatchDepth === 0) {
|
|
219
|
+
this.flushPreferences(reason);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
204
223
|
private flushPreferences(reason: string): void {
|
|
224
|
+
if (this.flushBatchDepth > 0) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
205
227
|
const flushablePreferences = this.preferences as FlushablePreferences;
|
|
206
228
|
if (typeof flushablePreferences.flushSync === 'function') {
|
|
207
229
|
try {
|
|
@@ -506,14 +528,21 @@ export class UpdateContext {
|
|
|
506
528
|
if (UpdateContext.resetGeneration !== expectedGeneration) {
|
|
507
529
|
return false;
|
|
508
530
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
531
|
+
// One flush for the whole round (see beginFlushBatch): version info,
|
|
532
|
+
// activation and response cache land together or not at all.
|
|
533
|
+
this.beginFlushBatch();
|
|
534
|
+
try {
|
|
535
|
+
if (hash && hashInfoJson) {
|
|
536
|
+
this.setKv(`hash_${hash}`, hashInfoJson);
|
|
537
|
+
}
|
|
538
|
+
if (activate && hash) {
|
|
539
|
+
this.switchVersion(hash);
|
|
540
|
+
}
|
|
541
|
+
if (responseCacheJson) {
|
|
542
|
+
this.setKv(KEY_RESP_CACHE, responseCacheJson);
|
|
543
|
+
}
|
|
544
|
+
} finally {
|
|
545
|
+
this.endFlushBatch('commit native check result');
|
|
517
546
|
}
|
|
518
547
|
return true;
|
|
519
548
|
}
|
|
@@ -595,13 +624,27 @@ export class UpdateContext {
|
|
|
595
624
|
|
|
596
625
|
// 原生冷启动检测(NativeCheckOrchestrator)用来跳过已就绪版本的重复下载
|
|
597
626
|
// ——alert 类策略下版本已下载但未激活,若不判在这里会每次冷启动重下一遍。
|
|
627
|
+
// 运行中热更版本安装记录里的 bundleSha256(崩溃归因用);内置 bundle /
|
|
628
|
+
// 历史安装 / 记录不可读时为空串。
|
|
629
|
+
public currentBundleSha256(hash: string): string {
|
|
630
|
+
if (!hash) {
|
|
631
|
+
return '';
|
|
632
|
+
}
|
|
633
|
+
try {
|
|
634
|
+
const record = readInstallRecord(
|
|
635
|
+
`${this.rootDir}/${assertSafePathComponent(hash)}`,
|
|
636
|
+
);
|
|
637
|
+
return record?.bundleSha256 ?? '';
|
|
638
|
+
} catch (e) {
|
|
639
|
+
return '';
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
598
643
|
public hasDownloadedVersion(hash: string): boolean {
|
|
599
644
|
try {
|
|
600
645
|
const safeHash = assertSafePathComponent(hash);
|
|
601
646
|
return fileIo.accessSync(this.getBundlePath(safeHash))
|
|
602
|
-
&&
|
|
603
|
-
`${this.rootDir}/${safeHash}/${VERSION_COMPLETE_FILE_NAME}`,
|
|
604
|
-
);
|
|
647
|
+
&& isInstallComplete(`${this.rootDir}/${safeHash}`, safeHash);
|
|
605
648
|
} catch (e) {
|
|
606
649
|
return false;
|
|
607
650
|
}
|
|
@@ -609,10 +652,30 @@ export class UpdateContext {
|
|
|
609
652
|
|
|
610
653
|
public switchVersion(hash: string): void {
|
|
611
654
|
try {
|
|
612
|
-
const
|
|
655
|
+
const safeHash = assertSafePathComponent(hash);
|
|
656
|
+
const bundlePath = this.getBundlePath(safeHash);
|
|
613
657
|
if (!fileIo.accessSync(bundlePath)) {
|
|
614
658
|
throw Error(`Bundle version ${hash} not found.`);
|
|
615
659
|
}
|
|
660
|
+
// Same rule as Android/iOS: only a version this SDK recorded as
|
|
661
|
+
// completely installed (bundle + marker) may be activated. Versions
|
|
662
|
+
// activated before markers existed are grandfathered through
|
|
663
|
+
// current/last state; any other markerless directory may be a
|
|
664
|
+
// crash-left partial install.
|
|
665
|
+
const legacyActivated =
|
|
666
|
+
this.readString('currentVersion') === safeHash ||
|
|
667
|
+
this.readString('lastVersion') === safeHash;
|
|
668
|
+
if (!this.hasDownloadedVersion(safeHash) && !legacyActivated) {
|
|
669
|
+
throw Error(`Bundle version ${hash} is incomplete.`);
|
|
670
|
+
}
|
|
671
|
+
if (!legacyActivated) {
|
|
672
|
+
// 记录里的 bundle 摘要必须与盘上字节一致,才能把下次启动指向它。
|
|
673
|
+
verifyInstallForActivation(
|
|
674
|
+
`${this.rootDir}/${safeHash}`,
|
|
675
|
+
safeHash,
|
|
676
|
+
bundlePath,
|
|
677
|
+
);
|
|
678
|
+
}
|
|
616
679
|
|
|
617
680
|
this.trace(`switchVersion:before ${hash}`);
|
|
618
681
|
this.runStateOperation(STATE_OP_SWITCH_VERSION, hash);
|
package/harmony/pushy.har
CHANGED
|
Binary file
|