@capgo/capacitor-updater 6.14.0 → 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 +11 -11
- 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 +960 -1165
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +1259 -1629
- 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 +17 -17
- package/dist/esm/definitions.d.ts +13 -13
- 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 +8 -8
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +1 -1
- package/package.json +5 -7
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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;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;;;;;;;;;;;;;;;"}
|
|
@@ -406,7 +406,7 @@ import UIKit
|
|
|
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
|
|
@@ -425,7 +425,7 @@ import UIKit
|
|
|
425
425
|
|
|
426
426
|
completedFiles += 1
|
|
427
427
|
self.notifyDownload(id: id, percent: self.calcTotalPercent(percent: Int((Double(completedFiles) / Double(totalFiles)) * 100), min: 10, max: 70))
|
|
428
|
-
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")
|
|
429
429
|
} catch {
|
|
430
430
|
downloadError = error
|
|
431
431
|
print("\(CapacitorUpdater.TAG) downloadManifest \(id) \(fileName) error: \(error)")
|
|
@@ -454,7 +454,7 @@ import UIKit
|
|
|
454
454
|
return updatedBundle
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
private func decompressBrotli(data: Data) -> Data? {
|
|
457
|
+
private func decompressBrotli(data: Data, fileName: String) -> Data? {
|
|
458
458
|
let outputBufferSize = 65536
|
|
459
459
|
var outputBuffer = [UInt8](repeating: 0, count: outputBufferSize)
|
|
460
460
|
var decompressedData = Data()
|
|
@@ -462,7 +462,7 @@ import UIKit
|
|
|
462
462
|
let streamPointer = UnsafeMutablePointer<compression_stream>.allocate(capacity: 1)
|
|
463
463
|
var status = compression_stream_init(streamPointer, COMPRESSION_STREAM_DECODE, COMPRESSION_BROTLI)
|
|
464
464
|
guard status != COMPRESSION_STATUS_ERROR else {
|
|
465
|
-
print("\(CapacitorUpdater.TAG) Unable to initialize the decompression stream.")
|
|
465
|
+
print("\(CapacitorUpdater.TAG) Unable to initialize the decompression stream. \(fileName)")
|
|
466
466
|
return nil
|
|
467
467
|
}
|
|
468
468
|
|
|
@@ -484,7 +484,7 @@ import UIKit
|
|
|
484
484
|
if let baseAddress = rawBufferPointer.baseAddress {
|
|
485
485
|
streamPointer.pointee.src_ptr = baseAddress.assumingMemoryBound(to: UInt8.self)
|
|
486
486
|
} else {
|
|
487
|
-
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)")
|
|
488
488
|
status = COMPRESSION_STATUS_ERROR
|
|
489
489
|
return
|
|
490
490
|
}
|
|
@@ -505,7 +505,7 @@ import UIKit
|
|
|
505
505
|
if status == COMPRESSION_STATUS_END {
|
|
506
506
|
break
|
|
507
507
|
} else if status == COMPRESSION_STATUS_ERROR {
|
|
508
|
-
print("\(CapacitorUpdater.TAG) Error during Brotli decompression")
|
|
508
|
+
print("\(CapacitorUpdater.TAG) Error during Brotli decompression. \(fileName)")
|
|
509
509
|
// Try to decode as text if mostly ASCII
|
|
510
510
|
if let text = String(data: data, encoding: .utf8) {
|
|
511
511
|
let asciiCount = text.unicodeScalars.filter { $0.isASCII }.count
|
|
@@ -791,8 +791,8 @@ import UIKit
|
|
|
791
791
|
// Check if this is the next bundle and prevent deletion if it is
|
|
792
792
|
if let next = self.getNextBundle(),
|
|
793
793
|
!next.isDeleted() &&
|
|
794
|
-
|
|
795
|
-
|
|
794
|
+
!next.isErrorStatus() &&
|
|
795
|
+
next.getId() == id {
|
|
796
796
|
print("\(CapacitorUpdater.TAG) Cannot delete the next bundle \(id)")
|
|
797
797
|
return false
|
|
798
798
|
}
|
|
@@ -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.14.
|
|
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"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-updater",
|
|
3
|
-
"version": "6.14.
|
|
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
|
}
|