@capgo/capacitor-updater 8.47.3 → 8.47.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2200,9 +2200,10 @@ If you don't use backend, you need to provide the URL and version of the bundle.
2200
2200
 
2201
2201
  ##### StartPreviewSessionOptions
2202
2202
 
2203
- | Prop | Type | Description | Default | Since |
2204
- | ----------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ------ |
2205
- | **`appId`** | <code>string</code> | App id to use while the preview session is active. The previous app id is restored when leaving the preview session. Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`. | <code>undefined</code> | 8.47.0 |
2203
+ | Prop | Type | Description | Default | Since |
2204
+ | ---------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ------ |
2205
+ | **`appId`** | <code>string</code> | App id to use while the preview session is active. The previous app id is restored when leaving the preview session. Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`. | <code>undefined</code> | 8.47.0 |
2206
+ | **`payloadUrl`** | <code>string</code> | HTTP(S) URL returning a preview download payload. When provided, the native shake reload action fetches this payload again before reloading so channel previews can move to the latest bundle. Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`. | <code>undefined</code> | 8.48.0 |
2206
2207
 
2207
2208
 
2208
2209
  ##### BundleListResult
@@ -49,9 +49,13 @@ import com.google.android.play.core.install.model.AppUpdateType;
49
49
  import com.google.android.play.core.install.model.InstallStatus;
50
50
  import com.google.android.play.core.install.model.UpdateAvailability;
51
51
  import io.github.g00fy2.versioncompare.Version;
52
+ import java.io.ByteArrayOutputStream;
52
53
  import java.io.IOException;
54
+ import java.io.InputStream;
55
+ import java.net.HttpURLConnection;
53
56
  import java.net.MalformedURLException;
54
57
  import java.net.URL;
58
+ import java.nio.charset.StandardCharsets;
55
59
  import java.util.ArrayList;
56
60
  import java.util.Date;
57
61
  import java.util.HashMap;
@@ -98,7 +102,10 @@ public class CapacitorUpdaterPlugin extends Plugin {
98
102
  private static final String PREVIEW_PREVIOUS_SHAKE_CHANNEL_SELECTOR_PREF_KEY = "CapacitorUpdater.previewPreviousShakeChannelSelector";
99
103
  private static final String PREVIEW_PREVIOUS_NEXT_BUNDLE_PREF_KEY = "CapacitorUpdater.previewPreviousNextBundle";
100
104
  private static final String PREVIEW_PREVIOUS_APP_ID_PREF_KEY = "CapacitorUpdater.previewPreviousAppId";
105
+ private static final String PREVIEW_PREVIOUS_DEFAULT_CHANNEL_PREF_KEY = "CapacitorUpdater.previewPreviousDefaultChannel";
106
+ private static final String PREVIEW_PREVIOUS_DEFAULT_CHANNEL_WAS_SET_PREF_KEY = "CapacitorUpdater.previewPreviousDefaultChannelWasSet";
101
107
  private static final String PREVIEW_APP_ID_PREF_KEY = "CapacitorUpdater.previewAppId";
108
+ private static final String PREVIEW_PAYLOAD_URL_PREF_KEY = "CapacitorUpdater.previewPayloadUrl";
102
109
  private static final String[] BREAKING_EVENT_NAMES = { "breakingAvailable", "majorAvailable" };
103
110
  private static final String LAST_FAILED_BUNDLE_PREF_KEY = "CapacitorUpdater.lastFailedBundle";
104
111
  private static final String LAST_REPORTED_APP_EXIT_TIMESTAMP_PREF_KEY = "CapacitorUpdater.lastReportedAppExitTimestamp";
@@ -120,7 +127,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
120
127
  static final int APPLICATION_EXIT_REASON_USER_REQUESTED = 10;
121
128
  static final int APPLICATION_EXIT_REASON_DEPENDENCY_DIED = 12;
122
129
 
123
- private final String pluginVersion = "8.47.3";
130
+ private final String pluginVersion = "8.47.4";
124
131
  private static final String DELAY_CONDITION_PREFERENCES = "";
125
132
 
126
133
  private SharedPreferences.Editor editor;
@@ -1930,6 +1937,20 @@ public class CapacitorUpdaterPlugin extends Plugin {
1930
1937
  }
1931
1938
  }
1932
1939
 
1940
+ private BundleInfo downloadBundle(
1941
+ final String url,
1942
+ final String version,
1943
+ final String sessionKey,
1944
+ final String checksum,
1945
+ final JSONArray manifest
1946
+ ) throws IOException {
1947
+ if (manifest != null) {
1948
+ return this.implementation.downloadManifest(url, version, sessionKey, checksum, manifest);
1949
+ }
1950
+
1951
+ return this.implementation.download(url, version, sessionKey, checksum);
1952
+ }
1953
+
1933
1954
  @PluginMethod
1934
1955
  public void download(final PluginCall call) {
1935
1956
  final String url = call.getString("url");
@@ -1951,20 +1972,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
1951
1972
  logger.info("Downloading " + url);
1952
1973
  startNewThread(() -> {
1953
1974
  try {
1954
- final BundleInfo downloaded;
1955
- if (manifest != null) {
1956
- // For manifest downloads, we need to handle this asynchronously
1957
- // to avoid automatically scheduling/applying the downloaded bundle.
1958
- // Manual download must not schedule/apply the bundle automatically.
1959
- CapacitorUpdaterPlugin.this.implementation.downloadBackground(url, version, sessionKey, checksum, manifest, false);
1960
- // Return immediately with a pending status - the actual result will come via listeners
1961
- final String id = CapacitorUpdaterPlugin.this.implementation.randomString();
1962
- downloaded = new BundleInfo(id, version, BundleStatus.DOWNLOADING, new Date(System.currentTimeMillis()), "");
1963
- call.resolve(InternalUtils.mapToJSObject(downloaded.toJSONMap()));
1964
- return;
1965
- } else {
1966
- downloaded = CapacitorUpdaterPlugin.this.implementation.download(url, version, sessionKey, checksum);
1967
- }
1975
+ final BundleInfo downloaded = this.downloadBundle(url, version, sessionKey, checksum, manifest);
1968
1976
  if (downloaded.isErrorStatus()) {
1969
1977
  throw new RuntimeException("Download failed: " + downloaded.getStatus());
1970
1978
  } else {
@@ -2231,6 +2239,13 @@ public class CapacitorUpdaterPlugin extends Plugin {
2231
2239
  return;
2232
2240
  }
2233
2241
  final String previewAppId = this.normalizePreviewAppId(call.getString("appId"));
2242
+ final String rawPayloadUrl = call.getString("payloadUrl");
2243
+ final String previewPayloadUrl = this.normalizePreviewPayloadUrl(rawPayloadUrl);
2244
+ if (this.hasPreviewPayloadUrl(rawPayloadUrl) && previewPayloadUrl == null) {
2245
+ logger.error("startPreviewSession called with invalid payloadUrl");
2246
+ call.reject("Invalid preview payloadUrl");
2247
+ return;
2248
+ }
2234
2249
  startNewThread(() -> {
2235
2250
  try {
2236
2251
  if (!Boolean.TRUE.equals(this.previewSessionEnabled)) {
@@ -2249,6 +2264,16 @@ public class CapacitorUpdaterPlugin extends Plugin {
2249
2264
  }
2250
2265
 
2251
2266
  this.editor.putString(PREVIEW_PREVIOUS_APP_ID_PREF_KEY, this.implementation.appId);
2267
+ if (this.prefs.contains(DEFAULT_CHANNEL_PREF_KEY)) {
2268
+ this.editor.putString(
2269
+ PREVIEW_PREVIOUS_DEFAULT_CHANNEL_PREF_KEY,
2270
+ this.prefs.getString(DEFAULT_CHANNEL_PREF_KEY, "")
2271
+ );
2272
+ this.editor.putBoolean(PREVIEW_PREVIOUS_DEFAULT_CHANNEL_WAS_SET_PREF_KEY, true);
2273
+ } else {
2274
+ this.editor.remove(PREVIEW_PREVIOUS_DEFAULT_CHANNEL_PREF_KEY);
2275
+ this.editor.putBoolean(PREVIEW_PREVIOUS_DEFAULT_CHANNEL_WAS_SET_PREF_KEY, false);
2276
+ }
2252
2277
  this.editor.putBoolean(PREVIEW_PREVIOUS_SHAKE_MENU_PREF_KEY, Boolean.TRUE.equals(this.shakeMenuEnabled));
2253
2278
  this.editor.putBoolean(
2254
2279
  PREVIEW_PREVIOUS_SHAKE_CHANNEL_SELECTOR_PREF_KEY,
@@ -2263,6 +2288,13 @@ public class CapacitorUpdaterPlugin extends Plugin {
2263
2288
  logger.info("Preview session using appId: " + previewAppId);
2264
2289
  }
2265
2290
 
2291
+ if (previewPayloadUrl != null) {
2292
+ this.editor.putString(PREVIEW_PAYLOAD_URL_PREF_KEY, previewPayloadUrl);
2293
+ logger.info("Preview session using payload URL");
2294
+ } else {
2295
+ this.editor.remove(PREVIEW_PAYLOAD_URL_PREF_KEY);
2296
+ }
2297
+
2266
2298
  this.previewSessionEnabled = true;
2267
2299
  this.previewSessionAlertPending = true;
2268
2300
  this.implementation.previewSession = true;
@@ -2287,9 +2319,6 @@ public class CapacitorUpdaterPlugin extends Plugin {
2287
2319
  return false;
2288
2320
  }
2289
2321
 
2290
- if (!this.clearPreviewChannelOverride()) {
2291
- return false;
2292
- }
2293
2322
  final BundleInfo previewFallbackBundle = this.implementation.getPreviewFallbackBundle();
2294
2323
  this.endPreviewSession();
2295
2324
  final BundleInfo restoredNextBundle = this.implementation.getNextBundle();
@@ -2308,6 +2337,11 @@ public class CapacitorUpdaterPlugin extends Plugin {
2308
2337
  }
2309
2338
 
2310
2339
  public boolean reloadPreviewSessionFromShakeMenu() {
2340
+ final String payloadUrl = this.storedPreviewPayloadUrl();
2341
+ if (payloadUrl != null) {
2342
+ return this.refreshPreviewSessionFromPayloadUrl(payloadUrl);
2343
+ }
2344
+
2311
2345
  return this._reload();
2312
2346
  }
2313
2347
 
@@ -2350,6 +2384,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
2350
2384
  );
2351
2385
  this.restorePreviewPreviousNextBundle();
2352
2386
  this.restorePreviewPreviousAppId();
2387
+ this.restorePreviewPreviousDefaultChannel();
2353
2388
 
2354
2389
  this.previewSessionEnabled = false;
2355
2390
  this.previewSessionAlertPending = false;
@@ -2376,6 +2411,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
2376
2411
 
2377
2412
  this.restorePreviewPreviousNextBundle();
2378
2413
  this.restorePreviewPreviousAppId();
2414
+ this.restorePreviewPreviousDefaultChannel();
2379
2415
  this.previewSessionEnabled = false;
2380
2416
  this.previewSessionAlertPending = false;
2381
2417
  this.implementation.previewSession = false;
@@ -2393,7 +2429,10 @@ public class CapacitorUpdaterPlugin extends Plugin {
2393
2429
  this.editor.remove(PREVIEW_PREVIOUS_SHAKE_CHANNEL_SELECTOR_PREF_KEY);
2394
2430
  this.editor.remove(PREVIEW_PREVIOUS_NEXT_BUNDLE_PREF_KEY);
2395
2431
  this.editor.remove(PREVIEW_PREVIOUS_APP_ID_PREF_KEY);
2432
+ this.editor.remove(PREVIEW_PREVIOUS_DEFAULT_CHANNEL_PREF_KEY);
2433
+ this.editor.remove(PREVIEW_PREVIOUS_DEFAULT_CHANNEL_WAS_SET_PREF_KEY);
2396
2434
  this.editor.remove(PREVIEW_APP_ID_PREF_KEY);
2435
+ this.editor.remove(PREVIEW_PAYLOAD_URL_PREF_KEY);
2397
2436
  this.editor.apply();
2398
2437
  }
2399
2438
 
@@ -2413,6 +2452,23 @@ public class CapacitorUpdaterPlugin extends Plugin {
2413
2452
  logger.info("Restored appId after preview: " + previousAppId);
2414
2453
  }
2415
2454
 
2455
+ private void restorePreviewPreviousDefaultChannel() {
2456
+ final String configDefaultChannel = this.getConfig().getString("defaultChannel", "");
2457
+ if (this.prefs.getBoolean(PREVIEW_PREVIOUS_DEFAULT_CHANNEL_WAS_SET_PREF_KEY, false)) {
2458
+ final String previousDefaultChannel = this.prefs.getString(PREVIEW_PREVIOUS_DEFAULT_CHANNEL_PREF_KEY, "");
2459
+ this.editor.putString(DEFAULT_CHANNEL_PREF_KEY, previousDefaultChannel);
2460
+ this.implementation.defaultChannel = previousDefaultChannel;
2461
+ this.editor.apply();
2462
+ logger.info("Restored defaultChannel after preview");
2463
+ return;
2464
+ }
2465
+
2466
+ this.editor.remove(DEFAULT_CHANNEL_PREF_KEY);
2467
+ this.implementation.defaultChannel = configDefaultChannel;
2468
+ this.editor.apply();
2469
+ logger.info("Restored defaultChannel after preview to config value");
2470
+ }
2471
+
2416
2472
  private String normalizePreviewAppId(final String rawAppId) {
2417
2473
  if (rawAppId == null) {
2418
2474
  return null;
@@ -2431,6 +2487,131 @@ public class CapacitorUpdaterPlugin extends Plugin {
2431
2487
  return appId;
2432
2488
  }
2433
2489
 
2490
+ private boolean hasPreviewPayloadUrl(final String rawPayloadUrl) {
2491
+ if (rawPayloadUrl == null) {
2492
+ return false;
2493
+ }
2494
+
2495
+ final String payloadUrl = rawPayloadUrl.trim();
2496
+ if (payloadUrl.isEmpty()) {
2497
+ return false;
2498
+ }
2499
+
2500
+ final String lowercasedPayloadUrl = payloadUrl.toLowerCase(java.util.Locale.ROOT);
2501
+ return !"undefined".equals(lowercasedPayloadUrl) && !"null".equals(lowercasedPayloadUrl);
2502
+ }
2503
+
2504
+ private String normalizePreviewPayloadUrl(final String rawPayloadUrl) {
2505
+ if (!this.hasPreviewPayloadUrl(rawPayloadUrl)) {
2506
+ return null;
2507
+ }
2508
+
2509
+ final String payloadUrl = rawPayloadUrl.trim();
2510
+ try {
2511
+ final URL parsedUrl = new URL(payloadUrl);
2512
+ final String protocol = parsedUrl.getProtocol();
2513
+ if (!"https".equals(protocol) && !"http".equals(protocol)) {
2514
+ return null;
2515
+ }
2516
+ return parsedUrl.toString();
2517
+ } catch (final MalformedURLException ignored) {
2518
+ return null;
2519
+ }
2520
+ }
2521
+
2522
+ private String storedPreviewPayloadUrl() {
2523
+ return this.normalizePreviewPayloadUrl(this.prefs.getString(PREVIEW_PAYLOAD_URL_PREF_KEY, null));
2524
+ }
2525
+
2526
+ private String readResponseBody(final InputStream stream) throws IOException {
2527
+ if (stream == null) {
2528
+ return "";
2529
+ }
2530
+
2531
+ try (InputStream input = stream; ByteArrayOutputStream output = new ByteArrayOutputStream()) {
2532
+ final byte[] buffer = new byte[8192];
2533
+ int read;
2534
+ while ((read = input.read(buffer)) != -1) {
2535
+ output.write(buffer, 0, read);
2536
+ }
2537
+ return output.toString(StandardCharsets.UTF_8.name());
2538
+ }
2539
+ }
2540
+
2541
+ private JSONObject fetchPreviewPayload(final String payloadUrl) throws IOException, JSONException {
2542
+ final HttpURLConnection connection = (HttpURLConnection) new URL(payloadUrl).openConnection();
2543
+ connection.setRequestMethod("GET");
2544
+ connection.setRequestProperty("Accept", "application/json");
2545
+ connection.setConnectTimeout(30000);
2546
+ connection.setReadTimeout(60000);
2547
+
2548
+ try {
2549
+ final int statusCode = connection.getResponseCode();
2550
+ final String body = this.readResponseBody(
2551
+ statusCode >= 200 && statusCode < 300 ? connection.getInputStream() : connection.getErrorStream()
2552
+ );
2553
+ final JSONObject payload = new JSONObject(body);
2554
+ if (statusCode < 200 || statusCode >= 300) {
2555
+ throw new IOException(
2556
+ payload.optString("message", payload.optString("error", "Preview payload request failed with HTTP " + statusCode))
2557
+ );
2558
+ }
2559
+ return payload;
2560
+ } finally {
2561
+ connection.disconnect();
2562
+ }
2563
+ }
2564
+
2565
+ private BundleInfo downloadPreviewPayloadBundle(final JSONObject payload) throws IOException, JSONException {
2566
+ final String version = payload.optString("version", "").trim();
2567
+ if (version.isEmpty()) {
2568
+ throw new IOException("Preview payload is missing a version");
2569
+ }
2570
+
2571
+ final JSONArray manifest = payload.optJSONArray("manifest");
2572
+ final String url = payload.optString("url", "");
2573
+ if ((url == null || url.isEmpty()) && (manifest == null || manifest.length() == 0)) {
2574
+ throw new IOException("Preview payload is missing download information");
2575
+ }
2576
+
2577
+ return this.downloadBundle(
2578
+ url == null || url.isEmpty() ? "https://404.capgo.app/no.zip" : url,
2579
+ version,
2580
+ payload.optString("sessionKey", ""),
2581
+ payload.optString("checksum", ""),
2582
+ manifest
2583
+ );
2584
+ }
2585
+
2586
+ private boolean refreshPreviewSessionFromPayloadUrl(final String payloadUrl) {
2587
+ try {
2588
+ final JSONObject payload = this.fetchPreviewPayload(payloadUrl);
2589
+ final String version = payload.optString("version", "").trim();
2590
+ if (version.isEmpty()) {
2591
+ throw new IOException("Preview payload is missing a version");
2592
+ }
2593
+
2594
+ if (version.equals(this.implementation.getCurrentBundle().getVersionName())) {
2595
+ logger.info("Preview payload unchanged, reloading current bundle");
2596
+ return this._reload();
2597
+ }
2598
+
2599
+ final BundleInfo next = this.downloadPreviewPayloadBundle(payload);
2600
+ if (next.isErrorStatus()) {
2601
+ throw new IOException("Download failed: " + next.getStatus());
2602
+ }
2603
+ if (!this.implementation.set(next.getId())) {
2604
+ throw new IOException("Downloaded preview bundle cannot be applied");
2605
+ }
2606
+
2607
+ this.notifyBundleSet(next);
2608
+ return this._reload();
2609
+ } catch (final Exception err) {
2610
+ logger.error("Could not refresh preview session: " + err.getMessage());
2611
+ return false;
2612
+ }
2613
+ }
2614
+
2434
2615
  private void clearPreviewSessionForNativeBuildChange() {
2435
2616
  if (!Boolean.TRUE.equals(this.previewSessionEnabled) && this.implementation.getPreviewFallbackBundle() == null) {
2436
2617
  return;
@@ -2442,35 +2623,12 @@ public class CapacitorUpdaterPlugin extends Plugin {
2442
2623
  this.shakeMenuEnabled = this.getConfig().getBoolean("shakeMenu", false);
2443
2624
  this.shakeChannelSelectorEnabled = this.getConfig().getBoolean("allowShakeChannelSelector", false);
2444
2625
  this.restorePreviewPreviousAppId();
2626
+ this.restorePreviewPreviousDefaultChannel();
2445
2627
  this.implementation.setPreviewFallbackBundle(null);
2446
2628
  this.implementation.setNextBundle(null);
2447
- this.clearPreviewChannelOverride();
2448
2629
  this.clearPreviewSessionPreferences();
2449
2630
  }
2450
2631
 
2451
- private boolean clearPreviewChannelOverride() {
2452
- final String configDefaultChannel = this.getConfig().getString("defaultChannel", "");
2453
- final AtomicReference<Map<String, Object>> unsetChannelResult = new AtomicReference<>();
2454
- try {
2455
- this.implementation.unsetChannel(this.editor, DEFAULT_CHANNEL_PREF_KEY, configDefaultChannel, unsetChannelResult::set);
2456
- } catch (final Exception err) {
2457
- logger.error("Could not clear preview channel override: " + err.getMessage());
2458
- return false;
2459
- }
2460
-
2461
- final Map<String, Object> result = unsetChannelResult.get();
2462
- if (result == null) {
2463
- logger.error("Could not clear preview channel override: no result");
2464
- return false;
2465
- }
2466
- if (result.containsKey("error")) {
2467
- final Object message = result.getOrDefault("message", result.get("error"));
2468
- logger.error("Could not clear preview channel override: " + message);
2469
- return false;
2470
- }
2471
- return true;
2472
- }
2473
-
2474
2632
  private void restorePreviewPreviousNextBundle() {
2475
2633
  final String previousNextBundleId = this.prefs.getString(PREVIEW_PREVIOUS_NEXT_BUNDLE_PREF_KEY, null);
2476
2634
  if (previousNextBundleId == null || previousNextBundleId.isEmpty()) {
package/dist/docs.json CHANGED
@@ -1991,6 +1991,22 @@
1991
1991
  "docs": "App id to use while the preview session is active.\nThe previous app id is restored when leaving the preview session.\nRequires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.",
1992
1992
  "complexTypes": [],
1993
1993
  "type": "string | undefined"
1994
+ },
1995
+ {
1996
+ "name": "payloadUrl",
1997
+ "tags": [
1998
+ {
1999
+ "text": "8.48.0",
2000
+ "name": "since"
2001
+ },
2002
+ {
2003
+ "text": "undefined",
2004
+ "name": "default"
2005
+ }
2006
+ ],
2007
+ "docs": "HTTP(S) URL returning a preview download payload.\nWhen provided, the native shake reload action fetches this payload again\nbefore reloading so channel previews can move to the latest bundle.\nRequires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.",
2008
+ "complexTypes": [],
2009
+ "type": "string | undefined"
1994
2010
  }
1995
2011
  ]
1996
2012
  },
@@ -1973,6 +1973,15 @@ export interface StartPreviewSessionOptions {
1973
1973
  * @default undefined
1974
1974
  */
1975
1975
  appId?: string;
1976
+ /**
1977
+ * HTTP(S) URL returning a preview download payload.
1978
+ * When provided, the native shake reload action fetches this payload again
1979
+ * before reloading so channel previews can move to the latest bundle.
1980
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.
1981
+ * @since 8.48.0
1982
+ * @default undefined
1983
+ */
1984
+ payloadUrl?: string;
1976
1985
  }
1977
1986
  export interface AppReadyResult {
1978
1987
  bundle: BundleInfo;
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAs8EH;;;;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 how the plugin should use Auto Update via an update server.\n *\n * Boolean values keep their existing behavior:\n * - `true`: Same as `\"atBackground\"`.\n * - `false`: Same as `\"off\"`.\n *\n * String values merge the previous Auto Update and Direct Update configuration:\n * - `\"off\"`: Disable Auto Update.\n * - `\"atBackground\"`: Check and download updates automatically, then apply them the next time the app moves to background.\n * - `\"atInstall\"`: Direct install only after app install or native app update, otherwise use `\"atBackground\"` behavior.\n * - `\"onLaunch\"`: Direct install on app launch, otherwise use `\"atBackground\"` behavior after the first launch attempt.\n * - `\"always\"`: Direct install whenever Auto Update runs.\n * - `\"onlyDownload\"`: Check and download updates automatically, emit `updateAvailable`, but never direct install or set the next bundle automatically.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example \"onlyDownload\"\n */\n autoUpdate?: boolean | 'off' | 'atBackground' | 'atInstall' | 'onLaunch' | 'always' | 'onlyDownload';\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 * Native stats include update lifecycle events, app health signals such as crashes,\n * Android ANRs, low-memory exits, iOS memory warnings, and WebView health signals\n * such as JavaScript errors, unhandled promise rejections, resource load failures,\n * WebView renderer exits, and unclean WebView restarts when available.\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 *\n * @deprecated Use {@link PluginsConfig.CapacitorUpdater.autoUpdate} string modes instead.\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 autoUpdate is set to \"atInstall\", \"always\", or \"onLaunch\", or when the deprecated directUpdate option 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 Auto Update and Direct Update behavior 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 * Allow JavaScript to start a native preview session and temporarily request updates for another app id.\n * This is intended for trusted container apps that implement Expo Go-style preview flows.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 8.47.0\n */\n allowPreview?: 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 * Start a temporary preview/testing session.\n *\n * This stores the currently active bundle as the pending fallback, enables the\n * native shake menu, and makes the next applied bundle show a native notice\n * explaining that shaking the device can reload or leave the preview.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.\n * When `appId` is provided, the preview session temporarily uses that app id\n * for update checks until the user leaves the preview. Native updater stats are\n * skipped while the preview session is active.\n *\n * Use this before calling {@link set} for Expo Go-style preview flows.\n *\n * @param options Optional preview session options.\n * @returns {Promise<void>} Resolves when preview session state is prepared.\n * @since 8.47.0\n */\n startPreviewSession(options?: StartPreviewSessionOptions): 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 * Trigger the native auto-update check/download pipeline immediately.\n *\n * This starts the same background update flow used when the app moves to the\n * foreground with auto-update enabled. It is useful for native integrations\n * such as a silent push notification asking the app to check for a Capgo\n * bundle without reimplementing the update protocol in JavaScript.\n *\n * The promise resolves after the native background work has been queued, not\n * after the update has been downloaded or installed. Listen to updater events\n * such as `updateAvailable`, `downloadComplete`, `downloadFailed`, and\n * `noNeedUpdate` for the final result.\n *\n * Native support is available on iOS and Android. On Web, this method returns\n * a result with `status: 'unavailable'`. Native platforms also return\n * `unavailable` when the native auto-update system is disabled.\n *\n * @returns {Promise<TriggerUpdateCheckResult>} Whether a native update check was queued.\n */\n triggerUpdateCheck(): Promise<TriggerUpdateCheckResult>;\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: Handling \"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 is a normal, expected condition and resolves with\n * `kind: \"up_to_date\"` when the backend provides that classification.\n *\n * You should check `kind` and `error` before attempting to download:\n *\n * ```typescript\n * const latest = await CapacitorUpdater.getLatest();\n * if (latest.kind === 'up_to_date') {\n * console.log('Already up to date');\n * } else if (latest.kind === 'blocked') {\n * console.log('Update is blocked:', latest.error);\n * } else if (latest.url) {\n * // New version is available, proceed with download\n * }\n * ```\n *\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} Throws for failed update checks or transport/request failures.\n * @since 4.0.0\n */\n getLatest(options?: GetLatestOptions): Promise<LatestVersion>;\n\n /**\n * Return the manifest entries that still need to be downloaded for a partial update.\n *\n * Pass the result from {@link getLatest} directly when it includes a `manifest`.\n * The native plugin compares each manifest entry with the files already available\n * in the builtin bundle and the local delta cache. Entries that can be reused are\n * omitted from the returned `missing` list.\n *\n * For encrypted manifests, pass the `sessionKey` returned by {@link getLatest} so\n * encrypted file hashes can be checked against local files.\n *\n * ```typescript\n * const latest = await CapacitorUpdater.getLatest();\n * const missing = await CapacitorUpdater.getMissingBundleFiles(latest);\n * ```\n *\n * @param options A {@link GetMissingBundleFilesOptions} object, or a {@link LatestVersion} response containing `manifest`.\n * @returns {Promise<GetMissingBundleFilesResult>} The manifest entries that require network download.\n * @throws {Error} If the manifest is missing or invalid.\n * @since 8.47.0\n */\n getMissingBundleFiles(options: GetMissingBundleFilesOptions): Promise<GetMissingBundleFilesResult>;\n\n /**\n * Estimate the download size for manifest entries before downloading them.\n *\n * This method sends the provided manifest entries to the Capgo update endpoint\n * once and reads the stored manifest `file_size` metadata. It does not perform\n * per-file `HEAD` requests from the app.\n *\n * Use this after {@link getMissingBundleFiles} to estimate only the files this\n * device still needs:\n *\n * ```typescript\n * const latest = await CapacitorUpdater.getLatest();\n * const missing = await CapacitorUpdater.getMissingBundleFiles(latest);\n * const size = await CapacitorUpdater.getBundleDownloadSize({\n * version: latest.version,\n * manifest: missing.missing,\n * });\n * ```\n *\n * @param options A {@link GetBundleDownloadSizeOptions} object containing manifest entries.\n * @returns {Promise<GetBundleDownloadSizeResult>} Known byte totals and per-file size results.\n * @throws {Error} If the manifest is missing or invalid.\n * @since 8.47.0\n */\n getBundleDownloadSize(options: GetBundleDownloadSizeOptions): Promise<GetBundleDownloadSizeResult>;\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 * - `updateCheckResult`\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 update check results before the updater decides whether to download.\n * The backend can classify the UpdateCheckResultEvent payload as `up_to_date`, `blocked`, or `failed`.\n *\n * This event is emitted alongside legacy events. For `up_to_date` and `blocked`, it is emitted before\n * `noNeedUpdate` and does not emit `downloadFailed`. For `failed`, it is emitted before the legacy\n * `downloadFailed` event and keeps the existing failure stats behavior.\n *\n * @since 8.45.11\n */\n addListener(\n eventName: 'updateCheckResult',\n listenerFunc: (state: UpdateCheckResultEvent) => void,\n ): 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\n/**\n * Classification for update-check responses that do not provide a downloadable bundle.\n * The update backend provides this field directly. Missing or unknown values are treated as\n * failed by native clients.\n *\n * @since 8.45.11\n */\nexport type UpdateResponseKind = 'up_to_date' | 'blocked' | 'failed';\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 UpdateCheckResultEvent {\n /**\n * Classification for the update check result, provided by the backend.\n *\n * @since 8.45.11\n */\n kind: UpdateResponseKind;\n /**\n * Backend error code, when provided.\n *\n * @since 8.45.11\n */\n error?: string;\n /**\n * Backend message, when provided.\n *\n * @since 8.45.11\n */\n message?: string;\n /**\n * HTTP status code returned by the update endpoint.\n *\n * @since 8.45.11\n */\n statusCode?: number;\n /**\n * Version referenced by the update check result.\n *\n * @since 8.45.11\n */\n version?: string;\n /**\n * Current bundle on the device.\n *\n * @since 8.45.11\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 GetMissingBundleFilesOptions {\n /**\n * Manifest returned by {@link getLatest}. Passing the full {@link LatestVersion}\n * response is supported because it contains this field.\n *\n * @since 8.47.0\n */\n manifest?: ManifestEntry[];\n /**\n * Target bundle version. Passing the full {@link LatestVersion} response is\n * supported because it contains this field.\n *\n * @since 8.47.0\n */\n version?: string;\n /**\n * Session key returned by {@link getLatest}, required only when file hashes are encrypted.\n *\n * @since 8.47.0\n */\n sessionKey?: string;\n}\n\nexport interface GetMissingBundleFilesResult {\n /**\n * Entries that are not available locally and need to be downloaded.\n *\n * @since 8.47.0\n */\n missing: ManifestEntry[];\n /**\n * Total entries in the provided manifest.\n *\n * @since 8.47.0\n */\n total: number;\n /**\n * Number of entries that need to be downloaded.\n *\n * @since 8.47.0\n */\n missingCount: number;\n /**\n * Number of entries that can be reused from builtin files or local cache.\n *\n * @since 8.47.0\n */\n reusableCount: number;\n}\n\nexport interface GetBundleDownloadSizeOptions {\n /**\n * Manifest entries to estimate. Pass `missing.missing` from {@link getMissingBundleFiles}\n * to estimate only the bytes this device still needs to download.\n *\n * @since 8.47.0\n */\n manifest?: ManifestEntry[];\n /**\n * Target bundle version. Pass `latest.version` when estimating files returned\n * by {@link getLatest}.\n *\n * @since 8.47.0\n */\n version?: string;\n}\n\nexport interface BundleFileSize {\n /**\n * File name from the manifest entry.\n *\n * @since 8.47.0\n */\n file_name: string | null;\n /**\n * File hash from the manifest entry.\n *\n * @since 8.47.0\n */\n file_hash: string | null;\n /**\n * Download URL from the manifest entry.\n *\n * @since 8.47.0\n */\n download_url: string | null;\n /**\n * Estimated bytes to download when the server exposes a size.\n *\n * @since 8.47.0\n */\n size?: number;\n /**\n * Error for this entry when the size could not be determined.\n *\n * @since 8.47.0\n */\n error?: string;\n}\n\nexport interface GetBundleDownloadSizeResult {\n /**\n * Sum of all known file sizes in bytes.\n *\n * @since 8.47.0\n */\n totalSize: number;\n /**\n * Number of files with a known size.\n *\n * @since 8.47.0\n */\n knownFiles: number;\n /**\n * Number of files whose size could not be determined.\n *\n * @since 8.47.0\n */\n unknownFiles: number;\n /**\n * Per-file size results.\n *\n * @since 8.47.0\n */\n files: BundleFileSize[];\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. Use `kind` for classification instead of parsing this value.\n */\n error?: string;\n /**\n * Classification for this response, provided by the backend.\n *\n * @since 8.45.11\n */\n kind?: UpdateResponseKind;\n /**\n * HTTP status code returned by the update server for classified update-check responses.\n *\n * @since 8.45.11\n */\n statusCode?: number;\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 * Missing manifest entries for this device when {@link GetLatestOptions.includeBundleSize}\n * is enabled.\n *\n * @since 8.47.0\n */\n missing?: GetMissingBundleFilesResult;\n /**\n * Estimated download size for missing manifest entries when\n * {@link GetLatestOptions.includeBundleSize} is enabled.\n *\n * @since 8.47.0\n */\n downloadSize?: GetBundleDownloadSizeResult;\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 * Temporarily use another app id for this update check while using a trusted preview container.\n * This only changes the app id sent by this request; it does not persist a preview session.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.\n * @since 8.47.0\n * @default undefined\n */\n appId?: string;\n /**\n * When true, the native plugin computes which manifest files are missing on\n * this device and asks the Capgo update endpoint for their stored sizes before\n * resolving {@link getLatest}.\n *\n * This adds one backend request only when the update response contains a\n * manifest. It does not perform per-file network checks.\n *\n * @since 8.47.0\n * @default false\n */\n includeBundleSize?: boolean;\n}\n\nexport interface StartPreviewSessionOptions {\n /**\n * App id to use while the preview session is active.\n * The previous app id is restored when leaving the preview session.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.\n * @since 8.47.0\n * @default undefined\n */\n appId?: 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\n/**\n * Result returned after requesting an immediate native auto-update check.\n *\n * @property status - Native trigger state: `queued` when a check was queued,\n * `already_running` when the native update pipeline is already active, or\n * `unavailable` on Web or when native auto-update is disabled.\n * @property queued - Whether a new native update check was queued. This is\n * `true` only when `status` is `queued`; otherwise it is `false`.\n */\nexport interface TriggerUpdateCheckResult {\n /**\n * Native trigger state: `queued` when a check was queued, `already_running`\n * when the native update pipeline is already active, or `unavailable` on Web\n * or when native auto-update is disabled.\n */\n status: 'queued' | 'already_running' | 'unavailable';\n /**\n * Whether a new native update check was queued. This is `true` only when\n * `status` is `queued`; otherwise it is `false`.\n */\n queued: 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;AA+8EH;;;;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 how the plugin should use Auto Update via an update server.\n *\n * Boolean values keep their existing behavior:\n * - `true`: Same as `\"atBackground\"`.\n * - `false`: Same as `\"off\"`.\n *\n * String values merge the previous Auto Update and Direct Update configuration:\n * - `\"off\"`: Disable Auto Update.\n * - `\"atBackground\"`: Check and download updates automatically, then apply them the next time the app moves to background.\n * - `\"atInstall\"`: Direct install only after app install or native app update, otherwise use `\"atBackground\"` behavior.\n * - `\"onLaunch\"`: Direct install on app launch, otherwise use `\"atBackground\"` behavior after the first launch attempt.\n * - `\"always\"`: Direct install whenever Auto Update runs.\n * - `\"onlyDownload\"`: Check and download updates automatically, emit `updateAvailable`, but never direct install or set the next bundle automatically.\n *\n * Only available for Android and iOS.\n *\n * @default true\n * @example \"onlyDownload\"\n */\n autoUpdate?: boolean | 'off' | 'atBackground' | 'atInstall' | 'onLaunch' | 'always' | 'onlyDownload';\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 * Native stats include update lifecycle events, app health signals such as crashes,\n * Android ANRs, low-memory exits, iOS memory warnings, and WebView health signals\n * such as JavaScript errors, unhandled promise rejections, resource load failures,\n * WebView renderer exits, and unclean WebView restarts when available.\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 *\n * @deprecated Use {@link PluginsConfig.CapacitorUpdater.autoUpdate} string modes instead.\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 autoUpdate is set to \"atInstall\", \"always\", or \"onLaunch\", or when the deprecated directUpdate option 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 Auto Update and Direct Update behavior 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 * Allow JavaScript to start a native preview session and temporarily request updates for another app id.\n * This is intended for trusted container apps that implement Expo Go-style preview flows.\n *\n * Only available for Android and iOS.\n *\n * @default false\n * @since 8.47.0\n */\n allowPreview?: 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 * Start a temporary preview/testing session.\n *\n * This stores the currently active bundle as the pending fallback, enables the\n * native shake menu, and makes the next applied bundle show a native notice\n * explaining that shaking the device can reload or leave the preview.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.\n * When `appId` is provided, the preview session temporarily uses that app id\n * for update checks until the user leaves the preview. Native updater stats are\n * skipped while the preview session is active.\n *\n * Use this before calling {@link set} for Expo Go-style preview flows.\n *\n * @param options Optional preview session options.\n * @returns {Promise<void>} Resolves when preview session state is prepared.\n * @since 8.47.0\n */\n startPreviewSession(options?: StartPreviewSessionOptions): 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 * Trigger the native auto-update check/download pipeline immediately.\n *\n * This starts the same background update flow used when the app moves to the\n * foreground with auto-update enabled. It is useful for native integrations\n * such as a silent push notification asking the app to check for a Capgo\n * bundle without reimplementing the update protocol in JavaScript.\n *\n * The promise resolves after the native background work has been queued, not\n * after the update has been downloaded or installed. Listen to updater events\n * such as `updateAvailable`, `downloadComplete`, `downloadFailed`, and\n * `noNeedUpdate` for the final result.\n *\n * Native support is available on iOS and Android. On Web, this method returns\n * a result with `status: 'unavailable'`. Native platforms also return\n * `unavailable` when the native auto-update system is disabled.\n *\n * @returns {Promise<TriggerUpdateCheckResult>} Whether a native update check was queued.\n */\n triggerUpdateCheck(): Promise<TriggerUpdateCheckResult>;\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: Handling \"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 is a normal, expected condition and resolves with\n * `kind: \"up_to_date\"` when the backend provides that classification.\n *\n * You should check `kind` and `error` before attempting to download:\n *\n * ```typescript\n * const latest = await CapacitorUpdater.getLatest();\n * if (latest.kind === 'up_to_date') {\n * console.log('Already up to date');\n * } else if (latest.kind === 'blocked') {\n * console.log('Update is blocked:', latest.error);\n * } else if (latest.url) {\n * // New version is available, proceed with download\n * }\n * ```\n *\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} Throws for failed update checks or transport/request failures.\n * @since 4.0.0\n */\n getLatest(options?: GetLatestOptions): Promise<LatestVersion>;\n\n /**\n * Return the manifest entries that still need to be downloaded for a partial update.\n *\n * Pass the result from {@link getLatest} directly when it includes a `manifest`.\n * The native plugin compares each manifest entry with the files already available\n * in the builtin bundle and the local delta cache. Entries that can be reused are\n * omitted from the returned `missing` list.\n *\n * For encrypted manifests, pass the `sessionKey` returned by {@link getLatest} so\n * encrypted file hashes can be checked against local files.\n *\n * ```typescript\n * const latest = await CapacitorUpdater.getLatest();\n * const missing = await CapacitorUpdater.getMissingBundleFiles(latest);\n * ```\n *\n * @param options A {@link GetMissingBundleFilesOptions} object, or a {@link LatestVersion} response containing `manifest`.\n * @returns {Promise<GetMissingBundleFilesResult>} The manifest entries that require network download.\n * @throws {Error} If the manifest is missing or invalid.\n * @since 8.47.0\n */\n getMissingBundleFiles(options: GetMissingBundleFilesOptions): Promise<GetMissingBundleFilesResult>;\n\n /**\n * Estimate the download size for manifest entries before downloading them.\n *\n * This method sends the provided manifest entries to the Capgo update endpoint\n * once and reads the stored manifest `file_size` metadata. It does not perform\n * per-file `HEAD` requests from the app.\n *\n * Use this after {@link getMissingBundleFiles} to estimate only the files this\n * device still needs:\n *\n * ```typescript\n * const latest = await CapacitorUpdater.getLatest();\n * const missing = await CapacitorUpdater.getMissingBundleFiles(latest);\n * const size = await CapacitorUpdater.getBundleDownloadSize({\n * version: latest.version,\n * manifest: missing.missing,\n * });\n * ```\n *\n * @param options A {@link GetBundleDownloadSizeOptions} object containing manifest entries.\n * @returns {Promise<GetBundleDownloadSizeResult>} Known byte totals and per-file size results.\n * @throws {Error} If the manifest is missing or invalid.\n * @since 8.47.0\n */\n getBundleDownloadSize(options: GetBundleDownloadSizeOptions): Promise<GetBundleDownloadSizeResult>;\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 * - `updateCheckResult`\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 update check results before the updater decides whether to download.\n * The backend can classify the UpdateCheckResultEvent payload as `up_to_date`, `blocked`, or `failed`.\n *\n * This event is emitted alongside legacy events. For `up_to_date` and `blocked`, it is emitted before\n * `noNeedUpdate` and does not emit `downloadFailed`. For `failed`, it is emitted before the legacy\n * `downloadFailed` event and keeps the existing failure stats behavior.\n *\n * @since 8.45.11\n */\n addListener(\n eventName: 'updateCheckResult',\n listenerFunc: (state: UpdateCheckResultEvent) => void,\n ): 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\n/**\n * Classification for update-check responses that do not provide a downloadable bundle.\n * The update backend provides this field directly. Missing or unknown values are treated as\n * failed by native clients.\n *\n * @since 8.45.11\n */\nexport type UpdateResponseKind = 'up_to_date' | 'blocked' | 'failed';\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 UpdateCheckResultEvent {\n /**\n * Classification for the update check result, provided by the backend.\n *\n * @since 8.45.11\n */\n kind: UpdateResponseKind;\n /**\n * Backend error code, when provided.\n *\n * @since 8.45.11\n */\n error?: string;\n /**\n * Backend message, when provided.\n *\n * @since 8.45.11\n */\n message?: string;\n /**\n * HTTP status code returned by the update endpoint.\n *\n * @since 8.45.11\n */\n statusCode?: number;\n /**\n * Version referenced by the update check result.\n *\n * @since 8.45.11\n */\n version?: string;\n /**\n * Current bundle on the device.\n *\n * @since 8.45.11\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 GetMissingBundleFilesOptions {\n /**\n * Manifest returned by {@link getLatest}. Passing the full {@link LatestVersion}\n * response is supported because it contains this field.\n *\n * @since 8.47.0\n */\n manifest?: ManifestEntry[];\n /**\n * Target bundle version. Passing the full {@link LatestVersion} response is\n * supported because it contains this field.\n *\n * @since 8.47.0\n */\n version?: string;\n /**\n * Session key returned by {@link getLatest}, required only when file hashes are encrypted.\n *\n * @since 8.47.0\n */\n sessionKey?: string;\n}\n\nexport interface GetMissingBundleFilesResult {\n /**\n * Entries that are not available locally and need to be downloaded.\n *\n * @since 8.47.0\n */\n missing: ManifestEntry[];\n /**\n * Total entries in the provided manifest.\n *\n * @since 8.47.0\n */\n total: number;\n /**\n * Number of entries that need to be downloaded.\n *\n * @since 8.47.0\n */\n missingCount: number;\n /**\n * Number of entries that can be reused from builtin files or local cache.\n *\n * @since 8.47.0\n */\n reusableCount: number;\n}\n\nexport interface GetBundleDownloadSizeOptions {\n /**\n * Manifest entries to estimate. Pass `missing.missing` from {@link getMissingBundleFiles}\n * to estimate only the bytes this device still needs to download.\n *\n * @since 8.47.0\n */\n manifest?: ManifestEntry[];\n /**\n * Target bundle version. Pass `latest.version` when estimating files returned\n * by {@link getLatest}.\n *\n * @since 8.47.0\n */\n version?: string;\n}\n\nexport interface BundleFileSize {\n /**\n * File name from the manifest entry.\n *\n * @since 8.47.0\n */\n file_name: string | null;\n /**\n * File hash from the manifest entry.\n *\n * @since 8.47.0\n */\n file_hash: string | null;\n /**\n * Download URL from the manifest entry.\n *\n * @since 8.47.0\n */\n download_url: string | null;\n /**\n * Estimated bytes to download when the server exposes a size.\n *\n * @since 8.47.0\n */\n size?: number;\n /**\n * Error for this entry when the size could not be determined.\n *\n * @since 8.47.0\n */\n error?: string;\n}\n\nexport interface GetBundleDownloadSizeResult {\n /**\n * Sum of all known file sizes in bytes.\n *\n * @since 8.47.0\n */\n totalSize: number;\n /**\n * Number of files with a known size.\n *\n * @since 8.47.0\n */\n knownFiles: number;\n /**\n * Number of files whose size could not be determined.\n *\n * @since 8.47.0\n */\n unknownFiles: number;\n /**\n * Per-file size results.\n *\n * @since 8.47.0\n */\n files: BundleFileSize[];\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. Use `kind` for classification instead of parsing this value.\n */\n error?: string;\n /**\n * Classification for this response, provided by the backend.\n *\n * @since 8.45.11\n */\n kind?: UpdateResponseKind;\n /**\n * HTTP status code returned by the update server for classified update-check responses.\n *\n * @since 8.45.11\n */\n statusCode?: number;\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 * Missing manifest entries for this device when {@link GetLatestOptions.includeBundleSize}\n * is enabled.\n *\n * @since 8.47.0\n */\n missing?: GetMissingBundleFilesResult;\n /**\n * Estimated download size for missing manifest entries when\n * {@link GetLatestOptions.includeBundleSize} is enabled.\n *\n * @since 8.47.0\n */\n downloadSize?: GetBundleDownloadSizeResult;\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 * Temporarily use another app id for this update check while using a trusted preview container.\n * This only changes the app id sent by this request; it does not persist a preview session.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.\n * @since 8.47.0\n * @default undefined\n */\n appId?: string;\n /**\n * When true, the native plugin computes which manifest files are missing on\n * this device and asks the Capgo update endpoint for their stored sizes before\n * resolving {@link getLatest}.\n *\n * This adds one backend request only when the update response contains a\n * manifest. It does not perform per-file network checks.\n *\n * @since 8.47.0\n * @default false\n */\n includeBundleSize?: boolean;\n}\n\nexport interface StartPreviewSessionOptions {\n /**\n * App id to use while the preview session is active.\n * The previous app id is restored when leaving the preview session.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.\n * @since 8.47.0\n * @default undefined\n */\n appId?: string;\n /**\n * HTTP(S) URL returning a preview download payload.\n * When provided, the native shake reload action fetches this payload again\n * before reloading so channel previews can move to the latest bundle.\n * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.\n * @since 8.48.0\n * @default undefined\n */\n payloadUrl?: 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\n/**\n * Result returned after requesting an immediate native auto-update check.\n *\n * @property status - Native trigger state: `queued` when a check was queued,\n * `already_running` when the native update pipeline is already active, or\n * `unavailable` on Web or when native auto-update is disabled.\n * @property queued - Whether a new native update check was queued. This is\n * `true` only when `status` is `queued`; otherwise it is `false`.\n */\nexport interface TriggerUpdateCheckResult {\n /**\n * Native trigger state: `queued` when a check was queued, `already_running`\n * when the native update pipeline is already active, or `unavailable` on Web\n * or when native auto-update is disabled.\n */\n status: 'queued' | 'already_running' | 'unavailable';\n /**\n * Whether a new native update check was queued. This is `true` only when\n * `status` is `queued`; otherwise it is `false`.\n */\n queued: 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"]}
@@ -79,7 +79,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
79
79
  CAPPluginMethod(name: "completeFlexibleUpdate", returnType: CAPPluginReturnPromise)
80
80
  ]
81
81
  public var implementation = CapgoUpdater()
82
- private let pluginVersion: String = "8.47.3"
82
+ private let pluginVersion: String = "8.47.4"
83
83
  static let updateUrlDefault = "https://plugin.capgo.app/updates"
84
84
  static let statsUrlDefault = "https://plugin.capgo.app/stats"
85
85
  static let channelUrlDefault = "https://plugin.capgo.app/channel_self"
@@ -101,7 +101,10 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
101
101
  private let previewPreviousShakeChannelSelectorDefaultsKey = "CapacitorUpdater.previewPreviousShakeChannelSelector"
102
102
  private let previewPreviousNextBundleDefaultsKey = "CapacitorUpdater.previewPreviousNextBundle"
103
103
  private let previewPreviousAppIdDefaultsKey = "CapacitorUpdater.previewPreviousAppId"
104
+ private let previewPreviousDefaultChannelDefaultsKey = "CapacitorUpdater.previewPreviousDefaultChannel"
105
+ private let previewPreviousDefaultChannelWasSetDefaultsKey = "CapacitorUpdater.previewPreviousDefaultChannelWasSet"
104
106
  private let previewAppIdDefaultsKey = "CapacitorUpdater.previewAppId"
107
+ private let previewPayloadUrlDefaultsKey = "CapacitorUpdater.previewPayloadUrl"
105
108
  // Note: DELAY_CONDITION_PREFERENCES is now defined in DelayUpdateUtils.DELAY_CONDITION_PREFERENCES
106
109
  private var updateUrl = ""
107
110
  private var backgroundTaskID: UIBackgroundTaskIdentifier = UIBackgroundTaskIdentifier.invalid
@@ -749,6 +752,62 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
749
752
  return manifestEntries
750
753
  }
751
754
 
755
+ private struct PreviewPayload: Decodable {
756
+ let version: String?
757
+ let url: String?
758
+ let checksum: String?
759
+ let sessionKey: String?
760
+ let manifest: [ManifestEntry]?
761
+ let message: String?
762
+ let error: String?
763
+ }
764
+
765
+ private func makePreviewError(_ message: String) -> NSError {
766
+ NSError(domain: "CapacitorUpdaterPreview", code: 0, userInfo: [NSLocalizedDescriptionKey: message])
767
+ }
768
+
769
+ private func downloadBundle(urlString: String, version: String, sessionKey: String, checksum rawChecksum: String, manifestEntries: [ManifestEntry]?) throws -> BundleInfo {
770
+ guard let url = URL(string: urlString) else {
771
+ throw makePreviewError("Invalid download URL")
772
+ }
773
+
774
+ var checksum = rawChecksum
775
+ let next: BundleInfo
776
+ if let manifestEntries = manifestEntries {
777
+ next = try self.implementation.downloadManifest(manifest: manifestEntries, version: version, sessionKey: sessionKey)
778
+ } else {
779
+ next = try self.implementation.download(url: url, version: version, sessionKey: sessionKey)
780
+ }
781
+
782
+ if self.implementation.publicKey != "" && checksum == "" {
783
+ self.logger.error("Public key present but no checksum provided")
784
+ self.implementation.sendStats(action: "checksum_required", versionName: next.getVersionName())
785
+ let id = next.getId()
786
+ let resDel = self.implementation.delete(id: id)
787
+ if !resDel {
788
+ self.logger.error("Delete failed, id \(id) doesn't exist")
789
+ }
790
+ throw ObjectSavableError.checksum
791
+ }
792
+
793
+ checksum = try CryptoCipher.decryptChecksum(checksum: checksum, publicKey: self.implementation.publicKey)
794
+ CryptoCipher.logChecksumInfo(label: "Bundle checksum", hexChecksum: next.getChecksum())
795
+ CryptoCipher.logChecksumInfo(label: "Expected checksum", hexChecksum: checksum)
796
+ if (checksum != "" || self.implementation.publicKey != "") && next.getChecksum() != checksum {
797
+ self.logger.error("Error checksum \(next.getChecksum()) \(checksum)")
798
+ self.implementation.sendStats(action: "checksum_fail", versionName: next.getVersionName())
799
+ let id = next.getId()
800
+ let resDel = self.implementation.delete(id: id)
801
+ if !resDel {
802
+ self.logger.error("Delete failed, id \(id) doesn't exist")
803
+ }
804
+ throw ObjectSavableError.checksum
805
+ }
806
+
807
+ self.logger.info("Good checksum \(next.getChecksum()) \(checksum)")
808
+ return next
809
+ }
810
+
752
811
  @objc func download(_ call: CAPPluginCall) {
753
812
  guard let urlString = call.getString("url") else {
754
813
  logger.error("Download called without url")
@@ -762,57 +821,30 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
762
821
  }
763
822
 
764
823
  let sessionKey = call.getString("sessionKey", "")
765
- var checksum = call.getString("checksum", "")
824
+ let checksum = call.getString("checksum", "")
766
825
  let manifestArray = call.getArray("manifest")
767
- let url = URL(string: urlString)
768
- logger.info("Downloading \(String(describing: url))")
826
+ logger.info("Downloading \(urlString)")
769
827
  self.saveCallForAsyncHandling(call)
770
828
  self.runBackgroundDownloadWork {
771
829
  do {
772
- let next: BundleInfo
773
- if let manifestEntries = self.manifestEntries(from: manifestArray) {
774
- next = try self.implementation.downloadManifest(manifest: manifestEntries, version: version, sessionKey: sessionKey)
775
- } else {
776
- next = try self.implementation.download(url: url!, version: version, sessionKey: sessionKey)
777
- }
778
- // If public key is present but no checksum provided, refuse installation
779
- if self.implementation.publicKey != "" && checksum == "" {
780
- self.logger.error("Public key present but no checksum provided")
781
- self.implementation.sendStats(action: "checksum_required", versionName: next.getVersionName())
782
- let id = next.getId()
783
- let resDel = self.implementation.delete(id: id)
784
- if !resDel {
785
- self.logger.error("Delete failed, id \(id) doesn't exist")
786
- }
787
- throw ObjectSavableError.checksum
788
- }
789
-
790
- checksum = try CryptoCipher.decryptChecksum(checksum: checksum, publicKey: self.implementation.publicKey)
791
- CryptoCipher.logChecksumInfo(label: "Bundle checksum", hexChecksum: next.getChecksum())
792
- CryptoCipher.logChecksumInfo(label: "Expected checksum", hexChecksum: checksum)
793
- if (checksum != "" || self.implementation.publicKey != "") && next.getChecksum() != checksum {
794
- self.logger.error("Error checksum \(next.getChecksum()) \(checksum)")
795
- self.implementation.sendStats(action: "checksum_fail", versionName: next.getVersionName())
796
- let id = next.getId()
797
- let resDel = self.implementation.delete(id: id)
798
- if !resDel {
799
- self.logger.error("Delete failed, id \(id) doesn't exist")
800
- }
801
- throw ObjectSavableError.checksum
802
- } else {
803
- self.logger.info("Good checksum \(next.getChecksum()) \(checksum)")
804
- }
830
+ let next = try self.downloadBundle(
831
+ urlString: urlString,
832
+ version: version,
833
+ sessionKey: sessionKey,
834
+ checksum: checksum,
835
+ manifestEntries: self.manifestEntries(from: manifestArray)
836
+ )
805
837
  var updateAvailablePayload: JSObject = [:]
806
838
  updateAvailablePayload["bundle"] = self.bundlePayload(next)
807
839
  self.notifyListenersOnMain("updateAvailable", data: updateAvailablePayload)
808
840
  self.resolveCall(call, data: next.toJSON())
809
841
  } catch {
810
- self.logger.error("Failed to download from: \(String(describing: url)) \(error.localizedDescription)")
842
+ self.logger.error("Failed to download from: \(urlString) \(error.localizedDescription)")
811
843
  var downloadFailedPayload: JSObject = [:]
812
844
  downloadFailedPayload["version"] = version
813
845
  self.notifyListenersOnMain("downloadFailed", data: downloadFailedPayload)
814
846
  self.implementation.sendStats(action: "download_fail")
815
- self.rejectCall(call, message: "Failed to download from: \(url!) - \(error.localizedDescription)")
847
+ self.rejectCall(call, message: "Failed to download from: \(urlString) - \(error.localizedDescription)")
816
848
  }
817
849
  }
818
850
  }
@@ -989,6 +1021,13 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
989
1021
  return
990
1022
  }
991
1023
  let previewAppId = self.normalizedPreviewAppId(call.getString("appId"))
1024
+ let rawPayloadUrl = call.getString("payloadUrl")
1025
+ let previewPayloadUrl = self.normalizedPreviewPayloadUrl(rawPayloadUrl)
1026
+ if let rawPayloadUrl = rawPayloadUrl, !rawPayloadUrl.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty, previewPayloadUrl == nil {
1027
+ logger.error("startPreviewSession called with invalid payloadUrl")
1028
+ call.reject("Invalid preview payloadUrl")
1029
+ return
1030
+ }
992
1031
 
993
1032
  if !self.previewSessionEnabled {
994
1033
  let current = self.implementation.getCurrentBundle()
@@ -1007,6 +1046,13 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
1007
1046
  }
1008
1047
 
1009
1048
  UserDefaults.standard.set(self.implementation.appId, forKey: self.previewPreviousAppIdDefaultsKey)
1049
+ if let previousDefaultChannel = UserDefaults.standard.object(forKey: self.defaultChannelDefaultsKey) as? String {
1050
+ UserDefaults.standard.set(previousDefaultChannel, forKey: self.previewPreviousDefaultChannelDefaultsKey)
1051
+ UserDefaults.standard.set(true, forKey: self.previewPreviousDefaultChannelWasSetDefaultsKey)
1052
+ } else {
1053
+ UserDefaults.standard.removeObject(forKey: self.previewPreviousDefaultChannelDefaultsKey)
1054
+ UserDefaults.standard.set(false, forKey: self.previewPreviousDefaultChannelWasSetDefaultsKey)
1055
+ }
1010
1056
  UserDefaults.standard.set(self.shakeMenuEnabled, forKey: self.previewPreviousShakeMenuDefaultsKey)
1011
1057
  UserDefaults.standard.set(self.shakeChannelSelectorEnabled, forKey: self.previewPreviousShakeChannelSelectorDefaultsKey)
1012
1058
  logger.info("Preview session started with fallback bundle: \(current.toString())")
@@ -1018,6 +1064,13 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
1018
1064
  logger.info("Preview session using appId: \(previewAppId)")
1019
1065
  }
1020
1066
 
1067
+ if let previewPayloadUrl = previewPayloadUrl {
1068
+ UserDefaults.standard.set(previewPayloadUrl.absoluteString, forKey: self.previewPayloadUrlDefaultsKey)
1069
+ logger.info("Preview session using payload URL")
1070
+ } else {
1071
+ UserDefaults.standard.removeObject(forKey: self.previewPayloadUrlDefaultsKey)
1072
+ }
1073
+
1021
1074
  self.previewSessionEnabled = true
1022
1075
  self.previewSessionAlertPending = true
1023
1076
  self.implementation.previewSession = true
@@ -1030,14 +1083,12 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
1030
1083
 
1031
1084
  func leavePreviewSessionFromShakeMenu() -> Bool {
1032
1085
  let previewBundle = self.implementation.getCurrentBundle()
1033
- let configDefaultChannel = self.getConfig().getString("defaultChannel", "")!
1034
1086
 
1035
1087
  let didReset = self.resetToPreviewFallbackBundle()
1036
1088
  guard didReset else {
1037
1089
  return false
1038
1090
  }
1039
1091
 
1040
- _ = self.implementation.unsetChannel(defaultChannelKey: self.defaultChannelDefaultsKey, configDefaultChannel: configDefaultChannel)
1041
1092
  let previewFallbackBundle = self.implementation.getPreviewFallbackBundle()
1042
1093
  self.endPreviewSession()
1043
1094
  let restoredNextBundle = self.implementation.getNextBundle()
@@ -1050,7 +1101,11 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
1050
1101
  }
1051
1102
 
1052
1103
  func reloadPreviewSessionFromShakeMenu() -> Bool {
1053
- self._reload()
1104
+ if let payloadUrl = self.storedPreviewPayloadUrl() {
1105
+ return self.refreshPreviewSessionFromPayloadUrl(payloadUrl)
1106
+ }
1107
+
1108
+ return self._reload()
1054
1109
  }
1055
1110
 
1056
1111
  func hasActivePreviewSession() -> Bool {
@@ -1088,6 +1143,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
1088
1143
  ?? getConfig().getBoolean("allowShakeChannelSelector", false)
1089
1144
  self.restorePreviewPreviousNextBundle()
1090
1145
  self.restorePreviewPreviousAppId()
1146
+ self.restorePreviewPreviousDefaultChannel()
1091
1147
 
1092
1148
  self.previewSessionEnabled = false
1093
1149
  self.previewSessionAlertPending = false
@@ -1117,6 +1173,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
1117
1173
 
1118
1174
  self.restorePreviewPreviousNextBundle()
1119
1175
  self.restorePreviewPreviousAppId()
1176
+ self.restorePreviewPreviousDefaultChannel()
1120
1177
  self.previewSessionEnabled = false
1121
1178
  self.previewSessionAlertPending = false
1122
1179
  self.implementation.previewSession = false
@@ -1132,7 +1189,10 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
1132
1189
  UserDefaults.standard.removeObject(forKey: self.previewPreviousShakeChannelSelectorDefaultsKey)
1133
1190
  UserDefaults.standard.removeObject(forKey: self.previewPreviousNextBundleDefaultsKey)
1134
1191
  UserDefaults.standard.removeObject(forKey: self.previewPreviousAppIdDefaultsKey)
1192
+ UserDefaults.standard.removeObject(forKey: self.previewPreviousDefaultChannelDefaultsKey)
1193
+ UserDefaults.standard.removeObject(forKey: self.previewPreviousDefaultChannelWasSetDefaultsKey)
1135
1194
  UserDefaults.standard.removeObject(forKey: self.previewAppIdDefaultsKey)
1195
+ UserDefaults.standard.removeObject(forKey: self.previewPayloadUrlDefaultsKey)
1136
1196
  UserDefaults.standard.synchronize()
1137
1197
  }
1138
1198
 
@@ -1145,6 +1205,23 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
1145
1205
  logger.info("Restored appId after preview: \(previousAppId)")
1146
1206
  }
1147
1207
 
1208
+ private func restorePreviewPreviousDefaultChannel() {
1209
+ let configDefaultChannel = self.getConfig().getString("defaultChannel", "")!
1210
+ let hadPreviousDefaultChannel = UserDefaults.standard.object(forKey: self.previewPreviousDefaultChannelWasSetDefaultsKey) as? Bool ?? false
1211
+
1212
+ guard hadPreviousDefaultChannel,
1213
+ let previousDefaultChannel = UserDefaults.standard.string(forKey: self.previewPreviousDefaultChannelDefaultsKey) else {
1214
+ UserDefaults.standard.removeObject(forKey: self.defaultChannelDefaultsKey)
1215
+ self.implementation.defaultChannel = configDefaultChannel
1216
+ logger.info("Restored defaultChannel after preview to config value")
1217
+ return
1218
+ }
1219
+
1220
+ UserDefaults.standard.set(previousDefaultChannel, forKey: self.defaultChannelDefaultsKey)
1221
+ self.implementation.defaultChannel = previousDefaultChannel
1222
+ logger.info("Restored defaultChannel after preview")
1223
+ }
1224
+
1148
1225
  private func normalizedPreviewAppId(_ rawAppId: String?) -> String? {
1149
1226
  guard let rawAppId else {
1150
1227
  return nil
@@ -1163,6 +1240,99 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
1163
1240
  return appId
1164
1241
  }
1165
1242
 
1243
+ private func normalizedPreviewPayloadUrl(_ rawPayloadUrl: String?) -> URL? {
1244
+ guard let rawPayloadUrl else {
1245
+ return nil
1246
+ }
1247
+
1248
+ let payloadUrl = rawPayloadUrl.trimmingCharacters(in: .whitespacesAndNewlines)
1249
+ guard !payloadUrl.isEmpty,
1250
+ let url = URL(string: payloadUrl),
1251
+ url.scheme == "https" || url.scheme == "http" else {
1252
+ return nil
1253
+ }
1254
+
1255
+ return url
1256
+ }
1257
+
1258
+ private func storedPreviewPayloadUrl() -> URL? {
1259
+ normalizedPreviewPayloadUrl(UserDefaults.standard.string(forKey: self.previewPayloadUrlDefaultsKey))
1260
+ }
1261
+
1262
+ private func fetchPreviewPayload(_ payloadUrl: URL) throws -> PreviewPayload {
1263
+ var request = URLRequest(url: payloadUrl)
1264
+ request.setValue("application/json", forHTTPHeaderField: "Accept")
1265
+
1266
+ let semaphore = DispatchSemaphore(value: 0)
1267
+ var responseData: Data?
1268
+ var response: URLResponse?
1269
+ var responseError: Error?
1270
+
1271
+ URLSession.shared.dataTask(with: request) { data, urlResponse, error in
1272
+ responseData = data
1273
+ response = urlResponse
1274
+ responseError = error
1275
+ semaphore.signal()
1276
+ }.resume()
1277
+
1278
+ if semaphore.wait(timeout: .now() + 60) == .timedOut {
1279
+ throw makePreviewError("Preview payload request timed out")
1280
+ }
1281
+
1282
+ if let responseError = responseError {
1283
+ throw responseError
1284
+ }
1285
+
1286
+ let data = responseData ?? Data()
1287
+ if let httpResponse = response as? HTTPURLResponse, !(200...299).contains(httpResponse.statusCode) {
1288
+ if let payload = try? JSONDecoder().decode(PreviewPayload.self, from: data) {
1289
+ throw makePreviewError(payload.message ?? payload.error ?? "Preview payload request failed with HTTP \(httpResponse.statusCode)")
1290
+ }
1291
+ let message = String(data: data, encoding: .utf8) ?? "Preview payload request failed with HTTP \(httpResponse.statusCode)"
1292
+ throw makePreviewError(message)
1293
+ }
1294
+
1295
+ return try JSONDecoder().decode(PreviewPayload.self, from: data)
1296
+ }
1297
+
1298
+ private func refreshPreviewSessionFromPayloadUrl(_ payloadUrl: URL) -> Bool {
1299
+ do {
1300
+ let payload = try self.fetchPreviewPayload(payloadUrl)
1301
+ guard let version = payload.version, !version.isEmpty else {
1302
+ throw makePreviewError("Preview payload is missing a version")
1303
+ }
1304
+ guard payload.url != nil || payload.manifest?.isEmpty == false else {
1305
+ throw makePreviewError("Preview payload is missing download information")
1306
+ }
1307
+
1308
+ let current = self.implementation.getCurrentBundle()
1309
+ if current.getVersionName() == version {
1310
+ self.logger.info("Preview payload unchanged, reloading current bundle")
1311
+ return self._reload()
1312
+ }
1313
+
1314
+ let next = try self.downloadBundle(
1315
+ // Fallback URL is only provided when payload.url is missing; when manifestEntries is present,
1316
+ // downloadBundle routes through downloadManifest and ignores urlString.
1317
+ urlString: payload.url ?? "https://404.capgo.app/no.zip",
1318
+ version: version,
1319
+ sessionKey: payload.sessionKey ?? "",
1320
+ checksum: payload.checksum ?? "",
1321
+ manifestEntries: payload.manifest
1322
+ )
1323
+
1324
+ guard self.implementation.set(id: next.getId()) else {
1325
+ throw makePreviewError("Downloaded preview bundle cannot be applied")
1326
+ }
1327
+
1328
+ self.notifyBundleSet(next)
1329
+ return self._reload()
1330
+ } catch {
1331
+ self.logger.error("Could not refresh preview session: \(error.localizedDescription)")
1332
+ return false
1333
+ }
1334
+ }
1335
+
1166
1336
  private func clearPreviewSessionForNativeBuildChange() {
1167
1337
  guard self.previewSessionEnabled || self.implementation.getPreviewFallbackBundle() != nil else {
1168
1338
  return
@@ -1174,10 +1344,9 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
1174
1344
  self.shakeMenuEnabled = getConfig().getBoolean("shakeMenu", false)
1175
1345
  self.shakeChannelSelectorEnabled = getConfig().getBoolean("allowShakeChannelSelector", false)
1176
1346
  self.restorePreviewPreviousAppId()
1347
+ self.restorePreviewPreviousDefaultChannel()
1177
1348
  _ = self.implementation.setPreviewFallbackBundle(fallback: nil)
1178
1349
  _ = self.implementation.setNextBundle(next: Optional<String>.none)
1179
- let configDefaultChannel = self.getConfig().getString("defaultChannel", "")!
1180
- _ = self.implementation.unsetChannel(defaultChannelKey: self.defaultChannelDefaultsKey, configDefaultChannel: configDefaultChannel)
1181
1350
  self.clearPreviewSessionPreferences()
1182
1351
  }
1183
1352
 
@@ -81,9 +81,11 @@ extension UIWindow {
81
81
  })
82
82
 
83
83
  alertShake.addAction(UIAlertAction(title: reloadButtonTitle, style: .default) { _ in
84
- DispatchQueue.main.async {
84
+ DispatchQueue.global(qos: .userInitiated).async {
85
85
  if !plugin.reloadPreviewSessionFromShakeMenu() {
86
- self.showError(message: "Could not reload the test app.", plugin: plugin)
86
+ DispatchQueue.main.async {
87
+ self.showError(message: "Could not reload the test app.", plugin: plugin)
88
+ }
87
89
  }
88
90
  }
89
91
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "8.47.3",
3
+ "version": "8.47.4",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",