@capgo/capacitor-updater 9.0.0 → 9.0.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.
Files changed (109) hide show
  1. package/CapgoCapacitorUpdater.podspec +3 -6
  2. package/Package.swift +30 -0
  3. package/README.md +2382 -292
  4. package/android/build.gradle +37 -15
  5. package/android/consumer-rules.pro +48 -0
  6. package/android/proguard-rules.pro +23 -0
  7. package/android/src/main/AndroidManifest.xml +0 -1
  8. package/android/src/main/java/ee/forgr/capacitor_updater/AndroidAppExitReporter.java +92 -0
  9. package/android/src/main/java/ee/forgr/capacitor_updater/AppLifecycleObserver.java +115 -0
  10. package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +227 -195
  11. package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +24 -23
  12. package/android/src/main/java/ee/forgr/capacitor_updater/Callback.java +13 -0
  13. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +7435 -1243
  14. package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +5144 -0
  15. package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +564 -121
  16. package/android/src/main/java/ee/forgr/capacitor_updater/DataManager.java +44 -0
  17. package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +43 -49
  18. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUntilNext.java +4 -4
  19. package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +427 -0
  20. package/android/src/main/java/ee/forgr/capacitor_updater/DeviceIdHelper.java +230 -0
  21. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +1969 -118
  22. package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +278 -0
  23. package/android/src/main/java/ee/forgr/capacitor_updater/HeadlessUpdateWorker.java +385 -0
  24. package/android/src/main/java/ee/forgr/capacitor_updater/Http3.java +356 -0
  25. package/android/src/main/java/ee/forgr/capacitor_updater/HttpEngineTransport.java +553 -0
  26. package/android/src/main/java/ee/forgr/capacitor_updater/InternalUtils.java +79 -0
  27. package/android/src/main/java/ee/forgr/capacitor_updater/Logger.java +419 -0
  28. package/android/src/main/java/ee/forgr/capacitor_updater/NativeUpdatePrompt.java +303 -0
  29. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeDetector.java +72 -0
  30. package/android/src/main/java/ee/forgr/capacitor_updater/ShakeMenu.java +959 -0
  31. package/android/src/main/java/ee/forgr/capacitor_updater/StatsBatchFailureDiagnostics.java +40 -0
  32. package/android/src/main/java/ee/forgr/capacitor_updater/ThreeFingerPinchDetector.java +323 -0
  33. package/android/src/main/java/ee/forgr/capacitor_updater/Version.java +306 -0
  34. package/dist/docs.json +4431 -840
  35. package/dist/esm/definitions.d.ts +2607 -225
  36. package/dist/esm/definitions.js +103 -1
  37. package/dist/esm/definitions.js.map +1 -1
  38. package/dist/esm/history.d.ts +1 -0
  39. package/dist/esm/history.js +283 -0
  40. package/dist/esm/history.js.map +1 -0
  41. package/dist/esm/index.d.ts +3 -2
  42. package/dist/esm/index.js +5 -4
  43. package/dist/esm/index.js.map +1 -1
  44. package/dist/esm/web.d.ts +53 -42
  45. package/dist/esm/web.js +180 -37
  46. package/dist/esm/web.js.map +1 -1
  47. package/dist/plugin.cjs.js +570 -37
  48. package/dist/plugin.cjs.js.map +1 -1
  49. package/dist/plugin.js +570 -37
  50. package/dist/plugin.js.map +1 -1
  51. package/ios/Sources/CapacitorUpdaterPlugin/AES.swift +262 -0
  52. package/ios/Sources/CapacitorUpdaterPlugin/AppHealthTracker.swift +82 -0
  53. package/ios/Sources/CapacitorUpdaterPlugin/BundleInfo.swift +185 -0
  54. package/ios/Sources/CapacitorUpdaterPlugin/BundleStatus.swift +127 -0
  55. package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +5642 -0
  56. package/ios/Sources/CapacitorUpdaterPlugin/CapgoRawRsa.swift +36 -0
  57. package/ios/Sources/CapacitorUpdaterPlugin/CapgoSemanticVersion.swift +162 -0
  58. package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +4572 -0
  59. package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +380 -0
  60. package/ios/Sources/CapacitorUpdaterPlugin/DelayUpdateUtils.swift +343 -0
  61. package/ios/Sources/CapacitorUpdaterPlugin/DeviceIdHelper.swift +120 -0
  62. package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +452 -0
  63. package/ios/Sources/CapacitorUpdaterPlugin/Logger.swift +380 -0
  64. package/ios/Sources/CapacitorUpdaterPlugin/NativeUpdatePrompt.swift +183 -0
  65. package/ios/Sources/CapacitorUpdaterPlugin/RSA.swift +96 -0
  66. package/ios/Sources/CapacitorUpdaterPlugin/RedirectPolicyDelegate.swift +97 -0
  67. package/ios/Sources/CapacitorUpdaterPlugin/ShakeMenu.swift +871 -0
  68. package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/UserDefaultsExtension.swift +0 -2
  69. package/ios/Sources/CapacitorUpdaterPlugin/WKWebView+CapgoObjcBridge.swift +20 -0
  70. package/ios/Sources/CapacitorUpdaterPlugin/WebViewStatsReporter.swift +304 -0
  71. package/ios/Sources/CapacitorUpdaterPlugin/ZipArchiveReader.swift +247 -0
  72. package/ios/Sources/CapacitorUpdaterPlugin/ZipCentralDirectory.swift +280 -0
  73. package/ios/Tests/CapacitorUpdaterPluginTests/BuiltinHashesTests.swift +210 -0
  74. package/ios/Tests/CapacitorUpdaterPluginTests/BundleHardeningTests.swift +292 -0
  75. package/ios/Tests/CapacitorUpdaterPluginTests/CapacitorUpdaterPluginTests.swift +3905 -0
  76. package/ios/Tests/CapacitorUpdaterPluginTests/CapgoSemanticVersionTests.swift +64 -0
  77. package/ios/Tests/CapacitorUpdaterPluginTests/ChecksumRequiredTests.swift +151 -0
  78. package/ios/Tests/CapacitorUpdaterPluginTests/CliCryptoFixtureTests.swift +249 -0
  79. package/ios/Tests/CapacitorUpdaterPluginTests/HttpsOnlyBuiltinMinimumTests.swift +528 -0
  80. package/ios/Tests/CapacitorUpdaterPluginTests/InstallPerfTests.swift +174 -0
  81. package/ios/Tests/CapacitorUpdaterPluginTests/ListChannelsTests.swift +74 -0
  82. package/ios/Tests/CapacitorUpdaterPluginTests/LoggerSecurityTests.swift +149 -0
  83. package/ios/Tests/CapacitorUpdaterPluginTests/NativeContractTests.swift +160 -0
  84. package/ios/Tests/CapacitorUpdaterPluginTests/NetworkTransportTests.swift +1095 -0
  85. package/ios/Tests/CapacitorUpdaterPluginTests/PopulateDeltaCacheTests.swift +573 -0
  86. package/ios/Tests/CapacitorUpdaterPluginTests/RedirectPolicyTests.swift +63 -0
  87. package/ios/Tests/CapacitorUpdaterPluginTests/RsaContractTests.swift +281 -0
  88. package/ios/Tests/CapacitorUpdaterPluginTests/SessionKeyRequiredTests.swift +192 -0
  89. package/ios/Tests/CapacitorUpdaterPluginTests/TestZipWriter.swift +235 -0
  90. package/ios/Tests/CapacitorUpdaterPluginTests/UpdateLifecycleTests.swift +454 -0
  91. package/ios/Tests/CapacitorUpdaterPluginTests/WebKitOverlayGuardTests.swift +32 -0
  92. package/ios/Tests/CapacitorUpdaterPluginTests/ZipArchiveReaderTests.swift +302 -0
  93. package/ios/Tests/CapacitorUpdaterPluginTests/ZipBundleExtractionTests.swift +122 -0
  94. package/package.json +80 -43
  95. package/scripts/builtin-hashes-lib.mjs +148 -0
  96. package/scripts/capacitor-builtin-hashes-hook.mjs +65 -0
  97. package/scripts/resolve-real-path.mjs +25 -0
  98. package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +0 -1130
  99. package/ios/Plugin/BundleInfo.swift +0 -113
  100. package/ios/Plugin/BundleStatus.swift +0 -48
  101. package/ios/Plugin/CapacitorUpdater.swift +0 -858
  102. package/ios/Plugin/CapacitorUpdaterPlugin.h +0 -10
  103. package/ios/Plugin/CapacitorUpdaterPlugin.m +0 -27
  104. package/ios/Plugin/CapacitorUpdaterPlugin.swift +0 -677
  105. package/ios/Plugin/CryptoCipher.swift +0 -240
  106. /package/{LICENCE → LICENSE} +0 -0
  107. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayCondition.swift +0 -0
  108. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/DelayUntilNext.swift +0 -0
  109. /package/ios/{Plugin → Sources/CapacitorUpdaterPlugin}/Info.plist +0 -0
package/dist/plugin.js CHANGED
@@ -1,12 +1,403 @@
1
1
  var capacitorCapacitorUpdater = (function (exports, core) {
2
2
  'use strict';
3
3
 
4
+ /*
5
+ * Maintains navigation history across Capgo-controlled reloads when keepUrlPathAfterReload is enabled.
6
+ */
7
+ const KEEP_FLAG_KEY = '__capgo_keep_url_path_after_reload';
8
+ const HISTORY_STORAGE_KEY = '__capgo_history_stack__';
9
+ const MAX_STACK_ENTRIES = 100;
10
+ const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof history !== 'undefined';
11
+ if (isBrowser) {
12
+ const win = window;
13
+ if (!win.__capgoHistoryPatched) {
14
+ win.__capgoHistoryPatched = true;
15
+ const isFeatureConfigured = () => {
16
+ try {
17
+ if (win.__capgoKeepUrlPathAfterReload) {
18
+ return true;
19
+ }
20
+ }
21
+ catch (_a) {
22
+ // ignore access issues
23
+ }
24
+ try {
25
+ return window.localStorage.getItem(KEEP_FLAG_KEY) === '1';
26
+ }
27
+ catch (_b) {
28
+ return false;
29
+ }
30
+ };
31
+ const readStored = () => {
32
+ try {
33
+ const raw = window.sessionStorage.getItem(HISTORY_STORAGE_KEY);
34
+ if (!raw) {
35
+ return { stack: [], index: -1 };
36
+ }
37
+ const parsed = JSON.parse(raw);
38
+ if (!parsed || !Array.isArray(parsed.stack) || typeof parsed.index !== 'number') {
39
+ return { stack: [], index: -1 };
40
+ }
41
+ return parsed;
42
+ }
43
+ catch (_a) {
44
+ return { stack: [], index: -1 };
45
+ }
46
+ };
47
+ const writeStored = (stack, index) => {
48
+ try {
49
+ window.sessionStorage.setItem(HISTORY_STORAGE_KEY, JSON.stringify({ stack, index }));
50
+ }
51
+ catch (_a) {
52
+ // Storage might be unavailable; fail silently.
53
+ }
54
+ };
55
+ const clearStored = () => {
56
+ try {
57
+ window.sessionStorage.removeItem(HISTORY_STORAGE_KEY);
58
+ }
59
+ catch (_a) {
60
+ // ignore
61
+ }
62
+ };
63
+ const normalize = (url) => {
64
+ try {
65
+ const base = url !== null && url !== void 0 ? url : window.location.href;
66
+ const parsed = new URL(base instanceof URL ? base.toString() : base, window.location.href);
67
+ return `${parsed.pathname}${parsed.search}${parsed.hash}`;
68
+ }
69
+ catch (_a) {
70
+ return null;
71
+ }
72
+ };
73
+ const trimStack = (stack, index) => {
74
+ if (stack.length <= MAX_STACK_ENTRIES) {
75
+ return { stack, index };
76
+ }
77
+ const start = stack.length - MAX_STACK_ENTRIES;
78
+ const trimmed = stack.slice(start);
79
+ const adjustedIndex = Math.max(0, index - start);
80
+ return { stack: trimmed, index: adjustedIndex };
81
+ };
82
+ const runWhenReady = (fn) => {
83
+ if (document.readyState === 'complete' || document.readyState === 'interactive') {
84
+ fn();
85
+ }
86
+ else {
87
+ window.addEventListener('DOMContentLoaded', fn, { once: true });
88
+ }
89
+ };
90
+ let featureActive = false;
91
+ let isRestoring = false;
92
+ let restoreScheduled = false;
93
+ const ensureCurrentTracked = () => {
94
+ if (!featureActive) {
95
+ return;
96
+ }
97
+ const stored = readStored();
98
+ const current = normalize();
99
+ if (!current) {
100
+ return;
101
+ }
102
+ if (stored.stack.length === 0) {
103
+ stored.stack.push(current);
104
+ stored.index = 0;
105
+ writeStored(stored.stack, stored.index);
106
+ return;
107
+ }
108
+ if (stored.index < 0 || stored.index >= stored.stack.length) {
109
+ stored.index = stored.stack.length - 1;
110
+ }
111
+ if (stored.stack[stored.index] !== current) {
112
+ stored.stack[stored.index] = current;
113
+ writeStored(stored.stack, stored.index);
114
+ }
115
+ };
116
+ const record = (url, replace) => {
117
+ if (!featureActive || isRestoring) {
118
+ return;
119
+ }
120
+ const normalized = normalize(url);
121
+ if (!normalized) {
122
+ return;
123
+ }
124
+ let { stack, index } = readStored();
125
+ if (stack.length === 0) {
126
+ stack.push(normalized);
127
+ index = stack.length - 1;
128
+ }
129
+ else if (replace) {
130
+ if (index < 0 || index >= stack.length) {
131
+ index = stack.length - 1;
132
+ }
133
+ stack[index] = normalized;
134
+ }
135
+ else {
136
+ if (index >= stack.length - 1) {
137
+ stack.push(normalized);
138
+ index = stack.length - 1;
139
+ }
140
+ else {
141
+ stack = stack.slice(0, index + 1);
142
+ stack.push(normalized);
143
+ index = stack.length - 1;
144
+ }
145
+ }
146
+ ({ stack, index } = trimStack(stack, index));
147
+ writeStored(stack, index);
148
+ };
149
+ const restoreHistory = () => {
150
+ if (!featureActive || isRestoring) {
151
+ return;
152
+ }
153
+ const stored = readStored();
154
+ if (stored.stack.length === 0) {
155
+ ensureCurrentTracked();
156
+ return;
157
+ }
158
+ const targetIndex = stored.index >= 0 && stored.index < stored.stack.length ? stored.index : stored.stack.length - 1;
159
+ const normalizedCurrent = normalize();
160
+ if (stored.stack.length === 1 && normalizedCurrent === stored.stack[0]) {
161
+ return;
162
+ }
163
+ const firstEntry = stored.stack[0];
164
+ if (!firstEntry) {
165
+ return;
166
+ }
167
+ isRestoring = true;
168
+ try {
169
+ history.replaceState(history.state, document.title, firstEntry);
170
+ for (let i = 1; i < stored.stack.length; i += 1) {
171
+ history.pushState(history.state, document.title, stored.stack[i]);
172
+ }
173
+ }
174
+ catch (_a) {
175
+ isRestoring = false;
176
+ return;
177
+ }
178
+ isRestoring = false;
179
+ const currentIndex = stored.stack.length - 1;
180
+ const offset = targetIndex - currentIndex;
181
+ if (offset !== 0) {
182
+ history.go(offset);
183
+ }
184
+ else {
185
+ history.replaceState(history.state, document.title, stored.stack[targetIndex]);
186
+ window.dispatchEvent(new PopStateEvent('popstate'));
187
+ }
188
+ };
189
+ const scheduleRestore = () => {
190
+ if (!featureActive || restoreScheduled) {
191
+ return;
192
+ }
193
+ restoreScheduled = true;
194
+ runWhenReady(() => {
195
+ restoreScheduled = false;
196
+ restoreHistory();
197
+ });
198
+ };
199
+ let originalPushState = null;
200
+ let originalReplaceState = null;
201
+ const popstateHandler = () => {
202
+ if (!featureActive || isRestoring) {
203
+ return;
204
+ }
205
+ const normalized = normalize();
206
+ if (!normalized) {
207
+ return;
208
+ }
209
+ const stored = readStored();
210
+ const idx = stored.stack.lastIndexOf(normalized);
211
+ if (idx >= 0) {
212
+ stored.index = idx;
213
+ }
214
+ else {
215
+ stored.stack.push(normalized);
216
+ stored.index = stored.stack.length - 1;
217
+ }
218
+ const trimmed = trimStack(stored.stack, stored.index);
219
+ writeStored(trimmed.stack, trimmed.index);
220
+ };
221
+ const patchHistory = () => {
222
+ if (originalPushState && originalReplaceState) {
223
+ return;
224
+ }
225
+ originalPushState = history.pushState;
226
+ originalReplaceState = history.replaceState;
227
+ history.pushState = function pushStatePatched(state, title, url) {
228
+ const result = originalPushState === null || originalPushState === void 0 ? void 0 : originalPushState.call(history, state, title, url);
229
+ record(url, false);
230
+ return result;
231
+ };
232
+ history.replaceState = function replaceStatePatched(state, title, url) {
233
+ const result = originalReplaceState === null || originalReplaceState === void 0 ? void 0 : originalReplaceState.call(history, state, title, url);
234
+ record(url, true);
235
+ return result;
236
+ };
237
+ window.addEventListener('popstate', popstateHandler);
238
+ };
239
+ const unpatchHistory = () => {
240
+ if (originalPushState) {
241
+ history.pushState = originalPushState;
242
+ originalPushState = null;
243
+ }
244
+ if (originalReplaceState) {
245
+ history.replaceState = originalReplaceState;
246
+ originalReplaceState = null;
247
+ }
248
+ window.removeEventListener('popstate', popstateHandler);
249
+ };
250
+ const setFeatureActive = (enabled) => {
251
+ if (featureActive === enabled) {
252
+ if (featureActive) {
253
+ ensureCurrentTracked();
254
+ scheduleRestore();
255
+ }
256
+ return;
257
+ }
258
+ featureActive = enabled;
259
+ if (featureActive) {
260
+ patchHistory();
261
+ ensureCurrentTracked();
262
+ scheduleRestore();
263
+ }
264
+ else {
265
+ unpatchHistory();
266
+ clearStored();
267
+ }
268
+ };
269
+ window.addEventListener('CapacitorUpdaterKeepUrlPathAfterReload', (event) => {
270
+ var _a;
271
+ const evt = event;
272
+ const enabled = (_a = evt === null || evt === void 0 ? void 0 : evt.detail) === null || _a === void 0 ? void 0 : _a.enabled;
273
+ if (typeof enabled === 'boolean') {
274
+ win.__capgoKeepUrlPathAfterReload = enabled;
275
+ setFeatureActive(enabled);
276
+ }
277
+ else {
278
+ win.__capgoKeepUrlPathAfterReload = true;
279
+ setFeatureActive(true);
280
+ }
281
+ });
282
+ setFeatureActive(isFeatureConfigured());
283
+ }
284
+ }
285
+
4
286
  /*
5
287
  * This Source Code Form is subject to the terms of the Mozilla Public
6
288
  * License, v. 2.0. If a copy of the MPL was not distributed with this
7
289
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
290
  */
9
- const CapacitorUpdater = core.registerPlugin("CapacitorUpdater", {
291
+ /**
292
+ * Update availability status.
293
+ *
294
+ * @since 8.0.0
295
+ */
296
+ exports.AppUpdateAvailability = void 0;
297
+ (function (AppUpdateAvailability) {
298
+ /**
299
+ * Update availability is unknown.
300
+ * This typically means the check hasn't completed or failed.
301
+ */
302
+ AppUpdateAvailability[AppUpdateAvailability["UNKNOWN"] = 0] = "UNKNOWN";
303
+ /**
304
+ * No update is available.
305
+ * The installed version is the latest.
306
+ */
307
+ AppUpdateAvailability[AppUpdateAvailability["UPDATE_NOT_AVAILABLE"] = 1] = "UPDATE_NOT_AVAILABLE";
308
+ /**
309
+ * An update is available for download.
310
+ */
311
+ AppUpdateAvailability[AppUpdateAvailability["UPDATE_AVAILABLE"] = 2] = "UPDATE_AVAILABLE";
312
+ /**
313
+ * An update is currently being downloaded or installed.
314
+ */
315
+ AppUpdateAvailability[AppUpdateAvailability["UPDATE_IN_PROGRESS"] = 3] = "UPDATE_IN_PROGRESS";
316
+ })(exports.AppUpdateAvailability || (exports.AppUpdateAvailability = {}));
317
+ /**
318
+ * Installation status for flexible updates (Android only).
319
+ *
320
+ * @since 8.0.0
321
+ */
322
+ exports.FlexibleUpdateInstallStatus = void 0;
323
+ (function (FlexibleUpdateInstallStatus) {
324
+ /**
325
+ * Unknown install status.
326
+ */
327
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["UNKNOWN"] = 0] = "UNKNOWN";
328
+ /**
329
+ * Download is pending and will start soon.
330
+ */
331
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["PENDING"] = 1] = "PENDING";
332
+ /**
333
+ * Download is in progress.
334
+ * Check `bytesDownloaded` and `totalBytesToDownload` for progress.
335
+ */
336
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["DOWNLOADING"] = 2] = "DOWNLOADING";
337
+ /**
338
+ * The update is being installed.
339
+ */
340
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["INSTALLING"] = 3] = "INSTALLING";
341
+ /**
342
+ * The update has been installed.
343
+ * The app needs to be restarted to use the new version.
344
+ */
345
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["INSTALLED"] = 4] = "INSTALLED";
346
+ /**
347
+ * The update failed to download or install.
348
+ */
349
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["FAILED"] = 5] = "FAILED";
350
+ /**
351
+ * The update was canceled by the user.
352
+ */
353
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["CANCELED"] = 6] = "CANCELED";
354
+ /**
355
+ * The update has been downloaded and is ready to install.
356
+ * Call {@link CapacitorUpdaterPlugin.completeFlexibleUpdate} to install.
357
+ */
358
+ FlexibleUpdateInstallStatus[FlexibleUpdateInstallStatus["DOWNLOADED"] = 11] = "DOWNLOADED";
359
+ })(exports.FlexibleUpdateInstallStatus || (exports.FlexibleUpdateInstallStatus = {}));
360
+ /**
361
+ * Result codes for app update operations.
362
+ *
363
+ * @since 8.0.0
364
+ */
365
+ exports.AppUpdateResultCode = void 0;
366
+ (function (AppUpdateResultCode) {
367
+ /**
368
+ * The update completed successfully.
369
+ */
370
+ AppUpdateResultCode[AppUpdateResultCode["OK"] = 0] = "OK";
371
+ /**
372
+ * The user canceled the update.
373
+ */
374
+ AppUpdateResultCode[AppUpdateResultCode["CANCELED"] = 1] = "CANCELED";
375
+ /**
376
+ * The update failed.
377
+ */
378
+ AppUpdateResultCode[AppUpdateResultCode["FAILED"] = 2] = "FAILED";
379
+ /**
380
+ * No update is available.
381
+ */
382
+ AppUpdateResultCode[AppUpdateResultCode["NOT_AVAILABLE"] = 3] = "NOT_AVAILABLE";
383
+ /**
384
+ * The requested update type is not allowed.
385
+ * For example, trying to perform an immediate update when only flexible is allowed.
386
+ */
387
+ AppUpdateResultCode[AppUpdateResultCode["NOT_ALLOWED"] = 4] = "NOT_ALLOWED";
388
+ /**
389
+ * Required information is missing.
390
+ * This can happen if {@link CapacitorUpdaterPlugin.getAppUpdateInfo} wasn't called first.
391
+ */
392
+ AppUpdateResultCode[AppUpdateResultCode["INFO_MISSING"] = 5] = "INFO_MISSING";
393
+ })(exports.AppUpdateResultCode || (exports.AppUpdateResultCode = {}));
394
+
395
+ /*
396
+ * This Source Code Form is subject to the terms of the Mozilla Public
397
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
398
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
399
+ */
400
+ const CapacitorUpdater = core.registerPlugin('CapacitorUpdater', {
10
401
  web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CapacitorUpdaterWeb()),
11
402
  });
12
403
 
@@ -16,96 +407,238 @@ var capacitorCapacitorUpdater = (function (exports, core) {
16
407
  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
17
408
  */
18
409
  const BUNDLE_BUILTIN = {
19
- status: "success",
20
- version: "",
21
- downloaded: "1970-01-01T00:00:00.000Z",
22
- id: "builtin",
23
- checksum: "",
410
+ status: 'success',
411
+ version: '',
412
+ downloaded: '1970-01-01T00:00:00.000Z',
413
+ id: 'builtin',
414
+ checksum: '',
24
415
  };
25
416
  class CapacitorUpdaterWeb extends core.WebPlugin {
417
+ async setStatsUrl(options) {
418
+ console.warn('Cannot setStatsUrl in web', options);
419
+ return;
420
+ }
421
+ async setUpdateUrl(options) {
422
+ console.warn('Cannot setUpdateUrl in web', options);
423
+ return;
424
+ }
425
+ async setChannelUrl(options) {
426
+ console.warn('Cannot setChannelUrl in web', options);
427
+ return;
428
+ }
26
429
  async download(options) {
27
- console.warn("Cannot download version in web", options);
430
+ console.warn('Cannot download version in web', options);
28
431
  return BUNDLE_BUILTIN;
29
432
  }
30
433
  async next(options) {
31
- console.warn("Cannot set next version in web", options);
434
+ console.warn('Cannot set next version in web', options);
32
435
  return BUNDLE_BUILTIN;
33
436
  }
34
437
  async isAutoUpdateEnabled() {
35
- console.warn("Cannot get isAutoUpdateEnabled in web");
438
+ console.warn('Cannot get isAutoUpdateEnabled in web');
36
439
  return { enabled: false };
37
440
  }
38
441
  async set(options) {
39
- console.warn("Cannot set active bundle in web", options);
442
+ console.warn('Cannot set active bundle in web', options);
443
+ return;
444
+ }
445
+ async startPreviewSession(options) {
446
+ console.warn('Cannot start preview session in web', options);
447
+ return;
448
+ }
449
+ async listPreviews() {
450
+ console.warn('Cannot list previews in web');
451
+ return { previews: [], currentBundle: BUNDLE_BUILTIN };
452
+ }
453
+ async setPreview(options) {
454
+ console.warn('Cannot set preview in web', options);
40
455
  return;
41
456
  }
457
+ async resetPreview() {
458
+ console.warn('Cannot reset preview in web');
459
+ return;
460
+ }
461
+ async deletePreview(options) {
462
+ console.warn('Cannot delete preview in web', options);
463
+ return { removed: false, deleted: false };
464
+ }
465
+ async checkPreviewUpdate(options) {
466
+ console.warn('Cannot check preview update in web', options);
467
+ throw this.unimplemented('Preview updates are not available on web platform');
468
+ }
469
+ async updatePreview(options) {
470
+ console.warn('Cannot update preview in web', options);
471
+ throw this.unimplemented('Preview updates are not available on web platform');
472
+ }
42
473
  async getDeviceId() {
43
- console.warn("Cannot get ID in web");
44
- return { deviceId: "default" };
474
+ console.warn('Cannot get ID in web');
475
+ return { deviceId: 'default' };
476
+ }
477
+ async getBuiltinVersion() {
478
+ console.warn('Cannot get version in web');
479
+ return { version: 'default' };
45
480
  }
46
481
  async getPluginVersion() {
47
- console.warn("Cannot get plugin version in web");
48
- return { version: "default" };
482
+ console.warn('Cannot get plugin version in web');
483
+ return { version: 'default' };
49
484
  }
50
485
  async delete(options) {
51
- console.warn("Cannot delete bundle in web", options);
486
+ console.warn('Cannot delete bundle in web', options);
487
+ }
488
+ async setBundleError(options) {
489
+ console.warn('Cannot setBundleError in web', options);
490
+ return BUNDLE_BUILTIN;
52
491
  }
53
492
  async list() {
54
- console.warn("Cannot list bundles in web");
493
+ console.warn('Cannot list bundles in web');
55
494
  return { bundles: [] };
56
495
  }
57
496
  async reset(options) {
58
- console.warn("Cannot reset version in web", options);
497
+ console.warn('Cannot reset version in web', options);
59
498
  }
60
499
  async current() {
61
- console.warn("Cannot get current bundle in web");
62
- return { bundle: BUNDLE_BUILTIN, native: "0.0.0" };
500
+ console.warn('Cannot get current bundle in web');
501
+ return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };
63
502
  }
64
503
  async reload() {
65
- console.warn("Cannot reload current bundle in web");
504
+ console.warn('Cannot reload current bundle in web');
66
505
  return;
67
506
  }
68
507
  async getLatest() {
69
- console.warn("Cannot getLatest current bundle in web");
508
+ console.warn('Cannot getLatest current bundle in web');
509
+ return {
510
+ version: '0.0.0',
511
+ message: 'Cannot getLatest current bundle in web',
512
+ };
513
+ }
514
+ async triggerUpdateCheck() {
515
+ console.warn('Cannot triggerUpdateCheck in web');
516
+ return { status: 'unavailable', queued: false };
517
+ }
518
+ async getMissingBundleFiles(options) {
519
+ var _a, _b, _c;
520
+ console.warn('Cannot inspect missing bundle files in web', { manifestLength: (_b = (_a = options.manifest) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 });
521
+ const missing = (_c = options.manifest) !== null && _c !== void 0 ? _c : [];
522
+ return {
523
+ missing,
524
+ total: missing.length,
525
+ missingCount: missing.length,
526
+ reusableCount: 0,
527
+ };
528
+ }
529
+ async getBundleDownloadSize(options) {
530
+ var _a, _b, _c, _d, _e;
531
+ console.warn('Cannot estimate bundle download size in web', { manifestLength: (_b = (_a = options.manifest) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 });
70
532
  return {
71
- version: "0.0.0",
72
- message: "Cannot getLatest current bundle in web",
533
+ totalSize: 0,
534
+ knownFiles: 0,
535
+ unknownFiles: (_d = (_c = options.manifest) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
536
+ files: ((_e = options.manifest) !== null && _e !== void 0 ? _e : []).map((entry) => ({
537
+ file_name: entry.file_name,
538
+ file_hash: entry.file_hash,
539
+ download_url: entry.download_url,
540
+ error: 'unavailable',
541
+ })),
73
542
  };
74
543
  }
75
544
  async setChannel(options) {
76
- console.warn("Cannot setChannel in web", options);
545
+ console.warn('Cannot setChannel in web', options);
77
546
  return {
78
- status: "error",
79
- error: "Cannot setChannel in web",
547
+ status: 'error',
548
+ error: 'Cannot setChannel in web',
80
549
  };
81
550
  }
551
+ async unsetChannel(options) {
552
+ console.warn('Cannot unsetChannel in web', options);
553
+ return;
554
+ }
82
555
  async setCustomId(options) {
83
- console.warn("Cannot setCustomId in web", options);
556
+ console.warn('Cannot setCustomId in web', options);
84
557
  return;
85
558
  }
86
559
  async getChannel() {
87
- console.warn("Cannot getChannel in web");
560
+ console.warn('Cannot getChannel in web');
88
561
  return {
89
- status: "error",
90
- error: "Cannot getChannel in web",
562
+ status: 'error',
563
+ error: 'Cannot getChannel in web',
564
+ };
565
+ }
566
+ async listChannels() {
567
+ console.warn('Cannot listChannels in web');
568
+ throw {
569
+ message: 'Cannot listChannels in web',
570
+ error: 'platform_not_supported',
91
571
  };
92
572
  }
93
573
  async notifyAppReady() {
94
- console.warn("Cannot notify App Ready in web");
95
- return BUNDLE_BUILTIN;
574
+ return { bundle: BUNDLE_BUILTIN };
96
575
  }
97
576
  async setMultiDelay(options) {
98
- console.warn("Cannot setMultiDelay in web", options === null || options === void 0 ? void 0 : options.delayConditions);
577
+ console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);
99
578
  return;
100
579
  }
101
- async setDelay(option) {
102
- console.warn("Cannot setDelay in web", option);
580
+ async cancelDelay() {
581
+ console.warn('Cannot cancelDelay in web');
103
582
  return;
104
583
  }
105
- async cancelDelay() {
106
- console.warn("Cannot cancelDelay in web");
584
+ async isAutoUpdateAvailable() {
585
+ console.warn('Cannot isAutoUpdateAvailable in web');
586
+ return { available: false };
587
+ }
588
+ async getCurrentBundle() {
589
+ console.warn('Cannot get current bundle in web');
590
+ return BUNDLE_BUILTIN;
591
+ }
592
+ async getNextBundle() {
593
+ return Promise.resolve(null);
594
+ }
595
+ async getFailedUpdate() {
596
+ console.warn('Cannot getFailedUpdate in web');
597
+ return null;
598
+ }
599
+ async setShakeMenu(_options) {
600
+ throw this.unimplemented('Shake menu not available on web platform');
601
+ }
602
+ async isShakeMenuEnabled() {
603
+ return Promise.resolve({ enabled: false, gesture: 'shake' });
604
+ }
605
+ async setShakeChannelSelector(_options) {
606
+ throw this.unimplemented('Shake channel selector not available on web platform');
607
+ }
608
+ async isShakeChannelSelectorEnabled() {
609
+ return Promise.resolve({ enabled: false });
610
+ }
611
+ async getAppId() {
612
+ console.warn('Cannot getAppId in web');
613
+ return { appId: 'default' };
614
+ }
615
+ async setAppId(options) {
616
+ console.warn('Cannot setAppId in web', options);
107
617
  return;
108
618
  }
619
+ // ============================================================================
620
+ // App Store / Play Store Update Methods (Web stubs)
621
+ // ============================================================================
622
+ async getAppUpdateInfo(_options) {
623
+ console.warn('getAppUpdateInfo is not available on web platform');
624
+ return {
625
+ currentVersionName: '0.0.0',
626
+ currentVersionCode: '0',
627
+ updateAvailability: exports.AppUpdateAvailability.UNKNOWN,
628
+ };
629
+ }
630
+ async openAppStore(_options) {
631
+ throw this.unimplemented('openAppStore is not available on web platform');
632
+ }
633
+ async performImmediateUpdate() {
634
+ throw this.unimplemented('performImmediateUpdate is only available on Android');
635
+ }
636
+ async startFlexibleUpdate() {
637
+ throw this.unimplemented('startFlexibleUpdate is only available on Android');
638
+ }
639
+ async completeFlexibleUpdate() {
640
+ throw this.unimplemented('completeFlexibleUpdate is only available on Android');
641
+ }
109
642
  }
110
643
 
111
644
  var web = /*#__PURE__*/Object.freeze({