Skip to content

Commit c88b849

Browse files
committed
Working on JSBluetooth
1 parent 1a44d94 commit c88b849

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Sources/JavaScriptKit/JS Types/JSBluetooth.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public final class JSBluetooth: JSType {
2828
/// - Returns: A Promise to a `BluetoothDevice` object.
2929
public func requestDevice(//filters: [] = [],
3030
//services: [] = [],
31-
/*acceptAllDevices: Bool = true*/) -> JSPromise<JSBluetoothDevice> {
31+
acceptAllDevices: Bool = true) -> JSPromise<JSBluetoothDevice> {
32+
33+
JSObjectRef.global.console.object?.log.function?("\(#file) \(String(reflecting: type(of: self))) \(#function) \(#line)")
3234

3335
enum Option: String {
3436
case filters
@@ -44,14 +46,15 @@ public final class JSBluetooth: JSType {
4446

4547
// FIXME: Improve, support all options
4648
let options = JSObject()
47-
options[Option.acceptAllDevices.rawValue] = JSBoolean(true).jsValue()
49+
options[Option.acceptAllDevices.rawValue] = JSBoolean(acceptAllDevices).jsValue()
4850
options[Option.optionalServices.rawValue] = ["device_information"].jsValue()
4951

5052
let result = function(options.jsValue())
53+
JSObjectRef.global.console.object?.log.function?("\(#file) \(String(reflecting: type(of: self))) \(#function) \(#line)")
5154

5255
guard let promise = result.object.flatMap({ JSPromise<JSBluetoothDevice>($0) })
5356
else { fatalError("Invalid object \(result)") }
54-
57+
JSObjectRef.global.console.object?.log.function?("\(#file) \(String(reflecting: type(of: self))) \(#function) \(#line)")
5558
return promise
5659
}
5760
}

Sources/JavaScriptKit/JS Types/JSBoolean.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extension JSBoolean: CustomStringConvertible { }
3636

3737
extension JSBoolean: ExpressibleByBooleanLiteral {
3838

39-
public init(booleanLiteral value: Bool) {
39+
public convenience init(booleanLiteral value: Bool) {
4040
self.init(value)
4141
}
4242
}

Sources/JavaScriptKit/JS Types/JSError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class JSError: JSType, Error {
1717

1818
// MARK: - Initialization
1919

20-
public init(_ jsObject: JSObjectRef) {
20+
public required init?(_ jsObject: JSObjectRef) {
2121
self.jsObject = jsObject
2222
}
2323

0 commit comments

Comments
 (0)