summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock16
-rw-r--r--Cargo.toml1
-rw-r--r--cli/tests/testdata/worker_drop_handle_race.js.out4
-rw-r--r--ext/timers/Cargo.toml28
-rw-r--r--ext/timers/README.md5
-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.toml9
-rw-r--r--ext/web/benches/timers_ops.rs (renamed from ext/timers/benches/timers_ops.rs)5
-rw-r--r--ext/web/lib.rs20
-rw-r--r--ext/web/timers.rs (renamed from ext/timers/lib.rs)24
-rw-r--r--runtime/Cargo.toml2
-rw-r--r--runtime/build.rs8
-rw-r--r--runtime/lib.rs1
-rw-r--r--runtime/permissions.rs2
-rw-r--r--runtime/web_worker.rs6
-rw-r--r--runtime/worker.rs3
17 files changed, 46 insertions, 88 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 49d478a00..170272e9f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1006,7 +1006,6 @@ dependencies = [
"deno_ffi",
"deno_http",
"deno_net",
- "deno_timers",
"deno_tls",
"deno_url",
"deno_web",
@@ -1042,18 +1041,6 @@ dependencies = [
]
[[package]]
-name = "deno_timers"
-version = "0.34.0"
-dependencies = [
- "deno_bench_util",
- "deno_core",
- "deno_url",
- "deno_web",
- "deno_webidl",
- "tokio",
-]
-
-[[package]]
name = "deno_tls"
version = "0.23.0"
dependencies = [
@@ -1085,7 +1072,10 @@ version = "0.67.0"
dependencies = [
"async-trait",
"base64 0.13.0",
+ "deno_bench_util",
"deno_core",
+ "deno_url",
+ "deno_webidl",
"encoding_rs",
"flate2",
"serde",
diff --git a/Cargo.toml b/Cargo.toml
index 3f206b223..781b88cb5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,7 +17,6 @@ members = [
"ext/ffi",
"ext/http",
"ext/net",
- "ext/timers",
"ext/url",
"ext/web",
"ext/webgpu",
diff --git a/cli/tests/testdata/worker_drop_handle_race.js.out b/cli/tests/testdata/worker_drop_handle_race.js.out
index b7218e8f6..34c2d5be2 100644
--- a/cli/tests/testdata/worker_drop_handle_race.js.out
+++ b/cli/tests/testdata/worker_drop_handle_race.js.out
@@ -2,7 +2,7 @@ error: Uncaught (in worker "") Error
throw new Error();
^
at [WILDCARD]/workers/drop_handle_race.js:2:9
- at Object.action (deno:ext/timers/[WILDCARD])
- at handleTimerMacrotask (deno:ext/timers/[WILDCARD])
+ at Object.action (deno:ext/web/02_timers.js:[WILDCARD])
+ at handleTimerMacrotask (deno:ext/web/02_timers.js:[WILDCARD])
error: Uncaught (in promise) Error: Unhandled error event in child worker.
at Worker.#pollControl (deno:runtime/js/11_workers.js:[WILDCARD])
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
diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml
index 6333d3387..1763d6feb 100644
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -30,7 +30,6 @@ deno_fetch = { version = "0.59.0", path = "../ext/fetch" }
deno_ffi = { version = "0.23.0", path = "../ext/ffi" }
deno_http = { version = "0.28.0", path = "../ext/http" }
deno_net = { version = "0.28.0", path = "../ext/net" }
-deno_timers = { version = "0.34.0", path = "../ext/timers" }
deno_tls = { version = "0.23.0", path = "../ext/tls" }
deno_url = { version = "0.36.0", path = "../ext/url" }
deno_web = { version = "0.67.0", path = "../ext/web" }
@@ -54,7 +53,6 @@ deno_fetch = { version = "0.59.0", path = "../ext/fetch" }
deno_ffi = { version = "0.23.0", path = "../ext/ffi" }
deno_http = { version = "0.28.0", path = "../ext/http" }
deno_net = { version = "0.28.0", path = "../ext/net" }
-deno_timers = { version = "0.34.0", path = "../ext/timers" }
deno_tls = { version = "0.23.0", path = "../ext/tls" }
deno_url = { version = "0.36.0", path = "../ext/url" }
deno_web = { version = "0.67.0", path = "../ext/web" }
diff --git a/runtime/build.rs b/runtime/build.rs
index e2fe21b9e..eea7a3602 100644
--- a/runtime/build.rs
+++ b/runtime/build.rs
@@ -93,7 +93,7 @@ mod not_docs {
}
}
- impl deno_timers::TimersPermission for Permissions {
+ impl deno_web::TimersPermission for Permissions {
fn allow_hrtime(&mut self) -> bool {
unreachable!("snapshotting!")
}
@@ -145,13 +145,15 @@ mod not_docs {
deno_console::init(),
deno_url::init(),
deno_tls::init(),
- deno_web::init(deno_web::BlobStore::default(), Default::default()),
+ deno_web::init::<Permissions>(
+ deno_web::BlobStore::default(),
+ Default::default(),
+ ),
deno_fetch::init::<Permissions>(Default::default()),
deno_websocket::init::<Permissions>("".to_owned(), None, None),
deno_webstorage::init(None),
deno_crypto::init(None),
deno_webgpu::init(false),
- deno_timers::init::<Permissions>(),
deno_broadcast_channel::init(
deno_broadcast_channel::InMemoryBroadcastChannel::default(),
false, // No --unstable.
diff --git a/runtime/lib.rs b/runtime/lib.rs
index fef3956ea..543d3a0a2 100644
--- a/runtime/lib.rs
+++ b/runtime/lib.rs
@@ -8,7 +8,6 @@ pub use deno_fetch;
pub use deno_ffi;
pub use deno_http;
pub use deno_net;
-pub use deno_timers;
pub use deno_tls;
pub use deno_url;
pub use deno_web;
diff --git a/runtime/permissions.rs b/runtime/permissions.rs
index c404436d6..77ad8496f 100644
--- a/runtime/permissions.rs
+++ b/runtime/permissions.rs
@@ -1314,7 +1314,7 @@ impl deno_fetch::FetchPermissions for Permissions {
}
}
-impl deno_timers::TimersPermission for Permissions {
+impl deno_web::TimersPermission for Permissions {
fn allow_hrtime(&mut self) -> bool {
self.hrtime.check().is_ok()
}
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs
index 8cbbb5d4f..c90e91b92 100644
--- a/runtime/web_worker.rs
+++ b/runtime/web_worker.rs
@@ -368,7 +368,10 @@ impl WebWorker {
deno_webidl::init(),
deno_console::init(),
deno_url::init(),
- deno_web::init(options.blob_store.clone(), Some(main_module.clone())),
+ deno_web::init::<Permissions>(
+ options.blob_store.clone(),
+ Some(main_module.clone()),
+ ),
deno_fetch::init::<Permissions>(deno_fetch::Options {
user_agent: options.user_agent.clone(),
root_cert_store: options.root_cert_store.clone(),
@@ -386,7 +389,6 @@ impl WebWorker {
deno_broadcast_channel::init(options.broadcast_channel.clone(), unstable),
deno_crypto::init(options.seed),
deno_webgpu::init(unstable),
- deno_timers::init::<Permissions>(),
// ffi
deno_ffi::init::<Permissions>(unstable),
// Permissions ext (worker specific state)
diff --git a/runtime/worker.rs b/runtime/worker.rs
index 1dc9504d6..1e31b84dc 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -100,7 +100,7 @@ impl MainWorker {
deno_webidl::init(),
deno_console::init(),
deno_url::init(),
- deno_web::init(
+ deno_web::init::<Permissions>(
options.blob_store.clone(),
options.bootstrap.location.clone(),
),
@@ -122,7 +122,6 @@ impl MainWorker {
deno_crypto::init(options.seed),
deno_broadcast_channel::init(options.broadcast_channel.clone(), unstable),
deno_webgpu::init(unstable),
- deno_timers::init::<Permissions>(),
// ffi
deno_ffi::init::<Permissions>(unstable),
// Runtime ops