diff --git a/CHANGELOG.md b/CHANGELOG.md index 536b2a8ba64..a8363df0a58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ ### Added +* Add bindings for the Web Locks API to `web-sys`. + [#3604](https://github.com/rustwasm/wasm-bindgen/pull/3604) + * Add bindings for `ViewTransition` to `web-sys`. [#3598](https://github.com/rustwasm/wasm-bindgen/pull/3598) diff --git a/crates/web-sys/Cargo.toml b/crates/web-sys/Cargo.toml index 576d1adb0b8..6b319f5e4e4 100644 --- a/crates/web-sys/Cargo.toml +++ b/crates/web-sys/Cargo.toml @@ -757,6 +757,12 @@ ListBoxObject = [] LocalMediaStream = ["EventTarget", "MediaStream"] LocaleInfo = [] Location = [] +Lock = [] +LockInfo = [] +LockManager = [] +LockManagerSnapshot = [] +LockMode = [] +LockOptions = [] MediaCapabilities = [] MediaCapabilitiesInfo = [] MediaConfiguration = [] diff --git a/crates/web-sys/src/features/gen_Lock.rs b/crates/web-sys/src/features/gen_Lock.rs new file mode 100644 index 00000000000..98b93739a91 --- /dev/null +++ b/crates/web-sys/src/features/gen_Lock.rs @@ -0,0 +1,42 @@ +#![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 = Lock , typescript_type = "Lock")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `Lock` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Lock)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Lock`*"] + #[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 Lock; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , getter , js_class = "Lock" , js_name = name)] + #[doc = "Getter for the `name` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Lock/name)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Lock`*"] + #[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 name(this: &Lock) -> String; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "LockMode")] + # [wasm_bindgen (structural , method , getter , js_class = "Lock" , js_name = mode)] + #[doc = "Getter for the `mode` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Lock/mode)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Lock`, `LockMode`*"] + #[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 mode(this: &Lock) -> LockMode; +} diff --git a/crates/web-sys/src/features/gen_LockInfo.rs b/crates/web-sys/src/features/gen_LockInfo.rs new file mode 100644 index 00000000000..d9ea0f7ec87 --- /dev/null +++ b/crates/web-sys/src/features/gen_LockInfo.rs @@ -0,0 +1,93 @@ +#![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 = LockInfo)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `LockInfo` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockInfo`*"] + #[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 LockInfo; +} +#[cfg(web_sys_unstable_apis)] +impl LockInfo { + #[doc = "Construct a new `LockInfo`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockInfo`*"] + #[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 `clientId` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockInfo`*"] + #[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 client_id(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("clientId"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "LockMode")] + #[doc = "Change the `mode` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockInfo`, `LockMode`*"] + #[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 mode(&mut self, val: LockMode) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("mode"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `name` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockInfo`*"] + #[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 name(&mut self, val: &str) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("name"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} +#[cfg(web_sys_unstable_apis)] +impl Default for LockInfo { + fn default() -> Self { + Self::new() + } +} diff --git a/crates/web-sys/src/features/gen_LockManager.rs b/crates/web-sys/src/features/gen_LockManager.rs new file mode 100644 index 00000000000..d1d52894863 --- /dev/null +++ b/crates/web-sys/src/features/gen_LockManager.rs @@ -0,0 +1,62 @@ +#![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 = LockManager , typescript_type = "LockManager")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `LockManager` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/LockManager)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockManager`*"] + #[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 LockManager; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (method , structural , js_class = "LockManager" , js_name = query)] + #[doc = "The `query()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/LockManager/query)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockManager`*"] + #[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 query(this: &LockManager) -> ::js_sys::Promise; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (method , structural , js_class = "LockManager" , js_name = request)] + #[doc = "The `request()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockManager`*"] + #[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 request_with_callback( + this: &LockManager, + name: &str, + callback: &::js_sys::Function, + ) -> ::js_sys::Promise; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "LockOptions")] + # [wasm_bindgen (method , structural , js_class = "LockManager" , js_name = request)] + #[doc = "The `request()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockManager`, `LockOptions`*"] + #[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 request_with_options_and_callback( + this: &LockManager, + name: &str, + options: &LockOptions, + callback: &::js_sys::Function, + ) -> ::js_sys::Promise; +} diff --git a/crates/web-sys/src/features/gen_LockManagerSnapshot.rs b/crates/web-sys/src/features/gen_LockManagerSnapshot.rs new file mode 100644 index 00000000000..87d1eed1670 --- /dev/null +++ b/crates/web-sys/src/features/gen_LockManagerSnapshot.rs @@ -0,0 +1,75 @@ +#![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 = LockManagerSnapshot)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `LockManagerSnapshot` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockManagerSnapshot`*"] + #[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 LockManagerSnapshot; +} +#[cfg(web_sys_unstable_apis)] +impl LockManagerSnapshot { + #[doc = "Construct a new `LockManagerSnapshot`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockManagerSnapshot`*"] + #[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 `held` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockManagerSnapshot`*"] + #[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 held(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("held"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `pending` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockManagerSnapshot`*"] + #[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 pending(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("pending"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} +#[cfg(web_sys_unstable_apis)] +impl Default for LockManagerSnapshot { + fn default() -> Self { + Self::new() + } +} diff --git a/crates/web-sys/src/features/gen_LockMode.rs b/crates/web-sys/src/features/gen_LockMode.rs new file mode 100644 index 00000000000..18459e67ec1 --- /dev/null +++ b/crates/web-sys/src/features/gen_LockMode.rs @@ -0,0 +1,16 @@ +#![allow(unused_imports)] +#![allow(clippy::all)] +use wasm_bindgen::prelude::*; +#[cfg(web_sys_unstable_apis)] +#[wasm_bindgen] +#[doc = "The `LockMode` enum."] +#[doc = ""] +#[doc = "*This API requires the following crate features to be activated: `LockMode`*"] +#[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)*"] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum LockMode { + Shared = "shared", + Exclusive = "exclusive", +} diff --git a/crates/web-sys/src/features/gen_LockOptions.rs b/crates/web-sys/src/features/gen_LockOptions.rs new file mode 100644 index 00000000000..27131f050d3 --- /dev/null +++ b/crates/web-sys/src/features/gen_LockOptions.rs @@ -0,0 +1,112 @@ +#![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 = LockOptions)] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `LockOptions` dictionary."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockOptions`*"] + #[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 LockOptions; +} +#[cfg(web_sys_unstable_apis)] +impl LockOptions { + #[doc = "Construct a new `LockOptions`."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockOptions`*"] + #[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 `ifAvailable` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockOptions`*"] + #[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 if_available(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set( + self.as_ref(), + &JsValue::from("ifAvailable"), + &JsValue::from(val), + ); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "LockMode")] + #[doc = "Change the `mode` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockMode`, `LockOptions`*"] + #[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 mode(&mut self, val: LockMode) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("mode"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "AbortSignal")] + #[doc = "Change the `signal` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `AbortSignal`, `LockOptions`*"] + #[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 signal(&mut self, val: &AbortSignal) -> &mut Self { + use wasm_bindgen::JsValue; + let r = + ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("signal"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } + #[cfg(web_sys_unstable_apis)] + #[doc = "Change the `steal` field of this object."] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockOptions`*"] + #[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 steal(&mut self, val: bool) -> &mut Self { + use wasm_bindgen::JsValue; + let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("steal"), &JsValue::from(val)); + debug_assert!( + r.is_ok(), + "setting properties should never fail on our dictionary objects" + ); + let _ = r; + self + } +} +#[cfg(web_sys_unstable_apis)] +impl Default for LockOptions { + fn default() -> Self { + Self::new() + } +} diff --git a/crates/web-sys/src/features/gen_Navigator.rs b/crates/web-sys/src/features/gen_Navigator.rs index dbd6fad8961..17197347dce 100644 --- a/crates/web-sys/src/features/gen_Navigator.rs +++ b/crates/web-sys/src/features/gen_Navigator.rs @@ -296,6 +296,18 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `Navigator`*"] pub fn languages(this: &Navigator) -> ::js_sys::Array; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "LockManager")] + # [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = locks)] + #[doc = "Getter for the `locks` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/locks)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockManager`, `Navigator`*"] + #[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 locks(this: &Navigator) -> LockManager; # [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = onLine)] #[doc = "Getter for the `onLine` field of this object."] #[doc = ""] diff --git a/crates/web-sys/src/features/gen_WorkerNavigator.rs b/crates/web-sys/src/features/gen_WorkerNavigator.rs index e1038bda317..dc9fdf19315 100644 --- a/crates/web-sys/src/features/gen_WorkerNavigator.rs +++ b/crates/web-sys/src/features/gen_WorkerNavigator.rs @@ -127,6 +127,18 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `WorkerNavigator`*"] pub fn languages(this: &WorkerNavigator) -> ::js_sys::Array; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "LockManager")] + # [wasm_bindgen (structural , method , getter , js_class = "WorkerNavigator" , js_name = locks)] + #[doc = "Getter for the `locks` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WorkerNavigator/locks)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `LockManager`, `WorkerNavigator`*"] + #[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 locks(this: &WorkerNavigator) -> LockManager; # [wasm_bindgen (structural , method , getter , js_class = "WorkerNavigator" , js_name = onLine)] #[doc = "Getter for the `onLine` field of this object."] #[doc = ""] diff --git a/crates/web-sys/src/features/mod.rs b/crates/web-sys/src/features/mod.rs index e02ad43ad3e..9a3bb1d99c1 100644 --- a/crates/web-sys/src/features/mod.rs +++ b/crates/web-sys/src/features/mod.rs @@ -4354,6 +4354,42 @@ mod gen_Location; #[cfg(feature = "Location")] pub use gen_Location::*; +#[cfg(feature = "Lock")] +#[allow(non_snake_case)] +mod gen_Lock; +#[cfg(feature = "Lock")] +pub use gen_Lock::*; + +#[cfg(feature = "LockInfo")] +#[allow(non_snake_case)] +mod gen_LockInfo; +#[cfg(feature = "LockInfo")] +pub use gen_LockInfo::*; + +#[cfg(feature = "LockManager")] +#[allow(non_snake_case)] +mod gen_LockManager; +#[cfg(feature = "LockManager")] +pub use gen_LockManager::*; + +#[cfg(feature = "LockManagerSnapshot")] +#[allow(non_snake_case)] +mod gen_LockManagerSnapshot; +#[cfg(feature = "LockManagerSnapshot")] +pub use gen_LockManagerSnapshot::*; + +#[cfg(feature = "LockMode")] +#[allow(non_snake_case)] +mod gen_LockMode; +#[cfg(feature = "LockMode")] +pub use gen_LockMode::*; + +#[cfg(feature = "LockOptions")] +#[allow(non_snake_case)] +mod gen_LockOptions; +#[cfg(feature = "LockOptions")] +pub use gen_LockOptions::*; + #[cfg(feature = "MediaCapabilities")] #[allow(non_snake_case)] mod gen_MediaCapabilities; diff --git a/crates/web-sys/webidls/unstable/weblock-apis.webidl b/crates/web-sys/webidls/unstable/weblock-apis.webidl new file mode 100644 index 00000000000..14bc3a22cc3 --- /dev/null +++ b/crates/web-sys/webidls/unstable/weblock-apis.webidl @@ -0,0 +1,45 @@ +[SecureContext] +interface mixin NavigatorLocks { + readonly attribute LockManager locks; +}; +Navigator includes NavigatorLocks; +WorkerNavigator includes NavigatorLocks; + +[SecureContext, Exposed=(Window,Worker)] +interface LockManager { + Promise request(DOMString name, + LockGrantedCallback callback); + Promise request(DOMString name, + LockOptions options, + LockGrantedCallback callback); + + Promise query(); +}; + +callback LockGrantedCallback = Promise (Lock? lock); + +enum LockMode { "shared", "exclusive" }; + +dictionary LockOptions { + LockMode mode = "exclusive"; + boolean ifAvailable = false; + boolean steal = false; + AbortSignal signal; +}; + +dictionary LockManagerSnapshot { + sequence held; + sequence pending; +}; + +dictionary LockInfo { + DOMString name; + LockMode mode; + DOMString clientId; +}; + +[SecureContext, Exposed=(Window,Worker)] +interface Lock { + readonly attribute DOMString name; + readonly attribute LockMode mode; +};