@capgo/capacitor-updater 8.45.9 → 8.45.11

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.
@@ -134,6 +134,35 @@ struct InfoObject: Codable {
134
134
  var defaultChannel: String?
135
135
  var key_id: String?
136
136
  }
137
+
138
+ extension InfoObject {
139
+ func toParameters() -> [String: Any] {
140
+ var parameters: [String: Any] = [:]
141
+ func set(_ key: String, _ value: Any?) {
142
+ guard let value = value else {
143
+ return
144
+ }
145
+ parameters[key] = value
146
+ }
147
+ set("platform", platform)
148
+ set("device_id", device_id)
149
+ set("app_id", app_id)
150
+ set("custom_id", custom_id)
151
+ set("version_build", version_build)
152
+ set("version_code", version_code)
153
+ set("version_os", version_os)
154
+ set("version_name", version_name)
155
+ set("old_version_name", old_version_name)
156
+ set("plugin_version", plugin_version)
157
+ set("is_emulator", is_emulator)
158
+ set("is_prod", is_prod)
159
+ set("action", action)
160
+ set("channel", channel)
161
+ set("defaultChannel", defaultChannel)
162
+ set("key_id", key_id)
163
+ return parameters
164
+ }
165
+ }
137
166
  // swiftlint:enable identifier_name
138
167
 
139
168
  // swiftlint:disable identifier_name
@@ -186,6 +215,7 @@ struct AppVersionDec: Decodable {
186
215
  let url: String?
187
216
  let message: String?
188
217
  let error: String?
218
+ let kind: String?
189
219
  let session_key: String?
190
220
  let major: Bool?
191
221
  let breaking: Bool?
@@ -203,6 +233,7 @@ public class AppVersion: NSObject {
203
233
  var url: String = ""
204
234
  var message: String?
205
235
  var error: String?
236
+ var kind: String?
206
237
  var sessionKey: String?
207
238
  var major: Bool?
208
239
  var breaking: Bool?
@@ -308,19 +308,36 @@ extension UIWindow {
308
308
  }
309
309
 
310
310
  let latest = updater.getLatest(url: updateUrl, channel: name)
311
+ let latestKind = latest.kind
312
+
313
+ let detail = [latest.message, latest.error, latestKind]
314
+ .compactMap { value in
315
+ guard let value, !value.isEmpty else { return nil }
316
+ return value
317
+ }
318
+ .first ?? "server did not provide a message"
311
319
 
312
320
  // Handle update errors first (before "no new version" check)
313
- if let error = latest.error, !error.isEmpty && error != "no_new_version_available" {
321
+ if latestKind == "failed" || (latest.error?.isEmpty == false && latestKind != "up_to_date" && latestKind != "blocked") {
322
+ DispatchQueue.main.async {
323
+ progressAlert.dismiss(animated: true) {
324
+ self.showError(message: "Channel set to \(name). Update check failed: \(detail)", plugin: plugin)
325
+ }
326
+ }
327
+ return
328
+ }
329
+
330
+ if latestKind == "blocked" {
314
331
  DispatchQueue.main.async {
315
332
  progressAlert.dismiss(animated: true) {
316
- self.showError(message: "Channel set to \(name). Update check failed: \(error)", plugin: plugin)
333
+ self.showError(message: "Channel set to \(name). Update check blocked: \(detail)", plugin: plugin)
317
334
  }
318
335
  }
319
336
  return
320
337
  }
321
338
 
322
339
  // Check if there's an actual update available
323
- if latest.error == "no_new_version_available" || latest.url.isEmpty {
340
+ if latestKind == "up_to_date" || latest.url.isEmpty {
324
341
  DispatchQueue.main.async {
325
342
  progressAlert.dismiss(animated: true) {
326
343
  self.showSuccess(message: "Channel set to \(name). Already on latest version.", plugin: plugin)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "8.45.9",
3
+ "version": "8.45.11",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",
@@ -50,7 +50,8 @@
50
50
  "test:android": "cd android && ./gradlew test && cd ..",
51
51
  "test:maestro": "./scripts/maestro/run-android-live-update.sh",
52
52
  "test:maestro:android": "./scripts/test-maestro-android.sh",
53
- "test:maestro:ios": "./scripts/test-maestro-ios.sh",
53
+ "test:maestro:ios": "./scripts/maestro/run-ios-live-update.sh",
54
+ "test:maestro:ios:smoke": "./scripts/test-maestro-ios.sh",
54
55
  "lint": "bun run eslint && bun run prettier -- --check && bun run swiftlint -- lint",
55
56
  "fmt": "bun run eslint -- --fix && bun run prettier -- --write && bun run swiftlint -- --fix --format",
56
57
  "eslint": "eslint . --ext .ts",