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