Skip to content

Commit a2655cd

Browse files
committed
web-sys: Add WebBluetooth to enabled directory
Add WebBluetooth IDL (taken from WebBluetooth spec), as well as generated files and feature updates.
1 parent 6dd8f1c commit a2655cd

26 files changed

+2278
-1
lines changed

crates/web-sys/Cargo.toml

+23-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ AesKeyAlgorithm = []
4141
AesKeyGenParams = []
4242
Algorithm = []
4343
AlignSetting = []
44+
AllowedBluetoothDevice = []
4445
AnalyserNode = ["AudioNode", "EventTarget"]
4546
AnalyserOptions = []
4647
AngleInstancedArrays = []
@@ -111,6 +112,23 @@ BlobEvent = ["Event"]
111112
BlobEventInit = []
112113
BlobPropertyBag = []
113114
BlockParsingOptions = []
115+
Bluetooth = ["EventTarget"]
116+
BluetoothAdvertisingEvent = ["Event"]
117+
BluetoothAdvertisingEventInit = []
118+
BluetoothCharacteristicProperties = []
119+
BluetoothDataFilterInit = []
120+
BluetoothDevice = ["EventTarget"]
121+
BluetoothLeScanFilterInit = []
122+
BluetoothManufacturerDataMap = []
123+
BluetoothPermissionDescriptor = []
124+
BluetoothPermissionResult = ["EventTarget", "PermissionStatus"]
125+
BluetoothPermissionStorage = []
126+
BluetoothRemoteGattCharacteristic = ["EventTarget"]
127+
BluetoothRemoteGattDescriptor = []
128+
BluetoothRemoteGattServer = []
129+
BluetoothRemoteGattService = ["EventTarget"]
130+
BluetoothServiceDataMap = []
131+
BluetoothUuid = []
114132
BoxQuadOptions = []
115133
BroadcastChannel = ["EventTarget"]
116134
BrowserElementDownloadOptions = []
@@ -892,6 +910,7 @@ Request = []
892910
RequestCache = []
893911
RequestCredentials = []
894912
RequestDestination = []
913+
RequestDeviceOptions = []
895914
RequestInit = []
896915
RequestMediaKeySystemAccessNotification = []
897916
RequestMode = []
@@ -1222,6 +1241,8 @@ UserProximityEvent = ["Event"]
12221241
UserProximityEventInit = []
12231242
UserVerificationRequirement = []
12241243
ValidityState = []
1244+
ValueEvent = ["Event"]
1245+
ValueEventInit = []
12251246
VideoConfiguration = []
12261247
VideoFacingModeEnum = []
12271248
VideoPlaybackQuality = []
@@ -1245,6 +1266,7 @@ VrStageParameters = []
12451266
VrSubmitFrameResult = []
12461267
VttCue = ["EventTarget", "TextTrackCue"]
12471268
VttRegion = []
1269+
WatchAdvertisementsOptions = []
12481270
WaveShaperNode = ["AudioNode", "EventTarget"]
12491271
WaveShaperOptions = []
12501272
WebGl2RenderingContext = []
@@ -1342,4 +1364,4 @@ XrWebGlLayer = []
13421364
XrWebGlLayerInit = []
13431365
XsltProcessor = []
13441366
console = []
1345-
css = []
1367+
css = []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#![allow(unused_imports)]
2+
use super::*;
3+
use wasm_bindgen::prelude::*;
4+
#[wasm_bindgen]
5+
extern "C" {
6+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = AllowedBluetoothDevice)]
7+
#[derive(Debug, Clone, PartialEq, Eq)]
8+
#[doc = "The `AllowedBluetoothDevice` dictionary."]
9+
#[doc = ""]
10+
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
11+
pub type AllowedBluetoothDevice;
12+
}
13+
impl AllowedBluetoothDevice {
14+
#[doc = "Construct a new `AllowedBluetoothDevice`."]
15+
#[doc = ""]
16+
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
17+
pub fn new(
18+
allowed_services: &::wasm_bindgen::JsValue,
19+
device_id: &str,
20+
may_use_gatt: bool,
21+
) -> Self {
22+
#[allow(unused_mut)]
23+
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
24+
ret.allowed_services(allowed_services);
25+
ret.device_id(device_id);
26+
ret.may_use_gatt(may_use_gatt);
27+
ret
28+
}
29+
#[doc = "Change the `allowedServices` field of this object."]
30+
#[doc = ""]
31+
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
32+
pub fn allowed_services(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
33+
use wasm_bindgen::JsValue;
34+
let r = ::js_sys::Reflect::set(
35+
self.as_ref(),
36+
&JsValue::from("allowedServices"),
37+
&JsValue::from(val),
38+
);
39+
debug_assert!(
40+
r.is_ok(),
41+
"setting properties should never fail on our dictionary objects"
42+
);
43+
let _ = r;
44+
self
45+
}
46+
#[doc = "Change the `deviceId` field of this object."]
47+
#[doc = ""]
48+
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
49+
pub fn device_id(&mut self, val: &str) -> &mut Self {
50+
use wasm_bindgen::JsValue;
51+
let r = ::js_sys::Reflect::set(
52+
self.as_ref(),
53+
&JsValue::from("deviceId"),
54+
&JsValue::from(val),
55+
);
56+
debug_assert!(
57+
r.is_ok(),
58+
"setting properties should never fail on our dictionary objects"
59+
);
60+
let _ = r;
61+
self
62+
}
63+
#[doc = "Change the `mayUseGATT` field of this object."]
64+
#[doc = ""]
65+
#[doc = "*This API requires the following crate features to be activated: `AllowedBluetoothDevice`*"]
66+
pub fn may_use_gatt(&mut self, val: bool) -> &mut Self {
67+
use wasm_bindgen::JsValue;
68+
let r = ::js_sys::Reflect::set(
69+
self.as_ref(),
70+
&JsValue::from("mayUseGATT"),
71+
&JsValue::from(val),
72+
);
73+
debug_assert!(
74+
r.is_ok(),
75+
"setting properties should never fail on our dictionary objects"
76+
);
77+
let _ = r;
78+
self
79+
}
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
#![allow(unused_imports)]
2+
use super::*;
3+
use wasm_bindgen::prelude::*;
4+
#[wasm_bindgen]
5+
extern "C" {
6+
# [wasm_bindgen (extends = EventTarget , extends = :: js_sys :: Object , js_name = Bluetooth , typescript_type = "Bluetooth")]
7+
#[derive(Debug, Clone, PartialEq, Eq)]
8+
#[doc = "The `Bluetooth` class."]
9+
#[doc = ""]
10+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth)"]
11+
#[doc = ""]
12+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
13+
pub type Bluetooth;
14+
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = onavailabilitychanged)]
15+
#[doc = "Getter for the `onavailabilitychanged` field of this object."]
16+
#[doc = ""]
17+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onavailabilitychanged)"]
18+
#[doc = ""]
19+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
20+
pub fn onavailabilitychanged(this: &Bluetooth) -> Option<::js_sys::Function>;
21+
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = onavailabilitychanged)]
22+
#[doc = "Setter for the `onavailabilitychanged` field of this object."]
23+
#[doc = ""]
24+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onavailabilitychanged)"]
25+
#[doc = ""]
26+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
27+
pub fn set_onavailabilitychanged(this: &Bluetooth, value: Option<&::js_sys::Function>);
28+
#[cfg(feature = "BluetoothDevice")]
29+
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = referringDevice)]
30+
#[doc = "Getter for the `referringDevice` field of this object."]
31+
#[doc = ""]
32+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/referringDevice)"]
33+
#[doc = ""]
34+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`, `BluetoothDevice`*"]
35+
pub fn referring_device(this: &Bluetooth) -> Option<BluetoothDevice>;
36+
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = onadvertisementreceived)]
37+
#[doc = "Getter for the `onadvertisementreceived` field of this object."]
38+
#[doc = ""]
39+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onadvertisementreceived)"]
40+
#[doc = ""]
41+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
42+
pub fn onadvertisementreceived(this: &Bluetooth) -> Option<::js_sys::Function>;
43+
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = onadvertisementreceived)]
44+
#[doc = "Setter for the `onadvertisementreceived` field of this object."]
45+
#[doc = ""]
46+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onadvertisementreceived)"]
47+
#[doc = ""]
48+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
49+
pub fn set_onadvertisementreceived(this: &Bluetooth, value: Option<&::js_sys::Function>);
50+
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = ongattserverdisconnected)]
51+
#[doc = "Getter for the `ongattserverdisconnected` field of this object."]
52+
#[doc = ""]
53+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/ongattserverdisconnected)"]
54+
#[doc = ""]
55+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
56+
pub fn ongattserverdisconnected(this: &Bluetooth) -> Option<::js_sys::Function>;
57+
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = ongattserverdisconnected)]
58+
#[doc = "Setter for the `ongattserverdisconnected` field of this object."]
59+
#[doc = ""]
60+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/ongattserverdisconnected)"]
61+
#[doc = ""]
62+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
63+
pub fn set_ongattserverdisconnected(this: &Bluetooth, value: Option<&::js_sys::Function>);
64+
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = oncharacteristicvaluechanged)]
65+
#[doc = "Getter for the `oncharacteristicvaluechanged` field of this object."]
66+
#[doc = ""]
67+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/oncharacteristicvaluechanged)"]
68+
#[doc = ""]
69+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
70+
pub fn oncharacteristicvaluechanged(this: &Bluetooth) -> Option<::js_sys::Function>;
71+
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = oncharacteristicvaluechanged)]
72+
#[doc = "Setter for the `oncharacteristicvaluechanged` field of this object."]
73+
#[doc = ""]
74+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/oncharacteristicvaluechanged)"]
75+
#[doc = ""]
76+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
77+
pub fn set_oncharacteristicvaluechanged(this: &Bluetooth, value: Option<&::js_sys::Function>);
78+
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = onserviceadded)]
79+
#[doc = "Getter for the `onserviceadded` field of this object."]
80+
#[doc = ""]
81+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onserviceadded)"]
82+
#[doc = ""]
83+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
84+
pub fn onserviceadded(this: &Bluetooth) -> Option<::js_sys::Function>;
85+
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = onserviceadded)]
86+
#[doc = "Setter for the `onserviceadded` field of this object."]
87+
#[doc = ""]
88+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onserviceadded)"]
89+
#[doc = ""]
90+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
91+
pub fn set_onserviceadded(this: &Bluetooth, value: Option<&::js_sys::Function>);
92+
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = onservicechanged)]
93+
#[doc = "Getter for the `onservicechanged` field of this object."]
94+
#[doc = ""]
95+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onservicechanged)"]
96+
#[doc = ""]
97+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
98+
pub fn onservicechanged(this: &Bluetooth) -> Option<::js_sys::Function>;
99+
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = onservicechanged)]
100+
#[doc = "Setter for the `onservicechanged` field of this object."]
101+
#[doc = ""]
102+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onservicechanged)"]
103+
#[doc = ""]
104+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
105+
pub fn set_onservicechanged(this: &Bluetooth, value: Option<&::js_sys::Function>);
106+
# [wasm_bindgen (structural , method , getter , js_class = "Bluetooth" , js_name = onserviceremoved)]
107+
#[doc = "Getter for the `onserviceremoved` field of this object."]
108+
#[doc = ""]
109+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onserviceremoved)"]
110+
#[doc = ""]
111+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
112+
pub fn onserviceremoved(this: &Bluetooth) -> Option<::js_sys::Function>;
113+
# [wasm_bindgen (structural , method , setter , js_class = "Bluetooth" , js_name = onserviceremoved)]
114+
#[doc = "Setter for the `onserviceremoved` field of this object."]
115+
#[doc = ""]
116+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/onserviceremoved)"]
117+
#[doc = ""]
118+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
119+
pub fn set_onserviceremoved(this: &Bluetooth, value: Option<&::js_sys::Function>);
120+
# [wasm_bindgen (method , structural , js_class = "Bluetooth" , js_name = getAvailability)]
121+
#[doc = "The `getAvailability()` method."]
122+
#[doc = ""]
123+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getAvailability)"]
124+
#[doc = ""]
125+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
126+
pub fn get_availability(this: &Bluetooth) -> ::js_sys::Promise;
127+
# [wasm_bindgen (method , structural , js_class = "Bluetooth" , js_name = getDevices)]
128+
#[doc = "The `getDevices()` method."]
129+
#[doc = ""]
130+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/getDevices)"]
131+
#[doc = ""]
132+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
133+
pub fn get_devices(this: &Bluetooth) -> ::js_sys::Promise;
134+
# [wasm_bindgen (method , structural , js_class = "Bluetooth" , js_name = requestDevice)]
135+
#[doc = "The `requestDevice()` method."]
136+
#[doc = ""]
137+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice)"]
138+
#[doc = ""]
139+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`*"]
140+
pub fn request_device(this: &Bluetooth) -> ::js_sys::Promise;
141+
#[cfg(feature = "RequestDeviceOptions")]
142+
# [wasm_bindgen (method , structural , js_class = "Bluetooth" , js_name = requestDevice)]
143+
#[doc = "The `requestDevice()` method."]
144+
#[doc = ""]
145+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice)"]
146+
#[doc = ""]
147+
#[doc = "*This API requires the following crate features to be activated: `Bluetooth`, `RequestDeviceOptions`*"]
148+
pub fn request_device_with_options(
149+
this: &Bluetooth,
150+
options: &RequestDeviceOptions,
151+
) -> ::js_sys::Promise;
152+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#![allow(unused_imports)]
2+
use super::*;
3+
use wasm_bindgen::prelude::*;
4+
#[wasm_bindgen]
5+
extern "C" {
6+
# [wasm_bindgen (extends = Event , extends = :: js_sys :: Object , js_name = BluetoothAdvertisingEvent , typescript_type = "BluetoothAdvertisingEvent")]
7+
#[derive(Debug, Clone, PartialEq, Eq)]
8+
#[doc = "The `BluetoothAdvertisingEvent` class."]
9+
#[doc = ""]
10+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent)"]
11+
#[doc = ""]
12+
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`*"]
13+
pub type BluetoothAdvertisingEvent;
14+
#[cfg(feature = "BluetoothDevice")]
15+
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = device)]
16+
#[doc = "Getter for the `device` field of this object."]
17+
#[doc = ""]
18+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/device)"]
19+
#[doc = ""]
20+
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`, `BluetoothDevice`*"]
21+
pub fn device(this: &BluetoothAdvertisingEvent) -> BluetoothDevice;
22+
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = name)]
23+
#[doc = "Getter for the `name` field of this object."]
24+
#[doc = ""]
25+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/name)"]
26+
#[doc = ""]
27+
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`*"]
28+
pub fn name(this: &BluetoothAdvertisingEvent) -> Option<String>;
29+
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = appearance)]
30+
#[doc = "Getter for the `appearance` field of this object."]
31+
#[doc = ""]
32+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/appearance)"]
33+
#[doc = ""]
34+
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`*"]
35+
pub fn appearance(this: &BluetoothAdvertisingEvent) -> Option<u16>;
36+
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = txPower)]
37+
#[doc = "Getter for the `txPower` field of this object."]
38+
#[doc = ""]
39+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/txPower)"]
40+
#[doc = ""]
41+
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`*"]
42+
pub fn tx_power(this: &BluetoothAdvertisingEvent) -> Option<i8>;
43+
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = rssi)]
44+
#[doc = "Getter for the `rssi` field of this object."]
45+
#[doc = ""]
46+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/rssi)"]
47+
#[doc = ""]
48+
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`*"]
49+
pub fn rssi(this: &BluetoothAdvertisingEvent) -> Option<i8>;
50+
#[cfg(feature = "BluetoothManufacturerDataMap")]
51+
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = manufacturerData)]
52+
#[doc = "Getter for the `manufacturerData` field of this object."]
53+
#[doc = ""]
54+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/manufacturerData)"]
55+
#[doc = ""]
56+
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`, `BluetoothManufacturerDataMap`*"]
57+
pub fn manufacturer_data(this: &BluetoothAdvertisingEvent) -> BluetoothManufacturerDataMap;
58+
#[cfg(feature = "BluetoothServiceDataMap")]
59+
# [wasm_bindgen (structural , method , getter , js_class = "BluetoothAdvertisingEvent" , js_name = serviceData)]
60+
#[doc = "Getter for the `serviceData` field of this object."]
61+
#[doc = ""]
62+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/BluetoothAdvertisingEvent/serviceData)"]
63+
#[doc = ""]
64+
#[doc = "*This API requires the following crate features to be activated: `BluetoothAdvertisingEvent`, `BluetoothServiceDataMap`*"]
65+
pub fn service_data(this: &BluetoothAdvertisingEvent) -> BluetoothServiceDataMap;
66+
}

0 commit comments

Comments
 (0)