File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Sources/JavaScriptKit/JS Types Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,17 @@ public final class JSBluetooth: JSType {
22
22
23
23
public static var shared : JSBluetooth ? { return JSNavigator . shared? . bluetooth }
24
24
25
+ // MARK: - Accessors
26
+
27
+ public var isAvailable : JSPromise < Bool > {
28
+ guard let function = jsObject. getAvailability. function
29
+ else { fatalError ( " Invalid function \( #function) " ) }
30
+ let result = function. apply ( this: jsObject)
31
+ guard let promise = result. object. flatMap ( { JSPromise < Bool > ( $0) } )
32
+ else { fatalError ( " Invalid object \( result) " ) }
33
+ return promise
34
+ }
35
+
25
36
// MARK: - Methods
26
37
27
38
/// Returns a Promise to a BluetoothDevice object with the specified options.
@@ -46,7 +57,8 @@ public final class JSBluetooth: JSType {
46
57
47
58
// FIXME: Improve, support all options
48
59
let options = JSObject ( )
49
- options [ Option . acceptAllDevices. rawValue] = JSBoolean ( acceptAllDevices) . jsValue ( )
60
+ options [ Option . acceptAllDevices. rawValue] = acceptAllDevices. jsValue ( )
61
+ options [ Option . optionalServices. rawValue] = [ " device_information " ] . jsValue ( )
50
62
51
63
let result = function. apply ( this: jsObject, arguments: options)
52
64
@@ -56,8 +68,3 @@ public final class JSBluetooth: JSType {
56
68
return promise
57
69
}
58
70
}
59
-
60
- internal extension JSBluetooth {
61
-
62
- static let classObject = JSObjectRef . global. Bluetooth. function!
63
- }
You can’t perform that action at this time.
0 commit comments