@bravemobile/react-native-code-push 12.4.1 → 13.1.0-beta.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/CodePush.podspec +47 -2
- package/README.md +118 -3
- package/THIRD-PARTY-NOTICES +96 -0
- package/android/app/build.gradle +26 -0
- package/android/app/proguard-rules.pro +5 -0
- package/android/app/src/main/cpp/CMakeLists.txt +38 -0
- package/android/app/src/main/cpp/binarypatch_jni.c +181 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/BinaryPatchAttempt.java +92 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/BinaryPatchResult.java +64 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +46 -11
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushBinaryPatch.java +293 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushConstants.java +25 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +79 -88
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +159 -4
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateUtils.java +13 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/HDiffPatchNative.java +52 -0
- package/android/app/src/test/java/com/microsoft/codepush/react/CodePushBinaryPatchTest.java +393 -0
- package/android/app/src/test/java/com/microsoft/codepush/react/CodePushUpdateManagerBinaryPatchTest.java +207 -0
- package/android/app/src/test/java/com/microsoft/codepush/react/CodePushUpdateManagerDownloadTest.java +449 -0
- package/android/codepush-export.gradle +115 -0
- package/cli/commands/bundleCommand/bundleCodePush.ts +39 -7
- package/cli/commands/bundleCommand/index.ts +9 -1
- package/cli/commands/releaseCommand/addToReleaseHistory.ts +7 -0
- package/cli/commands/releaseCommand/index.test.ts +118 -0
- package/cli/commands/releaseCommand/index.ts +20 -2
- package/cli/commands/releaseCommand/release.test.ts +582 -0
- package/cli/commands/releaseCommand/release.ts +232 -15
- package/cli/dist/commands/bundleCommand/bundleCodePush.js +26 -7
- package/cli/dist/commands/bundleCommand/index.js +5 -1
- package/cli/dist/commands/releaseCommand/addToReleaseHistory.js +6 -1
- package/cli/dist/commands/releaseCommand/index.js +8 -1
- package/cli/dist/commands/releaseCommand/index.test.js +96 -0
- package/cli/dist/commands/releaseCommand/release.js +165 -17
- package/cli/dist/commands/releaseCommand/release.test.js +367 -0
- package/cli/dist/functions/makeBinaryPatchBundle.js +248 -0
- package/cli/dist/functions/makeBinaryPatchBundle.test.js +321 -0
- package/cli/dist/functions/makeCodePushBundle.js +4 -2
- package/cli/dist/functions/runHermesEmitBinaryCommand.js +98 -27
- package/cli/dist/functions/runHermesEmitBinaryCommand.test.js +100 -0
- package/cli/dist/jest.globalSetup.js +38 -0
- package/cli/dist/utils/binaryPatch.js +86 -0
- package/cli/dist/utils/binaryPatch.test.js +190 -0
- package/cli/functions/makeBinaryPatchBundle.test.ts +410 -0
- package/cli/functions/makeBinaryPatchBundle.ts +367 -0
- package/cli/functions/makeCodePushBundle.ts +4 -2
- package/cli/functions/runHermesEmitBinaryCommand.test.ts +124 -0
- package/cli/functions/runHermesEmitBinaryCommand.ts +112 -26
- package/cli/jest.globalSetup.ts +43 -0
- package/cli/utils/binaryPatch.test.ts +234 -0
- package/cli/utils/binaryPatch.ts +103 -0
- package/cpp/binarypatch/binarypatch_zstd_decompressor.c +187 -0
- package/cpp/binarypatch/binarypatch_zstd_decompressor.h +47 -0
- package/cpp/binarypatch/vendor/HDiffPatch/libHDiffPatch/HPatch/checksum_plugin.h +52 -0
- package/cpp/binarypatch/vendor/HDiffPatch/libHDiffPatch/HPatch/hpatch_mt/hpatch_mt.h +147 -0
- package/cpp/binarypatch/vendor/HDiffPatch/libHDiffPatch/HPatch/patch.c +3315 -0
- package/cpp/binarypatch/vendor/HDiffPatch/libHDiffPatch/HPatch/patch.h +268 -0
- package/cpp/binarypatch/vendor/HDiffPatch/libHDiffPatch/HPatch/patch_private.h +297 -0
- package/cpp/binarypatch/vendor/HDiffPatch/libHDiffPatch/HPatch/patch_types.h +434 -0
- package/cpp/binarypatch/vendor/zstd/common/allocations.h +55 -0
- package/cpp/binarypatch/vendor/zstd/common/bits.h +205 -0
- package/cpp/binarypatch/vendor/zstd/common/bitstream.h +454 -0
- package/cpp/binarypatch/vendor/zstd/common/compiler.h +464 -0
- package/cpp/binarypatch/vendor/zstd/common/cpu.h +249 -0
- package/cpp/binarypatch/vendor/zstd/common/debug.c +30 -0
- package/cpp/binarypatch/vendor/zstd/common/debug.h +107 -0
- package/cpp/binarypatch/vendor/zstd/common/entropy_common.c +340 -0
- package/cpp/binarypatch/vendor/zstd/common/error_private.c +64 -0
- package/cpp/binarypatch/vendor/zstd/common/error_private.h +158 -0
- package/cpp/binarypatch/vendor/zstd/common/fse.h +625 -0
- package/cpp/binarypatch/vendor/zstd/common/fse_decompress.c +315 -0
- package/cpp/binarypatch/vendor/zstd/common/huf.h +277 -0
- package/cpp/binarypatch/vendor/zstd/common/mem.h +422 -0
- package/cpp/binarypatch/vendor/zstd/common/pool.c +371 -0
- package/cpp/binarypatch/vendor/zstd/common/pool.h +81 -0
- package/cpp/binarypatch/vendor/zstd/common/portability_macros.h +171 -0
- package/cpp/binarypatch/vendor/zstd/common/threading.c +182 -0
- package/cpp/binarypatch/vendor/zstd/common/threading.h +142 -0
- package/cpp/binarypatch/vendor/zstd/common/xxhash.c +18 -0
- package/cpp/binarypatch/vendor/zstd/common/xxhash.h +7094 -0
- package/cpp/binarypatch/vendor/zstd/common/zstd_common.c +48 -0
- package/cpp/binarypatch/vendor/zstd/common/zstd_deps.h +123 -0
- package/cpp/binarypatch/vendor/zstd/common/zstd_internal.h +324 -0
- package/cpp/binarypatch/vendor/zstd/common/zstd_trace.h +156 -0
- package/cpp/binarypatch/vendor/zstd/decompress/huf_decompress.c +1944 -0
- package/cpp/binarypatch/vendor/zstd/decompress/zstd_ddict.c +244 -0
- package/cpp/binarypatch/vendor/zstd/decompress/zstd_ddict.h +44 -0
- package/cpp/binarypatch/vendor/zstd/decompress/zstd_decompress.c +2410 -0
- package/cpp/binarypatch/vendor/zstd/decompress/zstd_decompress_block.c +2209 -0
- package/cpp/binarypatch/vendor/zstd/decompress/zstd_decompress_block.h +73 -0
- package/cpp/binarypatch/vendor/zstd/decompress/zstd_decompress_internal.h +240 -0
- package/cpp/binarypatch/vendor/zstd/zstd.h +3206 -0
- package/cpp/binarypatch/vendor/zstd/zstd_errors.h +107 -0
- package/ios/CodePush/CodePush.h +58 -9
- package/ios/CodePush/{CodePush.m → CodePush.mm} +77 -63
- package/ios/CodePush/CodePushBinaryPatch.h +80 -0
- package/ios/CodePush/CodePushBinaryPatch.m +473 -0
- package/ios/CodePush/CodePushPackage.m +183 -2
- package/ios/CodePush/CodePushUpdateUtils.m +49 -1
- package/ios/CodePush.xcodeproj/project.pbxproj +6 -6
- package/package.json +28 -4
- package/react-native.config.js +3 -1
- package/scripts/binary-patch/build-hdiffpatch.sh +86 -0
- package/scripts/export-embedded-bundle.sh +76 -0
- package/src/CodePush.js +190 -96
- package/src/CodePush.test.js +382 -0
- package/src/native/NativeCodePush.ts +162 -0
- package/src/package-mixins.js +24 -11
- package/src/specs/NativeCodePush.ts +43 -0
- package/typings/react-native-code-push.d.ts +77 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +0 -102
- package/src/AlertAdapter.js +0 -24
|
@@ -28,6 +28,12 @@ export interface ReleaseInfo {
|
|
|
28
28
|
enabled: boolean;
|
|
29
29
|
mandatory: boolean;
|
|
30
30
|
downloadUrl: string;
|
|
31
|
+
/**
|
|
32
|
+
* The URL of a binary patch archive built against the JS bundle embedded in the app binary.
|
|
33
|
+
* It is only present when the release was published together with such a patch, and a client
|
|
34
|
+
* that cannot use it downloads the full update from `downloadUrl` instead.
|
|
35
|
+
*/
|
|
36
|
+
binaryPatchDownloadUrl?: string;
|
|
31
37
|
packageHash: string;
|
|
32
38
|
rollout?: number;
|
|
33
39
|
}
|
|
@@ -35,6 +41,12 @@ export interface ReleaseInfo {
|
|
|
35
41
|
// from code-push SDK
|
|
36
42
|
export interface UpdateCheckResponse {
|
|
37
43
|
download_url?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The URL of a binary patch archive built against the JS bundle embedded in the app binary.
|
|
46
|
+
* It is only present when the release was published together with such a patch, and a client
|
|
47
|
+
* that cannot use it downloads the full update from `download_url` instead.
|
|
48
|
+
*/
|
|
49
|
+
binary_patch_download_url?: string;
|
|
38
50
|
description?: string;
|
|
39
51
|
is_available: boolean;
|
|
40
52
|
is_disabled?: boolean;
|
|
@@ -47,6 +59,50 @@ export interface UpdateCheckResponse {
|
|
|
47
59
|
is_mandatory?: boolean;
|
|
48
60
|
}
|
|
49
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Why an update that was published with a binary patch had to be downloaded in full
|
|
64
|
+
* instead. These are the words every platform's applier reports, so a rollout can be
|
|
65
|
+
* judged by them whichever platform it is running on.
|
|
66
|
+
*/
|
|
67
|
+
export type BinaryPatchFallbackReason =
|
|
68
|
+
/** The bundle inside the app binary could not be opened or read. */
|
|
69
|
+
| "base_bundle_unavailable"
|
|
70
|
+
/** The bundle inside the app binary is not the one the patch was computed against. */
|
|
71
|
+
| "base_hash_mismatch"
|
|
72
|
+
/** The manifest is missing, malformed, points outside the archive, or asks for too much. */
|
|
73
|
+
| "invalid_manifest"
|
|
74
|
+
/** The patch was produced by a format or a codec this client cannot apply. */
|
|
75
|
+
| "unsupported_format"
|
|
76
|
+
/** The applier refused the patch, or the restored bundle could not be written. */
|
|
77
|
+
| "patch_apply_failed"
|
|
78
|
+
/** The restored bundle is not the one the manifest promised. */
|
|
79
|
+
| "target_verification_failed"
|
|
80
|
+
/** The update restored from the patch did not pass the checks that follow the restore. */
|
|
81
|
+
| "package_verification_failed";
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* How installing an update from its binary patch archive went.
|
|
85
|
+
*/
|
|
86
|
+
export interface BinaryPatchResult {
|
|
87
|
+
/**
|
|
88
|
+
* Whether the update was installed from its patch archive, or had to be downloaded in
|
|
89
|
+
* full instead. A fallback is not an error: the update is installed either way.
|
|
90
|
+
*/
|
|
91
|
+
status: "applied" | "fallback";
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Why the full archive had to be downloaded. Absent when the patch was applied, and
|
|
95
|
+
* also when the attempt ended in an error none of the appliers has a word for.
|
|
96
|
+
*/
|
|
97
|
+
fallbackReason?: BinaryPatchFallbackReason;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* How long the patch work took, in milliseconds: applying the patch when it was
|
|
101
|
+
* applied, and the whole attempt when it was given up on.
|
|
102
|
+
*/
|
|
103
|
+
applyDurationMs: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
50
106
|
export interface CodePushOptions extends SyncOptions {
|
|
51
107
|
/**
|
|
52
108
|
* The `ignoreFailedUpdates` option is only available as an option for `CodePush.sync()`.
|
|
@@ -192,6 +248,14 @@ export interface RemotePackage extends Package {
|
|
|
192
248
|
* The URL at which the package is available for download.
|
|
193
249
|
*/
|
|
194
250
|
downloadUrl: string;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The URL at which a binary patch archive of this package is available for download.
|
|
254
|
+
* The patch is built against the JS bundle embedded in the app binary, so it is only
|
|
255
|
+
* present when the release was published together with one. When it is absent, the
|
|
256
|
+
* package is downloaded in full from `downloadUrl`.
|
|
257
|
+
*/
|
|
258
|
+
binaryPatchDownloadUrl?: string;
|
|
195
259
|
}
|
|
196
260
|
|
|
197
261
|
export interface SyncOptions {
|
|
@@ -239,6 +303,19 @@ export interface SyncOptions {
|
|
|
239
303
|
*/
|
|
240
304
|
rollbackRetryOptions?: RollbackRetryOptions;
|
|
241
305
|
|
|
306
|
+
/**
|
|
307
|
+
* An optional callback for observing how an update published with a binary patch was
|
|
308
|
+
* installed: whether it came from the patch archive, why it did not when it did not, and
|
|
309
|
+
* how long the patch work took. It is called once per download that had a patch to try,
|
|
310
|
+
* with the label of the release being installed.
|
|
311
|
+
*
|
|
312
|
+
* Purely for observation. The library neither stores the result nor sends it anywhere -
|
|
313
|
+
* an app that wants it in its telemetry sends it itself - and nothing about the update
|
|
314
|
+
* depends on the callback: registering none changes nothing, and one that throws is
|
|
315
|
+
* logged and does not fail the install.
|
|
316
|
+
*/
|
|
317
|
+
onBinaryPatchResult?: (label: string, result: BinaryPatchResult) => void;
|
|
318
|
+
|
|
242
319
|
/**
|
|
243
320
|
* Specifies whether to ignore the update if the installation fails.
|
|
244
321
|
* If set to false, the update will be retried when the sync method is called, even if the previous installation attempt failed.
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
package com.microsoft.codepush.react;
|
|
2
|
-
|
|
3
|
-
import android.app.Activity;
|
|
4
|
-
import android.app.AlertDialog;
|
|
5
|
-
import android.content.DialogInterface;
|
|
6
|
-
|
|
7
|
-
import com.facebook.react.bridge.Callback;
|
|
8
|
-
import com.facebook.react.bridge.LifecycleEventListener;
|
|
9
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
11
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
12
|
-
|
|
13
|
-
public class CodePushDialog extends ReactContextBaseJavaModule{
|
|
14
|
-
|
|
15
|
-
public CodePushDialog(ReactApplicationContext reactContext) {
|
|
16
|
-
super(reactContext);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@ReactMethod
|
|
20
|
-
public void showDialog(final String title, final String message, final String button1Text,
|
|
21
|
-
final String button2Text, final Callback successCallback, Callback errorCallback) {
|
|
22
|
-
Activity currentActivity = getCurrentActivity();
|
|
23
|
-
if (currentActivity == null || currentActivity.isFinishing()) {
|
|
24
|
-
// If getCurrentActivity is null, it could be because the app is backgrounded,
|
|
25
|
-
// so we show the dialog when the app resumes)
|
|
26
|
-
getReactApplicationContext().addLifecycleEventListener(new LifecycleEventListener() {
|
|
27
|
-
@Override
|
|
28
|
-
public void onHostResume() {
|
|
29
|
-
Activity currentActivity = getCurrentActivity();
|
|
30
|
-
if (currentActivity != null) {
|
|
31
|
-
getReactApplicationContext().removeLifecycleEventListener(this);
|
|
32
|
-
showDialogInternal(title, message, button1Text, button2Text, successCallback, currentActivity);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@Override
|
|
37
|
-
public void onHostPause() {
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@Override
|
|
42
|
-
public void onHostDestroy() {
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
} else {
|
|
47
|
-
showDialogInternal(title, message, button1Text, button2Text, successCallback, currentActivity);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private void showDialogInternal(String title, String message, String button1Text,
|
|
52
|
-
String button2Text, final Callback successCallback, Activity currentActivity) {
|
|
53
|
-
AlertDialog.Builder builder = new AlertDialog.Builder(currentActivity);
|
|
54
|
-
|
|
55
|
-
builder.setCancelable(false);
|
|
56
|
-
|
|
57
|
-
DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
|
|
58
|
-
@Override
|
|
59
|
-
public void onClick(DialogInterface dialog, int which) {
|
|
60
|
-
try {
|
|
61
|
-
dialog.cancel();
|
|
62
|
-
switch (which) {
|
|
63
|
-
case DialogInterface.BUTTON_POSITIVE:
|
|
64
|
-
successCallback.invoke(0);
|
|
65
|
-
break;
|
|
66
|
-
case DialogInterface.BUTTON_NEGATIVE:
|
|
67
|
-
successCallback.invoke(1);
|
|
68
|
-
break;
|
|
69
|
-
default:
|
|
70
|
-
throw new CodePushUnknownException("Unknown button ID pressed.");
|
|
71
|
-
}
|
|
72
|
-
} catch (Throwable e) {
|
|
73
|
-
CodePushUtils.log(e);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
if (title != null) {
|
|
79
|
-
builder.setTitle(title);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (message != null) {
|
|
83
|
-
builder.setMessage(message);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (button1Text != null) {
|
|
87
|
-
builder.setPositiveButton(button1Text, clickListener);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (button2Text != null) {
|
|
91
|
-
builder.setNegativeButton(button2Text, clickListener);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
AlertDialog dialog = builder.create();
|
|
95
|
-
dialog.show();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
@Override
|
|
99
|
-
public String getName() {
|
|
100
|
-
return "CodePushDialog";
|
|
101
|
-
}
|
|
102
|
-
}
|
package/src/AlertAdapter.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React, { Platform } from "react-native";
|
|
2
|
-
let { Alert } = React;
|
|
3
|
-
|
|
4
|
-
if (Platform.OS === "android") {
|
|
5
|
-
const { NativeModules: { CodePushDialog } } = React;
|
|
6
|
-
|
|
7
|
-
Alert = {
|
|
8
|
-
alert(title, message, buttons) {
|
|
9
|
-
if (buttons.length > 2) {
|
|
10
|
-
throw "Can only show 2 buttons for Android dialog.";
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const button1Text = buttons[0] ? buttons[0].text : null,
|
|
14
|
-
button2Text = buttons[1] ? buttons[1].text : null;
|
|
15
|
-
|
|
16
|
-
CodePushDialog.showDialog(
|
|
17
|
-
title, message, button1Text, button2Text,
|
|
18
|
-
(buttonId) => { buttons[buttonId].onPress && buttons[buttonId].onPress(); },
|
|
19
|
-
(error) => { throw error; });
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = { Alert };
|