@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.
Files changed (56) hide show
  1. package/CapawesomeCapacitorLiveUpdate.podspec +3 -3
  2. package/Package.swift +32 -0
  3. package/README.md +419 -83
  4. package/android/build.gradle +12 -12
  5. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java +758 -273
  6. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateConfig.java +29 -27
  7. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateHttpClient.java +40 -7
  8. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java +212 -68
  9. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePreferences.java +52 -3
  10. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/api/GetLatestBundleResponse.java +27 -0
  11. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/events/DownloadBundleProgressEvent.java +32 -0
  12. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/{results/GetBundleResult.java → events/NextBundleSetEvent.java} +9 -7
  13. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/DownloadBundleOptions.java +16 -1
  14. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SetConfigOptions.java +19 -0
  15. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SyncOptions.java +4 -0
  16. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/FetchLatestBundleResult.java +29 -1
  17. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetBlockedBundlesResult.java +27 -0
  18. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetConfigResult.java +40 -0
  19. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetDownloadedBundlesResult.java +27 -0
  20. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/IsSyncingResult.java +26 -0
  21. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/ReadyResult.java +32 -0
  22. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/interfaces/DownloadProgressCallback.java +5 -0
  23. package/dist/docs.json +630 -103
  24. package/dist/esm/definitions.d.ts +365 -39
  25. package/dist/esm/definitions.js.map +1 -1
  26. package/dist/esm/index.js +1 -1
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/esm/web.d.ts +9 -2
  29. package/dist/esm/web.js +21 -0
  30. package/dist/esm/web.js.map +1 -1
  31. package/dist/plugin.cjs.js +22 -3
  32. package/dist/plugin.cjs.js.map +1 -1
  33. package/dist/plugin.js +22 -3
  34. package/dist/plugin.js.map +1 -1
  35. package/ios/Plugin/Classes/Events/DownloadBundleProgressEvent.swift +25 -0
  36. package/ios/Plugin/Classes/{Results/GetBundleResult.swift → Events/NextBundleSetEvent.swift} +3 -3
  37. package/ios/Plugin/Classes/Options/DownloadBundleOptions.swift +7 -1
  38. package/ios/Plugin/Classes/Options/SetConfigOptions.swift +14 -0
  39. package/ios/Plugin/Classes/Options/SyncOptions.swift +4 -0
  40. package/ios/Plugin/Classes/Results/{FetchLatestBundle.swift → FetchLatestBundleResult.swift} +16 -1
  41. package/ios/Plugin/Classes/Results/GetBlockedBundlesResult.swift +16 -0
  42. package/ios/Plugin/Classes/Results/GetConfigResult.swift +19 -0
  43. package/ios/Plugin/Classes/Results/GetDownloadedBundlesResult.swift +16 -0
  44. package/ios/Plugin/Classes/Results/IsSyncingResult.swift +16 -0
  45. package/ios/Plugin/Classes/Results/ReadyResult.swift +22 -0
  46. package/ios/Plugin/LiveUpdate.swift +370 -151
  47. package/ios/Plugin/LiveUpdateConfig.swift +4 -4
  48. package/ios/Plugin/LiveUpdateHttpClient.swift +10 -4
  49. package/ios/Plugin/LiveUpdatePlugin.swift +138 -35
  50. package/ios/Plugin/LiveUpdatePreferences.swift +56 -14
  51. package/ios/Plugin/Protocols/Api/GetLatestBundleResponse.swift +3 -0
  52. package/package.json +19 -20
  53. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SetBundleOptions.java +0 -18
  54. package/ios/Plugin/Classes/Options/SetBundleOptions.swift +0 -14
  55. package/ios/Plugin/LiveUpdatePlugin.h +0 -10
  56. package/ios/Plugin/LiveUpdatePlugin.m +0 -27
@@ -0,0 +1,32 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.events;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.JSObject;
5
+ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
6
+
7
+ public class DownloadBundleProgressEvent implements Result {
8
+
9
+ @NonNull
10
+ private final String bundleId;
11
+
12
+ private final long downloadedBytes;
13
+ private final long totalBytes;
14
+ private final double progress;
15
+
16
+ public DownloadBundleProgressEvent(@NonNull String bundleId, long downloadedBytes, long totalBytes) {
17
+ this.bundleId = bundleId;
18
+ this.downloadedBytes = downloadedBytes;
19
+ this.totalBytes = totalBytes;
20
+ this.progress = (double) downloadedBytes / (double) totalBytes;
21
+ }
22
+
23
+ @NonNull
24
+ public JSObject toJSObject() {
25
+ JSObject result = new JSObject();
26
+ result.put("bundleId", bundleId);
27
+ result.put("downloadedBytes", downloadedBytes);
28
+ result.put("progress", progress);
29
+ result.put("totalBytes", totalBytes);
30
+ return result;
31
+ }
32
+ }
@@ -1,21 +1,23 @@
1
- package io.capawesome.capacitorjs.plugins.liveupdate.classes.results;
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.events;
2
2
 
3
- import androidx.annotation.NonNull;
4
3
  import androidx.annotation.Nullable;
5
- import com.getcapacitor.JSArray;
6
4
  import com.getcapacitor.JSObject;
7
- import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
8
5
  import org.json.JSONObject;
9
6
 
10
- public class GetBundleResult implements Result {
7
+ public class NextBundleSetEvent {
11
8
 
12
9
  @Nullable
13
- private String bundleId;
10
+ private final String bundleId;
14
11
 
15
- public GetBundleResult(@Nullable String bundleId) {
12
+ public NextBundleSetEvent(@Nullable String bundleId) {
16
13
  this.bundleId = bundleId;
17
14
  }
18
15
 
16
+ @Nullable
17
+ public String getBundleId() {
18
+ return bundleId;
19
+ }
20
+
19
21
  public JSObject toJSObject() {
20
22
  JSObject result = new JSObject();
21
23
  result.put("bundleId", bundleId == null ? JSONObject.NULL : bundleId);
@@ -15,10 +15,19 @@ public class DownloadBundleOptions {
15
15
  @Nullable
16
16
  private String checksum;
17
17
 
18
+ @Nullable
19
+ private String signature;
20
+
18
21
  @NonNull
19
22
  private String url;
20
23
 
21
- public DownloadBundleOptions(@NonNull String artifactType, @NonNull String bundleId, @Nullable String checksum, @NonNull String url) {
24
+ public DownloadBundleOptions(
25
+ @NonNull String artifactType,
26
+ @NonNull String bundleId,
27
+ @Nullable String checksum,
28
+ @Nullable String signature,
29
+ @NonNull String url
30
+ ) {
22
31
  if (artifactType.equals("manifest")) {
23
32
  this.artifactType = ArtifactType.MANIFEST;
24
33
  } else {
@@ -26,6 +35,7 @@ public class DownloadBundleOptions {
26
35
  }
27
36
  this.bundleId = bundleId;
28
37
  this.checksum = checksum;
38
+ this.signature = signature;
29
39
  this.url = url;
30
40
  }
31
41
 
@@ -44,6 +54,11 @@ public class DownloadBundleOptions {
44
54
  return checksum;
45
55
  }
46
56
 
57
+ @Nullable
58
+ public String getSignature() {
59
+ return signature;
60
+ }
61
+
47
62
  @NonNull
48
63
  public String getUrl() {
49
64
  return url;
@@ -0,0 +1,19 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.options;
2
+
3
+ import androidx.annotation.Nullable;
4
+ import com.getcapacitor.PluginCall;
5
+
6
+ public class SetConfigOptions {
7
+
8
+ @Nullable
9
+ private final String appId;
10
+
11
+ public SetConfigOptions(PluginCall call) {
12
+ this.appId = call.getString("appId");
13
+ }
14
+
15
+ @Nullable
16
+ public String getAppId() {
17
+ return appId;
18
+ }
19
+ }
@@ -13,6 +13,10 @@ public class SyncOptions {
13
13
  this.channel = call.getString("channel", null);
14
14
  }
15
15
 
16
+ public SyncOptions(@Nullable String channel) {
17
+ this.channel = channel;
18
+ }
19
+
16
20
  @Nullable
17
21
  public String getChannel() {
18
22
  return channel;
@@ -15,13 +15,32 @@ public class FetchLatestBundleResult implements Result {
15
15
  @Nullable
16
16
  private final String bundleId;
17
17
 
18
+ @Nullable
19
+ private final String checksum;
20
+
21
+ @Nullable
22
+ private final JSONObject customProperties;
23
+
18
24
  @Nullable
19
25
  private final String downloadUrl;
20
26
 
21
- public FetchLatestBundleResult(@Nullable ArtifactType artifactType, @Nullable String bundleId, @Nullable String downloadUrl) {
27
+ @Nullable
28
+ private final String signature;
29
+
30
+ public FetchLatestBundleResult(
31
+ @Nullable ArtifactType artifactType,
32
+ @Nullable String bundleId,
33
+ @Nullable String checksum,
34
+ @Nullable JSONObject customProperties,
35
+ @Nullable String downloadUrl,
36
+ @Nullable String signature
37
+ ) {
22
38
  this.artifactType = artifactType;
23
39
  this.bundleId = bundleId;
40
+ this.checksum = checksum;
41
+ this.customProperties = customProperties;
24
42
  this.downloadUrl = downloadUrl;
43
+ this.signature = signature;
25
44
  }
26
45
 
27
46
  @NonNull
@@ -33,9 +52,18 @@ public class FetchLatestBundleResult implements Result {
33
52
  result.put("artifactType", "zip");
34
53
  }
35
54
  result.put("bundleId", bundleId == null ? JSONObject.NULL : bundleId);
55
+ if (checksum != null) {
56
+ result.put("checksum", checksum);
57
+ }
58
+ if (customProperties != null) {
59
+ result.put("customProperties", customProperties);
60
+ }
36
61
  if (downloadUrl != null) {
37
62
  result.put("downloadUrl", downloadUrl);
38
63
  }
64
+ if (signature != null) {
65
+ result.put("signature", signature);
66
+ }
39
67
  return result;
40
68
  }
41
69
  }
@@ -0,0 +1,27 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.results;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.JSArray;
5
+ import com.getcapacitor.JSObject;
6
+ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
7
+
8
+ public class GetBlockedBundlesResult implements Result {
9
+
10
+ @NonNull
11
+ private String[] bundleIds;
12
+
13
+ public GetBlockedBundlesResult(@NonNull String[] bundleIds) {
14
+ this.bundleIds = bundleIds;
15
+ }
16
+
17
+ public JSObject toJSObject() {
18
+ JSArray bundleIdsResult = new JSArray();
19
+ for (String bundleId : bundleIds) {
20
+ bundleIdsResult.put(bundleId);
21
+ }
22
+
23
+ JSObject result = new JSObject();
24
+ result.put("bundleIds", bundleIdsResult);
25
+ return result;
26
+ }
27
+ }
@@ -0,0 +1,40 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.results;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+ import com.getcapacitor.JSObject;
6
+ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
7
+ import org.json.JSONObject;
8
+
9
+ public class GetConfigResult implements Result {
10
+
11
+ @Nullable
12
+ private final String appId;
13
+
14
+ @NonNull
15
+ private final String autoUpdateStrategy;
16
+
17
+ public GetConfigResult(@Nullable String appId, @NonNull String autoUpdateStrategy) {
18
+ this.appId = appId;
19
+ this.autoUpdateStrategy = autoUpdateStrategy;
20
+ }
21
+
22
+ @Nullable
23
+ public String getAppId() {
24
+ return appId;
25
+ }
26
+
27
+ @NonNull
28
+ public String getAutoUpdateStrategy() {
29
+ return autoUpdateStrategy;
30
+ }
31
+
32
+ @Override
33
+ @NonNull
34
+ public JSObject toJSObject() {
35
+ JSObject result = new JSObject();
36
+ result.put("appId", appId == null ? JSONObject.NULL : appId);
37
+ result.put("autoUpdateStrategy", autoUpdateStrategy);
38
+ return result;
39
+ }
40
+ }
@@ -0,0 +1,27 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.results;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.JSArray;
5
+ import com.getcapacitor.JSObject;
6
+ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
7
+
8
+ public class GetDownloadedBundlesResult implements Result {
9
+
10
+ @NonNull
11
+ private String[] bundleIds;
12
+
13
+ public GetDownloadedBundlesResult(@NonNull String[] bundleIds) {
14
+ this.bundleIds = bundleIds;
15
+ }
16
+
17
+ public JSObject toJSObject() {
18
+ JSArray bundleIdsResult = new JSArray();
19
+ for (String bundleId : bundleIds) {
20
+ bundleIdsResult.put(bundleId);
21
+ }
22
+
23
+ JSObject result = new JSObject();
24
+ result.put("bundleIds", bundleIdsResult);
25
+ return result;
26
+ }
27
+ }
@@ -0,0 +1,26 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.results;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.JSObject;
5
+ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
6
+
7
+ public class IsSyncingResult implements Result {
8
+
9
+ private final boolean syncing;
10
+
11
+ public IsSyncingResult(boolean syncing) {
12
+ this.syncing = syncing;
13
+ }
14
+
15
+ public boolean getSyncing() {
16
+ return syncing;
17
+ }
18
+
19
+ @Override
20
+ @NonNull
21
+ public JSObject toJSObject() {
22
+ JSObject result = new JSObject();
23
+ result.put("syncing", syncing);
24
+ return result;
25
+ }
26
+ }
@@ -0,0 +1,32 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.results;
2
+
3
+ import androidx.annotation.Nullable;
4
+ import com.getcapacitor.JSObject;
5
+ import io.capawesome.capacitorjs.plugins.liveupdate.LiveUpdate;
6
+ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
7
+ import org.json.JSONObject;
8
+
9
+ public class ReadyResult implements Result {
10
+
11
+ @Nullable
12
+ private String currentBundleId;
13
+
14
+ @Nullable
15
+ private String previousBundleId;
16
+
17
+ private boolean rollback;
18
+
19
+ public ReadyResult(@Nullable String currentBundleId, @Nullable String previousBundleId, boolean rollback) {
20
+ this.currentBundleId = currentBundleId;
21
+ this.previousBundleId = previousBundleId;
22
+ this.rollback = rollback;
23
+ }
24
+
25
+ public JSObject toJSObject() {
26
+ JSObject result = new JSObject();
27
+ result.put("currentBundleId", currentBundleId == null ? JSONObject.NULL : currentBundleId);
28
+ result.put("previousBundleId", previousBundleId == null ? JSONObject.NULL : previousBundleId);
29
+ result.put("rollback", rollback);
30
+ return result;
31
+ }
32
+ }
@@ -0,0 +1,5 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.interfaces;
2
+
3
+ public interface DownloadProgressCallback {
4
+ void onProgress(long downloadedBytes, long totalBytes);
5
+ }