@capacitor-community/bluetooth-le 7.3.0 → 8.0.0-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 (52) hide show
  1. package/CapacitorCommunityBluetoothLe.podspec +17 -17
  2. package/LICENSE +21 -21
  3. package/Package.swift +28 -0
  4. package/android/build.gradle +71 -68
  5. package/android/src/main/AndroidManifest.xml +22 -22
  6. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/BluetoothLe.kt +1094 -1094
  7. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Conversion.kt +51 -51
  8. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Device.kt +771 -771
  9. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceList.kt +28 -28
  10. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceScanner.kt +189 -189
  11. package/dist/esm/bleClient.d.ts +278 -278
  12. package/dist/esm/bleClient.js +361 -361
  13. package/dist/esm/bleClient.js.map +1 -1
  14. package/dist/esm/config.d.ts +53 -53
  15. package/dist/esm/config.js +2 -2
  16. package/dist/esm/conversion.d.ts +56 -46
  17. package/dist/esm/conversion.js +134 -117
  18. package/dist/esm/conversion.js.map +1 -1
  19. package/dist/esm/definitions.d.ts +352 -352
  20. package/dist/esm/definitions.js +42 -42
  21. package/dist/esm/index.d.ts +5 -5
  22. package/dist/esm/index.js +5 -5
  23. package/dist/esm/plugin.d.ts +2 -2
  24. package/dist/esm/plugin.js +4 -4
  25. package/dist/esm/queue.d.ts +3 -3
  26. package/dist/esm/queue.js +17 -17
  27. package/dist/esm/queue.js.map +1 -1
  28. package/dist/esm/timeout.d.ts +1 -1
  29. package/dist/esm/timeout.js +9 -9
  30. package/dist/esm/validators.d.ts +1 -1
  31. package/dist/esm/validators.js +11 -11
  32. package/dist/esm/validators.js.map +1 -1
  33. package/dist/esm/web.d.ts +57 -57
  34. package/dist/esm/web.js +403 -403
  35. package/dist/esm/web.js.map +1 -1
  36. package/dist/plugin.cjs.js +965 -947
  37. package/dist/plugin.cjs.js.map +1 -1
  38. package/dist/plugin.js +965 -947
  39. package/dist/plugin.js.map +1 -1
  40. package/ios/{Plugin → Sources/BluetoothLe}/Conversion.swift +83 -83
  41. package/ios/{Plugin → Sources/BluetoothLe}/Device.swift +423 -423
  42. package/ios/{Plugin → Sources/BluetoothLe}/DeviceListView.swift +121 -121
  43. package/ios/{Plugin → Sources/BluetoothLe}/DeviceManager.swift +503 -502
  44. package/ios/{Plugin → Sources/BluetoothLe}/Logging.swift +8 -8
  45. package/ios/{Plugin → Sources/BluetoothLe}/Plugin.swift +775 -737
  46. package/ios/{Plugin → Sources/BluetoothLe}/ThreadSafeDictionary.swift +15 -13
  47. package/ios/Tests/BluetoothLeTests/ConversionTests.swift +55 -0
  48. package/ios/Tests/BluetoothLeTests/PluginTests.swift +27 -0
  49. package/package.json +115 -111
  50. package/ios/Plugin/Info.plist +0 -24
  51. package/ios/Plugin/Plugin.h +0 -10
  52. package/ios/Plugin/Plugin.m +0 -41
@@ -1,121 +1,121 @@
1
- import UIKit
2
-
3
- class DeviceListView: UIViewController, UITableViewDelegate, UITableViewDataSource {
4
-
5
- private let tableView = UITableView()
6
- private let cancelButton = UIButton(type: .system)
7
- private let titleLabel = UILabel()
8
- private let progressIndication = UIActivityIndicatorView()
9
- private var onCancel: (() -> Void)?
10
- private var devices: [(name: String, action: () -> Void)] = []
11
-
12
- override func viewDidLoad() {
13
- super.viewDidLoad()
14
- isModalInPresentation = true // don't allow drag to dismiss
15
- setupUI()
16
- addBlurBackground()
17
- }
18
-
19
- func setTitle(_ title: String?) {
20
- titleLabel.text = title
21
- }
22
-
23
- func setCancelButton(_ title: String?, action: @escaping () -> Void) {
24
- cancelButton.setTitle(title, for: .normal)
25
- self.onCancel = action
26
- }
27
-
28
- func addItem(_ name: String, action: @escaping () -> Void) {
29
- devices.append((name, action))
30
- tableView.reloadData()
31
- }
32
-
33
- private func addBlurBackground() {
34
- let blurEffect = UIBlurEffect(style: .systemChromeMaterial)
35
- let blurView = UIVisualEffectView(effect: blurEffect)
36
- blurView.frame = view.bounds
37
- blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
38
- view.insertSubview(blurView, at: 0)
39
- }
40
-
41
- private func setupUI() {
42
- titleLabel.textAlignment = .center
43
- titleLabel.font = UIFont.boldSystemFont(ofSize: 22)
44
-
45
- let titleStack = UIStackView(arrangedSubviews: [titleLabel, progressIndication])
46
- titleStack.axis = .horizontal
47
- titleStack.alignment = .center
48
- titleStack.distribution = .fill
49
- titleStack.spacing = 8
50
- titleStack.translatesAutoresizingMaskIntoConstraints = false
51
- view.addSubview(titleStack)
52
-
53
- progressIndication.translatesAutoresizingMaskIntoConstraints = false
54
- progressIndication.startAnimating()
55
- progressIndication.hidesWhenStopped = true
56
- progressIndication.setContentHuggingPriority(.required, for: .horizontal)
57
- NSLayoutConstraint.activate([
58
- progressIndication.widthAnchor.constraint(equalToConstant: 22),
59
- progressIndication.heightAnchor.constraint(equalToConstant: 22)
60
- ])
61
-
62
- tableView.backgroundColor = .clear
63
- tableView.delegate = self
64
- tableView.dataSource = self
65
- tableView.translatesAutoresizingMaskIntoConstraints = false
66
- tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
67
- view.addSubview(tableView)
68
-
69
- // Cancel Button
70
- cancelButton.setTitleColor(.systemRed, for: .normal)
71
- cancelButton.addTarget(self, action: #selector(dismissPopover), for: .touchUpInside)
72
- cancelButton.translatesAutoresizingMaskIntoConstraints = false
73
- view.addSubview(cancelButton)
74
-
75
- NSLayoutConstraint.activate([
76
- titleStack.topAnchor.constraint(equalTo: view.topAnchor, constant: 10),
77
- titleStack.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
78
- titleStack.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30),
79
- titleStack.heightAnchor.constraint(equalToConstant: 30),
80
-
81
- // TableView
82
- tableView.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 10),
83
- tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 10),
84
- tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -10),
85
- tableView.bottomAnchor.constraint(equalTo: cancelButton.topAnchor, constant: -10),
86
-
87
- // Cancel Button at the Bottom
88
- cancelButton.leadingAnchor.constraint(equalTo: view.leadingAnchor),
89
- cancelButton.trailingAnchor.constraint(equalTo: view.trailingAnchor),
90
- cancelButton.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -10),
91
- cancelButton.heightAnchor.constraint(equalToConstant: 40)
92
- ])
93
- }
94
-
95
- @objc private func dismissPopover() {
96
- onCancel?()
97
- dismiss(animated: true)
98
- }
99
-
100
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
101
- return devices.count
102
- }
103
-
104
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
105
- let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
106
- cell.textLabel?.text = devices[indexPath.row].name
107
- cell.textLabel?.textColor = .systemBlue
108
- cell.textLabel?.backgroundColor = .clear
109
- cell.backgroundColor = .clear
110
- cell.contentView.backgroundColor = .clear
111
- cell.textLabel?.textAlignment = .center
112
- cell.selectionStyle = .default
113
- return cell
114
- }
115
-
116
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
117
- tableView.deselectRow(at: indexPath, animated: true)
118
- devices[indexPath.row].action() // Execute closure action
119
- dismiss(animated: true) // Optionally close the popover
120
- }
121
- }
1
+ import UIKit
2
+
3
+ class DeviceListView: UIViewController, UITableViewDelegate, UITableViewDataSource {
4
+
5
+ private let tableView = UITableView()
6
+ private let cancelButton = UIButton(type: .system)
7
+ private let titleLabel = UILabel()
8
+ private let progressIndication = UIActivityIndicatorView()
9
+ private var onCancel: (() -> Void)?
10
+ private var devices: [(name: String, action: () -> Void)] = []
11
+
12
+ override func viewDidLoad() {
13
+ super.viewDidLoad()
14
+ isModalInPresentation = true // don't allow drag to dismiss
15
+ setupUI()
16
+ addBlurBackground()
17
+ }
18
+
19
+ func setTitle(_ title: String?) {
20
+ titleLabel.text = title
21
+ }
22
+
23
+ func setCancelButton(_ title: String?, action: @escaping () -> Void) {
24
+ cancelButton.setTitle(title, for: .normal)
25
+ self.onCancel = action
26
+ }
27
+
28
+ func addItem(_ name: String, action: @escaping () -> Void) {
29
+ devices.append((name, action))
30
+ tableView.reloadData()
31
+ }
32
+
33
+ private func addBlurBackground() {
34
+ let blurEffect = UIBlurEffect(style: .systemChromeMaterial)
35
+ let blurView = UIVisualEffectView(effect: blurEffect)
36
+ blurView.frame = view.bounds
37
+ blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
38
+ view.insertSubview(blurView, at: 0)
39
+ }
40
+
41
+ private func setupUI() {
42
+ titleLabel.textAlignment = .center
43
+ titleLabel.font = UIFont.boldSystemFont(ofSize: 22)
44
+
45
+ let titleStack = UIStackView(arrangedSubviews: [titleLabel, progressIndication])
46
+ titleStack.axis = .horizontal
47
+ titleStack.alignment = .center
48
+ titleStack.distribution = .fill
49
+ titleStack.spacing = 8
50
+ titleStack.translatesAutoresizingMaskIntoConstraints = false
51
+ view.addSubview(titleStack)
52
+
53
+ progressIndication.translatesAutoresizingMaskIntoConstraints = false
54
+ progressIndication.startAnimating()
55
+ progressIndication.hidesWhenStopped = true
56
+ progressIndication.setContentHuggingPriority(.required, for: .horizontal)
57
+ NSLayoutConstraint.activate([
58
+ progressIndication.widthAnchor.constraint(equalToConstant: 22),
59
+ progressIndication.heightAnchor.constraint(equalToConstant: 22)
60
+ ])
61
+
62
+ tableView.backgroundColor = .clear
63
+ tableView.delegate = self
64
+ tableView.dataSource = self
65
+ tableView.translatesAutoresizingMaskIntoConstraints = false
66
+ tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
67
+ view.addSubview(tableView)
68
+
69
+ // Cancel Button
70
+ cancelButton.setTitleColor(.systemRed, for: .normal)
71
+ cancelButton.addTarget(self, action: #selector(dismissPopover), for: .touchUpInside)
72
+ cancelButton.translatesAutoresizingMaskIntoConstraints = false
73
+ view.addSubview(cancelButton)
74
+
75
+ NSLayoutConstraint.activate([
76
+ titleStack.topAnchor.constraint(equalTo: view.topAnchor, constant: 10),
77
+ titleStack.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
78
+ titleStack.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30),
79
+ titleStack.heightAnchor.constraint(equalToConstant: 30),
80
+
81
+ // TableView
82
+ tableView.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 10),
83
+ tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 10),
84
+ tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -10),
85
+ tableView.bottomAnchor.constraint(equalTo: cancelButton.topAnchor, constant: -10),
86
+
87
+ // Cancel Button at the Bottom
88
+ cancelButton.leadingAnchor.constraint(equalTo: view.leadingAnchor),
89
+ cancelButton.trailingAnchor.constraint(equalTo: view.trailingAnchor),
90
+ cancelButton.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -10),
91
+ cancelButton.heightAnchor.constraint(equalToConstant: 40)
92
+ ])
93
+ }
94
+
95
+ @objc private func dismissPopover() {
96
+ onCancel?()
97
+ dismiss(animated: true)
98
+ }
99
+
100
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
101
+ return devices.count
102
+ }
103
+
104
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
105
+ let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
106
+ cell.textLabel?.text = devices[indexPath.row].name
107
+ cell.textLabel?.textColor = .systemBlue
108
+ cell.textLabel?.backgroundColor = .clear
109
+ cell.backgroundColor = .clear
110
+ cell.contentView.backgroundColor = .clear
111
+ cell.textLabel?.textAlignment = .center
112
+ cell.selectionStyle = .default
113
+ return cell
114
+ }
115
+
116
+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
117
+ tableView.deselectRow(at: indexPath, animated: true)
118
+ devices[indexPath.row].action() // Execute closure action
119
+ dismiss(animated: true) // Optionally close the popover
120
+ }
121
+ }