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

Updated Notification APIs #3667

Merged
merged 8 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,29 @@
proc-macro and accept the `--include-ignored` flag with `wasm-bindgen-test-runner`.
[#3644](https://github.com/rustwasm/wasm-bindgen/pull/3644)

* Added `Notification` fields
[#3667](https://github.com/rustwasm/wasm-bindgen/pull/3667)
* `max_actions`
* `image`
* `badge`
* `vibrate`
* `timestamp`
* `renotify`
* `silent`
* `actions`

* Added `NotificationOptions` fields
[#3667](https://github.com/rustwasm/wasm-bindgen/pull/3667)
* `image`
* `badge`
* `timestamp`
* `renotify`
* `silent`
* `actions`

* Added `NotificationAction`
[#3667](https://github.com/rustwasm/wasm-bindgen/pull/3667)
maccesch marked this conversation as resolved.
Show resolved Hide resolved

### Changed

* Updated the WebGPU WebIDL.
Expand Down Expand Up @@ -154,6 +177,9 @@
* Removed `ReadableStreamByobReader::read_with_u8_array()` because it doesn't work with Wasm.
[#3582](https://github.com/rustwasm/wasm-bindgen/pull/3582)

* Removed `GetNotificationOptions`, `NotificationBehavior` and `Notification.get()` because
they don't exist anymore.

## [0.2.87](https://github.com/rustwasm/wasm-bindgen/compare/0.2.86...0.2.87)

Released 2023-06-12.
Expand Down
3 changes: 1 addition & 2 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ GamepadPose = []
GamepadServiceTest = []
Geolocation = []
GetAnimationsOptions = []
GetNotificationOptions = []
GetRootNodeOptions = []
GetUserMediaRequest = []
Gpu = []
Expand Down Expand Up @@ -880,7 +879,7 @@ NodeFilter = []
NodeIterator = []
NodeList = []
Notification = ["EventTarget"]
NotificationBehavior = []
NotificationAction = []
NotificationDirection = []
NotificationEvent = ["Event", "ExtendableEvent"]
NotificationEventInit = []
Expand Down
41 changes: 0 additions & 41 deletions crates/web-sys/src/features/gen_GetNotificationOptions.rs

This file was deleted.

71 changes: 56 additions & 15 deletions crates/web-sys/src/features/gen_Notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`, `NotificationPermission`*"]
pub fn permission() -> NotificationPermission;
# [wasm_bindgen (structural , static_method_of = Notification , getter , js_class = "Notification" , js_name = maxActions)]
#[doc = "Getter for the `maxActions` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/maxActions)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`*"]
pub fn max_actions() -> u32;
# [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = onclick)]
#[doc = "Getter for the `onclick` field of this object."]
#[doc = ""]
Expand Down Expand Up @@ -112,13 +119,55 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`*"]
pub fn tag(this: &Notification) -> Option<String>;
# [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = image)]
#[doc = "Getter for the `image` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/image)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`*"]
pub fn image(this: &Notification) -> String;
# [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = icon)]
#[doc = "Getter for the `icon` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/icon)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`*"]
pub fn icon(this: &Notification) -> Option<String>;
# [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = badge)]
#[doc = "Getter for the `badge` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/badge)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`*"]
pub fn badge(this: &Notification) -> String;
# [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = vibrate)]
#[doc = "Getter for the `vibrate` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/vibrate)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`*"]
pub fn vibrate(this: &Notification) -> ::js_sys::Array;
# [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = timestamp)]
#[doc = "Getter for the `timestamp` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/timestamp)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`*"]
pub fn timestamp(this: &Notification) -> f64;
# [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = renotify)]
#[doc = "Getter for the `renotify` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/renotify)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`*"]
pub fn renotify(this: &Notification) -> bool;
# [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = silent)]
#[doc = "Getter for the `silent` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/silent)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`*"]
pub fn silent(this: &Notification) -> Option<bool>;
# [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = requireInteraction)]
#[doc = "Getter for the `requireInteraction` field of this object."]
#[doc = ""]
Expand All @@ -133,6 +182,13 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`*"]
pub fn data(this: &Notification) -> ::wasm_bindgen::JsValue;
# [wasm_bindgen (structural , method , getter , js_class = "Notification" , js_name = actions)]
#[doc = "Getter for the `actions` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/actions)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`*"]
pub fn actions(this: &Notification) -> ::js_sys::Array;
#[wasm_bindgen(catch, constructor, js_class = "Notification")]
#[doc = "The `new Notification(..)` constructor, creating a new instance of `Notification`."]
#[doc = ""]
Expand All @@ -158,21 +214,6 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`*"]
pub fn close(this: &Notification);
# [wasm_bindgen (catch , static_method_of = Notification , js_class = "Notification" , js_name = get)]
#[doc = "The `get()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/get)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Notification`*"]
pub fn get() -> Result<::js_sys::Promise, JsValue>;
#[cfg(feature = "GetNotificationOptions")]
# [wasm_bindgen (catch , static_method_of = Notification , js_class = "Notification" , js_name = get)]
#[doc = "The `get()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Notification/get)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `GetNotificationOptions`, `Notification`*"]
pub fn get_with_filter(filter: &GetNotificationOptions) -> Result<::js_sys::Promise, JsValue>;
# [wasm_bindgen (catch , static_method_of = Notification , js_class = "Notification" , js_name = requestPermission)]
#[doc = "The `requestPermission()` method."]
#[doc = ""]
Expand Down
65 changes: 65 additions & 0 deletions crates/web-sys/src/features/gen_NotificationAction.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = NotificationAction)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `NotificationAction` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"]
pub type NotificationAction;
}
impl NotificationAction {
#[doc = "Construct a new `NotificationAction`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"]
pub fn new(action: &str, title: &str) -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret.action(action);
ret.title(title);
ret
}
#[doc = "Change the `action` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"]
pub fn action(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r =
::js_sys::Reflect::set(self.as_ref(), &JsValue::from("action"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `icon` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"]
pub fn icon(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("icon"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[doc = "Change the `title` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `NotificationAction`*"]
pub fn title(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("title"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
113 changes: 0 additions & 113 deletions crates/web-sys/src/features/gen_NotificationBehavior.rs

This file was deleted.