Skip to content

Commit 9beb4c3

Browse files
authored
Added experimental User-Agent Client Hints (#3989)
1 parent ad05ecc commit 9beb4c3

10 files changed

+484
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
* Add bindings for `queueMicrotask`.
3434
[#3981](https://github.com/rustwasm/wasm-bindgen/pull/3981)
3535

36+
* Add experimental bindings for User Agent Client Hints API
37+
[#3989](https://github.com/rustwasm/wasm-bindgen/pull/3989)
38+
3639
### Changed
3740

3841
* Stabilize Web Share API.

crates/web-sys/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,8 @@ NativeOsFileWriteAtomicOptions = []
875875
NavigationType = []
876876
Navigator = []
877877
NavigatorAutomationInformation = []
878+
NavigatorUaBrandVersion = []
879+
NavigatorUaData = []
878880
NetworkCommandOptions = []
879881
NetworkInformation = ["EventTarget"]
880882
NetworkResultOptions = []
@@ -1409,6 +1411,8 @@ TreeWalker = []
14091411
U2f = []
14101412
U2fClientData = []
14111413
ULongRange = []
1414+
UaDataValues = []
1415+
UaLowEntropyJson = []
14121416
UdpMessageEventInit = []
14131417
UdpOptions = []
14141418
UiEvent = ["Event"]

crates/web-sys/src/features/gen_Navigator.rs

+12
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,18 @@ extern "C" {
331331
#[doc = ""]
332332
#[doc = "*This API requires the following crate features to be activated: `Navigator`, `StorageManager`*"]
333333
pub fn storage(this: &Navigator) -> StorageManager;
334+
#[cfg(web_sys_unstable_apis)]
335+
#[cfg(feature = "NavigatorUaData")]
336+
# [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = userAgentData)]
337+
#[doc = "Getter for the `userAgentData` field of this object."]
338+
#[doc = ""]
339+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgentData)"]
340+
#[doc = ""]
341+
#[doc = "*This API requires the following crate features to be activated: `Navigator`, `NavigatorUaData`*"]
342+
#[doc = ""]
343+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
344+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
345+
pub fn user_agent_data(this: &Navigator) -> NavigatorUaData;
334346
# [wasm_bindgen (method , structural , js_class = "Navigator" , js_name = canShare)]
335347
#[doc = "The `canShare()` method."]
336348
#[doc = ""]
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 = NavigatorUABrandVersion)]
9+
#[derive(Debug, Clone, PartialEq, Eq)]
10+
#[doc = "The `NavigatorUaBrandVersion` dictionary."]
11+
#[doc = ""]
12+
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaBrandVersion`*"]
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 NavigatorUaBrandVersion;
17+
#[wasm_bindgen(method, setter = "brand")]
18+
fn brand_shim(this: &NavigatorUaBrandVersion, val: &str);
19+
#[wasm_bindgen(method, setter = "version")]
20+
fn version_shim(this: &NavigatorUaBrandVersion, val: &str);
21+
}
22+
#[cfg(web_sys_unstable_apis)]
23+
impl NavigatorUaBrandVersion {
24+
#[doc = "Construct a new `NavigatorUaBrandVersion`."]
25+
#[doc = ""]
26+
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaBrandVersion`*"]
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 `brand` field of this object."]
37+
#[doc = ""]
38+
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaBrandVersion`*"]
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 brand(&mut self, val: &str) -> &mut Self {
43+
self.brand_shim(val);
44+
self
45+
}
46+
#[cfg(web_sys_unstable_apis)]
47+
#[doc = "Change the `version` field of this object."]
48+
#[doc = ""]
49+
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaBrandVersion`*"]
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 version(&mut self, val: &str) -> &mut Self {
54+
self.version_shim(val);
55+
self
56+
}
57+
}
58+
#[cfg(web_sys_unstable_apis)]
59+
impl Default for NavigatorUaBrandVersion {
60+
fn default() -> Self {
61+
Self::new()
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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 = NavigatorUAData , typescript_type = "NavigatorUAData")]
9+
#[derive(Debug, Clone, PartialEq, Eq)]
10+
#[doc = "The `NavigatorUaData` class."]
11+
#[doc = ""]
12+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData)"]
13+
#[doc = ""]
14+
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaData`*"]
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 NavigatorUaData;
19+
#[cfg(web_sys_unstable_apis)]
20+
# [wasm_bindgen (structural , method , getter , js_class = "NavigatorUAData" , js_name = brands)]
21+
#[doc = "Getter for the `brands` field of this object."]
22+
#[doc = ""]
23+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/brands)"]
24+
#[doc = ""]
25+
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaData`*"]
26+
#[doc = ""]
27+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
28+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
29+
pub fn brands(this: &NavigatorUaData) -> ::js_sys::Array;
30+
#[cfg(web_sys_unstable_apis)]
31+
# [wasm_bindgen (structural , method , getter , js_class = "NavigatorUAData" , js_name = mobile)]
32+
#[doc = "Getter for the `mobile` field of this object."]
33+
#[doc = ""]
34+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/mobile)"]
35+
#[doc = ""]
36+
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaData`*"]
37+
#[doc = ""]
38+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
39+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
40+
pub fn mobile(this: &NavigatorUaData) -> bool;
41+
#[cfg(web_sys_unstable_apis)]
42+
# [wasm_bindgen (structural , method , getter , js_class = "NavigatorUAData" , js_name = platform)]
43+
#[doc = "Getter for the `platform` field of this object."]
44+
#[doc = ""]
45+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/platform)"]
46+
#[doc = ""]
47+
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaData`*"]
48+
#[doc = ""]
49+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
50+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
51+
pub fn platform(this: &NavigatorUaData) -> String;
52+
#[cfg(web_sys_unstable_apis)]
53+
# [wasm_bindgen (method , structural , js_class = "NavigatorUAData" , js_name = getHighEntropyValues)]
54+
#[doc = "The `getHighEntropyValues()` method."]
55+
#[doc = ""]
56+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/getHighEntropyValues)"]
57+
#[doc = ""]
58+
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaData`*"]
59+
#[doc = ""]
60+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
61+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
62+
pub fn get_high_entropy_values(
63+
this: &NavigatorUaData,
64+
hints: &::wasm_bindgen::JsValue,
65+
) -> ::js_sys::Promise;
66+
#[cfg(web_sys_unstable_apis)]
67+
#[cfg(feature = "UaLowEntropyJson")]
68+
# [wasm_bindgen (method , structural , js_class = "NavigatorUAData" , js_name = toJSON)]
69+
#[doc = "The `toJSON()` method."]
70+
#[doc = ""]
71+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/toJSON)"]
72+
#[doc = ""]
73+
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaData`, `UaLowEntropyJson`*"]
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 to_json(this: &NavigatorUaData) -> UaLowEntropyJson;
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
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 = UADataValues)]
9+
#[derive(Debug, Clone, PartialEq, Eq)]
10+
#[doc = "The `UaDataValues` dictionary."]
11+
#[doc = ""]
12+
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
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 UaDataValues;
17+
#[wasm_bindgen(method, setter = "architecture")]
18+
fn architecture_shim(this: &UaDataValues, val: &str);
19+
#[wasm_bindgen(method, setter = "bitness")]
20+
fn bitness_shim(this: &UaDataValues, val: &str);
21+
#[wasm_bindgen(method, setter = "brands")]
22+
fn brands_shim(this: &UaDataValues, val: &::wasm_bindgen::JsValue);
23+
#[wasm_bindgen(method, setter = "formFactors")]
24+
fn form_factors_shim(this: &UaDataValues, val: &::wasm_bindgen::JsValue);
25+
#[wasm_bindgen(method, setter = "fullVersionList")]
26+
fn full_version_list_shim(this: &UaDataValues, val: &::wasm_bindgen::JsValue);
27+
#[wasm_bindgen(method, setter = "mobile")]
28+
fn mobile_shim(this: &UaDataValues, val: bool);
29+
#[wasm_bindgen(method, setter = "model")]
30+
fn model_shim(this: &UaDataValues, val: &str);
31+
#[wasm_bindgen(method, setter = "platform")]
32+
fn platform_shim(this: &UaDataValues, val: &str);
33+
#[wasm_bindgen(method, setter = "platformVersion")]
34+
fn platform_version_shim(this: &UaDataValues, val: &str);
35+
#[wasm_bindgen(method, setter = "wow64")]
36+
fn wow64_shim(this: &UaDataValues, val: bool);
37+
}
38+
#[cfg(web_sys_unstable_apis)]
39+
impl UaDataValues {
40+
#[doc = "Construct a new `UaDataValues`."]
41+
#[doc = ""]
42+
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
43+
#[doc = ""]
44+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
45+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
46+
pub fn new() -> Self {
47+
#[allow(unused_mut)]
48+
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
49+
ret
50+
}
51+
#[cfg(web_sys_unstable_apis)]
52+
#[doc = "Change the `architecture` field of this object."]
53+
#[doc = ""]
54+
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
55+
#[doc = ""]
56+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
57+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
58+
pub fn architecture(&mut self, val: &str) -> &mut Self {
59+
self.architecture_shim(val);
60+
self
61+
}
62+
#[cfg(web_sys_unstable_apis)]
63+
#[doc = "Change the `bitness` field of this object."]
64+
#[doc = ""]
65+
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
66+
#[doc = ""]
67+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
68+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
69+
pub fn bitness(&mut self, val: &str) -> &mut Self {
70+
self.bitness_shim(val);
71+
self
72+
}
73+
#[cfg(web_sys_unstable_apis)]
74+
#[doc = "Change the `brands` field of this object."]
75+
#[doc = ""]
76+
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
77+
#[doc = ""]
78+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
79+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
80+
pub fn brands(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
81+
self.brands_shim(val);
82+
self
83+
}
84+
#[cfg(web_sys_unstable_apis)]
85+
#[doc = "Change the `formFactors` field of this object."]
86+
#[doc = ""]
87+
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
88+
#[doc = ""]
89+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
90+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
91+
pub fn form_factors(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
92+
self.form_factors_shim(val);
93+
self
94+
}
95+
#[cfg(web_sys_unstable_apis)]
96+
#[doc = "Change the `fullVersionList` field of this object."]
97+
#[doc = ""]
98+
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
99+
#[doc = ""]
100+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
101+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
102+
pub fn full_version_list(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
103+
self.full_version_list_shim(val);
104+
self
105+
}
106+
#[cfg(web_sys_unstable_apis)]
107+
#[doc = "Change the `mobile` field of this object."]
108+
#[doc = ""]
109+
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
110+
#[doc = ""]
111+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
112+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
113+
pub fn mobile(&mut self, val: bool) -> &mut Self {
114+
self.mobile_shim(val);
115+
self
116+
}
117+
#[cfg(web_sys_unstable_apis)]
118+
#[doc = "Change the `model` field of this object."]
119+
#[doc = ""]
120+
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
121+
#[doc = ""]
122+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
123+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
124+
pub fn model(&mut self, val: &str) -> &mut Self {
125+
self.model_shim(val);
126+
self
127+
}
128+
#[cfg(web_sys_unstable_apis)]
129+
#[doc = "Change the `platform` field of this object."]
130+
#[doc = ""]
131+
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
132+
#[doc = ""]
133+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
134+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
135+
pub fn platform(&mut self, val: &str) -> &mut Self {
136+
self.platform_shim(val);
137+
self
138+
}
139+
#[cfg(web_sys_unstable_apis)]
140+
#[doc = "Change the `platformVersion` field of this object."]
141+
#[doc = ""]
142+
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
143+
#[doc = ""]
144+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
145+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
146+
pub fn platform_version(&mut self, val: &str) -> &mut Self {
147+
self.platform_version_shim(val);
148+
self
149+
}
150+
#[cfg(web_sys_unstable_apis)]
151+
#[doc = "Change the `wow64` field of this object."]
152+
#[doc = ""]
153+
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
154+
#[doc = ""]
155+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
156+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
157+
pub fn wow64(&mut self, val: bool) -> &mut Self {
158+
self.wow64_shim(val);
159+
self
160+
}
161+
}
162+
#[cfg(web_sys_unstable_apis)]
163+
impl Default for UaDataValues {
164+
fn default() -> Self {
165+
Self::new()
166+
}
167+
}

0 commit comments

Comments
 (0)