@capawesome/capacitor-live-update 6.4.2 → 6.6.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.
Files changed (32) hide show
  1. package/README.md +46 -5
  2. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java +363 -251
  3. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateHttpClient.java +71 -0
  4. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java +65 -60
  5. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/Manifest.java +58 -0
  6. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/ManifestItem.java +37 -0
  7. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/api/GetLatestBundleResponse.java +19 -27
  8. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/DownloadBundleOptions.java +15 -1
  9. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/FetchLatestBundleResult.java +22 -0
  10. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/enums/ArtifactType.java +6 -0
  11. package/dist/docs.json +67 -4
  12. package/dist/esm/definitions.d.ts +42 -3
  13. package/dist/esm/definitions.js.map +1 -1
  14. package/dist/esm/web.d.ts +2 -1
  15. package/dist/esm/web.js +3 -0
  16. package/dist/esm/web.js.map +1 -1
  17. package/dist/plugin.cjs.js +3 -0
  18. package/dist/plugin.cjs.js.map +1 -1
  19. package/dist/plugin.js +3 -0
  20. package/dist/plugin.js.map +1 -1
  21. package/ios/Plugin/Classes/Manifest.swift +20 -0
  22. package/ios/Plugin/Classes/Options/DownloadBundleOptions.swift +11 -1
  23. package/ios/Plugin/Classes/Results/FetchLatestBundle.swift +16 -0
  24. package/ios/Plugin/Enums/ArtifactType.swift +4 -0
  25. package/ios/Plugin/{Classes → Enums}/CustomError.swift +3 -0
  26. package/ios/Plugin/LiveUpdate.swift +279 -198
  27. package/ios/Plugin/LiveUpdateHttpClient.swift +42 -0
  28. package/ios/Plugin/LiveUpdatePlugin.m +1 -0
  29. package/ios/Plugin/LiveUpdatePlugin.swift +77 -61
  30. package/ios/Plugin/Protocols/Api/GetLatestBundleResponse.swift +2 -3
  31. package/ios/Plugin/Protocols/Api/ManifestItem.swift +5 -0
  32. package/package.json +1 -1
@@ -0,0 +1,71 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+ import java.io.File;
6
+ import java.io.IOException;
7
+ import java.util.concurrent.TimeUnit;
8
+ import okhttp3.OkHttpClient;
9
+ import okhttp3.Request;
10
+ import okhttp3.Response;
11
+ import okhttp3.ResponseBody;
12
+ import okio.Buffer;
13
+ import okio.BufferedSink;
14
+ import okio.BufferedSource;
15
+ import okio.Okio;
16
+
17
+ public class LiveUpdateHttpClient {
18
+
19
+ @NonNull
20
+ private final LiveUpdateConfig config;
21
+
22
+ @Nullable
23
+ public static String getChecksumFromResponse(Response response) {
24
+ String checksum = response.header("X-Checksum");
25
+ if (checksum == null) {
26
+ return null;
27
+ }
28
+ return checksum;
29
+ }
30
+
31
+ @Nullable
32
+ public static String getSignatureFromResponse(Response response) {
33
+ String signature = response.header("X-Signature");
34
+ if (signature == null) {
35
+ return null;
36
+ }
37
+ return signature;
38
+ }
39
+
40
+ public LiveUpdateHttpClient(@NonNull LiveUpdateConfig config) {
41
+ this.config = config;
42
+ }
43
+
44
+ public Response execute(String url) throws IOException {
45
+ int httpTimeout = config.getHttpTimeout();
46
+ OkHttpClient okHttpClient = new OkHttpClient.Builder()
47
+ .connectTimeout(httpTimeout, TimeUnit.MILLISECONDS)
48
+ .readTimeout(httpTimeout, TimeUnit.MILLISECONDS)
49
+ .writeTimeout(httpTimeout, TimeUnit.MILLISECONDS)
50
+ .build();
51
+ Request request = new Request.Builder().url(url).build();
52
+ return okHttpClient.newCall(request).execute();
53
+ }
54
+
55
+ public static void writeResponseBodyToFile(ResponseBody body, File file) throws IOException {
56
+ long contentLength = body.contentLength();
57
+ BufferedSource source = body.source();
58
+ BufferedSink sink = Okio.buffer(Okio.sink(file));
59
+ Buffer sinkBuffer = sink.getBuffer();
60
+ long totalBytesRead = 0;
61
+ int bufferSize = 8 * 1024;
62
+ for (long bytesRead; (bytesRead = source.read(sinkBuffer, bufferSize)) != -1;) {
63
+ sink.emit();
64
+ totalBytesRead += bytesRead;
65
+ int progress = (int) ((totalBytesRead * 100) / contentLength);
66
+ }
67
+ sink.flush();
68
+ sink.close();
69
+ source.close();
70
+ }
71
+ }
@@ -19,7 +19,7 @@ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
19
19
  public class LiveUpdatePlugin extends Plugin {
20
20
 
21
21
  public static final String TAG = "LiveUpdate";
22
- public static final String VERSION = "6.4.1";
22
+ public static final String VERSION = "6.6.0";
23
23
  public static final String SHARED_PREFERENCES_NAME = "CapawesomeLiveUpdate"; // DO NOT CHANGE
24
24
  public static final String ERROR_APP_ID_MISSING = "appId must be configured.";
25
25
  public static final String ERROR_BUNDLE_EXISTS = "bundle already exists.";
@@ -36,6 +36,7 @@ public class LiveUpdatePlugin extends Plugin {
36
36
  public static final String ERROR_PUBLIC_KEY_INVALID = "Invalid public key.";
37
37
  public static final String ERROR_SIGNATURE_MISSING = "Bundle does not contain a signature.";
38
38
  public static final String ERROR_SYNC_IN_PROGRESS = "Sync is already in progress.";
39
+ public static final String ERROR_UNKNOWN_ERROR = "An unknown error has occurred.";
39
40
 
40
41
  private boolean syncInProgress = false;
41
42
 
@@ -72,21 +73,20 @@ public class LiveUpdatePlugin extends Plugin {
72
73
 
73
74
  @Override
74
75
  public void error(Exception exception) {
75
- Logger.error(TAG, exception.getMessage(), exception);
76
- call.reject(exception.getMessage());
76
+ rejectCall(call, exception);
77
77
  }
78
78
  };
79
79
 
80
80
  implementation.deleteBundle(options, callback);
81
81
  } catch (Exception exception) {
82
- Logger.error(TAG, exception.getMessage(), exception);
83
- call.reject(exception.getMessage());
82
+ rejectCall(call, exception);
84
83
  }
85
84
  }
86
85
 
87
86
  @PluginMethod
88
87
  public void downloadBundle(PluginCall call) {
89
88
  try {
89
+ String artifactType = call.getString("artifactType", "zip");
90
90
  String bundleId = call.getString("bundleId");
91
91
  if (bundleId == null) {
92
92
  call.reject(ERROR_BUNDLE_ID_MISSING);
@@ -99,7 +99,7 @@ public class LiveUpdatePlugin extends Plugin {
99
99
  return;
100
100
  }
101
101
 
102
- DownloadBundleOptions options = new DownloadBundleOptions(bundleId, checksum, url);
102
+ DownloadBundleOptions options = new DownloadBundleOptions(artifactType, bundleId, checksum, url);
103
103
  EmptyCallback callback = new EmptyCallback() {
104
104
  @Override
105
105
  public void success() {
@@ -108,15 +108,34 @@ public class LiveUpdatePlugin extends Plugin {
108
108
 
109
109
  @Override
110
110
  public void error(Exception exception) {
111
- Logger.error(TAG, exception.getMessage(), exception);
112
- call.reject(exception.getMessage());
111
+ rejectCall(call, exception);
113
112
  }
114
113
  };
115
114
 
116
115
  implementation.downloadBundle(options, callback);
117
116
  } catch (Exception exception) {
118
- Logger.error(TAG, exception.getMessage(), exception);
119
- call.reject(exception.getMessage());
117
+ rejectCall(call, exception);
118
+ }
119
+ }
120
+
121
+ @PluginMethod
122
+ public void fetchLatestBundle(PluginCall call) {
123
+ try {
124
+ NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
125
+ @Override
126
+ public void success(Result result) {
127
+ call.resolve(result.toJSObject());
128
+ }
129
+
130
+ @Override
131
+ public void error(Exception exception) {
132
+ rejectCall(call, exception);
133
+ }
134
+ };
135
+
136
+ implementation.fetchLatestBundle(callback);
137
+ } catch (Exception exception) {
138
+ rejectCall(call, exception);
120
139
  }
121
140
  }
122
141
 
@@ -131,15 +150,13 @@ public class LiveUpdatePlugin extends Plugin {
131
150
 
132
151
  @Override
133
152
  public void error(Exception exception) {
134
- Logger.error(TAG, exception.getMessage(), exception);
135
- call.reject(exception.getMessage());
153
+ rejectCall(call, exception);
136
154
  }
137
155
  };
138
156
 
139
157
  implementation.getBundle(callback);
140
158
  } catch (Exception exception) {
141
- Logger.error(TAG, exception.getMessage(), exception);
142
- call.reject(exception.getMessage());
159
+ rejectCall(call, exception);
143
160
  }
144
161
  }
145
162
 
@@ -154,15 +171,13 @@ public class LiveUpdatePlugin extends Plugin {
154
171
 
155
172
  @Override
156
173
  public void error(Exception exception) {
157
- Logger.error(TAG, exception.getMessage(), exception);
158
- call.reject(exception.getMessage());
174
+ rejectCall(call, exception);
159
175
  }
160
176
  };
161
177
 
162
178
  implementation.getBundles(callback);
163
179
  } catch (Exception exception) {
164
- Logger.error(TAG, exception.getMessage(), exception);
165
- call.reject(exception.getMessage());
180
+ rejectCall(call, exception);
166
181
  }
167
182
  }
168
183
 
@@ -177,15 +192,13 @@ public class LiveUpdatePlugin extends Plugin {
177
192
 
178
193
  @Override
179
194
  public void error(Exception exception) {
180
- Logger.error(TAG, exception.getMessage(), exception);
181
- call.reject(exception.getMessage());
195
+ rejectCall(call, exception);
182
196
  }
183
197
  };
184
198
 
185
199
  implementation.getChannel(callback);
186
200
  } catch (Exception exception) {
187
- Logger.error(TAG, exception.getMessage(), exception);
188
- call.reject(exception.getMessage());
201
+ rejectCall(call, exception);
189
202
  }
190
203
  }
191
204
 
@@ -200,15 +213,13 @@ public class LiveUpdatePlugin extends Plugin {
200
213
 
201
214
  @Override
202
215
  public void error(Exception exception) {
203
- Logger.error(TAG, exception.getMessage(), exception);
204
- call.reject(exception.getMessage());
216
+ rejectCall(call, exception);
205
217
  }
206
218
  };
207
219
 
208
220
  implementation.getCustomId(callback);
209
221
  } catch (Exception exception) {
210
- Logger.error(TAG, exception.getMessage(), exception);
211
- call.reject(exception.getMessage());
222
+ rejectCall(call, exception);
212
223
  }
213
224
  }
214
225
 
@@ -223,15 +234,13 @@ public class LiveUpdatePlugin extends Plugin {
223
234
 
224
235
  @Override
225
236
  public void error(Exception exception) {
226
- Logger.error(TAG, exception.getMessage(), exception);
227
- call.reject(exception.getMessage());
237
+ rejectCall(call, exception);
228
238
  }
229
239
  };
230
240
 
231
241
  implementation.getDeviceId(callback);
232
242
  } catch (Exception exception) {
233
- Logger.error(TAG, exception.getMessage(), exception);
234
- call.reject(exception.getMessage());
243
+ rejectCall(call, exception);
235
244
  }
236
245
  }
237
246
 
@@ -246,15 +255,13 @@ public class LiveUpdatePlugin extends Plugin {
246
255
 
247
256
  @Override
248
257
  public void error(Exception exception) {
249
- Logger.error(TAG, exception.getMessage(), exception);
250
- call.reject(exception.getMessage());
258
+ rejectCall(call, exception);
251
259
  }
252
260
  };
253
261
 
254
262
  implementation.getVersionCode(callback);
255
263
  } catch (Exception exception) {
256
- Logger.error(TAG, exception.getMessage(), exception);
257
- call.reject(exception.getMessage());
264
+ rejectCall(call, exception);
258
265
  }
259
266
  }
260
267
 
@@ -269,15 +276,13 @@ public class LiveUpdatePlugin extends Plugin {
269
276
 
270
277
  @Override
271
278
  public void error(Exception exception) {
272
- Logger.error(TAG, exception.getMessage(), exception);
273
- call.reject(exception.getMessage());
279
+ rejectCall(call, exception);
274
280
  }
275
281
  };
276
282
 
277
283
  implementation.getVersionName(callback);
278
284
  } catch (Exception exception) {
279
- Logger.error(TAG, exception.getMessage(), exception);
280
- call.reject(exception.getMessage());
285
+ rejectCall(call, exception);
281
286
  }
282
287
  }
283
288
 
@@ -287,8 +292,7 @@ public class LiveUpdatePlugin extends Plugin {
287
292
  implementation.ready();
288
293
  call.resolve();
289
294
  } catch (Exception exception) {
290
- Logger.error(TAG, exception.getMessage(), exception);
291
- call.reject(exception.getMessage());
295
+ rejectCall(call, exception);
292
296
  }
293
297
  }
294
298
 
@@ -298,8 +302,7 @@ public class LiveUpdatePlugin extends Plugin {
298
302
  implementation.reload();
299
303
  call.resolve();
300
304
  } catch (Exception exception) {
301
- Logger.error(TAG, exception.getMessage(), exception);
302
- call.reject(exception.getMessage());
305
+ rejectCall(call, exception);
303
306
  }
304
307
  }
305
308
 
@@ -309,8 +312,7 @@ public class LiveUpdatePlugin extends Plugin {
309
312
  implementation.reset();
310
313
  call.resolve();
311
314
  } catch (Exception exception) {
312
- Logger.error(TAG, exception.getMessage(), exception);
313
- call.reject(exception.getMessage());
315
+ rejectCall(call, exception);
314
316
  }
315
317
  }
316
318
 
@@ -332,15 +334,13 @@ public class LiveUpdatePlugin extends Plugin {
332
334
 
333
335
  @Override
334
336
  public void error(Exception exception) {
335
- Logger.error(TAG, exception.getMessage(), exception);
336
- call.reject(exception.getMessage());
337
+ rejectCall(call, exception);
337
338
  }
338
339
  };
339
340
 
340
341
  implementation.setBundle(options, callback);
341
342
  } catch (Exception exception) {
342
- Logger.error(TAG, exception.getMessage(), exception);
343
- call.reject(exception.getMessage());
343
+ rejectCall(call, exception);
344
344
  }
345
345
  }
346
346
 
@@ -358,15 +358,13 @@ public class LiveUpdatePlugin extends Plugin {
358
358
 
359
359
  @Override
360
360
  public void error(Exception exception) {
361
- Logger.error(TAG, exception.getMessage(), exception);
362
- call.reject(exception.getMessage());
361
+ rejectCall(call, exception);
363
362
  }
364
363
  };
365
364
 
366
365
  implementation.setChannel(options, callback);
367
366
  } catch (Exception exception) {
368
- Logger.error(TAG, exception.getMessage(), exception);
369
- call.reject(exception.getMessage());
367
+ rejectCall(call, exception);
370
368
  }
371
369
  }
372
370
 
@@ -388,15 +386,13 @@ public class LiveUpdatePlugin extends Plugin {
388
386
 
389
387
  @Override
390
388
  public void error(Exception exception) {
391
- Logger.error(TAG, exception.getMessage(), exception);
392
- call.reject(exception.getMessage());
389
+ rejectCall(call, exception);
393
390
  }
394
391
  };
395
392
 
396
393
  implementation.setCustomId(options, callback);
397
394
  } catch (Exception exception) {
398
- Logger.error(TAG, exception.getMessage(), exception);
399
- call.reject(exception.getMessage());
395
+ rejectCall(call, exception);
400
396
  }
401
397
  }
402
398
 
@@ -425,16 +421,14 @@ public class LiveUpdatePlugin extends Plugin {
425
421
  @Override
426
422
  public void error(Exception exception) {
427
423
  syncInProgress = false;
428
- Logger.error(TAG, exception.getMessage(), exception);
429
- call.reject(exception.getMessage());
424
+ rejectCall(call, exception);
430
425
  }
431
426
  };
432
427
 
433
428
  implementation.sync(callback);
434
429
  } catch (Exception exception) {
435
430
  syncInProgress = false;
436
- Logger.error(TAG, exception.getMessage(), exception);
437
- call.reject(exception.getMessage());
431
+ rejectCall(call, exception);
438
432
  }
439
433
  }
440
434
 
@@ -462,4 +456,15 @@ public class LiveUpdatePlugin extends Plugin {
462
456
 
463
457
  return config;
464
458
  }
459
+
460
+ private void rejectCall(PluginCall call, Exception exception) {
461
+ String message = exception.getMessage();
462
+ if (exception instanceof java.net.SocketTimeoutException) {
463
+ message = ERROR_HTTP_TIMEOUT;
464
+ } else {
465
+ message = message == null ? ERROR_UNKNOWN_ERROR : message;
466
+ }
467
+ Logger.error(TAG, message, exception);
468
+ call.reject(message);
469
+ }
465
470
  }
@@ -0,0 +1,58 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes;
2
+
3
+ import java.util.ArrayList;
4
+ import java.util.HashSet;
5
+ import java.util.List;
6
+ import java.util.Set;
7
+ import org.json.JSONArray;
8
+ import org.json.JSONException;
9
+
10
+ public class Manifest {
11
+
12
+ private List<ManifestItem> items = new ArrayList<>();
13
+
14
+ public Manifest(JSONArray jsonArray) throws JSONException {
15
+ for (int i = 0; i < jsonArray.length(); i++) {
16
+ ManifestItem manifestItem = new ManifestItem(jsonArray.getJSONObject(i));
17
+ items.add(manifestItem);
18
+ }
19
+ }
20
+
21
+ public List<ManifestItem> getItems() {
22
+ return items;
23
+ }
24
+
25
+ public static List<ManifestItem> findDuplicateItems(Manifest manifest1, Manifest manifest2) {
26
+ List<ManifestItem> duplicateItems = new ArrayList<>();
27
+ Set<String> checksums = new HashSet<>();
28
+
29
+ for (ManifestItem item : manifest2.getItems()) {
30
+ checksums.add(item.getChecksum());
31
+ }
32
+
33
+ for (ManifestItem item : manifest1.getItems()) {
34
+ if (checksums.contains(item.getChecksum())) {
35
+ duplicateItems.add(item);
36
+ }
37
+ }
38
+
39
+ return duplicateItems;
40
+ }
41
+
42
+ public static List<ManifestItem> findMissingItems(Manifest manifest1, Manifest manifest2) {
43
+ List<ManifestItem> missingItems = new ArrayList<>();
44
+ Set<String> checksums = new HashSet<>();
45
+
46
+ for (ManifestItem item : manifest2.getItems()) {
47
+ checksums.add(item.getChecksum());
48
+ }
49
+
50
+ for (ManifestItem item : manifest1.getItems()) {
51
+ if (!checksums.contains(item.getChecksum())) {
52
+ missingItems.add(item);
53
+ }
54
+ }
55
+
56
+ return missingItems;
57
+ }
58
+ }
@@ -0,0 +1,37 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import org.json.JSONObject;
5
+
6
+ public class ManifestItem {
7
+
8
+ @NonNull
9
+ private String checksum;
10
+
11
+ @NonNull
12
+ private String href;
13
+
14
+ @NonNull
15
+ private int sizeInBytes;
16
+
17
+ public ManifestItem(JSONObject json) {
18
+ this.href = json.optString("href");
19
+ this.checksum = json.optString("checksum");
20
+ this.sizeInBytes = json.optInt("sizeInBytes");
21
+ }
22
+
23
+ @NonNull
24
+ public String getHref() {
25
+ return href;
26
+ }
27
+
28
+ @NonNull
29
+ public String getChecksum() {
30
+ return checksum;
31
+ }
32
+
33
+ @NonNull
34
+ public int getSizeInBytes() {
35
+ return sizeInBytes;
36
+ }
37
+ }
@@ -1,49 +1,41 @@
1
1
  package io.capawesome.capacitorjs.plugins.liveupdate.classes.api;
2
2
 
3
+ import androidx.annotation.NonNull;
3
4
  import androidx.annotation.Nullable;
5
+ import io.capawesome.capacitorjs.plugins.liveupdate.enums.ArtifactType;
6
+ import java.util.ArrayList;
7
+ import java.util.List;
8
+ import org.json.JSONArray;
4
9
  import org.json.JSONObject;
5
10
 
6
11
  public class GetLatestBundleResponse {
7
12
 
8
- private String bundleId;
9
-
10
- @Nullable
11
- private String checksum;
13
+ @NonNull
14
+ private ArtifactType artifactType;
12
15
 
13
- @Nullable
14
- private String signature;
16
+ @NonNull
17
+ private String bundleId;
15
18
 
19
+ @NonNull
16
20
  private String url;
17
21
 
18
22
  public GetLatestBundleResponse(JSONObject responseJson) {
19
- this.bundleId = responseJson.optString("bundleId");
20
- String checksum = responseJson.optString("checksum", "null");
21
- if (checksum.equals("null")) {
22
- this.checksum = null;
23
+ String artifactType = responseJson.optString("artifactType");
24
+ if (artifactType.equals("manifest")) {
25
+ this.artifactType = ArtifactType.MANIFEST;
23
26
  } else {
24
- this.checksum = checksum;
25
- }
26
- String signature = responseJson.optString("signature", "null");
27
- if (signature.equals("null")) {
28
- this.signature = null;
29
- } else {
30
- this.signature = signature;
27
+ this.artifactType = ArtifactType.ZIP;
31
28
  }
29
+ this.bundleId = responseJson.optString("bundleId");
32
30
  this.url = responseJson.optString("url");
33
31
  }
34
32
 
35
- public String getBundleId() {
36
- return bundleId;
37
- }
38
-
39
- @Nullable
40
- public String getChecksum() {
41
- return checksum;
33
+ public ArtifactType getArtifactType() {
34
+ return artifactType;
42
35
  }
43
36
 
44
- @Nullable
45
- public String getSignature() {
46
- return signature;
37
+ public String getBundleId() {
38
+ return bundleId;
47
39
  }
48
40
 
49
41
  public String getUrl() {
@@ -2,9 +2,13 @@ package io.capawesome.capacitorjs.plugins.liveupdate.classes.options;
2
2
 
3
3
  import androidx.annotation.NonNull;
4
4
  import androidx.annotation.Nullable;
5
+ import io.capawesome.capacitorjs.plugins.liveupdate.enums.ArtifactType;
5
6
 
6
7
  public class DownloadBundleOptions {
7
8
 
9
+ @NonNull
10
+ private ArtifactType artifactType;
11
+
8
12
  @NonNull
9
13
  private String bundleId;
10
14
 
@@ -14,12 +18,22 @@ public class DownloadBundleOptions {
14
18
  @NonNull
15
19
  private String url;
16
20
 
17
- public DownloadBundleOptions(@NonNull String bundleId, @Nullable String checksum, @NonNull String url) {
21
+ public DownloadBundleOptions(@NonNull String artifactType, @NonNull String bundleId, @Nullable String checksum, @NonNull String url) {
22
+ if (artifactType.equals("manifest")) {
23
+ this.artifactType = ArtifactType.MANIFEST;
24
+ } else {
25
+ this.artifactType = ArtifactType.ZIP;
26
+ }
18
27
  this.bundleId = bundleId;
19
28
  this.checksum = checksum;
20
29
  this.url = url;
21
30
  }
22
31
 
32
+ @NonNull
33
+ public ArtifactType getArtifactType() {
34
+ return artifactType;
35
+ }
36
+
23
37
  @NonNull
24
38
  public String getBundleId() {
25
39
  return bundleId;
@@ -0,0 +1,22 @@
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.interfaces.Result;
6
+ import org.json.JSONObject;
7
+
8
+ public class FetchLatestBundleResult implements Result {
9
+
10
+ @Nullable
11
+ private String bundleId;
12
+
13
+ public FetchLatestBundleResult(@Nullable String bundleId) {
14
+ this.bundleId = bundleId;
15
+ }
16
+
17
+ public JSObject toJSObject() {
18
+ JSObject result = new JSObject();
19
+ result.put("bundleId", bundleId == null ? JSONObject.NULL : bundleId);
20
+ return result;
21
+ }
22
+ }
@@ -0,0 +1,6 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.enums;
2
+
3
+ public enum ArtifactType {
4
+ MANIFEST,
5
+ ZIP
6
+ }