@capgo/capacitor-updater 8.45.3 → 8.45.8
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/Package.swift +1 -1
- package/README.md +4 -3
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +118 -17
- package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +76 -11
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +17 -1
- package/dist/docs.json +21 -4
- package/dist/esm/definitions.d.ts +17 -2
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +164 -48
- package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +87 -9
- package/package.json +1 -1
package/Package.swift
CHANGED
|
@@ -11,7 +11,7 @@ let package = Package(
|
|
|
11
11
|
],
|
|
12
12
|
dependencies: [
|
|
13
13
|
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"),
|
|
14
|
-
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.11.
|
|
14
|
+
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.11.2")),
|
|
15
15
|
.package(url: "https://github.com/weichsel/ZIPFoundation.git", from: "0.9.20"),
|
|
16
16
|
.package(url: "https://github.com/mrackwitz/Version.git", exact: "0.8.0"),
|
|
17
17
|
.package(url: "https://github.com/attaswift/BigInt.git", from: "5.7.0")
|
package/README.md
CHANGED
|
@@ -2063,9 +2063,10 @@ If you don't use backend, you need to provide the URL and version of the bundle.
|
|
|
2063
2063
|
|
|
2064
2064
|
##### ResetOptions
|
|
2065
2065
|
|
|
2066
|
-
| Prop | Type |
|
|
2067
|
-
| ---------------------- | -------------------- |
|
|
2068
|
-
| **`toLastSuccessful`** | <code>boolean</code> |
|
|
2066
|
+
| Prop | Type | Description | Default |
|
|
2067
|
+
| ---------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------ |
|
|
2068
|
+
| **`toLastSuccessful`** | <code>boolean</code> | Reset to the last successfully loaded bundle instead of the builtin one. | <code>false</code> |
|
|
2069
|
+
| **`usePendingBundle`** | <code>boolean</code> | Apply the pending bundle set via {@link next} while resetting. When `true`, the plugin will switch to the pending bundle immediately and clear the pending flag. If no pending bundle exists, the reset will fail. | <code>false</code> |
|
|
2069
2070
|
|
|
2070
2071
|
|
|
2071
2072
|
##### CurrentBundleResult
|
|
@@ -22,6 +22,7 @@ import android.view.View;
|
|
|
22
22
|
import android.view.ViewGroup;
|
|
23
23
|
import android.widget.FrameLayout;
|
|
24
24
|
import android.widget.ProgressBar;
|
|
25
|
+
import androidx.core.content.pm.PackageInfoCompat;
|
|
25
26
|
import com.getcapacitor.Bridge;
|
|
26
27
|
import com.getcapacitor.CapConfig;
|
|
27
28
|
import com.getcapacitor.JSArray;
|
|
@@ -88,7 +89,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
88
89
|
private static final int SPLASH_SCREEN_RETRY_DELAY_MS = 100;
|
|
89
90
|
private static final int SPLASH_SCREEN_MAX_RETRIES = 20;
|
|
90
91
|
|
|
91
|
-
private final String pluginVersion = "8.45.
|
|
92
|
+
private final String pluginVersion = "8.45.8";
|
|
92
93
|
private static final String DELAY_CONDITION_PREFERENCES = "";
|
|
93
94
|
|
|
94
95
|
private SharedPreferences.Editor editor;
|
|
@@ -191,7 +192,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
191
192
|
}
|
|
192
193
|
|
|
193
194
|
private String getVersionCode(final PackageInfo packageInfo) {
|
|
194
|
-
return Long.toString(
|
|
195
|
+
return Long.toString(PackageInfoCompat.getLongVersionCode(packageInfo));
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
private void notifyBreakingEvents(final String version) {
|
|
@@ -1333,12 +1334,12 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1333
1334
|
this.bridge.getWebView().post(() -> this.bridge.getWebView().evaluateJavascript(script, null));
|
|
1334
1335
|
}
|
|
1335
1336
|
|
|
1336
|
-
|
|
1337
|
+
private void applyCurrentBundleToBridge() {
|
|
1337
1338
|
final String path = this.implementation.getCurrentBundlePath();
|
|
1339
|
+
final boolean usingBuiltin = this.implementation.isUsingBuiltin();
|
|
1338
1340
|
if (this.keepUrlPathAfterReload) {
|
|
1339
1341
|
this.syncKeepUrlPathFlag(true);
|
|
1340
1342
|
}
|
|
1341
|
-
this.semaphoreUp();
|
|
1342
1343
|
logger.info("Reloading: " + path);
|
|
1343
1344
|
|
|
1344
1345
|
AtomicReference<URL> url = new AtomicReference<>();
|
|
@@ -1383,7 +1384,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1383
1384
|
}
|
|
1384
1385
|
|
|
1385
1386
|
if (url.get() != null) {
|
|
1386
|
-
if (
|
|
1387
|
+
if (usingBuiltin) {
|
|
1387
1388
|
this.bridge.getLocalServer().hostAssets(path);
|
|
1388
1389
|
} else {
|
|
1389
1390
|
this.bridge.getLocalServer().hostFiles(path);
|
|
@@ -1403,14 +1404,14 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1403
1404
|
} catch (MalformedURLException e) {
|
|
1404
1405
|
logger.error("Cannot get finalUrl from capacitor bridge " + e.getMessage());
|
|
1405
1406
|
|
|
1406
|
-
if (
|
|
1407
|
+
if (usingBuiltin) {
|
|
1407
1408
|
this.bridge.setServerAssetPath(path);
|
|
1408
1409
|
} else {
|
|
1409
1410
|
this.bridge.setServerBasePath(path);
|
|
1410
1411
|
}
|
|
1411
1412
|
}
|
|
1412
1413
|
} else {
|
|
1413
|
-
if (
|
|
1414
|
+
if (usingBuiltin) {
|
|
1414
1415
|
this.bridge.setServerAssetPath(path);
|
|
1415
1416
|
} else {
|
|
1416
1417
|
this.bridge.setServerBasePath(path);
|
|
@@ -1426,6 +1427,19 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1426
1427
|
});
|
|
1427
1428
|
}
|
|
1428
1429
|
}
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
protected void restoreLiveBundleStateAfterFailedReload() {
|
|
1433
|
+
try {
|
|
1434
|
+
this.applyCurrentBundleToBridge();
|
|
1435
|
+
} catch (final Exception e) {
|
|
1436
|
+
logger.warn("Failed to restore live bundle after rejected reload: " + e.getMessage());
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
protected boolean _reload() {
|
|
1441
|
+
this.semaphoreUp();
|
|
1442
|
+
this.applyCurrentBundleToBridge();
|
|
1429
1443
|
|
|
1430
1444
|
this.checkAppReady();
|
|
1431
1445
|
this.notifyListeners("appReloaded", new JSObject());
|
|
@@ -1444,6 +1458,38 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1444
1458
|
@PluginMethod
|
|
1445
1459
|
public void reload(final PluginCall call) {
|
|
1446
1460
|
try {
|
|
1461
|
+
final BundleInfo current = this.implementation.getCurrentBundle();
|
|
1462
|
+
final BundleInfo next = this.implementation.getNextBundle();
|
|
1463
|
+
|
|
1464
|
+
if (next != null && !next.isErrorStatus() && !next.getId().equals(current.getId())) {
|
|
1465
|
+
final CapgoUpdater.ResetState previousState = this.implementation.captureResetState();
|
|
1466
|
+
final String previousBundleName = this.implementation.getCurrentBundle().getVersionName();
|
|
1467
|
+
logger.info("Applying pending bundle before reload: " + next.getVersionName());
|
|
1468
|
+
final boolean didApplyPendingBundle;
|
|
1469
|
+
if (next.isBuiltin()) {
|
|
1470
|
+
this.implementation.prepareResetStateForTransition();
|
|
1471
|
+
didApplyPendingBundle = true;
|
|
1472
|
+
} else {
|
|
1473
|
+
didApplyPendingBundle = this.implementation.stagePendingReload(next);
|
|
1474
|
+
}
|
|
1475
|
+
if (didApplyPendingBundle && this._reload()) {
|
|
1476
|
+
if (next.isBuiltin()) {
|
|
1477
|
+
this.implementation.finalizeResetTransition(previousBundleName, false);
|
|
1478
|
+
} else {
|
|
1479
|
+
this.implementation.finalizePendingReload(next, previousBundleName);
|
|
1480
|
+
}
|
|
1481
|
+
this.notifyBundleSet(next);
|
|
1482
|
+
this.implementation.setNextBundle(null);
|
|
1483
|
+
call.resolve();
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
this.implementation.restoreResetState(previousState);
|
|
1487
|
+
this.restoreLiveBundleStateAfterFailedReload();
|
|
1488
|
+
logger.error("Reload failed after applying pending bundle: " + next.getVersionName());
|
|
1489
|
+
call.reject("Reload failed after applying pending bundle: " + next.getVersionName());
|
|
1490
|
+
return;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1447
1493
|
if (this._reload()) {
|
|
1448
1494
|
call.resolve();
|
|
1449
1495
|
} else {
|
|
@@ -1605,28 +1651,83 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1605
1651
|
);
|
|
1606
1652
|
}
|
|
1607
1653
|
|
|
1608
|
-
private boolean _reset(final Boolean toLastSuccessful) {
|
|
1654
|
+
private boolean _reset(final Boolean toLastSuccessful, final Boolean usePendingBundle) {
|
|
1655
|
+
return this.performReset(toLastSuccessful, usePendingBundle, false);
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
private boolean performReset(final Boolean toLastSuccessful, final Boolean usePendingBundle, final boolean internal) {
|
|
1609
1659
|
final BundleInfo fallback = this.implementation.getFallbackBundle();
|
|
1610
|
-
this.implementation.
|
|
1660
|
+
final BundleInfo pending = this.implementation.getNextBundle();
|
|
1661
|
+
final CapgoUpdater.ResetState previousState = this.implementation.captureResetState();
|
|
1662
|
+
final String previousBundleName = this.implementation.getCurrentBundle().getVersionName();
|
|
1611
1663
|
|
|
1612
|
-
if (
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1664
|
+
if (Boolean.TRUE.equals(usePendingBundle)) {
|
|
1665
|
+
if (pending == null || pending.isErrorStatus()) {
|
|
1666
|
+
logger.error("No pending bundle available to reset to");
|
|
1667
|
+
return false;
|
|
1668
|
+
}
|
|
1669
|
+
if (!this.implementation.canSet(pending)) {
|
|
1670
|
+
logger.error("Pending bundle is not installable");
|
|
1671
|
+
return false;
|
|
1672
|
+
}
|
|
1673
|
+
this.implementation.prepareResetStateForTransition();
|
|
1674
|
+
logger.info("Resetting to pending bundle: " + pending.getVersionName());
|
|
1675
|
+
final boolean didApplyPendingBundle;
|
|
1676
|
+
if (pending.isBuiltin()) {
|
|
1677
|
+
didApplyPendingBundle = true;
|
|
1678
|
+
} else {
|
|
1679
|
+
didApplyPendingBundle = this.implementation.set(pending);
|
|
1680
|
+
}
|
|
1681
|
+
if (didApplyPendingBundle && this._reload()) {
|
|
1682
|
+
this.implementation.finalizeResetTransition(previousBundleName, internal);
|
|
1683
|
+
this.notifyBundleSet(pending);
|
|
1684
|
+
this.implementation.setNextBundle(null);
|
|
1616
1685
|
return true;
|
|
1617
1686
|
}
|
|
1687
|
+
this.implementation.restoreResetState(previousState);
|
|
1688
|
+
this.restoreLiveBundleStateAfterFailedReload();
|
|
1618
1689
|
return false;
|
|
1619
1690
|
}
|
|
1620
1691
|
|
|
1692
|
+
if (Boolean.TRUE.equals(toLastSuccessful) && !fallback.isBuiltin()) {
|
|
1693
|
+
if (this.implementation.canSet(fallback)) {
|
|
1694
|
+
this.implementation.prepareResetStateForTransition();
|
|
1695
|
+
logger.info("Resetting to: " + fallback);
|
|
1696
|
+
if (this.implementation.set(fallback) && this._reload()) {
|
|
1697
|
+
this.implementation.finalizeResetTransition(previousBundleName, internal);
|
|
1698
|
+
this.notifyBundleSet(fallback);
|
|
1699
|
+
return true;
|
|
1700
|
+
}
|
|
1701
|
+
if (!internal) {
|
|
1702
|
+
this.implementation.restoreResetState(previousState);
|
|
1703
|
+
this.restoreLiveBundleStateAfterFailedReload();
|
|
1704
|
+
return false;
|
|
1705
|
+
}
|
|
1706
|
+
logger.warn("Fallback reload failed during internal reset, resetting to native instead");
|
|
1707
|
+
} else {
|
|
1708
|
+
logger.warn("Fallback bundle is not installable, resetting to native instead");
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
this.implementation.prepareResetStateForTransition();
|
|
1621
1713
|
logger.info("Resetting to native.");
|
|
1622
|
-
|
|
1714
|
+
if (this._reload()) {
|
|
1715
|
+
this.implementation.finalizeResetTransition(previousBundleName, internal);
|
|
1716
|
+
return true;
|
|
1717
|
+
}
|
|
1718
|
+
if (!internal) {
|
|
1719
|
+
this.implementation.restoreResetState(previousState);
|
|
1720
|
+
this.restoreLiveBundleStateAfterFailedReload();
|
|
1721
|
+
}
|
|
1722
|
+
return false;
|
|
1623
1723
|
}
|
|
1624
1724
|
|
|
1625
1725
|
@PluginMethod
|
|
1626
1726
|
public void reset(final PluginCall call) {
|
|
1627
1727
|
try {
|
|
1628
1728
|
final Boolean toLastSuccessful = call.getBoolean("toLastSuccessful", false);
|
|
1629
|
-
|
|
1729
|
+
final Boolean usePendingBundle = call.getBoolean("usePendingBundle", false);
|
|
1730
|
+
if (this._reset(toLastSuccessful, usePendingBundle)) {
|
|
1630
1731
|
call.resolve();
|
|
1631
1732
|
return;
|
|
1632
1733
|
}
|
|
@@ -1990,7 +2091,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
1990
2091
|
);
|
|
1991
2092
|
if (directUpdateAllowedNow) {
|
|
1992
2093
|
logger.info("Direct update to builtin version");
|
|
1993
|
-
this._reset(false);
|
|
2094
|
+
this._reset(false, false);
|
|
1994
2095
|
CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
|
|
1995
2096
|
"Updated to builtin version",
|
|
1996
2097
|
latestVersionName,
|
|
@@ -2256,7 +2357,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
|
|
|
2256
2357
|
this.notifyListeners("updateFailed", ret);
|
|
2257
2358
|
this.implementation.sendStats("update_fail", current.getVersionName());
|
|
2258
2359
|
this.implementation.setError(current);
|
|
2259
|
-
this.
|
|
2360
|
+
this.performReset(true, false, true);
|
|
2260
2361
|
if (CapacitorUpdaterPlugin.this.autoDeleteFailed && !current.isBuiltin()) {
|
|
2261
2362
|
logger.info("Deleting failing bundle: " + current.getVersionName());
|
|
2262
2363
|
try {
|
|
@@ -991,6 +991,64 @@ public class CapgoUpdater {
|
|
|
991
991
|
return (bundle.isDirectory() && bundle.exists() && new File(bundle.getPath(), "/index.html").exists() && !bundleInfo.isDeleted());
|
|
992
992
|
}
|
|
993
993
|
|
|
994
|
+
static final class ResetState {
|
|
995
|
+
|
|
996
|
+
final String currentBundlePath;
|
|
997
|
+
final String fallbackBundleId;
|
|
998
|
+
final String nextBundleId;
|
|
999
|
+
|
|
1000
|
+
ResetState(final String currentBundlePath, final String fallbackBundleId, final String nextBundleId) {
|
|
1001
|
+
this.currentBundlePath = currentBundlePath;
|
|
1002
|
+
this.fallbackBundleId = fallbackBundleId;
|
|
1003
|
+
this.nextBundleId = nextBundleId;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
ResetState captureResetState() {
|
|
1008
|
+
return new ResetState(
|
|
1009
|
+
this.getCurrentBundlePath(),
|
|
1010
|
+
this.prefs.getString(FALLBACK_VERSION, BundleInfo.ID_BUILTIN),
|
|
1011
|
+
this.prefs.getString(NEXT_VERSION, null)
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
void restoreResetState(final ResetState state) {
|
|
1016
|
+
final String currentBundlePath = state.currentBundlePath == null || state.currentBundlePath.trim().isEmpty()
|
|
1017
|
+
? "public"
|
|
1018
|
+
: state.currentBundlePath;
|
|
1019
|
+
final String fallbackBundleId = state.fallbackBundleId == null || state.fallbackBundleId.isEmpty()
|
|
1020
|
+
? BundleInfo.ID_BUILTIN
|
|
1021
|
+
: state.fallbackBundleId;
|
|
1022
|
+
|
|
1023
|
+
this.editor.putString(this.CAP_SERVER_PATH, currentBundlePath);
|
|
1024
|
+
this.editor.putString(FALLBACK_VERSION, fallbackBundleId);
|
|
1025
|
+
if (state.nextBundleId == null || state.nextBundleId.isEmpty()) {
|
|
1026
|
+
this.editor.remove(NEXT_VERSION);
|
|
1027
|
+
} else {
|
|
1028
|
+
this.editor.putString(NEXT_VERSION, state.nextBundleId);
|
|
1029
|
+
}
|
|
1030
|
+
this.editor.commit();
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
void prepareResetStateForTransition() {
|
|
1034
|
+
this.setCurrentBundle(new File("public"));
|
|
1035
|
+
this.setFallbackBundle(null);
|
|
1036
|
+
this.setNextBundle(null);
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
void finalizeResetTransition(final String previousBundleName, final boolean internal) {
|
|
1040
|
+
if (this.activity != null) {
|
|
1041
|
+
DownloadWorkerManager.cancelAllDownloads(this.activity);
|
|
1042
|
+
}
|
|
1043
|
+
if (!internal) {
|
|
1044
|
+
this.sendStats("reset", this.getCurrentBundle().getVersionName(), previousBundleName);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
boolean canSet(final BundleInfo bundle) {
|
|
1049
|
+
return bundle != null && (bundle.isBuiltin() || this.bundleExists(bundle.getId()));
|
|
1050
|
+
}
|
|
1051
|
+
|
|
994
1052
|
public Boolean set(final BundleInfo bundle) {
|
|
995
1053
|
return this.set(bundle.getId());
|
|
996
1054
|
}
|
|
@@ -1015,6 +1073,21 @@ public class CapgoUpdater {
|
|
|
1015
1073
|
return false;
|
|
1016
1074
|
}
|
|
1017
1075
|
|
|
1076
|
+
boolean stagePendingReload(final BundleInfo bundle) {
|
|
1077
|
+
if (bundle == null || bundle.isBuiltin() || !this.bundleExists(bundle.getId())) {
|
|
1078
|
+
return false;
|
|
1079
|
+
}
|
|
1080
|
+
this.setCurrentBundle(this.getBundleDirectory(bundle.getId()));
|
|
1081
|
+
return true;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
void finalizePendingReload(final BundleInfo bundle, final String previousBundleName) {
|
|
1085
|
+
if (bundle == null || bundle.isBuiltin()) {
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
this.sendStats("set", bundle.getVersionName(), previousBundleName);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1018
1091
|
public void autoReset() {
|
|
1019
1092
|
final BundleInfo currentBundle = this.getCurrentBundle();
|
|
1020
1093
|
if (!currentBundle.isBuiltin() && !this.bundleExists(currentBundle.getId())) {
|
|
@@ -1058,17 +1131,9 @@ public class CapgoUpdater {
|
|
|
1058
1131
|
|
|
1059
1132
|
public void reset(final boolean internal) {
|
|
1060
1133
|
logger.debug("reset: " + internal);
|
|
1061
|
-
|
|
1062
|
-
this.
|
|
1063
|
-
this.
|
|
1064
|
-
this.setNextBundle(null);
|
|
1065
|
-
// Cancel any ongoing downloads
|
|
1066
|
-
if (this.activity != null) {
|
|
1067
|
-
DownloadWorkerManager.cancelAllDownloads(this.activity);
|
|
1068
|
-
}
|
|
1069
|
-
if (!internal) {
|
|
1070
|
-
this.sendStats("reset", this.getCurrentBundle().getVersionName(), currentBundleName);
|
|
1071
|
-
}
|
|
1134
|
+
final String currentBundleName = this.getCurrentBundle().getVersionName();
|
|
1135
|
+
this.prepareResetStateForTransition();
|
|
1136
|
+
this.finalizeResetTransition(currentBundleName, internal);
|
|
1072
1137
|
}
|
|
1073
1138
|
|
|
1074
1139
|
private JSONObject createInfoObject() throws JSONException {
|
|
@@ -110,7 +110,23 @@ public class DownloadService extends Worker {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
private static String sanitizeUserAgentValue(String value) {
|
|
113
|
-
|
|
113
|
+
if (value == null || value.isEmpty()) {
|
|
114
|
+
return "unknown";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
StringBuilder sanitized = new StringBuilder();
|
|
118
|
+
value
|
|
119
|
+
.codePoints()
|
|
120
|
+
.forEach((cp) -> {
|
|
121
|
+
boolean isVisibleAscii = cp >= 0x20 && cp <= 0x7E;
|
|
122
|
+
boolean isIso88591 = cp >= 0xA0 && cp <= 0xFF;
|
|
123
|
+
if (isVisibleAscii || isIso88591) {
|
|
124
|
+
sanitized.appendCodePoint(cp);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
String result = sanitized.toString().trim();
|
|
129
|
+
return result.isEmpty() ? "unknown" : result;
|
|
114
130
|
}
|
|
115
131
|
|
|
116
132
|
// Method to update User-Agent values
|
package/dist/docs.json
CHANGED
|
@@ -343,7 +343,7 @@
|
|
|
343
343
|
},
|
|
344
344
|
{
|
|
345
345
|
"name": "link",
|
|
346
|
-
"text": "ResetOptions} to control reset behavior
|
|
346
|
+
"text": "ResetOptions} to control reset behavior.\nIf `toLastSuccessful` is `false` (or omitted), resets to builtin.\nIf `true`, resets to last successful bundle.\nIf `usePendingBundle` is `true`, applies the pending bundle set via {@link next} and clears it."
|
|
347
347
|
},
|
|
348
348
|
{
|
|
349
349
|
"name": "returns",
|
|
@@ -1872,10 +1872,27 @@
|
|
|
1872
1872
|
"properties": [
|
|
1873
1873
|
{
|
|
1874
1874
|
"name": "toLastSuccessful",
|
|
1875
|
-
"tags": [
|
|
1876
|
-
|
|
1875
|
+
"tags": [
|
|
1876
|
+
{
|
|
1877
|
+
"text": "false",
|
|
1878
|
+
"name": "default"
|
|
1879
|
+
}
|
|
1880
|
+
],
|
|
1881
|
+
"docs": "Reset to the last successfully loaded bundle instead of the builtin one.",
|
|
1877
1882
|
"complexTypes": [],
|
|
1878
|
-
"type": "boolean"
|
|
1883
|
+
"type": "boolean | undefined"
|
|
1884
|
+
},
|
|
1885
|
+
{
|
|
1886
|
+
"name": "usePendingBundle",
|
|
1887
|
+
"tags": [
|
|
1888
|
+
{
|
|
1889
|
+
"text": "false",
|
|
1890
|
+
"name": "default"
|
|
1891
|
+
}
|
|
1892
|
+
],
|
|
1893
|
+
"docs": "Apply the pending bundle set via {@link next} while resetting.\n\nWhen `true`, the plugin will switch to the pending bundle immediately and clear the pending flag.\nIf no pending bundle exists, the reset will fail.",
|
|
1894
|
+
"complexTypes": [],
|
|
1895
|
+
"type": "boolean | undefined"
|
|
1879
1896
|
}
|
|
1880
1897
|
]
|
|
1881
1898
|
},
|
|
@@ -568,7 +568,10 @@ export interface CapacitorUpdaterPlugin {
|
|
|
568
568
|
* - Testing rollback functionality
|
|
569
569
|
* - Providing users a "reset to factory" option
|
|
570
570
|
*
|
|
571
|
-
* @param options {@link ResetOptions} to control reset behavior.
|
|
571
|
+
* @param options {@link ResetOptions} to control reset behavior.
|
|
572
|
+
* If `toLastSuccessful` is `false` (or omitted), resets to builtin.
|
|
573
|
+
* If `true`, resets to last successful bundle.
|
|
574
|
+
* If `usePendingBundle` is `true`, applies the pending bundle set via {@link next} and clears it.
|
|
572
575
|
* @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.
|
|
573
576
|
* @throws {Error} If the reset operation fails.
|
|
574
577
|
*/
|
|
@@ -1680,7 +1683,19 @@ export interface BundleListResult {
|
|
|
1680
1683
|
bundles: BundleInfo[];
|
|
1681
1684
|
}
|
|
1682
1685
|
export interface ResetOptions {
|
|
1683
|
-
|
|
1686
|
+
/**
|
|
1687
|
+
* Reset to the last successfully loaded bundle instead of the builtin one.
|
|
1688
|
+
* @default false
|
|
1689
|
+
*/
|
|
1690
|
+
toLastSuccessful?: boolean;
|
|
1691
|
+
/**
|
|
1692
|
+
* Apply the pending bundle set via {@link next} while resetting.
|
|
1693
|
+
*
|
|
1694
|
+
* When `true`, the plugin will switch to the pending bundle immediately and clear the pending flag.
|
|
1695
|
+
* If no pending bundle exists, the reset will fail.
|
|
1696
|
+
* @default false
|
|
1697
|
+
*/
|
|
1698
|
+
usePendingBundle?: boolean;
|
|
1684
1699
|
}
|
|
1685
1700
|
export interface ListOptions {
|
|
1686
1701
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAyjEH;;;;GAIG;AACH,MAAM,CAAN,IAAY,qBAsBX;AAtBD,WAAY,qBAAqB;IAC/B;;;OAGG;IACH,uEAAW,CAAA;IAEX;;;OAGG;IACH,iGAAwB,CAAA;IAExB;;OAEG;IACH,yFAAoB,CAAA;IAEpB;;OAEG;IACH,6FAAsB,CAAA;AACxB,CAAC,EAtBW,qBAAqB,KAArB,qBAAqB,QAsBhC;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,2BA2CX;AA3CD,WAAY,2BAA2B;IACrC;;OAEG;IACH,mFAAW,CAAA;IAEX;;OAEG;IACH,mFAAW,CAAA;IAEX;;;OAGG;IACH,2FAAe,CAAA;IAEf;;OAEG;IACH,yFAAc,CAAA;IAEd;;;OAGG;IACH,uFAAa,CAAA;IAEb;;OAEG;IACH,iFAAU,CAAA;IAEV;;OAEG;IACH,qFAAY,CAAA;IAEZ;;;OAGG;IACH,0FAAe,CAAA;AACjB,CAAC,EA3CW,2BAA2B,KAA3B,2BAA2B,QA2CtC;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,mBAgCX;AAhCD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,yDAAM,CAAA;IAEN;;OAEG;IACH,qEAAY,CAAA;IAEZ;;OAEG;IACH,iEAAU,CAAA;IAEV;;OAEG;IACH,+EAAiB,CAAA;IAEjB;;;OAGG;IACH,2EAAe,CAAA;IAEf;;;OAGG;IACH,6EAAgB,CAAA;AAClB,CAAC,EAhCW,mBAAmB,KAAnB,mBAAmB,QAgC9B","sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\n\n/// <reference types=\"@capacitor/cli\" />\nimport type { PluginListenerHandle } from '@capacitor/core';\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * CapacitorUpdater can be configured with these options:\n */\n CapacitorUpdater?: {\n /**\n * Configure the number of milliseconds the native plugin should wait before considering an update 'failed'.\n *\n * Only available for Android and iOS.\n *\n * @default 10000 // (10 seconds)\n * @example 1000 // (1 second, minimum 1000)\n */\n appReadyTimeout?: number;\n\n /**\n * Configure the number of seconds the native plugin should wait before considering API timeout.\n *\n * Only available for Android and iOS.\n *\n * @default 20 // (20 second)\n * @example 10 // (10 second)\n */\n responseTimeout?: number;\n\n /**\n * Configure whether the plugin should use automatically delete failed bundles.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoDeleteFailed?: boolean;\n\n /**\n * Configure whether the plugin should use automatically delete previous bundles after a successful update.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoDeletePrevious?: boolean;\n\n /**\n * Configure whether the plugin should use Auto Update via an update server.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoUpdate?: boolean;\n\n /**\n * Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device.\n * Setting this to false can broke the auto update flow if the user download from the store a native app bundle that is older than the current downloaded bundle. Upload will be prevented by channel setting downgrade_under_native.\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n resetWhenUpdate?: boolean;\n\n /**\n * Configure the URL / endpoint to which update checks are sent.\n *\n * Only available for Android and iOS.\n *\n * @default https://plugin.capgo.app/updates\n * @example https://example.com/api/auto_update\n */\n updateUrl?: string;\n\n /**\n * Configure the URL / endpoint for channel operations.\n *\n * Only available for Android and iOS.\n *\n * @default https://plugin.capgo.app/channel_self\n * @example https://example.com/api/channel\n */\n channelUrl?: string;\n\n /**\n * Configure the URL / endpoint to which update statistics are sent.\n *\n * Only available for Android and iOS. Set to \"\" to disable stats reporting.\n *\n * @default https://plugin.capgo.app/stats\n * @example https://example.com/api/stats\n */\n statsUrl?: string;\n\n /**\n * Configure the public key for end to end live update encryption Version 2\n *\n * Only available for Android and iOS.\n *\n * @default undefined\n * @since 6.2.0\n */\n publicKey?: string;\n\n /**\n * Configure the current version of the app. This will be used for the first update request.\n * If not set, the plugin will get the version from the native code.\n *\n * Only available for Android and iOS.\n *\n * @default undefined\n * @since 4.17.48\n */\n version?: string;\n\n /**\n * Configure when the plugin should direct install updates. Only for autoUpdate mode.\n * Works well for apps less than 10MB and with uploads done using --delta flag.\n * Zip or apps more than 10MB will be relatively slow for users to update.\n * - false: Never do direct updates (use default behavior: download at start, set when backgrounded)\n * - atInstall: Direct update only when app is installed, updated from store, otherwise act as directUpdate = false\n * - onLaunch: Direct update only on app installed, updated from store or after app kill, otherwise act as directUpdate = false\n * - always: Direct update in all previous cases (app installed, updated from store, after app kill or app resume), never act as directUpdate = false\n * - true: (deprecated) Same as \"always\" for backward compatibility\n *\n * Activate this flag will automatically make the CLI upload delta in CICD envs and will ask for confirmation in local uploads.\n * Only available for Android and iOS.\n *\n * @default false\n * @since 5.1.0\n */\n directUpdate?: boolean | 'atInstall' | 'always' | 'onLaunch';\n\n /**\n * Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed.\n * This removes the need to manually listen for appReady events and call SplashScreen.hide().\n * Only works when directUpdate is set to \"atInstall\", \"always\", \"onLaunch\", or true.\n * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\n * Requires autoUpdate and directUpdate to be enabled.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.6.0\n */\n autoSplashscreen?: boolean;\n\n /**\n * Display a native loading indicator on top of the splashscreen while automatic direct updates are running.\n * Only takes effect when {@link autoSplashscreen} is enabled.\n * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.19.0\n */\n autoSplashscreenLoader?: boolean;\n\n /**\n * Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates.\n * If the timeout elapses, the update continues to download in the background while the splashscreen is dismissed.\n * Set to `0` (zero) to disable the timeout.\n * When the timeout fires, the direct update flow is skipped and the downloaded bundle is installed on the next background/launch.\n * Requires {@link autoSplashscreen} to be enabled.\n *\n * Only available for Android and iOS.\n *\n * @default 10000 // (10 seconds)\n * @since 7.19.0\n */\n autoSplashscreenTimeout?: number;\n\n /**\n * Configure the delay period for period update check. the unit is in seconds.\n *\n * Only available for Android and iOS.\n * Cannot be less than 600 seconds (10 minutes).\n *\n * @default 0 (disabled)\n * @example 3600 (1 hour)\n * @example 86400 (24 hours)\n */\n periodCheckDelay?: number;\n\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localS3?: boolean;\n\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localHost?: string;\n\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localWebHost?: string;\n\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localSupa?: string;\n\n /**\n * Configure the CLI to use a local server for testing.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localSupaAnon?: string;\n\n /**\n * Configure the CLI to use a local api for testing.\n *\n *\n * @default undefined\n * @since 6.3.3\n */\n localApi?: string;\n\n /**\n * Configure the CLI to use a local file api for testing.\n *\n *\n * @default undefined\n * @since 6.3.3\n */\n localApiFiles?: string;\n /**\n * Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side.\n *\n *\n * @default false\n * @since 5.4.0\n */\n allowModifyUrl?: boolean;\n\n /**\n * Allow the plugin to modify the appId dynamically from the JavaScript side.\n *\n *\n * @default false\n * @since 7.14.0\n */\n allowModifyAppId?: boolean;\n\n /**\n * Allow marking bundles as errored from JavaScript while using manual update flows.\n * When enabled, {@link CapacitorUpdaterPlugin.setBundleError} can change a bundle status to `error`.\n *\n * @default false\n * @since 7.20.0\n */\n allowManualBundleError?: boolean;\n\n /**\n * Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts.\n *\n * Only available for Android and iOS.\n *\n * @default false (will be true by default in a future major release v8.x.x)\n * @since 7.17.3\n */\n persistCustomId?: boolean;\n\n /**\n * Persist the updateUrl, statsUrl and channelUrl set through {@link CapacitorUpdaterPlugin.setUpdateUrl},\n * {@link CapacitorUpdaterPlugin.setStatsUrl} and {@link CapacitorUpdaterPlugin.setChannelUrl} across app restarts.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.20.0\n */\n persistModifyUrl?: boolean;\n\n /**\n * Allow or disallow the {@link CapacitorUpdaterPlugin.setChannel} method to modify the defaultChannel.\n * When set to `false`, calling `setChannel()` will return an error with code `disabled_by_config`.\n *\n * @default true\n * @since 7.34.0\n */\n allowSetDefaultChannel?: boolean;\n\n /**\n * Set the default channel for the app in the config. Case sensitive.\n * This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud.\n * This requires the channel to allow devices to self dissociate/associate in the channel settings. https://capgo.app/docs/public-api/channels/#channel-configuration-options\n *\n *\n * @default undefined\n * @since 5.5.0\n */\n defaultChannel?: string;\n /**\n * Configure the app id for the app in the config.\n *\n * @default undefined\n * @since 6.0.0\n */\n appId?: string;\n\n /**\n * Configure the plugin to keep the URL path after a reload.\n * WARNING: When a reload is triggered, 'window.history' will be cleared.\n *\n * @default false\n * @since 6.8.0\n */\n keepUrlPathAfterReload?: boolean;\n\n /**\n * Disable the JavaScript logging of the plugin. if true, the plugin will not log to the JavaScript console. only the native log will be done\n *\n * @default false\n * @since 7.3.0\n */\n disableJSLogging?: boolean;\n\n /**\n * Enable OS-level logging. When enabled, logs are written to the system log which can be inspected in production builds.\n *\n * - **iOS**: Uses os_log instead of Swift.print, logs accessible via Console.app or Instruments\n * - **Android**: Logs to Logcat (android.util.Log)\n *\n * When set to false, system logging is disabled on both platforms (only JavaScript console logging will occur if enabled).\n *\n * This is useful for debugging production apps (App Store/TestFlight builds on iOS, or production APKs on Android).\n *\n * @default true\n * @since 8.42.0\n */\n osLogging?: boolean;\n\n /**\n * Enable shake gesture to show update menu for debugging/testing purposes\n *\n * @default false\n * @since 7.5.0\n */\n shakeMenu?: boolean;\n\n /**\n * Enable the shake gesture to show a channel selector menu for switching between update channels.\n * When enabled AND `shakeMenu` is true, the shake gesture shows a channel selector\n * instead of the default debug menu (Go Home/Reload/Close).\n *\n * After selecting a channel, the app automatically checks for updates and downloads if available.\n * Only works if channels have `allow_self_set` enabled on the backend.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 8.43.0\n */\n allowShakeChannelSelector?: boolean;\n };\n }\n}\n\nexport interface CapacitorUpdaterPlugin {\n /**\n * Notify the native layer that JavaScript initialized successfully.\n *\n * **CRITICAL: You must call this method on every app launch to prevent automatic rollback.**\n *\n * This is a simple notification to confirm that your bundle's JavaScript loaded and executed.\n * The native web server successfully served the bundle files and your JS runtime started.\n * That's all it checks - nothing more complex.\n *\n * **What triggers rollback:**\n * - NOT calling this method within the timeout (default: 10 seconds)\n * - Complete JavaScript failure (bundle won't load at all)\n *\n * **What does NOT trigger rollback:**\n * - Runtime errors after initialization (API failures, crashes, etc.)\n * - Network request failures\n * - Application logic errors\n *\n * **IMPORTANT: Call this BEFORE any network requests.**\n * Don't wait for APIs, data loading, or async operations. Call it as soon as your\n * JavaScript bundle starts executing to confirm the bundle itself is valid.\n *\n * Best practices:\n * - Call immediately in your app entry point (main.js, app component mount, etc.)\n * - Don't put it after network calls or heavy initialization\n * - Don't wrap it in try/catch with conditions\n * - Adjust {@link PluginsConfig.CapacitorUpdater.appReadyTimeout} if you need more time\n *\n * @returns {Promise<AppReadyResult>} Always resolves successfully with current bundle info. This method never fails.\n */\n notifyAppReady(): Promise<AppReadyResult>;\n\n /**\n * Set the update URL for the app dynamically at runtime.\n *\n * This overrides the {@link PluginsConfig.CapacitorUpdater.updateUrl} config value.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.\n *\n * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.\n * Otherwise, the URL will reset to the config value on next app launch.\n *\n * @param options Contains the URL to use for checking for updates.\n * @returns {Promise<void>} Resolves when the URL is successfully updated.\n * @throws {Error} If `allowModifyUrl` is false or if the operation fails.\n * @since 5.4.0\n */\n setUpdateUrl(options: UpdateUrl): Promise<void>;\n\n /**\n * Set the statistics URL for the app dynamically at runtime.\n *\n * This overrides the {@link PluginsConfig.CapacitorUpdater.statsUrl} config value.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.\n *\n * Pass an empty string to disable statistics gathering entirely.\n * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.\n *\n * @param options Contains the URL to use for sending statistics, or an empty string to disable.\n * @returns {Promise<void>} Resolves when the URL is successfully updated.\n * @throws {Error} If `allowModifyUrl` is false or if the operation fails.\n * @since 5.4.0\n */\n setStatsUrl(options: StatsUrl): Promise<void>;\n\n /**\n * Set the channel URL for the app dynamically at runtime.\n *\n * This overrides the {@link PluginsConfig.CapacitorUpdater.channelUrl} config value.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.\n *\n * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.\n * Otherwise, the URL will reset to the config value on next app launch.\n *\n * @param options Contains the URL to use for channel operations.\n * @returns {Promise<void>} Resolves when the URL is successfully updated.\n * @throws {Error} If `allowModifyUrl` is false or if the operation fails.\n * @since 5.4.0\n */\n setChannelUrl(options: ChannelUrl): Promise<void>;\n\n /**\n * Download a new bundle from the provided URL for later installation.\n *\n * The downloaded bundle is stored locally but not activated. To use it:\n * - Call {@link next} to set it for installation on next app backgrounding/restart\n * - Call {@link set} to activate it immediately (destroys current JavaScript context)\n *\n * The URL should point to a zip file containing either:\n * - Your app files directly in the zip root, or\n * - A single folder containing all your app files\n *\n * The bundle must include an `index.html` file at the root level.\n *\n * For encrypted bundles, provide the `sessionKey` and `checksum` parameters.\n * For multi-file delta updates, provide the `manifest` array.\n *\n * @example\n * const bundle = await CapacitorUpdater.download({\n * url: `https://example.com/versions/${version}/dist.zip`,\n * version: version\n * });\n * // Bundle is downloaded but not active yet\n * await CapacitorUpdater.next({ id: bundle.id }); // Will activate on next background\n *\n * @param options The {@link DownloadOptions} for downloading a new bundle zip.\n * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the downloaded bundle.\n * @throws {Error} If the download fails or the bundle is invalid.\n */\n download(options: DownloadOptions): Promise<BundleInfo>;\n\n /**\n * Set the next bundle to be activated when the app backgrounds or restarts.\n *\n * This is the recommended way to apply updates as it doesn't interrupt the user's current session.\n * The bundle will be activated when:\n * - The app is backgrounded (user switches away), or\n * - The app is killed and relaunched, or\n * - {@link reload} is called manually\n *\n * Unlike {@link set}, this method does NOT destroy the current JavaScript context immediately.\n * Your app continues running normally until one of the above events occurs.\n *\n * Use {@link setMultiDelay} to add additional conditions before the update is applied.\n *\n * @param options Contains the ID of the bundle to set as next. Use {@link BundleInfo.id} from a downloaded bundle.\n * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle.\n * @throws {Error} When there is no index.html file inside the bundle folder or the bundle doesn't exist.\n */\n next(options: BundleId): Promise<BundleInfo>;\n\n /**\n * Set the current bundle and immediately reloads the app.\n *\n * **IMPORTANT: This is a terminal operation that destroys the current JavaScript context.**\n *\n * When you call this method:\n * - The entire JavaScript context is immediately destroyed\n * - The app reloads from a different folder with different files\n * - NO code after this call will execute\n * - NO promises will resolve\n * - NO callbacks will fire\n * - Event listeners registered after this call are unreliable and may never fire\n *\n * The reload happens automatically - you don't need to do anything else.\n * If you need to preserve state like the current URL path, use the {@link PluginsConfig.CapacitorUpdater.keepUrlPathAfterReload} config option.\n * For other state preservation needs, save your data before calling this method (e.g., to localStorage).\n *\n * **Do not** try to execute additional logic after calling `set()` - it won't work as expected.\n *\n * @param options A {@link BundleId} object containing the new bundle id to set as current.\n * @returns {Promise<void>} A promise that will never resolve because the JavaScript context is destroyed.\n * @throws {Error} When there is no index.html file inside the bundle folder.\n */\n set(options: BundleId): Promise<void>;\n\n /**\n * Delete a bundle from local storage to free up disk space.\n *\n * You cannot delete:\n * - The currently active bundle\n * - The `builtin` bundle (the version shipped with your app)\n * - The bundle set as `next` (call {@link next} with a different bundle first)\n *\n * Use {@link list} to get all available bundle IDs.\n *\n * **Note:** The bundle ID is NOT the same as the version name.\n * Use the `id` field from {@link BundleInfo}, not the `version` field.\n *\n * @param options A {@link BundleId} object containing the bundle ID to delete.\n * @returns {Promise<void>} Resolves when the bundle is successfully deleted.\n * @throws {Error} If the bundle is currently in use or doesn't exist.\n */\n delete(options: BundleId): Promise<void>;\n\n /**\n * Manually mark a bundle as failed/errored in manual update mode.\n *\n * This is useful when you detect that a bundle has critical issues and want to prevent\n * it from being used again. The bundle status will be changed to `error` and the plugin\n * will avoid using this bundle in the future.\n *\n * **Requirements:**\n * - {@link PluginsConfig.CapacitorUpdater.allowManualBundleError} must be set to `true`\n * - Only works in manual update mode (when autoUpdate is disabled)\n *\n * Common use case: After downloading and testing a bundle, you discover it has critical\n * bugs and want to mark it as failed so it won't be retried.\n *\n * @param options A {@link BundleId} object containing the bundle ID to mark as errored.\n * @returns {Promise<BundleInfo>} The updated {@link BundleInfo} with status set to `error`.\n * @throws {Error} When the bundle does not exist or `allowManualBundleError` is false.\n * @since 7.20.0\n */\n setBundleError(options: BundleId): Promise<BundleInfo>;\n\n /**\n * Get all locally downloaded bundles stored in your app.\n *\n * This returns all bundles that have been downloaded and are available locally, including:\n * - The currently active bundle\n * - The `builtin` bundle (shipped with your app)\n * - Any downloaded bundles waiting to be activated\n * - Failed bundles (with `error` status)\n *\n * Use this to:\n * - Check available disk space by counting bundles\n * - Delete old bundles with {@link delete}\n * - Monitor bundle download status\n *\n * @param options The {@link ListOptions} for customizing the bundle list output.\n * @returns {Promise<BundleListResult>} A promise containing the array of {@link BundleInfo} objects.\n * @throws {Error} If the operation fails.\n */\n list(options?: ListOptions): Promise<BundleListResult>;\n\n /**\n * Reset the app to a known good bundle.\n *\n * This method helps recover from problematic updates by reverting to either:\n * - The `builtin` bundle (the original version shipped with your app to App Store/Play Store)\n * - The last successfully loaded bundle (most recent bundle that worked correctly)\n *\n * **IMPORTANT: This triggers an immediate app reload, destroying the current JavaScript context.**\n * See {@link set} for details on the implications of this operation.\n *\n * Use cases:\n * - Emergency recovery when an update causes critical issues\n * - Testing rollback functionality\n * - Providing users a \"reset to factory\" option\n *\n * @param options {@link ResetOptions} to control reset behavior. If `toLastSuccessful` is `false` (or omitted), resets to builtin. If `true`, resets to last successful bundle.\n * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.\n * @throws {Error} If the reset operation fails.\n */\n reset(options?: ResetOptions): Promise<void>;\n\n /**\n * Get information about the currently active bundle.\n *\n * Returns:\n * - `bundle`: The currently active bundle information\n * - `native`: The version of the builtin bundle (the original app version from App/Play Store)\n *\n * If no updates have been applied, `bundle.id` will be `\"builtin\"`, indicating the app\n * is running the original version shipped with the native app.\n *\n * Use this to:\n * - Display the current version to users\n * - Check if an update is currently active\n * - Compare against available updates\n * - Log the active bundle for debugging\n *\n * @returns {Promise<CurrentBundleResult>} A promise with the current bundle and native version info.\n * @throws {Error} If the operation fails.\n */\n current(): Promise<CurrentBundleResult>;\n\n /**\n * Manually reload the app to apply a pending update.\n *\n * This triggers the same reload behavior that happens automatically when the app backgrounds.\n * If you've called {@link next} to queue an update, calling `reload()` will apply it immediately.\n *\n * **IMPORTANT: This destroys the current JavaScript context immediately.**\n * See {@link set} for details on the implications of this operation.\n *\n * Common use cases:\n * - Applying an update immediately after download instead of waiting for backgrounding\n * - Providing a \"Restart now\" button to users after an update is ready\n * - Testing update flows during development\n *\n * If no update is pending (no call to {@link next}), this simply reloads the current bundle.\n *\n * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.\n * @throws {Error} If the reload operation fails.\n */\n reload(): Promise<void>;\n\n /**\n * Configure conditions that must be met before a pending update is applied.\n *\n * After calling {@link next} to queue an update, use this method to control when it gets applied.\n * The update will only be installed after ALL specified conditions are satisfied.\n *\n * Available condition types:\n * - `background`: Wait for the app to be backgrounded. Optionally specify duration in milliseconds.\n * - `kill`: Wait for the app to be killed and relaunched (**Note:** Current behavior triggers update immediately on kill, not on next background. This will be fixed in v8.)\n * - `date`: Wait until a specific date/time (ISO 8601 format)\n * - `nativeVersion`: Wait until the native app is updated to a specific version\n *\n * Condition value formats:\n * - `background`: Number in milliseconds (e.g., `\"300000\"` for 5 minutes), or omit for immediate\n * - `kill`: No value needed\n * - `date`: ISO 8601 date string (e.g., `\"2025-12-31T23:59:59Z\"`)\n * - `nativeVersion`: Version string (e.g., `\"2.0.0\"`)\n *\n * @example\n * // Update after user kills app OR after 5 minutes in background\n * await CapacitorUpdater.setMultiDelay({\n * delayConditions: [\n * { kind: 'kill' },\n * { kind: 'background', value: '300000' }\n * ]\n * });\n *\n * @example\n * // Update after a specific date\n * await CapacitorUpdater.setMultiDelay({\n * delayConditions: [{ kind: 'date', value: '2025-12-31T23:59:59Z' }]\n * });\n *\n * @example\n * // Default behavior: update on next background\n * await CapacitorUpdater.setMultiDelay({\n * delayConditions: [{ kind: 'background' }]\n * });\n *\n * @param options Contains the {@link MultiDelayConditions} array of conditions.\n * @returns {Promise<void>} Resolves when the delay conditions are set.\n * @throws {Error} If the operation fails or conditions are invalid.\n * @since 4.3.0\n */\n setMultiDelay(options: MultiDelayConditions): Promise<void>;\n\n /**\n * Cancel all delay conditions and apply the pending update immediately.\n *\n * If you've set delay conditions with {@link setMultiDelay}, this method clears them\n * and triggers the pending update to be applied on the next app background or restart.\n *\n * This is useful when:\n * - User manually requests to update now (e.g., clicks \"Update now\" button)\n * - Your app detects it's a good time to update (e.g., user finished critical task)\n * - You want to override a time-based delay early\n *\n * @returns {Promise<void>} Resolves when the delay conditions are cleared.\n * @throws {Error} If the operation fails.\n * @since 4.0.0\n */\n cancelDelay(): Promise<void>;\n\n /**\n * Check the update server for the latest available bundle version.\n *\n * This queries your configured update URL (or Capgo backend) to see if a newer bundle\n * is available for download. It does NOT download the bundle automatically.\n *\n * The 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 *\n * After receiving the latest version info, you can:\n * 1. Compare it with your current version\n * 2. Download it using {@link download}\n * 3. Apply it using {@link next} or {@link set}\n *\n * **Important: Error handling for \"no new version available\"**\n *\n * When the device's current version matches the latest version on the server (i.e., the device is already\n * up-to-date), the server returns a 200 response with `error: \"no_new_version_available\"` and\n * `message: \"No new version available\"`. **This causes `getLatest()` to throw an error**, even though\n * this is a normal, expected condition.\n *\n * You should catch this specific error to handle it gracefully:\n *\n * ```typescript\n * try {\n * const latest = await CapacitorUpdater.getLatest();\n * // New version is available, proceed with download\n * } catch (error) {\n * if (error.message === 'No new version available') {\n * // Device is already on the latest version - this is normal\n * console.log('Already up to date');\n * } else {\n * // Actual error occurred\n * console.error('Failed to check for updates:', error);\n * }\n * }\n * ```\n *\n * In 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)\n *\n * @param options Optional {@link GetLatestOptions} to specify which channel to check.\n * @returns {Promise<LatestVersion>} Information about the latest available bundle version.\n * @throws {Error} Always throws when no new version is available (`error: \"no_new_version_available\"`), or when the request fails.\n * @since 4.0.0\n */\n getLatest(options?: GetLatestOptions): Promise<LatestVersion>;\n\n /**\n * Assign this device to a specific update channel at runtime.\n *\n * Channels allow you to distribute different bundle versions to different groups of users\n * (e.g., \"production\", \"beta\", \"staging\"). This method switches the device to a new channel.\n *\n * **Requirements:**\n * - The target channel must allow self-assignment (configured in your Capgo dashboard or backend)\n * - The backend may accept or reject the request based on channel settings\n *\n * **When to use:**\n * - After the app is ready and the user has interacted (e.g., opted into beta program)\n * - To implement in-app channel switching (beta toggle, tester access, etc.)\n * - For user-driven channel changes\n *\n * **When NOT to use:**\n * - At app boot/initialization - use {@link PluginsConfig.CapacitorUpdater.defaultChannel} config instead\n * - Before user interaction\n *\n * **Important: Listen for the `channelPrivate` event**\n *\n * When a user attempts to set a channel that doesn't allow device self-assignment, the method will\n * throw an error AND fire a {@link addListener}('channelPrivate') event. You should listen to this event\n * to provide appropriate feedback to users:\n *\n * ```typescript\n * CapacitorUpdater.addListener('channelPrivate', (data) => {\n * console.warn(`Cannot access channel \"${data.channel}\": ${data.message}`);\n * // Show user-friendly message\n * });\n * ```\n *\n * This sends a request to the Capgo backend linking your device ID to the specified channel.\n *\n * @param options The {@link SetChannelOptions} containing the channel name and optional auto-update trigger.\n * @returns {Promise<ChannelRes>} Channel operation result with status and optional error/message.\n * @throws {Error} If the channel doesn't exist or doesn't allow self-assignment.\n * @since 4.7.0\n */\n setChannel(options: SetChannelOptions): Promise<ChannelRes>;\n\n /**\n * Remove the device's channel assignment and return to the default channel.\n *\n * This unlinks the device from any specifically assigned channel, causing it to fall back to:\n * - The {@link PluginsConfig.CapacitorUpdater.defaultChannel} if configured, or\n * - Your backend's default channel for this app\n *\n * Use this when:\n * - Users opt out of beta/testing programs\n * - You want to reset a device to standard update distribution\n * - Testing channel switching behavior\n *\n * @param options {@link UnsetChannelOptions} containing optional auto-update trigger.\n * @returns {Promise<void>} Resolves when the channel is successfully unset.\n * @throws {Error} If the operation fails.\n * @since 4.7.0\n */\n unsetChannel(options: UnsetChannelOptions): Promise<void>;\n\n /**\n * Get the current channel assigned to this device.\n *\n * Returns information about:\n * - `channel`: The currently assigned channel name (if any)\n * - `allowSet`: Whether the channel allows self-assignment\n * - `status`: Operation status\n * - `error`/`message`: Additional information (if applicable)\n *\n * Use this to:\n * - Display current channel to users (e.g., \"You're on the Beta channel\")\n * - Check if a device is on a specific channel before showing features\n * - Verify channel assignment after calling {@link setChannel}\n *\n * @returns {Promise<GetChannelRes>} The current channel information.\n * @throws {Error} If the operation fails.\n * @since 4.8.0\n */\n getChannel(): Promise<GetChannelRes>;\n\n /**\n * Get a list of all channels available for this device to self-assign to.\n *\n * Only returns channels where `allow_self_set` is `true`. These are channels that\n * users can switch to using {@link setChannel} without backend administrator intervention.\n *\n * Each channel includes:\n * - `id`: Unique channel identifier\n * - `name`: Human-readable channel name\n * - `public`: Whether the channel is publicly visible\n * - `allow_self_set`: Always `true` in results (filtered to only self-assignable channels)\n *\n * Use this to:\n * - Build a channel selector UI for users (e.g., \"Join Beta\" button)\n * - Show available testing/preview channels\n * - Implement channel discovery features\n *\n * @returns {Promise<ListChannelsResult>} List of channels the device can self-assign to.\n * @throws {Error} If the operation fails or the request to the backend fails.\n * @since 7.5.0\n */\n listChannels(): Promise<ListChannelsResult>;\n\n /**\n * Set a custom identifier for this device.\n *\n * This allows you to identify devices by your own custom ID (user ID, account ID, etc.)\n * instead of or in addition to the device's unique hardware ID. The custom ID is sent\n * to your update server and can be used for:\n * - Targeting specific users for updates\n * - Analytics and user tracking\n * - Debugging and support (correlating devices with users)\n * - A/B testing or feature flagging\n *\n * **Persistence:**\n * - When {@link PluginsConfig.CapacitorUpdater.persistCustomId} is `true`, the ID persists across app restarts\n * - When `false`, the ID is only kept for the current session\n *\n * **Clearing the custom ID:**\n * - Pass an empty string `\"\"` to remove any stored custom ID\n *\n * @param options The {@link SetCustomIdOptions} containing the custom identifier string.\n * @returns {Promise<void>} Resolves immediately (synchronous operation).\n * @throws {Error} If the operation fails.\n * @since 4.9.0\n */\n setCustomId(options: SetCustomIdOptions): Promise<void>;\n\n /**\n * Get the builtin bundle version (the original version shipped with your native app).\n *\n * This returns the version of the bundle that was included when the app was installed\n * from the App Store or Play Store. This is NOT the currently active bundle version -\n * use {@link current} for that.\n *\n * Returns:\n * - The {@link PluginsConfig.CapacitorUpdater.version} config value if set, or\n * - The native app version from platform configs (package.json, Info.plist, build.gradle)\n *\n * Use this to:\n * - Display the \"factory\" version to users\n * - Compare against downloaded bundle versions\n * - Determine if any updates have been applied\n * - Debugging version mismatches\n *\n * @returns {Promise<BuiltinVersion>} The builtin bundle version string.\n * @since 5.2.0\n */\n getBuiltinVersion(): Promise<BuiltinVersion>;\n\n /**\n * Get the unique, privacy-friendly identifier for this device.\n *\n * This ID is used to identify the device when communicating with update servers.\n * It's automatically generated and stored securely by the plugin.\n *\n * **Privacy & Security characteristics:**\n * - Generated as a UUID (not based on hardware identifiers)\n * - Stored securely in platform-specific secure storage\n * - Android: Android Keystore (persists across app reinstalls on API 23+)\n * - iOS: Keychain with `kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly`\n * - Not synced to cloud (iOS)\n * - Follows Apple and Google privacy best practices\n * - Users can clear it via system settings (Android) or keychain access (iOS)\n *\n * **Persistence:**\n * The device ID persists across app reinstalls to maintain consistent device identity\n * for update tracking and analytics.\n *\n * Use this to:\n * - Debug update delivery issues (check what ID the server sees)\n * - Implement device-specific features\n * - Correlate server logs with specific devices\n *\n * @returns {Promise<DeviceId>} The unique device identifier string.\n * @throws {Error} If the operation fails.\n */\n getDeviceId(): Promise<DeviceId>;\n\n /**\n * Get the version of the Capacitor Updater plugin installed in your app.\n *\n * This returns the version of the native plugin code (Android/iOS), which is sent\n * to the update server with each request. This is NOT your app version or bundle version.\n *\n * Use this to:\n * - Debug plugin-specific issues (when reporting bugs)\n * - Verify plugin installation and version\n * - Check compatibility with backend features\n * - Display in debug/about screens\n *\n * @returns {Promise<PluginVersion>} The Capacitor Updater plugin version string.\n * @throws {Error} If the operation fails.\n */\n getPluginVersion(): Promise<PluginVersion>;\n\n /**\n * Check if automatic updates are currently enabled.\n *\n * Returns `true` if {@link PluginsConfig.CapacitorUpdater.autoUpdate} is enabled,\n * meaning the plugin will automatically check for, download, and apply updates.\n *\n * Returns `false` if in manual mode, where you control the update flow using\n * {@link getLatest}, {@link download}, {@link next}, and {@link set}.\n *\n * Use this to:\n * - Determine which update flow your app is using\n * - Show/hide manual update UI based on mode\n * - Debug update behavior\n *\n * @returns {Promise<AutoUpdateEnabled>} `true` if auto-update is enabled, `false` if in manual mode.\n * @throws {Error} If the operation fails.\n */\n isAutoUpdateEnabled(): Promise<AutoUpdateEnabled>;\n\n /**\n * Remove all event listeners registered for this plugin.\n *\n * This 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 *\n * Use this during cleanup (e.g., when unmounting components or closing screens)\n * to prevent memory leaks from lingering event listeners.\n *\n * @returns {Promise<void>} Resolves when all listeners are removed.\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Listen for bundle download event in the App. Fires once a download has started, during downloading and when finished.\n * This will return you all download percent during the download\n *\n * @since 2.0.11\n */\n addListener(eventName: 'download', listenerFunc: (state: DownloadEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for no need to update event, useful when you want force check every time the app is launched\n *\n * @since 4.0.0\n */\n addListener(eventName: 'noNeedUpdate', listenerFunc: (state: NoNeedEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for available update event, useful when you want to force check every time the app is launched\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'updateAvailable',\n listenerFunc: (state: UpdateAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for downloadComplete events.\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'downloadComplete',\n listenerFunc: (state: DownloadCompleteEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for breaking update events when the backend flags an update as incompatible with the current app.\n * Emits the same payload as the legacy `majorAvailable` listener.\n *\n * @since 7.22.0\n */\n addListener(\n eventName: 'breakingAvailable',\n listenerFunc: (state: BreakingAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking\n *\n * @deprecated Deprecated alias for {@link addListener} with `breakingAvailable`. Emits the same payload. will be removed in v8\n * @since 2.3.0\n */\n addListener(\n eventName: 'majorAvailable',\n listenerFunc: (state: MajorAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for update fail event in the App, let you know when update has fail to install at next app start\n *\n * @since 2.3.0\n */\n addListener(\n eventName: 'updateFailed',\n listenerFunc: (state: UpdateFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for set event in the App, let you know when a bundle has been applied successfully.\n * This event is retained natively until JavaScript consumes it, so if the app reloads before your\n * listener is attached, the last pending `set` event is delivered once the listener subscribes.\n *\n * @since 8.43.12\n */\n addListener(eventName: 'set', listenerFunc: (state: SetEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for set next event in the App, let you know when a bundle is queued as the next bundle to install.\n *\n * @since 6.14.0\n */\n addListener(eventName: 'setNext', listenerFunc: (state: SetNextEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for download fail event in the App, let you know when a bundle download has failed\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'downloadFailed',\n listenerFunc: (state: DownloadFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for reload event in the App, let you know when reload has happened\n *\n * @since 4.3.0\n */\n addListener(eventName: 'appReloaded', listenerFunc: () => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for app ready event in the App, let you know when app is ready to use.\n * This event is retained natively until JavaScript consumes it, so it can still be delivered after\n * a reload even if the listener is attached later in app startup.\n *\n * @since 5.1.0\n */\n addListener(eventName: 'appReady', listenerFunc: (state: AppReadyEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for channel private event, fired when attempting to set a channel that doesn't allow device self-assignment.\n *\n * This event is useful for:\n * - Informing users they don't have permission to switch to a specific channel\n * - Implementing custom error handling for channel restrictions\n * - Logging unauthorized channel access attempts\n *\n * @since 7.34.0\n */\n addListener(\n eventName: 'channelPrivate',\n listenerFunc: (state: ChannelPrivateEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for flexible update state changes on Android.\n *\n * This event fires during the flexible update download process, providing:\n * - Download progress (bytes downloaded / total bytes)\n * - Installation status changes\n *\n * **Install status values:**\n * - `UNKNOWN` (0): Unknown status\n * - `PENDING` (1): Download pending\n * - `DOWNLOADING` (2): Download in progress\n * - `INSTALLING` (3): Installing the update\n * - `INSTALLED` (4): Update installed (app restart needed)\n * - `FAILED` (5): Update failed\n * - `CANCELED` (6): Update was canceled\n * - `DOWNLOADED` (11): Download complete, ready to install\n *\n * When status is `DOWNLOADED`, you should prompt the user and call\n * {@link completeFlexibleUpdate} to finish the installation.\n *\n * @since 8.0.0\n */\n addListener(\n eventName: 'onFlexibleUpdateStateChange',\n listenerFunc: (state: FlexibleUpdateState) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Check if the auto-update feature is available (not disabled by custom server configuration).\n *\n * Returns `false` when a custom `updateUrl` is configured, as this typically indicates\n * you're using a self-hosted update server that may not support all auto-update features.\n *\n * Returns `true` when using the default Capgo backend or when the feature is available.\n *\n * This is different from {@link isAutoUpdateEnabled}:\n * - `isAutoUpdateEnabled()`: Checks if auto-update MODE is turned on/off\n * - `isAutoUpdateAvailable()`: Checks if auto-update is SUPPORTED with your current configuration\n *\n * @returns {Promise<AutoUpdateAvailable>} `false` when custom updateUrl is set, `true` otherwise.\n * @throws {Error} If the operation fails.\n */\n isAutoUpdateAvailable(): Promise<AutoUpdateAvailable>;\n\n /**\n * Get information about the bundle queued to be activated on next reload.\n *\n * Returns:\n * - {@link BundleInfo} object if a bundle has been queued via {@link next}\n * - `null` if no update is pending\n *\n * This is useful to:\n * - Check if an update is waiting to be applied\n * - Display \"Update pending\" status to users\n * - Show version info of the queued update\n * - Decide whether to show a \"Restart to update\" prompt\n *\n * The queued bundle will be activated when:\n * - The app is backgrounded (default behavior)\n * - The app is killed and restarted\n * - {@link reload} is called manually\n * - Delay conditions set by {@link setMultiDelay} are met\n *\n * @returns {Promise<BundleInfo | null>} The pending bundle info, or `null` if none is queued.\n * @throws {Error} If the operation fails.\n * @since 6.8.0\n */\n getNextBundle(): Promise<BundleInfo | null>;\n\n /**\n * Retrieve information about the most recent bundle that failed to load.\n *\n * When a bundle fails to load (e.g., JavaScript errors prevent initialization, missing files),\n * the plugin automatically rolls back and stores information about the failure. This method\n * retrieves that failure information.\n *\n * **IMPORTANT: The stored value is cleared after being retrieved once.**\n * Calling this method multiple times will only return the failure info on the first call,\n * then `null` on subsequent calls until another failure occurs.\n *\n * Returns:\n * - {@link UpdateFailedEvent} with bundle info if a failure was recorded\n * - `null` if no failure has occurred or if it was already retrieved\n *\n * Use this to:\n * - Show users why an update failed\n * - Log failure information for debugging\n * - Implement custom error handling/reporting\n * - Display rollback notifications\n *\n * @returns {Promise<UpdateFailedEvent | null>} The failed update info (cleared after first retrieval), or `null`.\n * @throws {Error} If the operation fails.\n * @since 7.22.0\n */\n getFailedUpdate(): Promise<UpdateFailedEvent | null>;\n\n /**\n * Enable or disable the shake gesture menu for debugging and testing.\n *\n * When enabled, users can shake their device to open a debug menu that shows:\n * - Current bundle information\n * - Available bundles\n * - Options to switch bundles manually\n * - Update status\n *\n * This is useful during development and testing to:\n * - Quickly test different bundle versions\n * - Debug update flows\n * - Switch between production and test bundles\n * - Verify bundle installations\n *\n * **Important:** Disable this in production builds or only enable for internal testers.\n *\n * Can also be configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.\n *\n * @param options {@link SetShakeMenuOptions} with `enabled: true` to enable or `enabled: false` to disable.\n * @returns {Promise<void>} Resolves when the setting is applied.\n * @throws {Error} If the operation fails.\n * @since 7.5.0\n */\n setShakeMenu(options: SetShakeMenuOptions): Promise<void>;\n\n /**\n * Check if the shake gesture debug menu is currently enabled.\n *\n * Returns the current state of the shake menu feature that can be toggled via\n * {@link setShakeMenu} or configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.\n *\n * Use this to:\n * - Check if debug features are enabled\n * - Show/hide debug settings UI\n * - Verify configuration during testing\n *\n * @returns {Promise<ShakeMenuEnabled>} Object with `enabled: true` or `enabled: false`.\n * @throws {Error} If the operation fails.\n * @since 7.5.0\n */\n isShakeMenuEnabled(): Promise<ShakeMenuEnabled>;\n\n /**\n * Enable or disable the shake channel selector at runtime.\n *\n * When enabled AND shakeMenu is true, shaking the device shows a channel\n * selector instead of the debug menu. This allows users to switch between\n * update channels by shaking their device.\n *\n * After selecting a channel, the app automatically checks for updates\n * and downloads if available.\n *\n * Can also be configured via {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}.\n *\n * @param options {@link SetShakeChannelSelectorOptions} with `enabled: true` to enable or `enabled: false` to disable.\n * @returns {Promise<void>} Resolves when the setting is applied.\n * @throws {Error} If the operation fails.\n * @since 8.43.0\n */\n setShakeChannelSelector(options: SetShakeChannelSelectorOptions): Promise<void>;\n\n /**\n * Check if the shake channel selector is currently enabled.\n *\n * Returns the current state of the shake channel selector feature that can be toggled via\n * {@link setShakeChannelSelector} or configured via {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}.\n *\n * @returns {Promise<ShakeChannelSelectorEnabled>} Object with `enabled: true` or `enabled: false`.\n * @throws {Error} If the operation fails.\n * @since 8.43.0\n */\n isShakeChannelSelectorEnabled(): Promise<ShakeChannelSelectorEnabled>;\n\n /**\n * Get the currently configured App ID used for update server communication.\n *\n * Returns the App ID that identifies this app to the update server. This can be:\n * - The value set via {@link setAppId}, or\n * - The {@link PluginsConfig.CapacitorUpdater.appId} config value, or\n * - The default app identifier from your native app configuration\n *\n * Use this to:\n * - Verify which App ID is being used for updates\n * - Debug update delivery issues\n * - Display app configuration in debug screens\n * - Confirm App ID after calling {@link setAppId}\n *\n * @returns {Promise<GetAppIdRes>} Object containing the current `appId` string.\n * @throws {Error} If the operation fails.\n * @since 7.14.0\n */\n getAppId(): Promise<GetAppIdRes>;\n\n /**\n * Dynamically change the App ID used for update server communication.\n *\n * This overrides the App ID used to identify your app to the update server, allowing you\n * to switch between different app configurations at runtime (e.g., production vs staging\n * app IDs, or multi-tenant configurations).\n *\n * **Requirements:**\n * - {@link PluginsConfig.CapacitorUpdater.allowModifyAppId} must be set to `true`\n *\n * **Important considerations:**\n * - Changing the App ID will affect which updates this device receives\n * - The new App ID must exist on your update server\n * - This is primarily for advanced use cases (multi-tenancy, environment switching)\n * - Most apps should use the config-based {@link PluginsConfig.CapacitorUpdater.appId} instead\n *\n * @param options {@link SetAppIdOptions} containing the new App ID string.\n * @returns {Promise<void>} Resolves when the App ID is successfully changed.\n * @throws {Error} If `allowModifyAppId` is false or the operation fails.\n * @since 7.14.0\n */\n setAppId(options: SetAppIdOptions): Promise<void>;\n\n // ============================================================================\n // App Store / Play Store Update Methods\n // ============================================================================\n\n /**\n * Get information about the app's availability in the App Store or Play Store.\n *\n * This method checks the native app stores to see if a newer version of the app\n * is available for download. This is different from Capgo's OTA updates - this\n * checks for native app updates that require going through the app stores.\n *\n * **Platform differences:**\n * - **Android**: Uses Play Store's In-App Updates API for accurate update information\n * - **iOS**: Queries the App Store lookup API (requires country code for accurate results)\n *\n * **Returns information about:**\n * - Current installed version\n * - Available version in the store (if any)\n * - Whether an update is available\n * - Update priority (Android only)\n * - Whether immediate/flexible updates are allowed (Android only)\n *\n * Use this to:\n * - Check if users need to update from the app store\n * - Show \"Update Available\" prompts for native updates\n * - Implement version gating (require minimum native version)\n * - Combine with Capgo OTA updates for a complete update strategy\n *\n * @param options Optional {@link GetAppUpdateInfoOptions} with country code for iOS.\n * @returns {Promise<AppUpdateInfo>} Information about the current and available app versions.\n * @throws {Error} If the operation fails or store information is unavailable.\n * @since 8.0.0\n */\n getAppUpdateInfo(options?: GetAppUpdateInfoOptions): Promise<AppUpdateInfo>;\n\n /**\n * Open the app's page in the App Store or Play Store.\n *\n * This navigates the user to your app's store listing where they can manually\n * update the app. Use this as a fallback when in-app updates are not available\n * or when the user needs to update on iOS.\n *\n * **Platform behavior:**\n * - **Android**: Opens Play Store to the app's page\n * - **iOS**: Opens App Store to the app's page\n *\n * **Customization options:**\n * - `appId`: Specify a custom App Store ID (iOS) - useful for opening a different app's page\n * - `packageName`: Specify a custom package name (Android) - useful for opening a different app's page\n *\n * @param options Optional {@link OpenAppStoreOptions} to customize which app's store page to open.\n * @returns {Promise<void>} Resolves when the store is opened.\n * @throws {Error} If the store cannot be opened.\n * @since 8.0.0\n */\n openAppStore(options?: OpenAppStoreOptions): Promise<void>;\n\n /**\n * Perform an immediate in-app update on Android.\n *\n * This triggers Google Play's immediate update flow, which:\n * 1. Shows a full-screen update UI\n * 2. Downloads and installs the update\n * 3. Restarts the app automatically\n *\n * The user cannot continue using the app until the update is complete.\n * This is ideal for critical updates that must be installed immediately.\n *\n * **Requirements:**\n * - Android only (throws error on iOS)\n * - An update must be available (check with {@link getAppUpdateInfo} first)\n * - The update must allow immediate updates (`immediateUpdateAllowed: true`)\n *\n * **User experience:**\n * - Full-screen blocking UI\n * - Progress shown during download\n * - App automatically restarts after installation\n *\n * @returns {Promise<AppUpdateResult>} Result indicating success, cancellation, or failure.\n * @throws {Error} If not on Android, no update is available, or immediate updates not allowed.\n * @since 8.0.0\n */\n performImmediateUpdate(): Promise<AppUpdateResult>;\n\n /**\n * Start a flexible in-app update on Android.\n *\n * This triggers Google Play's flexible update flow, which:\n * 1. Downloads the update in the background\n * 2. Allows the user to continue using the app\n * 3. Notifies when download is complete\n * 4. Requires calling {@link completeFlexibleUpdate} to install\n *\n * Monitor the download progress using the `onFlexibleUpdateStateChange` listener.\n *\n * **Requirements:**\n * - Android only (throws error on iOS)\n * - An update must be available (check with {@link getAppUpdateInfo} first)\n * - The update must allow flexible updates (`flexibleUpdateAllowed: true`)\n *\n * **Typical flow:**\n * 1. Call `startFlexibleUpdate()` to begin download\n * 2. Listen to `onFlexibleUpdateStateChange` for progress\n * 3. When status is `DOWNLOADED`, prompt user to restart\n * 4. Call `completeFlexibleUpdate()` to install and restart\n *\n * @returns {Promise<AppUpdateResult>} Result indicating the update was started, cancelled, or failed.\n * @throws {Error} If not on Android, no update is available, or flexible updates not allowed.\n * @since 8.0.0\n */\n startFlexibleUpdate(): Promise<AppUpdateResult>;\n\n /**\n * Complete a flexible in-app update on Android.\n *\n * After a flexible update has been downloaded (status `DOWNLOADED` in\n * `onFlexibleUpdateStateChange`), call this method to install the update\n * and restart the app.\n *\n * **Important:** This will immediately restart the app. Make sure to:\n * - Save any user data before calling\n * - Prompt the user before restarting\n * - Only call when the download status is `DOWNLOADED`\n *\n * @returns {Promise<void>} Resolves when the update installation begins (app will restart).\n * @throws {Error} If not on Android or no downloaded update is pending.\n * @since 8.0.0\n */\n completeFlexibleUpdate(): Promise<void>;\n}\n\n/**\n * pending: The bundle is pending to be **SET** as the next bundle.\n * downloading: The bundle is being downloaded.\n * success: The bundle has been downloaded and is ready to be **SET** as the next bundle.\n * error: The bundle has failed to download.\n */\nexport type BundleStatus = 'success' | 'error' | 'pending' | 'downloading';\n\nexport type DelayUntilNext = 'background' | 'kill' | 'nativeVersion' | 'date';\n\nexport interface NoNeedEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface UpdateAvailableEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface ChannelRes {\n /**\n * Current status of set channel\n *\n * @since 4.7.0\n */\n status: string;\n error?: string;\n message?: string;\n}\n\nexport interface GetChannelRes {\n /**\n * Current status of get channel\n *\n * @since 4.8.0\n */\n channel?: string;\n error?: string;\n message?: string;\n status?: string;\n allowSet?: boolean;\n}\n\nexport interface ChannelInfo {\n /**\n * The channel ID\n *\n * @since 7.5.0\n */\n id: string;\n /**\n * The channel name\n *\n * @since 7.5.0\n */\n name: string;\n /**\n * Whether this is a public channel\n *\n * @since 7.5.0\n */\n public: boolean;\n /**\n * Whether devices can self-assign to this channel\n *\n * @since 7.5.0\n */\n allow_self_set: boolean;\n}\n\nexport interface ListChannelsResult {\n /**\n * List of available channels\n *\n * @since 7.5.0\n */\n channels: ChannelInfo[];\n}\n\nexport interface DownloadEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n percent: number;\n bundle: BundleInfo;\n}\n\nexport interface MajorAvailableEvent {\n /**\n * Emit when a breaking update is available.\n *\n * @deprecated Deprecated alias for {@link BreakingAvailableEvent}. Receives the same payload.\n * @since 4.0.0\n */\n version: string;\n}\n\n/**\n * Payload emitted by {@link CapacitorUpdaterPlugin.addListener} with `breakingAvailable`.\n *\n * @since 7.22.0\n */\nexport type BreakingAvailableEvent = MajorAvailableEvent;\n\nexport interface DownloadFailedEvent {\n /**\n * Emit when a download fail.\n *\n * @since 4.0.0\n */\n version: string;\n}\n\nexport interface DownloadCompleteEvent {\n /**\n * Emit when a new update is available.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface UpdateFailedEvent {\n /**\n * Emit when a update failed to install.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface SetEvent {\n /**\n * Emit when a bundle has been applied successfully.\n * This event uses native `retainUntilConsumed` behavior.\n *\n * @since 8.43.12\n */\n bundle: BundleInfo;\n}\n\nexport interface SetNextEvent {\n /**\n * Emit when a bundle is queued as the next bundle to install.\n *\n * @since 6.14.0\n */\n bundle: BundleInfo;\n}\n\nexport interface AppReadyEvent {\n /**\n * Emitted when the app is ready to use.\n * This event uses native `retainUntilConsumed` behavior.\n *\n * @since 5.2.0\n */\n bundle: BundleInfo;\n status: string;\n}\n\nexport interface ChannelPrivateEvent {\n /**\n * Emitted when attempting to set a channel that doesn't allow device self-assignment.\n *\n * @since 7.34.0\n */\n channel: string;\n message: string;\n}\n\nexport interface ManifestEntry {\n file_name: string | null;\n file_hash: string | null;\n download_url: string | null;\n}\n\nexport interface LatestVersion {\n /**\n * Result of getLatest method\n *\n * @since 4.0.0\n */\n version: string;\n /**\n * @since 6\n */\n checksum?: string;\n /**\n * Indicates whether the update was flagged as breaking by the backend.\n *\n * @since 7.22.0\n */\n breaking?: boolean;\n /**\n * @deprecated Use {@link LatestVersion.breaking} instead.\n */\n major?: boolean;\n /**\n * Optional message from the server.\n * When no new version is available, this will be \"No new version available\".\n */\n message?: string;\n sessionKey?: string;\n /**\n * Error code from the server, if any.\n * Common values:\n * - `\"no_new_version_available\"`: Device is already on the latest version (not a failure)\n * - Other error codes indicate actual failures in the update process\n */\n error?: string;\n /**\n * The previous/current version name (provided for reference).\n */\n old?: string;\n /**\n * Download URL for the bundle (when a new version is available).\n */\n url?: string;\n /**\n * File list for delta updates (when using multi-file downloads).\n * @since 6.1\n */\n manifest?: ManifestEntry[];\n /**\n * Optional link associated with this bundle version (e.g., release notes URL, changelog, GitHub release).\n * @since 7.35.0\n */\n link?: string;\n /**\n * Optional comment or description for this bundle version.\n * @since 7.35.0\n */\n comment?: string;\n}\n\nexport interface BundleInfo {\n id: string;\n version: string;\n downloaded: string;\n checksum: string;\n status: BundleStatus;\n}\n\nexport interface SetChannelOptions {\n channel: string;\n triggerAutoUpdate?: boolean;\n}\n\nexport interface UnsetChannelOptions {\n triggerAutoUpdate?: boolean;\n}\n\nexport interface SetCustomIdOptions {\n /**\n * Custom identifier to associate with the device. Use an empty string to clear any saved value.\n */\n customId: string;\n}\n\nexport interface DelayCondition {\n /**\n * Set up delay conditions in setMultiDelay\n * @param value is useless for @param kind \"kill\", optional for \"background\" (default value: \"0\") and required for \"nativeVersion\" and \"date\"\n */\n kind: DelayUntilNext;\n value?: string;\n}\n\nexport interface GetLatestOptions {\n /**\n * The channel to get the latest version for\n * The channel must allow 'self_assign' for this to work\n * @since 6.8.0\n * @default undefined\n */\n channel?: string;\n}\n\nexport interface AppReadyResult {\n bundle: BundleInfo;\n}\n\nexport interface UpdateUrl {\n url: string;\n}\n\nexport interface StatsUrl {\n url: string;\n}\n\nexport interface ChannelUrl {\n url: string;\n}\n\n/**\n * This URL and versions are used to download the bundle from the server, If you use backend all information will be given by the method getLatest.\n * If you don't use backend, you need to provide the URL and version of the bundle. Checksum and sessionKey are required if you encrypted the bundle with the CLI command encrypt, you should receive them as result of the command.\n */\nexport interface DownloadOptions {\n /**\n * The URL of the bundle zip file (e.g: dist.zip) to be downloaded. (This can be any URL. E.g: Amazon S3, a GitHub tag, any other place you've hosted your bundle.)\n */\n url: string;\n /**\n * The version code/name of this bundle/version\n */\n version: string;\n /**\n * The session key for the update, when the bundle is encrypted with a session key\n * @since 4.0.0\n * @default undefined\n */\n sessionKey?: string;\n /**\n * The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted\n * @since 4.0.0\n * @default undefined\n */\n checksum?: string;\n /**\n * The manifest for multi-file downloads\n * @since 6.1.0\n * @default undefined\n */\n manifest?: ManifestEntry[];\n}\n\nexport interface BundleId {\n id: string;\n}\n\nexport interface BundleListResult {\n bundles: BundleInfo[];\n}\n\nexport interface ResetOptions {\n toLastSuccessful: boolean;\n}\n\nexport interface ListOptions {\n /**\n * Whether to return the raw bundle list or the manifest. If true, the list will attempt to read the internal database instead of files on disk.\n * @since 6.14.0\n * @default false\n */\n raw?: boolean;\n}\n\nexport interface CurrentBundleResult {\n bundle: BundleInfo;\n native: string;\n}\n\nexport interface MultiDelayConditions {\n delayConditions: DelayCondition[];\n}\n\nexport interface BuiltinVersion {\n version: string;\n}\n\nexport interface DeviceId {\n deviceId: string;\n}\n\nexport interface PluginVersion {\n version: string;\n}\n\nexport interface AutoUpdateEnabled {\n enabled: boolean;\n}\n\nexport interface AutoUpdateAvailable {\n available: boolean;\n}\n\nexport interface SetShakeMenuOptions {\n enabled: boolean;\n}\n\nexport interface ShakeMenuEnabled {\n enabled: boolean;\n}\n\nexport interface SetShakeChannelSelectorOptions {\n enabled: boolean;\n}\n\nexport interface ShakeChannelSelectorEnabled {\n enabled: boolean;\n}\n\nexport interface GetAppIdRes {\n appId: string;\n}\n\nexport interface SetAppIdOptions {\n appId: string;\n}\n\n// ============================================================================\n// App Store / Play Store Update Types\n// ============================================================================\n\n/**\n * Options for {@link CapacitorUpdaterPlugin.getAppUpdateInfo}.\n *\n * @since 8.0.0\n */\nexport interface GetAppUpdateInfoOptions {\n /**\n * Two-letter country code (ISO 3166-1 alpha-2) for the App Store lookup.\n *\n * This is required on iOS to get accurate App Store information, as app\n * availability and versions can vary by country.\n *\n * Examples: \"US\", \"GB\", \"DE\", \"JP\", \"FR\"\n *\n * On Android, this option is ignored as the Play Store handles region\n * detection automatically.\n *\n * @since 8.0.0\n */\n country?: string;\n}\n\n/**\n * Information about app updates available in the App Store or Play Store.\n *\n * @since 8.0.0\n */\nexport interface AppUpdateInfo {\n /**\n * The currently installed version name (e.g., \"1.2.3\").\n *\n * @since 8.0.0\n */\n currentVersionName: string;\n\n /**\n * The version name available in the store, if an update is available.\n * May be undefined if no update information is available.\n *\n * @since 8.0.0\n */\n availableVersionName?: string;\n\n /**\n * The currently installed version code (Android) or build number (iOS).\n *\n * @since 8.0.0\n */\n currentVersionCode: string;\n\n /**\n * The version code available in the store (Android only).\n * On iOS, this will be the same as `availableVersionName`.\n *\n * @since 8.0.0\n */\n availableVersionCode?: string;\n\n /**\n * The release date of the available version (iOS only).\n * Format: ISO 8601 date string.\n *\n * @since 8.0.0\n */\n availableVersionReleaseDate?: string;\n\n /**\n * The current update availability status.\n *\n * @since 8.0.0\n */\n updateAvailability: AppUpdateAvailability;\n\n /**\n * The priority of the update as set by the developer in Play Console (Android only).\n * Values range from 0 (default/lowest) to 5 (highest priority).\n *\n * Use this to decide whether to show an update prompt or force an update.\n *\n * @since 8.0.0\n */\n updatePriority?: number;\n\n /**\n * Whether an immediate update is allowed (Android only).\n *\n * If `true`, you can call {@link CapacitorUpdaterPlugin.performImmediateUpdate}.\n *\n * @since 8.0.0\n */\n immediateUpdateAllowed?: boolean;\n\n /**\n * Whether a flexible update is allowed (Android only).\n *\n * If `true`, you can call {@link CapacitorUpdaterPlugin.startFlexibleUpdate}.\n *\n * @since 8.0.0\n */\n flexibleUpdateAllowed?: boolean;\n\n /**\n * Number of days since the update became available (Android only).\n *\n * Use this to implement \"update nagging\" - remind users more frequently\n * as the update ages.\n *\n * @since 8.0.0\n */\n clientVersionStalenessDays?: number;\n\n /**\n * The current install status of a flexible update (Android only).\n *\n * @since 8.0.0\n */\n installStatus?: FlexibleUpdateInstallStatus;\n\n /**\n * The minimum OS version required for the available update (iOS only).\n *\n * @since 8.0.0\n */\n minimumOsVersion?: string;\n}\n\n/**\n * Options for {@link CapacitorUpdaterPlugin.openAppStore}.\n *\n * @since 8.0.0\n */\nexport interface OpenAppStoreOptions {\n /**\n * The Android package name to open in the Play Store.\n *\n * If not specified, uses the current app's package name.\n * Use this to open a different app's store page.\n *\n * Only used on Android.\n *\n * @since 8.0.0\n */\n packageName?: string;\n\n /**\n * The iOS App Store ID to open.\n *\n * If not specified, uses the current app's bundle identifier to look up the app.\n * Use this to open a different app's store page or when automatic lookup fails.\n *\n * Only used on iOS.\n *\n * @since 8.0.0\n */\n appId?: string;\n}\n\n/**\n * State information for flexible update progress (Android only).\n *\n * @since 8.0.0\n */\nexport interface FlexibleUpdateState {\n /**\n * The current installation status.\n *\n * @since 8.0.0\n */\n installStatus: FlexibleUpdateInstallStatus;\n\n /**\n * Number of bytes downloaded so far.\n * Only available during the `DOWNLOADING` status.\n *\n * @since 8.0.0\n */\n bytesDownloaded?: number;\n\n /**\n * Total number of bytes to download.\n * Only available during the `DOWNLOADING` status.\n *\n * @since 8.0.0\n */\n totalBytesToDownload?: number;\n}\n\n/**\n * Result of an app update operation.\n *\n * @since 8.0.0\n */\nexport interface AppUpdateResult {\n /**\n * The result code of the update operation.\n *\n * @since 8.0.0\n */\n code: AppUpdateResultCode;\n}\n\n/**\n * Update availability status.\n *\n * @since 8.0.0\n */\nexport enum AppUpdateAvailability {\n /**\n * Update availability is unknown.\n * This typically means the check hasn't completed or failed.\n */\n UNKNOWN = 0,\n\n /**\n * No update is available.\n * The installed version is the latest.\n */\n UPDATE_NOT_AVAILABLE = 1,\n\n /**\n * An update is available for download.\n */\n UPDATE_AVAILABLE = 2,\n\n /**\n * An update is currently being downloaded or installed.\n */\n UPDATE_IN_PROGRESS = 3,\n}\n\n/**\n * Installation status for flexible updates (Android only).\n *\n * @since 8.0.0\n */\nexport enum FlexibleUpdateInstallStatus {\n /**\n * Unknown install status.\n */\n UNKNOWN = 0,\n\n /**\n * Download is pending and will start soon.\n */\n PENDING = 1,\n\n /**\n * Download is in progress.\n * Check `bytesDownloaded` and `totalBytesToDownload` for progress.\n */\n DOWNLOADING = 2,\n\n /**\n * The update is being installed.\n */\n INSTALLING = 3,\n\n /**\n * The update has been installed.\n * The app needs to be restarted to use the new version.\n */\n INSTALLED = 4,\n\n /**\n * The update failed to download or install.\n */\n FAILED = 5,\n\n /**\n * The update was canceled by the user.\n */\n CANCELED = 6,\n\n /**\n * The update has been downloaded and is ready to install.\n * Call {@link CapacitorUpdaterPlugin.completeFlexibleUpdate} to install.\n */\n DOWNLOADED = 11,\n}\n\n/**\n * Result codes for app update operations.\n *\n * @since 8.0.0\n */\nexport enum AppUpdateResultCode {\n /**\n * The update completed successfully.\n */\n OK = 0,\n\n /**\n * The user canceled the update.\n */\n CANCELED = 1,\n\n /**\n * The update failed.\n */\n FAILED = 2,\n\n /**\n * No update is available.\n */\n NOT_AVAILABLE = 3,\n\n /**\n * The requested update type is not allowed.\n * For example, trying to perform an immediate update when only flexible is allowed.\n */\n NOT_ALLOWED = 4,\n\n /**\n * Required information is missing.\n * This can happen if {@link CapacitorUpdaterPlugin.getAppUpdateInfo} wasn't called first.\n */\n INFO_MISSING = 5,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwkEH;;;;GAIG;AACH,MAAM,CAAN,IAAY,qBAsBX;AAtBD,WAAY,qBAAqB;IAC/B;;;OAGG;IACH,uEAAW,CAAA;IAEX;;;OAGG;IACH,iGAAwB,CAAA;IAExB;;OAEG;IACH,yFAAoB,CAAA;IAEpB;;OAEG;IACH,6FAAsB,CAAA;AACxB,CAAC,EAtBW,qBAAqB,KAArB,qBAAqB,QAsBhC;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,2BA2CX;AA3CD,WAAY,2BAA2B;IACrC;;OAEG;IACH,mFAAW,CAAA;IAEX;;OAEG;IACH,mFAAW,CAAA;IAEX;;;OAGG;IACH,2FAAe,CAAA;IAEf;;OAEG;IACH,yFAAc,CAAA;IAEd;;;OAGG;IACH,uFAAa,CAAA;IAEb;;OAEG;IACH,iFAAU,CAAA;IAEV;;OAEG;IACH,qFAAY,CAAA;IAEZ;;;OAGG;IACH,0FAAe,CAAA;AACjB,CAAC,EA3CW,2BAA2B,KAA3B,2BAA2B,QA2CtC;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,mBAgCX;AAhCD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,yDAAM,CAAA;IAEN;;OAEG;IACH,qEAAY,CAAA;IAEZ;;OAEG;IACH,iEAAU,CAAA;IAEV;;OAEG;IACH,+EAAiB,CAAA;IAEjB;;;OAGG;IACH,2EAAe,CAAA;IAEf;;;OAGG;IACH,6EAAgB,CAAA;AAClB,CAAC,EAhCW,mBAAmB,KAAnB,mBAAmB,QAgC9B","sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\n\n/// <reference types=\"@capacitor/cli\" />\nimport type { PluginListenerHandle } from '@capacitor/core';\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * CapacitorUpdater can be configured with these options:\n */\n CapacitorUpdater?: {\n /**\n * Configure the number of milliseconds the native plugin should wait before considering an update 'failed'.\n *\n * Only available for Android and iOS.\n *\n * @default 10000 // (10 seconds)\n * @example 1000 // (1 second, minimum 1000)\n */\n appReadyTimeout?: number;\n\n /**\n * Configure the number of seconds the native plugin should wait before considering API timeout.\n *\n * Only available for Android and iOS.\n *\n * @default 20 // (20 second)\n * @example 10 // (10 second)\n */\n responseTimeout?: number;\n\n /**\n * Configure whether the plugin should use automatically delete failed bundles.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoDeleteFailed?: boolean;\n\n /**\n * Configure whether the plugin should use automatically delete previous bundles after a successful update.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoDeletePrevious?: boolean;\n\n /**\n * Configure whether the plugin should use Auto Update via an update server.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n autoUpdate?: boolean;\n\n /**\n * Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device.\n * Setting this to false can broke the auto update flow if the user download from the store a native app bundle that is older than the current downloaded bundle. Upload will be prevented by channel setting downgrade_under_native.\n * Only available for Android and iOS.\n *\n * @default true\n * @example false\n */\n resetWhenUpdate?: boolean;\n\n /**\n * Configure the URL / endpoint to which update checks are sent.\n *\n * Only available for Android and iOS.\n *\n * @default https://plugin.capgo.app/updates\n * @example https://example.com/api/auto_update\n */\n updateUrl?: string;\n\n /**\n * Configure the URL / endpoint for channel operations.\n *\n * Only available for Android and iOS.\n *\n * @default https://plugin.capgo.app/channel_self\n * @example https://example.com/api/channel\n */\n channelUrl?: string;\n\n /**\n * Configure the URL / endpoint to which update statistics are sent.\n *\n * Only available for Android and iOS. Set to \"\" to disable stats reporting.\n *\n * @default https://plugin.capgo.app/stats\n * @example https://example.com/api/stats\n */\n statsUrl?: string;\n\n /**\n * Configure the public key for end to end live update encryption Version 2\n *\n * Only available for Android and iOS.\n *\n * @default undefined\n * @since 6.2.0\n */\n publicKey?: string;\n\n /**\n * Configure the current version of the app. This will be used for the first update request.\n * If not set, the plugin will get the version from the native code.\n *\n * Only available for Android and iOS.\n *\n * @default undefined\n * @since 4.17.48\n */\n version?: string;\n\n /**\n * Configure when the plugin should direct install updates. Only for autoUpdate mode.\n * Works well for apps less than 10MB and with uploads done using --delta flag.\n * Zip or apps more than 10MB will be relatively slow for users to update.\n * - false: Never do direct updates (use default behavior: download at start, set when backgrounded)\n * - atInstall: Direct update only when app is installed, updated from store, otherwise act as directUpdate = false\n * - onLaunch: Direct update only on app installed, updated from store or after app kill, otherwise act as directUpdate = false\n * - always: Direct update in all previous cases (app installed, updated from store, after app kill or app resume), never act as directUpdate = false\n * - true: (deprecated) Same as \"always\" for backward compatibility\n *\n * Activate this flag will automatically make the CLI upload delta in CICD envs and will ask for confirmation in local uploads.\n * Only available for Android and iOS.\n *\n * @default false\n * @since 5.1.0\n */\n directUpdate?: boolean | 'atInstall' | 'always' | 'onLaunch';\n\n /**\n * Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed.\n * This removes the need to manually listen for appReady events and call SplashScreen.hide().\n * Only works when directUpdate is set to \"atInstall\", \"always\", \"onLaunch\", or true.\n * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\n * Requires autoUpdate and directUpdate to be enabled.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.6.0\n */\n autoSplashscreen?: boolean;\n\n /**\n * Display a native loading indicator on top of the splashscreen while automatic direct updates are running.\n * Only takes effect when {@link autoSplashscreen} is enabled.\n * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.19.0\n */\n autoSplashscreenLoader?: boolean;\n\n /**\n * Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates.\n * If the timeout elapses, the update continues to download in the background while the splashscreen is dismissed.\n * Set to `0` (zero) to disable the timeout.\n * When the timeout fires, the direct update flow is skipped and the downloaded bundle is installed on the next background/launch.\n * Requires {@link autoSplashscreen} to be enabled.\n *\n * Only available for Android and iOS.\n *\n * @default 10000 // (10 seconds)\n * @since 7.19.0\n */\n autoSplashscreenTimeout?: number;\n\n /**\n * Configure the delay period for period update check. the unit is in seconds.\n *\n * Only available for Android and iOS.\n * Cannot be less than 600 seconds (10 minutes).\n *\n * @default 0 (disabled)\n * @example 3600 (1 hour)\n * @example 86400 (24 hours)\n */\n periodCheckDelay?: number;\n\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localS3?: boolean;\n\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localHost?: string;\n\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localWebHost?: string;\n\n /**\n * Configure the CLI to use a local server for testing or self-hosted update server.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localSupa?: string;\n\n /**\n * Configure the CLI to use a local server for testing.\n *\n *\n * @default undefined\n * @since 4.17.48\n */\n localSupaAnon?: string;\n\n /**\n * Configure the CLI to use a local api for testing.\n *\n *\n * @default undefined\n * @since 6.3.3\n */\n localApi?: string;\n\n /**\n * Configure the CLI to use a local file api for testing.\n *\n *\n * @default undefined\n * @since 6.3.3\n */\n localApiFiles?: string;\n /**\n * Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side.\n *\n *\n * @default false\n * @since 5.4.0\n */\n allowModifyUrl?: boolean;\n\n /**\n * Allow the plugin to modify the appId dynamically from the JavaScript side.\n *\n *\n * @default false\n * @since 7.14.0\n */\n allowModifyAppId?: boolean;\n\n /**\n * Allow marking bundles as errored from JavaScript while using manual update flows.\n * When enabled, {@link CapacitorUpdaterPlugin.setBundleError} can change a bundle status to `error`.\n *\n * @default false\n * @since 7.20.0\n */\n allowManualBundleError?: boolean;\n\n /**\n * Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts.\n *\n * Only available for Android and iOS.\n *\n * @default false (will be true by default in a future major release v8.x.x)\n * @since 7.17.3\n */\n persistCustomId?: boolean;\n\n /**\n * Persist the updateUrl, statsUrl and channelUrl set through {@link CapacitorUpdaterPlugin.setUpdateUrl},\n * {@link CapacitorUpdaterPlugin.setStatsUrl} and {@link CapacitorUpdaterPlugin.setChannelUrl} across app restarts.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 7.20.0\n */\n persistModifyUrl?: boolean;\n\n /**\n * Allow or disallow the {@link CapacitorUpdaterPlugin.setChannel} method to modify the defaultChannel.\n * When set to `false`, calling `setChannel()` will return an error with code `disabled_by_config`.\n *\n * @default true\n * @since 7.34.0\n */\n allowSetDefaultChannel?: boolean;\n\n /**\n * Set the default channel for the app in the config. Case sensitive.\n * This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud.\n * This requires the channel to allow devices to self dissociate/associate in the channel settings. https://capgo.app/docs/public-api/channels/#channel-configuration-options\n *\n *\n * @default undefined\n * @since 5.5.0\n */\n defaultChannel?: string;\n /**\n * Configure the app id for the app in the config.\n *\n * @default undefined\n * @since 6.0.0\n */\n appId?: string;\n\n /**\n * Configure the plugin to keep the URL path after a reload.\n * WARNING: When a reload is triggered, 'window.history' will be cleared.\n *\n * @default false\n * @since 6.8.0\n */\n keepUrlPathAfterReload?: boolean;\n\n /**\n * Disable the JavaScript logging of the plugin. if true, the plugin will not log to the JavaScript console. only the native log will be done\n *\n * @default false\n * @since 7.3.0\n */\n disableJSLogging?: boolean;\n\n /**\n * Enable OS-level logging. When enabled, logs are written to the system log which can be inspected in production builds.\n *\n * - **iOS**: Uses os_log instead of Swift.print, logs accessible via Console.app or Instruments\n * - **Android**: Logs to Logcat (android.util.Log)\n *\n * When set to false, system logging is disabled on both platforms (only JavaScript console logging will occur if enabled).\n *\n * This is useful for debugging production apps (App Store/TestFlight builds on iOS, or production APKs on Android).\n *\n * @default true\n * @since 8.42.0\n */\n osLogging?: boolean;\n\n /**\n * Enable shake gesture to show update menu for debugging/testing purposes\n *\n * @default false\n * @since 7.5.0\n */\n shakeMenu?: boolean;\n\n /**\n * Enable the shake gesture to show a channel selector menu for switching between update channels.\n * When enabled AND `shakeMenu` is true, the shake gesture shows a channel selector\n * instead of the default debug menu (Go Home/Reload/Close).\n *\n * After selecting a channel, the app automatically checks for updates and downloads if available.\n * Only works if channels have `allow_self_set` enabled on the backend.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 8.43.0\n */\n allowShakeChannelSelector?: boolean;\n };\n }\n}\n\nexport interface CapacitorUpdaterPlugin {\n /**\n * Notify the native layer that JavaScript initialized successfully.\n *\n * **CRITICAL: You must call this method on every app launch to prevent automatic rollback.**\n *\n * This is a simple notification to confirm that your bundle's JavaScript loaded and executed.\n * The native web server successfully served the bundle files and your JS runtime started.\n * That's all it checks - nothing more complex.\n *\n * **What triggers rollback:**\n * - NOT calling this method within the timeout (default: 10 seconds)\n * - Complete JavaScript failure (bundle won't load at all)\n *\n * **What does NOT trigger rollback:**\n * - Runtime errors after initialization (API failures, crashes, etc.)\n * - Network request failures\n * - Application logic errors\n *\n * **IMPORTANT: Call this BEFORE any network requests.**\n * Don't wait for APIs, data loading, or async operations. Call it as soon as your\n * JavaScript bundle starts executing to confirm the bundle itself is valid.\n *\n * Best practices:\n * - Call immediately in your app entry point (main.js, app component mount, etc.)\n * - Don't put it after network calls or heavy initialization\n * - Don't wrap it in try/catch with conditions\n * - Adjust {@link PluginsConfig.CapacitorUpdater.appReadyTimeout} if you need more time\n *\n * @returns {Promise<AppReadyResult>} Always resolves successfully with current bundle info. This method never fails.\n */\n notifyAppReady(): Promise<AppReadyResult>;\n\n /**\n * Set the update URL for the app dynamically at runtime.\n *\n * This overrides the {@link PluginsConfig.CapacitorUpdater.updateUrl} config value.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.\n *\n * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.\n * Otherwise, the URL will reset to the config value on next app launch.\n *\n * @param options Contains the URL to use for checking for updates.\n * @returns {Promise<void>} Resolves when the URL is successfully updated.\n * @throws {Error} If `allowModifyUrl` is false or if the operation fails.\n * @since 5.4.0\n */\n setUpdateUrl(options: UpdateUrl): Promise<void>;\n\n /**\n * Set the statistics URL for the app dynamically at runtime.\n *\n * This overrides the {@link PluginsConfig.CapacitorUpdater.statsUrl} config value.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.\n *\n * Pass an empty string to disable statistics gathering entirely.\n * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.\n *\n * @param options Contains the URL to use for sending statistics, or an empty string to disable.\n * @returns {Promise<void>} Resolves when the URL is successfully updated.\n * @throws {Error} If `allowModifyUrl` is false or if the operation fails.\n * @since 5.4.0\n */\n setStatsUrl(options: StatsUrl): Promise<void>;\n\n /**\n * Set the channel URL for the app dynamically at runtime.\n *\n * This overrides the {@link PluginsConfig.CapacitorUpdater.channelUrl} config value.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowModifyUrl} to be set to `true`.\n *\n * Use {@link PluginsConfig.CapacitorUpdater.persistModifyUrl} to persist this value across app restarts.\n * Otherwise, the URL will reset to the config value on next app launch.\n *\n * @param options Contains the URL to use for channel operations.\n * @returns {Promise<void>} Resolves when the URL is successfully updated.\n * @throws {Error} If `allowModifyUrl` is false or if the operation fails.\n * @since 5.4.0\n */\n setChannelUrl(options: ChannelUrl): Promise<void>;\n\n /**\n * Download a new bundle from the provided URL for later installation.\n *\n * The downloaded bundle is stored locally but not activated. To use it:\n * - Call {@link next} to set it for installation on next app backgrounding/restart\n * - Call {@link set} to activate it immediately (destroys current JavaScript context)\n *\n * The URL should point to a zip file containing either:\n * - Your app files directly in the zip root, or\n * - A single folder containing all your app files\n *\n * The bundle must include an `index.html` file at the root level.\n *\n * For encrypted bundles, provide the `sessionKey` and `checksum` parameters.\n * For multi-file delta updates, provide the `manifest` array.\n *\n * @example\n * const bundle = await CapacitorUpdater.download({\n * url: `https://example.com/versions/${version}/dist.zip`,\n * version: version\n * });\n * // Bundle is downloaded but not active yet\n * await CapacitorUpdater.next({ id: bundle.id }); // Will activate on next background\n *\n * @param options The {@link DownloadOptions} for downloading a new bundle zip.\n * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the downloaded bundle.\n * @throws {Error} If the download fails or the bundle is invalid.\n */\n download(options: DownloadOptions): Promise<BundleInfo>;\n\n /**\n * Set the next bundle to be activated when the app backgrounds or restarts.\n *\n * This is the recommended way to apply updates as it doesn't interrupt the user's current session.\n * The bundle will be activated when:\n * - The app is backgrounded (user switches away), or\n * - The app is killed and relaunched, or\n * - {@link reload} is called manually\n *\n * Unlike {@link set}, this method does NOT destroy the current JavaScript context immediately.\n * Your app continues running normally until one of the above events occurs.\n *\n * Use {@link setMultiDelay} to add additional conditions before the update is applied.\n *\n * @param options Contains the ID of the bundle to set as next. Use {@link BundleInfo.id} from a downloaded bundle.\n * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified bundle.\n * @throws {Error} When there is no index.html file inside the bundle folder or the bundle doesn't exist.\n */\n next(options: BundleId): Promise<BundleInfo>;\n\n /**\n * Set the current bundle and immediately reloads the app.\n *\n * **IMPORTANT: This is a terminal operation that destroys the current JavaScript context.**\n *\n * When you call this method:\n * - The entire JavaScript context is immediately destroyed\n * - The app reloads from a different folder with different files\n * - NO code after this call will execute\n * - NO promises will resolve\n * - NO callbacks will fire\n * - Event listeners registered after this call are unreliable and may never fire\n *\n * The reload happens automatically - you don't need to do anything else.\n * If you need to preserve state like the current URL path, use the {@link PluginsConfig.CapacitorUpdater.keepUrlPathAfterReload} config option.\n * For other state preservation needs, save your data before calling this method (e.g., to localStorage).\n *\n * **Do not** try to execute additional logic after calling `set()` - it won't work as expected.\n *\n * @param options A {@link BundleId} object containing the new bundle id to set as current.\n * @returns {Promise<void>} A promise that will never resolve because the JavaScript context is destroyed.\n * @throws {Error} When there is no index.html file inside the bundle folder.\n */\n set(options: BundleId): Promise<void>;\n\n /**\n * Delete a bundle from local storage to free up disk space.\n *\n * You cannot delete:\n * - The currently active bundle\n * - The `builtin` bundle (the version shipped with your app)\n * - The bundle set as `next` (call {@link next} with a different bundle first)\n *\n * Use {@link list} to get all available bundle IDs.\n *\n * **Note:** The bundle ID is NOT the same as the version name.\n * Use the `id` field from {@link BundleInfo}, not the `version` field.\n *\n * @param options A {@link BundleId} object containing the bundle ID to delete.\n * @returns {Promise<void>} Resolves when the bundle is successfully deleted.\n * @throws {Error} If the bundle is currently in use or doesn't exist.\n */\n delete(options: BundleId): Promise<void>;\n\n /**\n * Manually mark a bundle as failed/errored in manual update mode.\n *\n * This is useful when you detect that a bundle has critical issues and want to prevent\n * it from being used again. The bundle status will be changed to `error` and the plugin\n * will avoid using this bundle in the future.\n *\n * **Requirements:**\n * - {@link PluginsConfig.CapacitorUpdater.allowManualBundleError} must be set to `true`\n * - Only works in manual update mode (when autoUpdate is disabled)\n *\n * Common use case: After downloading and testing a bundle, you discover it has critical\n * bugs and want to mark it as failed so it won't be retried.\n *\n * @param options A {@link BundleId} object containing the bundle ID to mark as errored.\n * @returns {Promise<BundleInfo>} The updated {@link BundleInfo} with status set to `error`.\n * @throws {Error} When the bundle does not exist or `allowManualBundleError` is false.\n * @since 7.20.0\n */\n setBundleError(options: BundleId): Promise<BundleInfo>;\n\n /**\n * Get all locally downloaded bundles stored in your app.\n *\n * This returns all bundles that have been downloaded and are available locally, including:\n * - The currently active bundle\n * - The `builtin` bundle (shipped with your app)\n * - Any downloaded bundles waiting to be activated\n * - Failed bundles (with `error` status)\n *\n * Use this to:\n * - Check available disk space by counting bundles\n * - Delete old bundles with {@link delete}\n * - Monitor bundle download status\n *\n * @param options The {@link ListOptions} for customizing the bundle list output.\n * @returns {Promise<BundleListResult>} A promise containing the array of {@link BundleInfo} objects.\n * @throws {Error} If the operation fails.\n */\n list(options?: ListOptions): Promise<BundleListResult>;\n\n /**\n * Reset the app to a known good bundle.\n *\n * This method helps recover from problematic updates by reverting to either:\n * - The `builtin` bundle (the original version shipped with your app to App Store/Play Store)\n * - The last successfully loaded bundle (most recent bundle that worked correctly)\n *\n * **IMPORTANT: This triggers an immediate app reload, destroying the current JavaScript context.**\n * See {@link set} for details on the implications of this operation.\n *\n * Use cases:\n * - Emergency recovery when an update causes critical issues\n * - Testing rollback functionality\n * - Providing users a \"reset to factory\" option\n *\n * @param options {@link ResetOptions} to control reset behavior.\n * If `toLastSuccessful` is `false` (or omitted), resets to builtin.\n * If `true`, resets to last successful bundle.\n * If `usePendingBundle` is `true`, applies the pending bundle set via {@link next} and clears it.\n * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.\n * @throws {Error} If the reset operation fails.\n */\n reset(options?: ResetOptions): Promise<void>;\n\n /**\n * Get information about the currently active bundle.\n *\n * Returns:\n * - `bundle`: The currently active bundle information\n * - `native`: The version of the builtin bundle (the original app version from App/Play Store)\n *\n * If no updates have been applied, `bundle.id` will be `\"builtin\"`, indicating the app\n * is running the original version shipped with the native app.\n *\n * Use this to:\n * - Display the current version to users\n * - Check if an update is currently active\n * - Compare against available updates\n * - Log the active bundle for debugging\n *\n * @returns {Promise<CurrentBundleResult>} A promise with the current bundle and native version info.\n * @throws {Error} If the operation fails.\n */\n current(): Promise<CurrentBundleResult>;\n\n /**\n * Manually reload the app to apply a pending update.\n *\n * This triggers the same reload behavior that happens automatically when the app backgrounds.\n * If you've called {@link next} to queue an update, calling `reload()` will apply it immediately.\n *\n * **IMPORTANT: This destroys the current JavaScript context immediately.**\n * See {@link set} for details on the implications of this operation.\n *\n * Common use cases:\n * - Applying an update immediately after download instead of waiting for backgrounding\n * - Providing a \"Restart now\" button to users after an update is ready\n * - Testing update flows during development\n *\n * If no update is pending (no call to {@link next}), this simply reloads the current bundle.\n *\n * @returns {Promise<void>} A promise that may never resolve because the app will be reloaded.\n * @throws {Error} If the reload operation fails.\n */\n reload(): Promise<void>;\n\n /**\n * Configure conditions that must be met before a pending update is applied.\n *\n * After calling {@link next} to queue an update, use this method to control when it gets applied.\n * The update will only be installed after ALL specified conditions are satisfied.\n *\n * Available condition types:\n * - `background`: Wait for the app to be backgrounded. Optionally specify duration in milliseconds.\n * - `kill`: Wait for the app to be killed and relaunched (**Note:** Current behavior triggers update immediately on kill, not on next background. This will be fixed in v8.)\n * - `date`: Wait until a specific date/time (ISO 8601 format)\n * - `nativeVersion`: Wait until the native app is updated to a specific version\n *\n * Condition value formats:\n * - `background`: Number in milliseconds (e.g., `\"300000\"` for 5 minutes), or omit for immediate\n * - `kill`: No value needed\n * - `date`: ISO 8601 date string (e.g., `\"2025-12-31T23:59:59Z\"`)\n * - `nativeVersion`: Version string (e.g., `\"2.0.0\"`)\n *\n * @example\n * // Update after user kills app OR after 5 minutes in background\n * await CapacitorUpdater.setMultiDelay({\n * delayConditions: [\n * { kind: 'kill' },\n * { kind: 'background', value: '300000' }\n * ]\n * });\n *\n * @example\n * // Update after a specific date\n * await CapacitorUpdater.setMultiDelay({\n * delayConditions: [{ kind: 'date', value: '2025-12-31T23:59:59Z' }]\n * });\n *\n * @example\n * // Default behavior: update on next background\n * await CapacitorUpdater.setMultiDelay({\n * delayConditions: [{ kind: 'background' }]\n * });\n *\n * @param options Contains the {@link MultiDelayConditions} array of conditions.\n * @returns {Promise<void>} Resolves when the delay conditions are set.\n * @throws {Error} If the operation fails or conditions are invalid.\n * @since 4.3.0\n */\n setMultiDelay(options: MultiDelayConditions): Promise<void>;\n\n /**\n * Cancel all delay conditions and apply the pending update immediately.\n *\n * If you've set delay conditions with {@link setMultiDelay}, this method clears them\n * and triggers the pending update to be applied on the next app background or restart.\n *\n * This is useful when:\n * - User manually requests to update now (e.g., clicks \"Update now\" button)\n * - Your app detects it's a good time to update (e.g., user finished critical task)\n * - You want to override a time-based delay early\n *\n * @returns {Promise<void>} Resolves when the delay conditions are cleared.\n * @throws {Error} If the operation fails.\n * @since 4.0.0\n */\n cancelDelay(): Promise<void>;\n\n /**\n * Check the update server for the latest available bundle version.\n *\n * This queries your configured update URL (or Capgo backend) to see if a newer bundle\n * is available for download. It does NOT download the bundle automatically.\n *\n * The 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 *\n * After receiving the latest version info, you can:\n * 1. Compare it with your current version\n * 2. Download it using {@link download}\n * 3. Apply it using {@link next} or {@link set}\n *\n * **Important: Error handling for \"no new version available\"**\n *\n * When the device's current version matches the latest version on the server (i.e., the device is already\n * up-to-date), the server returns a 200 response with `error: \"no_new_version_available\"` and\n * `message: \"No new version available\"`. **This causes `getLatest()` to throw an error**, even though\n * this is a normal, expected condition.\n *\n * You should catch this specific error to handle it gracefully:\n *\n * ```typescript\n * try {\n * const latest = await CapacitorUpdater.getLatest();\n * // New version is available, proceed with download\n * } catch (error) {\n * if (error.message === 'No new version available') {\n * // Device is already on the latest version - this is normal\n * console.log('Already up to date');\n * } else {\n * // Actual error occurred\n * console.error('Failed to check for updates:', error);\n * }\n * }\n * ```\n *\n * In 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)\n *\n * @param options Optional {@link GetLatestOptions} to specify which channel to check.\n * @returns {Promise<LatestVersion>} Information about the latest available bundle version.\n * @throws {Error} Always throws when no new version is available (`error: \"no_new_version_available\"`), or when the request fails.\n * @since 4.0.0\n */\n getLatest(options?: GetLatestOptions): Promise<LatestVersion>;\n\n /**\n * Assign this device to a specific update channel at runtime.\n *\n * Channels allow you to distribute different bundle versions to different groups of users\n * (e.g., \"production\", \"beta\", \"staging\"). This method switches the device to a new channel.\n *\n * **Requirements:**\n * - The target channel must allow self-assignment (configured in your Capgo dashboard or backend)\n * - The backend may accept or reject the request based on channel settings\n *\n * **When to use:**\n * - After the app is ready and the user has interacted (e.g., opted into beta program)\n * - To implement in-app channel switching (beta toggle, tester access, etc.)\n * - For user-driven channel changes\n *\n * **When NOT to use:**\n * - At app boot/initialization - use {@link PluginsConfig.CapacitorUpdater.defaultChannel} config instead\n * - Before user interaction\n *\n * **Important: Listen for the `channelPrivate` event**\n *\n * When a user attempts to set a channel that doesn't allow device self-assignment, the method will\n * throw an error AND fire a {@link addListener}('channelPrivate') event. You should listen to this event\n * to provide appropriate feedback to users:\n *\n * ```typescript\n * CapacitorUpdater.addListener('channelPrivate', (data) => {\n * console.warn(`Cannot access channel \"${data.channel}\": ${data.message}`);\n * // Show user-friendly message\n * });\n * ```\n *\n * This sends a request to the Capgo backend linking your device ID to the specified channel.\n *\n * @param options The {@link SetChannelOptions} containing the channel name and optional auto-update trigger.\n * @returns {Promise<ChannelRes>} Channel operation result with status and optional error/message.\n * @throws {Error} If the channel doesn't exist or doesn't allow self-assignment.\n * @since 4.7.0\n */\n setChannel(options: SetChannelOptions): Promise<ChannelRes>;\n\n /**\n * Remove the device's channel assignment and return to the default channel.\n *\n * This unlinks the device from any specifically assigned channel, causing it to fall back to:\n * - The {@link PluginsConfig.CapacitorUpdater.defaultChannel} if configured, or\n * - Your backend's default channel for this app\n *\n * Use this when:\n * - Users opt out of beta/testing programs\n * - You want to reset a device to standard update distribution\n * - Testing channel switching behavior\n *\n * @param options {@link UnsetChannelOptions} containing optional auto-update trigger.\n * @returns {Promise<void>} Resolves when the channel is successfully unset.\n * @throws {Error} If the operation fails.\n * @since 4.7.0\n */\n unsetChannel(options: UnsetChannelOptions): Promise<void>;\n\n /**\n * Get the current channel assigned to this device.\n *\n * Returns information about:\n * - `channel`: The currently assigned channel name (if any)\n * - `allowSet`: Whether the channel allows self-assignment\n * - `status`: Operation status\n * - `error`/`message`: Additional information (if applicable)\n *\n * Use this to:\n * - Display current channel to users (e.g., \"You're on the Beta channel\")\n * - Check if a device is on a specific channel before showing features\n * - Verify channel assignment after calling {@link setChannel}\n *\n * @returns {Promise<GetChannelRes>} The current channel information.\n * @throws {Error} If the operation fails.\n * @since 4.8.0\n */\n getChannel(): Promise<GetChannelRes>;\n\n /**\n * Get a list of all channels available for this device to self-assign to.\n *\n * Only returns channels where `allow_self_set` is `true`. These are channels that\n * users can switch to using {@link setChannel} without backend administrator intervention.\n *\n * Each channel includes:\n * - `id`: Unique channel identifier\n * - `name`: Human-readable channel name\n * - `public`: Whether the channel is publicly visible\n * - `allow_self_set`: Always `true` in results (filtered to only self-assignable channels)\n *\n * Use this to:\n * - Build a channel selector UI for users (e.g., \"Join Beta\" button)\n * - Show available testing/preview channels\n * - Implement channel discovery features\n *\n * @returns {Promise<ListChannelsResult>} List of channels the device can self-assign to.\n * @throws {Error} If the operation fails or the request to the backend fails.\n * @since 7.5.0\n */\n listChannels(): Promise<ListChannelsResult>;\n\n /**\n * Set a custom identifier for this device.\n *\n * This allows you to identify devices by your own custom ID (user ID, account ID, etc.)\n * instead of or in addition to the device's unique hardware ID. The custom ID is sent\n * to your update server and can be used for:\n * - Targeting specific users for updates\n * - Analytics and user tracking\n * - Debugging and support (correlating devices with users)\n * - A/B testing or feature flagging\n *\n * **Persistence:**\n * - When {@link PluginsConfig.CapacitorUpdater.persistCustomId} is `true`, the ID persists across app restarts\n * - When `false`, the ID is only kept for the current session\n *\n * **Clearing the custom ID:**\n * - Pass an empty string `\"\"` to remove any stored custom ID\n *\n * @param options The {@link SetCustomIdOptions} containing the custom identifier string.\n * @returns {Promise<void>} Resolves immediately (synchronous operation).\n * @throws {Error} If the operation fails.\n * @since 4.9.0\n */\n setCustomId(options: SetCustomIdOptions): Promise<void>;\n\n /**\n * Get the builtin bundle version (the original version shipped with your native app).\n *\n * This returns the version of the bundle that was included when the app was installed\n * from the App Store or Play Store. This is NOT the currently active bundle version -\n * use {@link current} for that.\n *\n * Returns:\n * - The {@link PluginsConfig.CapacitorUpdater.version} config value if set, or\n * - The native app version from platform configs (package.json, Info.plist, build.gradle)\n *\n * Use this to:\n * - Display the \"factory\" version to users\n * - Compare against downloaded bundle versions\n * - Determine if any updates have been applied\n * - Debugging version mismatches\n *\n * @returns {Promise<BuiltinVersion>} The builtin bundle version string.\n * @since 5.2.0\n */\n getBuiltinVersion(): Promise<BuiltinVersion>;\n\n /**\n * Get the unique, privacy-friendly identifier for this device.\n *\n * This ID is used to identify the device when communicating with update servers.\n * It's automatically generated and stored securely by the plugin.\n *\n * **Privacy & Security characteristics:**\n * - Generated as a UUID (not based on hardware identifiers)\n * - Stored securely in platform-specific secure storage\n * - Android: Android Keystore (persists across app reinstalls on API 23+)\n * - iOS: Keychain with `kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly`\n * - Not synced to cloud (iOS)\n * - Follows Apple and Google privacy best practices\n * - Users can clear it via system settings (Android) or keychain access (iOS)\n *\n * **Persistence:**\n * The device ID persists across app reinstalls to maintain consistent device identity\n * for update tracking and analytics.\n *\n * Use this to:\n * - Debug update delivery issues (check what ID the server sees)\n * - Implement device-specific features\n * - Correlate server logs with specific devices\n *\n * @returns {Promise<DeviceId>} The unique device identifier string.\n * @throws {Error} If the operation fails.\n */\n getDeviceId(): Promise<DeviceId>;\n\n /**\n * Get the version of the Capacitor Updater plugin installed in your app.\n *\n * This returns the version of the native plugin code (Android/iOS), which is sent\n * to the update server with each request. This is NOT your app version or bundle version.\n *\n * Use this to:\n * - Debug plugin-specific issues (when reporting bugs)\n * - Verify plugin installation and version\n * - Check compatibility with backend features\n * - Display in debug/about screens\n *\n * @returns {Promise<PluginVersion>} The Capacitor Updater plugin version string.\n * @throws {Error} If the operation fails.\n */\n getPluginVersion(): Promise<PluginVersion>;\n\n /**\n * Check if automatic updates are currently enabled.\n *\n * Returns `true` if {@link PluginsConfig.CapacitorUpdater.autoUpdate} is enabled,\n * meaning the plugin will automatically check for, download, and apply updates.\n *\n * Returns `false` if in manual mode, where you control the update flow using\n * {@link getLatest}, {@link download}, {@link next}, and {@link set}.\n *\n * Use this to:\n * - Determine which update flow your app is using\n * - Show/hide manual update UI based on mode\n * - Debug update behavior\n *\n * @returns {Promise<AutoUpdateEnabled>} `true` if auto-update is enabled, `false` if in manual mode.\n * @throws {Error} If the operation fails.\n */\n isAutoUpdateEnabled(): Promise<AutoUpdateEnabled>;\n\n /**\n * Remove all event listeners registered for this plugin.\n *\n * This 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 *\n * Use this during cleanup (e.g., when unmounting components or closing screens)\n * to prevent memory leaks from lingering event listeners.\n *\n * @returns {Promise<void>} Resolves when all listeners are removed.\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Listen for bundle download event in the App. Fires once a download has started, during downloading and when finished.\n * This will return you all download percent during the download\n *\n * @since 2.0.11\n */\n addListener(eventName: 'download', listenerFunc: (state: DownloadEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for no need to update event, useful when you want force check every time the app is launched\n *\n * @since 4.0.0\n */\n addListener(eventName: 'noNeedUpdate', listenerFunc: (state: NoNeedEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for available update event, useful when you want to force check every time the app is launched\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'updateAvailable',\n listenerFunc: (state: UpdateAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for downloadComplete events.\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'downloadComplete',\n listenerFunc: (state: DownloadCompleteEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for breaking update events when the backend flags an update as incompatible with the current app.\n * Emits the same payload as the legacy `majorAvailable` listener.\n *\n * @since 7.22.0\n */\n addListener(\n eventName: 'breakingAvailable',\n listenerFunc: (state: BreakingAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking\n *\n * @deprecated Deprecated alias for {@link addListener} with `breakingAvailable`. Emits the same payload. will be removed in v8\n * @since 2.3.0\n */\n addListener(\n eventName: 'majorAvailable',\n listenerFunc: (state: MajorAvailableEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for update fail event in the App, let you know when update has fail to install at next app start\n *\n * @since 2.3.0\n */\n addListener(\n eventName: 'updateFailed',\n listenerFunc: (state: UpdateFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for set event in the App, let you know when a bundle has been applied successfully.\n * This event is retained natively until JavaScript consumes it, so if the app reloads before your\n * listener is attached, the last pending `set` event is delivered once the listener subscribes.\n *\n * @since 8.43.12\n */\n addListener(eventName: 'set', listenerFunc: (state: SetEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for set next event in the App, let you know when a bundle is queued as the next bundle to install.\n *\n * @since 6.14.0\n */\n addListener(eventName: 'setNext', listenerFunc: (state: SetNextEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for download fail event in the App, let you know when a bundle download has failed\n *\n * @since 4.0.0\n */\n addListener(\n eventName: 'downloadFailed',\n listenerFunc: (state: DownloadFailedEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for reload event in the App, let you know when reload has happened\n *\n * @since 4.3.0\n */\n addListener(eventName: 'appReloaded', listenerFunc: () => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for app ready event in the App, let you know when app is ready to use.\n * This event is retained natively until JavaScript consumes it, so it can still be delivered after\n * a reload even if the listener is attached later in app startup.\n *\n * @since 5.1.0\n */\n addListener(eventName: 'appReady', listenerFunc: (state: AppReadyEvent) => void): Promise<PluginListenerHandle>;\n\n /**\n * Listen for channel private event, fired when attempting to set a channel that doesn't allow device self-assignment.\n *\n * This event is useful for:\n * - Informing users they don't have permission to switch to a specific channel\n * - Implementing custom error handling for channel restrictions\n * - Logging unauthorized channel access attempts\n *\n * @since 7.34.0\n */\n addListener(\n eventName: 'channelPrivate',\n listenerFunc: (state: ChannelPrivateEvent) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for flexible update state changes on Android.\n *\n * This event fires during the flexible update download process, providing:\n * - Download progress (bytes downloaded / total bytes)\n * - Installation status changes\n *\n * **Install status values:**\n * - `UNKNOWN` (0): Unknown status\n * - `PENDING` (1): Download pending\n * - `DOWNLOADING` (2): Download in progress\n * - `INSTALLING` (3): Installing the update\n * - `INSTALLED` (4): Update installed (app restart needed)\n * - `FAILED` (5): Update failed\n * - `CANCELED` (6): Update was canceled\n * - `DOWNLOADED` (11): Download complete, ready to install\n *\n * When status is `DOWNLOADED`, you should prompt the user and call\n * {@link completeFlexibleUpdate} to finish the installation.\n *\n * @since 8.0.0\n */\n addListener(\n eventName: 'onFlexibleUpdateStateChange',\n listenerFunc: (state: FlexibleUpdateState) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Check if the auto-update feature is available (not disabled by custom server configuration).\n *\n * Returns `false` when a custom `updateUrl` is configured, as this typically indicates\n * you're using a self-hosted update server that may not support all auto-update features.\n *\n * Returns `true` when using the default Capgo backend or when the feature is available.\n *\n * This is different from {@link isAutoUpdateEnabled}:\n * - `isAutoUpdateEnabled()`: Checks if auto-update MODE is turned on/off\n * - `isAutoUpdateAvailable()`: Checks if auto-update is SUPPORTED with your current configuration\n *\n * @returns {Promise<AutoUpdateAvailable>} `false` when custom updateUrl is set, `true` otherwise.\n * @throws {Error} If the operation fails.\n */\n isAutoUpdateAvailable(): Promise<AutoUpdateAvailable>;\n\n /**\n * Get information about the bundle queued to be activated on next reload.\n *\n * Returns:\n * - {@link BundleInfo} object if a bundle has been queued via {@link next}\n * - `null` if no update is pending\n *\n * This is useful to:\n * - Check if an update is waiting to be applied\n * - Display \"Update pending\" status to users\n * - Show version info of the queued update\n * - Decide whether to show a \"Restart to update\" prompt\n *\n * The queued bundle will be activated when:\n * - The app is backgrounded (default behavior)\n * - The app is killed and restarted\n * - {@link reload} is called manually\n * - Delay conditions set by {@link setMultiDelay} are met\n *\n * @returns {Promise<BundleInfo | null>} The pending bundle info, or `null` if none is queued.\n * @throws {Error} If the operation fails.\n * @since 6.8.0\n */\n getNextBundle(): Promise<BundleInfo | null>;\n\n /**\n * Retrieve information about the most recent bundle that failed to load.\n *\n * When a bundle fails to load (e.g., JavaScript errors prevent initialization, missing files),\n * the plugin automatically rolls back and stores information about the failure. This method\n * retrieves that failure information.\n *\n * **IMPORTANT: The stored value is cleared after being retrieved once.**\n * Calling this method multiple times will only return the failure info on the first call,\n * then `null` on subsequent calls until another failure occurs.\n *\n * Returns:\n * - {@link UpdateFailedEvent} with bundle info if a failure was recorded\n * - `null` if no failure has occurred or if it was already retrieved\n *\n * Use this to:\n * - Show users why an update failed\n * - Log failure information for debugging\n * - Implement custom error handling/reporting\n * - Display rollback notifications\n *\n * @returns {Promise<UpdateFailedEvent | null>} The failed update info (cleared after first retrieval), or `null`.\n * @throws {Error} If the operation fails.\n * @since 7.22.0\n */\n getFailedUpdate(): Promise<UpdateFailedEvent | null>;\n\n /**\n * Enable or disable the shake gesture menu for debugging and testing.\n *\n * When enabled, users can shake their device to open a debug menu that shows:\n * - Current bundle information\n * - Available bundles\n * - Options to switch bundles manually\n * - Update status\n *\n * This is useful during development and testing to:\n * - Quickly test different bundle versions\n * - Debug update flows\n * - Switch between production and test bundles\n * - Verify bundle installations\n *\n * **Important:** Disable this in production builds or only enable for internal testers.\n *\n * Can also be configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.\n *\n * @param options {@link SetShakeMenuOptions} with `enabled: true` to enable or `enabled: false` to disable.\n * @returns {Promise<void>} Resolves when the setting is applied.\n * @throws {Error} If the operation fails.\n * @since 7.5.0\n */\n setShakeMenu(options: SetShakeMenuOptions): Promise<void>;\n\n /**\n * Check if the shake gesture debug menu is currently enabled.\n *\n * Returns the current state of the shake menu feature that can be toggled via\n * {@link setShakeMenu} or configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.\n *\n * Use this to:\n * - Check if debug features are enabled\n * - Show/hide debug settings UI\n * - Verify configuration during testing\n *\n * @returns {Promise<ShakeMenuEnabled>} Object with `enabled: true` or `enabled: false`.\n * @throws {Error} If the operation fails.\n * @since 7.5.0\n */\n isShakeMenuEnabled(): Promise<ShakeMenuEnabled>;\n\n /**\n * Enable or disable the shake channel selector at runtime.\n *\n * When enabled AND shakeMenu is true, shaking the device shows a channel\n * selector instead of the debug menu. This allows users to switch between\n * update channels by shaking their device.\n *\n * After selecting a channel, the app automatically checks for updates\n * and downloads if available.\n *\n * Can also be configured via {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}.\n *\n * @param options {@link SetShakeChannelSelectorOptions} with `enabled: true` to enable or `enabled: false` to disable.\n * @returns {Promise<void>} Resolves when the setting is applied.\n * @throws {Error} If the operation fails.\n * @since 8.43.0\n */\n setShakeChannelSelector(options: SetShakeChannelSelectorOptions): Promise<void>;\n\n /**\n * Check if the shake channel selector is currently enabled.\n *\n * Returns the current state of the shake channel selector feature that can be toggled via\n * {@link setShakeChannelSelector} or configured via {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}.\n *\n * @returns {Promise<ShakeChannelSelectorEnabled>} Object with `enabled: true` or `enabled: false`.\n * @throws {Error} If the operation fails.\n * @since 8.43.0\n */\n isShakeChannelSelectorEnabled(): Promise<ShakeChannelSelectorEnabled>;\n\n /**\n * Get the currently configured App ID used for update server communication.\n *\n * Returns the App ID that identifies this app to the update server. This can be:\n * - The value set via {@link setAppId}, or\n * - The {@link PluginsConfig.CapacitorUpdater.appId} config value, or\n * - The default app identifier from your native app configuration\n *\n * Use this to:\n * - Verify which App ID is being used for updates\n * - Debug update delivery issues\n * - Display app configuration in debug screens\n * - Confirm App ID after calling {@link setAppId}\n *\n * @returns {Promise<GetAppIdRes>} Object containing the current `appId` string.\n * @throws {Error} If the operation fails.\n * @since 7.14.0\n */\n getAppId(): Promise<GetAppIdRes>;\n\n /**\n * Dynamically change the App ID used for update server communication.\n *\n * This overrides the App ID used to identify your app to the update server, allowing you\n * to switch between different app configurations at runtime (e.g., production vs staging\n * app IDs, or multi-tenant configurations).\n *\n * **Requirements:**\n * - {@link PluginsConfig.CapacitorUpdater.allowModifyAppId} must be set to `true`\n *\n * **Important considerations:**\n * - Changing the App ID will affect which updates this device receives\n * - The new App ID must exist on your update server\n * - This is primarily for advanced use cases (multi-tenancy, environment switching)\n * - Most apps should use the config-based {@link PluginsConfig.CapacitorUpdater.appId} instead\n *\n * @param options {@link SetAppIdOptions} containing the new App ID string.\n * @returns {Promise<void>} Resolves when the App ID is successfully changed.\n * @throws {Error} If `allowModifyAppId` is false or the operation fails.\n * @since 7.14.0\n */\n setAppId(options: SetAppIdOptions): Promise<void>;\n\n // ============================================================================\n // App Store / Play Store Update Methods\n // ============================================================================\n\n /**\n * Get information about the app's availability in the App Store or Play Store.\n *\n * This method checks the native app stores to see if a newer version of the app\n * is available for download. This is different from Capgo's OTA updates - this\n * checks for native app updates that require going through the app stores.\n *\n * **Platform differences:**\n * - **Android**: Uses Play Store's In-App Updates API for accurate update information\n * - **iOS**: Queries the App Store lookup API (requires country code for accurate results)\n *\n * **Returns information about:**\n * - Current installed version\n * - Available version in the store (if any)\n * - Whether an update is available\n * - Update priority (Android only)\n * - Whether immediate/flexible updates are allowed (Android only)\n *\n * Use this to:\n * - Check if users need to update from the app store\n * - Show \"Update Available\" prompts for native updates\n * - Implement version gating (require minimum native version)\n * - Combine with Capgo OTA updates for a complete update strategy\n *\n * @param options Optional {@link GetAppUpdateInfoOptions} with country code for iOS.\n * @returns {Promise<AppUpdateInfo>} Information about the current and available app versions.\n * @throws {Error} If the operation fails or store information is unavailable.\n * @since 8.0.0\n */\n getAppUpdateInfo(options?: GetAppUpdateInfoOptions): Promise<AppUpdateInfo>;\n\n /**\n * Open the app's page in the App Store or Play Store.\n *\n * This navigates the user to your app's store listing where they can manually\n * update the app. Use this as a fallback when in-app updates are not available\n * or when the user needs to update on iOS.\n *\n * **Platform behavior:**\n * - **Android**: Opens Play Store to the app's page\n * - **iOS**: Opens App Store to the app's page\n *\n * **Customization options:**\n * - `appId`: Specify a custom App Store ID (iOS) - useful for opening a different app's page\n * - `packageName`: Specify a custom package name (Android) - useful for opening a different app's page\n *\n * @param options Optional {@link OpenAppStoreOptions} to customize which app's store page to open.\n * @returns {Promise<void>} Resolves when the store is opened.\n * @throws {Error} If the store cannot be opened.\n * @since 8.0.0\n */\n openAppStore(options?: OpenAppStoreOptions): Promise<void>;\n\n /**\n * Perform an immediate in-app update on Android.\n *\n * This triggers Google Play's immediate update flow, which:\n * 1. Shows a full-screen update UI\n * 2. Downloads and installs the update\n * 3. Restarts the app automatically\n *\n * The user cannot continue using the app until the update is complete.\n * This is ideal for critical updates that must be installed immediately.\n *\n * **Requirements:**\n * - Android only (throws error on iOS)\n * - An update must be available (check with {@link getAppUpdateInfo} first)\n * - The update must allow immediate updates (`immediateUpdateAllowed: true`)\n *\n * **User experience:**\n * - Full-screen blocking UI\n * - Progress shown during download\n * - App automatically restarts after installation\n *\n * @returns {Promise<AppUpdateResult>} Result indicating success, cancellation, or failure.\n * @throws {Error} If not on Android, no update is available, or immediate updates not allowed.\n * @since 8.0.0\n */\n performImmediateUpdate(): Promise<AppUpdateResult>;\n\n /**\n * Start a flexible in-app update on Android.\n *\n * This triggers Google Play's flexible update flow, which:\n * 1. Downloads the update in the background\n * 2. Allows the user to continue using the app\n * 3. Notifies when download is complete\n * 4. Requires calling {@link completeFlexibleUpdate} to install\n *\n * Monitor the download progress using the `onFlexibleUpdateStateChange` listener.\n *\n * **Requirements:**\n * - Android only (throws error on iOS)\n * - An update must be available (check with {@link getAppUpdateInfo} first)\n * - The update must allow flexible updates (`flexibleUpdateAllowed: true`)\n *\n * **Typical flow:**\n * 1. Call `startFlexibleUpdate()` to begin download\n * 2. Listen to `onFlexibleUpdateStateChange` for progress\n * 3. When status is `DOWNLOADED`, prompt user to restart\n * 4. Call `completeFlexibleUpdate()` to install and restart\n *\n * @returns {Promise<AppUpdateResult>} Result indicating the update was started, cancelled, or failed.\n * @throws {Error} If not on Android, no update is available, or flexible updates not allowed.\n * @since 8.0.0\n */\n startFlexibleUpdate(): Promise<AppUpdateResult>;\n\n /**\n * Complete a flexible in-app update on Android.\n *\n * After a flexible update has been downloaded (status `DOWNLOADED` in\n * `onFlexibleUpdateStateChange`), call this method to install the update\n * and restart the app.\n *\n * **Important:** This will immediately restart the app. Make sure to:\n * - Save any user data before calling\n * - Prompt the user before restarting\n * - Only call when the download status is `DOWNLOADED`\n *\n * @returns {Promise<void>} Resolves when the update installation begins (app will restart).\n * @throws {Error} If not on Android or no downloaded update is pending.\n * @since 8.0.0\n */\n completeFlexibleUpdate(): Promise<void>;\n}\n\n/**\n * pending: The bundle is pending to be **SET** as the next bundle.\n * downloading: The bundle is being downloaded.\n * success: The bundle has been downloaded and is ready to be **SET** as the next bundle.\n * error: The bundle has failed to download.\n */\nexport type BundleStatus = 'success' | 'error' | 'pending' | 'downloading';\n\nexport type DelayUntilNext = 'background' | 'kill' | 'nativeVersion' | 'date';\n\nexport interface NoNeedEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface UpdateAvailableEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface ChannelRes {\n /**\n * Current status of set channel\n *\n * @since 4.7.0\n */\n status: string;\n error?: string;\n message?: string;\n}\n\nexport interface GetChannelRes {\n /**\n * Current status of get channel\n *\n * @since 4.8.0\n */\n channel?: string;\n error?: string;\n message?: string;\n status?: string;\n allowSet?: boolean;\n}\n\nexport interface ChannelInfo {\n /**\n * The channel ID\n *\n * @since 7.5.0\n */\n id: string;\n /**\n * The channel name\n *\n * @since 7.5.0\n */\n name: string;\n /**\n * Whether this is a public channel\n *\n * @since 7.5.0\n */\n public: boolean;\n /**\n * Whether devices can self-assign to this channel\n *\n * @since 7.5.0\n */\n allow_self_set: boolean;\n}\n\nexport interface ListChannelsResult {\n /**\n * List of available channels\n *\n * @since 7.5.0\n */\n channels: ChannelInfo[];\n}\n\nexport interface DownloadEvent {\n /**\n * Current status of download, between 0 and 100.\n *\n * @since 4.0.0\n */\n percent: number;\n bundle: BundleInfo;\n}\n\nexport interface MajorAvailableEvent {\n /**\n * Emit when a breaking update is available.\n *\n * @deprecated Deprecated alias for {@link BreakingAvailableEvent}. Receives the same payload.\n * @since 4.0.0\n */\n version: string;\n}\n\n/**\n * Payload emitted by {@link CapacitorUpdaterPlugin.addListener} with `breakingAvailable`.\n *\n * @since 7.22.0\n */\nexport type BreakingAvailableEvent = MajorAvailableEvent;\n\nexport interface DownloadFailedEvent {\n /**\n * Emit when a download fail.\n *\n * @since 4.0.0\n */\n version: string;\n}\n\nexport interface DownloadCompleteEvent {\n /**\n * Emit when a new update is available.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface UpdateFailedEvent {\n /**\n * Emit when a update failed to install.\n *\n * @since 4.0.0\n */\n bundle: BundleInfo;\n}\n\nexport interface SetEvent {\n /**\n * Emit when a bundle has been applied successfully.\n * This event uses native `retainUntilConsumed` behavior.\n *\n * @since 8.43.12\n */\n bundle: BundleInfo;\n}\n\nexport interface SetNextEvent {\n /**\n * Emit when a bundle is queued as the next bundle to install.\n *\n * @since 6.14.0\n */\n bundle: BundleInfo;\n}\n\nexport interface AppReadyEvent {\n /**\n * Emitted when the app is ready to use.\n * This event uses native `retainUntilConsumed` behavior.\n *\n * @since 5.2.0\n */\n bundle: BundleInfo;\n status: string;\n}\n\nexport interface ChannelPrivateEvent {\n /**\n * Emitted when attempting to set a channel that doesn't allow device self-assignment.\n *\n * @since 7.34.0\n */\n channel: string;\n message: string;\n}\n\nexport interface ManifestEntry {\n file_name: string | null;\n file_hash: string | null;\n download_url: string | null;\n}\n\nexport interface LatestVersion {\n /**\n * Result of getLatest method\n *\n * @since 4.0.0\n */\n version: string;\n /**\n * @since 6\n */\n checksum?: string;\n /**\n * Indicates whether the update was flagged as breaking by the backend.\n *\n * @since 7.22.0\n */\n breaking?: boolean;\n /**\n * @deprecated Use {@link LatestVersion.breaking} instead.\n */\n major?: boolean;\n /**\n * Optional message from the server.\n * When no new version is available, this will be \"No new version available\".\n */\n message?: string;\n sessionKey?: string;\n /**\n * Error code from the server, if any.\n * Common values:\n * - `\"no_new_version_available\"`: Device is already on the latest version (not a failure)\n * - Other error codes indicate actual failures in the update process\n */\n error?: string;\n /**\n * The previous/current version name (provided for reference).\n */\n old?: string;\n /**\n * Download URL for the bundle (when a new version is available).\n */\n url?: string;\n /**\n * File list for delta updates (when using multi-file downloads).\n * @since 6.1\n */\n manifest?: ManifestEntry[];\n /**\n * Optional link associated with this bundle version (e.g., release notes URL, changelog, GitHub release).\n * @since 7.35.0\n */\n link?: string;\n /**\n * Optional comment or description for this bundle version.\n * @since 7.35.0\n */\n comment?: string;\n}\n\nexport interface BundleInfo {\n id: string;\n version: string;\n downloaded: string;\n checksum: string;\n status: BundleStatus;\n}\n\nexport interface SetChannelOptions {\n channel: string;\n triggerAutoUpdate?: boolean;\n}\n\nexport interface UnsetChannelOptions {\n triggerAutoUpdate?: boolean;\n}\n\nexport interface SetCustomIdOptions {\n /**\n * Custom identifier to associate with the device. Use an empty string to clear any saved value.\n */\n customId: string;\n}\n\nexport interface DelayCondition {\n /**\n * Set up delay conditions in setMultiDelay\n * @param value is useless for @param kind \"kill\", optional for \"background\" (default value: \"0\") and required for \"nativeVersion\" and \"date\"\n */\n kind: DelayUntilNext;\n value?: string;\n}\n\nexport interface GetLatestOptions {\n /**\n * The channel to get the latest version for\n * The channel must allow 'self_assign' for this to work\n * @since 6.8.0\n * @default undefined\n */\n channel?: string;\n}\n\nexport interface AppReadyResult {\n bundle: BundleInfo;\n}\n\nexport interface UpdateUrl {\n url: string;\n}\n\nexport interface StatsUrl {\n url: string;\n}\n\nexport interface ChannelUrl {\n url: string;\n}\n\n/**\n * This URL and versions are used to download the bundle from the server, If you use backend all information will be given by the method getLatest.\n * If you don't use backend, you need to provide the URL and version of the bundle. Checksum and sessionKey are required if you encrypted the bundle with the CLI command encrypt, you should receive them as result of the command.\n */\nexport interface DownloadOptions {\n /**\n * The URL of the bundle zip file (e.g: dist.zip) to be downloaded. (This can be any URL. E.g: Amazon S3, a GitHub tag, any other place you've hosted your bundle.)\n */\n url: string;\n /**\n * The version code/name of this bundle/version\n */\n version: string;\n /**\n * The session key for the update, when the bundle is encrypted with a session key\n * @since 4.0.0\n * @default undefined\n */\n sessionKey?: string;\n /**\n * The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted\n * @since 4.0.0\n * @default undefined\n */\n checksum?: string;\n /**\n * The manifest for multi-file downloads\n * @since 6.1.0\n * @default undefined\n */\n manifest?: ManifestEntry[];\n}\n\nexport interface BundleId {\n id: string;\n}\n\nexport interface BundleListResult {\n bundles: BundleInfo[];\n}\n\nexport interface ResetOptions {\n /**\n * Reset to the last successfully loaded bundle instead of the builtin one.\n * @default false\n */\n toLastSuccessful?: boolean;\n /**\n * Apply the pending bundle set via {@link next} while resetting.\n *\n * When `true`, the plugin will switch to the pending bundle immediately and clear the pending flag.\n * If no pending bundle exists, the reset will fail.\n * @default false\n */\n usePendingBundle?: boolean;\n}\n\nexport interface ListOptions {\n /**\n * Whether to return the raw bundle list or the manifest. If true, the list will attempt to read the internal database instead of files on disk.\n * @since 6.14.0\n * @default false\n */\n raw?: boolean;\n}\n\nexport interface CurrentBundleResult {\n bundle: BundleInfo;\n native: string;\n}\n\nexport interface MultiDelayConditions {\n delayConditions: DelayCondition[];\n}\n\nexport interface BuiltinVersion {\n version: string;\n}\n\nexport interface DeviceId {\n deviceId: string;\n}\n\nexport interface PluginVersion {\n version: string;\n}\n\nexport interface AutoUpdateEnabled {\n enabled: boolean;\n}\n\nexport interface AutoUpdateAvailable {\n available: boolean;\n}\n\nexport interface SetShakeMenuOptions {\n enabled: boolean;\n}\n\nexport interface ShakeMenuEnabled {\n enabled: boolean;\n}\n\nexport interface SetShakeChannelSelectorOptions {\n enabled: boolean;\n}\n\nexport interface ShakeChannelSelectorEnabled {\n enabled: boolean;\n}\n\nexport interface GetAppIdRes {\n appId: string;\n}\n\nexport interface SetAppIdOptions {\n appId: string;\n}\n\n// ============================================================================\n// App Store / Play Store Update Types\n// ============================================================================\n\n/**\n * Options for {@link CapacitorUpdaterPlugin.getAppUpdateInfo}.\n *\n * @since 8.0.0\n */\nexport interface GetAppUpdateInfoOptions {\n /**\n * Two-letter country code (ISO 3166-1 alpha-2) for the App Store lookup.\n *\n * This is required on iOS to get accurate App Store information, as app\n * availability and versions can vary by country.\n *\n * Examples: \"US\", \"GB\", \"DE\", \"JP\", \"FR\"\n *\n * On Android, this option is ignored as the Play Store handles region\n * detection automatically.\n *\n * @since 8.0.0\n */\n country?: string;\n}\n\n/**\n * Information about app updates available in the App Store or Play Store.\n *\n * @since 8.0.0\n */\nexport interface AppUpdateInfo {\n /**\n * The currently installed version name (e.g., \"1.2.3\").\n *\n * @since 8.0.0\n */\n currentVersionName: string;\n\n /**\n * The version name available in the store, if an update is available.\n * May be undefined if no update information is available.\n *\n * @since 8.0.0\n */\n availableVersionName?: string;\n\n /**\n * The currently installed version code (Android) or build number (iOS).\n *\n * @since 8.0.0\n */\n currentVersionCode: string;\n\n /**\n * The version code available in the store (Android only).\n * On iOS, this will be the same as `availableVersionName`.\n *\n * @since 8.0.0\n */\n availableVersionCode?: string;\n\n /**\n * The release date of the available version (iOS only).\n * Format: ISO 8601 date string.\n *\n * @since 8.0.0\n */\n availableVersionReleaseDate?: string;\n\n /**\n * The current update availability status.\n *\n * @since 8.0.0\n */\n updateAvailability: AppUpdateAvailability;\n\n /**\n * The priority of the update as set by the developer in Play Console (Android only).\n * Values range from 0 (default/lowest) to 5 (highest priority).\n *\n * Use this to decide whether to show an update prompt or force an update.\n *\n * @since 8.0.0\n */\n updatePriority?: number;\n\n /**\n * Whether an immediate update is allowed (Android only).\n *\n * If `true`, you can call {@link CapacitorUpdaterPlugin.performImmediateUpdate}.\n *\n * @since 8.0.0\n */\n immediateUpdateAllowed?: boolean;\n\n /**\n * Whether a flexible update is allowed (Android only).\n *\n * If `true`, you can call {@link CapacitorUpdaterPlugin.startFlexibleUpdate}.\n *\n * @since 8.0.0\n */\n flexibleUpdateAllowed?: boolean;\n\n /**\n * Number of days since the update became available (Android only).\n *\n * Use this to implement \"update nagging\" - remind users more frequently\n * as the update ages.\n *\n * @since 8.0.0\n */\n clientVersionStalenessDays?: number;\n\n /**\n * The current install status of a flexible update (Android only).\n *\n * @since 8.0.0\n */\n installStatus?: FlexibleUpdateInstallStatus;\n\n /**\n * The minimum OS version required for the available update (iOS only).\n *\n * @since 8.0.0\n */\n minimumOsVersion?: string;\n}\n\n/**\n * Options for {@link CapacitorUpdaterPlugin.openAppStore}.\n *\n * @since 8.0.0\n */\nexport interface OpenAppStoreOptions {\n /**\n * The Android package name to open in the Play Store.\n *\n * If not specified, uses the current app's package name.\n * Use this to open a different app's store page.\n *\n * Only used on Android.\n *\n * @since 8.0.0\n */\n packageName?: string;\n\n /**\n * The iOS App Store ID to open.\n *\n * If not specified, uses the current app's bundle identifier to look up the app.\n * Use this to open a different app's store page or when automatic lookup fails.\n *\n * Only used on iOS.\n *\n * @since 8.0.0\n */\n appId?: string;\n}\n\n/**\n * State information for flexible update progress (Android only).\n *\n * @since 8.0.0\n */\nexport interface FlexibleUpdateState {\n /**\n * The current installation status.\n *\n * @since 8.0.0\n */\n installStatus: FlexibleUpdateInstallStatus;\n\n /**\n * Number of bytes downloaded so far.\n * Only available during the `DOWNLOADING` status.\n *\n * @since 8.0.0\n */\n bytesDownloaded?: number;\n\n /**\n * Total number of bytes to download.\n * Only available during the `DOWNLOADING` status.\n *\n * @since 8.0.0\n */\n totalBytesToDownload?: number;\n}\n\n/**\n * Result of an app update operation.\n *\n * @since 8.0.0\n */\nexport interface AppUpdateResult {\n /**\n * The result code of the update operation.\n *\n * @since 8.0.0\n */\n code: AppUpdateResultCode;\n}\n\n/**\n * Update availability status.\n *\n * @since 8.0.0\n */\nexport enum AppUpdateAvailability {\n /**\n * Update availability is unknown.\n * This typically means the check hasn't completed or failed.\n */\n UNKNOWN = 0,\n\n /**\n * No update is available.\n * The installed version is the latest.\n */\n UPDATE_NOT_AVAILABLE = 1,\n\n /**\n * An update is available for download.\n */\n UPDATE_AVAILABLE = 2,\n\n /**\n * An update is currently being downloaded or installed.\n */\n UPDATE_IN_PROGRESS = 3,\n}\n\n/**\n * Installation status for flexible updates (Android only).\n *\n * @since 8.0.0\n */\nexport enum FlexibleUpdateInstallStatus {\n /**\n * Unknown install status.\n */\n UNKNOWN = 0,\n\n /**\n * Download is pending and will start soon.\n */\n PENDING = 1,\n\n /**\n * Download is in progress.\n * Check `bytesDownloaded` and `totalBytesToDownload` for progress.\n */\n DOWNLOADING = 2,\n\n /**\n * The update is being installed.\n */\n INSTALLING = 3,\n\n /**\n * The update has been installed.\n * The app needs to be restarted to use the new version.\n */\n INSTALLED = 4,\n\n /**\n * The update failed to download or install.\n */\n FAILED = 5,\n\n /**\n * The update was canceled by the user.\n */\n CANCELED = 6,\n\n /**\n * The update has been downloaded and is ready to install.\n * Call {@link CapacitorUpdaterPlugin.completeFlexibleUpdate} to install.\n */\n DOWNLOADED = 11,\n}\n\n/**\n * Result codes for app update operations.\n *\n * @since 8.0.0\n */\nexport enum AppUpdateResultCode {\n /**\n * The update completed successfully.\n */\n OK = 0,\n\n /**\n * The user canceled the update.\n */\n CANCELED = 1,\n\n /**\n * The update failed.\n */\n FAILED = 2,\n\n /**\n * No update is available.\n */\n NOT_AVAILABLE = 3,\n\n /**\n * The requested update type is not allowed.\n * For example, trying to perform an immediate update when only flexible is allowed.\n */\n NOT_ALLOWED = 4,\n\n /**\n * Required information is missing.\n * This can happen if {@link CapacitorUpdaterPlugin.getAppUpdateInfo} wasn't called first.\n */\n INFO_MISSING = 5,\n}\n"]}
|
|
@@ -72,7 +72,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
72
72
|
CAPPluginMethod(name: "completeFlexibleUpdate", returnType: CAPPluginReturnPromise)
|
|
73
73
|
]
|
|
74
74
|
public var implementation = CapgoUpdater()
|
|
75
|
-
private let pluginVersion: String = "8.45.
|
|
75
|
+
private let pluginVersion: String = "8.45.8"
|
|
76
76
|
static let updateUrlDefault = "https://plugin.capgo.app/updates"
|
|
77
77
|
static let statsUrlDefault = "https://plugin.capgo.app/stats"
|
|
78
78
|
static let channelUrlDefault = "https://plugin.capgo.app/channel_self"
|
|
@@ -436,7 +436,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
436
436
|
|
|
437
437
|
let previous = UserDefaults.standard.string(forKey: "LatestNativeBuildVersion") ?? UserDefaults.standard.string(forKey: "LatestVersionNative") ?? "0"
|
|
438
438
|
if previous != "0" && self.currentBuildVersion != previous {
|
|
439
|
-
_ = self._reset(toLastSuccessful: false)
|
|
439
|
+
_ = self._reset(toLastSuccessful: false, usePendingBundle: false)
|
|
440
440
|
let res = self.implementation.list()
|
|
441
441
|
for version in res {
|
|
442
442
|
// Check if thread was cancelled
|
|
@@ -655,47 +655,77 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
655
655
|
}
|
|
656
656
|
}
|
|
657
657
|
|
|
658
|
-
|
|
659
|
-
guard let bridge = self.bridge else { return false }
|
|
660
|
-
self.semaphoreUp()
|
|
658
|
+
private func currentReloadDestination() -> URL {
|
|
661
659
|
let id = self.implementation.getCurrentBundleId()
|
|
662
|
-
let dest: URL
|
|
663
660
|
if BundleInfo.ID_BUILTIN == id {
|
|
664
|
-
|
|
661
|
+
return Bundle.main.resourceURL!.appendingPathComponent("public")
|
|
665
662
|
} else {
|
|
666
|
-
|
|
663
|
+
return self.implementation.getBundleDirectory(id: id)
|
|
667
664
|
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
private func applyCurrentBundleToBridge(_ bridge: CAPBridgeProtocol) -> Bool {
|
|
668
|
+
let id = self.implementation.getCurrentBundleId()
|
|
669
|
+
let dest = self.currentReloadDestination()
|
|
668
670
|
logger.info("Reloading \(id)")
|
|
669
671
|
|
|
670
|
-
let
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
if
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
_ = vc.webView?.load(URLRequest(url: finalUrl))
|
|
688
|
-
} else {
|
|
689
|
-
self.logger.error("Unable to build final URL when keeping path after reload; falling back to base path")
|
|
690
|
-
vc.setServerBasePath(path: dest.path)
|
|
691
|
-
}
|
|
672
|
+
guard let vc = bridge.viewController as? CAPBridgeViewController else {
|
|
673
|
+
self.logger.error("Cannot get viewController")
|
|
674
|
+
return false
|
|
675
|
+
}
|
|
676
|
+
guard let capBridge = vc.bridge else {
|
|
677
|
+
self.logger.error("Cannot get capBridge")
|
|
678
|
+
return false
|
|
679
|
+
}
|
|
680
|
+
if self.keepUrlPathAfterReload {
|
|
681
|
+
if let currentURL = vc.webView?.url {
|
|
682
|
+
capBridge.setServerBasePath(dest.path)
|
|
683
|
+
var urlComponents = URLComponents(url: capBridge.config.serverURL, resolvingAgainstBaseURL: false)!
|
|
684
|
+
urlComponents.path = currentURL.path
|
|
685
|
+
urlComponents.query = currentURL.query
|
|
686
|
+
urlComponents.fragment = currentURL.fragment
|
|
687
|
+
if let finalUrl = urlComponents.url {
|
|
688
|
+
_ = vc.webView?.load(URLRequest(url: finalUrl))
|
|
692
689
|
} else {
|
|
693
|
-
self.logger.error("
|
|
690
|
+
self.logger.error("Unable to build final URL when keeping path after reload; falling back to base path")
|
|
694
691
|
vc.setServerBasePath(path: dest.path)
|
|
695
692
|
}
|
|
696
693
|
} else {
|
|
694
|
+
self.logger.error("vc.webView?.url is null? Falling back to base path reload.")
|
|
697
695
|
vc.setServerBasePath(path: dest.path)
|
|
698
696
|
}
|
|
697
|
+
} else {
|
|
698
|
+
vc.setServerBasePath(path: dest.path)
|
|
699
|
+
}
|
|
700
|
+
return true
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
func restoreLiveBundleStateAfterFailedReload() {
|
|
704
|
+
guard let bridge = self.bridge else {
|
|
705
|
+
return
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
let restoreLiveState = {
|
|
709
|
+
_ = self.applyCurrentBundleToBridge(bridge)
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
if Thread.isMainThread {
|
|
713
|
+
restoreLiveState()
|
|
714
|
+
} else {
|
|
715
|
+
DispatchQueue.main.sync {
|
|
716
|
+
restoreLiveState()
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
public func _reload() -> Bool {
|
|
722
|
+
guard let bridge = self.bridge else { return false }
|
|
723
|
+
self.semaphoreUp()
|
|
724
|
+
|
|
725
|
+
let performReload: () -> Bool = {
|
|
726
|
+
guard self.applyCurrentBundleToBridge(bridge) else {
|
|
727
|
+
return false
|
|
728
|
+
}
|
|
699
729
|
self.checkAppReady()
|
|
700
730
|
self.notifyListeners("appReloaded", data: [:])
|
|
701
731
|
return true
|
|
@@ -713,6 +743,38 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
713
743
|
}
|
|
714
744
|
|
|
715
745
|
@objc func reload(_ call: CAPPluginCall) {
|
|
746
|
+
let current: BundleInfo = self.implementation.getCurrentBundle()
|
|
747
|
+
let next: BundleInfo? = self.implementation.getNextBundle()
|
|
748
|
+
|
|
749
|
+
if let next = next, !next.isErrorStatus(), next.getId() != current.getId() {
|
|
750
|
+
let previousState = self.implementation.captureResetState()
|
|
751
|
+
let previousBundleName = self.implementation.getCurrentBundle().getVersionName()
|
|
752
|
+
logger.info("Applying pending bundle before reload: \(next.toString())")
|
|
753
|
+
let didApplyPendingBundle: Bool
|
|
754
|
+
if next.isBuiltin() {
|
|
755
|
+
self.implementation.prepareResetStateForTransition()
|
|
756
|
+
didApplyPendingBundle = true
|
|
757
|
+
} else {
|
|
758
|
+
didApplyPendingBundle = self.implementation.stagePendingReload(bundle: next)
|
|
759
|
+
}
|
|
760
|
+
if didApplyPendingBundle && self._reload() {
|
|
761
|
+
if next.isBuiltin() {
|
|
762
|
+
self.implementation.finalizeResetTransition(previousBundleName: previousBundleName, isInternal: false)
|
|
763
|
+
} else {
|
|
764
|
+
self.implementation.finalizePendingReload(bundle: next, previousBundleName: previousBundleName)
|
|
765
|
+
}
|
|
766
|
+
self.notifyBundleSet(next)
|
|
767
|
+
_ = self.implementation.setNextBundle(next: Optional<String>.none)
|
|
768
|
+
call.resolve()
|
|
769
|
+
return
|
|
770
|
+
}
|
|
771
|
+
self.implementation.restoreResetState(previousState)
|
|
772
|
+
self.restoreLiveBundleStateAfterFailedReload()
|
|
773
|
+
logger.error("Reload failed after applying pending bundle: \(next.toString())")
|
|
774
|
+
call.reject("Reload failed after applying pending bundle")
|
|
775
|
+
return
|
|
776
|
+
}
|
|
777
|
+
|
|
716
778
|
if self._reload() {
|
|
717
779
|
call.resolve()
|
|
718
780
|
} else {
|
|
@@ -936,36 +998,90 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
936
998
|
call.resolve()
|
|
937
999
|
}
|
|
938
1000
|
|
|
939
|
-
@objc func _reset(toLastSuccessful: Bool) -> Bool {
|
|
940
|
-
|
|
1001
|
+
@objc func _reset(toLastSuccessful: Bool, usePendingBundle: Bool) -> Bool {
|
|
1002
|
+
self.performReset(toLastSuccessful: toLastSuccessful, usePendingBundle: usePendingBundle, isInternal: false)
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
func performReset(toLastSuccessful: Bool, usePendingBundle: Bool, isInternal: Bool) -> Bool {
|
|
1006
|
+
guard self.canPerformResetTransition() else { return false }
|
|
1007
|
+
|
|
1008
|
+
let fallback: BundleInfo = self.implementation.getFallbackBundle()
|
|
1009
|
+
let pending: BundleInfo? = self.implementation.getNextBundle()
|
|
1010
|
+
let previousState = self.implementation.captureResetState()
|
|
1011
|
+
let previousBundleName = self.implementation.getCurrentBundle().getVersionName()
|
|
941
1012
|
|
|
942
|
-
if
|
|
943
|
-
let
|
|
1013
|
+
if usePendingBundle {
|
|
1014
|
+
guard let pending = pending, !pending.isErrorStatus() else {
|
|
1015
|
+
logger.error("No pending bundle available to reset to")
|
|
1016
|
+
return false
|
|
1017
|
+
}
|
|
1018
|
+
guard self.implementation.canSet(bundle: pending) else {
|
|
1019
|
+
logger.error("Pending bundle is not installable")
|
|
1020
|
+
return false
|
|
1021
|
+
}
|
|
1022
|
+
self.implementation.prepareResetStateForTransition()
|
|
1023
|
+
logger.info("Resetting to pending bundle: \(pending.toString())")
|
|
1024
|
+
let didApplyPendingBundle: Bool
|
|
1025
|
+
if pending.isBuiltin() {
|
|
1026
|
+
didApplyPendingBundle = true
|
|
1027
|
+
} else {
|
|
1028
|
+
didApplyPendingBundle = self.implementation.set(bundle: pending)
|
|
1029
|
+
}
|
|
1030
|
+
if didApplyPendingBundle && self._reload() {
|
|
1031
|
+
self.implementation.finalizeResetTransition(previousBundleName: previousBundleName, isInternal: isInternal)
|
|
1032
|
+
self.notifyBundleSet(pending)
|
|
1033
|
+
_ = self.implementation.setNextBundle(next: Optional<String>.none)
|
|
1034
|
+
return true
|
|
1035
|
+
}
|
|
1036
|
+
self.implementation.restoreResetState(previousState)
|
|
1037
|
+
self.restoreLiveBundleStateAfterFailedReload()
|
|
1038
|
+
return false
|
|
1039
|
+
}
|
|
944
1040
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
1041
|
+
// If developer wants to reset to the last successful bundle, and that bundle is not
|
|
1042
|
+
// the built-in bundle, set it as the bundle to use and reload.
|
|
1043
|
+
if toLastSuccessful && !fallback.isBuiltin() {
|
|
1044
|
+
if self.implementation.canSet(bundle: fallback) {
|
|
1045
|
+
self.implementation.prepareResetStateForTransition()
|
|
948
1046
|
logger.info("Resetting to: \(fallback.toString())")
|
|
949
1047
|
if self.implementation.set(bundle: fallback) && self._reload() {
|
|
1048
|
+
self.implementation.finalizeResetTransition(previousBundleName: previousBundleName, isInternal: isInternal)
|
|
950
1049
|
self.notifyBundleSet(fallback)
|
|
951
1050
|
return true
|
|
952
1051
|
}
|
|
953
|
-
|
|
1052
|
+
if !isInternal {
|
|
1053
|
+
self.implementation.restoreResetState(previousState)
|
|
1054
|
+
self.restoreLiveBundleStateAfterFailedReload()
|
|
1055
|
+
return false
|
|
1056
|
+
}
|
|
1057
|
+
logger.warn("Fallback reload failed during internal reset, resetting to builtin instead")
|
|
1058
|
+
} else {
|
|
1059
|
+
logger.warn("Fallback bundle is not installable, resetting to builtin instead")
|
|
954
1060
|
}
|
|
955
|
-
|
|
956
|
-
logger.info("Resetting to builtin version")
|
|
957
|
-
|
|
958
|
-
// Otherwise, reset back to the built-in bundle and reload.
|
|
959
|
-
self.implementation.reset()
|
|
960
|
-
return self._reload()
|
|
961
1061
|
}
|
|
962
1062
|
|
|
1063
|
+
self.implementation.prepareResetStateForTransition()
|
|
1064
|
+
logger.info("Resetting to builtin version")
|
|
1065
|
+
if self._reload() {
|
|
1066
|
+
self.implementation.finalizeResetTransition(previousBundleName: previousBundleName, isInternal: isInternal)
|
|
1067
|
+
return true
|
|
1068
|
+
}
|
|
1069
|
+
if !isInternal {
|
|
1070
|
+
self.implementation.restoreResetState(previousState)
|
|
1071
|
+
self.restoreLiveBundleStateAfterFailedReload()
|
|
1072
|
+
}
|
|
963
1073
|
return false
|
|
964
1074
|
}
|
|
965
1075
|
|
|
1076
|
+
func canPerformResetTransition() -> Bool {
|
|
1077
|
+
guard let bridge = self.bridge else { return false }
|
|
1078
|
+
return (bridge.viewController as? CAPBridgeViewController) != nil
|
|
1079
|
+
}
|
|
1080
|
+
|
|
966
1081
|
@objc func reset(_ call: CAPPluginCall) {
|
|
967
1082
|
let toLastSuccessful = call.getBool("toLastSuccessful") ?? false
|
|
968
|
-
|
|
1083
|
+
let usePendingBundle = call.getBool("usePendingBundle") ?? false
|
|
1084
|
+
if self._reset(toLastSuccessful: toLastSuccessful, usePendingBundle: usePendingBundle) {
|
|
969
1085
|
call.resolve()
|
|
970
1086
|
} else {
|
|
971
1087
|
logger.error("Reset failed")
|
|
@@ -1084,7 +1200,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1084
1200
|
self.persistLastFailedBundle(current)
|
|
1085
1201
|
self.implementation.sendStats(action: "update_fail", versionName: current.getVersionName())
|
|
1086
1202
|
self.implementation.setError(bundle: current)
|
|
1087
|
-
_ = self.
|
|
1203
|
+
_ = self.performReset(toLastSuccessful: true, usePendingBundle: false, isInternal: true)
|
|
1088
1204
|
if self.autoDeleteFailed && !current.isBuiltin() {
|
|
1089
1205
|
logger.info("Deleting failing bundle: \(current.toString())")
|
|
1090
1206
|
let res = self.implementation.delete(id: current.getId(), removeInfo: false)
|
|
@@ -1609,7 +1725,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
1609
1725
|
let directUpdateAllowed = plannedDirectUpdate && !self.autoSplashscreenTimedOut
|
|
1610
1726
|
if directUpdateAllowed {
|
|
1611
1727
|
self.logger.info("Direct update to builtin version")
|
|
1612
|
-
_ = self._reset(toLastSuccessful: false)
|
|
1728
|
+
_ = self._reset(toLastSuccessful: false, usePendingBundle: false)
|
|
1613
1729
|
self.endBackGroundTaskWithNotif(
|
|
1614
1730
|
msg: "Updated to builtin version",
|
|
1615
1731
|
latestVersionName: res.version,
|
|
@@ -54,10 +54,31 @@ import UIKit
|
|
|
54
54
|
private var statsFlushTimer: Timer?
|
|
55
55
|
private static let statsFlushInterval: TimeInterval = 1.0
|
|
56
56
|
|
|
57
|
+
private static func sanitizeHeaderValue(_ value: String) -> String {
|
|
58
|
+
if value.isEmpty {
|
|
59
|
+
return "unknown"
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let filteredScalars = value.unicodeScalars.filter { scalar in
|
|
63
|
+
let cp = scalar.value
|
|
64
|
+
let isVisibleAscii = (0x20...0x7E).contains(cp)
|
|
65
|
+
let isIso88591 = (0xA0...0xFF).contains(cp)
|
|
66
|
+
return isVisibleAscii || isIso88591
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let sanitized = String(String.UnicodeScalarView(filteredScalars)).trimmingCharacters(in: .whitespacesAndNewlines)
|
|
70
|
+
return sanitized.isEmpty ? "unknown" : sanitized
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static func buildUserAgent(appId: String, pluginVersion: String, versionOs: String) -> String {
|
|
74
|
+
let safePluginVersion = sanitizeHeaderValue(pluginVersion)
|
|
75
|
+
let safeAppId = sanitizeHeaderValue(appId)
|
|
76
|
+
let safeVersionOs = sanitizeHeaderValue(versionOs)
|
|
77
|
+
return "CapacitorUpdater/\(safePluginVersion) (\(safeAppId)) ios/\(safeVersionOs)"
|
|
78
|
+
}
|
|
79
|
+
|
|
57
80
|
private var userAgent: String {
|
|
58
|
-
|
|
59
|
-
let safeAppId = appId.isEmpty ? "unknown" : appId
|
|
60
|
-
return "CapacitorUpdater/\(safePluginVersion) (\(safeAppId)) ios/\(versionOs)"
|
|
81
|
+
CapgoUpdater.buildUserAgent(appId: appId, pluginVersion: pluginVersion, versionOs: versionOs)
|
|
61
82
|
}
|
|
62
83
|
|
|
63
84
|
private lazy var alamofireSession: Session = {
|
|
@@ -1459,6 +1480,52 @@ import UIKit
|
|
|
1459
1480
|
return libraryDir.appendingPathComponent(self.bundleDirectory).appendingPathComponent(id)
|
|
1460
1481
|
}
|
|
1461
1482
|
|
|
1483
|
+
struct ResetState {
|
|
1484
|
+
let currentBundlePath: String
|
|
1485
|
+
let fallbackBundleId: String
|
|
1486
|
+
let nextBundleId: String?
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
func captureResetState() -> ResetState {
|
|
1490
|
+
ResetState(
|
|
1491
|
+
currentBundlePath: UserDefaults.standard.string(forKey: self.CAP_SERVER_PATH) ?? self.DEFAULT_FOLDER,
|
|
1492
|
+
fallbackBundleId: UserDefaults.standard.string(forKey: self.FALLBACK_VERSION) ?? BundleInfo.ID_BUILTIN,
|
|
1493
|
+
nextBundleId: UserDefaults.standard.string(forKey: self.NEXT_VERSION)
|
|
1494
|
+
)
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
func restoreResetState(_ state: ResetState) {
|
|
1498
|
+
let currentBundlePath = state.currentBundlePath.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
|
1499
|
+
? self.DEFAULT_FOLDER
|
|
1500
|
+
: state.currentBundlePath
|
|
1501
|
+
let fallbackBundleId = state.fallbackBundleId.isEmpty ? BundleInfo.ID_BUILTIN : state.fallbackBundleId
|
|
1502
|
+
|
|
1503
|
+
self.setCurrentBundle(bundle: currentBundlePath)
|
|
1504
|
+
UserDefaults.standard.set(fallbackBundleId, forKey: self.FALLBACK_VERSION)
|
|
1505
|
+
if let nextBundleId = state.nextBundleId, !nextBundleId.isEmpty {
|
|
1506
|
+
UserDefaults.standard.set(nextBundleId, forKey: self.NEXT_VERSION)
|
|
1507
|
+
} else {
|
|
1508
|
+
UserDefaults.standard.removeObject(forKey: self.NEXT_VERSION)
|
|
1509
|
+
}
|
|
1510
|
+
UserDefaults.standard.synchronize()
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
func prepareResetStateForTransition() {
|
|
1514
|
+
self.setCurrentBundle(bundle: "")
|
|
1515
|
+
self.setFallbackBundle(fallback: Optional<BundleInfo>.none)
|
|
1516
|
+
_ = self.setNextBundle(next: Optional<String>.none)
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
func finalizeResetTransition(previousBundleName: String, isInternal: Bool) {
|
|
1520
|
+
if !isInternal {
|
|
1521
|
+
self.sendStats(action: "reset", versionName: self.getCurrentBundle().getVersionName(), oldVersionName: previousBundleName)
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
func canSet(bundle: BundleInfo) -> Bool {
|
|
1526
|
+
bundle.isBuiltin() || self.bundleExists(id: bundle.getId())
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1462
1529
|
public func set(bundle: BundleInfo) -> Bool {
|
|
1463
1530
|
return self.set(id: bundle.getId())
|
|
1464
1531
|
}
|
|
@@ -1496,6 +1563,21 @@ import UIKit
|
|
|
1496
1563
|
return false
|
|
1497
1564
|
}
|
|
1498
1565
|
|
|
1566
|
+
func stagePendingReload(bundle: BundleInfo) -> Bool {
|
|
1567
|
+
guard !bundle.isBuiltin(), bundleExists(id: bundle.getId()) else {
|
|
1568
|
+
return false
|
|
1569
|
+
}
|
|
1570
|
+
self.setCurrentBundle(bundle: self.getBundleDirectory(id: bundle.getId()).path)
|
|
1571
|
+
return true
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
func finalizePendingReload(bundle: BundleInfo, previousBundleName: String) {
|
|
1575
|
+
guard !bundle.isBuiltin() else {
|
|
1576
|
+
return
|
|
1577
|
+
}
|
|
1578
|
+
self.sendStats(action: "set", versionName: bundle.getVersionName(), oldVersionName: previousBundleName)
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1499
1581
|
public func autoReset() {
|
|
1500
1582
|
let currentBundle: BundleInfo = self.getCurrentBundle()
|
|
1501
1583
|
if !currentBundle.isBuiltin() && !self.bundleExists(id: currentBundle.getId()) {
|
|
@@ -1521,12 +1603,8 @@ import UIKit
|
|
|
1521
1603
|
public func reset(isInternal: Bool) {
|
|
1522
1604
|
logger.info("reset: \(isInternal)")
|
|
1523
1605
|
let currentBundleName = self.getCurrentBundle().getVersionName()
|
|
1524
|
-
self.
|
|
1525
|
-
self.
|
|
1526
|
-
_ = self.setNextBundle(next: Optional<String>.none)
|
|
1527
|
-
if !isInternal {
|
|
1528
|
-
self.sendStats(action: "reset", versionName: self.getCurrentBundle().getVersionName(), oldVersionName: currentBundleName)
|
|
1529
|
-
}
|
|
1606
|
+
self.prepareResetStateForTransition()
|
|
1607
|
+
self.finalizeResetTransition(previousBundleName: currentBundleName, isInternal: isInternal)
|
|
1530
1608
|
}
|
|
1531
1609
|
|
|
1532
1610
|
public func setSuccess(bundle: BundleInfo, autoDeletePrevious: Bool) {
|