diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/timers/Cargo.toml | 28 | ||||
-rw-r--r-- | ext/timers/README.md | 5 | ||||
-rw-r--r-- | ext/web/02_timers.js (renamed from ext/timers/01_timers.js) | 0 | ||||
-rw-r--r-- | ext/web/15_performance.js (renamed from ext/timers/02_performance.js) | 0 | ||||
-rw-r--r-- | ext/web/Cargo.toml | 9 | ||||
-rw-r--r-- | ext/web/benches/timers_ops.rs (renamed from ext/timers/benches/timers_ops.rs) | 5 | ||||
-rw-r--r-- | ext/web/lib.rs | 20 | ||||
-rw-r--r-- | ext/web/timers.rs (renamed from ext/timers/lib.rs) | 24 |
8 files changed, 30 insertions, 61 deletions
diff --git a/ext/timers/Cargo.toml b/ext/timers/Cargo.toml deleted file mode 100644 index 15979388e..000000000 --- a/ext/timers/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. - -[package] -name = "deno_timers" -version = "0.34.0" -authors = ["the Deno authors"] -edition = "2021" -license = "MIT" -readme = "README.md" -repository = "https://github.com/denoland/deno" -description = "Timers API implementation for Deno" - -[lib] -path = "lib.rs" - -[dependencies] -deno_core = { version = "0.118.0", path = "../../core" } -tokio = { version = "1.10.1", features = ["full"] } - -[dev-dependencies] -deno_bench_util = { version = "0.30.0", path = "../../bench_util" } -deno_url = { version = "0.36.0", path = "../url" } -deno_web = { version = "0.67.0", path = "../web" } -deno_webidl = { version = "0.36.0", path = "../webidl" } - -[[bench]] -name = "timers_ops" -harness = false diff --git a/ext/timers/README.md b/ext/timers/README.md deleted file mode 100644 index 5a2a8e516..000000000 --- a/ext/timers/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# deno_timers - -This crate implements the timers API. - -Spec: https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers diff --git a/ext/timers/01_timers.js b/ext/web/02_timers.js index a0b1deb45..a0b1deb45 100644 --- a/ext/timers/01_timers.js +++ b/ext/web/02_timers.js diff --git a/ext/timers/02_performance.js b/ext/web/15_performance.js index c48a3d888..c48a3d888 100644 --- a/ext/timers/02_performance.js +++ b/ext/web/15_performance.js diff --git a/ext/web/Cargo.toml b/ext/web/Cargo.toml index 0e1c1433b..f32a05999 100644 --- a/ext/web/Cargo.toml +++ b/ext/web/Cargo.toml @@ -22,3 +22,12 @@ flate2 = "1" serde = "1.0.129" tokio = { version = "1.10.1", features = ["full"] } uuid = { version = "0.8.2", features = ["v4", "serde"] } + +[dev-dependencies] +deno_bench_util = { version = "0.30.0", path = "../../bench_util" } +deno_url = { version = "0.36.0", path = "../url" } +deno_webidl = { version = "0.36.0", path = "../webidl" } + +[[bench]] +name = "timers_ops" +harness = false diff --git a/ext/timers/benches/timers_ops.rs b/ext/web/benches/timers_ops.rs index 8d13d5807..30f50b7d9 100644 --- a/ext/timers/benches/timers_ops.rs +++ b/ext/web/benches/timers_ops.rs @@ -7,7 +7,7 @@ use deno_web::BlobStore; struct Permissions; -impl deno_timers::TimersPermission for Permissions { +impl deno_web::TimersPermission for Permissions { fn allow_hrtime(&mut self) -> bool { true } @@ -23,8 +23,7 @@ fn setup() -> Vec<Extension> { vec![ deno_webidl::init(), deno_url::init(), - deno_web::init(BlobStore::default(), None), - deno_timers::init::<Permissions>(), + deno_web::init::<Permissions>(BlobStore::default(), None), Extension::builder() .js(vec![ ("setup", diff --git a/ext/web/lib.rs b/ext/web/lib.rs index b32deeb97..b10cb972d 100644 --- a/ext/web/lib.rs +++ b/ext/web/lib.rs @@ -3,6 +3,7 @@ mod blob; mod compression; mod message_port; +mod timers; use deno_core::error::range_error; use deno_core::error::type_error; @@ -47,8 +48,18 @@ use crate::message_port::op_message_port_recv_message; pub use crate::message_port::JsMessageData; pub use crate::message_port::MessagePort; +use crate::timers::op_now; +use crate::timers::op_sleep; +use crate::timers::op_sleep_sync; +use crate::timers::op_timer_handle; +use crate::timers::StartTime; +pub use crate::timers::TimersPermission; + /// Load and execute the javascript code. -pub fn init(blob_store: BlobStore, maybe_location: Option<Url>) -> Extension { +pub fn init<P: TimersPermission + 'static>( + blob_store: BlobStore, + maybe_location: Option<Url>, +) -> Extension { Extension::builder() .js(include_js_files!( prefix "deno:ext/web", @@ -57,6 +68,7 @@ pub fn init(blob_store: BlobStore, maybe_location: Option<Url>) -> Extension { "01_mimesniff.js", "02_event.js", "02_structured_clone.js", + "02_timers.js", "03_abort_signal.js", "04_global_interfaces.js", "05_base64.js", @@ -68,6 +80,7 @@ pub fn init(blob_store: BlobStore, maybe_location: Option<Url>) -> Extension { "12_location.js", "13_message_port.js", "14_compression.js", + "15_performance.js", )) .ops(vec![ ("op_base64_decode", op_sync(op_base64_decode)), @@ -116,12 +129,17 @@ pub fn init(blob_store: BlobStore, maybe_location: Option<Url>) -> Extension { "op_compression_finish", op_sync(compression::op_compression_finish), ), + ("op_now", op_sync(op_now::<P>)), + ("op_timer_handle", op_sync(op_timer_handle)), + ("op_sleep", op_async(op_sleep)), + ("op_sleep_sync", op_sync(op_sleep_sync::<P>)), ]) .state(move |state| { state.put(blob_store.clone()); if let Some(location) = maybe_location.clone() { state.put(Location(location)); } + state.put(StartTime::now()); Ok(()) }) .build() diff --git a/ext/timers/lib.rs b/ext/web/timers.rs index 63aabe9d4..7f17aa969 100644 --- a/ext/timers/lib.rs +++ b/ext/web/timers.rs @@ -3,12 +3,8 @@ //! This module helps deno implement timers and performance APIs. use deno_core::error::AnyError; -use deno_core::include_js_files; -use deno_core::op_async; -use deno_core::op_sync; use deno_core::CancelFuture; use deno_core::CancelHandle; -use deno_core::Extension; use deno_core::OpState; use deno_core::Resource; use deno_core::ResourceId; @@ -23,26 +19,6 @@ pub trait TimersPermission { fn check_unstable(&self, state: &OpState, api_name: &'static str); } -pub fn init<P: TimersPermission + 'static>() -> Extension { - Extension::builder() - .js(include_js_files!( - prefix "deno:ext/timers", - "01_timers.js", - "02_performance.js", - )) - .ops(vec![ - ("op_now", op_sync(op_now::<P>)), - ("op_timer_handle", op_sync(op_timer_handle)), - ("op_sleep", op_async(op_sleep)), - ("op_sleep_sync", op_sync(op_sleep_sync::<P>)), - ]) - .state(|state| { - state.put(StartTime::now()); - Ok(()) - }) - .build() -} - pub type StartTime = Instant; // Returns a milliseconds and nanoseconds subsec |