@capgo/capacitor-updater 8.45.10 → 8.45.11
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/README.md +74 -28
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +147 -50
- package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +40 -16
- package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +27 -3
- package/dist/docs.json +163 -4
- package/dist/esm/definitions.d.ts +82 -19
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/BundleInfo.swift +2 -2
- package/ios/Sources/CapacitorUpdaterPlugin/BundleStatus.swift +78 -2
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +289 -94
- package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +672 -300
- package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +31 -0
- package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +20 -3
- package/package.json +3 -2
package/dist/docs.json
CHANGED
|
@@ -492,14 +492,14 @@
|
|
|
492
492
|
},
|
|
493
493
|
{
|
|
494
494
|
"name": "throws",
|
|
495
|
-
"text": "{Error}
|
|
495
|
+
"text": "{Error} Throws for failed update checks or transport/request failures."
|
|
496
496
|
},
|
|
497
497
|
{
|
|
498
498
|
"name": "since",
|
|
499
499
|
"text": "4.0.0"
|
|
500
500
|
}
|
|
501
501
|
],
|
|
502
|
-
"docs": "Check the update server for the latest available bundle version.\n\nThis queries your configured update URL (or Capgo backend) to see if a newer bundle\nis available for download. It does NOT download the bundle automatically.\n\nThe response includes:\n- `version`: The latest available version identifier\n- `url`: Download URL for the bundle (if available)\n- `breaking`: Whether this update is marked as incompatible (requires native app update)\n- `message`: Optional message from the server\n- `manifest`: File list for delta updates (if using multi-file downloads)\n\nAfter receiving the latest version info, you can:\n1. Compare it with your current version\n2. Download it using {@link download}\n3. Apply it using {@link next} or {@link set}\n\n**Important:
|
|
502
|
+
"docs": "Check the update server for the latest available bundle version.\n\nThis queries your configured update URL (or Capgo backend) to see if a newer bundle\nis available for download. It does NOT download the bundle automatically.\n\nThe response includes:\n- `version`: The latest available version identifier\n- `url`: Download URL for the bundle (if available)\n- `breaking`: Whether this update is marked as incompatible (requires native app update)\n- `message`: Optional message from the server\n- `manifest`: File list for delta updates (if using multi-file downloads)\n\nAfter receiving the latest version info, you can:\n1. Compare it with your current version\n2. Download it using {@link download}\n3. Apply it using {@link next} or {@link set}\n\n**Important: Handling \"no new version available\"**\n\nWhen the device's current version matches the latest version on the server (i.e., the device is already\nup-to-date), the server returns a 200 response with `error: \"no_new_version_available\"` and\n`message: \"No new version available\"`. This is a normal, expected condition and resolves with\n`kind: \"up_to_date\"` when the backend provides that classification.\n\nYou should check `kind` and `error` before attempting to download:\n\n```typescript\nconst latest = await CapacitorUpdater.getLatest();\nif (latest.kind === 'up_to_date') {\n console.log('Already up to date');\n} else if (latest.kind === 'blocked') {\n console.log('Update is blocked:', latest.error);\n} else if (latest.url) {\n // New version is available, proceed with download\n}\n```\n\nIn this scenario, the server:\n- Logs the request with a \"No new version available\" message\n- Sends a \"noNew\" stat action to track that the device checked for updates but was already current (done on the backend)",
|
|
503
503
|
"complexTypes": [
|
|
504
504
|
"LatestVersion",
|
|
505
505
|
"GetLatestOptions"
|
|
@@ -765,7 +765,7 @@
|
|
|
765
765
|
"text": "1.0.0"
|
|
766
766
|
}
|
|
767
767
|
],
|
|
768
|
-
"docs": "Remove all event listeners registered for this plugin.\n\nThis unregisters all listeners added via {@link addListener} for all event types:\n- `download`\n- `noNeedUpdate`\n- `updateAvailable`\n- `downloadComplete`\n- `downloadFailed`\n- `breakingAvailable` / `majorAvailable`\n- `updateFailed`\n- `appReloaded`\n- `appReady`\n\nUse this during cleanup (e.g., when unmounting components or closing screens)\nto prevent memory leaks from lingering event listeners.",
|
|
768
|
+
"docs": "Remove all event listeners registered for this plugin.\n\nThis unregisters all listeners added via {@link addListener} for all event types:\n- `download`\n- `noNeedUpdate`\n- `updateCheckResult`\n- `updateAvailable`\n- `downloadComplete`\n- `downloadFailed`\n- `breakingAvailable` / `majorAvailable`\n- `updateFailed`\n- `appReloaded`\n- `appReady`\n\nUse this during cleanup (e.g., when unmounting components or closing screens)\nto prevent memory leaks from lingering event listeners.",
|
|
769
769
|
"complexTypes": [],
|
|
770
770
|
"slug": "removealllisteners"
|
|
771
771
|
},
|
|
@@ -827,6 +827,35 @@
|
|
|
827
827
|
],
|
|
828
828
|
"slug": "addlistenernoneedupdate-"
|
|
829
829
|
},
|
|
830
|
+
{
|
|
831
|
+
"name": "addListener",
|
|
832
|
+
"signature": "(eventName: 'updateCheckResult', listenerFunc: (state: UpdateCheckResultEvent) => void) => Promise<PluginListenerHandle>",
|
|
833
|
+
"parameters": [
|
|
834
|
+
{
|
|
835
|
+
"name": "eventName",
|
|
836
|
+
"docs": "",
|
|
837
|
+
"type": "'updateCheckResult'"
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
"name": "listenerFunc",
|
|
841
|
+
"docs": "",
|
|
842
|
+
"type": "(state: UpdateCheckResultEvent) => void"
|
|
843
|
+
}
|
|
844
|
+
],
|
|
845
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
846
|
+
"tags": [
|
|
847
|
+
{
|
|
848
|
+
"name": "since",
|
|
849
|
+
"text": "8.45.11"
|
|
850
|
+
}
|
|
851
|
+
],
|
|
852
|
+
"docs": "Listen for update check results before the updater decides whether to download.\nThe backend can classify the UpdateCheckResultEvent payload as `up_to_date`, `blocked`, or `failed`.\n\nThis event is emitted alongside legacy events. For `up_to_date` and `blocked`, it is emitted before\n`noNeedUpdate` and does not emit `downloadFailed`. For `failed`, it is emitted before the legacy\n`downloadFailed` event and keeps the existing failure stats behavior.",
|
|
853
|
+
"complexTypes": [
|
|
854
|
+
"PluginListenerHandle",
|
|
855
|
+
"UpdateCheckResultEvent"
|
|
856
|
+
],
|
|
857
|
+
"slug": "addlistenerupdatecheckresult-"
|
|
858
|
+
},
|
|
830
859
|
{
|
|
831
860
|
"name": "addListener",
|
|
832
861
|
"signature": "(eventName: 'updateAvailable', listenerFunc: (state: UpdateAvailableEvent) => void) => Promise<PluginListenerHandle>",
|
|
@@ -2045,10 +2074,36 @@
|
|
|
2045
2074
|
{
|
|
2046
2075
|
"name": "error",
|
|
2047
2076
|
"tags": [],
|
|
2048
|
-
"docs": "Error code from the server, if any
|
|
2077
|
+
"docs": "Error code from the server, if any. Use `kind` for classification instead of parsing this value.",
|
|
2049
2078
|
"complexTypes": [],
|
|
2050
2079
|
"type": "string | undefined"
|
|
2051
2080
|
},
|
|
2081
|
+
{
|
|
2082
|
+
"name": "kind",
|
|
2083
|
+
"tags": [
|
|
2084
|
+
{
|
|
2085
|
+
"text": "8.45.11",
|
|
2086
|
+
"name": "since"
|
|
2087
|
+
}
|
|
2088
|
+
],
|
|
2089
|
+
"docs": "Classification for this response, provided by the backend.",
|
|
2090
|
+
"complexTypes": [
|
|
2091
|
+
"UpdateResponseKind"
|
|
2092
|
+
],
|
|
2093
|
+
"type": "UpdateResponseKind"
|
|
2094
|
+
},
|
|
2095
|
+
{
|
|
2096
|
+
"name": "statusCode",
|
|
2097
|
+
"tags": [
|
|
2098
|
+
{
|
|
2099
|
+
"text": "8.45.11",
|
|
2100
|
+
"name": "since"
|
|
2101
|
+
}
|
|
2102
|
+
],
|
|
2103
|
+
"docs": "HTTP status code returned by the update server for classified update-check responses.",
|
|
2104
|
+
"complexTypes": [],
|
|
2105
|
+
"type": "number | undefined"
|
|
2106
|
+
},
|
|
2052
2107
|
{
|
|
2053
2108
|
"name": "old",
|
|
2054
2109
|
"tags": [],
|
|
@@ -2480,6 +2535,91 @@
|
|
|
2480
2535
|
}
|
|
2481
2536
|
]
|
|
2482
2537
|
},
|
|
2538
|
+
{
|
|
2539
|
+
"name": "UpdateCheckResultEvent",
|
|
2540
|
+
"slug": "updatecheckresultevent",
|
|
2541
|
+
"docs": "",
|
|
2542
|
+
"tags": [],
|
|
2543
|
+
"methods": [],
|
|
2544
|
+
"properties": [
|
|
2545
|
+
{
|
|
2546
|
+
"name": "kind",
|
|
2547
|
+
"tags": [
|
|
2548
|
+
{
|
|
2549
|
+
"text": "8.45.11",
|
|
2550
|
+
"name": "since"
|
|
2551
|
+
}
|
|
2552
|
+
],
|
|
2553
|
+
"docs": "Classification for the update check result, provided by the backend.",
|
|
2554
|
+
"complexTypes": [
|
|
2555
|
+
"UpdateResponseKind"
|
|
2556
|
+
],
|
|
2557
|
+
"type": "UpdateResponseKind"
|
|
2558
|
+
},
|
|
2559
|
+
{
|
|
2560
|
+
"name": "error",
|
|
2561
|
+
"tags": [
|
|
2562
|
+
{
|
|
2563
|
+
"text": "8.45.11",
|
|
2564
|
+
"name": "since"
|
|
2565
|
+
}
|
|
2566
|
+
],
|
|
2567
|
+
"docs": "Backend error code, when provided.",
|
|
2568
|
+
"complexTypes": [],
|
|
2569
|
+
"type": "string | undefined"
|
|
2570
|
+
},
|
|
2571
|
+
{
|
|
2572
|
+
"name": "message",
|
|
2573
|
+
"tags": [
|
|
2574
|
+
{
|
|
2575
|
+
"text": "8.45.11",
|
|
2576
|
+
"name": "since"
|
|
2577
|
+
}
|
|
2578
|
+
],
|
|
2579
|
+
"docs": "Backend message, when provided.",
|
|
2580
|
+
"complexTypes": [],
|
|
2581
|
+
"type": "string | undefined"
|
|
2582
|
+
},
|
|
2583
|
+
{
|
|
2584
|
+
"name": "statusCode",
|
|
2585
|
+
"tags": [
|
|
2586
|
+
{
|
|
2587
|
+
"text": "8.45.11",
|
|
2588
|
+
"name": "since"
|
|
2589
|
+
}
|
|
2590
|
+
],
|
|
2591
|
+
"docs": "HTTP status code returned by the update endpoint.",
|
|
2592
|
+
"complexTypes": [],
|
|
2593
|
+
"type": "number | undefined"
|
|
2594
|
+
},
|
|
2595
|
+
{
|
|
2596
|
+
"name": "version",
|
|
2597
|
+
"tags": [
|
|
2598
|
+
{
|
|
2599
|
+
"text": "8.45.11",
|
|
2600
|
+
"name": "since"
|
|
2601
|
+
}
|
|
2602
|
+
],
|
|
2603
|
+
"docs": "Version referenced by the update check result.",
|
|
2604
|
+
"complexTypes": [],
|
|
2605
|
+
"type": "string | undefined"
|
|
2606
|
+
},
|
|
2607
|
+
{
|
|
2608
|
+
"name": "bundle",
|
|
2609
|
+
"tags": [
|
|
2610
|
+
{
|
|
2611
|
+
"text": "8.45.11",
|
|
2612
|
+
"name": "since"
|
|
2613
|
+
}
|
|
2614
|
+
],
|
|
2615
|
+
"docs": "Current bundle on the device.",
|
|
2616
|
+
"complexTypes": [
|
|
2617
|
+
"BundleInfo"
|
|
2618
|
+
],
|
|
2619
|
+
"type": "BundleInfo"
|
|
2620
|
+
}
|
|
2621
|
+
]
|
|
2622
|
+
},
|
|
2483
2623
|
{
|
|
2484
2624
|
"name": "UpdateAvailableEvent",
|
|
2485
2625
|
"slug": "updateavailableevent",
|
|
@@ -3293,6 +3433,25 @@
|
|
|
3293
3433
|
}
|
|
3294
3434
|
]
|
|
3295
3435
|
},
|
|
3436
|
+
{
|
|
3437
|
+
"name": "UpdateResponseKind",
|
|
3438
|
+
"slug": "updateresponsekind",
|
|
3439
|
+
"docs": "Classification for update-check responses that do not provide a downloadable bundle.\nThe update backend provides this field directly. Missing or unknown values are treated as\nfailed by native clients.",
|
|
3440
|
+
"types": [
|
|
3441
|
+
{
|
|
3442
|
+
"text": "'up_to_date'",
|
|
3443
|
+
"complexTypes": []
|
|
3444
|
+
},
|
|
3445
|
+
{
|
|
3446
|
+
"text": "'blocked'",
|
|
3447
|
+
"complexTypes": []
|
|
3448
|
+
},
|
|
3449
|
+
{
|
|
3450
|
+
"text": "'failed'",
|
|
3451
|
+
"complexTypes": []
|
|
3452
|
+
}
|
|
3453
|
+
]
|
|
3454
|
+
},
|
|
3296
3455
|
{
|
|
3297
3456
|
"name": "BreakingAvailableEvent",
|
|
3298
3457
|
"slug": "breakingavailableevent",
|
|
@@ -695,27 +695,23 @@ export interface CapacitorUpdaterPlugin {
|
|
|
695
695
|
* 2. Download it using {@link download}
|
|
696
696
|
* 3. Apply it using {@link next} or {@link set}
|
|
697
697
|
*
|
|
698
|
-
* **Important:
|
|
698
|
+
* **Important: Handling "no new version available"**
|
|
699
699
|
*
|
|
700
700
|
* When the device's current version matches the latest version on the server (i.e., the device is already
|
|
701
701
|
* up-to-date), the server returns a 200 response with `error: "no_new_version_available"` and
|
|
702
|
-
* `message: "No new version available"`.
|
|
703
|
-
*
|
|
702
|
+
* `message: "No new version available"`. This is a normal, expected condition and resolves with
|
|
703
|
+
* `kind: "up_to_date"` when the backend provides that classification.
|
|
704
704
|
*
|
|
705
|
-
* You should
|
|
705
|
+
* You should check `kind` and `error` before attempting to download:
|
|
706
706
|
*
|
|
707
707
|
* ```typescript
|
|
708
|
-
*
|
|
709
|
-
*
|
|
708
|
+
* const latest = await CapacitorUpdater.getLatest();
|
|
709
|
+
* if (latest.kind === 'up_to_date') {
|
|
710
|
+
* console.log('Already up to date');
|
|
711
|
+
* } else if (latest.kind === 'blocked') {
|
|
712
|
+
* console.log('Update is blocked:', latest.error);
|
|
713
|
+
* } else if (latest.url) {
|
|
710
714
|
* // New version is available, proceed with download
|
|
711
|
-
* } catch (error) {
|
|
712
|
-
* if (error.message === 'No new version available') {
|
|
713
|
-
* // Device is already on the latest version - this is normal
|
|
714
|
-
* console.log('Already up to date');
|
|
715
|
-
* } else {
|
|
716
|
-
* // Actual error occurred
|
|
717
|
-
* console.error('Failed to check for updates:', error);
|
|
718
|
-
* }
|
|
719
715
|
* }
|
|
720
716
|
* ```
|
|
721
717
|
*
|
|
@@ -725,7 +721,7 @@ export interface CapacitorUpdaterPlugin {
|
|
|
725
721
|
*
|
|
726
722
|
* @param options Optional {@link GetLatestOptions} to specify which channel to check.
|
|
727
723
|
* @returns {Promise<LatestVersion>} Information about the latest available bundle version.
|
|
728
|
-
* @throws {Error}
|
|
724
|
+
* @throws {Error} Throws for failed update checks or transport/request failures.
|
|
729
725
|
* @since 4.0.0
|
|
730
726
|
*/
|
|
731
727
|
getLatest(options?: GetLatestOptions): Promise<LatestVersion>;
|
|
@@ -941,6 +937,7 @@ export interface CapacitorUpdaterPlugin {
|
|
|
941
937
|
* This unregisters all listeners added via {@link addListener} for all event types:
|
|
942
938
|
* - `download`
|
|
943
939
|
* - `noNeedUpdate`
|
|
940
|
+
* - `updateCheckResult`
|
|
944
941
|
* - `updateAvailable`
|
|
945
942
|
* - `downloadComplete`
|
|
946
943
|
* - `downloadFailed`
|
|
@@ -969,6 +966,17 @@ export interface CapacitorUpdaterPlugin {
|
|
|
969
966
|
* @since 4.0.0
|
|
970
967
|
*/
|
|
971
968
|
addListener(eventName: 'noNeedUpdate', listenerFunc: (state: NoNeedEvent) => void): Promise<PluginListenerHandle>;
|
|
969
|
+
/**
|
|
970
|
+
* Listen for update check results before the updater decides whether to download.
|
|
971
|
+
* The backend can classify the UpdateCheckResultEvent payload as `up_to_date`, `blocked`, or `failed`.
|
|
972
|
+
*
|
|
973
|
+
* This event is emitted alongside legacy events. For `up_to_date` and `blocked`, it is emitted before
|
|
974
|
+
* `noNeedUpdate` and does not emit `downloadFailed`. For `failed`, it is emitted before the legacy
|
|
975
|
+
* `downloadFailed` event and keeps the existing failure stats behavior.
|
|
976
|
+
*
|
|
977
|
+
* @since 8.45.11
|
|
978
|
+
*/
|
|
979
|
+
addListener(eventName: 'updateCheckResult', listenerFunc: (state: UpdateCheckResultEvent) => void): Promise<PluginListenerHandle>;
|
|
972
980
|
/**
|
|
973
981
|
* Listen for available update event, useful when you want to force check every time the app is launched
|
|
974
982
|
*
|
|
@@ -1376,6 +1384,14 @@ export interface CapacitorUpdaterPlugin {
|
|
|
1376
1384
|
*/
|
|
1377
1385
|
export type BundleStatus = 'success' | 'error' | 'pending' | 'downloading';
|
|
1378
1386
|
export type DelayUntilNext = 'background' | 'kill' | 'nativeVersion' | 'date';
|
|
1387
|
+
/**
|
|
1388
|
+
* Classification for update-check responses that do not provide a downloadable bundle.
|
|
1389
|
+
* The update backend provides this field directly. Missing or unknown values are treated as
|
|
1390
|
+
* failed by native clients.
|
|
1391
|
+
*
|
|
1392
|
+
* @since 8.45.11
|
|
1393
|
+
*/
|
|
1394
|
+
export type UpdateResponseKind = 'up_to_date' | 'blocked' | 'failed';
|
|
1379
1395
|
export interface NoNeedEvent {
|
|
1380
1396
|
/**
|
|
1381
1397
|
* Current status of download, between 0 and 100.
|
|
@@ -1384,6 +1400,44 @@ export interface NoNeedEvent {
|
|
|
1384
1400
|
*/
|
|
1385
1401
|
bundle: BundleInfo;
|
|
1386
1402
|
}
|
|
1403
|
+
export interface UpdateCheckResultEvent {
|
|
1404
|
+
/**
|
|
1405
|
+
* Classification for the update check result, provided by the backend.
|
|
1406
|
+
*
|
|
1407
|
+
* @since 8.45.11
|
|
1408
|
+
*/
|
|
1409
|
+
kind: UpdateResponseKind;
|
|
1410
|
+
/**
|
|
1411
|
+
* Backend error code, when provided.
|
|
1412
|
+
*
|
|
1413
|
+
* @since 8.45.11
|
|
1414
|
+
*/
|
|
1415
|
+
error?: string;
|
|
1416
|
+
/**
|
|
1417
|
+
* Backend message, when provided.
|
|
1418
|
+
*
|
|
1419
|
+
* @since 8.45.11
|
|
1420
|
+
*/
|
|
1421
|
+
message?: string;
|
|
1422
|
+
/**
|
|
1423
|
+
* HTTP status code returned by the update endpoint.
|
|
1424
|
+
*
|
|
1425
|
+
* @since 8.45.11
|
|
1426
|
+
*/
|
|
1427
|
+
statusCode?: number;
|
|
1428
|
+
/**
|
|
1429
|
+
* Version referenced by the update check result.
|
|
1430
|
+
*
|
|
1431
|
+
* @since 8.45.11
|
|
1432
|
+
*/
|
|
1433
|
+
version?: string;
|
|
1434
|
+
/**
|
|
1435
|
+
* Current bundle on the device.
|
|
1436
|
+
*
|
|
1437
|
+
* @since 8.45.11
|
|
1438
|
+
*/
|
|
1439
|
+
bundle: BundleInfo;
|
|
1440
|
+
}
|
|
1387
1441
|
export interface UpdateAvailableEvent {
|
|
1388
1442
|
/**
|
|
1389
1443
|
* Current status of download, between 0 and 100.
|
|
@@ -1565,12 +1619,21 @@ export interface LatestVersion {
|
|
|
1565
1619
|
message?: string;
|
|
1566
1620
|
sessionKey?: string;
|
|
1567
1621
|
/**
|
|
1568
|
-
* Error code from the server, if any.
|
|
1569
|
-
* Common values:
|
|
1570
|
-
* - `"no_new_version_available"`: Device is already on the latest version (not a failure)
|
|
1571
|
-
* - Other error codes indicate actual failures in the update process
|
|
1622
|
+
* Error code from the server, if any. Use `kind` for classification instead of parsing this value.
|
|
1572
1623
|
*/
|
|
1573
1624
|
error?: string;
|
|
1625
|
+
/**
|
|
1626
|
+
* Classification for this response, provided by the backend.
|
|
1627
|
+
*
|
|
1628
|
+
* @since 8.45.11
|
|
1629
|
+
*/
|
|
1630
|
+
kind?: UpdateResponseKind;
|
|
1631
|
+
/**
|
|
1632
|
+
* HTTP status code returned by the update server for classified update-check responses.
|
|
1633
|
+
*
|
|
1634
|
+
* @since 8.45.11
|
|
1635
|
+
*/
|
|
1636
|
+
statusCode?: number;
|
|
1574
1637
|
/**
|
|
1575
1638
|
* The previous/current version name (provided for reference).
|
|
1576
1639
|
*/
|