-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Worker and NodeJS Support * Fixed CI errors
- Loading branch information
Showing
9 changed files
with
81 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use js_sys::Object; | ||
use wasm_bindgen::{prelude::wasm_bindgen, JsCast}; | ||
|
||
#[wasm_bindgen] | ||
extern "C" { | ||
pub type GlobalScope; | ||
|
||
pub type Performance; | ||
|
||
#[wasm_bindgen(structural, method, getter, js_name = "performance")] | ||
pub fn performance(this: &GlobalScope) -> Performance; | ||
|
||
#[wasm_bindgen(method, js_name = "now")] | ||
pub fn now(this: &Performance) -> f64; | ||
|
||
#[cfg(feature = "tokio")] | ||
#[wasm_bindgen(catch , method, js_name = setTimeout)] | ||
pub fn set_timeout_with_callback_and_timeout_and_arguments_0( | ||
this: &GlobalScope, | ||
handler: &::js_sys::Function, | ||
timeout: i32, | ||
) -> Result<i32, wasm_bindgen::JsValue>; | ||
} | ||
|
||
pub fn performance_now() -> f64 { | ||
let global_this: Object = js_sys::global(); | ||
let global_scope = global_this.unchecked_ref::<GlobalScope>(); | ||
global_scope.performance().now() | ||
} | ||
|
||
#[cfg(feature = "tokio")] | ||
pub fn set_timeout( | ||
handler: &::js_sys::Function, | ||
timeout: i32, | ||
) -> Result<i32, wasm_bindgen::JsValue> { | ||
let global_this: Object = js_sys::global(); | ||
let global_scope = global_this.unchecked_ref::<GlobalScope>(); | ||
global_scope.set_timeout_with_callback_and_timeout_and_arguments_0(handler, timeout) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters