@capawesome/cordova-live-update 0.1.0
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/LICENSE +21 -0
- package/README.md +1113 -0
- package/dist/docs.json +1654 -0
- package/dist/esm/definitions.d.ts +788 -0
- package/dist/esm/definitions.js +7 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/exec.d.ts +1 -0
- package/dist/esm/exec.js +8 -0
- package/dist/esm/exec.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +46 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/plugin.js +56 -0
- package/dist/plugin.js.map +1 -0
- package/package.json +93 -0
- package/plugin.xml +268 -0
- package/src/android/capawesome-cordova-live-update.gradle +12 -0
- package/src/android/capawesome-live-update.xml +5 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/LiveUpdate.java +1480 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/LiveUpdateConfig.java +105 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/LiveUpdateHttpClient.java +114 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/LiveUpdatePathHandler.java +96 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/LiveUpdatePlugin.java +550 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/LiveUpdatePreferences.java +151 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/Manifest.java +58 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/ManifestItem.java +37 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/api/GetChannelsResponseItem.java +28 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/api/GetLatestBundleResponse.java +74 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/events/DownloadBundleProgressEvent.java +33 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/events/NextBundleSetEvent.java +26 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/options/DeleteBundleOptions.java +18 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/options/DownloadBundleOptions.java +66 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/options/FetchChannelsOptions.java +39 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/options/FetchLatestBundleOptions.java +25 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/options/SetChannelOptions.java +18 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/options/SetConfigOptions.java +20 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/options/SetCustomIdOptions.java +18 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/options/SetNextBundleOptions.java +21 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/options/SyncOptions.java +25 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/ChannelResult.java +29 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/FetchChannelsResult.java +29 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/FetchLatestBundleResult.java +69 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/GetBlockedBundlesResult.java +28 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/GetBundlesResult.java +28 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/GetChannelResult.java +22 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/GetConfigResult.java +40 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/GetCurrentBundleResult.java +22 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/GetCustomIdResult.java +22 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/GetDeviceIdResult.java +22 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/GetDownloadedBundlesResult.java +28 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/GetNextBundleResult.java +22 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/GetVersionCodeResult.java +21 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/GetVersionNameResult.java +22 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/IsSyncingResult.java +27 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/ReadyResult.java +32 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/classes/results/SyncResult.java +22 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/enums/ArtifactType.java +6 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/interfaces/Callback.java +5 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/interfaces/DownloadProgressCallback.java +5 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/interfaces/EmptyCallback.java +5 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/interfaces/NonEmptyCallback.java +7 -0
- package/src/android/io/capawesome/cordova/plugins/liveupdate/interfaces/Result.java +8 -0
- package/src/ios/LiveUpdate.swift +895 -0
- package/src/ios/LiveUpdateArtifactType.swift +4 -0
- package/src/ios/LiveUpdateChannelResult.swift +18 -0
- package/src/ios/LiveUpdateConfig.swift +11 -0
- package/src/ios/LiveUpdateDeleteBundleOptions.swift +13 -0
- package/src/ios/LiveUpdateDownloadBundleOptions.swift +41 -0
- package/src/ios/LiveUpdateDownloadBundleProgressEvent.swift +24 -0
- package/src/ios/LiveUpdateError.swift +62 -0
- package/src/ios/LiveUpdateFetchChannelsOptions.swift +25 -0
- package/src/ios/LiveUpdateFetchChannelsResult.swift +15 -0
- package/src/ios/LiveUpdateFetchLatestBundleOptions.swift +17 -0
- package/src/ios/LiveUpdateFetchLatestBundleResult.swift +42 -0
- package/src/ios/LiveUpdateGetBlockedBundlesResult.swift +15 -0
- package/src/ios/LiveUpdateGetBundlesResult.swift +15 -0
- package/src/ios/LiveUpdateGetChannelResult.swift +15 -0
- package/src/ios/LiveUpdateGetChannelsResponseItem.swift +4 -0
- package/src/ios/LiveUpdateGetConfigResult.swift +18 -0
- package/src/ios/LiveUpdateGetCurrentBundleResult.swift +15 -0
- package/src/ios/LiveUpdateGetCustomIdResult.swift +15 -0
- package/src/ios/LiveUpdateGetDeviceIdResult.swift +15 -0
- package/src/ios/LiveUpdateGetDownloadedBundlesResult.swift +15 -0
- package/src/ios/LiveUpdateGetLatestBundleResponse.swift +8 -0
- package/src/ios/LiveUpdateGetNextBundleResult.swift +15 -0
- package/src/ios/LiveUpdateGetVersionCodeResult.swift +15 -0
- package/src/ios/LiveUpdateGetVersionNameResult.swift +15 -0
- package/src/ios/LiveUpdateHttpClient.swift +58 -0
- package/src/ios/LiveUpdateIsSyncingResult.swift +15 -0
- package/src/ios/LiveUpdateManifest.swift +19 -0
- package/src/ios/LiveUpdateManifestItem.swift +5 -0
- package/src/ios/LiveUpdateNextBundleSetEvent.swift +15 -0
- package/src/ios/LiveUpdatePlugin.swift +521 -0
- package/src/ios/LiveUpdatePreferences.swift +116 -0
- package/src/ios/LiveUpdateReadyResult.swift +21 -0
- package/src/ios/LiveUpdateResult.swift +5 -0
- package/src/ios/LiveUpdateSchemeHandler.swift +286 -0
- package/src/ios/LiveUpdateSetChannelOptions.swift +13 -0
- package/src/ios/LiveUpdateSetConfigOptions.swift +13 -0
- package/src/ios/LiveUpdateSetCustomIdOptions.swift +13 -0
- package/src/ios/LiveUpdateSetNextBundleOptions.swift +13 -0
- package/src/ios/LiveUpdateSyncOptions.swift +17 -0
- package/src/ios/LiveUpdateSyncResult.swift +15 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateChannelResult: NSObject, LiveUpdateResult {
|
|
4
|
+
private let id: String
|
|
5
|
+
private let name: String
|
|
6
|
+
|
|
7
|
+
init(id: String, name: String) {
|
|
8
|
+
self.id = id
|
|
9
|
+
self.name = name
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public func toJSObject() -> [String: Any] {
|
|
13
|
+
var result: [String: Any] = [:]
|
|
14
|
+
result["id"] = id
|
|
15
|
+
result["name"] = name
|
|
16
|
+
return result
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
public struct LiveUpdateConfig {
|
|
2
|
+
var appId: String?
|
|
3
|
+
var autoBlockRolledBackBundles = false
|
|
4
|
+
var autoDeleteBundles = false
|
|
5
|
+
var autoUpdateStrategy = "none"
|
|
6
|
+
var defaultChannel: String?
|
|
7
|
+
var httpTimeout = 60000
|
|
8
|
+
var publicKey: String?
|
|
9
|
+
var readyTimeout = 0
|
|
10
|
+
var serverDomain = "api.cloud.capawesome.io"
|
|
11
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateDownloadBundleOptions: NSObject {
|
|
4
|
+
private var artifactType: LiveUpdateArtifactType
|
|
5
|
+
private var bundleId: String
|
|
6
|
+
private var checksum: String?
|
|
7
|
+
private var signature: String?
|
|
8
|
+
private var url: String
|
|
9
|
+
|
|
10
|
+
init(artifactType: String, bundleId: String, checksum: String?, signature: String?, url: String) {
|
|
11
|
+
if artifactType == "manifest" {
|
|
12
|
+
self.artifactType = .manifest
|
|
13
|
+
} else {
|
|
14
|
+
self.artifactType = .zip
|
|
15
|
+
}
|
|
16
|
+
self.bundleId = bundleId
|
|
17
|
+
self.checksum = checksum
|
|
18
|
+
self.signature = signature
|
|
19
|
+
self.url = url
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
func getArtifactType() -> LiveUpdateArtifactType {
|
|
23
|
+
return artifactType
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
func getBundleId() -> String {
|
|
27
|
+
return bundleId
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
func getChecksum() -> String? {
|
|
31
|
+
return checksum
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
func getSignature() -> String? {
|
|
35
|
+
return signature
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
func getUrl() -> String {
|
|
39
|
+
return url
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateDownloadBundleProgressEvent: NSObject, LiveUpdateResult {
|
|
4
|
+
let bundleId: String
|
|
5
|
+
let downloadedBytes: Int64
|
|
6
|
+
let progress: Double
|
|
7
|
+
let totalBytes: Int64
|
|
8
|
+
|
|
9
|
+
init(bundleId: String, downloadedBytes: Int64, totalBytes: Int64) {
|
|
10
|
+
self.bundleId = bundleId
|
|
11
|
+
self.downloadedBytes = downloadedBytes
|
|
12
|
+
self.progress = Double(downloadedBytes) / Double(totalBytes)
|
|
13
|
+
self.totalBytes = totalBytes
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public func toJSObject() -> [String: Any] {
|
|
17
|
+
var result: [String: Any] = [:]
|
|
18
|
+
result["bundleId"] = bundleId
|
|
19
|
+
result["downloadedBytes"] = Int(truncatingIfNeeded: downloadedBytes)
|
|
20
|
+
result["progress"] = progress
|
|
21
|
+
result["totalBytes"] = Int(truncatingIfNeeded: totalBytes)
|
|
22
|
+
return result
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
public enum LiveUpdateError: Error {
|
|
4
|
+
case appIdMissing
|
|
5
|
+
case bundleAlreadyExists
|
|
6
|
+
case bundleIdMissing
|
|
7
|
+
case bundleIndexHtmlMissing
|
|
8
|
+
case bundleNotFound
|
|
9
|
+
case channelDiscoveryNotEnabled
|
|
10
|
+
case channelMissing
|
|
11
|
+
case checksumCalculationFailed
|
|
12
|
+
case checksumMismatch
|
|
13
|
+
case customIdMissing
|
|
14
|
+
case downloadFailed
|
|
15
|
+
case httpTimeout
|
|
16
|
+
case signatureMissing
|
|
17
|
+
case signatureVerificationFailed
|
|
18
|
+
case syncInProgress
|
|
19
|
+
case unknown
|
|
20
|
+
case urlMissing
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
extension LiveUpdateError: LocalizedError {
|
|
24
|
+
public var errorDescription: String? {
|
|
25
|
+
switch self {
|
|
26
|
+
case .appIdMissing:
|
|
27
|
+
return NSLocalizedString("appId must be configured.", comment: "appIdMissing")
|
|
28
|
+
case .bundleAlreadyExists:
|
|
29
|
+
return NSLocalizedString("bundle already exists.", comment: "bundleAlreadyExists")
|
|
30
|
+
case .bundleIdMissing:
|
|
31
|
+
return NSLocalizedString("bundleId must be provided.", comment: "bundleIdMissing")
|
|
32
|
+
case .bundleIndexHtmlMissing:
|
|
33
|
+
return NSLocalizedString("The bundle does not contain an index.html file.", comment: "bundleIndexHtmlMissing")
|
|
34
|
+
case .bundleNotFound:
|
|
35
|
+
return NSLocalizedString("bundle not found.", comment: "bundleNotFound")
|
|
36
|
+
case .channelDiscoveryNotEnabled:
|
|
37
|
+
return NSLocalizedString("Unauthorized. Channel Discovery may not be enabled for this app.", comment: "channelDiscoveryNotEnabled")
|
|
38
|
+
case .channelMissing:
|
|
39
|
+
return NSLocalizedString("channel must be provided.", comment: "channelMissing")
|
|
40
|
+
case .checksumCalculationFailed:
|
|
41
|
+
return NSLocalizedString("Failed to calculate checksum.", comment: "checksumCalculationFailed")
|
|
42
|
+
case .checksumMismatch:
|
|
43
|
+
return NSLocalizedString("Checksum mismatch.", comment: "checksumMismatch")
|
|
44
|
+
case .customIdMissing:
|
|
45
|
+
return NSLocalizedString("customId must be provided.", comment: "customIdMissing")
|
|
46
|
+
case .downloadFailed:
|
|
47
|
+
return NSLocalizedString("Bundle could not be downloaded.", comment: "downloadFailed")
|
|
48
|
+
case .httpTimeout:
|
|
49
|
+
return NSLocalizedString("Request timed out.", comment: "httpTimeout")
|
|
50
|
+
case .signatureMissing:
|
|
51
|
+
return NSLocalizedString("Bundle does not contain a signature.", comment: "signatureMissing")
|
|
52
|
+
case .signatureVerificationFailed:
|
|
53
|
+
return NSLocalizedString("Signature verification failed.", comment: "signatureVerificationFailed")
|
|
54
|
+
case .syncInProgress:
|
|
55
|
+
return NSLocalizedString("Sync is already in progress.", comment: "syncInProgress")
|
|
56
|
+
case .unknown:
|
|
57
|
+
return NSLocalizedString("An unknown error occurred.", comment: "unknown")
|
|
58
|
+
case .urlMissing:
|
|
59
|
+
return NSLocalizedString("url must be provided.", comment: "urlMissing")
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateFetchChannelsOptions: NSObject {
|
|
4
|
+
private var limit: Int?
|
|
5
|
+
private var offset: Int?
|
|
6
|
+
private var query: String?
|
|
7
|
+
|
|
8
|
+
init(_ options: [String: Any]) {
|
|
9
|
+
self.limit = options["limit"] as? Int
|
|
10
|
+
self.offset = options["offset"] as? Int
|
|
11
|
+
self.query = options["query"] as? String
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
func getLimit() -> Int? {
|
|
15
|
+
return limit
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
func getOffset() -> Int? {
|
|
19
|
+
return offset
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
func getQuery() -> String? {
|
|
23
|
+
return query
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateFetchChannelsResult: NSObject, LiveUpdateResult {
|
|
4
|
+
private let channels: [LiveUpdateChannelResult]
|
|
5
|
+
|
|
6
|
+
init(channels: [LiveUpdateChannelResult]) {
|
|
7
|
+
self.channels = channels
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public func toJSObject() -> [String: Any] {
|
|
11
|
+
var result: [String: Any] = [:]
|
|
12
|
+
result["channels"] = channels.map { $0.toJSObject() }
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateFetchLatestBundleOptions: NSObject {
|
|
4
|
+
private var channel: String?
|
|
5
|
+
|
|
6
|
+
init(_ options: [String: Any]) {
|
|
7
|
+
self.channel = options["channel"] as? String
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
init(channel: String?) {
|
|
11
|
+
self.channel = channel
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
func getChannel() -> String? {
|
|
15
|
+
return channel
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateFetchLatestBundleResult: NSObject, LiveUpdateResult {
|
|
4
|
+
private let artifactType: LiveUpdateArtifactType?
|
|
5
|
+
private let bundleId: String?
|
|
6
|
+
private let checksum: String?
|
|
7
|
+
private let customProperties: [String: Any]?
|
|
8
|
+
private let downloadUrl: String?
|
|
9
|
+
private let signature: String?
|
|
10
|
+
|
|
11
|
+
init(artifactType: LiveUpdateArtifactType?, bundleId: String?, checksum: String?, customProperties: [String: Any]?, downloadUrl: String?, signature: String?) {
|
|
12
|
+
self.artifactType = artifactType
|
|
13
|
+
self.bundleId = bundleId
|
|
14
|
+
self.checksum = checksum
|
|
15
|
+
self.customProperties = customProperties
|
|
16
|
+
self.downloadUrl = downloadUrl
|
|
17
|
+
self.signature = signature
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public func toJSObject() -> [String: Any] {
|
|
21
|
+
var result: [String: Any] = [:]
|
|
22
|
+
if artifactType == .manifest {
|
|
23
|
+
result["artifactType"] = "manifest"
|
|
24
|
+
} else if artifactType == .zip {
|
|
25
|
+
result["artifactType"] = "zip"
|
|
26
|
+
}
|
|
27
|
+
result["bundleId"] = bundleId == nil ? NSNull() : bundleId
|
|
28
|
+
if let checksum = checksum {
|
|
29
|
+
result["checksum"] = checksum
|
|
30
|
+
}
|
|
31
|
+
if let customProperties = customProperties {
|
|
32
|
+
result["customProperties"] = customProperties
|
|
33
|
+
}
|
|
34
|
+
if let downloadUrl = downloadUrl {
|
|
35
|
+
result["downloadUrl"] = downloadUrl
|
|
36
|
+
}
|
|
37
|
+
if let signature = signature {
|
|
38
|
+
result["signature"] = signature
|
|
39
|
+
}
|
|
40
|
+
return result
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateGetBlockedBundlesResult: NSObject, LiveUpdateResult {
|
|
4
|
+
let bundleIds: [String]
|
|
5
|
+
|
|
6
|
+
init(bundleIds: [String]) {
|
|
7
|
+
self.bundleIds = bundleIds
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public func toJSObject() -> [String: Any] {
|
|
11
|
+
var result: [String: Any] = [:]
|
|
12
|
+
result["bundleIds"] = bundleIds
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateGetBundlesResult: NSObject, LiveUpdateResult {
|
|
4
|
+
let bundleIds: [String]
|
|
5
|
+
|
|
6
|
+
init(bundleIds: [String]) {
|
|
7
|
+
self.bundleIds = bundleIds
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public func toJSObject() -> [String: Any] {
|
|
11
|
+
var result: [String: Any] = [:]
|
|
12
|
+
result["bundleIds"] = bundleIds
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateGetChannelResult: NSObject, LiveUpdateResult {
|
|
4
|
+
let channel: String?
|
|
5
|
+
|
|
6
|
+
init(channel: String?) {
|
|
7
|
+
self.channel = channel
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public func toJSObject() -> [String: Any] {
|
|
11
|
+
var result: [String: Any] = [:]
|
|
12
|
+
result["channel"] = channel == nil ? NSNull() : channel
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateGetConfigResult: NSObject, LiveUpdateResult {
|
|
4
|
+
let appId: String?
|
|
5
|
+
let autoUpdateStrategy: String
|
|
6
|
+
|
|
7
|
+
init(appId: String?, autoUpdateStrategy: String) {
|
|
8
|
+
self.appId = appId
|
|
9
|
+
self.autoUpdateStrategy = autoUpdateStrategy
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public func toJSObject() -> [String: Any] {
|
|
13
|
+
var result: [String: Any] = [:]
|
|
14
|
+
result["appId"] = appId == nil ? NSNull() : appId
|
|
15
|
+
result["autoUpdateStrategy"] = autoUpdateStrategy
|
|
16
|
+
return result
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateGetCurrentBundleResult: NSObject, LiveUpdateResult {
|
|
4
|
+
let bundleId: String?
|
|
5
|
+
|
|
6
|
+
init(bundleId: String?) {
|
|
7
|
+
self.bundleId = bundleId
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public func toJSObject() -> [String: Any] {
|
|
11
|
+
var result: [String: Any] = [:]
|
|
12
|
+
result["bundleId"] = bundleId == nil ? NSNull() : bundleId
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateGetCustomIdResult: NSObject, LiveUpdateResult {
|
|
4
|
+
let customId: String?
|
|
5
|
+
|
|
6
|
+
init(customId: String?) {
|
|
7
|
+
self.customId = customId
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public func toJSObject() -> [String: Any] {
|
|
11
|
+
var result: [String: Any] = [:]
|
|
12
|
+
result["customId"] = customId == nil ? NSNull() : customId
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateGetDeviceIdResult: NSObject, LiveUpdateResult {
|
|
4
|
+
let deviceId: String
|
|
5
|
+
|
|
6
|
+
init(deviceId: String) {
|
|
7
|
+
self.deviceId = deviceId
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public func toJSObject() -> [String: Any] {
|
|
11
|
+
var result: [String: Any] = [:]
|
|
12
|
+
result["deviceId"] = deviceId
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateGetDownloadedBundlesResult: NSObject, LiveUpdateResult {
|
|
4
|
+
let bundleIds: [String]
|
|
5
|
+
|
|
6
|
+
init(bundleIds: [String]) {
|
|
7
|
+
self.bundleIds = bundleIds
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public func toJSObject() -> [String: Any] {
|
|
11
|
+
var result: [String: Any] = [:]
|
|
12
|
+
result["bundleIds"] = bundleIds
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateGetNextBundleResult: NSObject, LiveUpdateResult {
|
|
4
|
+
let bundleId: String?
|
|
5
|
+
|
|
6
|
+
init(bundleId: String?) {
|
|
7
|
+
self.bundleId = bundleId
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public func toJSObject() -> [String: Any] {
|
|
11
|
+
var result: [String: Any] = [:]
|
|
12
|
+
result["bundleId"] = bundleId == nil ? NSNull() : bundleId
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateGetVersionCodeResult: NSObject, LiveUpdateResult {
|
|
4
|
+
let versionCode: String
|
|
5
|
+
|
|
6
|
+
init(versionCode: String) {
|
|
7
|
+
self.versionCode = versionCode
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public func toJSObject() -> [String: Any] {
|
|
11
|
+
var result: [String: Any] = [:]
|
|
12
|
+
result["versionCode"] = versionCode
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateGetVersionNameResult: NSObject, LiveUpdateResult {
|
|
4
|
+
let versionName: String
|
|
5
|
+
|
|
6
|
+
init(versionName: String) {
|
|
7
|
+
self.versionName = versionName
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public func toJSObject() -> [String: Any] {
|
|
11
|
+
var result: [String: Any] = [:]
|
|
12
|
+
result["versionName"] = versionName
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Alamofire
|
|
3
|
+
|
|
4
|
+
public class LiveUpdateHttpClient: NSObject {
|
|
5
|
+
|
|
6
|
+
private let config: LiveUpdateConfig
|
|
7
|
+
private var deviceId: String?
|
|
8
|
+
|
|
9
|
+
public static func getChecksumFromResponse(response: HTTPURLResponse) -> String? {
|
|
10
|
+
guard let headers = response.allHeaderFields as? [String: String] else { return nil }
|
|
11
|
+
return headers.first(where: { $0.key.lowercased() == "x-checksum" })?.value
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public static func getSignatureFromResponse(response: HTTPURLResponse) -> String? {
|
|
15
|
+
guard let headers = response.allHeaderFields as? [String: String] else { return nil }
|
|
16
|
+
return headers.first(where: { $0.key.lowercased() == "x-signature" })?.value
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
init(config: LiveUpdateConfig) {
|
|
20
|
+
self.config = config
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public func setDeviceId(_ deviceId: String) {
|
|
24
|
+
self.deviceId = deviceId
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public func download(url: URL, destination: @escaping DownloadRequest.Destination, callback: ((Progress) -> Void)?) async throws -> AFDownloadResponse<Data> {
|
|
28
|
+
var request = URLRequest(url: url)
|
|
29
|
+
request.httpMethod = HTTPMethod.get.rawValue
|
|
30
|
+
request.timeoutInterval = Double(config.httpTimeout) / 1000.0
|
|
31
|
+
if let deviceId = deviceId, !deviceId.isEmpty {
|
|
32
|
+
request.setValue(deviceId, forHTTPHeaderField: "X-Capawesome-Device-Id")
|
|
33
|
+
}
|
|
34
|
+
return try await withCheckedThrowingContinuation { continuation in
|
|
35
|
+
AF.download(request, to: destination).downloadProgress { progress in
|
|
36
|
+
if let callback = callback {
|
|
37
|
+
callback(progress)
|
|
38
|
+
}
|
|
39
|
+
}.responseData(emptyResponseCodes: [200, 204, 205]) { response in
|
|
40
|
+
continuation.resume(returning: response)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public func request<T: Decodable>(url: URL, type: T.Type) async throws -> AFDataResponse<T> {
|
|
46
|
+
var request = URLRequest(url: url)
|
|
47
|
+
request.httpMethod = HTTPMethod.get.rawValue
|
|
48
|
+
request.timeoutInterval = Double(config.httpTimeout) / 1000.0
|
|
49
|
+
if let deviceId = deviceId, !deviceId.isEmpty {
|
|
50
|
+
request.setValue(deviceId, forHTTPHeaderField: "X-Capawesome-Device-Id")
|
|
51
|
+
}
|
|
52
|
+
return try await withCheckedThrowingContinuation { continuation in
|
|
53
|
+
AF.request(request).validate().responseDecodable(of: type) { response in
|
|
54
|
+
continuation.resume(returning: response)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateIsSyncingResult: NSObject, LiveUpdateResult {
|
|
4
|
+
let syncing: Bool
|
|
5
|
+
|
|
6
|
+
init(syncing: Bool) {
|
|
7
|
+
self.syncing = syncing
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@objc public func toJSObject() -> [String: Any] {
|
|
11
|
+
var result: [String: Any] = [:]
|
|
12
|
+
result["syncing"] = syncing
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateManifest: NSObject, Codable {
|
|
4
|
+
let items: [LiveUpdateManifestItem]
|
|
5
|
+
|
|
6
|
+
init(items: [LiveUpdateManifestItem]) {
|
|
7
|
+
self.items = items
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public static func findDuplicateItems(_ manifest1: LiveUpdateManifest, _ manifest2: LiveUpdateManifest) -> [LiveUpdateManifestItem] {
|
|
11
|
+
let checksumSet = Set(manifest2.items.map { $0.checksum })
|
|
12
|
+
return manifest1.items.filter { checksumSet.contains($0.checksum) }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public static func findMissingItems(_ manifest1: LiveUpdateManifest, _ manifest2: LiveUpdateManifest) -> [LiveUpdateManifestItem] {
|
|
16
|
+
let checksumSet = Set(manifest2.items.map { $0.checksum })
|
|
17
|
+
return manifest1.items.filter { !checksumSet.contains($0.checksum) }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
@objc public class LiveUpdateNextBundleSetEvent: NSObject {
|
|
4
|
+
let bundleId: String?
|
|
5
|
+
|
|
6
|
+
init(bundleId: String?) {
|
|
7
|
+
self.bundleId = bundleId
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public func toJSObject() -> [String: Any] {
|
|
11
|
+
var result: [String: Any] = [:]
|
|
12
|
+
result["bundleId"] = bundleId == nil ? NSNull() : bundleId
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
}
|