mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
refactor: Split extension registration for runtime and snapshotting (#18095)
This commit splits "<ext_name>::init" functions into "init_ops" and "init_ops_and_esm". That way we don't have to construct list of ESM sources on each startup if we're running with a snapshot. In a follow up commit "deno_core" will be changed to not have a split between "extensions" and "extensions_with_js" - it will be embedders' responsibility to pass appropriately configured extensions. Prerequisite for https://github.com/denoland/deno/pull/18080
This commit is contained in:
parent
99da8a69e7
commit
8f207c0f3f
26 changed files with 1015 additions and 496 deletions
40
cli/build.rs
40
cli/build.rs
|
@ -322,36 +322,40 @@ mod ts {
|
||||||
|
|
||||||
fn create_cli_snapshot(snapshot_path: PathBuf) {
|
fn create_cli_snapshot(snapshot_path: PathBuf) {
|
||||||
let extensions: Vec<Extension> = vec![
|
let extensions: Vec<Extension> = vec![
|
||||||
deno_webidl::init(),
|
deno_webidl::init_esm(),
|
||||||
deno_console::init(),
|
deno_console::init_esm(),
|
||||||
deno_url::init(),
|
deno_url::init_ops_and_esm(),
|
||||||
deno_tls::init(),
|
deno_tls::init(),
|
||||||
deno_web::init::<PermissionsContainer>(
|
deno_web::init_ops_and_esm::<PermissionsContainer>(
|
||||||
deno_web::BlobStore::default(),
|
deno_web::BlobStore::default(),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
),
|
),
|
||||||
deno_fetch::init::<PermissionsContainer>(Default::default()),
|
deno_fetch::init_ops_and_esm::<PermissionsContainer>(Default::default()),
|
||||||
deno_cache::init::<SqliteBackedCache>(None),
|
deno_cache::init_ops_and_esm::<SqliteBackedCache>(None),
|
||||||
deno_websocket::init::<PermissionsContainer>("".to_owned(), None, None),
|
deno_websocket::init_ops_and_esm::<PermissionsContainer>(
|
||||||
deno_webstorage::init(None),
|
"".to_owned(),
|
||||||
deno_crypto::init(None),
|
None,
|
||||||
deno_webgpu::init(false),
|
None,
|
||||||
deno_broadcast_channel::init(
|
),
|
||||||
|
deno_webstorage::init_ops_and_esm(None),
|
||||||
|
deno_crypto::init_ops_and_esm(None),
|
||||||
|
deno_webgpu::init_ops_and_esm(false),
|
||||||
|
deno_broadcast_channel::init_ops_and_esm(
|
||||||
deno_broadcast_channel::InMemoryBroadcastChannel::default(),
|
deno_broadcast_channel::InMemoryBroadcastChannel::default(),
|
||||||
false, // No --unstable.
|
false, // No --unstable.
|
||||||
),
|
),
|
||||||
deno_io::init(Default::default()),
|
deno_io::init_ops_and_esm(Default::default()),
|
||||||
deno_fs::init::<PermissionsContainer>(false),
|
deno_fs::init_ops_and_esm::<PermissionsContainer>(false),
|
||||||
deno_node::init::<PermissionsContainer>(None), // No --unstable.
|
deno_node::init_ops_and_esm::<PermissionsContainer>(None), // No --unstable.
|
||||||
deno_node::init_polyfill_ops_and_esm(),
|
deno_node::init_polyfill_ops_and_esm(),
|
||||||
deno_ffi::init::<PermissionsContainer>(false),
|
deno_ffi::init_ops_and_esm::<PermissionsContainer>(false),
|
||||||
deno_net::init::<PermissionsContainer>(
|
deno_net::init_ops_and_esm::<PermissionsContainer>(
|
||||||
None, false, // No --unstable.
|
None, false, // No --unstable.
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
deno_napi::init::<PermissionsContainer>(),
|
deno_napi::init::<PermissionsContainer>(),
|
||||||
deno_http::init(),
|
deno_http::init_ops_and_esm(),
|
||||||
deno_flash::init::<PermissionsContainer>(false), // No --unstable
|
deno_flash::init_ops_and_esm::<PermissionsContainer>(false), // No --unstable
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut esm_files = include_js_files!(
|
let mut esm_files = include_js_files!(
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
mod in_memory_broadcast_channel;
|
mod in_memory_broadcast_channel;
|
||||||
|
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
pub use in_memory_broadcast_channel::InMemoryBroadcastChannel;
|
pub use in_memory_broadcast_channel::InMemoryBroadcastChannel;
|
||||||
pub use in_memory_broadcast_channel::InMemoryBroadcastChannelResource;
|
pub use in_memory_broadcast_channel::InMemoryBroadcastChannelResource;
|
||||||
|
|
||||||
|
@ -106,15 +107,19 @@ where
|
||||||
bc.recv(&resource).await
|
bc.recv(&resource).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init<BC: BroadcastChannel + 'static>(
|
fn ext() -> ExtensionBuilder {
|
||||||
bc: BC,
|
|
||||||
unstable: bool,
|
|
||||||
) -> Extension {
|
|
||||||
Extension::builder_with_deps(
|
Extension::builder_with_deps(
|
||||||
env!("CARGO_PKG_NAME"),
|
env!("CARGO_PKG_NAME"),
|
||||||
&["deno_webidl", "deno_web"],
|
&["deno_webidl", "deno_web"],
|
||||||
)
|
)
|
||||||
.esm(include_js_files!("01_broadcast_channel.js",))
|
}
|
||||||
|
|
||||||
|
fn ops<BC: BroadcastChannel + 'static>(
|
||||||
|
ext: &mut ExtensionBuilder,
|
||||||
|
bc: BC,
|
||||||
|
unstable: bool,
|
||||||
|
) -> &mut ExtensionBuilder {
|
||||||
|
ext
|
||||||
.ops(vec![
|
.ops(vec![
|
||||||
op_broadcast_subscribe::decl::<BC>(),
|
op_broadcast_subscribe::decl::<BC>(),
|
||||||
op_broadcast_unsubscribe::decl::<BC>(),
|
op_broadcast_unsubscribe::decl::<BC>(),
|
||||||
|
@ -125,9 +130,24 @@ pub fn init<BC: BroadcastChannel + 'static>(
|
||||||
state.put(bc.clone());
|
state.put(bc.clone());
|
||||||
state.put(Unstable(unstable));
|
state.put(Unstable(unstable));
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm<BC: BroadcastChannel + 'static>(
|
||||||
|
bc: BC,
|
||||||
|
unstable: bool,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<BC>(&mut ext(), bc, unstable)
|
||||||
|
.esm(include_js_files!("01_broadcast_channel.js",))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_ops<BC: BroadcastChannel + 'static>(
|
||||||
|
bc: BC,
|
||||||
|
unstable: bool,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<BC>(&mut ext(), bc, unstable).build()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_declaration() -> PathBuf {
|
pub fn get_declaration() -> PathBuf {
|
||||||
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||||
.join("lib.deno_broadcast_channel.d.ts")
|
.join("lib.deno_broadcast_channel.d.ts")
|
||||||
|
|
26
ext/cache/lib.rs
vendored
26
ext/cache/lib.rs
vendored
|
@ -13,6 +13,7 @@ use deno_core::serde::Deserialize;
|
||||||
use deno_core::serde::Serialize;
|
use deno_core::serde::Serialize;
|
||||||
use deno_core::ByteString;
|
use deno_core::ByteString;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_core::Resource;
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
|
@ -22,14 +23,18 @@ pub use sqlite::SqliteBackedCache;
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct CreateCache<C: Cache + 'static>(pub Arc<dyn Fn() -> C>);
|
pub struct CreateCache<C: Cache + 'static>(pub Arc<dyn Fn() -> C>);
|
||||||
|
|
||||||
pub fn init<CA: Cache + 'static>(
|
fn ext() -> ExtensionBuilder {
|
||||||
maybe_create_cache: Option<CreateCache<CA>>,
|
|
||||||
) -> Extension {
|
|
||||||
Extension::builder_with_deps(
|
Extension::builder_with_deps(
|
||||||
env!("CARGO_PKG_NAME"),
|
env!("CARGO_PKG_NAME"),
|
||||||
&["deno_webidl", "deno_web", "deno_url", "deno_fetch"],
|
&["deno_webidl", "deno_web", "deno_url", "deno_fetch"],
|
||||||
)
|
)
|
||||||
.esm(include_js_files!("01_cache.js",))
|
}
|
||||||
|
|
||||||
|
fn ops<CA: Cache + 'static>(
|
||||||
|
ext: &mut ExtensionBuilder,
|
||||||
|
maybe_create_cache: Option<CreateCache<CA>>,
|
||||||
|
) -> &mut ExtensionBuilder {
|
||||||
|
ext
|
||||||
.ops(vec![
|
.ops(vec![
|
||||||
op_cache_storage_open::decl::<CA>(),
|
op_cache_storage_open::decl::<CA>(),
|
||||||
op_cache_storage_has::decl::<CA>(),
|
op_cache_storage_has::decl::<CA>(),
|
||||||
|
@ -43,9 +48,22 @@ pub fn init<CA: Cache + 'static>(
|
||||||
state.put(create_cache);
|
state.put(create_cache);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm<CA: Cache + 'static>(
|
||||||
|
maybe_create_cache: Option<CreateCache<CA>>,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<CA>(&mut ext(), maybe_create_cache)
|
||||||
|
.esm(include_js_files!("01_cache.js",))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_ops<CA: Cache + 'static>(
|
||||||
|
maybe_create_cache: Option<CreateCache<CA>>,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<CA>(&mut ext(), maybe_create_cache).build()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_declaration() -> PathBuf {
|
pub fn get_declaration() -> PathBuf {
|
||||||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_cache.d.ts")
|
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_cache.d.ts")
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,18 @@
|
||||||
|
|
||||||
use deno_core::include_js_files;
|
use deno_core::include_js_files;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub fn init() -> Extension {
|
fn ext() -> ExtensionBuilder {
|
||||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||||
|
}
|
||||||
|
pub fn init() -> Extension {
|
||||||
|
ext().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_esm() -> Extension {
|
||||||
|
ext()
|
||||||
.esm(include_js_files!("01_colors.js", "02_console.js",))
|
.esm(include_js_files!("01_colors.js", "02_console.js",))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ use deno_core::error::type_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::include_js_files;
|
use deno_core::include_js_files;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
|
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
|
@ -72,12 +73,18 @@ use crate::key::CryptoNamedCurve;
|
||||||
use crate::key::HkdfOutput;
|
use crate::key::HkdfOutput;
|
||||||
use crate::shared::RawKeyData;
|
use crate::shared::RawKeyData;
|
||||||
|
|
||||||
pub fn init(maybe_seed: Option<u64>) -> Extension {
|
fn ext() -> ExtensionBuilder {
|
||||||
Extension::builder_with_deps(
|
Extension::builder_with_deps(
|
||||||
env!("CARGO_PKG_NAME"),
|
env!("CARGO_PKG_NAME"),
|
||||||
&["deno_webidl", "deno_web"],
|
&["deno_webidl", "deno_web"],
|
||||||
)
|
)
|
||||||
.esm(include_js_files!("00_crypto.js", "01_webidl.js",))
|
}
|
||||||
|
|
||||||
|
fn ops(
|
||||||
|
ext: &mut ExtensionBuilder,
|
||||||
|
maybe_seed: Option<u64>,
|
||||||
|
) -> &mut ExtensionBuilder {
|
||||||
|
ext
|
||||||
.ops(vec![
|
.ops(vec![
|
||||||
op_crypto_get_random_values::decl(),
|
op_crypto_get_random_values::decl(),
|
||||||
op_crypto_generate_key::decl(),
|
op_crypto_generate_key::decl(),
|
||||||
|
@ -114,9 +121,18 @@ pub fn init(maybe_seed: Option<u64>) -> Extension {
|
||||||
state.put(StdRng::seed_from_u64(seed));
|
state.put(StdRng::seed_from_u64(seed));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm(maybe_seed: Option<u64>) -> Extension {
|
||||||
|
ops(&mut ext(), maybe_seed)
|
||||||
|
.esm(include_js_files!("00_crypto.js", "01_webidl.js",))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_ops(maybe_seed: Option<u64>) -> Extension {
|
||||||
|
ops(&mut ext(), maybe_seed).build()
|
||||||
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
pub fn op_crypto_base64url_decode(data: String) -> ZeroCopyBuf {
|
pub fn op_crypto_base64url_decode(data: String) -> ZeroCopyBuf {
|
||||||
let data: Vec<u8> =
|
let data: Vec<u8> =
|
||||||
|
|
|
@ -13,6 +13,7 @@ use deno_core::futures::StreamExt;
|
||||||
use deno_core::include_js_files;
|
use deno_core::include_js_files;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
use deno_core::BufView;
|
use deno_core::BufView;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use deno_core::WriteOutcome;
|
use deno_core::WriteOutcome;
|
||||||
|
|
||||||
use deno_core::url::Url;
|
use deno_core::url::Url;
|
||||||
|
@ -91,23 +92,21 @@ impl Default for Options {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init<FP>(options: Options) -> Extension
|
fn ext() -> ExtensionBuilder {
|
||||||
where
|
|
||||||
FP: FetchPermissions + 'static,
|
|
||||||
{
|
|
||||||
Extension::builder_with_deps(
|
Extension::builder_with_deps(
|
||||||
env!("CARGO_PKG_NAME"),
|
env!("CARGO_PKG_NAME"),
|
||||||
&["deno_webidl", "deno_web", "deno_url", "deno_console"],
|
&["deno_webidl", "deno_web", "deno_url", "deno_console"],
|
||||||
)
|
)
|
||||||
.esm(include_js_files!(
|
}
|
||||||
"20_headers.js",
|
|
||||||
"21_formdata.js",
|
fn ops<FP>(
|
||||||
"22_body.js",
|
ext: &mut ExtensionBuilder,
|
||||||
"22_http_client.js",
|
options: Options,
|
||||||
"23_request.js",
|
) -> &mut ExtensionBuilder
|
||||||
"23_response.js",
|
where
|
||||||
"26_fetch.js",
|
FP: FetchPermissions + 'static,
|
||||||
))
|
{
|
||||||
|
ext
|
||||||
.ops(vec![
|
.ops(vec![
|
||||||
op_fetch::decl::<FP>(),
|
op_fetch::decl::<FP>(),
|
||||||
op_fetch_send::decl(),
|
op_fetch_send::decl(),
|
||||||
|
@ -127,6 +126,39 @@ where
|
||||||
.unwrap()
|
.unwrap()
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm<FP>(options: Options) -> Extension
|
||||||
|
where
|
||||||
|
FP: FetchPermissions + 'static,
|
||||||
|
{
|
||||||
|
ops::<FP>(&mut ext(), options)
|
||||||
|
.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",
|
||||||
|
))
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops<FP>(options: Options) -> Extension
|
||||||
|
where
|
||||||
|
FP: FetchPermissions + 'static,
|
||||||
|
{
|
||||||
|
ops::<FP>(&mut ext(), options)
|
||||||
|
.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",
|
||||||
|
))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ use deno_core::futures::channel::mpsc;
|
||||||
use deno_core::include_js_files;
|
use deno_core::include_js_files;
|
||||||
use deno_core::v8;
|
use deno_core::v8;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
@ -81,9 +82,15 @@ pub(crate) struct FfiState {
|
||||||
pub(crate) async_work_receiver: mpsc::UnboundedReceiver<PendingFfiAsyncWork>,
|
pub(crate) async_work_receiver: mpsc::UnboundedReceiver<PendingFfiAsyncWork>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init<P: FfiPermissions + 'static>(unstable: bool) -> Extension {
|
fn ext() -> ExtensionBuilder {
|
||||||
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_web"])
|
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_web"])
|
||||||
.esm(include_js_files!("00_ffi.js",))
|
}
|
||||||
|
|
||||||
|
fn ops<P: FfiPermissions + 'static>(
|
||||||
|
ext: &mut ExtensionBuilder,
|
||||||
|
unstable: bool,
|
||||||
|
) -> &mut ExtensionBuilder {
|
||||||
|
ext
|
||||||
.ops(vec![
|
.ops(vec![
|
||||||
op_ffi_load::decl::<P>(),
|
op_ffi_load::decl::<P>(),
|
||||||
op_ffi_get_static::decl(),
|
op_ffi_get_static::decl(),
|
||||||
|
@ -151,5 +158,18 @@ pub fn init<P: FfiPermissions + 'static>(unstable: bool) -> Extension {
|
||||||
async_work_sender,
|
async_work_sender,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm<P: FfiPermissions + 'static>(
|
||||||
|
unstable: bool,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<P>(&mut ext(), unstable)
|
||||||
|
.esm(include_js_files!("00_ffi.js",))
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops<P: FfiPermissions + 'static>(unstable: bool) -> Extension {
|
||||||
|
ops::<P>(&mut ext(), unstable)
|
||||||
|
.esm(include_js_files!("00_ffi.js",))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ use deno_core::ByteString;
|
||||||
use deno_core::CancelFuture;
|
use deno_core::CancelFuture;
|
||||||
use deno_core::CancelHandle;
|
use deno_core::CancelHandle;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_core::StringOrBuffer;
|
use deno_core::StringOrBuffer;
|
||||||
use deno_core::ZeroCopyBuf;
|
use deno_core::ZeroCopyBuf;
|
||||||
|
@ -1526,7 +1527,7 @@ pub trait FlashPermissions {
|
||||||
) -> Result<(), AnyError>;
|
) -> Result<(), AnyError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init<P: FlashPermissions + 'static>(unstable: bool) -> Extension {
|
fn ext() -> ExtensionBuilder {
|
||||||
Extension::builder_with_deps(
|
Extension::builder_with_deps(
|
||||||
env!("CARGO_PKG_NAME"),
|
env!("CARGO_PKG_NAME"),
|
||||||
&[
|
&[
|
||||||
|
@ -1537,7 +1538,13 @@ pub fn init<P: FlashPermissions + 'static>(unstable: bool) -> Extension {
|
||||||
"deno_http",
|
"deno_http",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.esm(deno_core::include_js_files!("01_http.js",))
|
}
|
||||||
|
|
||||||
|
fn ops<P: FlashPermissions + 'static>(
|
||||||
|
ext: &mut ExtensionBuilder,
|
||||||
|
unstable: bool,
|
||||||
|
) -> &mut ExtensionBuilder {
|
||||||
|
ext
|
||||||
.ops(vec![
|
.ops(vec![
|
||||||
op_flash_serve::decl::<P>(),
|
op_flash_serve::decl::<P>(),
|
||||||
op_node_unstable_flash_serve::decl::<P>(),
|
op_node_unstable_flash_serve::decl::<P>(),
|
||||||
|
@ -1570,5 +1577,16 @@ pub fn init<P: FlashPermissions + 'static>(unstable: bool) -> Extension {
|
||||||
servers: HashMap::default(),
|
servers: HashMap::default(),
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm<P: FlashPermissions + 'static>(
|
||||||
|
unstable: bool,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<P>(&mut ext(), unstable)
|
||||||
|
.esm(deno_core::include_js_files!("01_http.js",))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_ops<P: FlashPermissions + 'static>(unstable: bool) -> Extension {
|
||||||
|
ops::<P>(&mut ext(), unstable).build()
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ use deno_core::op;
|
||||||
use deno_core::CancelFuture;
|
use deno_core::CancelFuture;
|
||||||
use deno_core::CancelHandle;
|
use deno_core::CancelHandle;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
use deno_core::ZeroCopyBuf;
|
use deno_core::ZeroCopyBuf;
|
||||||
|
@ -117,9 +118,15 @@ use deno_core::error::generic_error;
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
use deno_core::error::not_supported;
|
use deno_core::error::not_supported;
|
||||||
|
|
||||||
pub fn init<P: FsPermissions + 'static>(unstable: bool) -> Extension {
|
fn ext() -> ExtensionBuilder {
|
||||||
Extension::builder("deno_fs")
|
Extension::builder("deno_fs")
|
||||||
.esm(include_js_files!("30_fs.js",))
|
}
|
||||||
|
|
||||||
|
fn ops<P: FsPermissions + 'static>(
|
||||||
|
ext: &mut ExtensionBuilder,
|
||||||
|
unstable: bool,
|
||||||
|
) -> &mut ExtensionBuilder {
|
||||||
|
ext
|
||||||
.state(move |state| {
|
.state(move |state| {
|
||||||
state.put(UnstableChecker { unstable });
|
state.put(UnstableChecker { unstable });
|
||||||
})
|
})
|
||||||
|
@ -184,6 +191,19 @@ pub fn init<P: FsPermissions + 'static>(unstable: bool) -> Extension {
|
||||||
op_readfile_async::decl::<P>(),
|
op_readfile_async::decl::<P>(),
|
||||||
op_readfile_text_async::decl::<P>(),
|
op_readfile_text_async::decl::<P>(),
|
||||||
])
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm<P: FsPermissions + 'static>(
|
||||||
|
unstable: bool,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<P>(&mut ext(), unstable)
|
||||||
|
.esm(include_js_files!("30_fs.js",))
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops<P: FsPermissions + 'static>(unstable: bool) -> Extension {
|
||||||
|
ops::<P>(&mut ext(), unstable)
|
||||||
|
.esm(include_js_files!("30_fs.js",))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ use deno_core::CancelFuture;
|
||||||
use deno_core::CancelHandle;
|
use deno_core::CancelHandle;
|
||||||
use deno_core::CancelTryFuture;
|
use deno_core::CancelTryFuture;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_core::RcRef;
|
use deno_core::RcRef;
|
||||||
use deno_core::Resource;
|
use deno_core::Resource;
|
||||||
|
@ -77,13 +78,15 @@ use crate::reader_stream::ShutdownHandle;
|
||||||
pub mod compressible;
|
pub mod compressible;
|
||||||
mod reader_stream;
|
mod reader_stream;
|
||||||
|
|
||||||
pub fn init() -> Extension {
|
fn ext() -> ExtensionBuilder {
|
||||||
Extension::builder_with_deps(
|
Extension::builder_with_deps(
|
||||||
env!("CARGO_PKG_NAME"),
|
env!("CARGO_PKG_NAME"),
|
||||||
&["deno_web", "deno_net", "deno_fetch", "deno_websocket"],
|
&["deno_web", "deno_net", "deno_fetch", "deno_websocket"],
|
||||||
)
|
)
|
||||||
.esm(include_js_files!("01_http.js",))
|
}
|
||||||
.ops(vec![
|
|
||||||
|
fn ops(ext: &mut ExtensionBuilder) -> &mut ExtensionBuilder {
|
||||||
|
ext.ops(vec![
|
||||||
op_http_accept::decl(),
|
op_http_accept::decl(),
|
||||||
op_http_write_headers::decl(),
|
op_http_write_headers::decl(),
|
||||||
op_http_headers::decl(),
|
op_http_headers::decl(),
|
||||||
|
@ -93,9 +96,18 @@ pub fn init() -> Extension {
|
||||||
op_http_websocket_accept_header::decl(),
|
op_http_websocket_accept_header::decl(),
|
||||||
op_http_upgrade_websocket::decl(),
|
op_http_upgrade_websocket::decl(),
|
||||||
])
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm() -> Extension {
|
||||||
|
ops(&mut ext())
|
||||||
|
.esm(include_js_files!("01_http.js",))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_ops() -> Extension {
|
||||||
|
ops(&mut ext()).build()
|
||||||
|
}
|
||||||
|
|
||||||
pub enum HttpSocketAddr {
|
pub enum HttpSocketAddr {
|
||||||
IpSocket(std::net::SocketAddr),
|
IpSocket(std::net::SocketAddr),
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
|
|
@ -13,6 +13,7 @@ use deno_core::BufView;
|
||||||
use deno_core::CancelHandle;
|
use deno_core::CancelHandle;
|
||||||
use deno_core::CancelTryFuture;
|
use deno_core::CancelTryFuture;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_core::RcRef;
|
use deno_core::RcRef;
|
||||||
use deno_core::Resource;
|
use deno_core::Resource;
|
||||||
|
@ -78,13 +79,16 @@ pub static STDERR_HANDLE: Lazy<StdFile> = Lazy::new(|| {
|
||||||
unsafe { StdFile::from_raw_handle(GetStdHandle(winbase::STD_ERROR_HANDLE)) }
|
unsafe { StdFile::from_raw_handle(GetStdHandle(winbase::STD_ERROR_HANDLE)) }
|
||||||
});
|
});
|
||||||
|
|
||||||
pub fn init(stdio: Stdio) -> Extension {
|
fn ext() -> ExtensionBuilder {
|
||||||
// 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_with_deps("deno_io", &["deno_web"])
|
Extension::builder_with_deps("deno_io", &["deno_web"])
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ops(
|
||||||
|
ext: &mut ExtensionBuilder,
|
||||||
|
stdio: Rc<RefCell<Option<Stdio>>>,
|
||||||
|
) -> &mut ExtensionBuilder {
|
||||||
|
ext
|
||||||
.ops(vec![op_read_sync::decl(), op_write_sync::decl()])
|
.ops(vec![op_read_sync::decl(), op_write_sync::decl()])
|
||||||
.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(),
|
||||||
_ => op,
|
_ => op,
|
||||||
|
@ -132,9 +136,24 @@ pub fn init(stdio: Stdio) -> Extension {
|
||||||
));
|
));
|
||||||
assert_eq!(rid, 2, "stderr must have ResourceId 2");
|
assert_eq!(rid, 2, "stderr must have ResourceId 2");
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm(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)));
|
||||||
|
|
||||||
|
ops(&mut ext(), stdio)
|
||||||
|
.esm(include_js_files!("12_io.js",))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_ops(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)));
|
||||||
|
|
||||||
|
ops(&mut ext(), stdio).build()
|
||||||
|
}
|
||||||
|
|
||||||
pub enum StdioPipe {
|
pub enum StdioPipe {
|
||||||
Inherit,
|
Inherit,
|
||||||
File(StdFile),
|
File(StdFile),
|
||||||
|
|
|
@ -10,6 +10,7 @@ pub mod resolve_addr;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::include_js_files;
|
use deno_core::include_js_files;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_tls::rustls::RootCertStore;
|
use deno_tls::rustls::RootCertStore;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
@ -77,17 +78,20 @@ pub struct DefaultTlsOptions {
|
||||||
/// would override previously used alias.
|
/// would override previously used alias.
|
||||||
pub struct UnsafelyIgnoreCertificateErrors(pub Option<Vec<String>>);
|
pub struct UnsafelyIgnoreCertificateErrors(pub Option<Vec<String>>);
|
||||||
|
|
||||||
pub fn init<P: NetPermissions + 'static>(
|
fn ext() -> ExtensionBuilder {
|
||||||
|
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_web"])
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ops<P: NetPermissions + 'static>(
|
||||||
|
ext: &mut ExtensionBuilder,
|
||||||
root_cert_store: Option<RootCertStore>,
|
root_cert_store: Option<RootCertStore>,
|
||||||
unstable: bool,
|
unstable: bool,
|
||||||
unsafely_ignore_certificate_errors: Option<Vec<String>>,
|
unsafely_ignore_certificate_errors: Option<Vec<String>>,
|
||||||
) -> Extension {
|
) -> &mut ExtensionBuilder {
|
||||||
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_with_deps(env!("CARGO_PKG_NAME"), &["deno_web"])
|
|
||||||
.esm(include_js_files!("01_net.js", "02_tls.js",))
|
ext.ops(ops).state(move |state| {
|
||||||
.ops(ops)
|
|
||||||
.state(move |state| {
|
|
||||||
state.put(DefaultTlsOptions {
|
state.put(DefaultTlsOptions {
|
||||||
root_cert_store: root_cert_store.clone(),
|
root_cert_store: root_cert_store.clone(),
|
||||||
});
|
});
|
||||||
|
@ -96,5 +100,33 @@ pub fn init<P: NetPermissions + 'static>(
|
||||||
unsafely_ignore_certificate_errors.clone(),
|
unsafely_ignore_certificate_errors.clone(),
|
||||||
));
|
));
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm<P: NetPermissions + 'static>(
|
||||||
|
root_cert_store: Option<RootCertStore>,
|
||||||
|
unstable: bool,
|
||||||
|
unsafely_ignore_certificate_errors: Option<Vec<String>>,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<P>(
|
||||||
|
&mut ext(),
|
||||||
|
root_cert_store,
|
||||||
|
unstable,
|
||||||
|
unsafely_ignore_certificate_errors,
|
||||||
|
)
|
||||||
|
.esm(include_js_files!("01_net.js", "02_tls.js",))
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops<P: NetPermissions + 'static>(
|
||||||
|
root_cert_store: Option<RootCertStore>,
|
||||||
|
unstable: bool,
|
||||||
|
unsafely_ignore_certificate_errors: Option<Vec<String>>,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<P>(
|
||||||
|
&mut ext(),
|
||||||
|
root_cert_store,
|
||||||
|
unstable,
|
||||||
|
unsafely_ignore_certificate_errors,
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ use deno_core::include_js_files;
|
||||||
use deno_core::located_script_name;
|
use deno_core::located_script_name;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use deno_core::JsRuntime;
|
use deno_core::JsRuntime;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
@ -95,16 +96,34 @@ fn op_node_build_os() -> String {
|
||||||
.to_string()
|
.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_polyfill_ops() -> Extension {
|
fn ext_polyfill() -> ExtensionBuilder {
|
||||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_io", "deno_fs"])
|
||||||
.ops(vec![
|
}
|
||||||
|
|
||||||
|
fn ops_polyfill(ext: &mut ExtensionBuilder) -> &mut ExtensionBuilder {
|
||||||
|
ext.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(),
|
||||||
|
crypto::op_node_hash_update_str::decl(),
|
||||||
crypto::op_node_hash_digest::decl(),
|
crypto::op_node_hash_digest::decl(),
|
||||||
|
crypto::op_node_hash_digest_hex::decl(),
|
||||||
crypto::op_node_hash_clone::decl(),
|
crypto::op_node_hash_clone::decl(),
|
||||||
|
crypto::op_node_private_encrypt::decl(),
|
||||||
|
crypto::op_node_private_decrypt::decl(),
|
||||||
|
crypto::op_node_public_encrypt::decl(),
|
||||||
|
winerror::op_node_sys_to_uv_error::decl(),
|
||||||
|
v8::op_v8_cached_data_version_tag::decl(),
|
||||||
|
v8::op_v8_get_heap_statistics::decl(),
|
||||||
|
idna::op_node_idna_domain_to_ascii::decl(),
|
||||||
|
idna::op_node_idna_domain_to_unicode::decl(),
|
||||||
|
idna::op_node_idna_punycode_decode::decl(),
|
||||||
|
idna::op_node_idna_punycode_encode::decl(),
|
||||||
op_node_build_os::decl(),
|
op_node_build_os::decl(),
|
||||||
])
|
])
|
||||||
.build()
|
}
|
||||||
|
|
||||||
|
pub fn init_polyfill_ops() -> Extension {
|
||||||
|
ops_polyfill(&mut ext_polyfill()).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_polyfill_ops_and_esm() -> Extension {
|
pub fn init_polyfill_ops_and_esm() -> Extension {
|
||||||
|
@ -332,40 +351,21 @@ pub fn init_polyfill_ops_and_esm() -> Extension {
|
||||||
"zlib.ts",
|
"zlib.ts",
|
||||||
);
|
);
|
||||||
|
|
||||||
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_io", "deno_fs"])
|
ops_polyfill(&mut ext_polyfill())
|
||||||
.esm(esm_files)
|
.esm(esm_files)
|
||||||
.esm_entry_point("ext:deno_node/module_all.ts")
|
.esm_entry_point("ext:deno_node/module_all.ts")
|
||||||
.ops(vec![
|
|
||||||
crypto::op_node_create_hash::decl(),
|
|
||||||
crypto::op_node_hash_update::decl(),
|
|
||||||
crypto::op_node_hash_update_str::decl(),
|
|
||||||
crypto::op_node_hash_digest::decl(),
|
|
||||||
crypto::op_node_hash_digest_hex::decl(),
|
|
||||||
crypto::op_node_hash_clone::decl(),
|
|
||||||
crypto::op_node_private_encrypt::decl(),
|
|
||||||
crypto::op_node_private_decrypt::decl(),
|
|
||||||
crypto::op_node_public_encrypt::decl(),
|
|
||||||
winerror::op_node_sys_to_uv_error::decl(),
|
|
||||||
v8::op_v8_cached_data_version_tag::decl(),
|
|
||||||
v8::op_v8_get_heap_statistics::decl(),
|
|
||||||
idna::op_node_idna_domain_to_ascii::decl(),
|
|
||||||
idna::op_node_idna_domain_to_unicode::decl(),
|
|
||||||
idna::op_node_idna_punycode_decode::decl(),
|
|
||||||
idna::op_node_idna_punycode_encode::decl(),
|
|
||||||
op_node_build_os::decl(),
|
|
||||||
])
|
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init<P: NodePermissions + 'static>(
|
fn ext() -> ExtensionBuilder {
|
||||||
maybe_npm_resolver: Option<Rc<dyn RequireNpmResolver>>,
|
|
||||||
) -> Extension {
|
|
||||||
Extension::builder("deno_node_loading")
|
Extension::builder("deno_node_loading")
|
||||||
.esm(include_js_files!(
|
}
|
||||||
"01_node.js",
|
|
||||||
"02_require.js",
|
fn ops<P: NodePermissions + 'static>(
|
||||||
"module_es_shim.js",
|
ext: &mut ExtensionBuilder,
|
||||||
))
|
maybe_npm_resolver: Option<Rc<dyn RequireNpmResolver>>,
|
||||||
|
) -> &mut ExtensionBuilder {
|
||||||
|
ext
|
||||||
.ops(vec![
|
.ops(vec![
|
||||||
ops::op_require_init_paths::decl(),
|
ops::op_require_init_paths::decl(),
|
||||||
ops::op_require_node_module_paths::decl::<P>(),
|
ops::op_require_node_module_paths::decl::<P>(),
|
||||||
|
@ -395,9 +395,26 @@ pub fn init<P: NodePermissions + 'static>(
|
||||||
state.put(npm_resolver);
|
state.put(npm_resolver);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm<P: NodePermissions + 'static>(
|
||||||
|
maybe_npm_resolver: Option<Rc<dyn RequireNpmResolver>>,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<P>(&mut ext(), maybe_npm_resolver)
|
||||||
|
.esm(include_js_files!(
|
||||||
|
"01_node.js",
|
||||||
|
"02_require.js",
|
||||||
|
"module_es_shim.js",
|
||||||
|
))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_ops<P: NodePermissions + 'static>(
|
||||||
|
maybe_npm_resolver: Option<Rc<dyn RequireNpmResolver>>,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<P>(&mut ext(), maybe_npm_resolver).build()
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn initialize_runtime(
|
pub async fn initialize_runtime(
|
||||||
js_runtime: &mut JsRuntime,
|
js_runtime: &mut JsRuntime,
|
||||||
uses_local_node_modules_dir: bool,
|
uses_local_node_modules_dir: bool,
|
||||||
|
|
|
@ -11,8 +11,8 @@ use deno_core::ExtensionFileSourceCode;
|
||||||
|
|
||||||
fn setup() -> Vec<Extension> {
|
fn setup() -> Vec<Extension> {
|
||||||
vec![
|
vec![
|
||||||
deno_webidl::init(),
|
deno_webidl::init_esm(),
|
||||||
deno_url::init(),
|
deno_url::init_ops_and_esm(),
|
||||||
Extension::builder("bench_setup")
|
Extension::builder("bench_setup")
|
||||||
.esm(vec![ExtensionFileSource {
|
.esm(vec![ExtensionFileSource {
|
||||||
specifier: "ext:setup".to_string(),
|
specifier: "ext:setup".to_string(),
|
||||||
|
|
|
@ -10,6 +10,7 @@ use deno_core::url::form_urlencoded;
|
||||||
use deno_core::url::quirks;
|
use deno_core::url::quirks;
|
||||||
use deno_core::url::Url;
|
use deno_core::url::Url;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_core::ZeroCopyBuf;
|
use deno_core::ZeroCopyBuf;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -17,10 +18,12 @@ use std::path::PathBuf;
|
||||||
use crate::urlpattern::op_urlpattern_parse;
|
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 {
|
fn ext() -> ExtensionBuilder {
|
||||||
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_webidl"])
|
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_webidl"])
|
||||||
.esm(include_js_files!("00_url.js", "01_urlpattern.js",))
|
}
|
||||||
.ops(vec![
|
|
||||||
|
fn ops(ext: &mut ExtensionBuilder) -> &mut ExtensionBuilder {
|
||||||
|
ext.ops(vec![
|
||||||
op_url_reparse::decl(),
|
op_url_reparse::decl(),
|
||||||
op_url_parse::decl(),
|
op_url_parse::decl(),
|
||||||
op_url_get_serialization::decl(),
|
op_url_get_serialization::decl(),
|
||||||
|
@ -30,9 +33,18 @@ pub fn init() -> Extension {
|
||||||
op_urlpattern_parse::decl(),
|
op_urlpattern_parse::decl(),
|
||||||
op_urlpattern_process_match_input::decl(),
|
op_urlpattern_process_match_input::decl(),
|
||||||
])
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm() -> Extension {
|
||||||
|
ops(&mut ext())
|
||||||
|
.esm(include_js_files!("00_url.js", "01_urlpattern.js",))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_ops() -> Extension {
|
||||||
|
ops(&mut ext()).build()
|
||||||
|
}
|
||||||
|
|
||||||
/// Parse `href` with a `base_href`. Fills the out `buf` with URL components.
|
/// Parse `href` with a `base_href`. Fills the out `buf` with URL components.
|
||||||
#[op]
|
#[op]
|
||||||
pub fn op_url_parse_with_base(
|
pub fn op_url_parse_with_base(
|
||||||
|
|
|
@ -23,10 +23,10 @@ impl deno_web::TimersPermission for Permissions {
|
||||||
|
|
||||||
fn setup() -> Vec<Extension> {
|
fn setup() -> Vec<Extension> {
|
||||||
vec![
|
vec![
|
||||||
deno_webidl::init(),
|
deno_webidl::init_esm(),
|
||||||
deno_url::init(),
|
deno_url::init_ops_and_esm(),
|
||||||
deno_console::init(),
|
deno_console::init_esm(),
|
||||||
deno_web::init::<Permissions>(BlobStore::default(), None),
|
deno_web::init_ops_and_esm::<Permissions>(BlobStore::default(), None),
|
||||||
Extension::builder("bench_setup")
|
Extension::builder("bench_setup")
|
||||||
.esm(vec![ExtensionFileSource {
|
.esm(vec![ExtensionFileSource {
|
||||||
specifier: "ext:setup".to_string(),
|
specifier: "ext:setup".to_string(),
|
||||||
|
|
|
@ -21,10 +21,10 @@ impl deno_web::TimersPermission for Permissions {
|
||||||
|
|
||||||
fn setup() -> Vec<Extension> {
|
fn setup() -> Vec<Extension> {
|
||||||
vec![
|
vec![
|
||||||
deno_webidl::init(),
|
deno_webidl::init_esm(),
|
||||||
deno_url::init(),
|
deno_url::init_ops_and_esm(),
|
||||||
deno_console::init(),
|
deno_console::init_esm(),
|
||||||
deno_web::init::<Permissions>(BlobStore::default(), None),
|
deno_web::init_ops_and_esm::<Permissions>(BlobStore::default(), None),
|
||||||
Extension::builder("bench_setup")
|
Extension::builder("bench_setup")
|
||||||
.esm(vec![
|
.esm(vec![
|
||||||
ExtensionFileSource {
|
ExtensionFileSource {
|
||||||
|
|
|
@ -16,6 +16,7 @@ use deno_core::v8;
|
||||||
use deno_core::ByteString;
|
use deno_core::ByteString;
|
||||||
use deno_core::CancelHandle;
|
use deno_core::CancelHandle;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_core::Resource;
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
|
@ -57,35 +58,19 @@ use crate::timers::op_timer_handle;
|
||||||
use crate::timers::StartTime;
|
use crate::timers::StartTime;
|
||||||
pub use crate::timers::TimersPermission;
|
pub use crate::timers::TimersPermission;
|
||||||
|
|
||||||
/// Load and execute the javascript code.
|
fn ext() -> ExtensionBuilder {
|
||||||
pub fn init<P: TimersPermission + 'static>(
|
|
||||||
blob_store: BlobStore,
|
|
||||||
maybe_location: Option<Url>,
|
|
||||||
) -> Extension {
|
|
||||||
Extension::builder_with_deps(
|
Extension::builder_with_deps(
|
||||||
env!("CARGO_PKG_NAME"),
|
env!("CARGO_PKG_NAME"),
|
||||||
&["deno_webidl", "deno_console", "deno_url"],
|
&["deno_webidl", "deno_console", "deno_url"],
|
||||||
)
|
)
|
||||||
.esm(include_js_files!(
|
}
|
||||||
"00_infra.js",
|
|
||||||
"01_dom_exception.js",
|
fn ops<P: TimersPermission + 'static>(
|
||||||
"01_mimesniff.js",
|
ext: &mut ExtensionBuilder,
|
||||||
"02_event.js",
|
blob_store: BlobStore,
|
||||||
"02_structured_clone.js",
|
maybe_location: Option<Url>,
|
||||||
"02_timers.js",
|
) -> &mut ExtensionBuilder {
|
||||||
"03_abort_signal.js",
|
ext
|
||||||
"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![
|
.ops(vec![
|
||||||
op_base64_decode::decl(),
|
op_base64_decode::decl(),
|
||||||
op_base64_encode::decl(),
|
op_base64_encode::decl(),
|
||||||
|
@ -124,9 +109,43 @@ pub fn init<P: TimersPermission + 'static>(
|
||||||
}
|
}
|
||||||
state.put(StartTime::now());
|
state.put(StartTime::now());
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm<P: TimersPermission + 'static>(
|
||||||
|
blob_store: BlobStore,
|
||||||
|
maybe_location: Option<Url>,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<P>(&mut ext(), blob_store, maybe_location)
|
||||||
|
.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",
|
||||||
|
))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_ops<P: TimersPermission + 'static>(
|
||||||
|
blob_store: BlobStore,
|
||||||
|
maybe_location: Option<Url>,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<P>(&mut ext(), blob_store, maybe_location).build()
|
||||||
|
}
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_base64_decode(input: String) -> Result<ZeroCopyBuf, AnyError> {
|
fn op_base64_decode(input: String) -> Result<ZeroCopyBuf, AnyError> {
|
||||||
let mut s = input.into_bytes();
|
let mut s = input.into_bytes();
|
||||||
|
|
|
@ -6,6 +6,7 @@ use deno_core::error::AnyError;
|
||||||
use deno_core::include_js_files;
|
use deno_core::include_js_files;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_core::Resource;
|
use deno_core::Resource;
|
||||||
use deno_core::ResourceId;
|
use deno_core::ResourceId;
|
||||||
|
@ -116,23 +117,33 @@ impl Resource for WebGpuQuerySet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(unstable: bool) -> Extension {
|
fn ext() -> ExtensionBuilder {
|
||||||
Extension::builder_with_deps(
|
Extension::builder_with_deps(
|
||||||
env!("CARGO_PKG_NAME"),
|
env!("CARGO_PKG_NAME"),
|
||||||
&["deno_webidl", "deno_web"],
|
&["deno_webidl", "deno_web"],
|
||||||
)
|
)
|
||||||
.esm(include_js_files!("01_webgpu.js", "02_idl_types.js",))
|
}
|
||||||
.ops(declare_webgpu_ops())
|
|
||||||
.state(move |state| {
|
fn ops(ext: &mut ExtensionBuilder, unstable: bool) -> &mut ExtensionBuilder {
|
||||||
|
ext.ops(declare_webgpu_ops()).state(move |state| {
|
||||||
// TODO: check & possibly streamline this
|
// TODO: check & possibly streamline this
|
||||||
// Unstable might be able to be OpMiddleware
|
// Unstable might be able to be OpMiddleware
|
||||||
// let unstable_checker = state.borrow::<super::UnstableChecker>();
|
// let unstable_checker = state.borrow::<super::UnstableChecker>();
|
||||||
// let unstable = unstable_checker.unstable;
|
// let unstable = unstable_checker.unstable;
|
||||||
state.put(Unstable(unstable));
|
state.put(Unstable(unstable));
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm(unstable: bool) -> Extension {
|
||||||
|
ops(&mut ext(), unstable)
|
||||||
|
.esm(include_js_files!("01_webgpu.js", "02_idl_types.js",))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_ops(unstable: bool) -> Extension {
|
||||||
|
ops(&mut ext(), unstable).build()
|
||||||
|
}
|
||||||
|
|
||||||
fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> {
|
fn deserialize_features(features: &wgpu_types::Features) -> Vec<&'static str> {
|
||||||
let mut return_features: Vec<&'static str> = vec![];
|
let mut return_features: Vec<&'static str> = vec![];
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ use deno_core::ExtensionFileSourceCode;
|
||||||
|
|
||||||
fn setup() -> Vec<Extension> {
|
fn setup() -> Vec<Extension> {
|
||||||
vec![
|
vec![
|
||||||
deno_webidl::init(),
|
deno_webidl::init_esm(),
|
||||||
Extension::builder("deno_webidl_bench")
|
Extension::builder("deno_webidl_bench")
|
||||||
.esm(vec![ExtensionFileSource {
|
.esm(vec![ExtensionFileSource {
|
||||||
specifier: "ext:setup".to_string(),
|
specifier: "ext:setup".to_string(),
|
||||||
|
|
|
@ -3,8 +3,11 @@
|
||||||
use deno_core::include_js_files;
|
use deno_core::include_js_files;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
|
||||||
/// Load and execute the javascript code.
|
|
||||||
pub fn init() -> Extension {
|
pub fn init() -> Extension {
|
||||||
|
Extension::builder(env!("CARGO_PKG_NAME")).build()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_esm() -> Extension {
|
||||||
Extension::builder(env!("CARGO_PKG_NAME"))
|
Extension::builder(env!("CARGO_PKG_NAME"))
|
||||||
.esm(include_js_files!("00_webidl.js",))
|
.esm(include_js_files!("00_webidl.js",))
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -9,6 +9,7 @@ use deno_core::futures::SinkExt;
|
||||||
use deno_core::futures::StreamExt;
|
use deno_core::futures::StreamExt;
|
||||||
use deno_core::include_js_files;
|
use deno_core::include_js_files;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
|
|
||||||
use deno_core::url;
|
use deno_core::url;
|
||||||
use deno_core::AsyncRefCell;
|
use deno_core::AsyncRefCell;
|
||||||
|
@ -497,19 +498,20 @@ pub async fn op_ws_next_event(
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init<P: WebSocketPermissions + 'static>(
|
fn ext() -> ExtensionBuilder {
|
||||||
user_agent: String,
|
|
||||||
root_cert_store: Option<RootCertStore>,
|
|
||||||
unsafely_ignore_certificate_errors: Option<Vec<String>>,
|
|
||||||
) -> Extension {
|
|
||||||
Extension::builder_with_deps(
|
Extension::builder_with_deps(
|
||||||
env!("CARGO_PKG_NAME"),
|
env!("CARGO_PKG_NAME"),
|
||||||
&["deno_url", "deno_webidl"],
|
&["deno_url", "deno_webidl"],
|
||||||
)
|
)
|
||||||
.esm(include_js_files!(
|
}
|
||||||
"01_websocket.js",
|
|
||||||
"02_websocketstream.js",
|
fn ops<P: WebSocketPermissions + 'static>(
|
||||||
))
|
ext: &mut ExtensionBuilder,
|
||||||
|
user_agent: String,
|
||||||
|
root_cert_store: Option<RootCertStore>,
|
||||||
|
unsafely_ignore_certificate_errors: Option<Vec<String>>,
|
||||||
|
) -> &mut ExtensionBuilder {
|
||||||
|
ext
|
||||||
.ops(vec![
|
.ops(vec![
|
||||||
op_ws_check_permission_and_cancel_handle::decl::<P>(),
|
op_ws_check_permission_and_cancel_handle::decl::<P>(),
|
||||||
op_ws_create::decl::<P>(),
|
op_ws_create::decl::<P>(),
|
||||||
|
@ -524,6 +526,37 @@ pub fn init<P: WebSocketPermissions + 'static>(
|
||||||
));
|
));
|
||||||
state.put::<WsRootStore>(WsRootStore(root_cert_store.clone()));
|
state.put::<WsRootStore>(WsRootStore(root_cert_store.clone()));
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm<P: WebSocketPermissions + 'static>(
|
||||||
|
user_agent: String,
|
||||||
|
root_cert_store: Option<RootCertStore>,
|
||||||
|
unsafely_ignore_certificate_errors: Option<Vec<String>>,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<P>(
|
||||||
|
&mut ext(),
|
||||||
|
user_agent,
|
||||||
|
root_cert_store,
|
||||||
|
unsafely_ignore_certificate_errors,
|
||||||
|
)
|
||||||
|
.esm(include_js_files!(
|
||||||
|
"01_websocket.js",
|
||||||
|
"02_websocketstream.js",
|
||||||
|
))
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops<P: WebSocketPermissions + 'static>(
|
||||||
|
user_agent: String,
|
||||||
|
root_cert_store: Option<RootCertStore>,
|
||||||
|
unsafely_ignore_certificate_errors: Option<Vec<String>>,
|
||||||
|
) -> Extension {
|
||||||
|
ops::<P>(
|
||||||
|
&mut ext(),
|
||||||
|
user_agent,
|
||||||
|
root_cert_store,
|
||||||
|
unsafely_ignore_certificate_errors,
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ use deno_core::error::AnyError;
|
||||||
use deno_core::include_js_files;
|
use deno_core::include_js_files;
|
||||||
use deno_core::op;
|
use deno_core::op;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
use deno_core::ExtensionBuilder;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use rusqlite::params;
|
use rusqlite::params;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
|
@ -21,9 +22,15 @@ struct OriginStorageDir(PathBuf);
|
||||||
|
|
||||||
const MAX_STORAGE_BYTES: usize = 10 * 1024 * 1024;
|
const MAX_STORAGE_BYTES: usize = 10 * 1024 * 1024;
|
||||||
|
|
||||||
pub fn init(origin_storage_dir: Option<PathBuf>) -> Extension {
|
fn ext() -> ExtensionBuilder {
|
||||||
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_webidl"])
|
Extension::builder_with_deps(env!("CARGO_PKG_NAME"), &["deno_webidl"])
|
||||||
.esm(include_js_files!("01_webstorage.js",))
|
}
|
||||||
|
|
||||||
|
fn ops(
|
||||||
|
ext: &mut ExtensionBuilder,
|
||||||
|
origin_storage_dir: Option<PathBuf>,
|
||||||
|
) -> &mut ExtensionBuilder {
|
||||||
|
ext
|
||||||
.ops(vec![
|
.ops(vec![
|
||||||
op_webstorage_length::decl(),
|
op_webstorage_length::decl(),
|
||||||
op_webstorage_key::decl(),
|
op_webstorage_key::decl(),
|
||||||
|
@ -38,9 +45,18 @@ pub fn init(origin_storage_dir: Option<PathBuf>) -> Extension {
|
||||||
state.put(OriginStorageDir(origin_storage_dir.clone()));
|
state.put(OriginStorageDir(origin_storage_dir.clone()));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_ops_and_esm(origin_storage_dir: Option<PathBuf>) -> Extension {
|
||||||
|
ops(&mut ext(), origin_storage_dir)
|
||||||
|
.esm(include_js_files!("01_webstorage.js",))
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn init_ops(origin_storage_dir: Option<PathBuf>) -> Extension {
|
||||||
|
ops(&mut ext(), origin_storage_dir).build()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_declaration() -> PathBuf {
|
pub fn get_declaration() -> PathBuf {
|
||||||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_webstorage.d.ts")
|
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("lib.deno_webstorage.d.ts")
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,38 +251,42 @@ mod startup_snapshot {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let mut extensions_with_js: Vec<Extension> = vec![
|
let mut extensions_with_js: Vec<Extension> = vec![
|
||||||
deno_webidl::init(),
|
deno_webidl::init_esm(),
|
||||||
deno_console::init(),
|
deno_console::init_esm(),
|
||||||
deno_url::init(),
|
deno_url::init_ops_and_esm(),
|
||||||
deno_tls::init(),
|
deno_tls::init(),
|
||||||
deno_web::init::<Permissions>(
|
deno_web::init_ops_and_esm::<Permissions>(
|
||||||
deno_web::BlobStore::default(),
|
deno_web::BlobStore::default(),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
),
|
),
|
||||||
deno_fetch::init::<Permissions>(Default::default()),
|
deno_fetch::init_ops_and_esm::<Permissions>(Default::default()),
|
||||||
deno_cache::init::<SqliteBackedCache>(None),
|
deno_cache::init_ops_and_esm::<SqliteBackedCache>(None),
|
||||||
deno_websocket::init::<Permissions>("".to_owned(), None, None),
|
deno_websocket::init_ops_and_esm::<Permissions>(
|
||||||
deno_webstorage::init(None),
|
"".to_owned(),
|
||||||
deno_crypto::init(None),
|
None,
|
||||||
deno_webgpu::init(false),
|
None,
|
||||||
deno_broadcast_channel::init(
|
),
|
||||||
|
deno_webstorage::init_ops_and_esm(None),
|
||||||
|
deno_crypto::init_ops_and_esm(None),
|
||||||
|
deno_webgpu::init_ops_and_esm(false),
|
||||||
|
deno_broadcast_channel::init_ops_and_esm(
|
||||||
deno_broadcast_channel::InMemoryBroadcastChannel::default(),
|
deno_broadcast_channel::InMemoryBroadcastChannel::default(),
|
||||||
false, // No --unstable.
|
false, // No --unstable.
|
||||||
),
|
),
|
||||||
deno_ffi::init::<Permissions>(false),
|
deno_ffi::init_ops_and_esm::<Permissions>(false),
|
||||||
deno_net::init::<Permissions>(
|
deno_net::init_ops_and_esm::<Permissions>(
|
||||||
None, false, // No --unstable.
|
None, false, // No --unstable.
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
deno_napi::init::<Permissions>(),
|
deno_napi::init::<Permissions>(),
|
||||||
deno_http::init(),
|
deno_http::init_ops_and_esm(),
|
||||||
deno_io::init(Default::default()),
|
deno_io::init_ops_and_esm(Default::default()),
|
||||||
deno_fs::init::<Permissions>(false),
|
deno_fs::init_ops_and_esm::<Permissions>(false),
|
||||||
deno_flash::init::<Permissions>(false), // No --unstable
|
deno_flash::init_ops_and_esm::<Permissions>(false), // No --unstable
|
||||||
runtime_extension,
|
runtime_extension,
|
||||||
// FIXME(bartlomieju): these extensions are specified last, because they
|
// FIXME(bartlomieju): these extensions are specified last, because they
|
||||||
// depend on `runtime`, even though it should be other way around
|
// depend on `runtime`, even though it should be other way around
|
||||||
deno_node::init::<Permissions>(None),
|
deno_node::init_ops_and_esm::<Permissions>(None),
|
||||||
deno_node::init_polyfill_ops_and_esm(),
|
deno_node::init_polyfill_ops_and_esm(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -346,6 +346,168 @@ pub struct WebWorkerOptions {
|
||||||
pub stdio: Stdio,
|
pub stdio: Stdio,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "dont_create_runtime_snapshot")]
|
||||||
|
fn get_extensions(
|
||||||
|
options: &mut WebWorkerOptions,
|
||||||
|
unstable: bool,
|
||||||
|
main_module: ModuleSpecifier,
|
||||||
|
) -> Vec<Extension> {
|
||||||
|
let create_cache = options.cache_storage_dir.take().map(|storage_dir| {
|
||||||
|
let create_cache_fn = move || SqliteBackedCache::new(storage_dir.clone());
|
||||||
|
CreateCache(Arc::new(create_cache_fn))
|
||||||
|
});
|
||||||
|
|
||||||
|
vec![
|
||||||
|
// Web APIs
|
||||||
|
deno_webidl::init(),
|
||||||
|
deno_console::init(),
|
||||||
|
deno_url::init_ops(),
|
||||||
|
deno_web::init_ops::<PermissionsContainer>(
|
||||||
|
options.blob_store.clone(),
|
||||||
|
Some(main_module.clone()),
|
||||||
|
),
|
||||||
|
deno_fetch::init_ops::<PermissionsContainer>(deno_fetch::Options {
|
||||||
|
user_agent: options.bootstrap.user_agent.clone(),
|
||||||
|
root_cert_store: options.root_cert_store.clone(),
|
||||||
|
unsafely_ignore_certificate_errors: options
|
||||||
|
.unsafely_ignore_certificate_errors
|
||||||
|
.clone(),
|
||||||
|
file_fetch_handler: Rc::new(deno_fetch::FsFetchHandler),
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
deno_cache::init_ops::<SqliteBackedCache>(create_cache),
|
||||||
|
deno_websocket::init_ops::<PermissionsContainer>(
|
||||||
|
options.bootstrap.user_agent.clone(),
|
||||||
|
options.root_cert_store.clone(),
|
||||||
|
options.unsafely_ignore_certificate_errors.clone(),
|
||||||
|
),
|
||||||
|
deno_webstorage::init_ops(None).disable(),
|
||||||
|
deno_broadcast_channel::init_ops(
|
||||||
|
options.broadcast_channel.clone(),
|
||||||
|
unstable,
|
||||||
|
),
|
||||||
|
deno_crypto::init_ops(options.seed),
|
||||||
|
deno_webgpu::init_ops(unstable),
|
||||||
|
// ffi
|
||||||
|
deno_ffi::init_ops::<PermissionsContainer>(unstable),
|
||||||
|
// Runtime ops that are always initialized for WebWorkers
|
||||||
|
ops::web_worker::init(),
|
||||||
|
ops::runtime::init(main_module),
|
||||||
|
ops::worker_host::init(
|
||||||
|
options.create_web_worker_cb.clone(),
|
||||||
|
options.preload_module_cb.clone(),
|
||||||
|
options.pre_execute_module_cb.clone(),
|
||||||
|
options.format_js_error_fn.clone(),
|
||||||
|
),
|
||||||
|
// Extensions providing Deno.* features
|
||||||
|
ops::fs_events::init(),
|
||||||
|
deno_fs::init_ops::<PermissionsContainer>(unstable),
|
||||||
|
deno_io::init_ops(std::mem::take(&mut options.stdio)),
|
||||||
|
deno_tls::init(),
|
||||||
|
deno_net::init_ops::<PermissionsContainer>(
|
||||||
|
options.root_cert_store.clone(),
|
||||||
|
unstable,
|
||||||
|
options.unsafely_ignore_certificate_errors.clone(),
|
||||||
|
),
|
||||||
|
deno_napi::init::<PermissionsContainer>(),
|
||||||
|
// TODO(bartlomieju): thes two should be conditional on `dont_create_runtime_snapshot`
|
||||||
|
// cargo feature and should use `init_polyfill_ops` or `init_polyfill_ops_and_esm`
|
||||||
|
// if the feature is enabled
|
||||||
|
deno_node::init_polyfill_ops(),
|
||||||
|
deno_node::init_ops::<PermissionsContainer>(options.npm_resolver.take()),
|
||||||
|
ops::os::init_for_worker(),
|
||||||
|
ops::permissions::init(),
|
||||||
|
ops::process::init_ops(),
|
||||||
|
ops::signal::init(),
|
||||||
|
ops::tty::init(),
|
||||||
|
deno_http::init_ops(),
|
||||||
|
deno_flash::init_ops::<PermissionsContainer>(unstable),
|
||||||
|
ops::http::init(),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "dont_create_runtime_snapshot"))]
|
||||||
|
fn get_extensions(
|
||||||
|
options: &mut WebWorkerOptions,
|
||||||
|
unstable: bool,
|
||||||
|
main_module: ModuleSpecifier,
|
||||||
|
) -> Vec<Extension> {
|
||||||
|
let create_cache = options.cache_storage_dir.take().map(|storage_dir| {
|
||||||
|
let create_cache_fn = move || SqliteBackedCache::new(storage_dir.clone());
|
||||||
|
CreateCache(Arc::new(create_cache_fn))
|
||||||
|
});
|
||||||
|
|
||||||
|
vec![
|
||||||
|
// Web APIs
|
||||||
|
deno_webidl::init_esm(),
|
||||||
|
deno_console::init_esm(),
|
||||||
|
deno_url::init_ops_and_esm(),
|
||||||
|
deno_web::init_ops_and_esm::<PermissionsContainer>(
|
||||||
|
options.blob_store.clone(),
|
||||||
|
Some(main_module.clone()),
|
||||||
|
),
|
||||||
|
deno_fetch::init_ops_and_esm::<PermissionsContainer>(deno_fetch::Options {
|
||||||
|
user_agent: options.bootstrap.user_agent.clone(),
|
||||||
|
root_cert_store: options.root_cert_store.clone(),
|
||||||
|
unsafely_ignore_certificate_errors: options
|
||||||
|
.unsafely_ignore_certificate_errors
|
||||||
|
.clone(),
|
||||||
|
file_fetch_handler: Rc::new(deno_fetch::FsFetchHandler),
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
deno_cache::init_ops_and_esm::<SqliteBackedCache>(create_cache),
|
||||||
|
deno_websocket::init_ops_and_esm::<PermissionsContainer>(
|
||||||
|
options.bootstrap.user_agent.clone(),
|
||||||
|
options.root_cert_store.clone(),
|
||||||
|
options.unsafely_ignore_certificate_errors.clone(),
|
||||||
|
),
|
||||||
|
deno_webstorage::init_ops_and_esm(None).disable(),
|
||||||
|
deno_broadcast_channel::init_ops_and_esm(
|
||||||
|
options.broadcast_channel.clone(),
|
||||||
|
unstable,
|
||||||
|
),
|
||||||
|
deno_crypto::init_ops_and_esm(options.seed),
|
||||||
|
deno_webgpu::init_ops_and_esm(unstable),
|
||||||
|
// ffi
|
||||||
|
deno_ffi::init_ops_and_esm::<PermissionsContainer>(unstable),
|
||||||
|
// Runtime ops that are always initialized for WebWorkers
|
||||||
|
ops::web_worker::init(),
|
||||||
|
ops::runtime::init(main_module),
|
||||||
|
ops::worker_host::init(
|
||||||
|
options.create_web_worker_cb.clone(),
|
||||||
|
options.preload_module_cb.clone(),
|
||||||
|
options.pre_execute_module_cb.clone(),
|
||||||
|
options.format_js_error_fn.clone(),
|
||||||
|
),
|
||||||
|
// Extensions providing Deno.* features
|
||||||
|
ops::fs_events::init(),
|
||||||
|
deno_fs::init_ops_and_esm::<PermissionsContainer>(unstable),
|
||||||
|
deno_io::init_ops_and_esm(std::mem::take(&mut options.stdio)),
|
||||||
|
deno_tls::init(),
|
||||||
|
deno_net::init_ops_and_esm::<PermissionsContainer>(
|
||||||
|
options.root_cert_store.clone(),
|
||||||
|
unstable,
|
||||||
|
options.unsafely_ignore_certificate_errors.clone(),
|
||||||
|
),
|
||||||
|
deno_napi::init::<PermissionsContainer>(),
|
||||||
|
// TODO(bartlomieju): thes two should be conditional on `dont_create_runtime_snapshot`
|
||||||
|
// cargo feature and should use `init_polyfill_ops` or `init_polyfill_ops_and_esm`
|
||||||
|
// if the feature is enabled
|
||||||
|
deno_node::init_polyfill_ops_and_esm(),
|
||||||
|
deno_node::init_ops_and_esm::<PermissionsContainer>(
|
||||||
|
options.npm_resolver.take(),
|
||||||
|
),
|
||||||
|
ops::os::init_for_worker(),
|
||||||
|
ops::permissions::init(),
|
||||||
|
ops::process::init_ops(),
|
||||||
|
ops::signal::init(),
|
||||||
|
ops::tty::init(),
|
||||||
|
deno_http::init_ops_and_esm(),
|
||||||
|
deno_flash::init_ops_and_esm::<PermissionsContainer>(unstable),
|
||||||
|
ops::http::init(),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
impl WebWorker {
|
impl WebWorker {
|
||||||
pub fn bootstrap_from_options(
|
pub fn bootstrap_from_options(
|
||||||
name: String,
|
name: String,
|
||||||
|
@ -378,77 +540,10 @@ impl WebWorker {
|
||||||
state.put(ops::TestingFeaturesEnabled(enable_testing_features));
|
state.put(ops::TestingFeaturesEnabled(enable_testing_features));
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
let create_cache = options.cache_storage_dir.map(|storage_dir| {
|
|
||||||
let create_cache_fn = move || SqliteBackedCache::new(storage_dir.clone());
|
|
||||||
CreateCache(Arc::new(create_cache_fn))
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut extensions: Vec<Extension> = vec![
|
let mut extensions =
|
||||||
// Web APIs
|
get_extensions(&mut options, unstable, main_module.clone());
|
||||||
deno_webidl::init(),
|
extensions.push(perm_ext);
|
||||||
deno_console::init(),
|
|
||||||
deno_url::init(),
|
|
||||||
deno_web::init::<PermissionsContainer>(
|
|
||||||
options.blob_store.clone(),
|
|
||||||
Some(main_module.clone()),
|
|
||||||
),
|
|
||||||
deno_fetch::init::<PermissionsContainer>(deno_fetch::Options {
|
|
||||||
user_agent: options.bootstrap.user_agent.clone(),
|
|
||||||
root_cert_store: options.root_cert_store.clone(),
|
|
||||||
unsafely_ignore_certificate_errors: options
|
|
||||||
.unsafely_ignore_certificate_errors
|
|
||||||
.clone(),
|
|
||||||
file_fetch_handler: Rc::new(deno_fetch::FsFetchHandler),
|
|
||||||
..Default::default()
|
|
||||||
}),
|
|
||||||
deno_cache::init::<SqliteBackedCache>(create_cache),
|
|
||||||
deno_websocket::init::<PermissionsContainer>(
|
|
||||||
options.bootstrap.user_agent.clone(),
|
|
||||||
options.root_cert_store.clone(),
|
|
||||||
options.unsafely_ignore_certificate_errors.clone(),
|
|
||||||
),
|
|
||||||
deno_webstorage::init(None).disable(),
|
|
||||||
deno_broadcast_channel::init(options.broadcast_channel.clone(), unstable),
|
|
||||||
deno_crypto::init(options.seed),
|
|
||||||
deno_webgpu::init(unstable),
|
|
||||||
// ffi
|
|
||||||
deno_ffi::init::<PermissionsContainer>(unstable),
|
|
||||||
// Runtime ops that are always initialized for WebWorkers
|
|
||||||
ops::web_worker::init(),
|
|
||||||
ops::runtime::init(main_module.clone()),
|
|
||||||
ops::worker_host::init(
|
|
||||||
options.create_web_worker_cb.clone(),
|
|
||||||
options.preload_module_cb.clone(),
|
|
||||||
options.pre_execute_module_cb.clone(),
|
|
||||||
options.format_js_error_fn.clone(),
|
|
||||||
),
|
|
||||||
// Extensions providing Deno.* features
|
|
||||||
ops::fs_events::init(),
|
|
||||||
deno_fs::init::<PermissionsContainer>(unstable),
|
|
||||||
deno_io::init(options.stdio),
|
|
||||||
deno_tls::init(),
|
|
||||||
deno_net::init::<PermissionsContainer>(
|
|
||||||
options.root_cert_store.clone(),
|
|
||||||
unstable,
|
|
||||||
options.unsafely_ignore_certificate_errors.clone(),
|
|
||||||
),
|
|
||||||
deno_napi::init::<PermissionsContainer>(),
|
|
||||||
// TODO(bartlomieju): this should be conditional on `dont_create_runtime_snapshot`
|
|
||||||
// cargo feature and should use `init_polyfill_ops` or `init_polyfill_ops_and_esm`
|
|
||||||
// if the feature is enabled
|
|
||||||
deno_node::init_polyfill_ops(),
|
|
||||||
deno_node::init::<PermissionsContainer>(options.npm_resolver),
|
|
||||||
ops::os::init_for_worker(),
|
|
||||||
ops::permissions::init(),
|
|
||||||
ops::process::init_ops(),
|
|
||||||
ops::signal::init(),
|
|
||||||
ops::tty::init(),
|
|
||||||
deno_http::init(),
|
|
||||||
deno_flash::init::<PermissionsContainer>(unstable),
|
|
||||||
ops::http::init(),
|
|
||||||
// Permissions ext (worker specific state)
|
|
||||||
perm_ext,
|
|
||||||
];
|
|
||||||
|
|
||||||
// Append exts
|
// Append exts
|
||||||
extensions.extend(std::mem::take(&mut options.extensions));
|
extensions.extend(std::mem::take(&mut options.extensions));
|
||||||
|
|
|
@ -183,6 +183,160 @@ impl Default for WorkerOptions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "dont_create_runtime_snapshot"))]
|
||||||
|
fn get_extensions(
|
||||||
|
options: &mut WorkerOptions,
|
||||||
|
unstable: bool,
|
||||||
|
exit_code: ExitCode,
|
||||||
|
main_module: ModuleSpecifier,
|
||||||
|
) -> Vec<Extension> {
|
||||||
|
let create_cache = options.cache_storage_dir.take().map(|storage_dir| {
|
||||||
|
let create_cache_fn = move || SqliteBackedCache::new(storage_dir.clone());
|
||||||
|
CreateCache(Arc::new(create_cache_fn))
|
||||||
|
});
|
||||||
|
|
||||||
|
vec![
|
||||||
|
// Web APIs
|
||||||
|
deno_webidl::init(),
|
||||||
|
deno_console::init(),
|
||||||
|
deno_url::init_ops(),
|
||||||
|
deno_web::init_ops::<PermissionsContainer>(
|
||||||
|
options.blob_store.clone(),
|
||||||
|
options.bootstrap.location.clone(),
|
||||||
|
),
|
||||||
|
deno_fetch::init_ops::<PermissionsContainer>(deno_fetch::Options {
|
||||||
|
user_agent: options.bootstrap.user_agent.clone(),
|
||||||
|
root_cert_store: options.root_cert_store.clone(),
|
||||||
|
unsafely_ignore_certificate_errors: options
|
||||||
|
.unsafely_ignore_certificate_errors
|
||||||
|
.clone(),
|
||||||
|
file_fetch_handler: Rc::new(deno_fetch::FsFetchHandler),
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
deno_cache::init_ops::<SqliteBackedCache>(create_cache),
|
||||||
|
deno_websocket::init_ops::<PermissionsContainer>(
|
||||||
|
options.bootstrap.user_agent.clone(),
|
||||||
|
options.root_cert_store.clone(),
|
||||||
|
options.unsafely_ignore_certificate_errors.clone(),
|
||||||
|
),
|
||||||
|
deno_webstorage::init_ops(options.origin_storage_dir.clone()),
|
||||||
|
deno_broadcast_channel::init_ops(
|
||||||
|
options.broadcast_channel.clone(),
|
||||||
|
unstable,
|
||||||
|
),
|
||||||
|
deno_crypto::init_ops(options.seed),
|
||||||
|
deno_webgpu::init_ops(unstable),
|
||||||
|
// ffi
|
||||||
|
deno_ffi::init_ops::<PermissionsContainer>(unstable),
|
||||||
|
// Runtime ops
|
||||||
|
ops::runtime::init(main_module),
|
||||||
|
ops::worker_host::init(
|
||||||
|
options.create_web_worker_cb.clone(),
|
||||||
|
options.web_worker_preload_module_cb.clone(),
|
||||||
|
options.web_worker_pre_execute_module_cb.clone(),
|
||||||
|
options.format_js_error_fn.clone(),
|
||||||
|
),
|
||||||
|
ops::fs_events::init(),
|
||||||
|
deno_fs::init_ops::<PermissionsContainer>(unstable),
|
||||||
|
deno_io::init_ops(std::mem::take(&mut options.stdio)),
|
||||||
|
deno_tls::init(),
|
||||||
|
deno_net::init_ops::<PermissionsContainer>(
|
||||||
|
options.root_cert_store.clone(),
|
||||||
|
unstable,
|
||||||
|
options.unsafely_ignore_certificate_errors.clone(),
|
||||||
|
),
|
||||||
|
deno_napi::init::<PermissionsContainer>(),
|
||||||
|
deno_node::init_ops::<PermissionsContainer>(options.npm_resolver.take()),
|
||||||
|
ops::os::init(exit_code),
|
||||||
|
ops::permissions::init(),
|
||||||
|
ops::process::init_ops(),
|
||||||
|
ops::signal::init(),
|
||||||
|
ops::tty::init(),
|
||||||
|
deno_http::init_ops(),
|
||||||
|
deno_flash::init_ops::<PermissionsContainer>(unstable),
|
||||||
|
ops::http::init(),
|
||||||
|
deno_node::init_polyfill_ops(),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "dont_create_runtime_snapshot")]
|
||||||
|
fn get_extensions(
|
||||||
|
options: &mut WorkerOptions,
|
||||||
|
unstable: bool,
|
||||||
|
exit_code: ExitCode,
|
||||||
|
main_module: ModuleSpecifier,
|
||||||
|
) -> Vec<Extension> {
|
||||||
|
let create_cache = options.cache_storage_dir.take().map(|storage_dir| {
|
||||||
|
let create_cache_fn = move || SqliteBackedCache::new(storage_dir.clone());
|
||||||
|
CreateCache(Arc::new(create_cache_fn))
|
||||||
|
});
|
||||||
|
|
||||||
|
vec![
|
||||||
|
// Web APIs
|
||||||
|
deno_webidl::init_esm(),
|
||||||
|
deno_console::init_esm(),
|
||||||
|
deno_url::init_ops_and_esm(),
|
||||||
|
deno_web::init_ops_and_esm::<PermissionsContainer>(
|
||||||
|
options.blob_store.clone(),
|
||||||
|
options.bootstrap.location.clone(),
|
||||||
|
),
|
||||||
|
deno_fetch::init_ops_and_esm::<PermissionsContainer>(deno_fetch::Options {
|
||||||
|
user_agent: options.bootstrap.user_agent.clone(),
|
||||||
|
root_cert_store: options.root_cert_store.clone(),
|
||||||
|
unsafely_ignore_certificate_errors: options
|
||||||
|
.unsafely_ignore_certificate_errors
|
||||||
|
.clone(),
|
||||||
|
file_fetch_handler: Rc::new(deno_fetch::FsFetchHandler),
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
deno_cache::init_ops_and_esm::<SqliteBackedCache>(create_cache),
|
||||||
|
deno_websocket::init_ops_and_esm::<PermissionsContainer>(
|
||||||
|
options.bootstrap.user_agent.clone(),
|
||||||
|
options.root_cert_store.clone(),
|
||||||
|
options.unsafely_ignore_certificate_errors.clone(),
|
||||||
|
),
|
||||||
|
deno_webstorage::init_ops_and_esm(options.origin_storage_dir.clone()),
|
||||||
|
deno_broadcast_channel::init_ops_and_esm(
|
||||||
|
options.broadcast_channel.clone(),
|
||||||
|
unstable,
|
||||||
|
),
|
||||||
|
deno_crypto::init_ops_and_esm(options.seed),
|
||||||
|
deno_webgpu::init_ops_and_esm(unstable),
|
||||||
|
// ffi
|
||||||
|
deno_ffi::init_ops_and_esm::<PermissionsContainer>(unstable),
|
||||||
|
// Runtime ops
|
||||||
|
ops::runtime::init(main_module),
|
||||||
|
ops::worker_host::init(
|
||||||
|
options.create_web_worker_cb.clone(),
|
||||||
|
options.web_worker_preload_module_cb.clone(),
|
||||||
|
options.web_worker_pre_execute_module_cb.clone(),
|
||||||
|
options.format_js_error_fn.clone(),
|
||||||
|
),
|
||||||
|
ops::fs_events::init(),
|
||||||
|
deno_fs::init_ops_and_esm::<PermissionsContainer>(unstable),
|
||||||
|
deno_io::init_ops_and_esm(std::mem::take(&mut options.stdio)),
|
||||||
|
deno_tls::init(),
|
||||||
|
deno_net::init_ops_and_esm::<PermissionsContainer>(
|
||||||
|
options.root_cert_store.clone(),
|
||||||
|
unstable,
|
||||||
|
options.unsafely_ignore_certificate_errors.clone(),
|
||||||
|
),
|
||||||
|
deno_napi::init::<PermissionsContainer>(),
|
||||||
|
deno_node::init_ops_and_esm::<PermissionsContainer>(
|
||||||
|
options.npm_resolver.take(),
|
||||||
|
),
|
||||||
|
ops::os::init(exit_code),
|
||||||
|
ops::permissions::init(),
|
||||||
|
ops::process::init_ops(),
|
||||||
|
ops::signal::init(),
|
||||||
|
ops::tty::init(),
|
||||||
|
deno_http::init_ops_and_esm(),
|
||||||
|
deno_flash::init_ops_and_esm::<PermissionsContainer>(unstable),
|
||||||
|
ops::http::init(),
|
||||||
|
deno_node::init_polyfill_ops_and_esm(),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
impl MainWorker {
|
impl MainWorker {
|
||||||
pub fn bootstrap_from_options(
|
pub fn bootstrap_from_options(
|
||||||
main_module: ModuleSpecifier,
|
main_module: ModuleSpecifier,
|
||||||
|
@ -211,77 +365,13 @@ impl MainWorker {
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
let exit_code = ExitCode(Arc::new(AtomicI32::new(0)));
|
let exit_code = ExitCode(Arc::new(AtomicI32::new(0)));
|
||||||
let create_cache = options.cache_storage_dir.map(|storage_dir| {
|
|
||||||
let create_cache_fn = move || SqliteBackedCache::new(storage_dir.clone());
|
|
||||||
CreateCache(Arc::new(create_cache_fn))
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut extensions = vec![
|
let mut extensions = get_extensions(
|
||||||
// Web APIs
|
&mut options,
|
||||||
deno_webidl::init(),
|
|
||||||
deno_console::init(),
|
|
||||||
deno_url::init(),
|
|
||||||
deno_web::init::<PermissionsContainer>(
|
|
||||||
options.blob_store.clone(),
|
|
||||||
options.bootstrap.location.clone(),
|
|
||||||
),
|
|
||||||
deno_fetch::init::<PermissionsContainer>(deno_fetch::Options {
|
|
||||||
user_agent: options.bootstrap.user_agent.clone(),
|
|
||||||
root_cert_store: options.root_cert_store.clone(),
|
|
||||||
unsafely_ignore_certificate_errors: options
|
|
||||||
.unsafely_ignore_certificate_errors
|
|
||||||
.clone(),
|
|
||||||
file_fetch_handler: Rc::new(deno_fetch::FsFetchHandler),
|
|
||||||
..Default::default()
|
|
||||||
}),
|
|
||||||
deno_cache::init::<SqliteBackedCache>(create_cache),
|
|
||||||
deno_websocket::init::<PermissionsContainer>(
|
|
||||||
options.bootstrap.user_agent.clone(),
|
|
||||||
options.root_cert_store.clone(),
|
|
||||||
options.unsafely_ignore_certificate_errors.clone(),
|
|
||||||
),
|
|
||||||
deno_webstorage::init(options.origin_storage_dir.clone()),
|
|
||||||
deno_broadcast_channel::init(options.broadcast_channel.clone(), unstable),
|
|
||||||
deno_crypto::init(options.seed),
|
|
||||||
deno_webgpu::init(unstable),
|
|
||||||
// ffi
|
|
||||||
deno_ffi::init::<PermissionsContainer>(unstable),
|
|
||||||
// Runtime ops
|
|
||||||
ops::runtime::init(main_module.clone()),
|
|
||||||
ops::worker_host::init(
|
|
||||||
options.create_web_worker_cb.clone(),
|
|
||||||
options.web_worker_preload_module_cb.clone(),
|
|
||||||
options.web_worker_pre_execute_module_cb.clone(),
|
|
||||||
options.format_js_error_fn.clone(),
|
|
||||||
),
|
|
||||||
ops::fs_events::init(),
|
|
||||||
deno_fs::init::<PermissionsContainer>(unstable),
|
|
||||||
deno_io::init(options.stdio),
|
|
||||||
deno_tls::init(),
|
|
||||||
deno_net::init::<PermissionsContainer>(
|
|
||||||
options.root_cert_store.clone(),
|
|
||||||
unstable,
|
unstable,
|
||||||
options.unsafely_ignore_certificate_errors.clone(),
|
exit_code.clone(),
|
||||||
),
|
main_module.clone(),
|
||||||
deno_napi::init::<PermissionsContainer>(),
|
);
|
||||||
deno_node::init::<PermissionsContainer>(options.npm_resolver),
|
|
||||||
ops::os::init(exit_code.clone()),
|
|
||||||
ops::permissions::init(),
|
|
||||||
ops::process::init_ops(),
|
|
||||||
ops::signal::init(),
|
|
||||||
ops::tty::init(),
|
|
||||||
deno_http::init(),
|
|
||||||
deno_flash::init::<PermissionsContainer>(unstable),
|
|
||||||
ops::http::init(),
|
|
||||||
];
|
|
||||||
|
|
||||||
// TODO(bartlomieju): finish this work, currently only `deno_node` is different
|
|
||||||
// as it has the most files
|
|
||||||
#[cfg(feature = "dont_create_runtime_snapshot")]
|
|
||||||
extensions.push(deno_node::init_polyfill_ops_and_esm());
|
|
||||||
|
|
||||||
#[cfg(not(feature = "dont_create_runtime_snapshot"))]
|
|
||||||
extensions.push(deno_node::init_polyfill_ops());
|
|
||||||
|
|
||||||
extensions.push(perm_ext);
|
extensions.push(perm_ext);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue