@capawesome/capacitor-live-update 6.7.2 → 7.0.0-dev.1765885034
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/CapawesomeCapacitorLiveUpdate.podspec +3 -3
- package/Package.swift +32 -0
- package/README.md +419 -83
- package/android/build.gradle +12 -12
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java +758 -273
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateConfig.java +29 -27
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateHttpClient.java +40 -7
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java +212 -68
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePreferences.java +52 -3
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/api/GetLatestBundleResponse.java +27 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/events/DownloadBundleProgressEvent.java +32 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/{results/GetBundleResult.java → events/NextBundleSetEvent.java} +9 -7
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/DownloadBundleOptions.java +16 -1
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SetConfigOptions.java +19 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SyncOptions.java +4 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/FetchLatestBundleResult.java +29 -1
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetBlockedBundlesResult.java +27 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetConfigResult.java +40 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetDownloadedBundlesResult.java +27 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/IsSyncingResult.java +26 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/ReadyResult.java +32 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/interfaces/DownloadProgressCallback.java +5 -0
- package/dist/docs.json +630 -103
- package/dist/esm/definitions.d.ts +365 -39
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +9 -2
- package/dist/esm/web.js +21 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +22 -3
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +22 -3
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Classes/Events/DownloadBundleProgressEvent.swift +25 -0
- package/ios/Plugin/Classes/{Results/GetBundleResult.swift → Events/NextBundleSetEvent.swift} +3 -3
- package/ios/Plugin/Classes/Options/DownloadBundleOptions.swift +7 -1
- package/ios/Plugin/Classes/Options/SetConfigOptions.swift +14 -0
- package/ios/Plugin/Classes/Options/SyncOptions.swift +4 -0
- package/ios/Plugin/Classes/Results/{FetchLatestBundle.swift → FetchLatestBundleResult.swift} +16 -1
- package/ios/Plugin/Classes/Results/GetBlockedBundlesResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetConfigResult.swift +19 -0
- package/ios/Plugin/Classes/Results/GetDownloadedBundlesResult.swift +16 -0
- package/ios/Plugin/Classes/Results/IsSyncingResult.swift +16 -0
- package/ios/Plugin/Classes/Results/ReadyResult.swift +22 -0
- package/ios/Plugin/LiveUpdate.swift +370 -151
- package/ios/Plugin/LiveUpdateConfig.swift +4 -4
- package/ios/Plugin/LiveUpdateHttpClient.swift +10 -4
- package/ios/Plugin/LiveUpdatePlugin.swift +138 -35
- package/ios/Plugin/LiveUpdatePreferences.swift +56 -14
- package/ios/Plugin/Protocols/Api/GetLatestBundleResponse.swift +3 -0
- package/package.json +19 -20
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SetBundleOptions.java +0 -18
- package/ios/Plugin/Classes/Options/SetBundleOptions.swift +0 -14
- package/ios/Plugin/LiveUpdatePlugin.h +0 -10
- package/ios/Plugin/LiveUpdatePlugin.m +0 -27
package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateConfig.java
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package io.capawesome.capacitorjs.plugins.liveupdate;
|
|
2
2
|
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
3
4
|
import androidx.annotation.Nullable;
|
|
4
5
|
import java.security.Key;
|
|
5
6
|
|
|
@@ -8,50 +9,51 @@ public class LiveUpdateConfig {
|
|
|
8
9
|
@Nullable
|
|
9
10
|
private String appId = null;
|
|
10
11
|
|
|
12
|
+
private boolean autoBlockRolledBackBundles = false;
|
|
13
|
+
|
|
11
14
|
private boolean autoDeleteBundles = false;
|
|
12
15
|
|
|
16
|
+
@NonNull
|
|
17
|
+
private String autoUpdateStrategy = "none";
|
|
18
|
+
|
|
13
19
|
@Nullable
|
|
14
20
|
private String defaultChannel = null;
|
|
15
21
|
|
|
16
|
-
private boolean enabled = true;
|
|
17
22
|
private int httpTimeout = 60000;
|
|
18
23
|
|
|
19
|
-
@Nullable
|
|
20
|
-
private String location = null;
|
|
21
|
-
|
|
22
24
|
@Nullable
|
|
23
25
|
private String publicKey = null;
|
|
24
26
|
|
|
25
|
-
private int readyTimeout =
|
|
26
|
-
private
|
|
27
|
+
private int readyTimeout = 0;
|
|
28
|
+
private String serverDomain = "api.cloud.capawesome.io";
|
|
27
29
|
|
|
28
30
|
@Nullable
|
|
29
31
|
public String getAppId() {
|
|
30
32
|
return appId;
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
public boolean getAutoBlockRolledBackBundles() {
|
|
36
|
+
return autoBlockRolledBackBundles;
|
|
37
|
+
}
|
|
38
|
+
|
|
33
39
|
public boolean getAutoDeleteBundles() {
|
|
34
40
|
return autoDeleteBundles;
|
|
35
41
|
}
|
|
36
42
|
|
|
43
|
+
@NonNull
|
|
44
|
+
public String getAutoUpdateStrategy() {
|
|
45
|
+
return autoUpdateStrategy;
|
|
46
|
+
}
|
|
47
|
+
|
|
37
48
|
@Nullable
|
|
38
49
|
public String getDefaultChannel() {
|
|
39
50
|
return defaultChannel;
|
|
40
51
|
}
|
|
41
52
|
|
|
42
|
-
public boolean getEnabled() {
|
|
43
|
-
return enabled;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
53
|
public int getHttpTimeout() {
|
|
47
54
|
return httpTimeout;
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
@Nullable
|
|
51
|
-
public String getLocation() {
|
|
52
|
-
return location;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
57
|
@Nullable
|
|
56
58
|
public String getPublicKey() {
|
|
57
59
|
return publicKey;
|
|
@@ -61,34 +63,34 @@ public class LiveUpdateConfig {
|
|
|
61
63
|
return readyTimeout;
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
public
|
|
65
|
-
return
|
|
66
|
+
public String getServerDomain() {
|
|
67
|
+
return serverDomain;
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
public void setAppId(@Nullable String appId) {
|
|
69
71
|
this.appId = appId;
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
public void setAutoBlockRolledBackBundles(boolean autoBlockRolledBackBundles) {
|
|
75
|
+
this.autoBlockRolledBackBundles = autoBlockRolledBackBundles;
|
|
76
|
+
}
|
|
77
|
+
|
|
72
78
|
public void setAutoDeleteBundles(boolean autoDeleteBundles) {
|
|
73
79
|
this.autoDeleteBundles = autoDeleteBundles;
|
|
74
80
|
}
|
|
75
81
|
|
|
76
|
-
public void
|
|
77
|
-
this.
|
|
82
|
+
public void setAutoUpdateStrategy(@NonNull String autoUpdateStrategy) {
|
|
83
|
+
this.autoUpdateStrategy = autoUpdateStrategy;
|
|
78
84
|
}
|
|
79
85
|
|
|
80
|
-
public void
|
|
81
|
-
this.
|
|
86
|
+
public void setDefaultChannel(@Nullable String defaultChannel) {
|
|
87
|
+
this.defaultChannel = defaultChannel;
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
public void setHttpTimeout(int httpTimeout) {
|
|
85
91
|
this.httpTimeout = httpTimeout;
|
|
86
92
|
}
|
|
87
93
|
|
|
88
|
-
public void setLocation(@Nullable String location) {
|
|
89
|
-
this.location = location;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
94
|
public void setPublicKey(@Nullable String publicKey) {
|
|
93
95
|
this.publicKey = publicKey;
|
|
94
96
|
}
|
|
@@ -97,7 +99,7 @@ public class LiveUpdateConfig {
|
|
|
97
99
|
this.readyTimeout = readyTimeout;
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
public void
|
|
101
|
-
this.
|
|
102
|
+
public void setServerDomain(String serverDomain) {
|
|
103
|
+
this.serverDomain = serverDomain;
|
|
102
104
|
}
|
|
103
105
|
}
|
package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateHttpClient.java
CHANGED
|
@@ -2,9 +2,15 @@ package io.capawesome.capacitorjs.plugins.liveupdate;
|
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
4
|
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.Logger;
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.DownloadProgressCallback;
|
|
7
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.EmptyCallback;
|
|
8
|
+
import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.NonEmptyCallback;
|
|
5
9
|
import java.io.File;
|
|
6
10
|
import java.io.IOException;
|
|
7
11
|
import java.util.concurrent.TimeUnit;
|
|
12
|
+
import okhttp3.Call;
|
|
13
|
+
import okhttp3.Callback;
|
|
8
14
|
import okhttp3.OkHttpClient;
|
|
9
15
|
import okhttp3.Request;
|
|
10
16
|
import okhttp3.Response;
|
|
@@ -19,6 +25,9 @@ public class LiveUpdateHttpClient {
|
|
|
19
25
|
@NonNull
|
|
20
26
|
private final LiveUpdateConfig config;
|
|
21
27
|
|
|
28
|
+
@NonNull
|
|
29
|
+
private final OkHttpClient okHttpClient;
|
|
30
|
+
|
|
22
31
|
@Nullable
|
|
23
32
|
public static String getChecksumFromResponse(Response response) {
|
|
24
33
|
String checksum = response.header("X-Checksum");
|
|
@@ -39,20 +48,42 @@ public class LiveUpdateHttpClient {
|
|
|
39
48
|
|
|
40
49
|
public LiveUpdateHttpClient(@NonNull LiveUpdateConfig config) {
|
|
41
50
|
this.config = config;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public Response execute(String url) throws IOException {
|
|
45
51
|
int httpTimeout = config.getHttpTimeout();
|
|
46
|
-
|
|
52
|
+
|
|
53
|
+
// Increase max requests per host to allow multiple parallel downloads from the same host
|
|
54
|
+
okhttp3.Dispatcher dispatcher = new okhttp3.Dispatcher();
|
|
55
|
+
dispatcher.setMaxRequestsPerHost(30);
|
|
56
|
+
|
|
57
|
+
this.okHttpClient = new OkHttpClient.Builder()
|
|
58
|
+
.dispatcher(dispatcher)
|
|
47
59
|
.connectTimeout(httpTimeout, TimeUnit.MILLISECONDS)
|
|
48
60
|
.readTimeout(httpTimeout, TimeUnit.MILLISECONDS)
|
|
49
61
|
.writeTimeout(httpTimeout, TimeUnit.MILLISECONDS)
|
|
50
62
|
.build();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public Call enqueue(String url, NonEmptyCallback<Response> callback) {
|
|
51
66
|
Request request = new Request.Builder().url(url).build();
|
|
52
|
-
|
|
67
|
+
|
|
68
|
+
Call call = okHttpClient.newCall(request);
|
|
69
|
+
call.enqueue(
|
|
70
|
+
new Callback() {
|
|
71
|
+
@Override
|
|
72
|
+
public void onResponse(@NonNull Call call, @NonNull Response response) {
|
|
73
|
+
callback.success(response);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@Override
|
|
77
|
+
public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
|
78
|
+
callback.error(new Exception(e));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
return call;
|
|
53
83
|
}
|
|
54
84
|
|
|
55
|
-
public static void writeResponseBodyToFile(ResponseBody body, File file
|
|
85
|
+
public static void writeResponseBodyToFile(ResponseBody body, File file, @Nullable DownloadProgressCallback callback)
|
|
86
|
+
throws IOException {
|
|
56
87
|
long contentLength = body.contentLength();
|
|
57
88
|
BufferedSource source = body.source();
|
|
58
89
|
BufferedSink sink = Okio.buffer(Okio.sink(file));
|
|
@@ -62,7 +93,9 @@ public class LiveUpdateHttpClient {
|
|
|
62
93
|
for (long bytesRead; (bytesRead = source.read(sinkBuffer, bufferSize)) != -1;) {
|
|
63
94
|
sink.emit();
|
|
64
95
|
totalBytesRead += bytesRead;
|
|
65
|
-
|
|
96
|
+
if (callback != null) {
|
|
97
|
+
callback.onProgress(totalBytesRead, contentLength);
|
|
98
|
+
}
|
|
66
99
|
}
|
|
67
100
|
sink.flush();
|
|
68
101
|
sink.close();
|