summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--bench_util/benches/op_baseline.rs2
-rw-r--r--bench_util/benches/utf8.rs2
-rw-r--r--cli/build.rs2
-rw-r--r--cli/lsp/tsc.rs2
-rw-r--r--cli/ops/bench.rs2
-rw-r--r--cli/ops/mod.rs2
-rw-r--r--cli/ops/testing.rs2
-rw-r--r--cli/tsc/mod.rs2
-rw-r--r--core/examples/disable_ops.rs2
-rw-r--r--core/examples/hello_world.rs2
-rw-r--r--core/examples/http_bench_json_ops.rs2
-rw-r--r--core/examples/panik.rs5
-rw-r--r--core/examples/schedule_task.rs2
-rw-r--r--core/examples/wasm.rs2
-rw-r--r--core/extensions.rs40
-rw-r--r--core/modules.rs4
-rw-r--r--core/ops_builtin.rs2
-rw-r--r--core/runtime.rs61
-rw-r--r--ext/broadcast_channel/lib.rs3
-rw-r--r--ext/cache/lib.rs3
-rw-r--r--ext/console/lib.rs2
-rw-r--r--ext/crypto/lib.rs3
-rw-r--r--ext/fetch/lib.rs3
-rw-r--r--ext/ffi/lib.rs2
-rw-r--r--ext/flash/lib.rs9
-rw-r--r--ext/http/lib.rs3
-rw-r--r--ext/napi/lib.rs2
-rw-r--r--ext/net/lib.rs3
-rw-r--r--ext/net/ops.rs2
-rw-r--r--ext/node/lib.rs2
-rw-r--r--ext/tls/lib.rs2
-rw-r--r--ext/url/benches/url_ops.rs2
-rw-r--r--ext/url/lib.rs3
-rw-r--r--ext/web/Cargo.toml1
-rw-r--r--ext/web/benches/encoding.rs3
-rw-r--r--ext/web/benches/timers_ops.rs3
-rw-r--r--ext/web/lib.rs3
-rw-r--r--ext/webgpu/src/lib.rs3
-rw-r--r--ext/webidl/lib.rs2
-rw-r--r--ext/websocket/lib.rs3
-rw-r--r--ext/webstorage/lib.rs3
-rw-r--r--runtime/ops/fs.rs2
-rw-r--r--runtime/ops/fs_events.rs2
-rw-r--r--runtime/ops/http.rs2
-rw-r--r--runtime/ops/io.rs4
-rw-r--r--runtime/ops/os/mod.rs4
-rw-r--r--runtime/ops/permissions.rs2
-rw-r--r--runtime/ops/process.rs2
-rw-r--r--runtime/ops/runtime.rs2
-rw-r--r--runtime/ops/signal.rs2
-rw-r--r--runtime/ops/spawn.rs2
-rw-r--r--runtime/ops/tty.rs2
-rw-r--r--runtime/ops/web_worker.rs2
-rw-r--r--runtime/ops/worker_host.rs2
-rw-r--r--runtime/web_worker.rs2
-rw-r--r--runtime/worker.rs2
57 files changed, 158 insertions, 80 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 09cb1295d..414f57cb4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1258,6 +1258,7 @@ dependencies = [
"async-trait",
"base64-simd",
"deno_bench_util",
+ "deno_console",
"deno_core",
"deno_url",
"deno_webidl",
diff --git a/bench_util/benches/op_baseline.rs b/bench_util/benches/op_baseline.rs
index 14d04f60d..9c3ac16c4 100644
--- a/bench_util/benches/op_baseline.rs
+++ b/bench_util/benches/op_baseline.rs
@@ -6,7 +6,7 @@ use deno_core::op;
use deno_core::Extension;
fn setup() -> Vec<Extension> {
- vec![Extension::builder()
+ vec![Extension::builder("bench_setup")
.ops(vec![
op_pi_json::decl(),
op_pi_async::decl(),
diff --git a/bench_util/benches/utf8.rs b/bench_util/benches/utf8.rs
index 499571e5e..363300d5e 100644
--- a/bench_util/benches/utf8.rs
+++ b/bench_util/benches/utf8.rs
@@ -6,7 +6,7 @@ use deno_bench_util::BenchOptions;
use deno_core::Extension;
fn setup() -> Vec<Extension> {
- vec![Extension::builder()
+ vec![Extension::builder("bench_setup")
.js(vec![(
"setup.js",
r#"
diff --git a/cli/build.rs b/cli/build.rs
index b4acc0d1d..24898a7a1 100644
--- a/cli/build.rs
+++ b/cli/build.rs
@@ -238,7 +238,7 @@ mod ts {
cargo_manifest_dir: env!("CARGO_MANIFEST_DIR"),
snapshot_path,
startup_snapshot: None,
- extensions: vec![Extension::builder()
+ extensions: vec![Extension::builder("deno_tsc")
.ops(vec![
op_build_info::decl(),
op_cwd::decl(),
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index 9f2ac2ba0..fabe30ac7 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -2805,7 +2805,7 @@ fn js_runtime(performance: Arc<Performance>) -> JsRuntime {
}
fn init_extension(performance: Arc<Performance>) -> Extension {
- Extension::builder()
+ Extension::builder("deno_tsc")
.ops(vec![
op_exists::decl(),
op_is_cancelled::decl(),
diff --git a/cli/ops/bench.rs b/cli/ops/bench.rs
index 3b27ffa7e..9b70cfa79 100644
--- a/cli/ops/bench.rs
+++ b/cli/ops/bench.rs
@@ -22,7 +22,7 @@ pub fn init(
sender: UnboundedSender<BenchEvent>,
filter: TestFilter,
) -> Extension {
- Extension::builder()
+ Extension::builder("deno_bench")
.ops(vec![
op_pledge_test_permissions::decl(),
op_restore_test_permissions::decl(),
diff --git a/cli/ops/mod.rs b/cli/ops/mod.rs
index 96599a663..c31a30531 100644
--- a/cli/ops/mod.rs
+++ b/cli/ops/mod.rs
@@ -14,7 +14,7 @@ pub fn cli_exts(ps: ProcState) -> Vec<Extension> {
}
fn init_proc_state(ps: ProcState) -> Extension {
- Extension::builder()
+ Extension::builder("deno_cli")
.ops(vec![op_npm_process_state::decl()])
.state(move |state| {
state.put(ps.clone());
diff --git a/cli/ops/testing.rs b/cli/ops/testing.rs
index e5c0a2b99..e9d0acf41 100644
--- a/cli/ops/testing.rs
+++ b/cli/ops/testing.rs
@@ -30,7 +30,7 @@ pub fn init(
fail_fast_tracker: FailFastTracker,
filter: TestFilter,
) -> Extension {
- Extension::builder()
+ Extension::builder("deno_test")
.ops(vec![
op_pledge_test_permissions::decl(),
op_restore_test_permissions::decl(),
diff --git a/cli/tsc/mod.rs b/cli/tsc/mod.rs
index 497105cb5..c08b4e1ae 100644
--- a/cli/tsc/mod.rs
+++ b/cli/tsc/mod.rs
@@ -770,7 +770,7 @@ pub fn exec(request: Request) -> Result<Response, AnyError> {
.collect();
let mut runtime = JsRuntime::new(RuntimeOptions {
startup_snapshot: Some(compiler_snapshot()),
- extensions: vec![Extension::builder()
+ extensions: vec![Extension::builder("deno_cli_tsc")
.ops(vec![
op_cwd::decl(),
op_create_hash::decl(),
diff --git a/core/examples/disable_ops.rs b/core/examples/disable_ops.rs
index a99568589..b9a5e7fca 100644
--- a/core/examples/disable_ops.rs
+++ b/core/examples/disable_ops.rs
@@ -7,7 +7,7 @@ use deno_core::JsRuntime;
use deno_core::RuntimeOptions;
fn main() {
- let my_ext = Extension::builder()
+ let my_ext = Extension::builder("my_ext")
.middleware(|op| match op.name {
"op_print" => op.disable(),
_ => op,
diff --git a/core/examples/hello_world.rs b/core/examples/hello_world.rs
index a1edbead0..50cbe4e2c 100644
--- a/core/examples/hello_world.rs
+++ b/core/examples/hello_world.rs
@@ -22,7 +22,7 @@ fn op_sum(nums: Vec<f64>) -> Result<f64, deno_core::error::AnyError> {
fn main() {
// Build a deno_core::Extension providing custom ops
- let ext = Extension::builder()
+ let ext = Extension::builder("my_ext")
.ops(vec![
// An op for summing an array of numbers
// The op-layer automatically deserializes inputs
diff --git a/core/examples/http_bench_json_ops.rs b/core/examples/http_bench_json_ops.rs
index 23945c632..9a55a0823 100644
--- a/core/examples/http_bench_json_ops.rs
+++ b/core/examples/http_bench_json_ops.rs
@@ -117,7 +117,7 @@ impl From<tokio::net::TcpStream> for TcpStream {
}
fn create_js_runtime() -> JsRuntime {
- let ext = deno_core::Extension::builder()
+ let ext = deno_core::Extension::builder("my_ext")
.ops(vec![op_listen::decl(), op_accept::decl()])
.build();
diff --git a/core/examples/panik.rs b/core/examples/panik.rs
index 76be108ec..1d2286a88 100644
--- a/core/examples/panik.rs
+++ b/core/examples/panik.rs
@@ -24,8 +24,9 @@ fn main() {
panic!("panik !!!")
}
- let extensions =
- vec![Extension::builder().ops(vec![op_panik::decl()]).build()];
+ let extensions = vec![Extension::builder("my_ext")
+ .ops(vec![op_panik::decl()])
+ .build()];
let mut rt = JsRuntime::new(RuntimeOptions {
extensions,
..Default::default()
diff --git a/core/examples/schedule_task.rs b/core/examples/schedule_task.rs
index ba0f3ef0f..6a61619d8 100644
--- a/core/examples/schedule_task.rs
+++ b/core/examples/schedule_task.rs
@@ -18,7 +18,7 @@ use deno_core::*;
type Task = Box<dyn FnOnce()>;
fn main() {
- let my_ext = Extension::builder()
+ let my_ext = Extension::builder("my_ext")
.ops(vec![op_schedule_task::decl()])
.event_loop_middleware(|state_rc, cx| {
let mut state = state_rc.borrow_mut();
diff --git a/core/examples/wasm.rs b/core/examples/wasm.rs
index c4bb8b9ad..7c2d98bc9 100644
--- a/core/examples/wasm.rs
+++ b/core/examples/wasm.rs
@@ -51,7 +51,7 @@ fn op_set_wasm_mem(
fn main() {
// Build a deno_core::Extension providing custom ops
- let ext = Extension::builder()
+ let ext = Extension::builder("my_ext")
.ops(vec![op_wasm::decl(), op_set_wasm_mem::decl()])
.build();
diff --git a/core/extensions.rs b/core/extensions.rs
index 6fca570df..437621c0e 100644
--- a/core/extensions.rs
+++ b/core/extensions.rs
@@ -42,13 +42,39 @@ pub struct Extension {
event_loop_middleware: Option<Box<OpEventLoopFn>>,
initialized: bool,
enabled: bool,
+ name: &'static str,
+ deps: Option<Vec<&'static str>>,
}
// Note: this used to be a trait, but we "downgraded" it to a single concrete type
// for the initial iteration, it will likely become a trait in the future
impl Extension {
- pub fn builder() -> ExtensionBuilder {
- Default::default()
+ pub fn builder(name: &'static str) -> ExtensionBuilder {
+ ExtensionBuilder {
+ name,
+ ..Default::default()
+ }
+ }
+
+ /// Check if dependencies have been loaded, and errors if either:
+ /// - The extension is depending on itself or an extension with the same name.
+ /// - A dependency hasn't been loaded yet.
+ pub fn check_dependencies(&self, previous_exts: &[&mut Extension]) {
+ if let Some(deps) = &self.deps {
+ 'dep_loop: for dep in deps {
+ if dep == &self.name {
+ panic!("Extension '{}' is either depending on itself or there is another extension with the same name", self.name);
+ }
+
+ for ext in previous_exts {
+ if dep == &ext.name {
+ continue 'dep_loop;
+ }
+ }
+
+ panic!("Extension '{}' is missing dependency '{dep}'", self.name);
+ }
+ }
}
/// returns JS source code to be loaded into the isolate (either at snapshotting,
@@ -121,9 +147,16 @@ pub struct ExtensionBuilder {
state: Option<Box<OpStateFn>>,
middleware: Option<Box<OpMiddlewareFn>>,
event_loop_middleware: Option<Box<OpEventLoopFn>>,
+ name: &'static str,
+ deps: Vec<&'static str>,
}
impl ExtensionBuilder {
+ pub fn dependencies(&mut self, dependencies: Vec<&'static str>) -> &mut Self {
+ self.deps.extend(dependencies);
+ self
+ }
+
pub fn js(&mut self, js_files: Vec<SourcePair>) -> &mut Self {
self.js.extend(js_files);
self
@@ -161,6 +194,7 @@ impl ExtensionBuilder {
pub fn build(&mut self) -> Extension {
let js_files = Some(std::mem::take(&mut self.js));
let ops = Some(std::mem::take(&mut self.ops));
+ let deps = Some(std::mem::take(&mut self.deps));
Extension {
js_files,
ops,
@@ -169,6 +203,8 @@ impl ExtensionBuilder {
event_loop_middleware: self.event_loop_middleware.take(),
initialized: false,
enabled: true,
+ name: self.name,
+ deps,
}
}
}
diff --git a/core/modules.rs b/core/modules.rs
index ff253db61..8abced200 100644
--- a/core/modules.rs
+++ b/core/modules.rs
@@ -1479,7 +1479,9 @@ import "/a.js";
43
}
- let ext = Extension::builder().ops(vec![op_test::decl()]).build();
+ let ext = Extension::builder("test_ext")
+ .ops(vec![op_test::decl()])
+ .build();
let mut runtime = JsRuntime::new(RuntimeOptions {
extensions: vec![ext],
diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs
index 6889c5dbc..905496025 100644
--- a/core/ops_builtin.rs
+++ b/core/ops_builtin.rs
@@ -17,7 +17,7 @@ use std::io::{stderr, stdout, Write};
use std::rc::Rc;
pub(crate) fn init_builtins() -> Extension {
- Extension::builder()
+ Extension::builder("deno_builtins")
.js(include_js_files!(
prefix "deno:core",
"00_primordials.js",
diff --git a/core/runtime.rs b/core/runtime.rs
index 4a1302b3f..baa7de1a1 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -728,10 +728,9 @@ impl JsRuntime {
/// Initializes JS of provided Extensions in the given realm
fn init_extension_js(&mut self, realm: &JsRealm) -> Result<(), Error> {
// Take extensions to avoid double-borrow
- let mut extensions: Vec<Extension> =
- std::mem::take(&mut self.extensions_with_js);
- for m in extensions.iter_mut() {
- let js_files = m.init_js();
+ let extensions = std::mem::take(&mut self.extensions_with_js);
+ for ext in &extensions {
+ let js_files = ext.init_js();
for (filename, source) in js_files {
// TODO(@AaronO): use JsRuntime::execute_static() here to move src off heap
realm.execute_script(self.v8_isolate(), filename, source)?;
@@ -752,6 +751,12 @@ impl JsRuntime {
exts.extend(extensions);
exts.extend(extensions_with_js);
+ for (ext, previous_exts) in
+ exts.iter().enumerate().map(|(i, ext)| (ext, &exts[..i]))
+ {
+ ext.check_dependencies(previous_exts);
+ }
+
// Middleware
let middleware: Vec<Box<OpMiddlewareFn>> = exts
.iter_mut()
@@ -2554,7 +2559,7 @@ pub mod tests {
fn setup(mode: Mode) -> (JsRuntime, Arc<AtomicUsize>) {
let dispatch_count = Arc::new(AtomicUsize::new(0));
let dispatch_count2 = dispatch_count.clone();
- let ext = Extension::builder()
+ let ext = Extension::builder("test_ext")
.ops(vec![op_test::decl()])
.state(move |state| {
state.put(TestState {
@@ -2976,7 +2981,9 @@ pub mod tests {
}
run_in_task(|cx| {
- let ext = Extension::builder().ops(vec![op_err::decl()]).build();
+ let ext = Extension::builder("test_ext")
+ .ops(vec![op_err::decl()])
+ .build();
let mut runtime = JsRuntime::new(RuntimeOptions {
extensions: vec![ext],
get_error_class_fn: Some(&get_error_class_name),
@@ -3428,7 +3435,7 @@ main();
}
run_in_task(|cx| {
- let ext = Extension::builder()
+ let ext = Extension::builder("test_ext")
.ops(vec![op_err_sync::decl(), op_err_async::decl()])
.build();
let mut runtime = JsRuntime::new(RuntimeOptions {
@@ -3596,7 +3603,7 @@ assertEquals(1, notify_return_value);
Ok(())
}
- let extension = Extension::builder()
+ let extension = Extension::builder("test_ext")
.ops(vec![op_async_borrow::decl()])
.state(|state| {
state.put(InnerState(42));
@@ -3631,7 +3638,7 @@ assertEquals(1, notify_return_value);
Ok(())
}
- let extension = Extension::builder()
+ let extension = Extension::builder("test_ext")
.ops(vec![op_sync_serialize_object_with_numbers_as_keys::decl()])
.build();
@@ -3673,7 +3680,7 @@ Deno.core.ops.op_sync_serialize_object_with_numbers_as_keys({
Ok(())
}
- let extension = Extension::builder()
+ let extension = Extension::builder("test_ext")
.ops(vec![op_async_serialize_object_with_numbers_as_keys::decl()])
.build();
@@ -3712,7 +3719,7 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
Ok(())
}
- let extension = Extension::builder()
+ let extension = Extension::builder("test_ext")
.ops(vec![op_async_sleep::decl()])
.build();
@@ -3792,7 +3799,7 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
Ok(())
}
- let extension = Extension::builder()
+ let extension = Extension::builder("test_ext")
.ops(vec![op_macrotask::decl(), op_next_tick::decl()])
.build();
@@ -3922,7 +3929,7 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
Ok(())
}
- let extension = Extension::builder()
+ let extension = Extension::builder("test_ext")
.ops(vec![op_promise_reject::decl()])
.build();
@@ -3982,7 +3989,7 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
Ok(())
}
- let extension = Extension::builder()
+ let extension = Extension::builder("test_ext")
.ops(vec![op_promise_reject::decl()])
.build();
@@ -4051,7 +4058,9 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
Ok([(1, 2), (3, 4)].into_iter().collect()) // Maps can't have non-string keys in serde_v8
}
- let ext = Extension::builder().ops(vec![op_err::decl()]).build();
+ let ext = Extension::builder("test_ext")
+ .ops(vec![op_err::decl()])
+ .build();
let mut runtime = JsRuntime::new(RuntimeOptions {
extensions: vec![ext],
..Default::default()
@@ -4076,7 +4085,9 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
Ok(x1 + x2 + x3 + x4)
}
- let ext = Extension::builder().ops(vec![op_add_4::decl()]).build();
+ let ext = Extension::builder("test_ext")
+ .ops(vec![op_add_4::decl()])
+ .build();
let mut runtime = JsRuntime::new(RuntimeOptions {
extensions: vec![ext],
..Default::default()
@@ -4095,7 +4106,7 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
Ok(42)
}
- let ext = Extension::builder()
+ let ext = Extension::builder("test_ext")
.ops(vec![op_foo::decl().disable()])
.build();
let mut runtime = JsRuntime::new(RuntimeOptions {
@@ -4125,7 +4136,7 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
Ok(b)
}
- let ext = Extension::builder()
+ let ext = Extension::builder("test_ext")
.ops(vec![op_sum_take::decl(), op_boomerang::decl()])
.build();
@@ -4193,7 +4204,7 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
Ok(42)
}
- let ext = Extension::builder()
+ let ext = Extension::builder("test_ext")
.ops(vec![op_foo::decl(), op_bar::decl()])
.middleware(|op| if op.is_unstable { op.disable() } else { op })
.build();
@@ -4245,7 +4256,9 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
}
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![Extension::builder().ops(vec![op_test::decl()]).build()],
+ extensions: vec![Extension::builder("test_ext")
+ .ops(vec![op_test::decl()])
+ .build()],
..Default::default()
});
let realm = runtime.create_realm().unwrap();
@@ -4275,7 +4288,9 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
let mut runtime = JsRuntime::new(RuntimeOptions {
startup_snapshot: Some(Snapshot::Boxed(snapshot)),
- extensions: vec![Extension::builder().ops(vec![op_test::decl()]).build()],
+ extensions: vec![Extension::builder("test_ext")
+ .ops(vec![op_test::decl()])
+ .build()],
..Default::default()
});
let realm = runtime.create_realm().unwrap();
@@ -4304,7 +4319,9 @@ Deno.core.ops.op_async_serialize_object_with_numbers_as_keys({
}
let mut runtime = JsRuntime::new(RuntimeOptions {
- extensions: vec![Extension::builder().ops(vec![op_test::decl()]).build()],
+ extensions: vec![Extension::builder("test_ext")
+ .ops(vec![op_test::decl()])
+ .build()],
get_error_class_fn: Some(&|error| {
crate::error::get_custom_error_class(error).unwrap()
}),
diff --git a/ext/broadcast_channel/lib.rs b/ext/broadcast_channel/lib.rs
index 00f8ec9ce..0bf359e6b 100644
--- a/ext/broadcast_channel/lib.rs
+++ b/ext/broadcast_channel/lib.rs
@@ -109,7 +109,8 @@ pub fn init<BC: BroadcastChannel + 'static>(
bc: BC,
unstable: bool,
) -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
+ .dependencies(vec!["deno_webidl", "deno_web"])
.js(include_js_files!(
prefix "deno:ext/broadcast_channel",
"01_broadcast_channel.js",
diff --git a/ext/cache/lib.rs b/ext/cache/lib.rs
index 50a07b255..c48b7cda4 100644
--- a/ext/cache/lib.rs
+++ b/ext/cache/lib.rs
@@ -26,7 +26,8 @@ pub struct CreateCache<C: Cache + 'static>(pub Arc<dyn Fn() -> C>);
pub fn init<CA: Cache + 'static>(
maybe_create_cache: Option<CreateCache<CA>>,
) -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
+ .dependencies(vec!["deno_webidl", "deno_web", "deno_url", "deno_fetch"])
.js(include_js_files!(
prefix "deno:ext/cache",
"01_cache.js",
diff --git a/ext/console/lib.rs b/ext/console/lib.rs
index 3d98fc57f..d8fdb38f3 100644
--- a/ext/console/lib.rs
+++ b/ext/console/lib.rs
@@ -5,7 +5,7 @@ use deno_core::Extension;
use std::path::PathBuf;
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
.js(include_js_files!(
prefix "deno:ext/console",
"01_colors.js",
diff --git a/ext/crypto/lib.rs b/ext/crypto/lib.rs
index d5a83b5ec..cbcb816d9 100644
--- a/ext/crypto/lib.rs
+++ b/ext/crypto/lib.rs
@@ -73,7 +73,8 @@ use crate::key::HkdfOutput;
use crate::shared::RawKeyData;
pub fn init(maybe_seed: Option<u64>) -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
+ .dependencies(vec!["deno_webidl", "deno_web"])
.js(include_js_files!(
prefix "deno:ext/crypto",
"00_crypto.js",
diff --git a/ext/fetch/lib.rs b/ext/fetch/lib.rs
index 07af9fa15..b4c12fcbc 100644
--- a/ext/fetch/lib.rs
+++ b/ext/fetch/lib.rs
@@ -94,7 +94,8 @@ pub fn init<FP>(options: Options) -> Extension
where
FP: FetchPermissions + 'static,
{
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
+ .dependencies(vec!["deno_webidl", "deno_web", "deno_url", "deno_console"])
.js(include_js_files!(
prefix "deno:ext/fetch",
"01_fetch_util.js",
diff --git a/ext/ffi/lib.rs b/ext/ffi/lib.rs
index 0ae01dcd6..64d731491 100644
--- a/ext/ffi/lib.rs
+++ b/ext/ffi/lib.rs
@@ -84,7 +84,7 @@ pub(crate) struct FfiState {
}
pub fn init<P: FfiPermissions + 'static>(unstable: bool) -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
.js(include_js_files!(
prefix "deno:ext/ffi",
"00_ffi.js",
diff --git a/ext/flash/lib.rs b/ext/flash/lib.rs
index 6eaf39944..2e2417892 100644
--- a/ext/flash/lib.rs
+++ b/ext/flash/lib.rs
@@ -1505,7 +1505,14 @@ pub trait FlashPermissions {
}
pub fn init<P: FlashPermissions + 'static>(unstable: bool) -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
+ .dependencies(vec![
+ "deno_web",
+ "deno_net",
+ "deno_fetch",
+ "deno_websocket",
+ "deno_http",
+ ])
.js(deno_core::include_js_files!(
prefix "deno:ext/flash",
"01_http.js",
diff --git a/ext/http/lib.rs b/ext/http/lib.rs
index 8719f9de6..f1371ffec 100644
--- a/ext/http/lib.rs
+++ b/ext/http/lib.rs
@@ -78,7 +78,8 @@ pub mod compressible;
mod reader_stream;
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
+ .dependencies(vec!["deno_web", "deno_net", "deno_fetch", "deno_websocket"])
.js(include_js_files!(
prefix "deno:ext/http",
"01_http.js",
diff --git a/ext/napi/lib.rs b/ext/napi/lib.rs
index b281fb9f2..e76a08ed9 100644
--- a/ext/napi/lib.rs
+++ b/ext/napi/lib.rs
@@ -410,7 +410,7 @@ impl Env {
}
pub fn init<P: NapiPermissions + 'static>(unstable: bool) -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
.ops(vec![op_napi_open::decl::<P>()])
.event_loop_middleware(|op_state_rc, cx| {
// `work` can call back into the runtime. It can also schedule an async task
diff --git a/ext/net/lib.rs b/ext/net/lib.rs
index 63016ae6c..64e28fd00 100644
--- a/ext/net/lib.rs
+++ b/ext/net/lib.rs
@@ -85,7 +85,8 @@ pub fn init<P: NetPermissions + 'static>(
) -> Extension {
let mut ops = ops::init::<P>();
ops.extend(ops_tls::init::<P>());
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
+ .dependencies(vec!["deno_web"])
.js(include_js_files!(
prefix "deno:ext/net",
"01_net.js",
diff --git a/ext/net/ops.rs b/ext/net/ops.rs
index 583ce6b45..5f832a4b9 100644
--- a/ext/net/ops.rs
+++ b/ext/net/ops.rs
@@ -865,7 +865,7 @@ mod tests {
let listener = TcpListener::bind(addr).await.unwrap();
let _ = listener.accept().await;
});
- let my_ext = Extension::builder()
+ let my_ext = Extension::builder("test_ext")
.state(move |state| {
state.put(TestPermission {});
state.put(UnstableChecker { unstable: true });
diff --git a/ext/node/lib.rs b/ext/node/lib.rs
index d6fdd7679..a670586d1 100644
--- a/ext/node/lib.rs
+++ b/ext/node/lib.rs
@@ -80,7 +80,7 @@ pub static NODE_ENV_VAR_ALLOWLIST: Lazy<HashSet<String>> = Lazy::new(|| {
pub fn init<P: NodePermissions + 'static>(
maybe_npm_resolver: Option<Rc<dyn RequireNpmResolver>>,
) -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
.js(include_js_files!(
prefix "deno:ext/node",
"01_node.js",
diff --git a/ext/tls/lib.rs b/ext/tls/lib.rs
index 2b4a0600d..b762ac90a 100644
--- a/ext/tls/lib.rs
+++ b/ext/tls/lib.rs
@@ -37,7 +37,7 @@ use std::time::SystemTime;
/// This extension has no runtime apis, it only exports some shared native functions.
pub fn init() -> Extension {
- Extension::builder().build()
+ Extension::builder(env!("CARGO_PKG_NAME")).build()
}
struct DefaultSignatureVerification;
diff --git a/ext/url/benches/url_ops.rs b/ext/url/benches/url_ops.rs
index 315ea7260..63810733d 100644
--- a/ext/url/benches/url_ops.rs
+++ b/ext/url/benches/url_ops.rs
@@ -8,7 +8,7 @@ fn setup() -> Vec<Extension> {
vec![
deno_webidl::init(),
deno_url::init(),
- Extension::builder()
+ Extension::builder("bench_setup")
.js(vec![(
"setup",
"const { URL } = globalThis.__bootstrap.url;",
diff --git a/ext/url/lib.rs b/ext/url/lib.rs
index ba1167d54..6990017f5 100644
--- a/ext/url/lib.rs
+++ b/ext/url/lib.rs
@@ -18,7 +18,8 @@ use crate::urlpattern::op_urlpattern_parse;
use crate::urlpattern::op_urlpattern_process_match_input;
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
+ .dependencies(vec!["deno_webidl"])
.js(include_js_files!(
prefix "deno:ext/url",
"00_url.js",
diff --git a/ext/web/Cargo.toml b/ext/web/Cargo.toml
index bf30684ba..69a17963c 100644
--- a/ext/web/Cargo.toml
+++ b/ext/web/Cargo.toml
@@ -25,6 +25,7 @@ uuid = { workspace = true, features = ["serde"] }
[dev-dependencies]
deno_bench_util.workspace = true
+deno_console.workspace = true
deno_url.workspace = true
deno_webidl.workspace = true
diff --git a/ext/web/benches/encoding.rs b/ext/web/benches/encoding.rs
index 61c853328..8c9eaeb6c 100644
--- a/ext/web/benches/encoding.rs
+++ b/ext/web/benches/encoding.rs
@@ -24,8 +24,9 @@ fn setup() -> Vec<Extension> {
vec![
deno_webidl::init(),
deno_url::init(),
+ deno_console::init(),
deno_web::init::<Permissions>(BlobStore::default(), None),
- Extension::builder()
+ Extension::builder("bench_setup")
.js(vec![(
"setup",
r#"
diff --git a/ext/web/benches/timers_ops.rs b/ext/web/benches/timers_ops.rs
index 10b434015..2ba93c5e1 100644
--- a/ext/web/benches/timers_ops.rs
+++ b/ext/web/benches/timers_ops.rs
@@ -23,8 +23,9 @@ fn setup() -> Vec<Extension> {
vec![
deno_webidl::init(),
deno_url::init(),
+ deno_console::init(),
deno_web::init::<Permissions>(BlobStore::default(), None),
- Extension::builder()
+ Extension::builder("bench_setup")
.js(vec![
("setup", r#"
const { setTimeout, handleTimerMacrotask } = globalThis.__bootstrap.timers;
diff --git a/ext/web/lib.rs b/ext/web/lib.rs
index a270882a9..de8984232 100644
--- a/ext/web/lib.rs
+++ b/ext/web/lib.rs
@@ -62,7 +62,8 @@ pub fn init<P: TimersPermission + 'static>(
blob_store: BlobStore,
maybe_location: Option<Url>,
) -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
+ .dependencies(vec!["deno_webidl", "deno_console", "deno_url"])
.js(include_js_files!(
prefix "deno:ext/web",
"00_infra.js",
diff --git a/ext/webgpu/src/lib.rs b/ext/webgpu/src/lib.rs
index 8e67da6b8..9ee220dd0 100644
--- a/ext/webgpu/src/lib.rs
+++ b/ext/webgpu/src/lib.rs
@@ -104,7 +104,8 @@ impl Resource for WebGpuQuerySet {
}
pub fn init(unstable: bool) -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
+ .dependencies(vec!["deno_webidl", "deno_web"])
.js(include_js_files!(
prefix "deno:ext/webgpu",
"01_webgpu.js",
diff --git a/ext/webidl/lib.rs b/ext/webidl/lib.rs
index 583717d97..7962165c6 100644
--- a/ext/webidl/lib.rs
+++ b/ext/webidl/lib.rs
@@ -5,7 +5,7 @@ use deno_core::Extension;
/// Load and execute the javascript code.
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
.js(include_js_files!(
prefix "deno:ext/webidl",
"00_webidl.js",
diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs
index a58701e7a..bc4b3876d 100644
--- a/ext/websocket/lib.rs
+++ b/ext/websocket/lib.rs
@@ -602,7 +602,8 @@ pub fn init<P: WebSocketPermissions + 'static>(
root_cert_store: Option<RootCertStore>,
unsafely_ignore_certificate_errors: Option<Vec<String>>,
) -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
+ .dependencies(vec!["deno_url", "deno_webidl"])
.js(include_js_files!(
prefix "deno:ext/websocket",
"01_websocket.js",
diff --git a/ext/webstorage/lib.rs b/ext/webstorage/lib.rs
index 5425edc04..53175f196 100644
--- a/ext/webstorage/lib.rs
+++ b/ext/webstorage/lib.rs
@@ -22,7 +22,8 @@ struct OriginStorageDir(PathBuf);
const MAX_STORAGE_BYTES: u32 = 10 * 1024 * 1024;
pub fn init(origin_storage_dir: Option<PathBuf>) -> Extension {
- Extension::builder()
+ Extension::builder(env!("CARGO_PKG_NAME"))
+ .dependencies(vec!["deno_webidl"])
.js(include_js_files!(
prefix "deno:ext/webstorage",
"01_webstorage.js",
diff --git a/runtime/ops/fs.rs b/runtime/ops/fs.rs
index 87bb090c3..fe263d944 100644
--- a/runtime/ops/fs.rs
+++ b/runtime/ops/fs.rs
@@ -42,7 +42,7 @@ use deno_core::error::generic_error;
use deno_core::error::not_supported;
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder("deno_fs")
.ops(vec![
op_open_sync::decl(),
op_open_async::decl(),
diff --git a/runtime/ops/fs_events.rs b/runtime/ops/fs_events.rs
index 6cda48ef3..e550d204c 100644
--- a/runtime/ops/fs_events.rs
+++ b/runtime/ops/fs_events.rs
@@ -30,7 +30,7 @@ use std::rc::Rc;
use tokio::sync::mpsc;
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder("deno_fs_events")
.ops(vec![op_fs_events_open::decl(), op_fs_events_poll::decl()])
.build()
}
diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs
index e751adae8..a531deb84 100644
--- a/runtime/ops/http.rs
+++ b/runtime/ops/http.rs
@@ -27,7 +27,7 @@ use deno_net::io::UnixStreamResource;
use tokio::net::UnixStream;
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder("deno_http_runtime")
.ops(vec![
op_http_start::decl(),
op_http_upgrade::decl(),
diff --git a/runtime/ops/io.rs b/runtime/ops/io.rs
index 3bee7db60..43016395e 100644
--- a/runtime/ops/io.rs
+++ b/runtime/ops/io.rs
@@ -76,7 +76,7 @@ pub static STDERR_HANDLE: Lazy<StdFile> = Lazy::new(|| {
});
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder("deno_io")
.ops(vec![op_read_sync::decl(), op_write_sync::decl()])
.build()
}
@@ -114,7 +114,7 @@ pub fn init_stdio(stdio: Stdio) -> Extension {
// todo(dsheret): don't do this? Taking out the writers was necessary to prevent invalid handle panics
let stdio = Rc::new(RefCell::new(Some(stdio)));
- Extension::builder()
+ Extension::builder("deno_stdio")
.middleware(|op| match op.name {
"op_print" => op_print::decl(),
_ => op,
diff --git a/runtime/ops/os/mod.rs b/runtime/ops/os/mod.rs
index 537bb33f9..fec7629f5 100644
--- a/runtime/ops/os/mod.rs
+++ b/runtime/ops/os/mod.rs
@@ -40,7 +40,7 @@ fn init_ops(builder: &mut ExtensionBuilder) -> &mut ExtensionBuilder {
}
pub fn init(exit_code: ExitCode) -> Extension {
- let mut builder = Extension::builder();
+ let mut builder = Extension::builder("deno_os");
init_ops(&mut builder)
.state(move |state| {
state.put::<ExitCode>(exit_code.clone());
@@ -50,7 +50,7 @@ pub fn init(exit_code: ExitCode) -> Extension {
}
pub fn init_for_worker() -> Extension {
- let mut builder = Extension::builder();
+ let mut builder = Extension::builder("deno_os_worker");
init_ops(&mut builder)
.middleware(|op| match op.name {
"op_exit" => noop_op::decl(),
diff --git a/runtime/ops/permissions.rs b/runtime/ops/permissions.rs
index d0b0cdd8b..2b01da0a9 100644
--- a/runtime/ops/permissions.rs
+++ b/runtime/ops/permissions.rs
@@ -13,7 +13,7 @@ use serde::Deserialize;
use std::path::Path;
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder("deno_permissions")
.ops(vec![
op_query_permission::decl(),
op_revoke_permission::decl(),
diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs
index 86ad292b8..75d9cfdc9 100644
--- a/runtime/ops/process.rs
+++ b/runtime/ops/process.rs
@@ -27,7 +27,7 @@ use tokio::process::Command;
use std::os::unix::process::ExitStatusExt;
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder("deno_process")
.ops(vec![op_run::decl(), op_run_status::decl(), op_kill::decl()])
.build()
}
diff --git a/runtime/ops/runtime.rs b/runtime/ops/runtime.rs
index 52dc3f745..b97741acc 100644
--- a/runtime/ops/runtime.rs
+++ b/runtime/ops/runtime.rs
@@ -9,7 +9,7 @@ use deno_core::ModuleSpecifier;
use deno_core::OpState;
pub fn init(main_module: ModuleSpecifier) -> Extension {
- Extension::builder()
+ Extension::builder("deno_runtime")
.ops(vec![op_main_module::decl()])
.state(move |state| {
state.put::<ModuleSpecifier>(main_module.clone());
diff --git a/runtime/ops/signal.rs b/runtime/ops/signal.rs
index 14a9215ed..0af9a5c44 100644
--- a/runtime/ops/signal.rs
+++ b/runtime/ops/signal.rs
@@ -21,7 +21,7 @@ use tokio::signal::unix::{signal, Signal, SignalKind};
use tokio::signal::windows::{ctrl_break, ctrl_c, CtrlBreak, CtrlC};
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder("deno_signal")
.ops(vec![
op_signal_bind::decl(),
op_signal_unbind::decl(),
diff --git a/runtime/ops/spawn.rs b/runtime/ops/spawn.rs
index 4bbf1ef48..f552e9690 100644
--- a/runtime/ops/spawn.rs
+++ b/runtime/ops/spawn.rs
@@ -28,7 +28,7 @@ use std::os::unix::prelude::ExitStatusExt;
use std::os::unix::process::CommandExt;
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder("deno_spawn")
.ops(vec![
op_spawn_child::decl(),
op_node_unstable_spawn_child::decl(),
diff --git a/runtime/ops/tty.rs b/runtime/ops/tty.rs
index fd87f0e39..d022a43dc 100644
--- a/runtime/ops/tty.rs
+++ b/runtime/ops/tty.rs
@@ -34,7 +34,7 @@ fn get_windows_handle(
}
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder("deno_tty")
.ops(vec![
op_stdin_set_raw::decl(),
op_isatty::decl(),
diff --git a/runtime/ops/web_worker.rs b/runtime/ops/web_worker.rs
index 11aeac852..617615424 100644
--- a/runtime/ops/web_worker.rs
+++ b/runtime/ops/web_worker.rs
@@ -17,7 +17,7 @@ use std::rc::Rc;
use self::sync_fetch::op_worker_sync_fetch;
pub fn init() -> Extension {
- Extension::builder()
+ Extension::builder("deno_web_worker")
.ops(vec![
op_worker_post_message::decl(),
op_worker_recv_message::decl(),
diff --git a/runtime/ops/worker_host.rs b/runtime/ops/worker_host.rs
index 041d3ee6f..8945ff1cc 100644
--- a/runtime/ops/worker_host.rs
+++ b/runtime/ops/worker_host.rs
@@ -94,7 +94,7 @@ pub fn init(
pre_execute_module_cb: Arc<WorkerEventCb>,
format_js_error_fn: Option<Arc<FormatJsErrorFn>>,
) -> Extension {
- Extension::builder()
+ Extension::builder("deno_worker_host")
.state(move |state| {
state.put::<WorkersTable>(WorkersTable::default());
state.put::<WorkerId>(WorkerId::default());
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs
index 97ccbc870..5424860db 100644
--- a/runtime/web_worker.rs
+++ b/runtime/web_worker.rs
@@ -370,7 +370,7 @@ impl WebWorker {
// Permissions: many ops depend on this
let unstable = options.bootstrap.unstable;
let enable_testing_features = options.bootstrap.enable_testing_features;
- let perm_ext = Extension::builder()
+ let perm_ext = Extension::builder("deno_permissions_web_worker")
.state(move |state| {
state.put::<PermissionsContainer>(permissions.clone());
state.put(ops::UnstableChecker { unstable });
diff --git a/runtime/worker.rs b/runtime/worker.rs
index 64b8b2c06..5c076a2a5 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -202,7 +202,7 @@ impl MainWorker {
// Permissions: many ops depend on this
let unstable = options.bootstrap.unstable;
let enable_testing_features = options.bootstrap.enable_testing_features;
- let perm_ext = Extension::builder()
+ let perm_ext = Extension::builder("deno_permissions_worker")
.state(move |state| {
state.put::<PermissionsContainer>(permissions.clone());
state.put(ops::UnstableChecker { unstable });