Skip to content

Commit 7ad4c3f

Browse files
authored
Add WebIDL definitions for InputDeviceInfo and MediaTrackCapabilities (#3935)
* Add WebIDL definitions for `InputDeviceInfo` and `MediaTrackCapabilities` * Regenerate WebIDL bindings * Add changelog entry for `InputDeviceInfo` and `MediaTrackCapabilities`
1 parent 73e5a8c commit 7ad4c3f

9 files changed

+489
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
* Added support for returning `Vec`s from async functions.
1818
[#3630](https://github.com/rustwasm/wasm-bindgen/pull/3630)
1919

20+
* Added bindings for `InputDeviceInfo` and `MediaTrackCapabilities`.
21+
[#3935](https://github.com/rustwasm/wasm-bindgen/pull/3935)
22+
2023
### Changed
2124

2225
* Stabilize Web Share API.

crates/web-sys/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ DomStringList = []
326326
DomStringMap = []
327327
DomTokenList = []
328328
DomWindowResizeEventDetail = []
329+
DoubleRange = []
329330
DragEvent = ["Event", "MouseEvent", "UiEvent"]
330331
DragEventInit = []
331332
DynamicsCompressorNode = ["AudioNode", "EventTarget"]
@@ -728,6 +729,7 @@ ImageEncodeOptions = []
728729
ImageOrientation = []
729730
ImageTrack = ["EventTarget"]
730731
ImageTrackList = []
732+
InputDeviceInfo = ["MediaDeviceInfo"]
731733
InputEvent = ["Event", "UiEvent"]
732734
InputEventInit = []
733735
IntersectionObserver = []
@@ -829,6 +831,7 @@ MediaStreamTrackGeneratorInit = []
829831
MediaStreamTrackProcessor = []
830832
MediaStreamTrackProcessorInit = []
831833
MediaStreamTrackState = []
834+
MediaTrackCapabilities = []
832835
MediaTrackConstraintSet = []
833836
MediaTrackConstraints = []
834837
MediaTrackSettings = []
@@ -1405,6 +1408,7 @@ TreeView = []
14051408
TreeWalker = []
14061409
U2f = []
14071410
U2fClientData = []
1411+
ULongRange = []
14081412
UdpMessageEventInit = []
14091413
UdpOptions = []
14101414
UiEvent = ["Event"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#![allow(unused_imports)]
2+
#![allow(clippy::all)]
3+
use super::*;
4+
use wasm_bindgen::prelude::*;
5+
#[cfg(web_sys_unstable_apis)]
6+
#[wasm_bindgen]
7+
extern "C" {
8+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = DoubleRange)]
9+
#[derive(Debug, Clone, PartialEq, Eq)]
10+
#[doc = "The `DoubleRange` dictionary."]
11+
#[doc = ""]
12+
#[doc = "*This API requires the following crate features to be activated: `DoubleRange`*"]
13+
#[doc = ""]
14+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
15+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
16+
pub type DoubleRange;
17+
#[wasm_bindgen(method, setter = "max")]
18+
fn max_shim(this: &DoubleRange, val: f64);
19+
#[wasm_bindgen(method, setter = "min")]
20+
fn min_shim(this: &DoubleRange, val: f64);
21+
}
22+
#[cfg(web_sys_unstable_apis)]
23+
impl DoubleRange {
24+
#[doc = "Construct a new `DoubleRange`."]
25+
#[doc = ""]
26+
#[doc = "*This API requires the following crate features to be activated: `DoubleRange`*"]
27+
#[doc = ""]
28+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
29+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
30+
pub fn new() -> Self {
31+
#[allow(unused_mut)]
32+
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
33+
ret
34+
}
35+
#[cfg(web_sys_unstable_apis)]
36+
#[doc = "Change the `max` field of this object."]
37+
#[doc = ""]
38+
#[doc = "*This API requires the following crate features to be activated: `DoubleRange`*"]
39+
#[doc = ""]
40+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
41+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
42+
pub fn max(&mut self, val: f64) -> &mut Self {
43+
self.max_shim(val);
44+
self
45+
}
46+
#[cfg(web_sys_unstable_apis)]
47+
#[doc = "Change the `min` field of this object."]
48+
#[doc = ""]
49+
#[doc = "*This API requires the following crate features to be activated: `DoubleRange`*"]
50+
#[doc = ""]
51+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
52+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
53+
pub fn min(&mut self, val: f64) -> &mut Self {
54+
self.min_shim(val);
55+
self
56+
}
57+
}
58+
#[cfg(web_sys_unstable_apis)]
59+
impl Default for DoubleRange {
60+
fn default() -> Self {
61+
Self::new()
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#![allow(unused_imports)]
2+
#![allow(clippy::all)]
3+
use super::*;
4+
use wasm_bindgen::prelude::*;
5+
#[cfg(web_sys_unstable_apis)]
6+
#[wasm_bindgen]
7+
extern "C" {
8+
# [wasm_bindgen (extends = MediaDeviceInfo , extends = :: js_sys :: Object , js_name = InputDeviceInfo , typescript_type = "InputDeviceInfo")]
9+
#[derive(Debug, Clone, PartialEq, Eq)]
10+
#[doc = "The `InputDeviceInfo` class."]
11+
#[doc = ""]
12+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceInfo)"]
13+
#[doc = ""]
14+
#[doc = "*This API requires the following crate features to be activated: `InputDeviceInfo`*"]
15+
#[doc = ""]
16+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
17+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
18+
pub type InputDeviceInfo;
19+
#[cfg(web_sys_unstable_apis)]
20+
#[cfg(feature = "MediaTrackCapabilities")]
21+
# [wasm_bindgen (method , structural , js_class = "InputDeviceInfo" , js_name = getCapabilities)]
22+
#[doc = "The `getCapabilities()` method."]
23+
#[doc = ""]
24+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/InputDeviceInfo/getCapabilities)"]
25+
#[doc = ""]
26+
#[doc = "*This API requires the following crate features to be activated: `InputDeviceInfo`, `MediaTrackCapabilities`*"]
27+
#[doc = ""]
28+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
29+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
30+
pub fn get_capabilities(this: &InputDeviceInfo) -> MediaTrackCapabilities;
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
#![allow(unused_imports)]
2+
#![allow(clippy::all)]
3+
use super::*;
4+
use wasm_bindgen::prelude::*;
5+
#[cfg(web_sys_unstable_apis)]
6+
#[wasm_bindgen]
7+
extern "C" {
8+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = MediaTrackCapabilities)]
9+
#[derive(Debug, Clone, PartialEq, Eq)]
10+
#[doc = "The `MediaTrackCapabilities` dictionary."]
11+
#[doc = ""]
12+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`*"]
13+
#[doc = ""]
14+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
15+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
16+
pub type MediaTrackCapabilities;
17+
#[cfg(feature = "DoubleRange")]
18+
#[wasm_bindgen(method, setter = "aspectRatio")]
19+
fn aspect_ratio_shim(this: &MediaTrackCapabilities, val: &DoubleRange);
20+
#[wasm_bindgen(method, setter = "autoGainControl")]
21+
fn auto_gain_control_shim(this: &MediaTrackCapabilities, val: &::wasm_bindgen::JsValue);
22+
#[cfg(feature = "ULongRange")]
23+
#[wasm_bindgen(method, setter = "channelCount")]
24+
fn channel_count_shim(this: &MediaTrackCapabilities, val: &ULongRange);
25+
#[wasm_bindgen(method, setter = "deviceId")]
26+
fn device_id_shim(this: &MediaTrackCapabilities, val: &str);
27+
#[wasm_bindgen(method, setter = "echoCancellation")]
28+
fn echo_cancellation_shim(this: &MediaTrackCapabilities, val: &::wasm_bindgen::JsValue);
29+
#[wasm_bindgen(method, setter = "facingMode")]
30+
fn facing_mode_shim(this: &MediaTrackCapabilities, val: &::wasm_bindgen::JsValue);
31+
#[cfg(feature = "DoubleRange")]
32+
#[wasm_bindgen(method, setter = "frameRate")]
33+
fn frame_rate_shim(this: &MediaTrackCapabilities, val: &DoubleRange);
34+
#[wasm_bindgen(method, setter = "groupId")]
35+
fn group_id_shim(this: &MediaTrackCapabilities, val: &str);
36+
#[cfg(feature = "ULongRange")]
37+
#[wasm_bindgen(method, setter = "height")]
38+
fn height_shim(this: &MediaTrackCapabilities, val: &ULongRange);
39+
#[cfg(feature = "DoubleRange")]
40+
#[wasm_bindgen(method, setter = "latency")]
41+
fn latency_shim(this: &MediaTrackCapabilities, val: &DoubleRange);
42+
#[wasm_bindgen(method, setter = "noiseSuppression")]
43+
fn noise_suppression_shim(this: &MediaTrackCapabilities, val: &::wasm_bindgen::JsValue);
44+
#[wasm_bindgen(method, setter = "resizeMode")]
45+
fn resize_mode_shim(this: &MediaTrackCapabilities, val: &::wasm_bindgen::JsValue);
46+
#[cfg(feature = "ULongRange")]
47+
#[wasm_bindgen(method, setter = "sampleRate")]
48+
fn sample_rate_shim(this: &MediaTrackCapabilities, val: &ULongRange);
49+
#[cfg(feature = "ULongRange")]
50+
#[wasm_bindgen(method, setter = "sampleSize")]
51+
fn sample_size_shim(this: &MediaTrackCapabilities, val: &ULongRange);
52+
#[cfg(feature = "ULongRange")]
53+
#[wasm_bindgen(method, setter = "width")]
54+
fn width_shim(this: &MediaTrackCapabilities, val: &ULongRange);
55+
}
56+
#[cfg(web_sys_unstable_apis)]
57+
impl MediaTrackCapabilities {
58+
#[doc = "Construct a new `MediaTrackCapabilities`."]
59+
#[doc = ""]
60+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`*"]
61+
#[doc = ""]
62+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
63+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
64+
pub fn new() -> Self {
65+
#[allow(unused_mut)]
66+
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
67+
ret
68+
}
69+
#[cfg(web_sys_unstable_apis)]
70+
#[cfg(feature = "DoubleRange")]
71+
#[doc = "Change the `aspectRatio` field of this object."]
72+
#[doc = ""]
73+
#[doc = "*This API requires the following crate features to be activated: `DoubleRange`, `MediaTrackCapabilities`*"]
74+
#[doc = ""]
75+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
76+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
77+
pub fn aspect_ratio(&mut self, val: &DoubleRange) -> &mut Self {
78+
self.aspect_ratio_shim(val);
79+
self
80+
}
81+
#[cfg(web_sys_unstable_apis)]
82+
#[doc = "Change the `autoGainControl` field of this object."]
83+
#[doc = ""]
84+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`*"]
85+
#[doc = ""]
86+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
87+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
88+
pub fn auto_gain_control(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
89+
self.auto_gain_control_shim(val);
90+
self
91+
}
92+
#[cfg(web_sys_unstable_apis)]
93+
#[cfg(feature = "ULongRange")]
94+
#[doc = "Change the `channelCount` field of this object."]
95+
#[doc = ""]
96+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`, `ULongRange`*"]
97+
#[doc = ""]
98+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
99+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
100+
pub fn channel_count(&mut self, val: &ULongRange) -> &mut Self {
101+
self.channel_count_shim(val);
102+
self
103+
}
104+
#[cfg(web_sys_unstable_apis)]
105+
#[doc = "Change the `deviceId` field of this object."]
106+
#[doc = ""]
107+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`*"]
108+
#[doc = ""]
109+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
110+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
111+
pub fn device_id(&mut self, val: &str) -> &mut Self {
112+
self.device_id_shim(val);
113+
self
114+
}
115+
#[cfg(web_sys_unstable_apis)]
116+
#[doc = "Change the `echoCancellation` field of this object."]
117+
#[doc = ""]
118+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`*"]
119+
#[doc = ""]
120+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
121+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
122+
pub fn echo_cancellation(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
123+
self.echo_cancellation_shim(val);
124+
self
125+
}
126+
#[cfg(web_sys_unstable_apis)]
127+
#[doc = "Change the `facingMode` field of this object."]
128+
#[doc = ""]
129+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`*"]
130+
#[doc = ""]
131+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
132+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
133+
pub fn facing_mode(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
134+
self.facing_mode_shim(val);
135+
self
136+
}
137+
#[cfg(web_sys_unstable_apis)]
138+
#[cfg(feature = "DoubleRange")]
139+
#[doc = "Change the `frameRate` field of this object."]
140+
#[doc = ""]
141+
#[doc = "*This API requires the following crate features to be activated: `DoubleRange`, `MediaTrackCapabilities`*"]
142+
#[doc = ""]
143+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
144+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
145+
pub fn frame_rate(&mut self, val: &DoubleRange) -> &mut Self {
146+
self.frame_rate_shim(val);
147+
self
148+
}
149+
#[cfg(web_sys_unstable_apis)]
150+
#[doc = "Change the `groupId` field of this object."]
151+
#[doc = ""]
152+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`*"]
153+
#[doc = ""]
154+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
155+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
156+
pub fn group_id(&mut self, val: &str) -> &mut Self {
157+
self.group_id_shim(val);
158+
self
159+
}
160+
#[cfg(web_sys_unstable_apis)]
161+
#[cfg(feature = "ULongRange")]
162+
#[doc = "Change the `height` field of this object."]
163+
#[doc = ""]
164+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`, `ULongRange`*"]
165+
#[doc = ""]
166+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
167+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
168+
pub fn height(&mut self, val: &ULongRange) -> &mut Self {
169+
self.height_shim(val);
170+
self
171+
}
172+
#[cfg(web_sys_unstable_apis)]
173+
#[cfg(feature = "DoubleRange")]
174+
#[doc = "Change the `latency` field of this object."]
175+
#[doc = ""]
176+
#[doc = "*This API requires the following crate features to be activated: `DoubleRange`, `MediaTrackCapabilities`*"]
177+
#[doc = ""]
178+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
179+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
180+
pub fn latency(&mut self, val: &DoubleRange) -> &mut Self {
181+
self.latency_shim(val);
182+
self
183+
}
184+
#[cfg(web_sys_unstable_apis)]
185+
#[doc = "Change the `noiseSuppression` field of this object."]
186+
#[doc = ""]
187+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`*"]
188+
#[doc = ""]
189+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
190+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
191+
pub fn noise_suppression(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
192+
self.noise_suppression_shim(val);
193+
self
194+
}
195+
#[cfg(web_sys_unstable_apis)]
196+
#[doc = "Change the `resizeMode` field of this object."]
197+
#[doc = ""]
198+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`*"]
199+
#[doc = ""]
200+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
201+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
202+
pub fn resize_mode(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
203+
self.resize_mode_shim(val);
204+
self
205+
}
206+
#[cfg(web_sys_unstable_apis)]
207+
#[cfg(feature = "ULongRange")]
208+
#[doc = "Change the `sampleRate` field of this object."]
209+
#[doc = ""]
210+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`, `ULongRange`*"]
211+
#[doc = ""]
212+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
213+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
214+
pub fn sample_rate(&mut self, val: &ULongRange) -> &mut Self {
215+
self.sample_rate_shim(val);
216+
self
217+
}
218+
#[cfg(web_sys_unstable_apis)]
219+
#[cfg(feature = "ULongRange")]
220+
#[doc = "Change the `sampleSize` field of this object."]
221+
#[doc = ""]
222+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`, `ULongRange`*"]
223+
#[doc = ""]
224+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
225+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
226+
pub fn sample_size(&mut self, val: &ULongRange) -> &mut Self {
227+
self.sample_size_shim(val);
228+
self
229+
}
230+
#[cfg(web_sys_unstable_apis)]
231+
#[cfg(feature = "ULongRange")]
232+
#[doc = "Change the `width` field of this object."]
233+
#[doc = ""]
234+
#[doc = "*This API requires the following crate features to be activated: `MediaTrackCapabilities`, `ULongRange`*"]
235+
#[doc = ""]
236+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
237+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
238+
pub fn width(&mut self, val: &ULongRange) -> &mut Self {
239+
self.width_shim(val);
240+
self
241+
}
242+
}
243+
#[cfg(web_sys_unstable_apis)]
244+
impl Default for MediaTrackCapabilities {
245+
fn default() -> Self {
246+
Self::new()
247+
}
248+
}

0 commit comments

Comments
 (0)