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

Prioritized Task Scheduling API #3566

Merged
merged 1 commit into from
Aug 25, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
* Add bindings for `HTMLElement.inert`.
[#3557](https://github.com/rustwasm/wasm-bindgen/pull/3557)

* Add unstable bindings for the Prioritized Task Scheduling API.
[#3566](https://github.com/rustwasm/wasm-bindgen/pull/3566)

### Changed

* Updated the WebGPU WebIDL.
Expand Down
11 changes: 11 additions & 0 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ IntersectionObserverEntry = []
IntersectionObserverEntryInit = []
IntersectionObserverInit = []
IntlUtils = []
IsInputPendingOptions = []
IterableKeyAndValueResult = []
IterableKeyOrValueResult = []
IterationCompositeOperation = []
Expand Down Expand Up @@ -1130,6 +1131,9 @@ RtcdtmfToneChangeEvent = ["Event"]
RtcdtmfToneChangeEventInit = []
RtcrtpContributingSourceStats = []
RtcrtpStreamStats = []
Scheduler = []
SchedulerPostTaskOptions = []
Scheduling = []
Screen = ["EventTarget"]
ScreenColorGamut = []
ScreenLuminance = []
Expand Down Expand Up @@ -1338,6 +1342,13 @@ SvggElement = ["Element", "EventTarget", "Node", "SvgElement", "SvgGraphicsEleme
SvgmPathElement = ["Element", "EventTarget", "Node", "SvgElement"]
SvgsvgElement = ["Element", "EventTarget", "Node", "SvgElement", "SvgGraphicsElement"]
SvgtSpanElement = ["Element", "EventTarget", "Node", "SvgElement", "SvgGraphicsElement", "SvgTextContentElement", "SvgTextPositioningElement"]
TaskController = ["AbortController"]
TaskControllerInit = []
TaskPriority = []
TaskPriorityChangeEvent = ["Event"]
TaskPriorityChangeEventInit = []
TaskSignal = ["AbortSignal", "EventTarget"]
TaskSignalAnyInit = []
TcpReadyState = []
TcpServerSocket = ["EventTarget"]
TcpServerSocketEvent = ["Event"]
Expand Down
58 changes: 58 additions & 0 deletions crates/web-sys/src/features/gen_IsInputPendingOptions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#![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 = IsInputPendingOptions)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `IsInputPendingOptions` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `IsInputPendingOptions`*"]
#[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 IsInputPendingOptions;
}
#[cfg(web_sys_unstable_apis)]
impl IsInputPendingOptions {
#[doc = "Construct a new `IsInputPendingOptions`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `IsInputPendingOptions`*"]
#[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 `includeContinuous` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `IsInputPendingOptions`*"]
#[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 include_continuous(&mut self, val: bool) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("includeContinuous"),
&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 IsInputPendingOptions {
fn default() -> Self {
Self::new()
}
}
12 changes: 12 additions & 0 deletions crates/web-sys/src/features/gen_Navigator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ extern "C" {
#[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 xr(this: &Navigator) -> XrSystem;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "Scheduling")]
# [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = scheduling)]
#[doc = "Getter for the `scheduling` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/scheduling)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Navigator`, `Scheduling`*"]
#[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 scheduling(this: &Navigator) -> Scheduling;
# [wasm_bindgen (structural , method , getter , js_class = "Navigator" , js_name = hardwareConcurrency)]
#[doc = "Getter for the `hardwareConcurrency` field of this object."]
#[doc = ""]
Expand Down
46 changes: 46 additions & 0 deletions crates/web-sys/src/features/gen_Scheduler.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#![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 = Scheduler , typescript_type = "Scheduler")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `Scheduler` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Scheduler)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Scheduler`*"]
#[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 Scheduler;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "Scheduler" , js_name = postTask)]
#[doc = "The `postTask()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Scheduler/postTask)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Scheduler`*"]
#[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 post_task(this: &Scheduler, callback: &::js_sys::Function) -> ::js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "SchedulerPostTaskOptions")]
# [wasm_bindgen (method , structural , js_class = "Scheduler" , js_name = postTask)]
#[doc = "The `postTask()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Scheduler/postTask)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Scheduler`, `SchedulerPostTaskOptions`*"]
#[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 post_task_with_options(
this: &Scheduler,
callback: &::js_sys::Function,
options: &SchedulerPostTaskOptions,
) -> ::js_sys::Promise;
}
95 changes: 95 additions & 0 deletions crates/web-sys/src/features/gen_SchedulerPostTaskOptions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#![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 = SchedulerPostTaskOptions)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `SchedulerPostTaskOptions` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `SchedulerPostTaskOptions`*"]
#[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 SchedulerPostTaskOptions;
}
#[cfg(web_sys_unstable_apis)]
impl SchedulerPostTaskOptions {
#[doc = "Construct a new `SchedulerPostTaskOptions`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `SchedulerPostTaskOptions`*"]
#[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 `delay` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `SchedulerPostTaskOptions`*"]
#[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 delay(&mut self, val: f64) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("delay"), &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 = "TaskPriority")]
#[doc = "Change the `priority` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `SchedulerPostTaskOptions`, `TaskPriority`*"]
#[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 priority(&mut self, val: TaskPriority) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("priority"),
&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`, `SchedulerPostTaskOptions`*"]
#[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)]
impl Default for SchedulerPostTaskOptions {
fn default() -> Self {
Self::new()
}
}
45 changes: 45 additions & 0 deletions crates/web-sys/src/features/gen_Scheduling.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#![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 = Scheduling , typescript_type = "Scheduling")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `Scheduling` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Scheduling)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Scheduling`*"]
#[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 Scheduling;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "Scheduling" , js_name = isInputPending)]
#[doc = "The `isInputPending()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Scheduling/isInputPending)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `Scheduling`*"]
#[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 is_input_pending(this: &Scheduling) -> bool;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "IsInputPendingOptions")]
# [wasm_bindgen (method , structural , js_class = "Scheduling" , js_name = isInputPending)]
#[doc = "The `isInputPending()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/Scheduling/isInputPending)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `IsInputPendingOptions`, `Scheduling`*"]
#[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 is_input_pending_with_is_input_pending_options(
this: &Scheduling,
is_input_pending_options: &IsInputPendingOptions,
) -> bool;
}
54 changes: 54 additions & 0 deletions crates/web-sys/src/features/gen_TaskController.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = AbortController , extends = :: js_sys :: Object , js_name = TaskController , typescript_type = "TaskController")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `TaskController` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/TaskController)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `TaskController`*"]
#[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 TaskController;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen(catch, constructor, js_class = "TaskController")]
#[doc = "The `new TaskController(..)` constructor, creating a new instance of `TaskController`."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/TaskController/TaskController)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `TaskController`*"]
#[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() -> Result<TaskController, JsValue>;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "TaskControllerInit")]
#[wasm_bindgen(catch, constructor, js_class = "TaskController")]
#[doc = "The `new TaskController(..)` constructor, creating a new instance of `TaskController`."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/TaskController/TaskController)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `TaskController`, `TaskControllerInit`*"]
#[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_with_init(init: &TaskControllerInit) -> Result<TaskController, JsValue>;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "TaskPriority")]
# [wasm_bindgen (method , structural , js_class = "TaskController" , js_name = setPriority)]
#[doc = "The `setPriority()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/TaskController/setPriority)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `TaskController`, `TaskPriority`*"]
#[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 set_priority(this: &TaskController, priority: TaskPriority);
}
Loading