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

Add experimental ViewTransition interface #3598

Merged
merged 3 commits into from
Sep 7, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,7 @@ VideoStreamTrack = ["EventTarget", "MediaStreamTrack"]
VideoTrack = []
VideoTrackList = ["EventTarget"]
VideoTransferCharacteristics = []
ViewTransition = []
VisibilityState = []
VoidCallback = []
VrDisplay = ["EventTarget"]
Expand Down
27 changes: 27 additions & 0 deletions crates/web-sys/src/features/gen_Document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ViewTransition, JsValue>;
#[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<ViewTransition, JsValue>;
#[cfg(feature = "Element")]
# [wasm_bindgen (method , structural , js_class = "Document" , js_name = elementFromPoint)]
#[doc = "The `elementFromPoint()` method."]
Expand Down
63 changes: 63 additions & 0 deletions crates/web-sys/src/features/gen_ViewTransition.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 = 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>;
}
6 changes: 6 additions & 0 deletions crates/web-sys/src/features/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions crates/web-sys/webidls/unstable/ViewTransition.webidl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
partial interface Document {
[Throws]
ViewTransition startViewTransition(optional UpdateCallback? updateCallback = null);
};

callback UpdateCallback = Promise<any> ();

[Exposed=Window]
interface ViewTransition {
readonly attribute Promise<undefined> updateCallbackDone;
readonly attribute Promise<undefined> ready;
readonly attribute Promise<undefined> finished;
[Throws]
undefined skipTransition();
};