@otakit/capacitor-updater 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +164 -128
- package/android/src/main/java/com/otakit/updater/BundleStore.java +37 -8
- package/android/src/main/java/com/otakit/updater/DeviceEventClient.java +2 -3
- package/android/src/main/java/com/otakit/updater/ManifestClient.java +20 -7
- package/android/src/main/java/com/otakit/updater/UpdaterCoordinator.java +726 -0
- package/android/src/main/java/com/otakit/updater/UpdaterPlugin.java +551 -493
- package/dist/esm/definitions.d.ts +41 -66
- package/dist/esm/definitions.d.ts.map +1 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -47
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +4 -3
- package/dist/esm/web.d.ts.map +1 -1
- package/dist/esm/web.js +5 -2
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +10 -49
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +10 -49
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/UpdaterPlugin/BundleStore.swift +28 -6
- package/ios/Sources/UpdaterPlugin/ManifestClient.swift +7 -3
- package/ios/Sources/UpdaterPlugin/UpdaterCoordinator.swift +635 -0
- package/ios/Sources/UpdaterPlugin/UpdaterPlugin.m +1 -0
- package/ios/Sources/UpdaterPlugin/UpdaterPlugin.swift +498 -489
- package/package.json +1 -1
|
@@ -5,7 +5,8 @@ final class BundleStore {
|
|
|
5
5
|
static let currentBundleId = "otakit_current_bundle_id"
|
|
6
6
|
static let fallbackBundleId = "otakit_fallback_bundle_id"
|
|
7
7
|
static let stagedBundleId = "otakit_staged_bundle_id"
|
|
8
|
-
static let
|
|
8
|
+
static let lastFailedBundleInfo = "otakit_last_failed_bundle_info"
|
|
9
|
+
static let lastResolvedRuntimeKey = "otakit_last_resolved_runtime_key"
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
private let defaults = UserDefaults.standard
|
|
@@ -142,6 +143,10 @@ final class BundleStore {
|
|
|
142
143
|
return bundle
|
|
143
144
|
}
|
|
144
145
|
|
|
146
|
+
func getCurrentBundleId() -> String? {
|
|
147
|
+
defaults.string(forKey: Keys.currentBundleId)
|
|
148
|
+
}
|
|
149
|
+
|
|
145
150
|
func setCurrentBundleId(_ id: String?) {
|
|
146
151
|
if let id {
|
|
147
152
|
defaults.set(id, forKey: Keys.currentBundleId)
|
|
@@ -160,6 +165,10 @@ final class BundleStore {
|
|
|
160
165
|
return bundle
|
|
161
166
|
}
|
|
162
167
|
|
|
168
|
+
func getFallbackBundleId() -> String? {
|
|
169
|
+
defaults.string(forKey: Keys.fallbackBundleId)
|
|
170
|
+
}
|
|
171
|
+
|
|
163
172
|
func setFallbackBundleId(_ id: String?) {
|
|
164
173
|
if let id {
|
|
165
174
|
defaults.set(id, forKey: Keys.fallbackBundleId)
|
|
@@ -180,23 +189,36 @@ final class BundleStore {
|
|
|
180
189
|
}
|
|
181
190
|
}
|
|
182
191
|
|
|
183
|
-
func
|
|
192
|
+
func setLastFailedBundle(_ bundle: BundleInfo?) {
|
|
184
193
|
if let bundle {
|
|
185
194
|
if let data = try? encoder.encode(bundle) {
|
|
186
|
-
defaults.set(data, forKey: Keys.
|
|
195
|
+
defaults.set(data, forKey: Keys.lastFailedBundleInfo)
|
|
187
196
|
}
|
|
188
197
|
} else {
|
|
189
|
-
defaults.removeObject(forKey: Keys.
|
|
198
|
+
defaults.removeObject(forKey: Keys.lastFailedBundleInfo)
|
|
190
199
|
}
|
|
191
200
|
}
|
|
192
201
|
|
|
193
|
-
func
|
|
194
|
-
guard let data = defaults.data(forKey: Keys.
|
|
202
|
+
func getLastFailedBundle() -> BundleInfo? {
|
|
203
|
+
guard let data = defaults.data(forKey: Keys.lastFailedBundleInfo) else {
|
|
195
204
|
return nil
|
|
196
205
|
}
|
|
197
206
|
return try? decoder.decode(BundleInfo.self, from: data)
|
|
198
207
|
}
|
|
199
208
|
|
|
209
|
+
func getLastResolvedRuntimeKey() -> String? {
|
|
210
|
+
defaults.string(forKey: Keys.lastResolvedRuntimeKey)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
func setLastResolvedRuntimeKey(_ runtimeKey: String?) {
|
|
214
|
+
if let runtimeKey {
|
|
215
|
+
defaults.set(runtimeKey, forKey: Keys.lastResolvedRuntimeKey)
|
|
216
|
+
} else {
|
|
217
|
+
// nil clears the key so the next cold start is treated as unresolved again
|
|
218
|
+
defaults.removeObject(forKey: Keys.lastResolvedRuntimeKey)
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
200
222
|
func markStatus(bundleId: String, status: BundleStatus) {
|
|
201
223
|
guard var bundle = getBundle(id: bundleId) else {
|
|
202
224
|
return
|
|
@@ -59,11 +59,15 @@ enum ManifestClient {
|
|
|
59
59
|
let runtimeKey = runtimeVersion?.trimmingCharacters(in: .whitespacesAndNewlines).nilIfEmpty
|
|
60
60
|
?? defaultRuntimeKey
|
|
61
61
|
|
|
62
|
-
guard let
|
|
63
|
-
string: "\(sanitizedBase)/manifests/\(appId)/\(channelKey)/\(runtimeKey)/manifest.json"
|
|
64
|
-
) else {
|
|
62
|
+
guard let baseURL = URL(string: sanitizedBase) else {
|
|
65
63
|
throw ManifestClientError.invalidURL
|
|
66
64
|
}
|
|
65
|
+
let url = baseURL
|
|
66
|
+
.appendingPathComponent("manifests", isDirectory: true)
|
|
67
|
+
.appendingPathComponent(appId, isDirectory: true)
|
|
68
|
+
.appendingPathComponent(channelKey, isDirectory: true)
|
|
69
|
+
.appendingPathComponent(runtimeKey, isDirectory: true)
|
|
70
|
+
.appendingPathComponent("manifest.json", isDirectory: false)
|
|
67
71
|
|
|
68
72
|
try requireHTTPS(url: url, allowInsecure: allowInsecureUrls)
|
|
69
73
|
|