native-update-capacitor 4.4.4 โ†’ 4.4.6

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.
@@ -107,7 +107,7 @@ if (eligibility.canRequest) {
107
107
  |--------|-------------|---------|
108
108
  | `sync(options?)` | Check and apply updates | `Promise<SyncResult>` |
109
109
  | `download(options)` | Download specific version | `Promise<BundleInfo>` |
110
- | `set(bundle)` | Set active bundle | `Promise<void>` |
110
+ | `set({ ...bundle, applyOn? })` | Make a bundle the app's bundle: `'now'` (default) switches at once, `'next-start'` (4.4.5+) stages it for the next cold start | `Promise<void>` |
111
111
  | `reload()` | Reload app with current bundle | `Promise<void>` |
112
112
  | `reset()` | Reset to original bundle | `Promise<void>` |
113
113
  | `current()` | Get current bundle info | `Promise<BundleInfo>` |
package/README.md CHANGED
@@ -21,6 +21,16 @@
21
21
 
22
22
  </div>
23
23
 
24
+ <a id="available-on"></a>
25
+ ## ๐Ÿ“ฆ Available on&nbsp;[#](#available-on)
26
+
27
+ | Where | Link |
28
+ |---|---|
29
+ | npm | [`native-update`](https://www.npmjs.com/package/native-update) |
30
+ | Dashboard | [nativeupdate.aoneahsan.com](https://nativeupdate.aoneahsan.com) |
31
+ | Docs | [nativeupdate-docs.aoneahsan.com](https://nativeupdate-docs.aoneahsan.com) |
32
+ | Everything | [All apps](https://nativeupdate-docs.aoneahsan.com/apps) |
33
+
24
34
  > [!IMPORTANT]
25
35
  > Call `NativeUpdate.notifyAppReady()` on **every** successful boot. Activating a bundle marks it
26
36
  > pending-verification, and the native layer rolls it back after two cold starts that never confirm. Miss
@@ -33,7 +43,7 @@ are available as an HTTP API for CI and coding agents.
33
43
 
34
44
  | | |
35
45
  |---|---|
36
- | **Version** | `4.4.4` |
46
+ | **Version** | `4.4.6` |
37
47
  | **License** | Proprietary โ€” free to use in your apps ([LICENSE](./LICENSE)) |
38
48
  | **Node** | `>=24.16.0` (install + CLI toolchain) |
39
49
  | **Platforms** | iOS 14+ ยท Android 8.0+ (API 26) ยท Web |
@@ -44,6 +54,7 @@ are available as an HTTP API for CI and coding agents.
44
54
  <a id="table-of-contents"></a>
45
55
  ## ๐Ÿงญ Table of Contents&nbsp;[#](#table-of-contents)
46
56
 
57
+ - [๐Ÿ“ฆ Available on](#available-on)
47
58
  - [๐Ÿ’ก Why native-update](#why-native-update)
48
59
  - [โœจ Features](#features)
49
60
  - [๐Ÿ“ฑ Platform Support](#platform-support)
@@ -222,6 +233,9 @@ if (latest.available && latest.url && latest.version && latest.checksum) {
222
233
  }
223
234
  ```
224
235
 
236
+ To leave the running app alone, stage the bundle instead: `await NativeUpdate.set({ ...bundle, applyOn: 'next-start' })`
237
+ loads it at the next cold start, where `notifyAppReady()` confirms it.
238
+
225
239
  ### Handle a store update
226
240
 
227
241
  ```ts
@@ -526,7 +540,7 @@ indexed at [`/raw/manifest.json`](https://nativeupdate-docs.aoneahsan.com/raw/ma
526
540
  <a id="changelog"></a>
527
541
  ## ๐Ÿ”„ Changelog&nbsp;[#](#changelog)
528
542
 
529
- Latest release: **`4.4.4`**. `--ota-tag` reads `versionName` only from a real statement in `build.gradle`
543
+ Latest release: **`4.4.6`** (README: every released place; no code changes). 4.4.5: `set()` takes `applyOn: 'next-start'`, which stages a bundle for the next cold start instead of reloading the running app. Before that, 4.4.4: `--ota-tag` reads `versionName` only from a real statement in `build.gradle`
530
544
  (comments and message strings are skipped, `versionName appVersionName` is followed to its value). **`4.4.3`**: Android logs `Built <id> from a N-byte patch` when an update arrives as a `NUDELTA/1`
531
545
  patch, so you can see deltas working on a device. No API change.
532
546
 
@@ -61,7 +61,7 @@ class LiveUpdatePlugin(
61
61
 
62
62
  companion object {
63
63
  /** This plugin's version, sent as X-Sdk-Version. Kept equal to package.json by tests/sdk-version.test.ts. */
64
- const val SDK_VERSION = "4.4.4"
64
+ const val SDK_VERSION = "4.4.6"
65
65
 
66
66
  // SharedPreferences keys. Kept as constants so A2 (boot-time
67
67
  // re-verification) and A3 (crash-loop auto-rollback) stay in sync
@@ -307,6 +307,14 @@ class LiveUpdatePlugin(
307
307
 
308
308
  setActiveBundle(bundleId)
309
309
  persistWebViewBasePath(extractedPath)
310
+ if (call.getString("applyOn") == "next-start") {
311
+ // Staged: Capacitor reads the persisted path at the next cold start. The running WebView is
312
+ // untouched, and this process's notifyAppReady() must not confirm a bundle that has not run.
313
+ stagedForNextStart = bundleId
314
+ call.resolve()
315
+ return
316
+ }
317
+ stagedForNextStart = null
310
318
  // Hop to UI thread; setServerBasePath must run on the WebView's
311
319
  // thread per Capacitor's Bridge contract.
312
320
  activity.runOnUiThread {
@@ -891,6 +899,10 @@ class LiveUpdatePlugin(
891
899
  prefs.edit().putString(bundleId, bundleInfo.toString()).apply()
892
900
  }
893
901
 
902
+ /** A bundle set with applyOn "next-start" in this process; it runs from the next cold start. */
903
+ @Volatile
904
+ private var stagedForNextStart: String? = null
905
+
894
906
  private fun setActiveBundle(bundleId: String) {
895
907
  val prefs = context.getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE)
896
908
  val currentActive = prefs.getString(ACTIVE_BUNDLE_KEY, null)
@@ -1047,6 +1059,11 @@ class LiveUpdatePlugin(
1047
1059
  // signal. Clear the pending-verify state so cold starts after this
1048
1060
  // no longer count against the bundle.
1049
1061
  val prefs = context.getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE)
1062
+ val staged = stagedForNextStart
1063
+ if (staged != null && prefs.getString(PENDING_BUNDLE_KEY, null) == staged) {
1064
+ // The bundle waiting for the next start has not run yet; only its own boot may confirm it.
1065
+ return
1066
+ }
1050
1067
  prefs.edit()
1051
1068
  .putBoolean("current_bundle_verified", true)
1052
1069
  .remove(PENDING_BUNDLE_KEY)
@@ -60,7 +60,7 @@ import type { AppIdentity } from '../types/app-identity';
60
60
  * This plugin's version, sent as `X-Sdk-Version`. Kept equal to package.json (and to the Kotlin and Swift
61
61
  * constants) by tests/sdk-version.test.ts.
62
62
  */
63
- export declare const SDK_VERSION = "4.4.4";
63
+ export declare const SDK_VERSION = "4.4.6";
64
64
  /** Request inputs for a single backend update check. */
65
65
  export interface UpdateCheckRequest {
66
66
  /** API key issued by the dashboard; sent as `X-API-Key`. Required. */
@@ -59,7 +59,7 @@
59
59
  * This plugin's version, sent as `X-Sdk-Version`. Kept equal to package.json (and to the Kotlin and Swift
60
60
  * constants) by tests/sdk-version.test.ts.
61
61
  */
62
- export const SDK_VERSION = '4.4.4';
62
+ export const SDK_VERSION = '4.4.6';
63
63
  /**
64
64
  * Perform one update check against the Native Update backend.
65
65
  *
@@ -13,9 +13,13 @@ export interface LiveUpdatePlugin {
13
13
  */
14
14
  download(options: DownloadOptions): Promise<BundleInfo>;
15
15
  /**
16
- * Set the active bundle
16
+ * Make a downloaded, verified bundle the app's bundle.
17
+ *
18
+ * `applyOn: 'now'` (the default) switches the WebView to it at once. `applyOn: 'next-start'` stages it: the
19
+ * running app is untouched and the bundle loads at the next cold start, where `notifyAppReady()` confirms it
20
+ * (two unconfirmed starts roll it back). Stage when a reload mid-task would lose the user's work.
17
21
  */
18
- set(bundle: BundleInfo): Promise<void>;
22
+ set(bundle: SetBundleOptions): Promise<void>;
19
23
  /**
20
24
  * Reload the app with current bundle
21
25
  */
@@ -344,6 +348,13 @@ export interface BundleInfo {
344
348
  verified: boolean;
345
349
  metadata?: Record<string, unknown>;
346
350
  }
351
+ /** When a bundle passed to `set()` becomes the running app. */
352
+ export type ApplyOn = 'now' | 'next-start';
353
+ /** A bundle from `download()`/`downloadUpdate()`, plus when to switch to it. */
354
+ export interface SetBundleOptions extends BundleInfo {
355
+ /** Default `'now'`. */
356
+ applyOn?: ApplyOn;
357
+ }
347
358
  export interface DeleteOptions {
348
359
  bundleId?: string;
349
360
  keepVersions?: number;
@@ -1,6 +1,6 @@
1
1
  export { NativeUpdate } from './plugin';
2
2
  export { BackgroundUpdateType, NotificationPriority, UpdateStrategy, UpdateMode, InstallMode, ChecksumAlgorithm, SyncStatus, BundleStatus, InstallStatus, UpdateErrorCode, } from './definitions';
3
- export type { NativeUpdatePlugin, NativeUpdateCombinedPlugin, NativeUpdateListeners, LiveUpdatePlugin, AppUpdatePlugin, AppReviewPlugin, PluginConfig, UpdateConfig, LiveUpdateConfig, AppUpdateConfig, AppReviewConfig, BundleInfo, DownloadOptions, DownloadProgressEvent, SyncOptions, SyncResult, DeleteOptions, LatestVersion, ValidateOptions, ValidationResult, CheckForUpdateResult, DownloadUpdateOptions, AppIdentity, AppUpdateInfo, OpenAppStoreOptions, ReviewResult, CanRequestReviewResult, UpdateStateChangedEvent, AppUpdateStateChangedEvent, AppUpdateProgressEvent, AppUpdateAvailableEvent, AppUpdateReadyEvent, AppUpdateFailedEvent, AppUpdateNotificationClickedEvent, AppUpdateInstallClickedEvent, BackgroundUpdateProgressEvent, BackgroundUpdateNotificationEvent, UpdateError, BackgroundUpdatePlugin, BackgroundUpdateConfig, BackgroundUpdateStatus, BackgroundCheckResult, NotificationPreferences, NotificationPermissionStatus, SecurityConfig, SecurityInfo, CertificatePinning, CertificatePin, PluginInitConfig, PluginListenerHandle, } from './definitions';
3
+ export type { NativeUpdatePlugin, NativeUpdateCombinedPlugin, NativeUpdateListeners, LiveUpdatePlugin, AppUpdatePlugin, AppReviewPlugin, PluginConfig, UpdateConfig, LiveUpdateConfig, AppUpdateConfig, AppReviewConfig, BundleInfo, SetBundleOptions, ApplyOn, DownloadOptions, DownloadProgressEvent, SyncOptions, SyncResult, DeleteOptions, LatestVersion, ValidateOptions, ValidationResult, CheckForUpdateResult, DownloadUpdateOptions, AppIdentity, AppUpdateInfo, OpenAppStoreOptions, ReviewResult, CanRequestReviewResult, UpdateStateChangedEvent, AppUpdateStateChangedEvent, AppUpdateProgressEvent, AppUpdateAvailableEvent, AppUpdateReadyEvent, AppUpdateFailedEvent, AppUpdateNotificationClickedEvent, AppUpdateInstallClickedEvent, BackgroundUpdateProgressEvent, BackgroundUpdateNotificationEvent, UpdateError, BackgroundUpdatePlugin, BackgroundUpdateConfig, BackgroundUpdateStatus, BackgroundCheckResult, NotificationPreferences, NotificationPermissionStatus, SecurityConfig, SecurityInfo, CertificatePinning, CertificatePin, PluginInitConfig, PluginListenerHandle, } from './definitions';
4
4
  export type { RolloutConfig, RolloutTargetSegments, RolloutSchedule, RolloutTimestamp, DeviceInfo, UpdateCheckResponse, } from './types/rollout';
5
5
  export { ErrorCode, NativeUpdateError, ConfigurationError, DownloadError, ValidationError, StorageError, UpdateError as UpdateErrorClass, } from './core/errors';
6
6
  export { ConfigManager } from './core/config';
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- import type { NativeUpdateCombinedPlugin, SecurityInfo, SyncOptions, SyncResult, DownloadOptions, BundleInfo, DeleteOptions, LatestVersion, ValidateOptions, ValidationResult, AppUpdateInfo, OpenAppStoreOptions, ReviewResult, CanRequestReviewResult, BackgroundUpdateConfig, BackgroundUpdateStatus, BackgroundCheckResult, NotificationPreferences, NotificationPermissionStatus, CheckForUpdateResult, DownloadUpdateOptions, AppIdentity } from './definitions';
2
+ import type { NativeUpdateCombinedPlugin, SecurityInfo, SyncOptions, SyncResult, DownloadOptions, BundleInfo, SetBundleOptions, DeleteOptions, LatestVersion, ValidateOptions, ValidationResult, AppUpdateInfo, OpenAppStoreOptions, ReviewResult, CanRequestReviewResult, BackgroundUpdateConfig, BackgroundUpdateStatus, BackgroundCheckResult, NotificationPreferences, NotificationPermissionStatus, CheckForUpdateResult, DownloadUpdateOptions, AppIdentity } from './definitions';
3
3
  import type { PluginInitConfig } from './definitions';
4
4
  export declare class NativeUpdateWeb extends WebPlugin implements NativeUpdateCombinedPlugin {
5
5
  private config;
@@ -25,7 +25,7 @@ export declare class NativeUpdateWeb extends WebPlugin implements NativeUpdateCo
25
25
  */
26
26
  sync(_options?: SyncOptions): Promise<SyncResult>;
27
27
  download(options: DownloadOptions): Promise<BundleInfo>;
28
- set(bundle: BundleInfo): Promise<void>;
28
+ set(bundle: SetBundleOptions): Promise<void>;
29
29
  reload(): Promise<void>;
30
30
  reset(): Promise<void>;
31
31
  current(): Promise<BundleInfo>;