@otakit/capacitor-updater 2.1.0 → 2.1.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.
@@ -1,4 +1,3 @@
1
- import type { PluginListenerHandle } from '@capacitor/core';
2
1
  /**
3
2
  * Bundle status enum.
4
3
  */
@@ -43,8 +42,6 @@ export interface LatestVersion {
43
42
  sha256: string;
44
43
  /** Bundle size in bytes */
45
44
  size: number;
46
- /** True when this exact update is already staged locally. */
47
- downloaded?: boolean;
48
45
  /** Release history ID associated with this manifest */
49
46
  releaseId: string;
50
47
  }
@@ -54,11 +51,31 @@ export interface OtaKitState {
54
51
  staged: BundleInfo | null;
55
52
  builtinVersion: string;
56
53
  }
57
- export type OtaKitUpdateMode = 'manual' | 'next-launch' | 'next-resume' | 'immediate';
54
+ export type OtaKitPolicy = 'off' | 'shadow' | 'apply-staged' | 'immediate';
58
55
  export interface OtaKitManifestKey {
59
56
  kid: string;
60
57
  key: string;
61
58
  }
59
+ export interface CheckNoUpdateResult {
60
+ kind: 'no_update';
61
+ }
62
+ export interface CheckAlreadyStagedResult {
63
+ kind: 'already_staged';
64
+ latest: LatestVersion;
65
+ }
66
+ export interface CheckUpdateAvailableResult {
67
+ kind: 'update_available';
68
+ latest: LatestVersion;
69
+ }
70
+ export type CheckResult = CheckNoUpdateResult | CheckAlreadyStagedResult | CheckUpdateAvailableResult;
71
+ export interface DownloadNoUpdateResult {
72
+ kind: 'no_update';
73
+ }
74
+ export interface DownloadStagedResult {
75
+ kind: 'staged';
76
+ bundle: BundleInfo;
77
+ }
78
+ export type DownloadResult = DownloadNoUpdateResult | DownloadStagedResult;
62
79
  /**
63
80
  * Plugin configuration for capacitor.config.ts.
64
81
  */
@@ -69,12 +86,17 @@ export interface OtaKitConfig {
69
86
  channel?: string;
70
87
  /** Optional native compatibility lane. Set this when a new store build should start a new OTA line. */
71
88
  runtimeVersion?: string;
72
- /** Overall update behavior. Defaults to next-launch. */
73
- updateMode?: OtaKitUpdateMode;
89
+ /** Cold-start policy after runtime has already been resolved. Defaults to apply-staged. */
90
+ launchPolicy?: OtaKitPolicy;
91
+ /** Foreground resume policy. Defaults to shadow. */
92
+ resumePolicy?: OtaKitPolicy;
93
+ /** Cold-start policy when runtimeVersion changes or resolves for the first time. Defaults to immediate. */
94
+ runtimePolicy?: OtaKitPolicy;
74
95
  /**
75
- * Minimum milliseconds between automatic update checks.
76
- * Applies only to automatic checks in `next-launch` and `next-resume`.
77
- * Manual APIs and `immediate` mode bypass this throttle. Defaults to 600000 (10 min).
96
+ * Minimum milliseconds between automatic background resume checks.
97
+ * Applies only to `resumePolicy: "shadow"` and `resumePolicy: "apply-staged"`
98
+ * when no staged bundle is already waiting. Defaults to 600000 (10 min).
99
+ * Set to 0 or a negative value to disable resume throttling.
78
100
  */
79
101
  checkInterval?: number;
80
102
  /** Milliseconds to wait for notifyAppReady(). Defaults to 10000. */
@@ -90,7 +112,6 @@ export interface OtaKitConfig {
90
112
  /** Allow HTTP only for localhost development. Defaults to false. */
91
113
  allowInsecureUrls?: boolean;
92
114
  }
93
- export type OtaKitEvent = 'downloadStarted' | 'downloadComplete' | 'downloadFailed' | 'updateAvailable' | 'noUpdateAvailable' | 'appReady' | 'rollback';
94
115
  export interface OtaKitPlugin {
95
116
  /**
96
117
  * Inspect the current updater state.
@@ -98,40 +119,33 @@ export interface OtaKitPlugin {
98
119
  getState(): Promise<OtaKitState>;
99
120
  /**
100
121
  * Check the configured channel for a newer version without downloading it.
101
- * When `downloaded` is true, the latest update is already staged locally.
102
122
  */
103
- check(): Promise<LatestVersion | null>;
123
+ check(): Promise<CheckResult>;
104
124
  /**
105
- * Check the configured channel and download the latest bundle if available.
106
- * The latest bundle is staged for later activation. If it is already staged,
107
- * the existing staged bundle is returned without re-downloading it.
125
+ * Check the configured channel and ensure the latest bundle is staged locally.
108
126
  */
109
- download(): Promise<BundleInfo | null>;
127
+ download(): Promise<DownloadResult>;
110
128
  /**
111
129
  * Activate the currently staged bundle and reload the WebView.
112
130
  *
113
131
  * **WARNING: TERMINAL OPERATION**
132
+ * On success this call does not resolve back into the old JS context.
114
133
  * Code after this call may not execute. The WebView will reload.
115
134
  */
116
135
  apply(): Promise<void>;
117
136
  /**
118
137
  * Friendly manual-mode helper.
119
- * Bring the app to the newest available update now.
120
- * If the newest update is already staged, apply it.
121
- * Otherwise download it and apply it.
138
+ * Bring the app to the newest available update now using one native
139
+ * immediate-flow operation.
122
140
  *
123
141
  * **WARNING: TERMINAL OPERATION**
142
+ * If an update is applied, this call does not resolve back into the old JS context.
124
143
  * Code after this call may not execute if an update is applied.
125
144
  */
126
145
  update(): Promise<void>;
127
146
  /**
128
147
  * **CRITICAL**: Call this when your app has successfully started.
129
148
  * Must be called within appReadyTimeout (default 10s) or rollback occurs.
130
- *
131
- * This confirms the current bundle is working and:
132
- * - Marks the bundle as SUCCESS
133
- * - Updates the fallback bundle pointer
134
- * - Removes the older fallback bundle once the new bundle proves healthy
135
149
  */
136
150
  notifyAppReady(): Promise<void>;
137
151
  /**
@@ -139,53 +153,14 @@ export interface OtaKitPlugin {
139
153
  * Returns null if no failure has occurred.
140
154
  */
141
155
  getLastFailure(): Promise<BundleInfo | null>;
142
- /**
143
- * Add listener for update events
144
- */
145
- addListener(event: 'downloadStarted', callback: (data: {
146
- version: string;
147
- }) => void): Promise<PluginListenerHandle>;
148
- addListener(event: 'downloadComplete', callback: (data: BundleInfo) => void): Promise<PluginListenerHandle>;
149
- addListener(event: 'downloadFailed', callback: (data: {
150
- version: string;
151
- error: string;
152
- }) => void): Promise<PluginListenerHandle>;
153
- addListener(event: 'updateAvailable', callback: (data: LatestVersion) => void): Promise<PluginListenerHandle>;
154
- addListener(event: 'noUpdateAvailable', callback: () => void): Promise<PluginListenerHandle>;
155
- addListener(event: 'appReady', callback: (data: BundleInfo) => void): Promise<PluginListenerHandle>;
156
- addListener(event: 'rollback', callback: (data: {
157
- from: BundleInfo;
158
- to: BundleInfo;
159
- reason?: string;
160
- }) => void): Promise<PluginListenerHandle>;
161
- /**
162
- * Remove all listeners for this plugin
163
- */
164
- removeAllListeners(): Promise<void>;
165
156
  }
166
157
  export interface OtaKitBridgePlugin {
167
158
  getState(): Promise<OtaKitState>;
168
- check(): Promise<LatestVersion | null>;
169
- download(): Promise<BundleInfo | null>;
159
+ check(): Promise<CheckResult>;
160
+ download(): Promise<DownloadResult>;
170
161
  apply(): Promise<void>;
162
+ update(): Promise<void>;
171
163
  notifyAppReady(): Promise<void>;
172
164
  getLastFailure(): Promise<BundleInfo | null>;
173
- addListener(event: 'downloadStarted', callback: (data: {
174
- version: string;
175
- }) => void): Promise<PluginListenerHandle>;
176
- addListener(event: 'downloadComplete', callback: (data: BundleInfo) => void): Promise<PluginListenerHandle>;
177
- addListener(event: 'downloadFailed', callback: (data: {
178
- version: string;
179
- error: string;
180
- }) => void): Promise<PluginListenerHandle>;
181
- addListener(event: 'updateAvailable', callback: (data: LatestVersion) => void): Promise<PluginListenerHandle>;
182
- addListener(event: 'noUpdateAvailable', callback: () => void): Promise<PluginListenerHandle>;
183
- addListener(event: 'appReady', callback: (data: BundleInfo) => void): Promise<PluginListenerHandle>;
184
- addListener(event: 'rollback', callback: (data: {
185
- from: BundleInfo;
186
- to: BundleInfo;
187
- reason?: string;
188
- }) => void): Promise<PluginListenerHandle>;
189
- removeAllListeners(): Promise<void>;
190
165
  }
191
166
  //# sourceMappingURL=definitions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5D;;GAEG;AACH,oBAAY,YAAY;IACtB,+BAA+B;IAC/B,OAAO,YAAY;IACnB,iDAAiD;IACjD,OAAO,YAAY;IACnB,mCAAmC;IACnC,KAAK,UAAU;IACf,wBAAwB;IACxB,OAAO,YAAY;IACnB,yDAAyD;IACzD,KAAK,UAAU;CAChB;AAED,M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CAAC,oBAAoB,CAAC,CAAC;IACjC,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC"}
1
+ {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,YAAY;IACtB,+BAA+B;IAC/B,OAAO,YAAY;IACnB,iDAAiD;IACjD,OAAO,YAAY;IACnB,mCAAmC;IACnC,KAAK,UAAU;IACf,wBAAwB;IACxB,OAAO,YAAY;IACnB,yDAAyD;IACzD,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mCAAmC;IACnC,MAAM,EAAE,YAAY,CAAC;IACrB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,UAAU,CAAC;IACrB,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAC1B,cAAc,EAAE,MAAM,CAA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,mCAAmB,CAAA;IACnB,iDAAiD;IACjD,mCAAmB,CAAA;IACnB,mCAAmC;IACnC,+BAAe,CAAA;IACf,wBAAwB;IACxB,mCAAmB,CAAA;IACnB,yDAAyD;IACzD,+BAAe,CAAA;AACjB,CAAC,EAXW,YAAY,KAAZ,YAAY,QAWvB"}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,YAWX;AAXD,WAAY,YAAY;IACtB,+BAA+B;IAC/B,mCAAmB,CAAA;IACnB,iDAAiD;IACjD,mCAAmB,CAAA;IACnB,mCAAmC;IACnC,+BAAe,CAAA;IACf,wBAAwB;IACxB,mCAAmB,CAAA;IACnB,yDAAyD;IACzD,+BAAe,CAAA;AACjB,CAAC,EAXW,YAAY,KAAZ,YAAY,QAWvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,YAAY,EAIb,MAAM,eAAe,CAAC;AAqEvB,QAAA,MAAM,MAAM,EAAE,YAWb,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAsB,YAAY,EAAc,MAAM,eAAe,CAAC;AAqBlF,QAAA,MAAM,MAAM,EAAE,YASb,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/dist/esm/index.js CHANGED
@@ -15,56 +15,14 @@ function isEmptyObject(obj) {
15
15
  function normalizeNullable(value) {
16
16
  return isEmptyObject(value) ? null : value;
17
17
  }
18
- async function getState() {
19
- return NativeOtaKit.getState();
20
- }
21
- async function check() {
22
- return normalizeNullable(await NativeOtaKit.check());
23
- }
24
- async function download() {
25
- return normalizeNullable(await NativeOtaKit.download());
26
- }
27
- function apply() {
28
- return NativeOtaKit.apply();
29
- }
30
- async function update() {
31
- const state = await getState();
32
- let latest;
33
- try {
34
- latest = await check();
35
- }
36
- catch (error) {
37
- if (state.staged) {
38
- await apply();
39
- return;
40
- }
41
- throw error;
42
- }
43
- if (latest) {
44
- if (latest.downloaded) {
45
- await apply();
46
- return;
47
- }
48
- const bundle = await download();
49
- if (bundle) {
50
- await apply();
51
- }
52
- return;
53
- }
54
- if (state.staged) {
55
- await apply();
56
- }
57
- }
58
18
  const OtaKit = {
59
- getState,
60
- check,
61
- download,
62
- apply,
63
- update,
19
+ getState: () => NativeOtaKit.getState(),
20
+ check: () => NativeOtaKit.check(),
21
+ download: () => NativeOtaKit.download(),
22
+ apply: () => NativeOtaKit.apply(),
23
+ update: () => NativeOtaKit.update(),
64
24
  notifyAppReady: () => NativeOtaKit.notifyAppReady(),
65
25
  getLastFailure: async () => normalizeNullable(await NativeOtaKit.getLastFailure()),
66
- addListener: NativeOtaKit.addListener.bind(NativeOtaKit),
67
- removeAllListeners: () => NativeOtaKit.removeAllListeners(),
68
26
  };
69
27
  export * from './definitions';
70
28
  export { OtaKit };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAUjD,MAAM,YAAY,GAAG,cAAc,CAAqB,QAAQ,EAAE;IAChE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;CAC1D,CAAC,CAAC;AAEH;;GAEG;AACH,SAAS,aAAa,CAAC,GAAY;IACjC,OAAO,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAA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Y,CAAC,KAAK,EAAE;IACjC,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE;IACvC,KAAK,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE;IACjC,MAAM,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE;IACnC,cAAc,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE;IACnD,cAAc,EAAE,KAAK,IAAgC,EAAE,CACrD,iBAAiB,CAAC,MAAM,YAAY,CAAC,cAAc,EAAE,CAAC;CACzD,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- import type { OtaKitBridgePlugin, BundleInfo, LatestVersion, OtaKitState } from './definitions';
2
+ import type { OtaKitBridgePlugin, BundleInfo, CheckResult, DownloadResult, OtaKitState } from './definitions';
3
3
  /**
4
4
  * Web implementation of the native bridge.
5
5
  * Most methods are no-ops since OTA updates don't apply to web.
@@ -7,9 +7,10 @@ import type { OtaKitBridgePlugin, BundleInfo, LatestVersion, OtaKitState } from
7
7
  export declare class OtaKitWeb extends WebPlugin implements OtaKitBridgePlugin {
8
8
  private readonly BUILTIN_BUNDLE;
9
9
  getState(): Promise<OtaKitState>;
10
- check(): Promise<LatestVersion | null>;
11
- download(): Promise<BundleInfo | null>;
10
+ check(): Promise<CheckResult>;
11
+ download(): Promise<DownloadResult>;
12
12
  apply(): Promise<void>;
13
+ update(): Promise<void>;
13
14
  notifyAppReady(): Promise<void>;
14
15
  getLastFailure(): Promise<BundleInfo | null>;
15
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,aAAa,EAEb,WAAW,EACZ,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,qBAAa,SAAU,SAAQ,SAAU,YAAW,kBAAkB;IACpE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAI7B;IAEI,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IAShC,KAAK,IAAI,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAKtC,QAAQ,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAKtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,cAAc,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAGnD"}
1
+ {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EAEV,WAAW,EACX,cAAc,EACd,WAAW,EACZ,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,qBAAa,SAAU,SAAQ,SAAU,YAAW,kBAAkB;IACpE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAI7B;IAEI,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IAShC,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC;IAK7B,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAKnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,cAAc,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAGnD"}
package/dist/esm/web.js CHANGED
@@ -19,16 +19,19 @@ export class OtaKitWeb extends WebPlugin {
19
19
  }
20
20
  async check() {
21
21
  console.warn('OtaKit.check() is not supported on web');
22
- return null;
22
+ return { kind: 'no_update' };
23
23
  }
24
24
  async download() {
25
25
  console.warn('OtaKit.download() is not supported on web');
26
- return null;
26
+ return { kind: 'no_update' };
27
27
  }
28
28
  async apply() {
29
29
  console.warn('OtaKit.apply() is not supported on web');
30
30
  throw new Error('OtaKit.apply() is not supported on web');
31
31
  }
32
+ async update() {
33
+ await this.download();
34
+ }
32
35
  async notifyAppReady() {
33
36
  // No-op on web, but don't warn - apps should call this unconditionally
34
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAU5C;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,SAAS;IACrB,cAAc,GAAe;QAC5C,EAAE,EAAE,SAAS;QACb,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,SAAyB;KAClC,CAAC;IAEF,KAAK,CAAC,QAAQ;QACZ,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,cAAc;YAC5B,QAAQ,EAAE,IAAI,CAAC,cAAc;YAC7B,MAAM,EAAE,IAAI;YACZ,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO;SAC5C,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,uEAAuE;IACzE,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,SAAS;IACrB,cAAc,GAAe;QAC5C,EAAE,EAAE,SAAS;QACb,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,SAAyB;KAClC,CAAC;IAEF,KAAK,CAAC,QAAQ;QACZ,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,cAAc;YAC5B,QAAQ,EAAE,IAAI,CAAC,cAAc;YAC7B,MAAM,EAAE,IAAI;YACZ,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO;SAC5C,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QACvD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;QAC1D,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,uEAAuE;IACzE,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -35,56 +35,14 @@ function isEmptyObject(obj) {
35
35
  function normalizeNullable(value) {
36
36
  return isEmptyObject(value) ? null : value;
37
37
  }
38
- async function getState() {
39
- return NativeOtaKit.getState();
40
- }
41
- async function check() {
42
- return normalizeNullable(await NativeOtaKit.check());
43
- }
44
- async function download() {
45
- return normalizeNullable(await NativeOtaKit.download());
46
- }
47
- function apply() {
48
- return NativeOtaKit.apply();
49
- }
50
- async function update() {
51
- const state = await getState();
52
- let latest;
53
- try {
54
- latest = await check();
55
- }
56
- catch (error) {
57
- if (state.staged) {
58
- await apply();
59
- return;
60
- }
61
- throw error;
62
- }
63
- if (latest) {
64
- if (latest.downloaded) {
65
- await apply();
66
- return;
67
- }
68
- const bundle = await download();
69
- if (bundle) {
70
- await apply();
71
- }
72
- return;
73
- }
74
- if (state.staged) {
75
- await apply();
76
- }
77
- }
78
38
  const OtaKit = {
79
- getState,
80
- check,
81
- download,
82
- apply,
83
- update,
39
+ getState: () => NativeOtaKit.getState(),
40
+ check: () => NativeOtaKit.check(),
41
+ download: () => NativeOtaKit.download(),
42
+ apply: () => NativeOtaKit.apply(),
43
+ update: () => NativeOtaKit.update(),
84
44
  notifyAppReady: () => NativeOtaKit.notifyAppReady(),
85
45
  getLastFailure: async () => normalizeNullable(await NativeOtaKit.getLastFailure()),
86
- addListener: NativeOtaKit.addListener.bind(NativeOtaKit),
87
- removeAllListeners: () => NativeOtaKit.removeAllListeners(),
88
46
  };
89
47
 
90
48
  /**
@@ -107,16 +65,19 @@ class OtaKitWeb extends core.WebPlugin {
107
65
  }
108
66
  async check() {
109
67
  console.warn('OtaKit.check() is not supported on web');
110
- return null;
68
+ return { kind: 'no_update' };
111
69
  }
112
70
  async download() {
113
71
  console.warn('OtaKit.download() is not supported on web');
114
- return null;
72
+ return { kind: 'no_update' };
115
73
  }
116
74
  async apply() {
117
75
  console.warn('OtaKit.apply() is not supported on web');
118
76
  throw new Error('OtaKit.apply() is not supported on web');
119
77
  }
78
+ async update() {
79
+ await this.download();
80
+ }
120
81
  async notifyAppReady() {
121
82
  // No-op on web, but don't warn - apps should call this unconditionally
122
83
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Bundle status enum.\n */\nexport var BundleStatus;\n(function (BundleStatus) {\n /** Factory-installed bundle */\n BundleStatus[\"BUILTIN\"] = \"builtin\";\n /** Downloaded and staged, awaiting activation */\n BundleStatus[\"PENDING\"] = \"pending\";\n /** Active but not yet confirmed */\n BundleStatus[\"TRIAL\"] = \"trial\";\n /** Confirmed working */\n BundleStatus[\"SUCCESS\"] = \"success\";\n /** Failed (hash mismatch, extraction error, rollback) */\n BundleStatus[\"ERROR\"] = \"error\";\n})(BundleStatus || (BundleStatus = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NativeOtaKit = registerPlugin('OtaKit', {\n web: () => import('./web').then((m) => new m.OtaKitWeb()),\n});\n/**\n * Check if result is an empty object (iOS returns {} instead of null)\n */\nfunction isEmptyObject(obj) {\n return obj !== null && typeof obj === 'object' && Object.keys(obj).length === 0;\n}\n/**\n * Wrapped plugin that normalizes null returns from native code.\n * iOS call.resolve() without arguments returns {} instead of null.\n */\nfunction normalizeNullable(value) {\n return isEmptyObject(value) ? null : value;\n}\nasync function getState() {\n return NativeOtaKit.getState();\n}\nasync function check() {\n return normalizeNullable(await NativeOtaKit.check());\n}\nasync function download() {\n return normalizeNullable(await NativeOtaKit.download());\n}\nfunction apply() {\n return NativeOtaKit.apply();\n}\nasync function update() {\n const state = await getState();\n let latest;\n try {\n latest = await check();\n }\n catch (error) {\n if (state.staged) {\n await apply();\n return;\n }\n throw error;\n }\n if (latest) {\n if (latest.downloaded) {\n await apply();\n return;\n }\n const bundle = await download();\n if (bundle) {\n await apply();\n }\n return;\n }\n if (state.staged) {\n await apply();\n }\n}\nconst OtaKit = {\n getState,\n check,\n download,\n apply,\n update,\n notifyAppReady: () => NativeOtaKit.notifyAppReady(),\n getLastFailure: async () => normalizeNullable(await NativeOtaKit.getLastFailure()),\n addListener: NativeOtaKit.addListener.bind(NativeOtaKit),\n removeAllListeners: () => NativeOtaKit.removeAllListeners(),\n};\nexport * from './definitions';\nexport { OtaKit };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the native bridge.\n * Most methods are no-ops since OTA updates don't apply to web.\n */\nexport class OtaKitWeb extends WebPlugin {\n BUILTIN_BUNDLE = {\n id: 'builtin',\n version: '0.0.0',\n status: 'builtin',\n };\n async getState() {\n return {\n current: this.BUILTIN_BUNDLE,\n fallback: this.BUILTIN_BUNDLE,\n staged: null,\n builtinVersion: this.BUILTIN_BUNDLE.version,\n };\n }\n async check() {\n console.warn('OtaKit.check() is not supported on web');\n return null;\n }\n async download() {\n console.warn('OtaKit.download() is not supported on web');\n return null;\n }\n async apply() {\n console.warn('OtaKit.apply() is not supported on web');\n throw new Error('OtaKit.apply() is not supported on web');\n }\n async notifyAppReady() {\n // No-op on web, but don't warn - apps should call this unconditionally\n }\n async getLastFailure() {\n return null;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BundleStatus","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACWA;AACX,CAAC,UAAU,YAAY,EAAE;AACzB;AACA,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,SAAS;AACvC;AACA,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,SAAS;AACvC;AACA,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO;AACnC;AACA,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,SAAS;AACvC;AACA,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO;AACnC,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,EAAE,CAAC,CAAC;;ACdvC,MAAM,YAAY,GAAGC,mBAAc,CAAC,QAAQ,EAAE;AAC9C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC7D,CAAC,CAAC;AACF;AACA;AACA;AACA,SA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AC,wCAAwC,CAAC;AAC9D,QAAQ,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC;AACjE,IAAI;AACJ,IAAI,MAAM,cAAc,GAAG;AAC3B;AACA,IAAI;AACJ,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,OAAO,IAAI;AACnB,IAAI;AACJ;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Bundle status enum.\n */\nexport var BundleStatus;\n(function (BundleStatus) {\n /** Factory-installed bundle */\n BundleStatus[\"BUILTIN\"] = \"builtin\";\n /** Downloaded and staged, awaiting activation */\n BundleStatus[\"PENDING\"] = \"pending\";\n /** Active but not yet confirmed */\n BundleStatus[\"TRIAL\"] = \"trial\";\n /** Confirmed working */\n BundleStatus[\"SUCCESS\"] = \"success\";\n /** Failed (hash mismatch, extraction error, rollback) */\n BundleStatus[\"ERROR\"] = \"error\";\n})(BundleStatus || (BundleStatus = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NativeOtaKit = registerPlugin('OtaKit', {\n web: () => import('./web').then((m) => new m.OtaKitWeb()),\n});\n/**\n * Check if result is an empty object (iOS returns {} instead of null)\n */\nfunction isEmptyObject(obj) {\n return obj !== null && typeof obj === 'object' && Object.keys(obj).length === 0;\n}\n/**\n * Wrapped plugin that normalizes null returns from native code.\n * iOS call.resolve() without arguments returns {} instead of null.\n */\nfunction normalizeNullable(value) {\n return isEmptyObject(value) ? null : value;\n}\nconst OtaKit = {\n getState: () => NativeOtaKit.getState(),\n check: () => NativeOtaKit.check(),\n download: () => NativeOtaKit.download(),\n apply: () => NativeOtaKit.apply(),\n update: () => NativeOtaKit.update(),\n notifyAppReady: () => NativeOtaKit.notifyAppReady(),\n getLastFailure: async () => normalizeNullable(await NativeOtaKit.getLastFailure()),\n};\nexport * from './definitions';\nexport { OtaKit };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the native bridge.\n * Most methods are no-ops since OTA updates don't apply to web.\n */\nexport class OtaKitWeb extends WebPlugin {\n BUILTIN_BUNDLE = {\n id: 'builtin',\n version: '0.0.0',\n status: 'builtin',\n };\n async getState() {\n return {\n current: this.BUILTIN_BUNDLE,\n fallback: this.BUILTIN_BUNDLE,\n staged: null,\n builtinVersion: this.BUILTIN_BUNDLE.version,\n };\n }\n async check() {\n console.warn('OtaKit.check() is not supported on web');\n return { kind: 'no_update' };\n }\n async download() {\n console.warn('OtaKit.download() is not supported on web');\n return { kind: 'no_update' };\n }\n async apply() {\n console.warn('OtaKit.apply() is not supported on web');\n throw new Error('OtaKit.apply() is not supported on web');\n }\n async update() {\n await this.download();\n }\n async notifyAppReady() {\n // No-op on web, but don't warn - apps should call this unconditionally\n }\n async getLastFailure() {\n return null;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BundleStatus","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACWA;AACX,CAAC,UAAU,YAAY,EAAE;AACzB;AACA,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,SAAS;AACvC;AACA,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,SAAS;AACvC;AACA,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO;AACnC;AACA,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,SAAS;AACvC;AACA,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO;AACnC,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,EAAE,CAAC,CAAC;;ACdvC,MAAM,YAAY,GAAGC,mBAAc,CAAC,QAAQ,EAAE;AAC9C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC7D,CAAC,CAAC;AACF;AACA;AACA;AACA,SAAS,aAAa,CAAC,GAAG,EAAE;AAC5B,IAAI,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E,IAAI,EAAE,WAAW,EAAE;AACpC,IAAI;AACJ,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC;AACjE,QAAQ,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE;AACpC,IAAI;AACJ,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC;AAC9D,QAAQ,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC;AACjE,IAAI;AACJ,IAAI,MAAM,MAAM,GAAG;AACnB,QAAQ,MAAM,IAAI,CAAC,QAAQ,EAAE;AAC7B,IAAI;AACJ,IAAI,MAAM,cAAc,GAAG;AAC3B;AACA,IAAI;AACJ,IAAI,MAAM,cAAc,GAAG;AAC3B,QAAQ,OAAO,IAAI;AACnB,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -34,56 +34,14 @@ var capacitorUpdater = (function (exports, core) {
34
34
  function normalizeNullable(value) {
35
35
  return isEmptyObject(value) ? null : value;
36
36
  }
37
- async function getState() {
38
- return NativeOtaKit.getState();
39
- }
40
- async function check() {
41
- return normalizeNullable(await NativeOtaKit.check());
42
- }
43
- async function download() {
44
- return normalizeNullable(await NativeOtaKit.download());
45
- }
46
- function apply() {
47
- return NativeOtaKit.apply();
48
- }
49
- async function update() {
50
- const state = await getState();
51
- let latest;
52
- try {
53
- latest = await check();
54
- }
55
- catch (error) {
56
- if (state.staged) {
57
- await apply();
58
- return;
59
- }
60
- throw error;
61
- }
62
- if (latest) {
63
- if (latest.downloaded) {
64
- await apply();
65
- return;
66
- }
67
- const bundle = await download();
68
- if (bundle) {
69
- await apply();
70
- }
71
- return;
72
- }
73
- if (state.staged) {
74
- await apply();
75
- }
76
- }
77
37
  const OtaKit = {
78
- getState,
79
- check,
80
- download,
81
- apply,
82
- update,
38
+ getState: () => NativeOtaKit.getState(),
39
+ check: () => NativeOtaKit.check(),
40
+ download: () => NativeOtaKit.download(),
41
+ apply: () => NativeOtaKit.apply(),
42
+ update: () => NativeOtaKit.update(),
83
43
  notifyAppReady: () => NativeOtaKit.notifyAppReady(),
84
44
  getLastFailure: async () => normalizeNullable(await NativeOtaKit.getLastFailure()),
85
- addListener: NativeOtaKit.addListener.bind(NativeOtaKit),
86
- removeAllListeners: () => NativeOtaKit.removeAllListeners(),
87
45
  };
88
46
 
89
47
  /**
@@ -106,16 +64,19 @@ var capacitorUpdater = (function (exports, core) {
106
64
  }
107
65
  async check() {
108
66
  console.warn('OtaKit.check() is not supported on web');
109
- return null;
67
+ return { kind: 'no_update' };
110
68
  }
111
69
  async download() {
112
70
  console.warn('OtaKit.download() is not supported on web');
113
- return null;
71
+ return { kind: 'no_update' };
114
72
  }
115
73
  async apply() {
116
74
  console.warn('OtaKit.apply() is not supported on web');
117
75
  throw new Error('OtaKit.apply() is not supported on web');
118
76
  }
77
+ async update() {
78
+ await this.download();
79
+ }
119
80
  async notifyAppReady() {
120
81
  // No-op on web, but don't warn - apps should call this unconditionally
121
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Bundle status enum.\n */\nexport var BundleStatus;\n(function (BundleStatus) {\n /** Factory-installed bundle */\n BundleStatus[\"BUILTIN\"] = \"builtin\";\n /** Downloaded and staged, awaiting activation */\n BundleStatus[\"PENDING\"] = \"pending\";\n /** Active but not yet confirmed */\n BundleStatus[\"TRIAL\"] = \"trial\";\n /** Confirmed working */\n BundleStatus[\"SUCCESS\"] = \"success\";\n /** Failed (hash mismatch, extraction error, rollback) */\n BundleStatus[\"ERROR\"] = \"error\";\n})(BundleStatus || (BundleStatus = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NativeOtaKit = registerPlugin('OtaKit', {\n web: () => import('./web').then((m) => new m.OtaKitWeb()),\n});\n/**\n * Check if result is an empty object (iOS returns {} instead of null)\n */\nfunction isEmptyObject(obj) {\n return obj !== null && typeof obj === 'object' && Object.keys(obj).length === 0;\n}\n/**\n * Wrapped plugin that normalizes null returns from native code.\n * iOS call.resolve() without arguments returns {} instead of null.\n */\nfunction normalizeNullable(value) {\n return isEmptyObject(value) ? null : value;\n}\nasync function getState() {\n return NativeOtaKit.getState();\n}\nasync function check() {\n return normalizeNullable(await NativeOtaKit.check());\n}\nasync function download() {\n return normalizeNullable(await NativeOtaKit.download());\n}\nfunction apply() {\n return NativeOtaKit.apply();\n}\nasync function update() {\n const state = await getState();\n let latest;\n try {\n latest = await check();\n }\n catch (error) {\n if (state.staged) {\n await apply();\n return;\n }\n throw error;\n }\n if (latest) {\n if (latest.downloaded) {\n await apply();\n return;\n }\n const bundle = await download();\n if (bundle) {\n await apply();\n }\n return;\n }\n if (state.staged) {\n await apply();\n }\n}\nconst OtaKit = {\n getState,\n check,\n download,\n apply,\n update,\n notifyAppReady: () => NativeOtaKit.notifyAppReady(),\n getLastFailure: async () => normalizeNullable(await NativeOtaKit.getLastFailure()),\n addListener: NativeOtaKit.addListener.bind(NativeOtaKit),\n removeAllListeners: () => NativeOtaKit.removeAllListeners(),\n};\nexport * from './definitions';\nexport { OtaKit };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the native bridge.\n * Most methods are no-ops since OTA updates don't apply to web.\n */\nexport class OtaKitWeb extends WebPlugin {\n BUILTIN_BUNDLE = {\n id: 'builtin',\n version: '0.0.0',\n status: 'builtin',\n };\n async getState() {\n return {\n current: this.BUILTIN_BUNDLE,\n fallback: this.BUILTIN_BUNDLE,\n staged: null,\n builtinVersion: this.BUILTIN_BUNDLE.version,\n };\n }\n async check() {\n console.warn('OtaKit.check() is not supported on web');\n return null;\n }\n async download() {\n console.warn('OtaKit.download() is not supported on web');\n return null;\n }\n async apply() {\n console.warn('OtaKit.apply() is not supported on web');\n throw new Error('OtaKit.apply() is not supported on web');\n }\n async notifyAppReady() {\n // No-op on web, but don't warn - apps should call this unconditionally\n }\n async getLastFailure() {\n return null;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["BundleStatus","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;AACWA;IACX,CAAC,UAAU,YAAY,EAAE;IACzB;IACA,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,SAAS;IACvC;IACA,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,SAAS;IACvC;IACA,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO;IACnC;IACA,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG,SAAS;IACvC;IACA,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO;IACnC,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,EAAE,CAAC,CAAC;;ICdvC,MAAM,YAAY,GAAGC,mBAAc,CAAC,QAAQ,EAAE;IAC9C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC7D,CAAC,CAAC;IACF;IACA;IACA;IACA,SAAS,aAAa,CAAC,GAAG,EAAE;IAC5B,IAAI,OAAO,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC;IACnF;IACA;IACA;IACA;IACA;IACA,SAAS,iBAAiB,CAAC,KAAK,EAAE;IAClC,IAAI,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,KAAK;IAC9C;IACA,eAAe,QAAQ,GAAG;IAC1B,IAAI,OAAO,YAAY,CAAC,QAAQ,EAAE;IAClC;IACA,eAAe,KAAK,GAAG;IACvB,IAAI,OAAO,iBAAiB,CAAC,MAAM,YAAY,CAAC,KAAK,EAAE,CAAC;IACxD;IACA,eAAe,QAAQ,GAAG;IAC1B,IAAI,OAAO,iBAAiB,CAAC,MAAM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SAAS,SAASC,cAAS,CAAC;IACzC,IAAI,cAAc,GAAG;IACrB,QAAQ,EAAE,EAAE,SAAS;IACrB,QAAQ,OAAO,EAAE,OAAO;IACxB,QAAQ,MAAM,EAAE,SAAS;IACzB,KAAK;IACL,IAAI,MAAM,QAAQ,GAAG;IACrB,QAAQ,OAAO;IACf,YAAY,OAAO,EAAE,IAAI,CAAC,cAAc;IACxC,YAAY,QAAQ,EAAE,IAAI,CAAC,cAAc;IACzC,YAAY,MAAM,EAAE,IAAI;IACxB,YAAY,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,OAAO;IACvD,SAAS;IACT,IAAI;IACJ,IAAI,MAAM,KAAK,GAAG;IAClB,QAAQ,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC;IAC9D,QAAQ,OAAO,IAAI;IACnB,IAAI;IACJ,IAAI,MAAM,QAAQ,GAAG;IACrB,QAAQ,OAAO,CAAC,IAAI,CAAC,2CAA2C,CAAC;IACjE,QAAQ,OAAO,IAAI;IACnB,IAAI;IACJ,IAAI,MAAM,KAAK,GAAG;IAClB,QAAQ,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC;IAC9D,QAAQ,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC;IACjE,IAAI;IACJ,IAAI,MAAM,cAAc,GAAG;IAC3B;IACA,IAAI;IACJ,IAAI,MAAM,cAAc,GAAG;IAC3B,QAAQ,OAAO,IAAI;IACnB,IAAI;IACJ;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Bundle status enum.\n */\nexport var BundleStatus;\n(function (BundleStatus) {\n /** Factory-installed bundle */\n BundleStatus[\"BUILTIN\"] = \"builtin\";\n /** Downloaded and staged, awaiting activation */\n BundleStatus[\"PENDING\"] = \"pending\";\n /** Active but not yet confirmed */\n BundleStatus[\"TRIAL\"] = \"trial\";\n /** Confirmed working */\n BundleStatus[\"SUCCESS\"] = \"success\";\n /** Failed (hash mismatch, extraction error, rollback) */\n BundleStatus[\"ERROR\"] = \"error\";\n})(BundleStatus || (BundleStatus = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst NativeOtaKit = registerPlugin('OtaKit', {\n web: () => import('./web').then((m) => new m.OtaKitWeb()),\n});\n/**\n * Check if result is an empty object (iOS returns {} instead of null)\n */\nfunction isEmptyObject(obj) {\n return obj !== null && typeof obj === 'object' && Object.keys(obj).length === 0;\n}\n/**\n * Wrapped plugin that normalizes null returns from native code.\n * iOS call.resolve() without arguments returns {} instead of null.\n */\nfunction normalizeNullable(value) {\n return isEmptyObject(value) ? null : value;\n}\nconst OtaKit = {\n getState: () => NativeOtaKit.getState(),\n check: () => NativeOtaKit.check(),\n download: () => NativeOtaKit.download(),\n apply: () => NativeOtaKit.apply(),\n update: () => NativeOtaKit.update(),\n notifyAppReady: () => NativeOtaKit.notifyAppReady(),\n getLastFailure: async () => normalizeNullable(await NativeOtaKit.getLastFailure()),\n};\nexport * from './definitions';\nexport { OtaKit };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the native bridge.\n * Most methods are no-ops since OTA updates don't apply to web.\n */\nexport class OtaKitWeb extends WebPlugin {\n BUILTIN_BUNDLE = {\n id: 'builtin',\n version: '0.0.0',\n status: 'builtin',\n };\n async getState() {\n return {\n current: this.BUILTIN_BUNDLE,\n fallback: this.BUILTIN_BUNDLE,\n staged: null,\n builtinVersion: this.BUILTIN_BUNDLE.version,\n };\n }\n async check() {\n console.warn('OtaKit.check() is not supported on web');\n return { kind: 'no_update' };\n }\n async download() {\n console.warn('OtaKit.download() is not supported on web');\n return { kind: 'no_update' };\n }\n async apply() {\n console.warn('OtaKit.apply() is not supported on web');\n throw new Error('OtaKit.apply() is not supported on web');\n }\n async update() {\n await this.download();\n }\n async notifyAppReady() {\n // No-op on web, but don't warn - apps should call this unconditionally\n }\n async getLastFailure() {\n return null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