From 8a7cedff020bc589e61ec0906d8a9e27cfe8d0d5 Mon Sep 17 00:00:00 2001 From: Leonard Date: Wed, 6 Sep 2023 21:39:10 +0200 Subject: [PATCH 1/3] Add experimental `ViewTransition` interface --- crates/web-sys/Cargo.toml | 1 + crates/web-sys/src/features/gen_Document.rs | 27 ++++++++ .../src/features/gen_ViewTransition.rs | 63 +++++++++++++++++++ crates/web-sys/src/features/mod.rs | 6 ++ .../webidls/unstable/ViewTransition.webidl | 15 +++++ 5 files changed, 112 insertions(+) create mode 100644 crates/web-sys/src/features/gen_ViewTransition.rs create mode 100644 crates/web-sys/webidls/unstable/ViewTransition.webidl diff --git a/crates/web-sys/Cargo.toml b/crates/web-sys/Cargo.toml index ab52e7a142f..41fb34deb51 100644 --- a/crates/web-sys/Cargo.toml +++ b/crates/web-sys/Cargo.toml @@ -1433,6 +1433,7 @@ UserVerificationRequirement = [] ValidityState = [] ValueEvent = ["Event"] ValueEventInit = [] +ViewTransition = [] VideoColorPrimaries = [] VideoColorSpace = [] VideoColorSpaceInit = [] diff --git a/crates/web-sys/src/features/gen_Document.rs b/crates/web-sys/src/features/gen_Document.rs index d2ad9eb374f..b910b43c3e8 100644 --- a/crates/web-sys/src/features/gen_Document.rs +++ b/crates/web-sys/src/features/gen_Document.rs @@ -2155,6 +2155,33 @@ extern "C" { #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `Document`*"] pub fn release_capture(this: &Document); + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "ViewTransition")] + # [wasm_bindgen (catch , method , structural , js_class = "Document" , js_name = startViewTransition)] + #[doc = "The `startViewTransition()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Document`, `ViewTransition`*"] + #[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 start_view_transition(this: &Document) -> Result; + #[cfg(web_sys_unstable_apis)] + #[cfg(feature = "ViewTransition")] + # [wasm_bindgen (catch , method , structural , js_class = "Document" , js_name = startViewTransition)] + #[doc = "The `startViewTransition()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `Document`, `ViewTransition`*"] + #[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 start_view_transition_with_update_callback( + this: &Document, + update_callback: Option<&::js_sys::Function>, + ) -> Result; #[cfg(feature = "Element")] # [wasm_bindgen (method , structural , js_class = "Document" , js_name = elementFromPoint)] #[doc = "The `elementFromPoint()` method."] diff --git a/crates/web-sys/src/features/gen_ViewTransition.rs b/crates/web-sys/src/features/gen_ViewTransition.rs new file mode 100644 index 00000000000..aa8f5ae1ef4 --- /dev/null +++ b/crates/web-sys/src/features/gen_ViewTransition.rs @@ -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 = ViewTransition , typescript_type = "ViewTransition")] + #[derive(Debug, Clone, PartialEq, Eq)] + #[doc = "The `ViewTransition` class."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `ViewTransition`*"] + #[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 ViewTransition; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , getter , js_class = "ViewTransition" , js_name = updateCallbackDone)] + #[doc = "Getter for the `updateCallbackDone` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/updateCallbackDone)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `ViewTransition`*"] + #[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 update_callback_done(this: &ViewTransition) -> ::js_sys::Promise; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , getter , js_class = "ViewTransition" , js_name = ready)] + #[doc = "Getter for the `ready` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/ready)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `ViewTransition`*"] + #[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 ready(this: &ViewTransition) -> ::js_sys::Promise; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (structural , method , getter , js_class = "ViewTransition" , js_name = finished)] + #[doc = "Getter for the `finished` field of this object."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/finished)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `ViewTransition`*"] + #[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 finished(this: &ViewTransition) -> ::js_sys::Promise; + #[cfg(web_sys_unstable_apis)] + # [wasm_bindgen (catch , method , structural , js_class = "ViewTransition" , js_name = skipTransition)] + #[doc = "The `skipTransition()` method."] + #[doc = ""] + #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/skipTransition)"] + #[doc = ""] + #[doc = "*This API requires the following crate features to be activated: `ViewTransition`*"] + #[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 skip_transition(this: &ViewTransition) -> Result<(), JsValue>; +} diff --git a/crates/web-sys/src/features/mod.rs b/crates/web-sys/src/features/mod.rs index 3e0f90fd6a4..e02ad43ad3e 100644 --- a/crates/web-sys/src/features/mod.rs +++ b/crates/web-sys/src/features/mod.rs @@ -8560,6 +8560,12 @@ mod gen_VideoTransferCharacteristics; #[cfg(feature = "VideoTransferCharacteristics")] pub use gen_VideoTransferCharacteristics::*; +#[cfg(feature = "ViewTransition")] +#[allow(non_snake_case)] +mod gen_ViewTransition; +#[cfg(feature = "ViewTransition")] +pub use gen_ViewTransition::*; + #[cfg(feature = "VisibilityState")] #[allow(non_snake_case)] mod gen_VisibilityState; diff --git a/crates/web-sys/webidls/unstable/ViewTransition.webidl b/crates/web-sys/webidls/unstable/ViewTransition.webidl new file mode 100644 index 00000000000..3f84c572497 --- /dev/null +++ b/crates/web-sys/webidls/unstable/ViewTransition.webidl @@ -0,0 +1,15 @@ +partial interface Document { + [Throws] + ViewTransition startViewTransition(optional UpdateCallback? updateCallback = null); +}; + +callback UpdateCallback = Promise (); + +[Exposed=Window] +interface ViewTransition { + readonly attribute Promise updateCallbackDone; + readonly attribute Promise ready; + readonly attribute Promise finished; + [Throws] + undefined skipTransition(); +}; From f97b93e6455321ba7cac3e55384a1137d51d06ce Mon Sep 17 00:00:00 2001 From: Leonard Date: Wed, 6 Sep 2023 21:50:43 +0200 Subject: [PATCH 2/3] Fix ViewTransition feature location --- crates/web-sys/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/web-sys/Cargo.toml b/crates/web-sys/Cargo.toml index 41fb34deb51..576d1adb0b8 100644 --- a/crates/web-sys/Cargo.toml +++ b/crates/web-sys/Cargo.toml @@ -1433,7 +1433,6 @@ UserVerificationRequirement = [] ValidityState = [] ValueEvent = ["Event"] ValueEventInit = [] -ViewTransition = [] VideoColorPrimaries = [] VideoColorSpace = [] VideoColorSpaceInit = [] @@ -1459,6 +1458,7 @@ VideoStreamTrack = ["EventTarget", "MediaStreamTrack"] VideoTrack = [] VideoTrackList = ["EventTarget"] VideoTransferCharacteristics = [] +ViewTransition = [] VisibilityState = [] VoidCallback = [] VrDisplay = ["EventTarget"] From ca20ee48ec9816ea9985b46374db365fb7e713d8 Mon Sep 17 00:00:00 2001 From: Leonard Date: Thu, 7 Sep 2023 20:27:03 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a12d912268..648da5d8aac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ ### Added +* Add bindings for `ViewTransition` to `web-sys`. + [#3598](https://github.com/rustwasm/wasm-bindgen/pull/3598) + * Extend `AudioContext` with unstable features supporting audio sink configuration. [#3433](https://github.com/rustwasm/wasm-bindgen/pull/3433)