@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
package/README.md CHANGED
@@ -12,6 +12,7 @@ Capacitor plugin to update your app remotely in real-time.
12
12
  - 🔄 **Auto Update**: Automatically download and set the latest bundle for the app.
13
13
  - 🛟 **Rollback**: Reset the app to the default bundle if an incompatible bundle has been set.
14
14
  - 🚀 **Rollout**: Gradually roll out new bundles to gather valuable feedback.
15
+ - 🔁 **Delta Updates**: Make your updates faster by only downloading changed files.
15
16
  - 🔒 **Security**: Verify the authenticity and integrity of the bundle using a public key.
16
17
  - 🌐 **Open Source**: Licensed under the MIT License.
17
18
 
@@ -155,6 +156,10 @@ const downloadBundle = async () => {
155
156
  await LiveUpdate.downloadBundle({ url: 'https://example.com/1.0.0.zip', bundleId: '1.0.0' });
156
157
  };
157
158
 
159
+ const fetchLatestBundle = async () => {
160
+ await LiveUpdate.fetchLatestBundle();
161
+ };
162
+
158
163
  const getBundle = async () => {
159
164
  const result = await LiveUpdate.getBundle();
160
165
  return result.bundleId;
@@ -218,6 +223,16 @@ const sync = async () => {
218
223
  const result = await LiveUpdate.sync();
219
224
  return result.nextBundleId;
220
225
  };
226
+
227
+ const isNewBundleAvailable = async () => {
228
+ const { bundleId: latestBundleId } = await LiveUpdate.fetchLatestBundle();
229
+ if (latestBundleId) {
230
+ const { bundleId: currentBundleId } = await LiveUpdate.getBundle();
231
+ return latestBundleId !== currentBundleId;
232
+ } else {
233
+ return false;
234
+ }
235
+ };
221
236
  ```
222
237
 
223
238
  ## API
@@ -226,6 +241,7 @@ const sync = async () => {
226
241
 
227
242
  * [`deleteBundle(...)`](#deletebundle)
228
243
  * [`downloadBundle(...)`](#downloadbundle)
244
+ * [`fetchLatestBundle()`](#fetchlatestbundle)
229
245
  * [`getBundle()`](#getbundle)
230
246
  * [`getBundles()`](#getbundles)
231
247
  * [`getChannel()`](#getchannel)
@@ -285,6 +301,23 @@ Only available on Android and iOS.
285
301
  --------------------
286
302
 
287
303
 
304
+ ### fetchLatestBundle()
305
+
306
+ ```typescript
307
+ fetchLatestBundle() => Promise<FetchLatestBundleResult>
308
+ ```
309
+
310
+ Fetch the latest bundle using the [Capawesome Cloud](https://capawesome.io/cloud/).
311
+
312
+ Only available on Android and iOS.
313
+
314
+ **Returns:** <code>Promise&lt;<a href="#fetchlatestbundleresult">FetchLatestBundleResult</a>&gt;</code>
315
+
316
+ **Since:** 6.6.0
317
+
318
+ --------------------
319
+
320
+
288
321
  ### getBundle()
289
322
 
290
323
  ```typescript
@@ -544,11 +577,19 @@ Only available on Android and iOS.
544
577
 
545
578
  #### DownloadBundleOptions
546
579
 
547
- | Prop | Type | Description | Since |
548
- | -------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------- | ----- |
549
- | **`bundleId`** | <code>string</code> | The unique identifier of the bundle. | 5.0.0 |
550
- | **`checksum`** | <code>string</code> | The checksum of the bundle to verify the integrity of the ZIP file. Must be a SHA-256 hash in hexadecimal format. | 6.1.0 |
551
- | **`url`** | <code>string</code> | The URL of the bundle to download. The bundle must be a ZIP file containing at least a `index.html` file. | 5.0.0 |
580
+ | Prop | Type | Description | Default | Since |
581
+ | ------------------ | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
582
+ | **`artifactType`** | <code>'manifest' \| 'zip'</code> | The artifact type of the bundle. | <code>'zip'</code> | 6.6.0 |
583
+ | **`bundleId`** | <code>string</code> | The unique identifier of the bundle. | | 5.0.0 |
584
+ | **`checksum`** | <code>string</code> | The checksum of the bundle to verify the integrity of the ZIP file. Must be a SHA-256 hash in base64 format. | | 6.1.0 |
585
+ | **`url`** | <code>string</code> | The URL of the bundle to download. For the `zip` artifact type, the URL must point to a ZIP file. For the `manifest` artifact type, the URL serves as the base URL to download the individual files. For example, if the URL is `https://example.com/download`, the plugin will download the file with the href `index.html` from `https://example.com/download?href=index.html`. To **verify the integrity** of the file, the server must return a `X-Checksum` header with the SHA-256 hash in base64 format. To **verify the signature** of the file, the server must return a `X-Signature` header with the signed SHA-256 hash in base64 format. | | 5.0.0 |
586
+
587
+
588
+ #### FetchLatestBundleResult
589
+
590
+ | Prop | Type | Description | Since |
591
+ | -------------- | --------------------------- | ------------------------------------------------------------------------------ | ----- |
592
+ | **`bundleId`** | <code>string \| null</code> | The unique identifier of the latest bundle. If `null`, no bundle is available. | 6.6.0 |
552
593
 
553
594
 
554
595
  #### GetBundleResult