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