mirror of
https://github.com/denoland/deno.git
synced 2025-01-05 13:59:01 -05:00
refactor(core): Extension::builder_with_deps (#18093)
Prerequisite for https://github.com/denoland/deno/pull/18080
This commit is contained in:
parent
cd9f11ae38
commit
9ebbd23ced
17 changed files with 309 additions and 289 deletions
|
@ -77,7 +77,7 @@ pub struct Extension {
|
|||
initialized: bool,
|
||||
enabled: bool,
|
||||
name: &'static str,
|
||||
deps: Option<Vec<&'static str>>,
|
||||
deps: Option<&'static [&'static str]>,
|
||||
}
|
||||
|
||||
// Note: this used to be a trait, but we "downgraded" it to a single concrete type
|
||||
|
@ -90,11 +90,22 @@ impl Extension {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn builder_with_deps(
|
||||
name: &'static str,
|
||||
deps: &'static [&'static str],
|
||||
) -> ExtensionBuilder {
|
||||
ExtensionBuilder {
|
||||
name,
|
||||
deps,
|
||||
..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 {
|
||||
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);
|
||||
|
@ -194,15 +205,10 @@ pub struct ExtensionBuilder {
|
|||
middleware: Option<Box<OpMiddlewareFn>>,
|
||||
event_loop_middleware: Option<Box<OpEventLoopFn>>,
|
||||
name: &'static str,
|
||||
deps: Vec<&'static str>,
|
||||
deps: &'static [&'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<ExtensionFileSource>) -> &mut Self {
|
||||
let js_files =
|
||||
// TODO(bartlomieju): if we're automatically remapping here, then we should
|
||||
|
|
|
@ -110,20 +110,22 @@ pub fn init<BC: BroadcastChannel + 'static>(
|
|||
bc: BC,
|
||||
unstable: bool,
|
||||
) -> Extension {
|
||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||
.dependencies(vec!["deno_webidl", "deno_web"])
|
||||
.esm(include_js_files!("01_broadcast_channel.js",))
|
||||
.ops(vec![
|
||||
op_broadcast_subscribe::decl::<BC>(),
|
||||
op_broadcast_unsubscribe::decl::<BC>(),
|
||||
op_broadcast_send::decl::<BC>(),
|
||||
op_broadcast_recv::decl::<BC>(),
|
||||
])
|
||||
.state(move |state| {
|
||||
state.put(bc.clone());
|
||||
state.put(Unstable(unstable));
|
||||
})
|
||||
.build()
|
||||
Extension::builder_with_deps(
|
||||
env!("CARGO_PKG_NAME"),
|
||||
&["deno_webidl", "deno_web"],
|
||||
)
|
||||
.esm(include_js_files!("01_broadcast_channel.js",))
|
||||
.ops(vec![
|
||||
op_broadcast_subscribe::decl::<BC>(),
|
||||
op_broadcast_unsubscribe::decl::<BC>(),
|
||||
op_broadcast_send::decl::<BC>(),
|
||||
op_broadcast_recv::decl::<BC>(),
|
||||
])
|
||||
.state(move |state| {
|
||||
state.put(bc.clone());
|
||||
state.put(Unstable(unstable));
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
||||
pub fn get_declaration() -> PathBuf {
|
||||
|
|
36
ext/cache/lib.rs
vendored
36
ext/cache/lib.rs
vendored
|
@ -25,23 +25,25 @@ 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(env!("CARGO_PKG_NAME"))
|
||||
.dependencies(vec!["deno_webidl", "deno_web", "deno_url", "deno_fetch"])
|
||||
.esm(include_js_files!("01_cache.js",))
|
||||
.ops(vec![
|
||||
op_cache_storage_open::decl::<CA>(),
|
||||
op_cache_storage_has::decl::<CA>(),
|
||||
op_cache_storage_delete::decl::<CA>(),
|
||||
op_cache_put::decl::<CA>(),
|
||||
op_cache_match::decl::<CA>(),
|
||||
op_cache_delete::decl::<CA>(),
|
||||
])
|
||||
.state(move |state| {
|
||||
if let Some(create_cache) = maybe_create_cache.clone() {
|
||||
state.put(create_cache);
|
||||
}
|
||||
})
|
||||
.build()
|
||||
Extension::builder_with_deps(
|
||||
env!("CARGO_PKG_NAME"),
|
||||
&["deno_webidl", "deno_web", "deno_url", "deno_fetch"],
|
||||
)
|
||||
.esm(include_js_files!("01_cache.js",))
|
||||
.ops(vec![
|
||||
op_cache_storage_open::decl::<CA>(),
|
||||
op_cache_storage_has::decl::<CA>(),
|
||||
op_cache_storage_delete::decl::<CA>(),
|
||||
op_cache_put::decl::<CA>(),
|
||||
op_cache_match::decl::<CA>(),
|
||||
op_cache_delete::decl::<CA>(),
|
||||
])
|
||||
.state(move |state| {
|
||||
if let Some(create_cache) = maybe_create_cache.clone() {
|
||||
state.put(create_cache);
|
||||
}
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
||||
pub fn get_declaration() -> PathBuf {
|
||||
|
|
|
@ -73,46 +73,48 @@ use crate::key::HkdfOutput;
|
|||
use crate::shared::RawKeyData;
|
||||
|
||||
pub fn init(maybe_seed: Option<u64>) -> Extension {
|
||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||
.dependencies(vec!["deno_webidl", "deno_web"])
|
||||
.esm(include_js_files!("00_crypto.js", "01_webidl.js",))
|
||||
.ops(vec![
|
||||
op_crypto_get_random_values::decl(),
|
||||
op_crypto_generate_key::decl(),
|
||||
op_crypto_sign_key::decl(),
|
||||
op_crypto_verify_key::decl(),
|
||||
op_crypto_derive_bits::decl(),
|
||||
op_crypto_import_key::decl(),
|
||||
op_crypto_export_key::decl(),
|
||||
op_crypto_encrypt::decl(),
|
||||
op_crypto_decrypt::decl(),
|
||||
op_crypto_subtle_digest::decl(),
|
||||
op_crypto_random_uuid::decl(),
|
||||
op_crypto_wrap_key::decl(),
|
||||
op_crypto_unwrap_key::decl(),
|
||||
op_crypto_base64url_decode::decl(),
|
||||
op_crypto_base64url_encode::decl(),
|
||||
x25519::op_generate_x25519_keypair::decl(),
|
||||
x25519::op_derive_bits_x25519::decl(),
|
||||
x25519::op_import_spki_x25519::decl(),
|
||||
x25519::op_import_pkcs8_x25519::decl(),
|
||||
ed25519::op_generate_ed25519_keypair::decl(),
|
||||
ed25519::op_import_spki_ed25519::decl(),
|
||||
ed25519::op_import_pkcs8_ed25519::decl(),
|
||||
ed25519::op_sign_ed25519::decl(),
|
||||
ed25519::op_verify_ed25519::decl(),
|
||||
ed25519::op_export_spki_ed25519::decl(),
|
||||
ed25519::op_export_pkcs8_ed25519::decl(),
|
||||
ed25519::op_jwk_x_ed25519::decl(),
|
||||
x25519::op_export_spki_x25519::decl(),
|
||||
x25519::op_export_pkcs8_x25519::decl(),
|
||||
])
|
||||
.state(move |state| {
|
||||
if let Some(seed) = maybe_seed {
|
||||
state.put(StdRng::seed_from_u64(seed));
|
||||
}
|
||||
})
|
||||
.build()
|
||||
Extension::builder_with_deps(
|
||||
env!("CARGO_PKG_NAME"),
|
||||
&["deno_webidl", "deno_web"],
|
||||
)
|
||||
.esm(include_js_files!("00_crypto.js", "01_webidl.js",))
|
||||
.ops(vec![
|
||||
op_crypto_get_random_values::decl(),
|
||||
op_crypto_generate_key::decl(),
|
||||
op_crypto_sign_key::decl(),
|
||||
op_crypto_verify_key::decl(),
|
||||
op_crypto_derive_bits::decl(),
|
||||
op_crypto_import_key::decl(),
|
||||
op_crypto_export_key::decl(),
|
||||
op_crypto_encrypt::decl(),
|
||||
op_crypto_decrypt::decl(),
|
||||
op_crypto_subtle_digest::decl(),
|
||||
op_crypto_random_uuid::decl(),
|
||||
op_crypto_wrap_key::decl(),
|
||||
op_crypto_unwrap_key::decl(),
|
||||
op_crypto_base64url_decode::decl(),
|
||||
op_crypto_base64url_encode::decl(),
|
||||
x25519::op_generate_x25519_keypair::decl(),
|
||||
x25519::op_derive_bits_x25519::decl(),
|
||||
x25519::op_import_spki_x25519::decl(),
|
||||
x25519::op_import_pkcs8_x25519::decl(),
|
||||
ed25519::op_generate_ed25519_keypair::decl(),
|
||||
ed25519::op_import_spki_ed25519::decl(),
|
||||
ed25519::op_import_pkcs8_ed25519::decl(),
|
||||
ed25519::op_sign_ed25519::decl(),
|
||||
ed25519::op_verify_ed25519::decl(),
|
||||
ed25519::op_export_spki_ed25519::decl(),
|
||||
ed25519::op_export_pkcs8_ed25519::decl(),
|
||||
ed25519::op_jwk_x_ed25519::decl(),
|
||||
x25519::op_export_spki_x25519::decl(),
|
||||
x25519::op_export_pkcs8_x25519::decl(),
|
||||
])
|
||||
.state(move |state| {
|
||||
if let Some(seed) = maybe_seed {
|
||||
state.put(StdRng::seed_from_u64(seed));
|
||||
}
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
||||
#[op]
|
||||
|
|
|
@ -95,37 +95,39 @@ pub fn init<FP>(options: Options) -> Extension
|
|||
where
|
||||
FP: FetchPermissions + 'static,
|
||||
{
|
||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||
.dependencies(vec!["deno_webidl", "deno_web", "deno_url", "deno_console"])
|
||||
.esm(include_js_files!(
|
||||
"20_headers.js",
|
||||
"21_formdata.js",
|
||||
"22_body.js",
|
||||
"22_http_client.js",
|
||||
"23_request.js",
|
||||
"23_response.js",
|
||||
"26_fetch.js",
|
||||
))
|
||||
.ops(vec![
|
||||
op_fetch::decl::<FP>(),
|
||||
op_fetch_send::decl(),
|
||||
op_fetch_custom_client::decl::<FP>(),
|
||||
])
|
||||
.state(move |state| {
|
||||
state.put::<Options>(options.clone());
|
||||
state.put::<reqwest::Client>({
|
||||
create_http_client(
|
||||
options.user_agent.clone(),
|
||||
options.root_cert_store.clone(),
|
||||
vec![],
|
||||
options.proxy.clone(),
|
||||
options.unsafely_ignore_certificate_errors.clone(),
|
||||
options.client_cert_chain_and_key.clone(),
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
})
|
||||
.build()
|
||||
Extension::builder_with_deps(
|
||||
env!("CARGO_PKG_NAME"),
|
||||
&["deno_webidl", "deno_web", "deno_url", "deno_console"],
|
||||
)
|
||||
.esm(include_js_files!(
|
||||
"20_headers.js",
|
||||
"21_formdata.js",
|
||||
"22_body.js",
|
||||
"22_http_client.js",
|
||||
"23_request.js",
|
||||
"23_response.js",
|
||||
"26_fetch.js",
|
||||
))
|
||||
.ops(vec![
|
||||
op_fetch::decl::<FP>(),
|
||||
op_fetch_send::decl(),
|
||||
op_fetch_custom_client::decl::<FP>(),
|
||||
])
|
||||
.state(move |state| {
|
||||
state.put::<Options>(options.clone());
|
||||
state.put::<reqwest::Client>({
|
||||
create_http_client(
|
||||
options.user_agent.clone(),
|
||||
options.root_cert_store.clone(),
|
||||
vec![],
|
||||
options.proxy.clone(),
|
||||
options.unsafely_ignore_certificate_errors.clone(),
|
||||
options.client_cert_chain_and_key.clone(),
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
||||
pub type CancelableResponseFuture =
|
||||
|
|
|
@ -82,8 +82,7 @@ pub(crate) struct FfiState {
|
|||
}
|
||||
|
||||
pub fn init<P: FfiPermissions + 'static>(unstable: bool) -> Extension {
|
||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||
.dependencies(vec!["deno_web"])
|
||||
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_web"])
|
||||
.esm(include_js_files!("00_ffi.js",))
|
||||
.ops(vec![
|
||||
op_ffi_load::decl::<P>(),
|
||||
|
|
|
@ -1527,46 +1527,48 @@ pub trait FlashPermissions {
|
|||
}
|
||||
|
||||
pub fn init<P: FlashPermissions + 'static>(unstable: bool) -> Extension {
|
||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||
.dependencies(vec![
|
||||
Extension::builder_with_deps(
|
||||
env!("CARGO_PKG_NAME"),
|
||||
&[
|
||||
"deno_web",
|
||||
"deno_net",
|
||||
"deno_fetch",
|
||||
"deno_websocket",
|
||||
"deno_http",
|
||||
])
|
||||
.esm(deno_core::include_js_files!("01_http.js",))
|
||||
.ops(vec![
|
||||
op_flash_serve::decl::<P>(),
|
||||
op_node_unstable_flash_serve::decl::<P>(),
|
||||
op_flash_respond::decl(),
|
||||
op_flash_respond_async::decl(),
|
||||
op_flash_respond_chunked::decl(),
|
||||
op_flash_method::decl(),
|
||||
op_flash_path::decl(),
|
||||
op_flash_headers::decl(),
|
||||
op_flash_addr::decl(),
|
||||
op_flash_next::decl(),
|
||||
op_flash_next_server::decl(),
|
||||
op_flash_next_async::decl(),
|
||||
op_flash_read_body::decl(),
|
||||
op_flash_upgrade_websocket::decl(),
|
||||
op_flash_drive_server::decl(),
|
||||
op_flash_wait_for_listening::decl(),
|
||||
op_flash_first_packet::decl(),
|
||||
op_flash_has_body_stream::decl(),
|
||||
op_flash_close_server::decl(),
|
||||
op_flash_make_request::decl(),
|
||||
op_flash_write_resource::decl(),
|
||||
op_try_flash_respond_chunked::decl(),
|
||||
])
|
||||
.state(move |op_state| {
|
||||
op_state.put(Unstable(unstable));
|
||||
op_state.put(FlashContext {
|
||||
next_server_id: 0,
|
||||
join_handles: HashMap::default(),
|
||||
servers: HashMap::default(),
|
||||
});
|
||||
})
|
||||
.build()
|
||||
],
|
||||
)
|
||||
.esm(deno_core::include_js_files!("01_http.js",))
|
||||
.ops(vec![
|
||||
op_flash_serve::decl::<P>(),
|
||||
op_node_unstable_flash_serve::decl::<P>(),
|
||||
op_flash_respond::decl(),
|
||||
op_flash_respond_async::decl(),
|
||||
op_flash_respond_chunked::decl(),
|
||||
op_flash_method::decl(),
|
||||
op_flash_path::decl(),
|
||||
op_flash_headers::decl(),
|
||||
op_flash_addr::decl(),
|
||||
op_flash_next::decl(),
|
||||
op_flash_next_server::decl(),
|
||||
op_flash_next_async::decl(),
|
||||
op_flash_read_body::decl(),
|
||||
op_flash_upgrade_websocket::decl(),
|
||||
op_flash_drive_server::decl(),
|
||||
op_flash_wait_for_listening::decl(),
|
||||
op_flash_first_packet::decl(),
|
||||
op_flash_has_body_stream::decl(),
|
||||
op_flash_close_server::decl(),
|
||||
op_flash_make_request::decl(),
|
||||
op_flash_write_resource::decl(),
|
||||
op_try_flash_respond_chunked::decl(),
|
||||
])
|
||||
.state(move |op_state| {
|
||||
op_state.put(Unstable(unstable));
|
||||
op_state.put(FlashContext {
|
||||
next_server_id: 0,
|
||||
join_handles: HashMap::default(),
|
||||
servers: HashMap::default(),
|
||||
});
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
|
|
@ -78,20 +78,22 @@ pub mod compressible;
|
|||
mod reader_stream;
|
||||
|
||||
pub fn init() -> Extension {
|
||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||
.dependencies(vec!["deno_web", "deno_net", "deno_fetch", "deno_websocket"])
|
||||
.esm(include_js_files!("01_http.js",))
|
||||
.ops(vec![
|
||||
op_http_accept::decl(),
|
||||
op_http_write_headers::decl(),
|
||||
op_http_headers::decl(),
|
||||
op_http_write::decl(),
|
||||
op_http_write_resource::decl(),
|
||||
op_http_shutdown::decl(),
|
||||
op_http_websocket_accept_header::decl(),
|
||||
op_http_upgrade_websocket::decl(),
|
||||
])
|
||||
.build()
|
||||
Extension::builder_with_deps(
|
||||
env!("CARGO_PKG_NAME"),
|
||||
&["deno_web", "deno_net", "deno_fetch", "deno_websocket"],
|
||||
)
|
||||
.esm(include_js_files!("01_http.js",))
|
||||
.ops(vec![
|
||||
op_http_accept::decl(),
|
||||
op_http_write_headers::decl(),
|
||||
op_http_headers::decl(),
|
||||
op_http_write::decl(),
|
||||
op_http_write_resource::decl(),
|
||||
op_http_shutdown::decl(),
|
||||
op_http_websocket_accept_header::decl(),
|
||||
op_http_upgrade_websocket::decl(),
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
pub enum HttpSocketAddr {
|
||||
|
|
|
@ -82,9 +82,8 @@ pub fn init(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("deno_io")
|
||||
Extension::builder_with_deps("deno_io", &["deno_web"])
|
||||
.ops(vec![op_read_sync::decl(), op_write_sync::decl()])
|
||||
.dependencies(vec!["deno_web"])
|
||||
.esm(include_js_files!("12_io.js",))
|
||||
.middleware(|op| match op.name {
|
||||
"op_print" => op_print::decl(),
|
||||
|
|
|
@ -84,8 +84,7 @@ pub fn init<P: NetPermissions + 'static>(
|
|||
) -> Extension {
|
||||
let mut ops = ops::init::<P>();
|
||||
ops.extend(ops_tls::init::<P>());
|
||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||
.dependencies(vec!["deno_web"])
|
||||
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_web"])
|
||||
.esm(include_js_files!("01_net.js", "02_tls.js",))
|
||||
.ops(ops)
|
||||
.state(move |state| {
|
||||
|
|
|
@ -332,10 +332,9 @@ pub fn init_polyfill_ops_and_esm() -> Extension {
|
|||
"zlib.ts",
|
||||
);
|
||||
|
||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_io", "deno_fs"])
|
||||
.esm(esm_files)
|
||||
.esm_entry_point("ext:deno_node/module_all.ts")
|
||||
.dependencies(vec!["deno_io", "deno_fs"])
|
||||
.ops(vec![
|
||||
crypto::op_node_create_hash::decl(),
|
||||
crypto::op_node_hash_update::decl(),
|
||||
|
|
|
@ -18,8 +18,7 @@ use crate::urlpattern::op_urlpattern_parse;
|
|||
use crate::urlpattern::op_urlpattern_process_match_input;
|
||||
|
||||
pub fn init() -> Extension {
|
||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||
.dependencies(vec!["deno_webidl"])
|
||||
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_webidl"])
|
||||
.esm(include_js_files!("00_url.js", "01_urlpattern.js",))
|
||||
.ops(vec![
|
||||
op_url_reparse::decl(),
|
||||
|
|
124
ext/web/lib.rs
124
ext/web/lib.rs
|
@ -62,67 +62,69 @@ pub fn init<P: TimersPermission + 'static>(
|
|||
blob_store: BlobStore,
|
||||
maybe_location: Option<Url>,
|
||||
) -> Extension {
|
||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||
.dependencies(vec!["deno_webidl", "deno_console", "deno_url"])
|
||||
.esm(include_js_files!(
|
||||
"00_infra.js",
|
||||
"01_dom_exception.js",
|
||||
"01_mimesniff.js",
|
||||
"02_event.js",
|
||||
"02_structured_clone.js",
|
||||
"02_timers.js",
|
||||
"03_abort_signal.js",
|
||||
"04_global_interfaces.js",
|
||||
"05_base64.js",
|
||||
"06_streams.js",
|
||||
"08_text_encoding.js",
|
||||
"09_file.js",
|
||||
"10_filereader.js",
|
||||
"11_blob_url.js",
|
||||
"12_location.js",
|
||||
"13_message_port.js",
|
||||
"14_compression.js",
|
||||
"15_performance.js",
|
||||
))
|
||||
.ops(vec![
|
||||
op_base64_decode::decl(),
|
||||
op_base64_encode::decl(),
|
||||
op_base64_atob::decl(),
|
||||
op_base64_btoa::decl(),
|
||||
op_encoding_normalize_label::decl(),
|
||||
op_encoding_decode_single::decl(),
|
||||
op_encoding_decode_utf8::decl(),
|
||||
op_encoding_new_decoder::decl(),
|
||||
op_encoding_decode::decl(),
|
||||
op_encoding_encode_into::decl(),
|
||||
op_encode_binary_string::decl(),
|
||||
op_blob_create_part::decl(),
|
||||
op_blob_slice_part::decl(),
|
||||
op_blob_read_part::decl(),
|
||||
op_blob_remove_part::decl(),
|
||||
op_blob_create_object_url::decl(),
|
||||
op_blob_revoke_object_url::decl(),
|
||||
op_blob_from_object_url::decl(),
|
||||
op_message_port_create_entangled::decl(),
|
||||
op_message_port_post_message::decl(),
|
||||
op_message_port_recv_message::decl(),
|
||||
compression::op_compression_new::decl(),
|
||||
compression::op_compression_write::decl(),
|
||||
compression::op_compression_finish::decl(),
|
||||
op_now::decl::<P>(),
|
||||
op_timer_handle::decl(),
|
||||
op_cancel_handle::decl(),
|
||||
op_sleep::decl(),
|
||||
op_transfer_arraybuffer::decl(),
|
||||
])
|
||||
.state(move |state| {
|
||||
state.put(blob_store.clone());
|
||||
if let Some(location) = maybe_location.clone() {
|
||||
state.put(Location(location));
|
||||
}
|
||||
state.put(StartTime::now());
|
||||
})
|
||||
.build()
|
||||
Extension::builder_with_deps(
|
||||
env!("CARGO_PKG_NAME"),
|
||||
&["deno_webidl", "deno_console", "deno_url"],
|
||||
)
|
||||
.esm(include_js_files!(
|
||||
"00_infra.js",
|
||||
"01_dom_exception.js",
|
||||
"01_mimesniff.js",
|
||||
"02_event.js",
|
||||
"02_structured_clone.js",
|
||||
"02_timers.js",
|
||||
"03_abort_signal.js",
|
||||
"04_global_interfaces.js",
|
||||
"05_base64.js",
|
||||
"06_streams.js",
|
||||
"08_text_encoding.js",
|
||||
"09_file.js",
|
||||
"10_filereader.js",
|
||||
"11_blob_url.js",
|
||||
"12_location.js",
|
||||
"13_message_port.js",
|
||||
"14_compression.js",
|
||||
"15_performance.js",
|
||||
))
|
||||
.ops(vec![
|
||||
op_base64_decode::decl(),
|
||||
op_base64_encode::decl(),
|
||||
op_base64_atob::decl(),
|
||||
op_base64_btoa::decl(),
|
||||
op_encoding_normalize_label::decl(),
|
||||
op_encoding_decode_single::decl(),
|
||||
op_encoding_decode_utf8::decl(),
|
||||
op_encoding_new_decoder::decl(),
|
||||
op_encoding_decode::decl(),
|
||||
op_encoding_encode_into::decl(),
|
||||
op_encode_binary_string::decl(),
|
||||
op_blob_create_part::decl(),
|
||||
op_blob_slice_part::decl(),
|
||||
op_blob_read_part::decl(),
|
||||
op_blob_remove_part::decl(),
|
||||
op_blob_create_object_url::decl(),
|
||||
op_blob_revoke_object_url::decl(),
|
||||
op_blob_from_object_url::decl(),
|
||||
op_message_port_create_entangled::decl(),
|
||||
op_message_port_post_message::decl(),
|
||||
op_message_port_recv_message::decl(),
|
||||
compression::op_compression_new::decl(),
|
||||
compression::op_compression_write::decl(),
|
||||
compression::op_compression_finish::decl(),
|
||||
op_now::decl::<P>(),
|
||||
op_timer_handle::decl(),
|
||||
op_cancel_handle::decl(),
|
||||
op_sleep::decl(),
|
||||
op_transfer_arraybuffer::decl(),
|
||||
])
|
||||
.state(move |state| {
|
||||
state.put(blob_store.clone());
|
||||
if let Some(location) = maybe_location.clone() {
|
||||
state.put(Location(location));
|
||||
}
|
||||
state.put(StartTime::now());
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
||||
#[op]
|
||||
|
|
|
@ -117,18 +117,20 @@ impl Resource for WebGpuQuerySet {
|
|||
}
|
||||
|
||||
pub fn init(unstable: bool) -> Extension {
|
||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||
.dependencies(vec!["deno_webidl", "deno_web"])
|
||||
.esm(include_js_files!("01_webgpu.js", "02_idl_types.js",))
|
||||
.ops(declare_webgpu_ops())
|
||||
.state(move |state| {
|
||||
// TODO: check & possibly streamline this
|
||||
// Unstable might be able to be OpMiddleware
|
||||
// let unstable_checker = state.borrow::<super::UnstableChecker>();
|
||||
// let unstable = unstable_checker.unstable;
|
||||
state.put(Unstable(unstable));
|
||||
})
|
||||
.build()
|
||||
Extension::builder_with_deps(
|
||||
env!("CARGO_PKG_NAME"),
|
||||
&["deno_webidl", "deno_web"],
|
||||
)
|
||||
.esm(include_js_files!("01_webgpu.js", "02_idl_types.js",))
|
||||
.ops(declare_webgpu_ops())
|
||||
.state(move |state| {
|
||||
// TODO: check & possibly streamline this
|
||||
// Unstable might be able to be OpMiddleware
|
||||
// let unstable_checker = state.borrow::<super::UnstableChecker>();
|
||||
// let unstable = unstable_checker.unstable;
|
||||
state.put(Unstable(unstable));
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
||||
fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> {
|
||||
|
|
|
@ -502,27 +502,29 @@ pub fn init<P: WebSocketPermissions + 'static>(
|
|||
root_cert_store: Option<RootCertStore>,
|
||||
unsafely_ignore_certificate_errors: Option<Vec<String>>,
|
||||
) -> Extension {
|
||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||
.dependencies(vec!["deno_url", "deno_webidl"])
|
||||
.esm(include_js_files!(
|
||||
"01_websocket.js",
|
||||
"02_websocketstream.js",
|
||||
))
|
||||
.ops(vec![
|
||||
op_ws_check_permission_and_cancel_handle::decl::<P>(),
|
||||
op_ws_create::decl::<P>(),
|
||||
op_ws_send::decl(),
|
||||
op_ws_close::decl(),
|
||||
op_ws_next_event::decl(),
|
||||
])
|
||||
.state(move |state| {
|
||||
state.put::<WsUserAgent>(WsUserAgent(user_agent.clone()));
|
||||
state.put(UnsafelyIgnoreCertificateErrors(
|
||||
unsafely_ignore_certificate_errors.clone(),
|
||||
));
|
||||
state.put::<WsRootStore>(WsRootStore(root_cert_store.clone()));
|
||||
})
|
||||
.build()
|
||||
Extension::builder_with_deps(
|
||||
env!("CARGO_PKG_NAME"),
|
||||
&["deno_url", "deno_webidl"],
|
||||
)
|
||||
.esm(include_js_files!(
|
||||
"01_websocket.js",
|
||||
"02_websocketstream.js",
|
||||
))
|
||||
.ops(vec![
|
||||
op_ws_check_permission_and_cancel_handle::decl::<P>(),
|
||||
op_ws_create::decl::<P>(),
|
||||
op_ws_send::decl(),
|
||||
op_ws_close::decl(),
|
||||
op_ws_next_event::decl(),
|
||||
])
|
||||
.state(move |state| {
|
||||
state.put::<WsUserAgent>(WsUserAgent(user_agent.clone()));
|
||||
state.put(UnsafelyIgnoreCertificateErrors(
|
||||
unsafely_ignore_certificate_errors.clone(),
|
||||
));
|
||||
state.put::<WsRootStore>(WsRootStore(root_cert_store.clone()));
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
||||
pub fn get_declaration() -> PathBuf {
|
||||
|
|
|
@ -22,8 +22,7 @@ struct OriginStorageDir(PathBuf);
|
|||
const MAX_STORAGE_BYTES: u32 = 10 * 1024 * 1024;
|
||||
|
||||
pub fn init(origin_storage_dir: Option<PathBuf>) -> Extension {
|
||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||
.dependencies(vec!["deno_webidl"])
|
||||
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_webidl"])
|
||||
.esm(include_js_files!("01_webstorage.js",))
|
||||
.ops(vec![
|
||||
op_webstorage_length::decl(),
|
||||
|
|
|
@ -204,8 +204,9 @@ mod startup_snapshot {
|
|||
snapshot_path: PathBuf,
|
||||
maybe_additional_extension: Option<Extension>,
|
||||
) {
|
||||
let runtime_extension = Extension::builder("runtime")
|
||||
.dependencies(vec![
|
||||
let runtime_extension = Extension::builder_with_deps(
|
||||
"runtime",
|
||||
&[
|
||||
"deno_webidl",
|
||||
"deno_console",
|
||||
"deno_url",
|
||||
|
@ -227,26 +228,27 @@ mod startup_snapshot {
|
|||
"deno_flash",
|
||||
"deno_io",
|
||||
"deno_fs",
|
||||
])
|
||||
.esm(include_js_files!(
|
||||
dir "js",
|
||||
"01_errors.js",
|
||||
"01_version.ts",
|
||||
"06_util.js",
|
||||
"10_permissions.js",
|
||||
"11_workers.js",
|
||||
"13_buffer.js",
|
||||
"30_os.js",
|
||||
"40_fs_events.js",
|
||||
"40_http.js",
|
||||
"40_process.js",
|
||||
"40_signals.js",
|
||||
"40_tty.js",
|
||||
"41_prompt.js",
|
||||
"90_deno_ns.js",
|
||||
"98_global_scope.js",
|
||||
))
|
||||
.build();
|
||||
],
|
||||
)
|
||||
.esm(include_js_files!(
|
||||
dir "js",
|
||||
"01_errors.js",
|
||||
"01_version.ts",
|
||||
"06_util.js",
|
||||
"10_permissions.js",
|
||||
"11_workers.js",
|
||||
"13_buffer.js",
|
||||
"30_os.js",
|
||||
"40_fs_events.js",
|
||||
"40_http.js",
|
||||
"40_process.js",
|
||||
"40_signals.js",
|
||||
"40_tty.js",
|
||||
"41_prompt.js",
|
||||
"90_deno_ns.js",
|
||||
"98_global_scope.js",
|
||||
))
|
||||
.build();
|
||||
|
||||
let mut extensions_with_js: Vec<Extension> = vec![
|
||||
deno_webidl::init(),
|
||||
|
|
Loading…
Reference in a new issue