@capgo/capacitor-updater 6.13.2 → 6.14.2
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/README.md +25 -14
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +134 -194
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +23 -23
- package/android/src/main/java/ee/forgr/capacitor_updater/Callback.java +1 -1
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +964 -1153
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +1259 -1628
- package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +161 -197
- package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipherV2.java +202 -256
- package/android/src/main/java/ee/forgr/capacitor_updater/DataManager.java +16 -16
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayCondition.java +44 -48
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayUntilNext.java +4 -4
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +378 -467
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +71 -83
- package/android/src/main/java/ee/forgr/capacitor_updater/InternalUtils.java +19 -28
- package/dist/docs.json +57 -21
- package/dist/esm/definitions.d.ts +24 -15
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +2 -2
- package/dist/esm/web.js +43 -43
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +43 -43
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +43 -43
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorUpdater.swift +51 -29
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +3 -2
- package/package.json +5 -7
package/dist/plugin.js
CHANGED
|
@@ -6,7 +6,7 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
6
6
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
7
7
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
8
8
|
*/
|
|
9
|
-
const CapacitorUpdater = core.registerPlugin(
|
|
9
|
+
const CapacitorUpdater = core.registerPlugin('CapacitorUpdater', {
|
|
10
10
|
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CapacitorUpdaterWeb()),
|
|
11
11
|
});
|
|
12
12
|
|
|
@@ -16,126 +16,126 @@ var capacitorCapacitorUpdater = (function (exports, core) {
|
|
|
16
16
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
17
17
|
*/
|
|
18
18
|
const BUNDLE_BUILTIN = {
|
|
19
|
-
status:
|
|
20
|
-
version:
|
|
21
|
-
downloaded:
|
|
22
|
-
id:
|
|
23
|
-
checksum:
|
|
19
|
+
status: 'success',
|
|
20
|
+
version: '',
|
|
21
|
+
downloaded: '1970-01-01T00:00:00.000Z',
|
|
22
|
+
id: 'builtin',
|
|
23
|
+
checksum: '',
|
|
24
24
|
};
|
|
25
25
|
class CapacitorUpdaterWeb extends core.WebPlugin {
|
|
26
26
|
async setStatsUrl(options) {
|
|
27
|
-
console.warn(
|
|
27
|
+
console.warn('Cannot setStatsUrl in web', options);
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
async setUpdateUrl(options) {
|
|
31
|
-
console.warn(
|
|
31
|
+
console.warn('Cannot setUpdateUrl in web', options);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
async setChannelUrl(options) {
|
|
35
|
-
console.warn(
|
|
35
|
+
console.warn('Cannot setChannelUrl in web', options);
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
async download(options) {
|
|
39
|
-
console.warn(
|
|
39
|
+
console.warn('Cannot download version in web', options);
|
|
40
40
|
return BUNDLE_BUILTIN;
|
|
41
41
|
}
|
|
42
42
|
async next(options) {
|
|
43
|
-
console.warn(
|
|
43
|
+
console.warn('Cannot set next version in web', options);
|
|
44
44
|
return BUNDLE_BUILTIN;
|
|
45
45
|
}
|
|
46
46
|
async isAutoUpdateEnabled() {
|
|
47
|
-
console.warn(
|
|
47
|
+
console.warn('Cannot get isAutoUpdateEnabled in web');
|
|
48
48
|
return { enabled: false };
|
|
49
49
|
}
|
|
50
50
|
async set(options) {
|
|
51
|
-
console.warn(
|
|
51
|
+
console.warn('Cannot set active bundle in web', options);
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
async getDeviceId() {
|
|
55
|
-
console.warn(
|
|
56
|
-
return { deviceId:
|
|
55
|
+
console.warn('Cannot get ID in web');
|
|
56
|
+
return { deviceId: 'default' };
|
|
57
57
|
}
|
|
58
58
|
async getBuiltinVersion() {
|
|
59
|
-
console.warn(
|
|
60
|
-
return { version:
|
|
59
|
+
console.warn('Cannot get version in web');
|
|
60
|
+
return { version: 'default' };
|
|
61
61
|
}
|
|
62
62
|
async getPluginVersion() {
|
|
63
|
-
console.warn(
|
|
64
|
-
return { version:
|
|
63
|
+
console.warn('Cannot get plugin version in web');
|
|
64
|
+
return { version: 'default' };
|
|
65
65
|
}
|
|
66
66
|
async delete(options) {
|
|
67
|
-
console.warn(
|
|
67
|
+
console.warn('Cannot delete bundle in web', options);
|
|
68
68
|
}
|
|
69
69
|
async list() {
|
|
70
|
-
console.warn(
|
|
70
|
+
console.warn('Cannot list bundles in web');
|
|
71
71
|
return { bundles: [] };
|
|
72
72
|
}
|
|
73
73
|
async reset(options) {
|
|
74
|
-
console.warn(
|
|
74
|
+
console.warn('Cannot reset version in web', options);
|
|
75
75
|
}
|
|
76
76
|
async current() {
|
|
77
|
-
console.warn(
|
|
78
|
-
return { bundle: BUNDLE_BUILTIN, native:
|
|
77
|
+
console.warn('Cannot get current bundle in web');
|
|
78
|
+
return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };
|
|
79
79
|
}
|
|
80
80
|
async reload() {
|
|
81
|
-
console.warn(
|
|
81
|
+
console.warn('Cannot reload current bundle in web');
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
async getLatest() {
|
|
85
|
-
console.warn(
|
|
85
|
+
console.warn('Cannot getLatest current bundle in web');
|
|
86
86
|
return {
|
|
87
|
-
version:
|
|
88
|
-
message:
|
|
87
|
+
version: '0.0.0',
|
|
88
|
+
message: 'Cannot getLatest current bundle in web',
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
async setChannel(options) {
|
|
92
|
-
console.warn(
|
|
92
|
+
console.warn('Cannot setChannel in web', options);
|
|
93
93
|
return {
|
|
94
|
-
status:
|
|
95
|
-
error:
|
|
94
|
+
status: 'error',
|
|
95
|
+
error: 'Cannot setChannel in web',
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
async unsetChannel(options) {
|
|
99
|
-
console.warn(
|
|
99
|
+
console.warn('Cannot unsetChannel in web', options);
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
async setCustomId(options) {
|
|
103
|
-
console.warn(
|
|
103
|
+
console.warn('Cannot setCustomId in web', options);
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
async getChannel() {
|
|
107
|
-
console.warn(
|
|
107
|
+
console.warn('Cannot getChannel in web');
|
|
108
108
|
return {
|
|
109
|
-
status:
|
|
110
|
-
error:
|
|
109
|
+
status: 'error',
|
|
110
|
+
error: 'Cannot getChannel in web',
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
async notifyAppReady() {
|
|
114
|
-
console.warn(
|
|
114
|
+
console.warn('Cannot notify App Ready in web');
|
|
115
115
|
return { bundle: BUNDLE_BUILTIN };
|
|
116
116
|
}
|
|
117
117
|
async setMultiDelay(options) {
|
|
118
|
-
console.warn(
|
|
118
|
+
console.warn('Cannot setMultiDelay in web', options === null || options === undefined ? undefined : options.delayConditions);
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
async setDelay(option) {
|
|
122
|
-
console.warn(
|
|
122
|
+
console.warn('Cannot setDelay in web', option);
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
125
125
|
async cancelDelay() {
|
|
126
|
-
console.warn(
|
|
126
|
+
console.warn('Cannot cancelDelay in web');
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
129
|
async isAutoUpdateAvailable() {
|
|
130
|
-
console.warn(
|
|
130
|
+
console.warn('Cannot isAutoUpdateAvailable in web');
|
|
131
131
|
return { available: false };
|
|
132
132
|
}
|
|
133
133
|
async getCurrentBundle() {
|
|
134
|
-
console.warn(
|
|
134
|
+
console.warn('Cannot get current bundle in web');
|
|
135
135
|
return BUNDLE_BUILTIN;
|
|
136
136
|
}
|
|
137
137
|
async getNextBundle() {
|
|
138
|
-
console.warn(
|
|
138
|
+
console.warn('Cannot get next bundle in web');
|
|
139
139
|
return null;
|
|
140
140
|
}
|
|
141
141
|
}
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { registerPlugin } from
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { registerPlugin } from '@capacitor/core';\nconst CapacitorUpdater = registerPlugin('CapacitorUpdater', {\n web: () => import('./web').then((m) => new m.CapacitorUpdaterWeb()),\n});\nexport * from './definitions';\nexport { CapacitorUpdater };\n//# sourceMappingURL=index.js.map","/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\nimport { WebPlugin } from '@capacitor/core';\nconst BUNDLE_BUILTIN = {\n status: 'success',\n version: '',\n downloaded: '1970-01-01T00:00:00.000Z',\n id: 'builtin',\n checksum: '',\n};\nexport class CapacitorUpdaterWeb extends WebPlugin {\n async setStatsUrl(options) {\n console.warn('Cannot setStatsUrl in web', options);\n return;\n }\n async setUpdateUrl(options) {\n console.warn('Cannot setUpdateUrl in web', options);\n return;\n }\n async setChannelUrl(options) {\n console.warn('Cannot setChannelUrl in web', options);\n return;\n }\n async download(options) {\n console.warn('Cannot download version in web', options);\n return BUNDLE_BUILTIN;\n }\n async next(options) {\n console.warn('Cannot set next version in web', options);\n return BUNDLE_BUILTIN;\n }\n async isAutoUpdateEnabled() {\n console.warn('Cannot get isAutoUpdateEnabled in web');\n return { enabled: false };\n }\n async set(options) {\n console.warn('Cannot set active bundle in web', options);\n return;\n }\n async getDeviceId() {\n console.warn('Cannot get ID in web');\n return { deviceId: 'default' };\n }\n async getBuiltinVersion() {\n console.warn('Cannot get version in web');\n return { version: 'default' };\n }\n async getPluginVersion() {\n console.warn('Cannot get plugin version in web');\n return { version: 'default' };\n }\n async delete(options) {\n console.warn('Cannot delete bundle in web', options);\n }\n async list() {\n console.warn('Cannot list bundles in web');\n return { bundles: [] };\n }\n async reset(options) {\n console.warn('Cannot reset version in web', options);\n }\n async current() {\n console.warn('Cannot get current bundle in web');\n return { bundle: BUNDLE_BUILTIN, native: '0.0.0' };\n }\n async reload() {\n console.warn('Cannot reload current bundle in web');\n return;\n }\n async getLatest() {\n console.warn('Cannot getLatest current bundle in web');\n return {\n version: '0.0.0',\n message: 'Cannot getLatest current bundle in web',\n };\n }\n async setChannel(options) {\n console.warn('Cannot setChannel in web', options);\n return {\n status: 'error',\n error: 'Cannot setChannel in web',\n };\n }\n async unsetChannel(options) {\n console.warn('Cannot unsetChannel in web', options);\n return;\n }\n async setCustomId(options) {\n console.warn('Cannot setCustomId in web', options);\n return;\n }\n async getChannel() {\n console.warn('Cannot getChannel in web');\n return {\n status: 'error',\n error: 'Cannot getChannel in web',\n };\n }\n async notifyAppReady() {\n console.warn('Cannot notify App Ready in web');\n return { bundle: BUNDLE_BUILTIN };\n }\n async setMultiDelay(options) {\n console.warn('Cannot setMultiDelay in web', options === null || options === void 0 ? void 0 : options.delayConditions);\n return;\n }\n async setDelay(option) {\n console.warn('Cannot setDelay in web', option);\n return;\n }\n async cancelDelay() {\n console.warn('Cannot cancelDelay in web');\n return;\n }\n async isAutoUpdateAvailable() {\n console.warn('Cannot isAutoUpdateAvailable in web');\n return { available: false };\n }\n async getCurrentBundle() {\n console.warn('Cannot get current bundle in web');\n return BUNDLE_BUILTIN;\n }\n async getNextBundle() {\n console.warn('Cannot get next bundle in web');\n return null;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;AAEK,UAAC,gBAAgB,GAAGA,mBAAc,CAAC,kBAAkB,EAAE;IAC5D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;IACvE,CAAC;;ICRD;IACA;IACA;IACA;IACA;IAEA,MAAM,cAAc,GAAG;IACvB,IAAI,MAAM,EAAE,SAAS;IACrB,IAAI,OAAO,EAAE,EAAE;IACf,IAAI,UAAU,EAAE,0BAA0B;IAC1C,IAAI,EAAE,EAAE,SAAS;IACjB,IAAI,QAAQ,EAAE,EAAE;IAChB,CAAC;IACM,MAAM,mBAAmB,SAASC,cAAS,CAAC;IACnD,IAAI,MAAM,WAAW,CAAC,OAAO,EAAE;IAC/B,QAAQ,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE,OAAO,CAAC;IAC1D,QAAQ;IACR;IACA,IAAI,MAAM,YAAY,CAAC,OAAO,EAAE;IAChC,QAAQ,OAAO,CAAC,IAAI,CAAC,4BAA4B,EAAE,OAAO,CAAC;IAC3D,QAAQ;IACR;IACA,IAAI,MAAM,aAAa,C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K,EAAE,0BAA0B;IAC7C,SAAS;IACT;IACA,IAAI,MAAM,cAAc,GAAG;IAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC;IACtD,QAAQ,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE;IACzC;IACA,IAAI,MAAM,aAAa,CAAC,OAAO,EAAE;IACjC,QAAQ,OAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAM,GAAG,SAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAC9H,QAAQ;IACR;IACA,IAAI,MAAM,QAAQ,CAAC,MAAM,EAAE;IAC3B,QAAQ,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC;IACtD,QAAQ;IACR;IACA,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC;IACjD,QAAQ;IACR;IACA,IAAI,MAAM,qBAAqB,GAAG;IAClC,QAAQ,OAAO,CAAC,IAAI,CAAC,qCAAqC,CAAC;IAC3D,QAAQ,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE;IACnC;IACA,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC;IACxD,QAAQ,OAAO,cAAc;IAC7B;IACA,IAAI,MAAM,aAAa,GAAG;IAC1B,QAAQ,OAAO,CAAC,IAAI,CAAC,+BAA+B,CAAC;IACrD,QAAQ,OAAO,IAAI;IACnB;IACA;;;;;;;;;;;;;;;"}
|
|
@@ -339,8 +339,8 @@ import UIKit
|
|
|
339
339
|
let downloadUrl = entry.download_url else {
|
|
340
340
|
continue
|
|
341
341
|
}
|
|
342
|
-
|
|
343
|
-
if
|
|
342
|
+
|
|
343
|
+
if !self.hasOldPrivateKeyPropertyInConfig && !self.publicKey.isEmpty && !sessionKey.isEmpty {
|
|
344
344
|
do {
|
|
345
345
|
fileHash = try CryptoCipherV2.decryptChecksum(checksum: fileHash, publicKey: self.publicKey, version: version)
|
|
346
346
|
} catch {
|
|
@@ -404,29 +404,28 @@ import UIKit
|
|
|
404
404
|
finalData = try Data(contentsOf: tempFile)
|
|
405
405
|
try FileManager.default.removeItem(at: tempFile)
|
|
406
406
|
}
|
|
407
|
-
|
|
407
|
+
|
|
408
408
|
// Decompress the Brotli data
|
|
409
|
-
guard let decompressedData = self.decompressBrotli(data: finalData) else {
|
|
409
|
+
guard let decompressedData = self.decompressBrotli(data: finalData, fileName: fileName) else {
|
|
410
410
|
throw NSError(domain: "BrotliDecompressionError", code: 1, userInfo: [NSLocalizedDescriptionKey: "Failed to decompress Brotli data"])
|
|
411
411
|
}
|
|
412
412
|
finalData = decompressedData
|
|
413
|
-
|
|
413
|
+
|
|
414
414
|
try finalData.write(to: destFilePath)
|
|
415
|
-
if
|
|
415
|
+
if !self.hasOldPrivateKeyPropertyInConfig && !self.publicKey.isEmpty && !sessionKey.isEmpty {
|
|
416
416
|
// assume that calcChecksum != null
|
|
417
417
|
let calculatedChecksum = CryptoCipherV2.calcChecksum(filePath: destFilePath)
|
|
418
|
-
if
|
|
418
|
+
if calculatedChecksum != fileHash {
|
|
419
419
|
throw NSError(domain: "ChecksumError", code: 1, userInfo: [NSLocalizedDescriptionKey: "Computed checksum is not equal to required checksum (\(calculatedChecksum) != \(fileHash))"])
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
|
-
|
|
422
|
+
|
|
423
423
|
// Save decrypted data to cache and destination
|
|
424
424
|
try finalData.write(to: cacheFilePath)
|
|
425
|
-
|
|
426
425
|
|
|
427
426
|
completedFiles += 1
|
|
428
427
|
self.notifyDownload(id: id, percent: self.calcTotalPercent(percent: Int((Double(completedFiles) / Double(totalFiles)) * 100), min: 10, max: 70))
|
|
429
|
-
print("\(CapacitorUpdater.TAG) downloadManifest \(id) \(fileName) downloaded, decompressed, decrypted, and cached")
|
|
428
|
+
print("\(CapacitorUpdater.TAG) downloadManifest \(id) \(fileName) downloaded, decompressed\(!self.publicKey.isEmpty && !sessionKey.isEmpty ? ", decrypted" : ""), and cached")
|
|
430
429
|
} catch {
|
|
431
430
|
downloadError = error
|
|
432
431
|
print("\(CapacitorUpdater.TAG) downloadManifest \(id) \(fileName) error: \(error)")
|
|
@@ -455,7 +454,7 @@ import UIKit
|
|
|
455
454
|
return updatedBundle
|
|
456
455
|
}
|
|
457
456
|
|
|
458
|
-
private func decompressBrotli(data: Data) -> Data? {
|
|
457
|
+
private func decompressBrotli(data: Data, fileName: String) -> Data? {
|
|
459
458
|
let outputBufferSize = 65536
|
|
460
459
|
var outputBuffer = [UInt8](repeating: 0, count: outputBufferSize)
|
|
461
460
|
var decompressedData = Data()
|
|
@@ -463,7 +462,7 @@ import UIKit
|
|
|
463
462
|
let streamPointer = UnsafeMutablePointer<compression_stream>.allocate(capacity: 1)
|
|
464
463
|
var status = compression_stream_init(streamPointer, COMPRESSION_STREAM_DECODE, COMPRESSION_BROTLI)
|
|
465
464
|
guard status != COMPRESSION_STATUS_ERROR else {
|
|
466
|
-
print("\(CapacitorUpdater.TAG) Unable to initialize the decompression stream.")
|
|
465
|
+
print("\(CapacitorUpdater.TAG) Unable to initialize the decompression stream. \(fileName)")
|
|
467
466
|
return nil
|
|
468
467
|
}
|
|
469
468
|
|
|
@@ -485,7 +484,7 @@ import UIKit
|
|
|
485
484
|
if let baseAddress = rawBufferPointer.baseAddress {
|
|
486
485
|
streamPointer.pointee.src_ptr = baseAddress.assumingMemoryBound(to: UInt8.self)
|
|
487
486
|
} else {
|
|
488
|
-
print("\(CapacitorUpdater.TAG) Error: Unable to get base address of input data")
|
|
487
|
+
print("\(CapacitorUpdater.TAG) Error: Unable to get base address of input data. \(fileName)")
|
|
489
488
|
status = COMPRESSION_STATUS_ERROR
|
|
490
489
|
return
|
|
491
490
|
}
|
|
@@ -506,7 +505,7 @@ import UIKit
|
|
|
506
505
|
if status == COMPRESSION_STATUS_END {
|
|
507
506
|
break
|
|
508
507
|
} else if status == COMPRESSION_STATUS_ERROR {
|
|
509
|
-
print("\(CapacitorUpdater.TAG) Error during Brotli decompression")
|
|
508
|
+
print("\(CapacitorUpdater.TAG) Error during Brotli decompression. \(fileName)")
|
|
510
509
|
// Try to decode as text if mostly ASCII
|
|
511
510
|
if let text = String(data: data, encoding: .utf8) {
|
|
512
511
|
let asciiCount = text.unicodeScalars.filter { $0.isASCII }.count
|
|
@@ -746,22 +745,40 @@ import UIKit
|
|
|
746
745
|
return 0
|
|
747
746
|
}
|
|
748
747
|
|
|
749
|
-
public func list() -> [BundleInfo] {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
let
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
748
|
+
public func list(raw: Bool = false) -> [BundleInfo] {
|
|
749
|
+
if !raw {
|
|
750
|
+
// UserDefaults.standard.dictionaryRepresentation().values
|
|
751
|
+
let dest: URL = libraryDir.appendingPathComponent(bundleDirectory)
|
|
752
|
+
do {
|
|
753
|
+
let files: [String] = try FileManager.default.contentsOfDirectory(atPath: dest.path)
|
|
754
|
+
var res: [BundleInfo] = []
|
|
755
|
+
print("\(CapacitorUpdater.TAG) list File : \(dest.path)")
|
|
756
|
+
if dest.exist {
|
|
757
|
+
for id: String in files {
|
|
758
|
+
res.append(self.getBundleInfo(id: id))
|
|
759
|
+
}
|
|
758
760
|
}
|
|
761
|
+
return res
|
|
762
|
+
} catch {
|
|
763
|
+
print("\(CapacitorUpdater.TAG) No version available \(dest.path)")
|
|
764
|
+
return []
|
|
765
|
+
}
|
|
766
|
+
} else {
|
|
767
|
+
guard let regex = try? NSRegularExpression(pattern: "^[0-9A-Za-z]{10}_info$") else {
|
|
768
|
+
print("\(CapacitorUpdater.TAG) Invald regex ?????")
|
|
769
|
+
return []
|
|
770
|
+
}
|
|
771
|
+
return UserDefaults.standard.dictionaryRepresentation().keys.filter {
|
|
772
|
+
let range = NSRange($0.startIndex..., in: $0)
|
|
773
|
+
let matches = regex.matches(in: $0, range: range)
|
|
774
|
+
return !matches.isEmpty
|
|
775
|
+
}.map {
|
|
776
|
+
$0.components(separatedBy: "_")[0]
|
|
777
|
+
}.map {
|
|
778
|
+
self.getBundleInfo(id: $0)
|
|
759
779
|
}
|
|
760
|
-
return res
|
|
761
|
-
} catch {
|
|
762
|
-
print("\(CapacitorUpdater.TAG) No version available \(dest.path)")
|
|
763
|
-
return []
|
|
764
780
|
}
|
|
781
|
+
|
|
765
782
|
}
|
|
766
783
|
|
|
767
784
|
public func delete(id: String, removeInfo: Bool) -> Bool {
|
|
@@ -774,8 +791,8 @@ import UIKit
|
|
|
774
791
|
// Check if this is the next bundle and prevent deletion if it is
|
|
775
792
|
if let next = self.getNextBundle(),
|
|
776
793
|
!next.isDeleted() &&
|
|
777
|
-
|
|
778
|
-
|
|
794
|
+
!next.isErrorStatus() &&
|
|
795
|
+
next.getId() == id {
|
|
779
796
|
print("\(CapacitorUpdater.TAG) Cannot delete the next bundle \(id)")
|
|
780
797
|
return false
|
|
781
798
|
}
|
|
@@ -785,6 +802,11 @@ import UIKit
|
|
|
785
802
|
try FileManager.default.removeItem(atPath: destPersist.path)
|
|
786
803
|
} catch {
|
|
787
804
|
print("\(CapacitorUpdater.TAG) Folder \(destPersist.path), not removed.")
|
|
805
|
+
// even if, we don;t care. Android doesn't care
|
|
806
|
+
if removeInfo {
|
|
807
|
+
self.removeBundleInfo(id: id)
|
|
808
|
+
}
|
|
809
|
+
self.sendStats(action: "delete", versionName: deleted.getVersionName())
|
|
788
810
|
return false
|
|
789
811
|
}
|
|
790
812
|
if removeInfo {
|
|
@@ -45,7 +45,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
45
45
|
CAPPluginMethod(name: "getNextBundle", returnType: CAPPluginReturnPromise)
|
|
46
46
|
]
|
|
47
47
|
public var implementation = CapacitorUpdater()
|
|
48
|
-
private let PLUGIN_VERSION: String = "6.
|
|
48
|
+
private let PLUGIN_VERSION: String = "6.14.2"
|
|
49
49
|
static let updateUrlDefault = "https://plugin.capgo.app/updates"
|
|
50
50
|
static let statsUrlDefault = "https://plugin.capgo.app/stats"
|
|
51
51
|
static let channelUrlDefault = "https://plugin.capgo.app/channel_self"
|
|
@@ -424,7 +424,8 @@ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
@objc func list(_ call: CAPPluginCall) {
|
|
427
|
-
let
|
|
427
|
+
let raw = call.getBool("raw", false)
|
|
428
|
+
let res = implementation.list(raw: raw)
|
|
428
429
|
var resArr: [[String: String]] = []
|
|
429
430
|
for v in res {
|
|
430
431
|
resArr.append(v.toJSON())
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-updater",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.14.2",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Live update for capacitor apps",
|
|
6
6
|
"main": "dist/plugin.cjs.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
49
49
|
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --autocorrect --format",
|
|
50
50
|
"eslint": "eslint . --ext .ts",
|
|
51
|
-
"prettier": "prettier
|
|
51
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
|
|
52
52
|
"swiftlint": "node-swiftlint",
|
|
53
53
|
"docgen": "docgen --api CapacitorUpdaterPlugin --output-readme README.md --output-json dist/docs.json",
|
|
54
54
|
"docgen:api": "docgen --api CapacitorUpdaterPlugin --output-readme api.md --output-json dist/docs.json && awk '{sub(/###/,\"##\")}1' api.md > temp.txt && mv temp.txt api.md",
|
|
@@ -67,12 +67,10 @@
|
|
|
67
67
|
"@ionic/prettier-config": "^4.0.0",
|
|
68
68
|
"@ionic/swiftlint-config": "^2.0.0",
|
|
69
69
|
"@types/node": "^22.10.5",
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
71
|
-
"@typescript-eslint/parser": "^7.18.0",
|
|
72
70
|
"eslint": "^8.57.1",
|
|
73
71
|
"eslint-plugin-import": "^2.31.0",
|
|
74
72
|
"prettier": "^3.4.2",
|
|
75
|
-
"prettier-plugin-java": "^2.6.
|
|
73
|
+
"prettier-plugin-java": "^2.6.6",
|
|
76
74
|
"rimraf": "^6.0.1",
|
|
77
75
|
"rollup": "^4.30.1",
|
|
78
76
|
"swiftlint": "^2.0.0",
|
|
@@ -82,6 +80,7 @@
|
|
|
82
80
|
"@capacitor/core": "^6.0.0"
|
|
83
81
|
},
|
|
84
82
|
"prettier": "@ionic/prettier-config",
|
|
83
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
85
84
|
"eslintConfig": {
|
|
86
85
|
"extends": "@ionic/eslint-config/recommended"
|
|
87
86
|
},
|
|
@@ -92,6 +91,5 @@
|
|
|
92
91
|
"android": {
|
|
93
92
|
"src": "android"
|
|
94
93
|
}
|
|
95
|
-
}
|
|
96
|
-
"packageManager": "pnpm@9.11.0"
|
|
94
|
+
}
|
|
97
95
|
}
|