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
@@ -9,22 +9,27 @@ import org.json.JSONArray;
9
9
  import org.json.JSONException;
10
10
  import org.json.JSONObject;
11
11
 
12
- /** Internal normalizer for the JSONObject accepted by PushyNativeUpdate.configure. */
13
- final class NativeUpdateConfig {
12
+ /** Internal normalizer for the JSONObject accepted by PushyRuntime.configure. */
13
+ final class PushyConfiguration {
14
14
  private static final Set<String> KEYS = new HashSet<>(Arrays.asList(
15
15
  "appKey", "endpoints", "queryUrls", "afterDownload", "disabled",
16
16
  "packageVersion", "rnu", "rn"));
17
17
  private static final Pattern URL = Pattern.compile(
18
18
  "^https?://(\\[[0-9a-fA-F:]+\\]|[a-zA-Z0-9.-]+)(:[0-9]+)?([/?#]|$)");
19
+ // Default service addresses, encoded by scripts/encode-native-text.ts.
19
20
  private static final String[] ENDPOINTS = {
20
- "https://update.react-native.cn/api", "https://update.reactnative.cn/api"
21
+ Texts.reveal("3203e0c1bdd1270a372f18f8c2b6de7f4f2607f5b3d5b9817b592947e5cdefbc8a7e"),
22
+ Texts.reveal("3203e0c1bdd1270a372f18f8c2b6de7f4f2607f5f0daac9c644a620ae88ca1ad93")
21
23
  };
22
24
  private static final String[] QUERY_URLS = {
23
- "https://gitee.com/sunnylqm/react-native-pushy/raw/master/endpoints.json",
24
- "https://cdn.jsdelivr.net/gh/reactnativecn/react-native-update@master/endpoints.json"
25
+ Texts.reveal("3203e0c1bdd1270a253608fcd3fd9362476817f4f0d5a1996342631be3c2a3a9d779552507fdcde8928a6f512f5ce2ccbdc869404d2f1de79daa826d562c0913eec4fa9b7d4426"),
26
+ Texts.reveal("3203e0c1bdd1270a213b12b7dca09468462e12f3b0d5bd813d482446f4c6a1be8e79552507fdcda68cd06e5c3710e480a4867048483e55e0c2ab8d7d43030d1ce9c3b183214e2601f2f0d5b782601e2719e8ca")
25
27
  };
26
28
 
27
- private NativeUpdateConfig() {}
29
+ // afterDownload value that selects the bundle for the next launch, encoded.
30
+ static final String POLICY_NEXT_LAUNCH = Texts.reveal("2912e0ffab8e6c70323b1dedd3");
31
+
32
+ private PushyConfiguration() {}
28
33
 
29
34
  static String normalize(String json) throws JSONException {
30
35
  JSONObject options = new JSONObject(json);
@@ -43,8 +48,8 @@ final class NativeUpdateConfig {
43
48
  "queryUrls", false);
44
49
  String afterDownload = options.has("afterDownload")
45
50
  ? string(options.get("afterDownload"), "afterDownload", false) : "none";
46
- if (!"none".equals(afterDownload) && !"setNeedUpdate".equals(afterDownload)) {
47
- throw invalid("afterDownload must be none or setNeedUpdate");
51
+ if (!"none".equals(afterDownload) && !POLICY_NEXT_LAUNCH.equals(afterDownload)) {
52
+ throw invalid("afterDownload must be none or " + POLICY_NEXT_LAUNCH);
48
53
  }
49
54
  Object disabled = options.has("disabled") ? options.get("disabled") : Boolean.FALSE;
50
55
  if (!(disabled instanceof Boolean)) {
@@ -11,18 +11,18 @@ import java.util.concurrent.Executors;
11
11
  import java.util.concurrent.ThreadFactory;
12
12
 
13
13
  /** Bridge-free native configuration and update APIs. */
14
- public final class PushyNativeUpdate {
14
+ public final class PushyRuntime {
15
15
  public interface Callback {
16
16
  /** Always called on the main thread, including skipped and failed checks. */
17
- void onComplete(NativeUpdateResult result);
17
+ void onComplete(BundlePreparationResult result);
18
18
  }
19
19
 
20
20
  // A single waiting worker, not one thread per caller. The actual round is
21
- // shared with cold start and crash rescue by NativeCheckOrchestrator.
21
+ // shared with cold start and crash rescue by SyncCoordinator.
22
22
  private static final Executor WORKER = Executors.newSingleThreadExecutor(new ThreadFactory() {
23
23
  @Override
24
24
  public Thread newThread(Runnable runnable) {
25
- Thread thread = new Thread(runnable, "pushy-host-check");
25
+ Thread thread = new Thread(runnable, "pushy-host-sync");
26
26
  thread.setDaemon(true);
27
27
  return thread;
28
28
  }
@@ -46,7 +46,7 @@ public final class PushyNativeUpdate {
46
46
  /**
47
47
  * Validate and persist a complete configuration, even before JS or bundle
48
48
  * resolution. This starts no network work and never resolves a bundle.
49
- * Await the callback before continuing startup/checkAndUpdate. Unless JS
49
+ * Await the callback before continuing startup/prepareBundle. Unless JS
50
50
  * uses nativeConfigSource: 'native', later JS config writes can replace it.
51
51
  */
52
52
  public static void configure(Context context, JSONObject options, final ConfigurationCallback callback) {
@@ -61,7 +61,7 @@ public final class PushyNativeUpdate {
61
61
  public void run() {
62
62
  Exception failure = null;
63
63
  try {
64
- String config = NativeUpdateConfig.normalize(snapshot);
64
+ String config = PushyConfiguration.normalize(snapshot);
65
65
  UpdateContext.getInstance(applicationContext).setNativeConfig(config);
66
66
  } catch (Exception e) {
67
67
  failure = e;
@@ -79,7 +79,7 @@ public final class PushyNativeUpdate {
79
79
  });
80
80
  }
81
81
 
82
- private PushyNativeUpdate() {
82
+ private PushyRuntime() {
83
83
  }
84
84
 
85
85
  /**
@@ -91,7 +91,7 @@ public final class PushyNativeUpdate {
91
91
  * this method: bundle resolution consumes first-load/rollback markers.
92
92
  * Missing persisted configuration and debug builds are reported as skipped.
93
93
  */
94
- public static void checkAndUpdate(Context context, final Callback callback) {
94
+ public static void prepareBundle(Context context, final Callback callback) {
95
95
  if (context == null || callback == null) {
96
96
  throw new IllegalArgumentException("context and callback are required");
97
97
  }
@@ -99,22 +99,22 @@ public final class PushyNativeUpdate {
99
99
  WORKER.execute(new Runnable() {
100
100
  @Override
101
101
  public void run() {
102
- NativeUpdateResult outcome;
102
+ BundlePreparationResult outcome;
103
103
  try {
104
104
  if (BuildConfig.DEBUG) {
105
- outcome = NativeUpdateResult.of(NativeUpdateResult.SKIPPED, "debug");
105
+ outcome = BundlePreparationResult.of(BundlePreparationResult.SKIPPED, "debug");
106
106
  } else {
107
- outcome = NativeCheckOrchestrator.checkAndUpdate(
107
+ outcome = SyncCoordinator.prepareBundle(
108
108
  UpdateContext.getInstance(applicationContext));
109
109
  }
110
110
  } catch (InterruptedException e) {
111
111
  Thread.currentThread().interrupt();
112
- outcome = NativeUpdateResult.of(NativeUpdateResult.CANCELLED, "interrupted");
112
+ outcome = BundlePreparationResult.of(BundlePreparationResult.CANCELLED, "interrupted");
113
113
  } catch (Exception | LinkageError e) {
114
- Log.w("react-native-update", "native host check failed", e);
115
- outcome = NativeUpdateResult.of(NativeUpdateResult.FAILED, "internal_error");
114
+ Log.w(Texts.LOG_TAG, "native host sync failed", e);
115
+ outcome = BundlePreparationResult.of(BundlePreparationResult.FAILED, "internal_error");
116
116
  }
117
- final NativeUpdateResult result = outcome;
117
+ final BundlePreparationResult result = outcome;
118
118
  new Handler(Looper.getMainLooper()).post(new Runnable() {
119
119
  @Override
120
120
  public void run() {
@@ -55,8 +55,8 @@ final class ReactReloadManager {
55
55
  reloadReactHost(reactHost, createBundleLoader(application, updateBundlePath, true));
56
56
  return;
57
57
  } catch (Throwable err) {
58
- Log.e(UpdateContext.TAG,
59
- "Failed to reload via ReactHost, trying ReactInstanceManager", err);
58
+ Log.e(Texts.LOG_TAG,
59
+ "Failed to restart via ReactHost, trying ReactInstanceManager", err);
60
60
  }
61
61
  }
62
62
 
@@ -123,7 +123,7 @@ final class ReactReloadManager {
123
123
  return (String) resolvedBundleAssetName;
124
124
  }
125
125
  } catch (Exception e) {
126
- Log.e(UpdateContext.TAG, "Failed to get default asset name from ReactNativeHost", e);
126
+ Log.e(Texts.LOG_TAG, "Failed to get default asset name from ReactNativeHost", e);
127
127
  }
128
128
 
129
129
  return bundleAssetName;
@@ -170,7 +170,7 @@ final class ReactReloadManager {
170
170
  }
171
171
  }
172
172
  } catch (Throwable ignored) {
173
- Log.w(UpdateContext.TAG, "getReactHost via ReactDelegate reflection failed", ignored);
173
+ Log.w(Texts.LOG_TAG, "getReactHost via ReactDelegate reflection failed", ignored);
174
174
  }
175
175
  }
176
176
 
@@ -178,7 +178,7 @@ final class ReactReloadManager {
178
178
  Method getReactHostMethod = application.getClass().getMethod("getReactHost");
179
179
  return getReactHostMethod.invoke(application);
180
180
  } catch (Throwable ignored) {
181
- Log.w(UpdateContext.TAG, "getReactHost via Application.getReactHost() failed", ignored);
181
+ Log.w(Texts.LOG_TAG, "getReactHost via Application.getReactHost() failed", ignored);
182
182
  }
183
183
 
184
184
  return null;
@@ -252,8 +252,8 @@ final class ReactReloadManager {
252
252
  jsBundleLoaderField.setAccessible(true);
253
253
  jsBundleLoaderField.set(reactHostDelegate, loader);
254
254
 
255
- Method reloadMethod = reactHost.getClass().getMethod("reload", String.class);
256
- reloadMethod.invoke(reactHost, "react-native-update");
255
+ Method reloadMethod = reactHost.getClass().getMethod(Texts.reveal("2812f8deaf8f"), String.class);
256
+ reloadMethod.invoke(reactHost, Texts.LOG_TAG);
257
257
  }
258
258
 
259
259
  private static ReactInstanceManager resolveReactInstanceManager(
@@ -56,7 +56,7 @@ final class StateSerialRunner {
56
56
  if (promise != null) {
57
57
  promise.reject(errorCode, operationName + " failed", error);
58
58
  } else {
59
- Log.e(UpdateContext.TAG, operationName + " failed", error);
59
+ Log.e(Texts.LOG_TAG, operationName + " failed", error);
60
60
  }
61
61
  }
62
62
  }