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.
Files changed (74) hide show
  1. package/README-CN.md +7 -0
  2. package/README.md +8 -0
  3. package/android/build.gradle +46 -14
  4. package/android/jni/Android.mk +2 -1
  5. package/android/lib/arm64-v8a/librnpushy.so +0 -0
  6. package/android/lib/armeabi-v7a/librnpushy.so +0 -0
  7. package/android/lib/x86/librnpushy.so +0 -0
  8. package/android/lib/x86_64/librnpushy.so +0 -0
  9. package/android/src/main/java/cn/reactnative/modules/update/ApkInstaller.java +6 -6
  10. package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateResult.java → BundlePreparationResult.java} +6 -6
  11. package/android/src/main/java/cn/reactnative/modules/update/BundledResourceCopier.java +4 -4
  12. package/android/src/main/java/cn/reactnative/modules/update/{CrashRescue.java → CrashHold.java} +12 -12
  13. package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +28 -24
  14. package/android/src/main/java/cn/reactnative/modules/update/ErrorCodes.java +2 -1
  15. package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateFlow.java → FlowBridge.java} +6 -6
  16. package/android/src/main/java/cn/reactnative/modules/update/HttpUtils.java +6 -3
  17. package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateCore.java → NativeCore.java} +4 -4
  18. package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateConfig.java → PushyConfiguration.java} +13 -8
  19. package/android/src/main/java/cn/reactnative/modules/update/{PushyNativeUpdate.java → PushyRuntime.java} +15 -15
  20. package/android/src/main/java/cn/reactnative/modules/update/ReactReloadManager.java +7 -7
  21. package/android/src/main/java/cn/reactnative/modules/update/StateSerialRunner.java +1 -1
  22. package/android/src/main/java/cn/reactnative/modules/update/{NativeCheckOrchestrator.java → SyncCoordinator.java} +107 -103
  23. package/android/src/main/java/cn/reactnative/modules/update/Texts.java +28 -0
  24. package/android/src/main/java/cn/reactnative/modules/update/UiThreadRunner.java +1 -1
  25. package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +29 -29
  26. package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +12 -9
  27. package/cpp/patch_core/archive_limits.h +5 -0
  28. package/cpp/patch_core/archive_patch_core.cpp +26 -19
  29. package/cpp/patch_core/archive_patch_core.h +17 -8
  30. package/cpp/patch_core/digest.h +6 -1
  31. package/cpp/patch_core/error_codes.h +8 -1
  32. package/cpp/patch_core/hbc_transform.h +5 -0
  33. package/cpp/patch_core/hbc_transform_wire.h +5 -0
  34. package/cpp/patch_core/install_record.h +5 -0
  35. package/cpp/patch_core/jni_natives.h +27 -0
  36. package/cpp/patch_core/jni_registration.cpp +103 -0
  37. package/cpp/patch_core/obscured_text.h +44 -0
  38. package/cpp/patch_core/patch_core.cpp +13 -13
  39. package/cpp/patch_core/patch_core.h +11 -6
  40. package/cpp/patch_core/patch_core_android.cpp +10 -10
  41. package/cpp/patch_core/state_core.h +5 -0
  42. package/cpp/patch_core/state_ops.h +5 -0
  43. package/cpp/patch_core/update_core_android.cpp +23 -22
  44. package/cpp/update_flow_core/flow_json.h +6 -1
  45. package/cpp/update_flow_core/update_flow_core.cpp +35 -18
  46. package/cpp/update_flow_core/update_flow_core.h +13 -8
  47. package/cpp/update_flow_core/update_flow_jni.cpp +11 -13
  48. package/harmony/pushy/src/main/cpp/CMakeLists.txt +8 -8
  49. package/harmony/pushy/src/main/cpp/pushy.cpp +33 -33
  50. package/harmony/pushy/src/main/ets/ArchiveLimits.ts +15 -15
  51. package/harmony/pushy/src/main/ets/{NativeUpdateResult.ts → BundlePreparationResult.ts} +6 -6
  52. package/harmony/pushy/src/main/ets/DownloadTask.ts +60 -60
  53. package/harmony/pushy/src/main/ets/ErrorCodes.ts +13 -11
  54. package/harmony/pushy/src/main/ets/InstallRecord.ts +4 -4
  55. package/harmony/pushy/src/main/ets/NativePatchCore.ts +9 -9
  56. package/harmony/pushy/src/main/ets/PathUtils.ts +2 -2
  57. package/harmony/pushy/src/main/ets/{NativeUpdateConfig.ts → PushyConfiguration.ts} +12 -10
  58. package/harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets +8 -8
  59. package/harmony/pushy/src/main/ets/PushyTurboModule.ts +42 -41
  60. package/harmony/pushy/src/main/ets/{NativeCheckOrchestrator.ts → SyncCoordinator.ts} +71 -70
  61. package/harmony/pushy/src/main/ets/Texts.ts +28 -0
  62. package/harmony/pushy/src/main/ets/UpdateContext.ts +32 -31
  63. package/harmony/pushy.har +0 -0
  64. package/ios/RCTPushy/RCTPushy.h +8 -8
  65. package/ios/RCTPushy/RCTPushy.mm +155 -147
  66. package/ios/RCTPushy/RCTPushyConfiguration.h +13 -0
  67. package/ios/RCTPushy/{RCTPushyNativeConfig.mm → RCTPushyConfiguration.mm} +34 -7
  68. package/package.json +1 -1
  69. package/react-native-update.podspec +15 -3
  70. package/android/lib/arm64-v8a/librnupdate.so +0 -0
  71. package/android/lib/armeabi-v7a/librnupdate.so +0 -0
  72. package/android/lib/x86/librnupdate.so +0 -0
  73. package/android/lib/x86_64/librnupdate.so +0 -0
  74. package/ios/RCTPushy/RCTPushyNativeConfig.h +0 -5
@@ -14,9 +14,9 @@ import logger from './Logger';
14
14
  import {
15
15
  KEY_CONFIG,
16
16
  KEY_RESP_CACHE,
17
- markJsCheckCompleted,
18
- scheduleNativeCheck,
19
- } from './NativeCheckOrchestrator';
17
+ recordJsRound,
18
+ scheduleNativeSync,
19
+ } from './SyncCoordinator';
20
20
  import NativePatchCore, {
21
21
  STATE_OP_CLEAR_FIRST_TIME,
22
22
  STATE_OP_CLEAR_ROLLBACK_MARK,
@@ -29,14 +29,15 @@ import NativePatchCore, {
29
29
  import { assertSafePathComponent } from './PathUtils';
30
30
  import {
31
31
  ERROR_SWITCH_VERSION_FAILED,
32
- createUpdateError,
32
+ createPushyError,
33
33
  getErrorMessage,
34
- toUpdateError,
34
+ toPushyError,
35
35
  } from './ErrorCodes';
36
+ import { APP_DELTA_SUFFIX, PPK_DELTA_SUFFIX, PREFERENCES_NAME, STORAGE_DIR_NAME } from './Texts';
36
37
 
37
38
  export { isSafePathComponent } from './PathUtils';
38
39
 
39
- const TAG = 'UpdateContext';
40
+ const TAG = 'PushyContext';
40
41
  // 常规清理保留最近 3 天内触碰过的条目(续传 partial、staging 同样按 mtime)。
41
42
  const CLEANUP_MAX_AGE_DAYS = 3;
42
43
 
@@ -101,7 +102,7 @@ export class UpdateContext {
101
102
 
102
103
  private constructor(context: common.UIAbilityContext) {
103
104
  this.context = context;
104
- this.rootDir = context.filesDir + '/_update';
105
+ this.rootDir = `${context.filesDir}/${STORAGE_DIR_NAME}`;
105
106
  this.instanceId = `uc#${++UpdateContext.instanceCounter}`;
106
107
 
107
108
  try {
@@ -145,7 +146,7 @@ export class UpdateContext {
145
146
  private initPreferences() {
146
147
  try {
147
148
  this.preferences = preferences.getPreferencesSync(this.context, {
148
- name: 'update',
149
+ name: PREFERENCES_NAME,
149
150
  });
150
151
  } catch (e) {
151
152
  // Fail fast: a missing preferences store means no state can be persisted,
@@ -447,7 +448,7 @@ export class UpdateContext {
447
448
 
448
449
  logger.info(
449
450
  TAG,
450
- `binary version changed, resetting update state id=${this.instanceId}`,
451
+ `binary version changed, resetting state id=${this.instanceId}`,
451
452
  );
452
453
  UpdateContext.ignoreRollback = false;
453
454
  this.cleanUp();
@@ -477,10 +478,10 @@ export class UpdateContext {
477
478
  UpdateContext.nativeConfigGeneration += 1;
478
479
  this.preferences.putSync(KEY_CONFIG, config);
479
480
  this.preferences.deleteSync(KEY_RESP_CACHE);
480
- markJsCheckCompleted('');
481
+ recordJsRound('');
481
482
  }
482
483
  // Flush even an equal value so a retry after a storage error can succeed.
483
- return this.flushPreferences('configure native update');
484
+ return this.flushPreferences('persist configuration');
484
485
  }
485
486
 
486
487
  public setKv(key: string, value: string): Promise<void> {
@@ -614,7 +615,7 @@ export class UpdateContext {
614
615
  * 可插入 reset 的窗口(iOS/Android 用锁达到同一效果)。三项写入以一次
615
616
  * flush 落盘,失败拒绝。返回是否提交成功。
616
617
  */
617
- public async commitNativeCheckResult(
618
+ public async commitSyncResult(
618
619
  expectedGeneration: number,
619
620
  hash: string,
620
621
  hashInfoJson: string,
@@ -646,7 +647,7 @@ export class UpdateContext {
646
647
  this.preferences.putSync(KEY_RESP_CACHE, responseCacheJson);
647
648
  }
648
649
  } finally {
649
- flushed = this.endFlushBatch('commit native check result');
650
+ flushed = this.endFlushBatch('commit sync result');
650
651
  }
651
652
  await flushed;
652
653
  return true;
@@ -668,7 +669,7 @@ export class UpdateContext {
668
669
  params.deadlineUptimeMs = deadlineUptimeMs;
669
670
  await this.executeTask(params);
670
671
  } catch (e) {
671
- logger.error(TAG, `Failed to download full update: ${getErrorMessage(e)}`);
672
+ logger.error(TAG, `Failed to download full package: ${getErrorMessage(e)}`);
672
673
  throw e;
673
674
  }
674
675
  }
@@ -685,7 +686,7 @@ export class UpdateContext {
685
686
  hash,
686
687
  );
687
688
  params.originHash = assertSafePathComponent(originHash);
688
- params.targetFile = `${this.rootDir}/${originHash}_${hash}.ppk.patch`;
689
+ params.targetFile = `${this.rootDir}/${originHash}_${hash}${PPK_DELTA_SUFFIX}`;
689
690
  params.unzipDirectory = `${this.rootDir}/${hash}`;
690
691
  params.originDirectory = `${this.rootDir}/${params.originHash}`;
691
692
  params.deadlineUptimeMs = deadlineUptimeMs;
@@ -703,14 +704,14 @@ export class UpdateContext {
703
704
  url,
704
705
  hash,
705
706
  );
706
- params.targetFile = `${this.rootDir}/${hash}.app.patch`;
707
+ params.targetFile = `${this.rootDir}/${hash}${APP_DELTA_SUFFIX}`;
707
708
  params.unzipDirectory = `${this.rootDir}/${hash}`;
708
709
  params.deadlineUptimeMs = deadlineUptimeMs;
709
710
  return await this.executeTask(params);
710
711
  } catch (e) {
711
712
  logger.error(
712
713
  TAG,
713
- `Failed to download package patch: ${getErrorMessage(e)}`,
714
+ `Failed to download package delta: ${getErrorMessage(e)}`,
714
715
  );
715
716
  throw e;
716
717
  }
@@ -732,7 +733,7 @@ export class UpdateContext {
732
733
  }
733
734
  }
734
735
 
735
- // 原生冷启动检测(NativeCheckOrchestrator)用来跳过已就绪版本的重复下载
736
+ // 原生冷启动检测(SyncCoordinator)用来跳过已就绪版本的重复下载
736
737
  // ——alert 类策略下版本已下载但未激活,若不判在这里会每次冷启动重下一遍。
737
738
  public hasDownloadedVersion(hash: string): boolean {
738
739
  try {
@@ -752,7 +753,7 @@ export class UpdateContext {
752
753
  */
753
754
  private assertActivatable(safeHash: string): boolean {
754
755
  if (!fileIo.accessSync(this.getBundlePath(safeHash))) {
755
- throw createUpdateError(
756
+ throw createPushyError(
756
757
  ERROR_SWITCH_VERSION_FAILED,
757
758
  `Bundle version ${safeHash} not found.`,
758
759
  );
@@ -761,7 +762,7 @@ export class UpdateContext {
761
762
  this.readString('currentVersion') === safeHash ||
762
763
  this.readString('lastVersion') === safeHash;
763
764
  if (!this.hasDownloadedVersion(safeHash) && !legacyActivated) {
764
- throw createUpdateError(
765
+ throw createPushyError(
765
766
  ERROR_SWITCH_VERSION_FAILED,
766
767
  `Bundle version ${safeHash} is incomplete.`,
767
768
  );
@@ -801,7 +802,7 @@ export class UpdateContext {
801
802
  await this.flushPreferences(`switch version ${safeHash}`);
802
803
  } catch (e) {
803
804
  logger.error(TAG, `Failed to switch version: ${getErrorMessage(e)}`);
804
- throw toUpdateError(e, ERROR_SWITCH_VERSION_FAILED);
805
+ throw toPushyError(e, ERROR_SWITCH_VERSION_FAILED);
805
806
  }
806
807
  }
807
808
 
@@ -818,7 +819,7 @@ export class UpdateContext {
818
819
  public getBundleUrl() {
819
820
  UpdateContext.isUsingBundleUrl = true;
820
821
  this.trace('getBundleUrl:enter');
821
- let nativeCheckRolledBackVersion = '';
822
+ let syncRolledBackVersion = '';
822
823
  try {
823
824
  const stateBeforeLaunch = this.getStateSnapshot();
824
825
  const launchState = NativePatchCore.runStateCore(
@@ -828,7 +829,7 @@ export class UpdateContext {
828
829
  UpdateContext.ignoreRollback,
829
830
  true,
830
831
  );
831
- nativeCheckRolledBackVersion = launchState.rolledBackVersion || '';
832
+ syncRolledBackVersion = launchState.rolledBackVersion || '';
832
833
  if (launchState.didRollback) {
833
834
  // The crash-protection rollback: the new version never called
834
835
  // markSuccess. Keep this visible in release logs.
@@ -865,24 +866,24 @@ export class UpdateContext {
865
866
  if (!fileIo.accessSync(bundleFile)) {
866
867
  logger.error(TAG, `Bundle version ${version} not found.`);
867
868
  version = this.rollBack();
868
- nativeCheckRolledBackVersion = this.rolledBackVersion();
869
+ syncRolledBackVersion = this.rolledBackVersion();
869
870
  continue;
870
871
  }
871
872
  UpdateContext.launchVersion = version;
872
- nativeCheckRolledBackVersion = this.rolledBackVersion();
873
+ syncRolledBackVersion = this.rolledBackVersion();
873
874
  return bundleFile;
874
875
  } catch (e) {
875
876
  logger.error(TAG, `Failed to access bundle file: ${getErrorMessage(e)}`);
876
877
  version = this.rollBack();
877
- nativeCheckRolledBackVersion = this.rolledBackVersion();
878
+ syncRolledBackVersion = this.rolledBackVersion();
878
879
  }
879
880
  }
880
- nativeCheckRolledBackVersion = this.rolledBackVersion();
881
+ syncRolledBackVersion = this.rolledBackVersion();
881
882
  return '';
882
883
  } finally {
883
884
  // State corruption is exactly when the native rescue check is needed;
884
885
  // schedule even if state parsing/rollback throws before a normal exit.
885
- scheduleNativeCheck(this, nativeCheckRolledBackVersion);
886
+ scheduleNativeSync(this, syncRolledBackVersion);
886
887
  }
887
888
  }
888
889
 
@@ -936,7 +937,7 @@ export class UpdateContext {
936
937
  // 安装的二进制,每次(覆盖)安装 updateTime 都会变,每个安装只算一次。
937
938
  private static readonly KEY_BUNDLE_HASH_CACHE = 'bundleHashCache';
938
939
 
939
- private getBundleUpdateTime(): number {
940
+ private getBundleModifiedTime(): number {
940
941
  try {
941
942
  const bundleInfo = bundleManager.getBundleInfoForSelfSync(
942
943
  this.getBundleFlags(),
@@ -945,7 +946,7 @@ export class UpdateContext {
945
946
  } catch (error) {
946
947
  logger.error(
947
948
  TAG,
948
- `Failed to get bundle update time: ${getErrorMessage(error)}`,
949
+ `Failed to get bundle modification time: ${getErrorMessage(error)}`,
949
950
  );
950
951
  return 0;
951
952
  }
@@ -962,7 +963,7 @@ export class UpdateContext {
962
963
  // debug 下 bundle 由 metro 提供,与 dev 删 buildTime 的行为对齐。
963
964
  return '';
964
965
  }
965
- const cachePrefix = `${this.getPackageVersion()}|${this.getBundleUpdateTime()}|`;
966
+ const cachePrefix = `${this.getPackageVersion()}|${this.getBundleModifiedTime()}|`;
966
967
  const cached = this.readString(UpdateContext.KEY_BUNDLE_HASH_CACHE);
967
968
  if (cached.startsWith(cachePrefix)) {
968
969
  return cached.slice(cachePrefix.length);
package/harmony/pushy.har CHANGED
Binary file
@@ -1,9 +1,9 @@
1
1
  #import <React/RCTBridgeModule.h>
2
2
  #import <React/RCTEventEmitter.h>
3
3
 
4
- typedef void (^RCTPushyNativeConfigurationCompletion)(NSError * _Nullable error);
4
+ typedef void (^RCTPushyConfigurationCompletion)(NSError * _Nullable error);
5
5
 
6
- typedef void (^RCTPushyNativeUpdateCompletion)(NSDictionary<NSString *, id> * _Nonnull result);
6
+ typedef void (^RCTPushyBundlePreparationCompletion)(NSDictionary<NSString *, id> * _Nonnull result);
7
7
 
8
8
  @interface RCTPushy : RCTEventEmitter<RCTBridgeModule>
9
9
 
@@ -14,20 +14,20 @@ typedef void (^RCTPushyNativeUpdateCompletion)(NSDictionary<NSString *, id> * _N
14
14
  * normal launch bundle resolution for first-install native-only provisioning.
15
15
  */
16
16
  + (void)configure:(NSDictionary<NSString *, id> * _Nonnull)options
17
- completion:(RCTPushyNativeConfigurationCompletion _Nullable)completion
17
+ completion:(RCTPushyConfigurationCompletion _Nullable)completion
18
18
  NS_SWIFT_NAME(configure(_:completion:));
19
19
 
20
20
  /**
21
- * Start, join, or reuse this process's native update round. Call after the
22
- * host's real bundleURL resolution; this method never resolves the bundle
23
- * again, reloads React Native, or displays UI. Configuration is the one
21
+ * Start, join, or reuse this process's native bundle-preparation round. Call
22
+ * after the host's real bundleURL resolution; this method never resolves the
23
+ * bundle again, reloads React Native, or displays UI. Configuration is the one
24
24
  * persisted by the JS SDK. The optional completion runs on the main queue.
25
25
  *
26
26
  * Result keys: status (skipped/noUpdate/downloaded/failed/cancelled), reason,
27
27
  * hash (empty when nothing was installed), activated (selected for NEXT
28
28
  * launch, not a reload of the running instance).
29
29
  */
30
- + (void)checkAndUpdateWithCompletion:(RCTPushyNativeUpdateCompletion _Nullable)completion
31
- NS_SWIFT_NAME(checkAndUpdate(completion:));
30
+ + (void)prepareBundleWithCompletion:(RCTPushyBundlePreparationCompletion _Nullable)completion
31
+ NS_SWIFT_NAME(prepareBundle(completion:));
32
32
 
33
33
  @end