@capgo/capacitor-updater 8.48.0 → 8.49.1

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.
@@ -552,12 +552,90 @@ export interface CapacitorUpdaterPlugin {
552
552
  * skipped while the preview session is active.
553
553
  *
554
554
  * Use this before calling {@link set} for Expo Go-style preview flows.
555
+ * Use {@link listPreviews}, {@link setPreview}, {@link resetPreview},
556
+ * {@link deletePreview}, {@link checkPreviewUpdate}, and
557
+ * {@link updatePreview} to manage saved local previews.
555
558
  *
556
559
  * @param options Optional preview session options.
557
560
  * @returns {Promise<void>} Resolves when preview session state is prepared.
558
561
  * @since 8.47.0
559
562
  */
560
563
  startPreviewSession(options?: StartPreviewSessionOptions): Promise<void>;
564
+ /**
565
+ * Get every locally available preview bundle that was registered by
566
+ * {@link startPreviewSession} and later applied with {@link set}.
567
+ *
568
+ * This only returns previews whose bundles are still available locally. It is
569
+ * safe to show this in a preview switcher or native debug menu.
570
+ *
571
+ * @returns {Promise<PreviewListResult>} Locally available previews and current preview state.
572
+ * @throws {Error} If preview sessions are not enabled by config.
573
+ * @since 8.49.0
574
+ */
575
+ listPreviews(): Promise<PreviewListResult>;
576
+ /**
577
+ * Switch to a locally available preview bundle and reload the WebView.
578
+ *
579
+ * If the app is not already in a preview session, the current live bundle is
580
+ * saved as the fallback so {@link resetPreview} or the native shake menu can
581
+ * return to it later.
582
+ *
583
+ * @param options A {@link BundleId} object containing the preview bundle ID.
584
+ * @returns {Promise<void>} Resolves once the preview switch is staged.
585
+ * @throws {Error} If preview sessions are disabled or the preview is not available locally.
586
+ * @since 8.49.0
587
+ */
588
+ setPreview(options: BundleId): Promise<void>;
589
+ /**
590
+ * Leave the active preview session and reload the saved live bundle.
591
+ *
592
+ * This does not delete any saved previews. Use {@link deletePreview} to remove
593
+ * a preview from local storage.
594
+ *
595
+ * @returns {Promise<void>} Resolves once the live bundle reload is staged.
596
+ * @throws {Error} If there is no preview fallback bundle available.
597
+ * @since 8.49.0
598
+ */
599
+ resetPreview(): Promise<void>;
600
+ /**
601
+ * Delete a locally saved preview and its bundle when possible.
602
+ *
603
+ * Active previews cannot be deleted until you switch away from them or call
604
+ * {@link resetPreview}. If only the preview metadata can be removed, the
605
+ * method still resolves with `deleted: false`.
606
+ *
607
+ * @param options A {@link BundleId} object containing the preview bundle ID.
608
+ * @returns {Promise<DeletePreviewResult>} Whether the underlying bundle was deleted.
609
+ * @throws {Error} If preview sessions are disabled.
610
+ * @since 8.49.0
611
+ */
612
+ deletePreview(options: BundleId): Promise<DeletePreviewResult>;
613
+ /**
614
+ * Check whether a saved preview's payload URL points to a newer preview bundle.
615
+ *
616
+ * Only previews started with a `payloadUrl` can be checked natively. Direct URL
617
+ * previews can still be switched or deleted locally, but the updater does not
618
+ * know where to check for newer versions.
619
+ *
620
+ * @param options A {@link BundleId} object containing the preview bundle ID.
621
+ * @returns {Promise<PreviewUpdateResult>} Update status for the preview.
622
+ * @throws {Error} If preview sessions are disabled or the preview has no payload URL.
623
+ * @since 8.49.0
624
+ */
625
+ checkPreviewUpdate(options: BundleId): Promise<PreviewUpdateResult>;
626
+ /**
627
+ * Download the newest bundle for a saved preview payload URL.
628
+ *
629
+ * If the preview being updated is active, the new bundle is applied and the
630
+ * WebView reloads. Otherwise, the saved preview entry is moved to the newly
631
+ * downloaded bundle and can be selected later with {@link setPreview}.
632
+ *
633
+ * @param options A {@link BundleId} object containing the preview bundle ID.
634
+ * @returns {Promise<PreviewUpdateResult>} The update result and saved preview metadata.
635
+ * @throws {Error} If preview sessions are disabled or the preview cannot be updated.
636
+ * @since 8.49.0
637
+ */
638
+ updatePreview(options: BundleId): Promise<PreviewUpdateResult>;
561
639
  /**
562
640
  * Delete a bundle from local storage to free up disk space.
563
641
  *
@@ -1289,8 +1367,7 @@ export interface CapacitorUpdaterPlugin {
1289
1367
  * **Important:** Disable this in production builds or only enable for internal testers.
1290
1368
  *
1291
1369
  * This can also be configured via {@link PluginsConfig.CapacitorUpdater.shakeMenu}.
1292
- * The native gesture can be configured via {@link PluginsConfig.CapacitorUpdater.shakeMenuGesture}
1293
- * or `options.gesture`.
1370
+ * The native gesture is configured via {@link PluginsConfig.CapacitorUpdater.shakeMenuGesture}.
1294
1371
  *
1295
1372
  * @param options {@link SetShakeMenuOptions} with `enabled: true` to enable or `enabled: false` to disable.
1296
1373
  * @returns {Promise<void>} Resolves when the setting is applied.
@@ -1322,8 +1399,7 @@ export interface CapacitorUpdaterPlugin {
1322
1399
  * both preview actions and channel switching.
1323
1400
  *
1324
1401
  * This can also be configured via {@link PluginsConfig.CapacitorUpdater.allowShakeChannelSelector}.
1325
- * The native gesture can be configured via {@link PluginsConfig.CapacitorUpdater.shakeMenuGesture}
1326
- * or {@link setShakeMenu}.
1402
+ * The native gesture is configured via {@link PluginsConfig.CapacitorUpdater.shakeMenuGesture}.
1327
1403
  *
1328
1404
  * @param options {@link SetShakeChannelSelectorOptions} with `enabled: true` to enable or `enabled: false` to disable.
1329
1405
  * @returns {Promise<void>} Resolves when the setting is applied.
@@ -1998,6 +2074,154 @@ export interface StartPreviewSessionOptions {
1998
2074
  * @default undefined
1999
2075
  */
2000
2076
  payloadUrl?: string;
2077
+ /**
2078
+ * Human-readable preview name stored with the next preview bundle applied by
2079
+ * {@link set}. Native preview menus and {@link listPreviews} can display it.
2080
+ * @since 8.49.0
2081
+ * @default undefined
2082
+ */
2083
+ name?: string;
2084
+ /**
2085
+ * Optional source label for the preview, such as `channel`, `bundle`, `url`,
2086
+ * or `payload`. This is stored as metadata only.
2087
+ * @since 8.49.0
2088
+ * @default undefined
2089
+ */
2090
+ source?: string;
2091
+ }
2092
+ export interface PreviewInfo {
2093
+ /**
2094
+ * Preview bundle id.
2095
+ *
2096
+ * @since 8.49.0
2097
+ */
2098
+ id: string;
2099
+ /**
2100
+ * Locally downloaded bundle backing this preview.
2101
+ *
2102
+ * @since 8.49.0
2103
+ */
2104
+ bundle: BundleInfo;
2105
+ /**
2106
+ * Human-readable name supplied when the preview was started.
2107
+ *
2108
+ * @since 8.49.0
2109
+ */
2110
+ name?: string;
2111
+ /**
2112
+ * Metadata source label supplied when the preview was started.
2113
+ *
2114
+ * @since 8.49.0
2115
+ */
2116
+ source?: string;
2117
+ /**
2118
+ * Preview app id, when the session uses an app id override.
2119
+ *
2120
+ * @since 8.49.0
2121
+ */
2122
+ appId?: string;
2123
+ /**
2124
+ * Payload URL used to refresh this preview.
2125
+ *
2126
+ * @since 8.49.0
2127
+ */
2128
+ payloadUrl?: string;
2129
+ /**
2130
+ * ISO timestamp for when this preview was first saved.
2131
+ *
2132
+ * @since 8.49.0
2133
+ */
2134
+ createdAt: string;
2135
+ /**
2136
+ * ISO timestamp for the last metadata or bundle update.
2137
+ *
2138
+ * @since 8.49.0
2139
+ */
2140
+ updatedAt: string;
2141
+ /**
2142
+ * ISO timestamp for the last time this preview was activated.
2143
+ *
2144
+ * @since 8.49.0
2145
+ */
2146
+ lastUsedAt: string;
2147
+ /**
2148
+ * Whether this preview is the currently active bundle in a preview session.
2149
+ *
2150
+ * @since 8.49.0
2151
+ */
2152
+ isActive: boolean;
2153
+ }
2154
+ export interface PreviewListResult {
2155
+ /**
2156
+ * Locally available preview bundles.
2157
+ *
2158
+ * @since 8.49.0
2159
+ */
2160
+ previews: PreviewInfo[];
2161
+ /**
2162
+ * Current preview when a preview session is active.
2163
+ *
2164
+ * @since 8.49.0
2165
+ */
2166
+ current?: PreviewInfo;
2167
+ /**
2168
+ * Bundle currently loaded by the WebView.
2169
+ *
2170
+ * @since 8.49.0
2171
+ */
2172
+ currentBundle: BundleInfo;
2173
+ /**
2174
+ * Bundle that will be restored when leaving preview mode.
2175
+ *
2176
+ * @since 8.49.0
2177
+ */
2178
+ liveBundle?: BundleInfo;
2179
+ }
2180
+ export interface DeletePreviewResult {
2181
+ /**
2182
+ * Whether preview metadata was removed.
2183
+ *
2184
+ * @since 8.49.0
2185
+ */
2186
+ removed: boolean;
2187
+ /**
2188
+ * Whether the underlying local bundle was deleted.
2189
+ *
2190
+ * @since 8.49.0
2191
+ */
2192
+ deleted: boolean;
2193
+ }
2194
+ export interface PreviewUpdateResult {
2195
+ /**
2196
+ * Saved preview metadata after the check or update.
2197
+ *
2198
+ * @since 8.49.0
2199
+ */
2200
+ preview: PreviewInfo;
2201
+ /**
2202
+ * Latest version returned by the preview payload endpoint.
2203
+ *
2204
+ * @since 8.49.0
2205
+ */
2206
+ latestVersion?: string;
2207
+ /**
2208
+ * Whether the saved preview already matches the latest payload version.
2209
+ *
2210
+ * @since 8.49.0
2211
+ */
2212
+ upToDate: boolean;
2213
+ /**
2214
+ * Whether a newer bundle was downloaded and saved.
2215
+ *
2216
+ * @since 8.49.0
2217
+ */
2218
+ updated: boolean;
2219
+ /**
2220
+ * New bundle when {@link updatePreview} downloaded one.
2221
+ *
2222
+ * @since 8.49.0
2223
+ */
2224
+ bundle?: BundleInfo;
2001
2225
  }
2002
2226
  export interface AppReadyResult {
2003
2227
  bundle: BundleInfo;
@@ -2126,12 +2350,6 @@ export interface TriggerUpdateCheckResult {
2126
2350
  export type ShakeMenuGesture = 'shake' | 'threeFingerPinch';
2127
2351
  export interface SetShakeMenuOptions {
2128
2352
  enabled: boolean;
2129
- /**
2130
- * Native gesture used to open the preview/channel menu.
2131
- *
2132
- * @default 'shake'
2133
- */
2134
- gesture?: ShakeMenuGesture;
2135
2353
  }
2136
2354
  export interface ShakeMenuEnabled {
2137
2355
  enabled: boolean;