Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added experimental User-Agent Client Hints #3989

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
* Add bindings for `queueMicrotask`.
[#3981](https://github.com/rustwasm/wasm-bindgen/pull/3981)

* Add experimental bindings for User Agent Client Hints API
[#3989](https://github.com/rustwasm/wasm-bindgen/pull/3989)

### Changed

* Stabilize Web Share API.
Expand Down
4 changes: 4 additions & 0 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,8 @@ NativeOsFileWriteAtomicOptions = []
NavigationType = []
Navigator = []
NavigatorAutomationInformation = []
NavigatorUaBrandVersion = []
NavigatorUaData = []
NetworkCommandOptions = []
NetworkInformation = ["EventTarget"]
NetworkResultOptions = []
Expand Down Expand Up @@ -1409,6 +1411,8 @@ TreeWalker = []
U2f = []
U2fClientData = []
ULongRange = []
UaDataValues = []
UaLowEntropyJson = []
UdpMessageEventInit = []
UdpOptions = []
UiEvent = ["Event"]
Expand Down
12 changes: 12 additions & 0 deletions crates/web-sys/src/features/gen_Navigator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,18 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Navigator`, `StorageManager`*"]
pub fn storage(this: &Navigator) -> StorageManager;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "NavigatorUaData")]
# [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = userAgentData)]
#[doc = "Getter for the `userAgentData` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgentData)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Navigator`, `NavigatorUaData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn user_agent_data(this: &Navigator) -> NavigatorUaData;
# [wasm_bindgen (method , structural , js_class = "Navigator" , js_name = canShare)]
#[doc = "The `canShare()` method."]
#[doc = ""]
Expand Down
63 changes: 63 additions & 0 deletions crates/web-sys/src/features/gen_NavigatorUaBrandVersion.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = NavigatorUABrandVersion)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `NavigatorUaBrandVersion` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaBrandVersion`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub type NavigatorUaBrandVersion;
#[wasm_bindgen(method, setter = "brand")]
fn brand_shim(this: &NavigatorUaBrandVersion, val: &str);
#[wasm_bindgen(method, setter = "version")]
fn version_shim(this: &NavigatorUaBrandVersion, val: &str);
}
#[cfg(web_sys_unstable_apis)]
impl NavigatorUaBrandVersion {
#[doc = "Construct a new `NavigatorUaBrandVersion`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaBrandVersion`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn new() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `brand` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaBrandVersion`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn brand(&mut self, val: &str) -> &mut Self {
self.brand_shim(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `version` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaBrandVersion`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn version(&mut self, val: &str) -> &mut Self {
self.version_shim(val);
self
}
}
#[cfg(web_sys_unstable_apis)]
impl Default for NavigatorUaBrandVersion {
fn default() -> Self {
Self::new()
}
}
78 changes: 78 additions & 0 deletions crates/web-sys/src/features/gen_NavigatorUaData.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = NavigatorUAData , typescript_type = "NavigatorUAData")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `NavigatorUaData` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub type NavigatorUaData;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "NavigatorUAData" , js_name = brands)]
#[doc = "Getter for the `brands` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/brands)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn brands(this: &NavigatorUaData) -> ::js_sys::Array;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "NavigatorUAData" , js_name = mobile)]
#[doc = "Getter for the `mobile` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/mobile)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn mobile(this: &NavigatorUaData) -> bool;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (structural , method , getter , js_class = "NavigatorUAData" , js_name = platform)]
#[doc = "Getter for the `platform` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/platform)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn platform(this: &NavigatorUaData) -> String;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "NavigatorUAData" , js_name = getHighEntropyValues)]
#[doc = "The `getHighEntropyValues()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/getHighEntropyValues)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaData`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn get_high_entropy_values(
this: &NavigatorUaData,
hints: &::wasm_bindgen::JsValue,
) -> ::js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "UaLowEntropyJson")]
# [wasm_bindgen (method , structural , js_class = "NavigatorUAData" , js_name = toJSON)]
#[doc = "The `toJSON()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/toJSON)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NavigatorUaData`, `UaLowEntropyJson`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn to_json(this: &NavigatorUaData) -> UaLowEntropyJson;
}
167 changes: 167 additions & 0 deletions crates/web-sys/src/features/gen_UaDataValues.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = UADataValues)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `UaDataValues` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub type UaDataValues;
#[wasm_bindgen(method, setter = "architecture")]
fn architecture_shim(this: &UaDataValues, val: &str);
#[wasm_bindgen(method, setter = "bitness")]
fn bitness_shim(this: &UaDataValues, val: &str);
#[wasm_bindgen(method, setter = "brands")]
fn brands_shim(this: &UaDataValues, val: &::wasm_bindgen::JsValue);
#[wasm_bindgen(method, setter = "formFactors")]
fn form_factors_shim(this: &UaDataValues, val: &::wasm_bindgen::JsValue);
#[wasm_bindgen(method, setter = "fullVersionList")]
fn full_version_list_shim(this: &UaDataValues, val: &::wasm_bindgen::JsValue);
#[wasm_bindgen(method, setter = "mobile")]
fn mobile_shim(this: &UaDataValues, val: bool);
#[wasm_bindgen(method, setter = "model")]
fn model_shim(this: &UaDataValues, val: &str);
#[wasm_bindgen(method, setter = "platform")]
fn platform_shim(this: &UaDataValues, val: &str);
#[wasm_bindgen(method, setter = "platformVersion")]
fn platform_version_shim(this: &UaDataValues, val: &str);
#[wasm_bindgen(method, setter = "wow64")]
fn wow64_shim(this: &UaDataValues, val: bool);
}
#[cfg(web_sys_unstable_apis)]
impl UaDataValues {
#[doc = "Construct a new `UaDataValues`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn new() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `architecture` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn architecture(&mut self, val: &str) -> &mut Self {
self.architecture_shim(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `bitness` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn bitness(&mut self, val: &str) -> &mut Self {
self.bitness_shim(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `brands` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn brands(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
self.brands_shim(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `formFactors` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn form_factors(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
self.form_factors_shim(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `fullVersionList` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn full_version_list(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
self.full_version_list_shim(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `mobile` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn mobile(&mut self, val: bool) -> &mut Self {
self.mobile_shim(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `model` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn model(&mut self, val: &str) -> &mut Self {
self.model_shim(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `platform` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn platform(&mut self, val: &str) -> &mut Self {
self.platform_shim(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `platformVersion` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn platform_version(&mut self, val: &str) -> &mut Self {
self.platform_version_shim(val);
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `wow64` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `UaDataValues`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn wow64(&mut self, val: bool) -> &mut Self {
self.wow64_shim(val);
self
}
}
#[cfg(web_sys_unstable_apis)]
impl Default for UaDataValues {
fn default() -> Self {
Self::new()
}
}
Loading