@blueid/access-capacitor 0.104.0 → 0.105.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.
Files changed (35) hide show
  1. package/BlueidAccessCapacitor.podspec +2 -1
  2. package/dist/esm/BlueCore_pb.d.ts +8 -0
  3. package/dist/esm/BlueCore_pb.js +10 -0
  4. package/dist/esm/BlueCore_pb.js.map +1 -1
  5. package/dist/esm/BlueSDK_pb.d.ts +48 -0
  6. package/dist/esm/BlueSDK_pb.js +12 -0
  7. package/dist/esm/BlueSDK_pb.js.map +1 -1
  8. package/dist/plugin.cjs.js +22 -0
  9. package/dist/plugin.cjs.js.map +1 -1
  10. package/dist/plugin.js +22 -0
  11. package/dist/plugin.js.map +1 -1
  12. package/ios/CBlueIDAccess.xcframework/Info.plist +8 -8
  13. package/ios/CBlueIDAccess.xcframework/ios-arm64/Headers/core/BlueCore.pb.h +2 -0
  14. package/ios/CBlueIDAccess.xcframework/ios-arm64/libCBlueIDAccess.a +0 -0
  15. package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/Headers/core/BlueCore.pb.h +2 -0
  16. package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/libCBlueIDAccess.a +0 -0
  17. package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/Headers/core/BlueCore.pb.h +2 -0
  18. package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/libCBlueIDAccess.a +0 -0
  19. package/ios/Plugin/BlueIDAccessSDK/BlueAPI.swift +7 -0
  20. package/ios/Plugin/BlueIDAccessSDK/BlueAPIProtocol.swift +13 -0
  21. package/ios/Plugin/BlueIDAccessSDK/BlueAccess.swift +12 -24
  22. package/ios/Plugin/BlueIDAccessSDK/BlueCommands.swift +3 -0
  23. package/ios/Plugin/BlueIDAccessSDK/BlueCore.pb.swift +8 -0
  24. package/ios/Plugin/BlueIDAccessSDK/BlueDFU/BlueDFUPeripheralService.swift +73 -0
  25. package/ios/Plugin/BlueIDAccessSDK/BlueDFU/BlueUpdateAccessDeviceFirmwareCommand.swift +226 -0
  26. package/ios/Plugin/BlueIDAccessSDK/BlueDevices.swift +24 -0
  27. package/ios/Plugin/BlueIDAccessSDK/BlueError.swift +1 -1
  28. package/ios/Plugin/BlueIDAccessSDK/BlueFetch.swift +10 -2
  29. package/ios/Plugin/BlueIDAccessSDK/BlueModal/BlueModal.swift +30 -5
  30. package/ios/Plugin/BlueIDAccessSDK/BlueModal/{BlueSynchronizeAccessDeviceModalSession.swift → BlueStepProgressModalSession.swift} +4 -4
  31. package/ios/Plugin/BlueIDAccessSDK/BlueModal/{BlueSynchronizeAccessDeviceModalView.swift → BlueStepProgressModalView.swift} +27 -11
  32. package/ios/Plugin/BlueIDAccessSDK/BlueSDK.pb.swift +216 -0
  33. package/ios/Plugin/BlueIDAccessSDK/BlueTaskRunner.swift +34 -3
  34. package/ios/Plugin/BlueIDAccessSDK/BlueZip.swift +30 -0
  35. package/package.json +1 -1
@@ -15,6 +15,10 @@ struct BlueFetchResponse<T> where T: Decodable {
15
15
 
16
16
  func getData() throws -> T {
17
17
  guard let data = data else {
18
+ if let rawData = rawData as? T {
19
+ return rawData
20
+ }
21
+
18
22
  let status: String = statusCode?.description ?? "Unknown"
19
23
  var description = ""
20
24
 
@@ -40,7 +44,6 @@ struct BlueFetchResponse<T> where T: Decodable {
40
44
  }
41
45
  }
42
46
 
43
- @available(macOS 12.0, *)
44
47
  class BlueFetch {
45
48
 
46
49
  static func post<T>(url: URL, data: Data?, config: BlueFetchConfig? = nil) async throws -> BlueFetchResponse<T> where T: Decodable {
@@ -65,18 +68,23 @@ class BlueFetch {
65
68
 
66
69
  var statusCode: Int?
67
70
  var decodedData: T?
71
+ var contentType: String?
68
72
 
69
73
  do {
70
74
  let (data, response) = try await URLSession.shared.data(for: request)
71
75
 
72
76
  if let httpResponse = response as? HTTPURLResponse {
73
77
  statusCode = httpResponse.statusCode
78
+ contentType = httpResponse.value(forHTTPHeaderField: "content-type")
74
79
 
75
80
  blueLogDebug("Status code: \(httpResponse.statusCode)")
81
+ blueLogDebug("Content-Type: \(String(describing: contentType))")
76
82
  blueLogDebug("Data: \(String(describing: String(data: data, encoding: .utf8)))")
77
83
  }
78
84
 
79
- if (statusCode == 200) {
85
+ let isJSON = contentType == "application/json"
86
+
87
+ if (statusCode == 200 && isJSON) {
80
88
  do {
81
89
  decodedData = try JSONDecoder().decode(T.self, from: data)
82
90
  } catch {
@@ -60,11 +60,36 @@ public func blueShowAccessDeviceModal(_ task: @escaping () async throws -> BlueO
60
60
  /// Displays a modal view (sheet) which performs tasks related to synchronizing a device.
61
61
  /// - parameter runner: The Task Runner.
62
62
  public func blueShowSynchronizeAccessDeviceModal(_ runner: BlueTaskRunner) async throws {
63
- let session = BlueSynchronizeAccessDeviceModalSession()
63
+ try await blueShowStepProgressModal(
64
+ title: blueI18n.syncDeviceInProgressTitle,
65
+ failedTitle: blueI18n.syncDeviceFailedTitle,
66
+ completedTitle: blueI18n.syncDeviceCompletedTitle,
67
+ runner: runner
68
+ )
69
+ }
70
+
71
+ /// Displays a modal view (sheet) which performs tasks related to updating a device firmware.
72
+ /// - parameter runner: The Task Runner.
73
+ public func blueShowUpdateAccessDeviceFirmwareModal(_ runner: BlueTaskRunner) async throws {
74
+ try await blueShowStepProgressModal(
75
+ title: blueI18n.dfuInProgressTitle,
76
+ failedTitle: blueI18n.dfuFailedTitle,
77
+ completedTitle: blueI18n.dfuCompletedTitle,
78
+ runner: runner
79
+ )
80
+ }
81
+
82
+ private func blueShowStepProgressModal(
83
+ title: String,
84
+ failedTitle: String,
85
+ completedTitle: String,
86
+ runner: BlueTaskRunner
87
+ ) async throws {
88
+ let session = BlueStepProgressModalSession()
64
89
 
65
90
  blueRunInMainThread {
66
91
  session.begin(
67
- title: blueI18n.syncDeviceInProgressTitle,
92
+ title: title,
68
93
  tasks: runner.getTasks(),
69
94
  dismiss: blueI18n.cmnCancelLabel
70
95
  ) {
@@ -87,17 +112,17 @@ public func blueShowSynchronizeAccessDeviceModal(_ runner: BlueTaskRunner) async
87
112
  session.updateDismiss(blueI18n.cmnCloseLabel)
88
113
 
89
114
  if runner.isFailed() {
90
- session.updateTitle(blueI18n.syncDeviceFailedTitle)
115
+ session.updateTitle(failedTitle)
91
116
  BlueSound.shared.play(BlueNegativeSoundSystemID)
92
117
  } else {
93
- session.updateTitle(blueI18n.syncDeviceCompletedTitle)
118
+ session.updateTitle(completedTitle)
94
119
  BlueSound.shared.play(BluePositiveSoundSystemID)
95
120
  }
96
121
  }
97
122
  }
98
123
  } catch {
99
124
  blueRunInMainThread {
100
- session.updateTitle(blueI18n.syncDeviceFailedTitle)
125
+ session.updateTitle(failedTitle)
101
126
  session.updateDismiss(blueI18n.cmnCloseLabel)
102
127
  BlueSound.shared.play(BlueNegativeSoundSystemID)
103
128
  }
@@ -2,14 +2,14 @@
2
2
  import AVFoundation
3
3
  import SwiftUI
4
4
 
5
- private class HostingController: UIHostingController<BlueSynchronizeAccessDeviceModalView> {
5
+ private class HostingController: UIHostingController<BlueStepProgressModalView> {
6
6
  override var prefersHomeIndicatorAutoHidden: Bool {
7
7
  return true
8
8
  }
9
9
  }
10
10
 
11
- internal class BlueSynchronizeAccessDeviceModalSession {
12
- private let viewModel = BlueSynchronizeAccessDeviceModalViewModel()
11
+ internal class BlueStepProgressModalSession {
12
+ private let viewModel = BlueStepProgressModalViewModel()
13
13
  private var isInvalidated: Bool = false
14
14
 
15
15
  func begin(title: String, tasks: [BlueTask], dismiss: String, _ onDismiss: @escaping () -> Void) {
@@ -18,7 +18,7 @@ internal class BlueSynchronizeAccessDeviceModalSession {
18
18
  viewModel.dismiss = dismiss
19
19
 
20
20
  let hostingController = HostingController(
21
- rootView: BlueSynchronizeAccessDeviceModalView(viewModel) { onDismiss() }
21
+ rootView: BlueStepProgressModalView(viewModel) { onDismiss() }
22
22
  )
23
23
 
24
24
  hostingController.view.backgroundColor = .clear
@@ -42,24 +42,27 @@ private func getSymbol(_ status: BlueTaskStatus) -> String {
42
42
  class BlueTaskModel: ObservableObject, Identifiable {
43
43
  @Published var label: String
44
44
  @Published var status: BlueTaskStatus
45
+ @Published var progress: Float?
45
46
  @Published var statusColor: Color
46
47
  @Published var textColor: Color
47
48
  @Published var symbol: String
48
49
  @Published var errorDescription: String
49
50
  @Published var isLast: Bool
50
51
 
51
- private var subscriber: AnyCancellable?
52
+ private var statusSubscriber: AnyCancellable?
53
+ private var progressSubscriber: AnyCancellable?
52
54
 
53
55
  init(_ task: BlueTask, _ isLast: Bool) {
54
56
  self.label = task.label
55
57
  self.status = task.status.value
58
+ self.progress = task.progress?.value
56
59
  self.textColor = getTextColor(task.status.value)
57
60
  self.statusColor = getColor(task.status.value)
58
61
  self.symbol = getSymbol(task.status.value)
59
62
  self.errorDescription = task.errorDescription ?? ""
60
63
  self.isLast = isLast
61
64
 
62
- self.subscriber = task.status.sink{ [weak self] status in
65
+ self.statusSubscriber = task.status.sink{ [weak self] status in
63
66
  guard let self = self else { return }
64
67
 
65
68
  self.status = status
@@ -70,6 +73,13 @@ class BlueTaskModel: ObservableObject, Identifiable {
70
73
 
71
74
  self.objectWillChange.send()
72
75
  }
76
+
77
+ self.progressSubscriber = task.progress?.sink{ [weak self] progress in
78
+ guard let self = self else { return }
79
+
80
+ self.progress = progress
81
+ self.objectWillChange.send()
82
+ }
73
83
  }
74
84
  }
75
85
 
@@ -112,6 +122,12 @@ struct TaskView: View {
112
122
  .padding(.bottom, 5)
113
123
  .fixedSize(horizontal: false, vertical: true)
114
124
  .alignmentGuide(.leading) { d in d[.leading] }
125
+ } else {
126
+ if task.status == .started && task.progress != nil {
127
+ ProgressView(value: task.progress, total: 100)
128
+ .padding(.leading, 32)
129
+ .alignmentGuide(.leading) { d in d[.leading] }
130
+ }
115
131
  }
116
132
  }
117
133
  }
@@ -119,7 +135,7 @@ struct TaskView: View {
119
135
  }
120
136
  }
121
137
 
122
- class BlueSynchronizeAccessDeviceModalViewModel: ObservableObject {
138
+ class BlueStepProgressModalViewModel: ObservableObject {
123
139
  @Published var title = ""
124
140
  @Published var dismiss: String = ""
125
141
  @Published var dismissEnabled: Bool = true
@@ -133,8 +149,8 @@ class BlueSynchronizeAccessDeviceModalViewModel: ObservableObject {
133
149
  }
134
150
  }
135
151
 
136
- struct BlueSynchronizeAccessDeviceModalView: View {
137
- @ObservedObject private var vm: BlueSynchronizeAccessDeviceModalViewModel
152
+ struct BlueStepProgressModalView: View {
153
+ @ObservedObject private var vm: BlueStepProgressModalViewModel
138
154
 
139
155
  internal var height: CGFloat = 550
140
156
  internal var backgroundColor: UIColor = .white
@@ -144,7 +160,7 @@ struct BlueSynchronizeAccessDeviceModalView: View {
144
160
  private let cornerRadius: CGFloat = 35
145
161
 
146
162
  public init(
147
- _ vm: BlueSynchronizeAccessDeviceModalViewModel,
163
+ _ vm: BlueStepProgressModalViewModel,
148
164
  _ onDismiss: @escaping () -> Void)
149
165
  {
150
166
  self.vm = vm
@@ -212,12 +228,12 @@ struct BlueSynchronizeAccessDeviceModalView: View {
212
228
  }
213
229
  }
214
230
 
215
- let noop: (BlueSerialTaskRunner) async throws -> BlueTaskResult = { _ in .result(nil) }
231
+ let noop: (BlueTask, BlueSerialTaskRunner) async throws -> BlueTaskResult = { _, _ in .result(nil) }
216
232
 
217
233
  struct BlueSynchronizeAccessDeviceModalView_Preview: PreviewProvider {
218
234
  static var previews: some View {
219
- BlueSynchronizeAccessDeviceModalView(
220
- BlueSynchronizeAccessDeviceModalViewModel(
235
+ BlueStepProgressModalView(
236
+ BlueStepProgressModalViewModel(
221
237
  title: "Synchronization has failed (Worst case)",
222
238
  dismiss: "Done",
223
239
  tasks: Array(1..<12).map { element in
@@ -232,8 +248,8 @@ struct BlueSynchronizeAccessDeviceModalView_Preview: PreviewProvider {
232
248
  )
233
249
  ) {}
234
250
 
235
- BlueSynchronizeAccessDeviceModalView(
236
- BlueSynchronizeAccessDeviceModalViewModel(
251
+ BlueStepProgressModalView(
252
+ BlueStepProgressModalViewModel(
237
253
  title: "Cancelling...",
238
254
  dismiss: "Cancel",
239
255
  dismissEnabled: false,
@@ -405,6 +405,114 @@ public struct BlueI18n {
405
405
  /// Clears the value of `syncDevicePushSystemStatusTaskLabel`. Subsequent reads from it will return its default value.
406
406
  public mutating func clearSyncDevicePushSystemStatusTaskLabel() {_uniqueStorage()._syncDevicePushSystemStatusTaskLabel = nil}
407
407
 
408
+ public var dfuInProgressTitle: String {
409
+ get {return _storage._dfuInProgressTitle ?? "Update in Progress"}
410
+ set {_uniqueStorage()._dfuInProgressTitle = newValue}
411
+ }
412
+ /// Returns true if `dfuInProgressTitle` has been explicitly set.
413
+ public var hasDfuInProgressTitle: Bool {return _storage._dfuInProgressTitle != nil}
414
+ /// Clears the value of `dfuInProgressTitle`. Subsequent reads from it will return its default value.
415
+ public mutating func clearDfuInProgressTitle() {_uniqueStorage()._dfuInProgressTitle = nil}
416
+
417
+ public var dfuFailedTitle: String {
418
+ get {return _storage._dfuFailedTitle ?? "Update has failed"}
419
+ set {_uniqueStorage()._dfuFailedTitle = newValue}
420
+ }
421
+ /// Returns true if `dfuFailedTitle` has been explicitly set.
422
+ public var hasDfuFailedTitle: Bool {return _storage._dfuFailedTitle != nil}
423
+ /// Clears the value of `dfuFailedTitle`. Subsequent reads from it will return its default value.
424
+ public mutating func clearDfuFailedTitle() {_uniqueStorage()._dfuFailedTitle = nil}
425
+
426
+ public var dfuCancellingTitle: String {
427
+ get {return _storage._dfuCancellingTitle ?? "Cancelling..."}
428
+ set {_uniqueStorage()._dfuCancellingTitle = newValue}
429
+ }
430
+ /// Returns true if `dfuCancellingTitle` has been explicitly set.
431
+ public var hasDfuCancellingTitle: Bool {return _storage._dfuCancellingTitle != nil}
432
+ /// Clears the value of `dfuCancellingTitle`. Subsequent reads from it will return its default value.
433
+ public mutating func clearDfuCancellingTitle() {_uniqueStorage()._dfuCancellingTitle = nil}
434
+
435
+ public var dfuCompletedTitle: String {
436
+ get {return _storage._dfuCompletedTitle ?? "Update has been completed"}
437
+ set {_uniqueStorage()._dfuCompletedTitle = newValue}
438
+ }
439
+ /// Returns true if `dfuCompletedTitle` has been explicitly set.
440
+ public var hasDfuCompletedTitle: Bool {return _storage._dfuCompletedTitle != nil}
441
+ /// Clears the value of `dfuCompletedTitle`. Subsequent reads from it will return its default value.
442
+ public mutating func clearDfuCompletedTitle() {_uniqueStorage()._dfuCompletedTitle = nil}
443
+
444
+ public var dfuGetAuthenticationTokenTaskLabel: String {
445
+ get {return _storage._dfuGetAuthenticationTokenTaskLabel ?? "Issue authentication token"}
446
+ set {_uniqueStorage()._dfuGetAuthenticationTokenTaskLabel = newValue}
447
+ }
448
+ /// Returns true if `dfuGetAuthenticationTokenTaskLabel` has been explicitly set.
449
+ public var hasDfuGetAuthenticationTokenTaskLabel: Bool {return _storage._dfuGetAuthenticationTokenTaskLabel != nil}
450
+ /// Clears the value of `dfuGetAuthenticationTokenTaskLabel`. Subsequent reads from it will return its default value.
451
+ public mutating func clearDfuGetAuthenticationTokenTaskLabel() {_uniqueStorage()._dfuGetAuthenticationTokenTaskLabel = nil}
452
+
453
+ public var dfuCheckLatestFwlabel: String {
454
+ get {return _storage._dfuCheckLatestFwlabel ?? "Check latest firmware"}
455
+ set {_uniqueStorage()._dfuCheckLatestFwlabel = newValue}
456
+ }
457
+ /// Returns true if `dfuCheckLatestFwlabel` has been explicitly set.
458
+ public var hasDfuCheckLatestFwlabel: Bool {return _storage._dfuCheckLatestFwlabel != nil}
459
+ /// Clears the value of `dfuCheckLatestFwlabel`. Subsequent reads from it will return its default value.
460
+ public mutating func clearDfuCheckLatestFwlabel() {_uniqueStorage()._dfuCheckLatestFwlabel = nil}
461
+
462
+ public var dfuDownloadLatestFwlabel: String {
463
+ get {return _storage._dfuDownloadLatestFwlabel ?? "Download latest firmware"}
464
+ set {_uniqueStorage()._dfuDownloadLatestFwlabel = newValue}
465
+ }
466
+ /// Returns true if `dfuDownloadLatestFwlabel` has been explicitly set.
467
+ public var hasDfuDownloadLatestFwlabel: Bool {return _storage._dfuDownloadLatestFwlabel != nil}
468
+ /// Clears the value of `dfuDownloadLatestFwlabel`. Subsequent reads from it will return its default value.
469
+ public mutating func clearDfuDownloadLatestFwlabel() {_uniqueStorage()._dfuDownloadLatestFwlabel = nil}
470
+
471
+ public var dfuPrepareUpdateLabel: String {
472
+ get {return _storage._dfuPrepareUpdateLabel ?? "Prepare Update"}
473
+ set {_uniqueStorage()._dfuPrepareUpdateLabel = newValue}
474
+ }
475
+ /// Returns true if `dfuPrepareUpdateLabel` has been explicitly set.
476
+ public var hasDfuPrepareUpdateLabel: Bool {return _storage._dfuPrepareUpdateLabel != nil}
477
+ /// Clears the value of `dfuPrepareUpdateLabel`. Subsequent reads from it will return its default value.
478
+ public mutating func clearDfuPrepareUpdateLabel() {_uniqueStorage()._dfuPrepareUpdateLabel = nil}
479
+
480
+ public var dfuStartBootloaderLabel: String {
481
+ get {return _storage._dfuStartBootloaderLabel ?? "Start Bootloader"}
482
+ set {_uniqueStorage()._dfuStartBootloaderLabel = newValue}
483
+ }
484
+ /// Returns true if `dfuStartBootloaderLabel` has been explicitly set.
485
+ public var hasDfuStartBootloaderLabel: Bool {return _storage._dfuStartBootloaderLabel != nil}
486
+ /// Clears the value of `dfuStartBootloaderLabel`. Subsequent reads from it will return its default value.
487
+ public mutating func clearDfuStartBootloaderLabel() {_uniqueStorage()._dfuStartBootloaderLabel = nil}
488
+
489
+ public var dfuFindDfuperipheralLabel: String {
490
+ get {return _storage._dfuFindDfuperipheralLabel ?? "Find DFU peripheral"}
491
+ set {_uniqueStorage()._dfuFindDfuperipheralLabel = newValue}
492
+ }
493
+ /// Returns true if `dfuFindDfuperipheralLabel` has been explicitly set.
494
+ public var hasDfuFindDfuperipheralLabel: Bool {return _storage._dfuFindDfuperipheralLabel != nil}
495
+ /// Clears the value of `dfuFindDfuperipheralLabel`. Subsequent reads from it will return its default value.
496
+ public mutating func clearDfuFindDfuperipheralLabel() {_uniqueStorage()._dfuFindDfuperipheralLabel = nil}
497
+
498
+ public var dfuUpdateFwlabel: String {
499
+ get {return _storage._dfuUpdateFwlabel ?? "Update firmware"}
500
+ set {_uniqueStorage()._dfuUpdateFwlabel = newValue}
501
+ }
502
+ /// Returns true if `dfuUpdateFwlabel` has been explicitly set.
503
+ public var hasDfuUpdateFwlabel: Bool {return _storage._dfuUpdateFwlabel != nil}
504
+ /// Clears the value of `dfuUpdateFwlabel`. Subsequent reads from it will return its default value.
505
+ public mutating func clearDfuUpdateFwlabel() {_uniqueStorage()._dfuUpdateFwlabel = nil}
506
+
507
+ public var dfuWaitForDeviceToRestartTaskLabel: String {
508
+ get {return _storage._dfuWaitForDeviceToRestartTaskLabel ?? "Wait for device to restart"}
509
+ set {_uniqueStorage()._dfuWaitForDeviceToRestartTaskLabel = newValue}
510
+ }
511
+ /// Returns true if `dfuWaitForDeviceToRestartTaskLabel` has been explicitly set.
512
+ public var hasDfuWaitForDeviceToRestartTaskLabel: Bool {return _storage._dfuWaitForDeviceToRestartTaskLabel != nil}
513
+ /// Clears the value of `dfuWaitForDeviceToRestartTaskLabel`. Subsequent reads from it will return its default value.
514
+ public mutating func clearDfuWaitForDeviceToRestartTaskLabel() {_uniqueStorage()._dfuWaitForDeviceToRestartTaskLabel = nil}
515
+
408
516
  public var unknownFields = SwiftProtobuf.UnknownStorage()
409
517
 
410
518
  public init() {}
@@ -1023,6 +1131,18 @@ extension BlueI18n: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB
1023
1131
  32: .same(proto: "syncDeviceDeployBlacklistEntriesTaskLabel"),
1024
1132
  33: .same(proto: "syncDeviceRetrieveSystemStatusTaskLabel"),
1025
1133
  34: .same(proto: "syncDevicePushSystemStatusTaskLabel"),
1134
+ 35: .same(proto: "dfuInProgressTitle"),
1135
+ 36: .same(proto: "dfuFailedTitle"),
1136
+ 37: .same(proto: "dfuCancellingTitle"),
1137
+ 38: .same(proto: "dfuCompletedTitle"),
1138
+ 39: .same(proto: "dfuGetAuthenticationTokenTaskLabel"),
1139
+ 40: .same(proto: "dfuCheckLatestFWLabel"),
1140
+ 41: .same(proto: "dfuDownloadLatestFWLabel"),
1141
+ 42: .same(proto: "dfuPrepareUpdateLabel"),
1142
+ 43: .same(proto: "dfuStartBootloaderLabel"),
1143
+ 44: .same(proto: "dfuFindDFUPeripheralLabel"),
1144
+ 45: .same(proto: "dfuUpdateFWLabel"),
1145
+ 46: .same(proto: "dfuWaitForDeviceToRestartTaskLabel"),
1026
1146
  ]
1027
1147
 
1028
1148
  fileprivate class _StorageClass {
@@ -1060,6 +1180,18 @@ extension BlueI18n: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB
1060
1180
  var _syncDeviceDeployBlacklistEntriesTaskLabel: String? = nil
1061
1181
  var _syncDeviceRetrieveSystemStatusTaskLabel: String? = nil
1062
1182
  var _syncDevicePushSystemStatusTaskLabel: String? = nil
1183
+ var _dfuInProgressTitle: String? = nil
1184
+ var _dfuFailedTitle: String? = nil
1185
+ var _dfuCancellingTitle: String? = nil
1186
+ var _dfuCompletedTitle: String? = nil
1187
+ var _dfuGetAuthenticationTokenTaskLabel: String? = nil
1188
+ var _dfuCheckLatestFwlabel: String? = nil
1189
+ var _dfuDownloadLatestFwlabel: String? = nil
1190
+ var _dfuPrepareUpdateLabel: String? = nil
1191
+ var _dfuStartBootloaderLabel: String? = nil
1192
+ var _dfuFindDfuperipheralLabel: String? = nil
1193
+ var _dfuUpdateFwlabel: String? = nil
1194
+ var _dfuWaitForDeviceToRestartTaskLabel: String? = nil
1063
1195
 
1064
1196
  static let defaultInstance = _StorageClass()
1065
1197
 
@@ -1100,6 +1232,18 @@ extension BlueI18n: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB
1100
1232
  _syncDeviceDeployBlacklistEntriesTaskLabel = source._syncDeviceDeployBlacklistEntriesTaskLabel
1101
1233
  _syncDeviceRetrieveSystemStatusTaskLabel = source._syncDeviceRetrieveSystemStatusTaskLabel
1102
1234
  _syncDevicePushSystemStatusTaskLabel = source._syncDevicePushSystemStatusTaskLabel
1235
+ _dfuInProgressTitle = source._dfuInProgressTitle
1236
+ _dfuFailedTitle = source._dfuFailedTitle
1237
+ _dfuCancellingTitle = source._dfuCancellingTitle
1238
+ _dfuCompletedTitle = source._dfuCompletedTitle
1239
+ _dfuGetAuthenticationTokenTaskLabel = source._dfuGetAuthenticationTokenTaskLabel
1240
+ _dfuCheckLatestFwlabel = source._dfuCheckLatestFwlabel
1241
+ _dfuDownloadLatestFwlabel = source._dfuDownloadLatestFwlabel
1242
+ _dfuPrepareUpdateLabel = source._dfuPrepareUpdateLabel
1243
+ _dfuStartBootloaderLabel = source._dfuStartBootloaderLabel
1244
+ _dfuFindDfuperipheralLabel = source._dfuFindDfuperipheralLabel
1245
+ _dfuUpdateFwlabel = source._dfuUpdateFwlabel
1246
+ _dfuWaitForDeviceToRestartTaskLabel = source._dfuWaitForDeviceToRestartTaskLabel
1103
1247
  }
1104
1248
  }
1105
1249
 
@@ -1146,6 +1290,18 @@ extension BlueI18n: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB
1146
1290
  if _storage._syncDeviceDeployBlacklistEntriesTaskLabel == nil {return false}
1147
1291
  if _storage._syncDeviceRetrieveSystemStatusTaskLabel == nil {return false}
1148
1292
  if _storage._syncDevicePushSystemStatusTaskLabel == nil {return false}
1293
+ if _storage._dfuInProgressTitle == nil {return false}
1294
+ if _storage._dfuFailedTitle == nil {return false}
1295
+ if _storage._dfuCancellingTitle == nil {return false}
1296
+ if _storage._dfuCompletedTitle == nil {return false}
1297
+ if _storage._dfuGetAuthenticationTokenTaskLabel == nil {return false}
1298
+ if _storage._dfuCheckLatestFwlabel == nil {return false}
1299
+ if _storage._dfuDownloadLatestFwlabel == nil {return false}
1300
+ if _storage._dfuPrepareUpdateLabel == nil {return false}
1301
+ if _storage._dfuStartBootloaderLabel == nil {return false}
1302
+ if _storage._dfuFindDfuperipheralLabel == nil {return false}
1303
+ if _storage._dfuUpdateFwlabel == nil {return false}
1304
+ if _storage._dfuWaitForDeviceToRestartTaskLabel == nil {return false}
1149
1305
  return true
1150
1306
  }
1151
1307
  }
@@ -1192,6 +1348,18 @@ extension BlueI18n: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB
1192
1348
  case 32: try { try decoder.decodeSingularStringField(value: &_storage._syncDeviceDeployBlacklistEntriesTaskLabel) }()
1193
1349
  case 33: try { try decoder.decodeSingularStringField(value: &_storage._syncDeviceRetrieveSystemStatusTaskLabel) }()
1194
1350
  case 34: try { try decoder.decodeSingularStringField(value: &_storage._syncDevicePushSystemStatusTaskLabel) }()
1351
+ case 35: try { try decoder.decodeSingularStringField(value: &_storage._dfuInProgressTitle) }()
1352
+ case 36: try { try decoder.decodeSingularStringField(value: &_storage._dfuFailedTitle) }()
1353
+ case 37: try { try decoder.decodeSingularStringField(value: &_storage._dfuCancellingTitle) }()
1354
+ case 38: try { try decoder.decodeSingularStringField(value: &_storage._dfuCompletedTitle) }()
1355
+ case 39: try { try decoder.decodeSingularStringField(value: &_storage._dfuGetAuthenticationTokenTaskLabel) }()
1356
+ case 40: try { try decoder.decodeSingularStringField(value: &_storage._dfuCheckLatestFwlabel) }()
1357
+ case 41: try { try decoder.decodeSingularStringField(value: &_storage._dfuDownloadLatestFwlabel) }()
1358
+ case 42: try { try decoder.decodeSingularStringField(value: &_storage._dfuPrepareUpdateLabel) }()
1359
+ case 43: try { try decoder.decodeSingularStringField(value: &_storage._dfuStartBootloaderLabel) }()
1360
+ case 44: try { try decoder.decodeSingularStringField(value: &_storage._dfuFindDfuperipheralLabel) }()
1361
+ case 45: try { try decoder.decodeSingularStringField(value: &_storage._dfuUpdateFwlabel) }()
1362
+ case 46: try { try decoder.decodeSingularStringField(value: &_storage._dfuWaitForDeviceToRestartTaskLabel) }()
1195
1363
  default: break
1196
1364
  }
1197
1365
  }
@@ -1306,6 +1474,42 @@ extension BlueI18n: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB
1306
1474
  try { if let v = _storage._syncDevicePushSystemStatusTaskLabel {
1307
1475
  try visitor.visitSingularStringField(value: v, fieldNumber: 34)
1308
1476
  } }()
1477
+ try { if let v = _storage._dfuInProgressTitle {
1478
+ try visitor.visitSingularStringField(value: v, fieldNumber: 35)
1479
+ } }()
1480
+ try { if let v = _storage._dfuFailedTitle {
1481
+ try visitor.visitSingularStringField(value: v, fieldNumber: 36)
1482
+ } }()
1483
+ try { if let v = _storage._dfuCancellingTitle {
1484
+ try visitor.visitSingularStringField(value: v, fieldNumber: 37)
1485
+ } }()
1486
+ try { if let v = _storage._dfuCompletedTitle {
1487
+ try visitor.visitSingularStringField(value: v, fieldNumber: 38)
1488
+ } }()
1489
+ try { if let v = _storage._dfuGetAuthenticationTokenTaskLabel {
1490
+ try visitor.visitSingularStringField(value: v, fieldNumber: 39)
1491
+ } }()
1492
+ try { if let v = _storage._dfuCheckLatestFwlabel {
1493
+ try visitor.visitSingularStringField(value: v, fieldNumber: 40)
1494
+ } }()
1495
+ try { if let v = _storage._dfuDownloadLatestFwlabel {
1496
+ try visitor.visitSingularStringField(value: v, fieldNumber: 41)
1497
+ } }()
1498
+ try { if let v = _storage._dfuPrepareUpdateLabel {
1499
+ try visitor.visitSingularStringField(value: v, fieldNumber: 42)
1500
+ } }()
1501
+ try { if let v = _storage._dfuStartBootloaderLabel {
1502
+ try visitor.visitSingularStringField(value: v, fieldNumber: 43)
1503
+ } }()
1504
+ try { if let v = _storage._dfuFindDfuperipheralLabel {
1505
+ try visitor.visitSingularStringField(value: v, fieldNumber: 44)
1506
+ } }()
1507
+ try { if let v = _storage._dfuUpdateFwlabel {
1508
+ try visitor.visitSingularStringField(value: v, fieldNumber: 45)
1509
+ } }()
1510
+ try { if let v = _storage._dfuWaitForDeviceToRestartTaskLabel {
1511
+ try visitor.visitSingularStringField(value: v, fieldNumber: 46)
1512
+ } }()
1309
1513
  }
1310
1514
  try unknownFields.traverse(visitor: &visitor)
1311
1515
  }
@@ -1349,6 +1553,18 @@ extension BlueI18n: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB
1349
1553
  if _storage._syncDeviceDeployBlacklistEntriesTaskLabel != rhs_storage._syncDeviceDeployBlacklistEntriesTaskLabel {return false}
1350
1554
  if _storage._syncDeviceRetrieveSystemStatusTaskLabel != rhs_storage._syncDeviceRetrieveSystemStatusTaskLabel {return false}
1351
1555
  if _storage._syncDevicePushSystemStatusTaskLabel != rhs_storage._syncDevicePushSystemStatusTaskLabel {return false}
1556
+ if _storage._dfuInProgressTitle != rhs_storage._dfuInProgressTitle {return false}
1557
+ if _storage._dfuFailedTitle != rhs_storage._dfuFailedTitle {return false}
1558
+ if _storage._dfuCancellingTitle != rhs_storage._dfuCancellingTitle {return false}
1559
+ if _storage._dfuCompletedTitle != rhs_storage._dfuCompletedTitle {return false}
1560
+ if _storage._dfuGetAuthenticationTokenTaskLabel != rhs_storage._dfuGetAuthenticationTokenTaskLabel {return false}
1561
+ if _storage._dfuCheckLatestFwlabel != rhs_storage._dfuCheckLatestFwlabel {return false}
1562
+ if _storage._dfuDownloadLatestFwlabel != rhs_storage._dfuDownloadLatestFwlabel {return false}
1563
+ if _storage._dfuPrepareUpdateLabel != rhs_storage._dfuPrepareUpdateLabel {return false}
1564
+ if _storage._dfuStartBootloaderLabel != rhs_storage._dfuStartBootloaderLabel {return false}
1565
+ if _storage._dfuFindDfuperipheralLabel != rhs_storage._dfuFindDfuperipheralLabel {return false}
1566
+ if _storage._dfuUpdateFwlabel != rhs_storage._dfuUpdateFwlabel {return false}
1567
+ if _storage._dfuWaitForDeviceToRestartTaskLabel != rhs_storage._dfuWaitForDeviceToRestartTaskLabel {return false}
1352
1568
  return true
1353
1569
  }
1354
1570
  if !storagesAreEqual {return false}
@@ -32,16 +32,32 @@ public class BlueTask {
32
32
  var result: Any? = nil
33
33
  var error: Error? = nil
34
34
  var status: CurrentValueSubject<BlueTaskStatus, Never>
35
+ var progress: CurrentValueSubject<Float, Never>?
35
36
 
36
- let handler: (BlueSerialTaskRunner) async throws -> BlueTaskResult
37
+ let handler: (BlueTask, BlueSerialTaskRunner) async throws -> BlueTaskResult
38
+ let cancelHandler: (() -> Void)?
37
39
 
38
- init(id: AnyHashable, label: String, failable: Bool = false, status: BlueTaskStatus = .ready, error: Error? = nil, handler: @escaping (BlueSerialTaskRunner) async throws -> BlueTaskResult) {
40
+ init(
41
+ id: AnyHashable,
42
+ label: String,
43
+ failable: Bool = false,
44
+ status: BlueTaskStatus = .ready,
45
+ error: Error? = nil,
46
+ progress: Float? = nil,
47
+ cancelHandler: (() -> Void)? = nil,
48
+ handler: @escaping (BlueTask, BlueSerialTaskRunner) async throws -> BlueTaskResult
49
+ ) {
39
50
  self.id = id
40
51
  self.label = label
41
52
  self.failable = failable
42
53
  self.error = error
43
54
  self.status = .init(status)
44
55
  self.handler = handler
56
+ self.cancelHandler = cancelHandler
57
+
58
+ if let progress = progress {
59
+ self.progress = CurrentValueSubject(progress)
60
+ }
45
61
  }
46
62
 
47
63
  var errorDescription: String? {
@@ -53,6 +69,16 @@ public class BlueTask {
53
69
  self.status.send(status)
54
70
  }
55
71
  }
72
+
73
+ func updateProgress(_ progress: Float) {
74
+ blueRunInMainThread {
75
+ self.progress?.send(progress)
76
+ }
77
+ }
78
+
79
+ func cancel() {
80
+ self.cancelHandler?()
81
+ }
56
82
  }
57
83
 
58
84
  public class BlueSerialTaskRunner: BlueTaskRunner {
@@ -61,6 +87,7 @@ public class BlueSerialTaskRunner: BlueTaskRunner {
61
87
  private var failed: Bool = false
62
88
  private var cancelled: Bool = false
63
89
  private var sucessful: Bool = false
90
+ private var currentTask: BlueTask? = nil
64
91
 
65
92
  init(_ tasks: [BlueTask]) {
66
93
  self.tasks = tasks
@@ -77,12 +104,14 @@ public class BlueSerialTaskRunner: BlueTaskRunner {
77
104
  return
78
105
  }
79
106
 
107
+ self.currentTask = task
108
+
80
109
  do {
81
110
  blueLogDebug("Started: \(task.id)")
82
111
 
83
112
  task.updateStatus(.started)
84
113
 
85
- let taskResult = try await task.handler(self)
114
+ let taskResult = try await task.handler(task, self)
86
115
 
87
116
  let taskStatus: BlueTaskStatus
88
117
 
@@ -131,6 +160,8 @@ public class BlueSerialTaskRunner: BlueTaskRunner {
131
160
 
132
161
  public func cancel() -> Bool {
133
162
  if (!sucessful && !failed) {
163
+ self.currentTask?.cancel()
164
+
134
165
  cancelled = true
135
166
 
136
167
  return true
@@ -0,0 +1,30 @@
1
+ import Foundation
2
+
3
+ /**
4
+ * @class BlueZip
5
+ * A utility class for working with zip files.
6
+ */
7
+ public class BlueZip {
8
+ /// Extracts contents of a zip file from the provided Data object.
9
+ ///
10
+ /// - parameter data: The Data object representing the zip file.
11
+ /// - returns: URL pointing to the location where the contents of the zip file are extracted.
12
+ /// - throws: An error if the extraction process encounters any issues.
13
+ static func extract(data: Data) throws -> URL {
14
+ let tempDirectoryURL = URL(fileURLWithPath: NSTemporaryDirectory())
15
+ let sourceURL = tempDirectoryURL.appendingPathComponent("package.zip")
16
+ let destinationURL = tempDirectoryURL.appendingPathComponent("extracted_package")
17
+
18
+ let fileManager = FileManager.default
19
+
20
+ if fileManager.fileExists(atPath: destinationURL.path) {
21
+ try fileManager.removeItem(at: destinationURL)
22
+ }
23
+
24
+ try data.write(to: sourceURL)
25
+
26
+ try fileManager.unzipItem(at: sourceURL, to: destinationURL)
27
+
28
+ return destinationURL
29
+ }
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueid/access-capacitor",
3
- "version": "0.104.0",
3
+ "version": "0.105.0",
4
4
  "description": "Capacitor JS plugin for the BlueID Access SDK",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",