@capgo/capacitor-updater 7.45.10 → 7.50.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/Package.swift +1 -1
  2. package/README.md +510 -92
  3. package/android/src/main/java/ee/forgr/capacitor_updater/AndroidAppExitReporter.java +92 -0
  4. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +3192 -777
  5. package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +798 -299
  6. package/android/src/main/java/ee/forgr/capacitor_updater/DeviceIdHelper.java +45 -30
  7. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +46 -28
  8. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +2 -0
  9. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeDetector.java +3 -3
  10. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +359 -25
  11. package/android/src/main/java/ee/forgr/capacitor_updater/ThreeFingerPinchDetector.java +323 -0
  12. package/dist/docs.json +1283 -169
  13. package/dist/esm/definitions.d.ts +621 -44
  14. package/dist/esm/definitions.js.map +1 -1
  15. package/dist/esm/web.d.ts +11 -1
  16. package/dist/esm/web.js +59 -1
  17. package/dist/esm/web.js.map +1 -1
  18. package/dist/plugin.cjs.js +59 -1
  19. package/dist/plugin.cjs.js.map +1 -1
  20. package/dist/plugin.js +59 -1
  21. package/dist/plugin.js.map +1 -1
  22. package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +0 -1
  23. package/ios/Sources/CapacitorUpdaterPlugin/AppHealthTracker.swift +82 -0
  24. package/ios/Sources/CapacitorUpdaterPlugin/BigInt.swift +0 -16
  25. package/ios/Sources/CapacitorUpdaterPlugin/BundleInfo.swift +2 -2
  26. package/ios/Sources/CapacitorUpdaterPlugin/BundleStatus.swift +78 -2
  27. package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +2116 -223
  28. package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +997 -332
  29. package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +0 -1
  30. package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +78 -1
  31. package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +418 -36
  32. package/ios/Sources/CapacitorUpdaterPlugin/WebViewStatsReporter.swift +276 -0
  33. package/package.json +15 -3
@@ -42,14 +42,29 @@ declare module '@capacitor/cli' {
42
42
  */
43
43
  autoDeletePrevious?: boolean;
44
44
  /**
45
- * Configure whether the plugin should use Auto Update via an update server.
45
+ * Configure how the plugin checks for, downloads, and applies live updates.
46
+ *
47
+ * The plugin checks for updates when the app moves to the foreground and, if
48
+ * {@link periodCheckDelay} is set, on a repeating timer while the app stays open.
49
+ *
50
+ * Boolean values keep their existing behavior:
51
+ * - `true`: Same as `"atBackground"`.
52
+ * - `false`: Same as `"off"`.
53
+ *
54
+ * String values merge the previous Auto Update and Direct Update configuration:
55
+ * - `"off"`: Disable automatic update checks.
56
+ * - `"atBackground"`: Check and download automatically on each foreground check, then apply the update the next time the app moves to background.
57
+ * - `"atInstall"`: Apply immediately only after a fresh install or native app store update; otherwise use `"atBackground"` behavior.
58
+ * - `"onLaunch"`: Apply immediately only when the app is brought to the foreground from a killed state (cold start). After that first check, fall back to `"atBackground"` behavior.
59
+ * - `"always"`: Check on every foreground transition and apply immediately whenever an update is available.
60
+ * - `"onlyDownload"`: Check and download automatically, emit `updateAvailable`, and never set the next bundle or apply an update automatically.
46
61
  *
47
62
  * Only available for Android and iOS.
48
63
  *
49
64
  * @default true
50
- * @example false
65
+ * @example "onlyDownload"
51
66
  */
52
- autoUpdate?: boolean;
67
+ autoUpdate?: boolean | 'off' | 'atBackground' | 'atInstall' | 'onLaunch' | 'always' | 'onlyDownload';
53
68
  /**
54
69
  * Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device.
55
70
  * 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.
@@ -81,6 +96,10 @@ declare module '@capacitor/cli' {
81
96
  * Configure the URL / endpoint to which update statistics are sent.
82
97
  *
83
98
  * Only available for Android and iOS. Set to "" to disable stats reporting.
99
+ * Native stats include update lifecycle events, app health signals such as crashes,
100
+ * Android ANRs, low-memory exits, iOS memory warnings, and WebView health signals
101
+ * such as JavaScript errors, unhandled promise rejections, resource load failures,
102
+ * WebView renderer exits, and unclean WebView restarts when available.
84
103
  *
85
104
  * @default https://plugin.capgo.app/stats
86
105
  * @example https://example.com/api/stats
@@ -107,12 +126,14 @@ declare module '@capacitor/cli' {
107
126
  version?: string;
108
127
  /**
109
128
  * Configure when the plugin should direct install updates. Only for autoUpdate mode.
129
+ *
130
+ * @deprecated Use {@link PluginsConfig.CapacitorUpdater.autoUpdate} string modes instead.
110
131
  * Works well for apps less than 10MB and with uploads done using --delta flag.
111
132
  * Zip or apps more than 10MB will be relatively slow for users to update.
112
- * - false: Never do direct updates (use default behavior: download at start, set when backgrounded)
113
- * - atInstall: Direct update only when app is installed, updated from store, otherwise act as directUpdate = false
114
- * - onLaunch: Direct update only on app installed, updated from store or after app kill, otherwise act as directUpdate = false
115
- * - always: Direct update in all previous cases (app installed, updated from store, after app kill or app resume), never act as directUpdate = false
133
+ * - false: Never do direct updates (use default behavior: download on foreground check, apply when backgrounded)
134
+ * - atInstall: Direct update only after app install or native app store update, otherwise act as directUpdate = false
135
+ * - onLaunch: Direct update only when the app is brought to the foreground from a killed state, otherwise act as directUpdate = false
136
+ * - always: Direct update on every foreground check whenever an update is available, never act as directUpdate = false
116
137
  * - true: (deprecated) Same as "always" for backward compatibility
117
138
  *
118
139
  * Activate this flag will automatically make the CLI upload delta in CICD envs and will ask for confirmation in local uploads.
@@ -125,9 +146,9 @@ declare module '@capacitor/cli' {
125
146
  /**
126
147
  * 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.
127
148
  * This removes the need to manually listen for appReady events and call SplashScreen.hide().
128
- * Only works when directUpdate is set to "atInstall", "always", "onLaunch", or true.
149
+ * 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.
129
150
  * Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false.
130
- * Requires autoUpdate and directUpdate to be enabled.
151
+ * Requires Auto Update and Direct Update behavior to be enabled.
131
152
  *
132
153
  * Only available for Android and iOS.
133
154
  *
@@ -250,6 +271,16 @@ declare module '@capacitor/cli' {
250
271
  * @since 7.20.0
251
272
  */
252
273
  allowManualBundleError?: boolean;
274
+ /**
275
+ * Allow JavaScript to start a native preview session and temporarily request updates for another app id.
276
+ * This is intended for trusted container apps that implement Expo Go-style preview flows.
277
+ *
278
+ * Only available for Android and iOS.
279
+ *
280
+ * @default false
281
+ * @since 8.47.0
282
+ */
283
+ allowPreview?: boolean;
253
284
  /**
254
285
  * Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts.
255
286
  *
@@ -324,19 +355,30 @@ declare module '@capacitor/cli' {
324
355
  */
325
356
  osLogging?: boolean;
326
357
  /**
327
- * Enable shake gesture to show update menu for debugging/testing purposes
358
+ * Enable the native preview menu gesture while a preview session is active.
359
+ * Outside preview sessions this preview menu is ignored, unless
360
+ * {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector} is enabled.
328
361
  *
329
362
  * @default false
330
363
  * @since 7.5.0
331
364
  */
332
365
  shakeMenu?: boolean;
333
366
  /**
334
- * Enable the shake gesture to show a channel selector menu for switching between update channels.
335
- * When enabled AND `shakeMenu` is true, the shake gesture shows a channel selector
336
- * instead of the default debug menu (Go Home/Reload/Close).
367
+ * Choose which native gesture opens the preview/channel menu.
368
+ * This applies to both {@link PluginsConfig.CapacitorUpdater.shakeMenu}
369
+ * and {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}.
370
+ *
371
+ * Only available for Android and iOS.
337
372
  *
338
- * After selecting a channel, the app automatically checks for updates and downloads if available.
339
- * Only works if channels have `allow_self_set` enabled on the backend.
373
+ * @default 'shake'
374
+ * @since 8.48.0
375
+ */
376
+ shakeMenuGesture?: ShakeMenuGesture;
377
+ /**
378
+ * Enable the native menu gesture to show a channel selector menu for switching between update channels.
379
+ * If {@link PluginsConfig.CapacitorUpdater.shakeMenu} is also enabled while a preview session is active,
380
+ * the shake menu includes both preview actions and channel switching.
381
+ * The native gesture can be changed with {@link PluginsConfig.CapacitorUpdater.shakeMenuGesture}.
340
382
  *
341
383
  * Only available for Android and iOS.
342
384
  *
@@ -440,6 +482,11 @@ export interface CapacitorUpdaterPlugin {
440
482
  * For encrypted bundles, provide the `sessionKey` and `checksum` parameters.
441
483
  * For multi-file delta updates, provide the `manifest` array.
442
484
  *
485
+ * **Android Background Runner note:** `@capacitor/background-runner` loads its
486
+ * configured runner script from native APK assets. Live updates cannot replace
487
+ * that runner script. Keep it stable across OTA updates and ship a native app
488
+ * update when the runner code changes.
489
+ *
443
490
  * @example
444
491
  * const bundle = await CapacitorUpdater.download({
445
492
  * url: `https://example.com/versions/${version}/dist.zip`,
@@ -496,6 +543,102 @@ export interface CapacitorUpdaterPlugin {
496
543
  * @throws {Error} When there is no index.html file inside the bundle folder.
497
544
  */
498
545
  set(options: BundleId): Promise<void>;
546
+ /**
547
+ * Start a temporary preview/testing session.
548
+ *
549
+ * This stores the currently active bundle as the pending fallback, enables the
550
+ * native shake menu, and makes the next applied bundle show a native notice
551
+ * explaining that shaking the device can reload or leave the preview.
552
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.
553
+ * When `appId` is provided, the preview session temporarily uses that app id
554
+ * for update checks until the user leaves the preview. Native updater stats are
555
+ * skipped while the preview session is active.
556
+ *
557
+ * Use this before calling {@link set} for Expo Go-style preview flows.
558
+ * Use {@link listPreviews}, {@link setPreview}, {@link resetPreview},
559
+ * {@link deletePreview}, {@link checkPreviewUpdate}, and
560
+ * {@link updatePreview} to manage saved local previews.
561
+ *
562
+ * @param options Optional preview session options.
563
+ * @returns {Promise<void>} Resolves when preview session state is prepared.
564
+ * @since 8.47.0
565
+ */
566
+ startPreviewSession(options?: StartPreviewSessionOptions): Promise<void>;
567
+ /**
568
+ * Get every locally available preview bundle that was registered by
569
+ * {@link startPreviewSession} and later applied with {@link set}.
570
+ *
571
+ * This only returns previews whose bundles are still available locally. It is
572
+ * safe to show this in a preview switcher or native debug menu.
573
+ *
574
+ * @returns {Promise<PreviewListResult>} Locally available previews and current preview state.
575
+ * @throws {Error} If preview sessions are not enabled by config.
576
+ * @since 8.49.0
577
+ */
578
+ listPreviews(): Promise<PreviewListResult>;
579
+ /**
580
+ * Switch to a locally available preview bundle and reload the WebView.
581
+ *
582
+ * If the app is not already in a preview session, the current live bundle is
583
+ * saved as the fallback so {@link resetPreview} or the native shake menu can
584
+ * return to it later.
585
+ *
586
+ * @param options A {@link BundleId} object containing the preview bundle ID.
587
+ * @returns {Promise<void>} Resolves once the preview switch is staged.
588
+ * @throws {Error} If preview sessions are disabled or the preview is not available locally.
589
+ * @since 8.49.0
590
+ */
591
+ setPreview(options: BundleId): Promise<void>;
592
+ /**
593
+ * Leave the active preview session and reload the saved live bundle.
594
+ *
595
+ * This does not delete any saved previews. Use {@link deletePreview} to remove
596
+ * a preview from local storage.
597
+ *
598
+ * @returns {Promise<void>} Resolves once the live bundle reload is staged.
599
+ * @throws {Error} If there is no preview fallback bundle available.
600
+ * @since 8.49.0
601
+ */
602
+ resetPreview(): Promise<void>;
603
+ /**
604
+ * Delete a locally saved preview and its bundle when possible.
605
+ *
606
+ * Active previews cannot be deleted until you switch away from them or call
607
+ * {@link resetPreview}. If only the preview metadata can be removed, the
608
+ * method still resolves with `deleted: false`.
609
+ *
610
+ * @param options A {@link BundleId} object containing the preview bundle ID.
611
+ * @returns {Promise<DeletePreviewResult>} Whether the underlying bundle was deleted.
612
+ * @throws {Error} If preview sessions are disabled.
613
+ * @since 8.49.0
614
+ */
615
+ deletePreview(options: BundleId): Promise<DeletePreviewResult>;
616
+ /**
617
+ * Check whether a saved preview's payload URL points to a newer preview bundle.
618
+ *
619
+ * Only previews started with a `payloadUrl` can be checked natively. Direct URL
620
+ * previews can still be switched or deleted locally, but the updater does not
621
+ * know where to check for newer versions.
622
+ *
623
+ * @param options A {@link BundleId} object containing the preview bundle ID.
624
+ * @returns {Promise<PreviewUpdateResult>} Update status for the preview.
625
+ * @throws {Error} If preview sessions are disabled or the preview has no payload URL.
626
+ * @since 8.49.0
627
+ */
628
+ checkPreviewUpdate(options: BundleId): Promise<PreviewUpdateResult>;
629
+ /**
630
+ * Download the newest bundle for a saved preview payload URL.
631
+ *
632
+ * If the preview being updated is active, the new bundle is applied and the
633
+ * WebView reloads. Otherwise, the saved preview entry is moved to the newly
634
+ * downloaded bundle and can be selected later with {@link setPreview}.
635
+ *
636
+ * @param options A {@link BundleId} object containing the preview bundle ID.
637
+ * @returns {Promise<PreviewUpdateResult>} The update result and saved preview metadata.
638
+ * @throws {Error} If preview sessions are disabled or the preview cannot be updated.
639
+ * @since 8.49.0
640
+ */
641
+ updatePreview(options: BundleId): Promise<PreviewUpdateResult>;
499
642
  /**
500
643
  * Delete a bundle from local storage to free up disk space.
501
644
  *
@@ -677,6 +820,26 @@ export interface CapacitorUpdaterPlugin {
677
820
  * @since 4.0.0
678
821
  */
679
822
  cancelDelay(): Promise<void>;
823
+ /**
824
+ * Trigger the native auto-update check/download pipeline immediately.
825
+ *
826
+ * This starts the same background update flow used when the app moves to the
827
+ * foreground with auto-update enabled. It is useful for native integrations
828
+ * such as a silent push notification asking the app to check for a Capgo
829
+ * bundle without reimplementing the update protocol in JavaScript.
830
+ *
831
+ * The promise resolves after the native background work has been queued, not
832
+ * after the update has been downloaded or installed. Listen to updater events
833
+ * such as `updateAvailable`, `downloadComplete`, `downloadFailed`, and
834
+ * `noNeedUpdate` for the final result.
835
+ *
836
+ * Native support is available on iOS and Android. On Web, this method returns
837
+ * a result with `status: 'unavailable'`. Native platforms also return
838
+ * `unavailable` when the native auto-update system is disabled.
839
+ *
840
+ * @returns {Promise<TriggerUpdateCheckResult>} Whether a native update check was queued.
841
+ */
842
+ triggerUpdateCheck(): Promise<TriggerUpdateCheckResult>;
680
843
  /**
681
844
  * Check the update server for the latest available bundle version.
682
845
  *
@@ -725,12 +888,64 @@ export interface CapacitorUpdaterPlugin {
725
888
  * @since 4.0.0
726
889
  */
727
890
  getLatest(options?: GetLatestOptions): Promise<LatestVersion>;
891
+ /**
892
+ * Return the manifest entries that still need to be downloaded for a partial update.
893
+ *
894
+ * Pass the result from {@link getLatest} directly when it includes a `manifest`.
895
+ * The native plugin compares each manifest entry with the files already available
896
+ * in the builtin bundle and the local delta cache. Entries that can be reused are
897
+ * omitted from the returned `missing` list.
898
+ *
899
+ * For encrypted manifests, pass the `sessionKey` returned by {@link getLatest} so
900
+ * encrypted file hashes can be checked against local files.
901
+ *
902
+ * ```typescript
903
+ * const latest = await CapacitorUpdater.getLatest();
904
+ * const missing = await CapacitorUpdater.getMissingBundleFiles(latest);
905
+ * ```
906
+ *
907
+ * @param options A {@link GetMissingBundleFilesOptions} object, or a {@link LatestVersion} response containing `manifest`.
908
+ * @returns {Promise<GetMissingBundleFilesResult>} The manifest entries that require network download.
909
+ * @throws {Error} If the manifest is missing or invalid.
910
+ * @since 8.47.0
911
+ */
912
+ getMissingBundleFiles(options: GetMissingBundleFilesOptions): Promise<GetMissingBundleFilesResult>;
913
+ /**
914
+ * Estimate the download size for manifest entries before downloading them.
915
+ *
916
+ * This method sends the provided manifest entries to the Capgo update endpoint
917
+ * once and reads the stored manifest `file_size` metadata. It does not perform
918
+ * per-file `HEAD` requests from the app.
919
+ *
920
+ * Use this after {@link getMissingBundleFiles} to estimate only the files this
921
+ * device still needs:
922
+ *
923
+ * ```typescript
924
+ * const latest = await CapacitorUpdater.getLatest();
925
+ * const missing = await CapacitorUpdater.getMissingBundleFiles(latest);
926
+ * const size = await CapacitorUpdater.getBundleDownloadSize({
927
+ * version: latest.version,
928
+ * manifest: missing.missing,
929
+ * });
930
+ * ```
931
+ *
932
+ * @param options A {@link GetBundleDownloadSizeOptions} object containing manifest entries.
933
+ * @returns {Promise<GetBundleDownloadSizeResult>} Known byte totals and per-file size results.
934
+ * @throws {Error} If the manifest is missing or invalid.
935
+ * @since 8.47.0
936
+ */
937
+ getBundleDownloadSize(options: GetBundleDownloadSizeOptions): Promise<GetBundleDownloadSizeResult>;
728
938
  /**
729
939
  * Assign this device to a specific update channel at runtime.
730
940
  *
731
941
  * Channels allow you to distribute different bundle versions to different groups of users
732
942
  * (e.g., "production", "beta", "staging"). This method switches the device to a new channel.
733
943
  *
944
+ * **Device Override UI:** `setChannel()` validates the channel with the backend, then stores the
945
+ * selected channel locally on the device. It does not create or update a backend Device Override,
946
+ * so the device will not appear as overridden in the Capgo dashboard. Only assignments created
947
+ * from the dashboard or the Public API are shown in the Device Override UI.
948
+ *
734
949
  * **Requirements:**
735
950
  * - The target channel must allow self-assignment (configured in your Capgo dashboard or backend)
736
951
  * - The backend may accept or reject the request based on channel settings
@@ -757,7 +972,8 @@ export interface CapacitorUpdaterPlugin {
757
972
  * });
758
973
  * ```
759
974
  *
760
- * This sends a request to the Capgo backend linking your device ID to the specified channel.
975
+ * This sends a request to the Capgo backend to validate the specified channel, then stores the
976
+ * channel locally on the device.
761
977
  *
762
978
  * @param options The {@link SetChannelOptions} containing the channel name and optional auto-update trigger.
763
979
  * @returns {Promise<ChannelRes>} Channel operation result with status and optional error/message.
@@ -766,11 +982,12 @@ export interface CapacitorUpdaterPlugin {
766
982
  */
767
983
  setChannel(options: SetChannelOptions): Promise<ChannelRes>;
768
984
  /**
769
- * Remove the device's channel assignment and return to the default channel.
985
+ * Remove the plugin-managed local channel assignment and return to the default channel.
770
986
  *
771
- * This unlinks the device from any specifically assigned channel, causing it to fall back to:
987
+ * This clears only the channel stored locally by {@link setChannel}; it does not delete Dashboard or Public API Device Override records. After the local assignment is cleared, normal channel precedence applies:
988
+ * - An existing Dashboard or Public API Device Override, if one exists
772
989
  * - The {@link PluginsConfig.CapacitorUpdater.defaultChannel} if configured, or
773
- * - Your backend's default channel for this app
990
+ * - Your backend default channel for this app
774
991
  *
775
992
  * Use this when:
776
993
  * - Users opt out of beta/testing programs
@@ -797,6 +1014,9 @@ export interface CapacitorUpdaterPlugin {
797
1014
  * - Check if a device is on a specific channel before showing features
798
1015
  * - Verify channel assignment after calling {@link setChannel}
799
1016
  *
1017
+ * On native platforms, a successful response also refreshes the locally persisted
1018
+ * default channel used by update checks.
1019
+ *
800
1020
  * @returns {Promise<GetChannelRes>} The current channel information.
801
1021
  * @throws {Error} If the operation fails.
802
1022
  * @since 4.8.0
@@ -878,7 +1098,7 @@ export interface CapacitorUpdaterPlugin {
878
1098
  * **Privacy & Security characteristics:**
879
1099
  * - Generated as a UUID (not based on hardware identifiers)
880
1100
  * - Stored securely in platform-specific secure storage
881
- * - Android: Android Keystore (persists across app reinstalls on API 23+)
1101
+ * - Android: mirrored into backup-restorable app preferences for reinstall restore
882
1102
  * - iOS: Keychain with `kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly`
883
1103
  * - Not synced to cloud (iOS)
884
1104
  * - Follows Apple and Google privacy best practices
@@ -886,7 +1106,9 @@ export interface CapacitorUpdaterPlugin {
886
1106
  *
887
1107
  * **Persistence:**
888
1108
  * The device ID persists across app reinstalls to maintain consistent device identity
889
- * for update tracking and analytics.
1109
+ * for update tracking and analytics when platform storage is preserved. On Android,
1110
+ * apps with custom backup rules must keep the plugin app preferences eligible for
1111
+ * backup/restore; disabling Android backup or clearing app data creates a new ID.
890
1112
  *
891
1113
  * Use this to:
892
1114
  * - Debug update delivery issues (check what ID the server sees)
@@ -1144,23 +1366,20 @@ export interface CapacitorUpdaterPlugin {
1144
1366
  */
1145
1367
  getFailedUpdate(): Promise<UpdateFailedEvent | null>;
1146
1368
  /**
1147
- * Enable or disable the shake gesture menu for debugging and testing.
1369
+ * Enable or disable the native preview menu gesture.
1148
1370
  *
1149
- * When enabled, users can shake their device to open a debug menu that shows:
1150
- * - Current bundle information
1151
- * - Available bundles
1152
- * - Options to switch bundles manually
1153
- * - Update status
1371
+ * During preview sessions, users can use the configured native gesture to:
1372
+ * - Reload the current preview
1373
+ * - Leave the test app and return to the fallback bundle
1374
+ * - Switch update channel, when {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector} is also enabled
1154
1375
  *
1155
- * This is useful during development and testing to:
1156
- * - Quickly test different bundle versions
1157
- * - Debug update flows
1158
- * - Switch between production and test bundles
1159
- * - Verify bundle installations
1376
+ * Outside preview sessions, this preview menu is ignored. The channel selector can still be
1377
+ * shown outside preview sessions when {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector} is enabled.
1160
1378
  *
1161
1379
  * **Important:** Disable this in production builds or only enable for internal testers.
1162
1380
  *
1163
- * Can also be configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.
1381
+ * This can also be configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.
1382
+ * The native gesture is configured via {@link PluginsConfig.CapacitorUpdater.shakeMenuGesture}.
1164
1383
  *
1165
1384
  * @param options {@link SetShakeMenuOptions} with `enabled: true` to enable or `enabled: false` to disable.
1166
1385
  * @returns {Promise<void>} Resolves when the setting is applied.
@@ -1169,7 +1388,7 @@ export interface CapacitorUpdaterPlugin {
1169
1388
  */
1170
1389
  setShakeMenu(options: SetShakeMenuOptions): Promise<void>;
1171
1390
  /**
1172
- * Check if the shake gesture debug menu is currently enabled.
1391
+ * Check if the native preview menu gesture is currently enabled.
1173
1392
  *
1174
1393
  * Returns the current state of the shake menu feature that can be toggled via
1175
1394
  * {@link setShakeMenu} or configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.
@@ -1179,22 +1398,20 @@ export interface CapacitorUpdaterPlugin {
1179
1398
  * - Show/hide debug settings UI
1180
1399
  * - Verify configuration during testing
1181
1400
  *
1182
- * @returns {Promise<ShakeMenuEnabled>} Object with `enabled: true` or `enabled: false`.
1401
+ * @returns {Promise<ShakeMenuEnabled>} Object with the current enabled state and gesture.
1183
1402
  * @throws {Error} If the operation fails.
1184
1403
  * @since 7.5.0
1185
1404
  */
1186
1405
  isShakeMenuEnabled(): Promise<ShakeMenuEnabled>;
1187
1406
  /**
1188
- * Enable or disable the shake channel selector at runtime.
1407
+ * Enable or disable the channel selector menu gesture at runtime.
1189
1408
  *
1190
- * When enabled AND shakeMenu is true, shaking the device shows a channel
1191
- * selector instead of the debug menu. This allows users to switch between
1192
- * update channels by shaking their device.
1409
+ * When enabled, the configured native gesture can show a channel selector, including outside preview sessions.
1410
+ * If {@link setShakeMenu} is also enabled while a preview session is active, the shake menu includes
1411
+ * both preview actions and channel switching.
1193
1412
  *
1194
- * After selecting a channel, the app automatically checks for updates
1195
- * and downloads if available.
1196
- *
1197
- * Can also be configured via {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}.
1413
+ * This can also be configured via {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}.
1414
+ * The native gesture is configured via {@link PluginsConfig.CapacitorUpdater.shakeMenuGesture}.
1198
1415
  *
1199
1416
  * @param options {@link SetShakeChannelSelectorOptions} with `enabled: true` to enable or `enabled: false` to disable.
1200
1417
  * @returns {Promise<void>} Resolves when the setting is applied.
@@ -1474,7 +1691,7 @@ export interface ChannelInfo {
1474
1691
  *
1475
1692
  * @since 7.5.0
1476
1693
  */
1477
- id: string;
1694
+ id: number;
1478
1695
  /**
1479
1696
  * The channel name
1480
1697
  *
@@ -1591,6 +1808,128 @@ export interface ManifestEntry {
1591
1808
  file_hash: string | null;
1592
1809
  download_url: string | null;
1593
1810
  }
1811
+ export interface GetMissingBundleFilesOptions {
1812
+ /**
1813
+ * Manifest returned by {@link getLatest}. Passing the full {@link LatestVersion}
1814
+ * response is supported because it contains this field.
1815
+ *
1816
+ * @since 8.47.0
1817
+ */
1818
+ manifest?: ManifestEntry[];
1819
+ /**
1820
+ * Target bundle version. Passing the full {@link LatestVersion} response is
1821
+ * supported because it contains this field.
1822
+ *
1823
+ * @since 8.47.0
1824
+ */
1825
+ version?: string;
1826
+ /**
1827
+ * Session key returned by {@link getLatest}, required only when file hashes are encrypted.
1828
+ *
1829
+ * @since 8.47.0
1830
+ */
1831
+ sessionKey?: string;
1832
+ }
1833
+ export interface GetMissingBundleFilesResult {
1834
+ /**
1835
+ * Entries that are not available locally and need to be downloaded.
1836
+ *
1837
+ * @since 8.47.0
1838
+ */
1839
+ missing: ManifestEntry[];
1840
+ /**
1841
+ * Total entries in the provided manifest.
1842
+ *
1843
+ * @since 8.47.0
1844
+ */
1845
+ total: number;
1846
+ /**
1847
+ * Number of entries that need to be downloaded.
1848
+ *
1849
+ * @since 8.47.0
1850
+ */
1851
+ missingCount: number;
1852
+ /**
1853
+ * Number of entries that can be reused from builtin files or local cache.
1854
+ *
1855
+ * @since 8.47.0
1856
+ */
1857
+ reusableCount: number;
1858
+ }
1859
+ export interface GetBundleDownloadSizeOptions {
1860
+ /**
1861
+ * Manifest entries to estimate. Pass `missing.missing` from {@link getMissingBundleFiles}
1862
+ * to estimate only the bytes this device still needs to download.
1863
+ *
1864
+ * @since 8.47.0
1865
+ */
1866
+ manifest?: ManifestEntry[];
1867
+ /**
1868
+ * Target bundle version. Pass `latest.version` when estimating files returned
1869
+ * by {@link getLatest}.
1870
+ *
1871
+ * @since 8.47.0
1872
+ */
1873
+ version?: string;
1874
+ }
1875
+ export interface BundleFileSize {
1876
+ /**
1877
+ * File name from the manifest entry.
1878
+ *
1879
+ * @since 8.47.0
1880
+ */
1881
+ file_name: string | null;
1882
+ /**
1883
+ * File hash from the manifest entry.
1884
+ *
1885
+ * @since 8.47.0
1886
+ */
1887
+ file_hash: string | null;
1888
+ /**
1889
+ * Download URL from the manifest entry.
1890
+ *
1891
+ * @since 8.47.0
1892
+ */
1893
+ download_url: string | null;
1894
+ /**
1895
+ * Estimated bytes to download when the server exposes a size.
1896
+ *
1897
+ * @since 8.47.0
1898
+ */
1899
+ size?: number;
1900
+ /**
1901
+ * Error for this entry when the size could not be determined.
1902
+ *
1903
+ * @since 8.47.0
1904
+ */
1905
+ error?: string;
1906
+ }
1907
+ export interface GetBundleDownloadSizeResult {
1908
+ /**
1909
+ * Sum of all known file sizes in bytes.
1910
+ *
1911
+ * @since 8.47.0
1912
+ */
1913
+ totalSize: number;
1914
+ /**
1915
+ * Number of files with a known size.
1916
+ *
1917
+ * @since 8.47.0
1918
+ */
1919
+ knownFiles: number;
1920
+ /**
1921
+ * Number of files whose size could not be determined.
1922
+ *
1923
+ * @since 8.47.0
1924
+ */
1925
+ unknownFiles: number;
1926
+ /**
1927
+ * Per-file size results.
1928
+ *
1929
+ * @since 8.47.0
1930
+ */
1931
+ files: BundleFileSize[];
1932
+ }
1594
1933
  export interface LatestVersion {
1595
1934
  /**
1596
1935
  * Result of getLatest method
@@ -1647,6 +1986,20 @@ export interface LatestVersion {
1647
1986
  * @since 6.1
1648
1987
  */
1649
1988
  manifest?: ManifestEntry[];
1989
+ /**
1990
+ * Missing manifest entries for this device when {@link GetLatestOptions.includeBundleSize}
1991
+ * is enabled.
1992
+ *
1993
+ * @since 8.47.0
1994
+ */
1995
+ missing?: GetMissingBundleFilesResult;
1996
+ /**
1997
+ * Estimated download size for missing manifest entries when
1998
+ * {@link GetLatestOptions.includeBundleSize} is enabled.
1999
+ *
2000
+ * @since 8.47.0
2001
+ */
2002
+ downloadSize?: GetBundleDownloadSizeResult;
1650
2003
  /**
1651
2004
  * Optional link associated with this bundle version (e.g., release notes URL, changelog, GitHub release).
1652
2005
  * @since 7.35.0
@@ -1694,6 +2047,193 @@ export interface GetLatestOptions {
1694
2047
  * @default undefined
1695
2048
  */
1696
2049
  channel?: string;
2050
+ /**
2051
+ * Temporarily use another app id for this update check while using a trusted preview container.
2052
+ * This only changes the app id sent by this request; it does not persist a preview session.
2053
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.
2054
+ * @since 8.47.0
2055
+ * @default undefined
2056
+ */
2057
+ appId?: string;
2058
+ /**
2059
+ * When true, the native plugin computes which manifest files are missing on
2060
+ * this device and asks the Capgo update endpoint for their stored sizes before
2061
+ * resolving {@link getLatest}.
2062
+ *
2063
+ * This adds one backend request only when the update response contains a
2064
+ * manifest. It does not perform per-file network checks.
2065
+ *
2066
+ * @since 8.47.0
2067
+ * @default false
2068
+ */
2069
+ includeBundleSize?: boolean;
2070
+ }
2071
+ export interface StartPreviewSessionOptions {
2072
+ /**
2073
+ * App id to use while the preview session is active.
2074
+ * The previous app id is restored when leaving the preview session.
2075
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.
2076
+ * @since 8.47.0
2077
+ * @default undefined
2078
+ */
2079
+ appId?: string;
2080
+ /**
2081
+ * HTTP(S) URL returning a preview download payload.
2082
+ * When provided, the native shake reload action fetches this payload again
2083
+ * before reloading so channel previews can move to the latest bundle.
2084
+ * Requires {@link PluginsConfig.CapacitorUpdater.allowPreview} to be `true`.
2085
+ * @since 8.48.0
2086
+ * @default undefined
2087
+ */
2088
+ payloadUrl?: string;
2089
+ /**
2090
+ * Human-readable preview name stored with the next preview bundle applied by
2091
+ * {@link set}. Native preview menus and {@link listPreviews} can display it.
2092
+ * @since 8.49.0
2093
+ * @default undefined
2094
+ */
2095
+ name?: string;
2096
+ /**
2097
+ * Optional source label for the preview, such as `channel`, `bundle`, `url`,
2098
+ * or `payload`. This is stored as metadata only.
2099
+ * @since 8.49.0
2100
+ * @default undefined
2101
+ */
2102
+ source?: string;
2103
+ }
2104
+ export interface PreviewInfo {
2105
+ /**
2106
+ * Preview bundle id.
2107
+ *
2108
+ * @since 8.49.0
2109
+ */
2110
+ id: string;
2111
+ /**
2112
+ * Locally downloaded bundle backing this preview.
2113
+ *
2114
+ * @since 8.49.0
2115
+ */
2116
+ bundle: BundleInfo;
2117
+ /**
2118
+ * Human-readable name supplied when the preview was started.
2119
+ *
2120
+ * @since 8.49.0
2121
+ */
2122
+ name?: string;
2123
+ /**
2124
+ * Metadata source label supplied when the preview was started.
2125
+ *
2126
+ * @since 8.49.0
2127
+ */
2128
+ source?: string;
2129
+ /**
2130
+ * Preview app id, when the session uses an app id override.
2131
+ *
2132
+ * @since 8.49.0
2133
+ */
2134
+ appId?: string;
2135
+ /**
2136
+ * Payload URL used to refresh this preview.
2137
+ *
2138
+ * @since 8.49.0
2139
+ */
2140
+ payloadUrl?: string;
2141
+ /**
2142
+ * ISO timestamp for when this preview was first saved.
2143
+ *
2144
+ * @since 8.49.0
2145
+ */
2146
+ createdAt: string;
2147
+ /**
2148
+ * ISO timestamp for the last metadata or bundle update.
2149
+ *
2150
+ * @since 8.49.0
2151
+ */
2152
+ updatedAt: string;
2153
+ /**
2154
+ * ISO timestamp for the last time this preview was activated.
2155
+ *
2156
+ * @since 8.49.0
2157
+ */
2158
+ lastUsedAt: string;
2159
+ /**
2160
+ * Whether this preview is the currently active bundle in a preview session.
2161
+ *
2162
+ * @since 8.49.0
2163
+ */
2164
+ isActive: boolean;
2165
+ }
2166
+ export interface PreviewListResult {
2167
+ /**
2168
+ * Locally available preview bundles.
2169
+ *
2170
+ * @since 8.49.0
2171
+ */
2172
+ previews: PreviewInfo[];
2173
+ /**
2174
+ * Current preview when a preview session is active.
2175
+ *
2176
+ * @since 8.49.0
2177
+ */
2178
+ current?: PreviewInfo;
2179
+ /**
2180
+ * Bundle currently loaded by the WebView.
2181
+ *
2182
+ * @since 8.49.0
2183
+ */
2184
+ currentBundle: BundleInfo;
2185
+ /**
2186
+ * Bundle that will be restored when leaving preview mode.
2187
+ *
2188
+ * @since 8.49.0
2189
+ */
2190
+ liveBundle?: BundleInfo;
2191
+ }
2192
+ export interface DeletePreviewResult {
2193
+ /**
2194
+ * Whether preview metadata was removed.
2195
+ *
2196
+ * @since 8.49.0
2197
+ */
2198
+ removed: boolean;
2199
+ /**
2200
+ * Whether the underlying local bundle was deleted.
2201
+ *
2202
+ * @since 8.49.0
2203
+ */
2204
+ deleted: boolean;
2205
+ }
2206
+ export interface PreviewUpdateResult {
2207
+ /**
2208
+ * Saved preview metadata after the check or update.
2209
+ *
2210
+ * @since 8.49.0
2211
+ */
2212
+ preview: PreviewInfo;
2213
+ /**
2214
+ * Latest version returned by the preview payload endpoint.
2215
+ *
2216
+ * @since 8.49.0
2217
+ */
2218
+ latestVersion?: string;
2219
+ /**
2220
+ * Whether the saved preview already matches the latest payload version.
2221
+ *
2222
+ * @since 8.49.0
2223
+ */
2224
+ upToDate: boolean;
2225
+ /**
2226
+ * Whether a newer bundle was downloaded and saved.
2227
+ *
2228
+ * @since 8.49.0
2229
+ */
2230
+ updated: boolean;
2231
+ /**
2232
+ * New bundle when {@link updatePreview} downloaded one.
2233
+ *
2234
+ * @since 8.49.0
2235
+ */
2236
+ bundle?: BundleInfo;
1697
2237
  }
1698
2238
  export interface AppReadyResult {
1699
2239
  bundle: BundleInfo;
@@ -1790,11 +2330,48 @@ export interface AutoUpdateEnabled {
1790
2330
  export interface AutoUpdateAvailable {
1791
2331
  available: boolean;
1792
2332
  }
2333
+ /**
2334
+ * Result returned after requesting an immediate native auto-update check.
2335
+ *
2336
+ * @property status - Native trigger state: `queued` when a check was queued,
2337
+ * `already_running` when the native update pipeline is already active, or
2338
+ * `unavailable` on Web or when native auto-update is disabled.
2339
+ * @property queued - Whether a new native update check was queued. This is
2340
+ * `true` only when `status` is `queued`; otherwise it is `false`.
2341
+ */
2342
+ export interface TriggerUpdateCheckResult {
2343
+ /**
2344
+ * Native trigger state: `queued` when a check was queued, `already_running`
2345
+ * when the native update pipeline is already active, or `unavailable` on Web
2346
+ * or when native auto-update is disabled.
2347
+ */
2348
+ status: 'queued' | 'already_running' | 'unavailable';
2349
+ /**
2350
+ * Whether a new native update check was queued. This is `true` only when
2351
+ * `status` is `queued`; otherwise it is `false`.
2352
+ */
2353
+ queued: boolean;
2354
+ }
2355
+ /**
2356
+ * Native gesture options that open the shake menu.
2357
+ *
2358
+ * Supported values are `shake` and `threeFingerPinch`.
2359
+ *
2360
+ * @public
2361
+ */
2362
+ export type ShakeMenuGesture = 'shake' | 'threeFingerPinch';
1793
2363
  export interface SetShakeMenuOptions {
1794
2364
  enabled: boolean;
1795
2365
  }
1796
2366
  export interface ShakeMenuEnabled {
1797
2367
  enabled: boolean;
2368
+ /**
2369
+ * The currently configured native gesture used to open the preview/channel menu.
2370
+ * Undefined means consumers should treat the gesture as the default `shake` behavior.
2371
+ *
2372
+ * @since 8.48.0
2373
+ */
2374
+ gesture?: ShakeMenuGesture;
1798
2375
  }
1799
2376
  export interface SetShakeChannelSelectorOptions {
1800
2377
  enabled: boolean;