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.
- package/README-CN.md +7 -0
- package/README.md +8 -0
- package/android/build.gradle +46 -14
- package/android/jni/Android.mk +2 -1
- 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/src/main/java/cn/reactnative/modules/update/ApkInstaller.java +6 -6
- package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateResult.java → BundlePreparationResult.java} +6 -6
- package/android/src/main/java/cn/reactnative/modules/update/BundledResourceCopier.java +4 -4
- package/android/src/main/java/cn/reactnative/modules/update/{CrashRescue.java → CrashHold.java} +12 -12
- package/android/src/main/java/cn/reactnative/modules/update/DownloadTask.java +28 -24
- package/android/src/main/java/cn/reactnative/modules/update/ErrorCodes.java +2 -1
- package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateFlow.java → FlowBridge.java} +6 -6
- package/android/src/main/java/cn/reactnative/modules/update/HttpUtils.java +6 -3
- package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateCore.java → NativeCore.java} +4 -4
- package/android/src/main/java/cn/reactnative/modules/update/{NativeUpdateConfig.java → PushyConfiguration.java} +13 -8
- package/android/src/main/java/cn/reactnative/modules/update/{PushyNativeUpdate.java → PushyRuntime.java} +15 -15
- package/android/src/main/java/cn/reactnative/modules/update/ReactReloadManager.java +7 -7
- package/android/src/main/java/cn/reactnative/modules/update/StateSerialRunner.java +1 -1
- package/android/src/main/java/cn/reactnative/modules/update/{NativeCheckOrchestrator.java → SyncCoordinator.java} +107 -103
- package/android/src/main/java/cn/reactnative/modules/update/Texts.java +28 -0
- package/android/src/main/java/cn/reactnative/modules/update/UiThreadRunner.java +1 -1
- package/android/src/main/java/cn/reactnative/modules/update/UpdateContext.java +29 -29
- package/android/src/main/java/cn/reactnative/modules/update/UpdateModuleImpl.java +12 -9
- package/cpp/patch_core/archive_limits.h +5 -0
- package/cpp/patch_core/archive_patch_core.cpp +26 -19
- package/cpp/patch_core/archive_patch_core.h +17 -8
- package/cpp/patch_core/digest.h +6 -1
- package/cpp/patch_core/error_codes.h +8 -1
- package/cpp/patch_core/hbc_transform.h +5 -0
- package/cpp/patch_core/hbc_transform_wire.h +5 -0
- package/cpp/patch_core/install_record.h +5 -0
- package/cpp/patch_core/jni_natives.h +27 -0
- package/cpp/patch_core/jni_registration.cpp +103 -0
- package/cpp/patch_core/obscured_text.h +44 -0
- package/cpp/patch_core/patch_core.cpp +13 -13
- package/cpp/patch_core/patch_core.h +11 -6
- package/cpp/patch_core/patch_core_android.cpp +10 -10
- package/cpp/patch_core/state_core.h +5 -0
- package/cpp/patch_core/state_ops.h +5 -0
- package/cpp/patch_core/update_core_android.cpp +23 -22
- package/cpp/update_flow_core/flow_json.h +6 -1
- package/cpp/update_flow_core/update_flow_core.cpp +35 -18
- package/cpp/update_flow_core/update_flow_core.h +13 -8
- package/cpp/update_flow_core/update_flow_jni.cpp +11 -13
- package/harmony/pushy/src/main/cpp/CMakeLists.txt +8 -8
- package/harmony/pushy/src/main/cpp/pushy.cpp +33 -33
- package/harmony/pushy/src/main/ets/ArchiveLimits.ts +15 -15
- package/harmony/pushy/src/main/ets/{NativeUpdateResult.ts → BundlePreparationResult.ts} +6 -6
- package/harmony/pushy/src/main/ets/DownloadTask.ts +60 -60
- package/harmony/pushy/src/main/ets/ErrorCodes.ts +13 -11
- package/harmony/pushy/src/main/ets/InstallRecord.ts +4 -4
- package/harmony/pushy/src/main/ets/NativePatchCore.ts +9 -9
- package/harmony/pushy/src/main/ets/PathUtils.ts +2 -2
- package/harmony/pushy/src/main/ets/{NativeUpdateConfig.ts → PushyConfiguration.ts} +12 -10
- package/harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets +8 -8
- package/harmony/pushy/src/main/ets/PushyTurboModule.ts +42 -41
- package/harmony/pushy/src/main/ets/{NativeCheckOrchestrator.ts → SyncCoordinator.ts} +71 -70
- package/harmony/pushy/src/main/ets/Texts.ts +28 -0
- package/harmony/pushy/src/main/ets/UpdateContext.ts +32 -31
- package/harmony/pushy.har +0 -0
- package/ios/RCTPushy/RCTPushy.h +8 -8
- package/ios/RCTPushy/RCTPushy.mm +155 -147
- package/ios/RCTPushy/RCTPushyConfiguration.h +13 -0
- package/ios/RCTPushy/{RCTPushyNativeConfig.mm → RCTPushyConfiguration.mm} +34 -7
- package/package.json +1 -1
- package/react-native-update.podspec +15 -3
- 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/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
|
|
13
|
-
final class
|
|
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
|
-
|
|
21
|
+
Texts.reveal("3203e0c1bdd1270a372f18f8c2b6de7f4f2607f5b3d5b9817b592947e5cdefbc8a7e"),
|
|
22
|
+
Texts.reveal("3203e0c1bdd1270a372f18f8c2b6de7f4f2607f5f0daac9c644a620ae88ca1ad93")
|
|
21
23
|
};
|
|
22
24
|
private static final String[] QUERY_URLS = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
Texts.reveal("3203e0c1bdd1270a253608fcd3fd9362476817f4f0d5a1996342631be3c2a3a9d779552507fdcde8928a6f512f5ce2ccbdc869404d2f1de79daa826d562c0913eec4fa9b7d4426"),
|
|
26
|
+
Texts.reveal("3203e0c1bdd1270a213b12b7dca09468462e12f3b0d5bd813d482446f4c6a1be8e79552507fdcda68cd06e5c3710e480a4867048483e55e0c2ab8d7d43030d1ce9c3b183214e2601f2f0d5b782601e2719e8ca")
|
|
25
27
|
};
|
|
26
28
|
|
|
27
|
-
|
|
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) && !
|
|
47
|
-
throw invalid("afterDownload must be none or
|
|
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
|
|
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(
|
|
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
|
|
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-
|
|
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/
|
|
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 =
|
|
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
|
|
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
|
|
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
|
-
|
|
102
|
+
BundlePreparationResult outcome;
|
|
103
103
|
try {
|
|
104
104
|
if (BuildConfig.DEBUG) {
|
|
105
|
-
outcome =
|
|
105
|
+
outcome = BundlePreparationResult.of(BundlePreparationResult.SKIPPED, "debug");
|
|
106
106
|
} else {
|
|
107
|
-
outcome =
|
|
107
|
+
outcome = SyncCoordinator.prepareBundle(
|
|
108
108
|
UpdateContext.getInstance(applicationContext));
|
|
109
109
|
}
|
|
110
110
|
} catch (InterruptedException e) {
|
|
111
111
|
Thread.currentThread().interrupt();
|
|
112
|
-
outcome =
|
|
112
|
+
outcome = BundlePreparationResult.of(BundlePreparationResult.CANCELLED, "interrupted");
|
|
113
113
|
} catch (Exception | LinkageError e) {
|
|
114
|
-
Log.w(
|
|
115
|
-
outcome =
|
|
114
|
+
Log.w(Texts.LOG_TAG, "native host sync failed", e);
|
|
115
|
+
outcome = BundlePreparationResult.of(BundlePreparationResult.FAILED, "internal_error");
|
|
116
116
|
}
|
|
117
|
-
final
|
|
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(
|
|
59
|
-
"Failed to
|
|
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(
|
|
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(
|
|
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(
|
|
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("
|
|
256
|
-
reloadMethod.invoke(reactHost,
|
|
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(
|
|
59
|
+
Log.e(Texts.LOG_TAG, operationName + " failed", error);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|