Skip to content

Commit

Permalink
Updated Notification APIs (#3667)
Browse files Browse the repository at this point in the history
* Updated Notification APIs

* Updated Notification APIs

* Update crates/web-sys/webidls/enabled/Notification.webidl

Co-authored-by: daxpedda <daxpedda@gmail.com>

* Update crates/web-sys/webidls/enabled/Notification.webidl

Co-authored-by: daxpedda <daxpedda@gmail.com>

* added entries to changelog

* regenerated

* Update CHANGELOG.md with new additions

* Update CHANGELOG.md

Co-authored-by: daxpedda <daxpedda@gmail.com>

---------

Co-authored-by: daxpedda <daxpedda@gmail.com>
  • Loading branch information
maccesch and daxpedda committed Oct 27, 2023
1 parent 54f22ee commit a03d23b
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 246 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
proc-macro and accept the `--include-ignored` flag with `wasm-bindgen-test-runner`.
[#3644](https://github.com/rustwasm/wasm-bindgen/pull/3644)

* Added missing additions to the Notification API.
[#3667](https://github.com/rustwasm/wasm-bindgen/pull/3667)

### Changed

* Updated the WebGPU WebIDL.
Expand Down Expand Up @@ -157,6 +160,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.

0 comments on commit a03d23b

Please sign in to comment.