@blueid/access-capacitor 0.93.0 → 0.97.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 (28) hide show
  1. package/dist/esm/BlueCore_pb.d.ts +20 -0
  2. package/dist/esm/BlueCore_pb.js +25 -0
  3. package/dist/esm/BlueCore_pb.js.map +1 -1
  4. package/dist/esm/BlueSDK_pb.d.ts +76 -12
  5. package/dist/esm/BlueSDK_pb.js +25 -9
  6. package/dist/esm/BlueSDK_pb.js.map +1 -1
  7. package/dist/plugin.cjs.js +50 -9
  8. package/dist/plugin.cjs.js.map +1 -1
  9. package/dist/plugin.js +50 -9
  10. package/dist/plugin.js.map +1 -1
  11. package/ios/CBlueIDAccess.xcframework/Info.plist +8 -8
  12. package/ios/CBlueIDAccess.xcframework/ios-arm64/Headers/core/BlueCore.pb.h +5 -0
  13. package/ios/CBlueIDAccess.xcframework/ios-arm64/libCBlueIDAccess.a +0 -0
  14. package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/Headers/core/BlueCore.pb.h +5 -0
  15. package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/libCBlueIDAccess.a +0 -0
  16. package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/Headers/core/BlueCore.pb.h +5 -0
  17. package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/libCBlueIDAccess.a +0 -0
  18. package/ios/Plugin/BlueIDAccessSDK/BlueAccess.swift +209 -58
  19. package/ios/Plugin/BlueIDAccessSDK/BlueCore.pb.swift +20 -0
  20. package/ios/Plugin/BlueIDAccessSDK/BlueModal/{BlueModalSession.swift → BlueAccessDeviceModalSession.swift} +5 -5
  21. package/ios/Plugin/BlueIDAccessSDK/BlueModal/{BlueModalView.swift → BlueAccessDeviceModalView.swift} +11 -22
  22. package/ios/Plugin/BlueIDAccessSDK/BlueModal/BlueModal+Extensions.swift +14 -0
  23. package/ios/Plugin/BlueIDAccessSDK/BlueModal/BlueModal.swift +51 -2
  24. package/ios/Plugin/BlueIDAccessSDK/BlueModal/BlueSynchronizeAccessDeviceModalSession.swift +56 -0
  25. package/ios/Plugin/BlueIDAccessSDK/BlueModal/BlueSynchronizeAccessDeviceModalView.swift +237 -0
  26. package/ios/Plugin/BlueIDAccessSDK/BlueSDK.pb.swift +328 -40
  27. package/ios/Plugin/BlueIDAccessSDK/BlueTaskRunner.swift +155 -0
  28. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
1
  #if os(iOS) || os(watchOS)
2
2
  import Foundation
3
3
 
4
- /// Displays a modal view (sheet) which performs a scoped task related to accessing an device via OSS.
4
+ /// Displays a modal view (sheet) which performs a scoped task related to accessing a device via OSS.
5
5
  /// - parameter task: The OSS task to be performed.
6
6
  public func blueShowAccessDeviceModal(_ task: @escaping () async throws -> BlueOssAccessResult) async throws -> BlueOssAccessResult {
7
- let session = BlueModalSession()
7
+ let session = BlueAccessDeviceModalSession()
8
8
 
9
9
  blueRunInMainThread {
10
10
  session.begin(title: blueI18n.openViaOssTitle, message: blueI18n.openViaOssWaitMessage)
@@ -56,4 +56,53 @@ public func blueShowAccessDeviceModal(_ task: @escaping () async throws -> BlueO
56
56
  throw error
57
57
  }
58
58
  }
59
+
60
+ /// Displays a modal view (sheet) which performs tasks related to synchronizing a device.
61
+ /// - parameter runner: The Task Runner.
62
+ public func blueShowSynchronizeAccessDeviceModal(_ runner: BlueTaskRunner) async throws {
63
+ let session = BlueSynchronizeAccessDeviceModalSession()
64
+
65
+ blueRunInMainThread {
66
+ session.begin(
67
+ title: blueI18n.syncDeviceInProgressTitle,
68
+ tasks: runner.getTasks(),
69
+ dismiss: blueI18n.cmnCancelLabel
70
+ ) {
71
+ if runner.cancel() {
72
+ session.disableDismiss()
73
+ session.updateTitle(blueI18n.syncDeviceCancellingTitle)
74
+ } else {
75
+ session.invalidate()
76
+ }
77
+ }
78
+ }
79
+
80
+ do {
81
+ try await runner.execute(false)
82
+
83
+ blueRunInMainThread {
84
+ if runner.isCancelled() {
85
+ session.invalidate()
86
+ } else {
87
+ session.updateDismiss(blueI18n.cmnCloseLabel)
88
+
89
+ if runner.isFailed() {
90
+ session.updateTitle(blueI18n.syncDeviceFailedTitle)
91
+ BlueSound.shared.play(BlueNegativeSoundSystemID)
92
+ } else {
93
+ session.updateTitle(blueI18n.syncDeviceCompletedTitle)
94
+ BlueSound.shared.play(BluePositiveSoundSystemID)
95
+ }
96
+ }
97
+ }
98
+ } catch {
99
+ blueRunInMainThread {
100
+ session.updateTitle(blueI18n.syncDeviceFailedTitle)
101
+ session.updateDismiss(blueI18n.cmnCloseLabel)
102
+ BlueSound.shared.play(BlueNegativeSoundSystemID)
103
+ }
104
+
105
+ throw error
106
+ }
107
+ }
59
108
  #endif
@@ -0,0 +1,56 @@
1
+ #if os(iOS) || os(watchOS)
2
+ import AVFoundation
3
+ import SwiftUI
4
+
5
+ private class HostingController: UIHostingController<BlueSynchronizeAccessDeviceModalView> {
6
+ override var prefersHomeIndicatorAutoHidden: Bool {
7
+ return true
8
+ }
9
+ }
10
+
11
+ internal class BlueSynchronizeAccessDeviceModalSession {
12
+ private let viewModel = BlueSynchronizeAccessDeviceModalViewModel()
13
+ private var isInvalidated: Bool = false
14
+
15
+ func begin(title: String, tasks: [BlueTask], dismiss: String, _ onDismiss: @escaping () -> Void) {
16
+ viewModel.title = title
17
+ viewModel.tasks = tasks
18
+ viewModel.dismiss = dismiss
19
+
20
+ let hostingController = HostingController(
21
+ rootView: BlueSynchronizeAccessDeviceModalView(viewModel) { onDismiss() }
22
+ )
23
+
24
+ hostingController.view.backgroundColor = .clear
25
+ hostingController.modalPresentationStyle = .overCurrentContext
26
+
27
+ blueGetKeyWindow()?.rootViewController?.present(hostingController, animated: true)
28
+ }
29
+
30
+ func updateTitle(_ title: String) {
31
+ viewModel.title = title
32
+ }
33
+
34
+ func updateDismiss(_ label: String) {
35
+ viewModel.dismiss = label
36
+ }
37
+
38
+ func disableDismiss() {
39
+ viewModel.dismissEnabled = false
40
+ }
41
+
42
+ func invalidate() {
43
+ if (isInvalidated) {
44
+ return
45
+ }
46
+
47
+ isInvalidated = true
48
+
49
+ blueGetKeyWindow()?.rootViewController?.dismiss(animated: true)
50
+ }
51
+
52
+ private func blueGetKeyWindow() -> UIWindow? {
53
+ return UIApplication.shared.windows.first(where: { $0.isKeyWindow })
54
+ }
55
+ }
56
+ #endif
@@ -0,0 +1,237 @@
1
+ #if os(iOS) || os(watchOS)
2
+ import SwiftUI
3
+ import Combine
4
+
5
+ private func getColor(_ status: BlueTaskStatus) -> Color {
6
+ switch (status) {
7
+ case .ready, .started, .skipped:
8
+ return .gray
9
+ case .failed:
10
+ return .red
11
+ case .succeeded:
12
+ return .green
13
+ }
14
+ }
15
+
16
+ private func getLineColor(_ status: BlueTaskStatus) -> Color {
17
+ switch (status) {
18
+ case .ready, .started:
19
+ return .gray
20
+ case .failed:
21
+ return .red
22
+ case .succeeded, .skipped:
23
+ return .green
24
+ }
25
+ }
26
+
27
+ private func getSymbol(_ status: BlueTaskStatus) -> String {
28
+ switch(status) {
29
+ case .ready:
30
+ return "circle"
31
+ case .started:
32
+ return "circle.circle"
33
+ case .failed:
34
+ return "xmark.circle"
35
+ case .succeeded, .skipped:
36
+ return "checkmark.circle"
37
+ }
38
+ }
39
+
40
+ class BlueTaskModel: ObservableObject, Identifiable {
41
+ @Published var label: String
42
+ @Published var status: BlueTaskStatus
43
+ @Published var statusColor: Color
44
+ @Published var lineColor: Color
45
+ @Published var symbol: String
46
+ @Published var errorDescription: String
47
+ @Published var isLast: Bool
48
+
49
+ private var subscriber: AnyCancellable?
50
+
51
+ init(_ task: BlueTask, _ isLast: Bool) {
52
+ self.label = task.label
53
+ self.status = task.status.value
54
+ self.statusColor = getColor(task.status.value)
55
+ self.lineColor = getLineColor(task.status.value)
56
+ self.symbol = getSymbol(task.status.value)
57
+ self.errorDescription = task.errorDescription ?? ""
58
+ self.isLast = isLast
59
+
60
+ self.subscriber = task.status.sink{ [weak self] status in
61
+ guard let self = self else { return }
62
+
63
+ self.status = status
64
+ self.statusColor = getColor(status)
65
+ self.lineColor = getLineColor(status)
66
+ self.symbol = getSymbol(status)
67
+ self.errorDescription = task.errorDescription ?? ""
68
+
69
+ self.objectWillChange.send()
70
+ }
71
+ }
72
+ }
73
+
74
+ struct TaskView: View {
75
+ @StateObject var task: BlueTaskModel
76
+
77
+ public var body: some View {
78
+ VStack(alignment: .leading, spacing: 0) {
79
+ HStack(alignment: .center){
80
+ if (task.status == .started) {
81
+ ProgressView()
82
+ .progressViewStyle(CircularProgressViewStyle(tint: .gray))
83
+ .padding(.leading, 2)
84
+ .padding(.trailing, 2)
85
+ } else {
86
+ Image(systemName: task.symbol)
87
+ .foregroundColor(task.statusColor)
88
+ .font(.system(size: 20))
89
+ }
90
+
91
+ Text(task.label)
92
+ .font(.system(size: 14))
93
+ .frame(maxWidth: .infinity, alignment: .leading)
94
+ }
95
+
96
+ HStack(alignment: .center) {
97
+ if !task.isLast {
98
+ Rectangle()
99
+ .fill(task.lineColor)
100
+ .frame(width: 2)
101
+ .padding(.horizontal, 10.5)
102
+ }
103
+
104
+ if !task.errorDescription.isEmpty {
105
+ Text(task.errorDescription)
106
+ .foregroundColor(.red)
107
+ .font(.system(size: 11))
108
+ .padding(.vertical, 2)
109
+ .multilineTextAlignment(.leading)
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+
116
+ class BlueSynchronizeAccessDeviceModalViewModel: ObservableObject {
117
+ @Published var title = ""
118
+ @Published var dismiss: String = ""
119
+ @Published var dismissEnabled: Bool = true
120
+ @Published var tasks: [BlueTask]
121
+
122
+ init(title: String = "", dismiss: String = "", tasks: [BlueTask] = []) {
123
+ self.title = title
124
+ self.dismiss = dismiss
125
+ self.tasks = tasks
126
+ }
127
+ }
128
+
129
+ struct BlueSynchronizeAccessDeviceModalView: View {
130
+ @ObservedObject private var vm: BlueSynchronizeAccessDeviceModalViewModel
131
+
132
+ internal var height: CGFloat = 500
133
+ internal var backgroundColor: UIColor = .white
134
+ internal var foregroundColor: UIColor = .black
135
+
136
+ private let onDismiss: () -> Void
137
+ private let cornerRadius: CGFloat = 35
138
+
139
+ public init(
140
+ _ vm: BlueSynchronizeAccessDeviceModalViewModel,
141
+ _ onDismiss: @escaping () -> Void)
142
+ {
143
+ self.vm = vm
144
+ self.onDismiss = onDismiss
145
+ }
146
+
147
+ public var body: some View {
148
+ GeometryReader { geometry in
149
+ ZStack {
150
+ VStack {
151
+ Spacer()
152
+
153
+ ZStack {
154
+ RoundedRectangle(cornerRadius: cornerRadius)
155
+ .foregroundColor(Color(backgroundColor))
156
+ .shadow(color: .gray, radius: 1)
157
+
158
+ VStack(alignment: .center) {
159
+ Text(vm.title)
160
+ .font(.system(size: 20))
161
+ .foregroundColor(.gray)
162
+
163
+ Spacer()
164
+
165
+ ScrollView {
166
+ VStack(alignment: .leading, spacing: 0) {
167
+ ForEach(vm.tasks.indices, id: \.self){ index in
168
+ TaskView(task: BlueTaskModel(vm.tasks[index], index == vm.tasks.indices.last))
169
+ }
170
+ }.padding(.vertical, 10)
171
+ }
172
+
173
+ if !vm.dismiss.isEmpty {
174
+ Spacer()
175
+
176
+ Button {
177
+ onDismiss()
178
+ } label: {
179
+ Text(vm.dismiss)
180
+ .font(.system(size: 18))
181
+ .frame(maxWidth: .infinity)
182
+ .padding(EdgeInsets(top: 15, leading: 10, bottom: 15, trailing: 10))
183
+ .background(Color.gray.opacity(0.5))
184
+ .cornerRadius(10)
185
+ }
186
+ .disabled(!vm.dismissEnabled)
187
+ }
188
+ }
189
+ .padding(30)
190
+ }
191
+ .frame(height: height + cornerRadius)
192
+ .offset(y: cornerRadius - 15)
193
+ .padding(.horizontal, 15)
194
+ }
195
+ .foregroundColor(Color(foregroundColor))
196
+ }
197
+ }
198
+ }
199
+ }
200
+
201
+ struct BlueSynchronizeAccessDeviceModalView_Preview: PreviewProvider {
202
+ static var previews: some View {
203
+ BlueSynchronizeAccessDeviceModalView(
204
+ BlueSynchronizeAccessDeviceModalViewModel(
205
+ title: "Synchronization in Progress",
206
+ dismiss: "Cancel",
207
+ tasks: [
208
+ BlueTask(
209
+ id: "A",
210
+ label: "Retrieve device configuration",
211
+ status: .failed,
212
+ error: BlueError(.sdkCredentialNotFound, cause: BlueError(.invalidCrc), detail: "Something is wrong")
213
+ ) { _ in .result(nil) },
214
+
215
+ BlueTask(
216
+ id: "B",
217
+ label: "Update device configuration",
218
+ status: .succeeded
219
+ ) { _ in .result(nil) },
220
+
221
+ BlueTask(
222
+ id: "C",
223
+ label: "Wait for device to restart",
224
+ status: .started
225
+ ) { _ in .result(nil) },
226
+
227
+ BlueTask(
228
+ id: "D",
229
+ label: "Push system status",
230
+ status: .ready
231
+ ) { _ in .result(nil) }
232
+ ]
233
+ )
234
+ ) {}
235
+ }
236
+ }
237
+ #endif