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.
Files changed (105) hide show
  1. package/README-CN.md +31 -31
  2. package/README.md +31 -31
  3. package/android/jni/HDiffPatch/.travis.yml +33 -0
  4. package/android/jni/HDiffPatch/builds/xcode/bestParams.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  5. package/android/jni/HDiffPatch/builds/xcode/hdiffz.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  6. package/android/jni/HDiffPatch/builds/xcode/hdiffz.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  7. package/android/jni/HDiffPatch/builds/xcode/hpatchz.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  8. package/android/jni/HDiffPatch/builds/xcode/lz4.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  9. package/android/jni/HDiffPatch/builds/xcode/lzma.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  10. package/android/jni/HDiffPatch/builds/xcode/testHashClash.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  11. package/android/jni/HDiffPatch/builds/xcode/testHashClash.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  12. package/android/jni/HDiffPatch/builds/xcode/unitTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  13. package/android/jni/HDiffPatch/builds/xcode/zstd.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  14. package/android/jni/lzma/DOC/7zC.txt +187 -0
  15. package/android/jni/lzma/DOC/7zFormat.txt +469 -0
  16. package/android/jni/lzma/DOC/Methods.txt +173 -0
  17. package/android/jni/lzma/DOC/installer.txt +166 -0
  18. package/android/jni/lzma/DOC/lzma-history.txt +446 -0
  19. package/android/jni/lzma/DOC/lzma-sdk.txt +357 -0
  20. package/android/jni/lzma/DOC/lzma-specification.txt +1176 -0
  21. package/android/jni/lzma/DOC/lzma.txt +328 -0
  22. package/android/jni/lzma/bin/7zS2.sfx +0 -0
  23. package/android/jni/lzma/bin/7zS2con.sfx +0 -0
  24. package/android/jni/lzma/bin/7zSD.sfx +0 -0
  25. package/android/jni/lzma/bin/7zdec.exe +0 -0
  26. package/android/jni/lzma/bin/7zr.exe +0 -0
  27. package/android/jni/lzma/bin/installer/config.txt +5 -0
  28. package/android/jni/lzma/bin/installer/cr.bat +5 -0
  29. package/android/jni/lzma/bin/lzma.exe +0 -0
  30. package/android/jni/lzma/bin/x64/7zr.exe +0 -0
  31. package/android/lib/arm64-v8a/librnupdate.so +0 -0
  32. package/android/lib/armeabi-v7a/librnupdate.so +0 -0
  33. package/android/lib/x86/librnupdate.so +0 -0
  34. package/android/lib/x86_64/librnupdate.so +0 -0
  35. package/android/src/main/java/cn/reactnative/modules/update/ArchiveLimits.java +44 -0
  36. package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +124 -40
  37. package/android/src/main/java/cn/reactnative/modules/update/InstallRecord.java +125 -0
  38. package/android/src/main/java/cn/reactnative/modules/update/NativeCheckOrchestrator.java +43 -11
  39. package/android/src/main/java/cn/reactnative/modules/update/NativeUpdateFlow.java +2 -0
  40. package/android/src/main/java/cn/reactnative/modules/update/SafeZipFile.java +90 -0
  41. package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +79 -19
  42. package/android/src/main/java/cn/reactnative/modules/update/UpdateFileUtils.java +21 -0
  43. package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +33 -2
  44. package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleSupport.java +1 -0
  45. package/android/src/newarch/cn/reactnative/modules/update/UpdateModule.java +5 -0
  46. package/android/src/oldarch/cn/reactnative/modules/update/UpdateModule.java +5 -0
  47. package/cpp/patch_core/archive_limits.h +38 -0
  48. package/cpp/patch_core/install_record.h +36 -0
  49. package/cpp/update_flow_core/flow_json.h +1 -0
  50. package/cpp/update_flow_core/update_flow_core.cpp +41 -7
  51. package/cpp/update_flow_core/update_flow_core.h +9 -0
  52. package/cpp/update_flow_core/update_flow_jni.cpp +12 -0
  53. package/harmony/pushy/src/main/cpp/PushyTurboModule.cpp +2 -0
  54. package/harmony/pushy/src/main/cpp/pushy.cpp +37 -0
  55. package/harmony/pushy/src/main/ets/ArchiveLimits.ts +83 -0
  56. package/harmony/pushy/src/main/ets/DownloadTask.ts +126 -30
  57. package/harmony/pushy/src/main/ets/InstallRecord.ts +129 -0
  58. package/harmony/pushy/src/main/ets/NativeCheckOrchestrator.ts +24 -2
  59. package/harmony/pushy/src/main/ets/NativePatchCore.ts +5 -0
  60. package/harmony/pushy/src/main/ets/PushyTurboModule.ts +12 -0
  61. package/harmony/pushy/src/main/ets/UpdateContext.ts +78 -15
  62. package/harmony/pushy.har +0 -0
  63. package/ios/RCTPushy/RCTPushy.mm +384 -25
  64. package/ios/RCTPushy/RCTPushyDownloader.mm +32 -0
  65. package/package.json +25 -2
  66. package/src/NativePushy.ts +13 -0
  67. package/src/client.ts +160 -43
  68. package/src/core.ts +17 -3
  69. package/src/error.ts +3 -0
  70. package/src/index.ts +8 -0
  71. package/src/locales/en.ts +3 -0
  72. package/src/locales/zh.ts +2 -0
  73. package/src/metadata.ts +166 -0
  74. package/src/provider.tsx +52 -17
  75. package/src/type.ts +22 -0
  76. package/src/updateFlowCore.ts +95 -4
  77. package/src/utils.ts +31 -19
  78. package/.gitmodules +0 -6
  79. package/BUNDLEHASH_MIGRATION.md +0 -355
  80. package/NATIVE_CHECKUPDATE_DESIGN.md +0 -539
  81. package/NATIVE_CHECK_FOLLOWUPS.md +0 -514
  82. package/android/jni/HDiffPatch/test/_private_searchBestParams.cpp +0 -301
  83. package/android/jni/HDiffPatch/test/hpatchz_test.cpp +0 -292
  84. package/android/jni/HDiffPatch/test/testHashClash.cpp +0 -436
  85. package/android/jni/HDiffPatch/test/unit_test.cpp +0 -417
  86. package/biome.json +0 -59
  87. package/cpp/patch_core/tests/fixtures/rawstored.lzma2label.patch.bin +0 -0
  88. package/cpp/patch_core/tests/fixtures/rawstored.new.bin +0 -0
  89. package/cpp/patch_core/tests/fixtures/rawstored.old.bin +0 -0
  90. package/cpp/patch_core/tests/fixtures/v96.hbc +0 -0
  91. package/cpp/patch_core/tests/fixtures/v96.meta.json +0 -1
  92. package/cpp/patch_core/tests/fixtures/v96.streampatch.bin +0 -0
  93. package/cpp/patch_core/tests/fixtures/v96.t.hbc +0 -0
  94. package/cpp/patch_core/tests/fixtures/v96.tpatch.bin +0 -0
  95. package/cpp/patch_core/tests/fixtures/v96.tstreampatch.bin +0 -0
  96. package/cpp/patch_core/tests/fixtures/v96b.hbc +0 -0
  97. package/cpp/patch_core/tests/fixtures/v98.hbc +0 -0
  98. package/cpp/patch_core/tests/fixtures/v98.t.hbc +0 -0
  99. package/cpp/patch_core/tests/fixtures/v98b.hbc +0 -0
  100. package/cpp/patch_core/tests/fixtures/v98b.t.hbc +0 -0
  101. package/cpp/patch_core/tests/hbc_transform_test.cpp +0 -384
  102. package/cpp/patch_core/tests/patch_core_test.cpp +0 -970
  103. package/cpp/update_flow_core/tests/flow_vectors.json +0 -1401
  104. package/cpp/update_flow_core/tests/update_flow_core_test.cpp +0 -317
  105. 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
- DownloadTask,
5
- VERSION_COMPLETE_FILE_NAME,
6
- } from './DownloadTask';
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
- if (hash && hashInfoJson) {
510
- this.setKv(`hash_${hash}`, hashInfoJson);
511
- }
512
- if (activate && hash) {
513
- this.switchVersion(hash);
514
- }
515
- if (responseCacheJson) {
516
- this.setKv(KEY_RESP_CACHE, responseCacheJson);
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
- && fileIo.accessSync(
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 bundlePath = this.getBundlePath(assertSafePathComponent(hash));
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