mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
perf(core) Reduce copying and cloning in extension initialization (#18252)
Follow-up to #18210: * we are passing the generated `cfg` object into the state function rather than passing individual config fields * reduce cloning dramatically by making the state_fn `FnOnce` * `take` for `ExtensionBuilder` to avoid more unnecessary copies * renamed `config` to `options`
This commit is contained in:
parent
e55b448730
commit
3487fde236
27 changed files with 206 additions and 174 deletions
14
cli/build.rs
14
cli/build.rs
|
@ -1,9 +1,7 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::rc::Rc;
|
|
||||||
|
|
||||||
use deno_core::snapshot_util::*;
|
use deno_core::snapshot_util::*;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
|
@ -122,15 +120,15 @@ mod ts {
|
||||||
"00_typescript.js",
|
"00_typescript.js",
|
||||||
"99_main_compiler.js",
|
"99_main_compiler.js",
|
||||||
],
|
],
|
||||||
config = {
|
options = {
|
||||||
op_crate_libs: HashMap<&'static str, PathBuf>,
|
op_crate_libs: HashMap<&'static str, PathBuf>,
|
||||||
build_libs: Vec<&'static str>,
|
build_libs: Vec<&'static str>,
|
||||||
path_dts: PathBuf,
|
path_dts: PathBuf,
|
||||||
},
|
},
|
||||||
state = |state, op_crate_libs, build_libs, path_dts| {
|
state = |state, options| {
|
||||||
state.put(op_crate_libs);
|
state.put(options.op_crate_libs);
|
||||||
state.put(build_libs);
|
state.put(options.build_libs);
|
||||||
state.put(path_dts);
|
state.put(options.path_dts);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -362,7 +360,7 @@ fn create_cli_snapshot(snapshot_path: PathBuf) {
|
||||||
deno_tls::deno_tls::init_ops(),
|
deno_tls::deno_tls::init_ops(),
|
||||||
deno_napi::deno_napi::init_ops::<PermissionsContainer>(),
|
deno_napi::deno_napi::init_ops::<PermissionsContainer>(),
|
||||||
deno_http::deno_http::init_ops(),
|
deno_http::deno_http::init_ops(),
|
||||||
deno_io::deno_io::init_ops(Rc::new(RefCell::new(Some(Default::default())))),
|
deno_io::deno_io::init_ops(Default::default()),
|
||||||
deno_fs::deno_fs::init_ops::<PermissionsContainer>(false),
|
deno_fs::deno_fs::init_ops::<PermissionsContainer>(false),
|
||||||
deno_flash::deno_flash::init_ops::<PermissionsContainer>(false), // No --unstable
|
deno_flash::deno_flash::init_ops::<PermissionsContainer>(false), // No --unstable
|
||||||
deno_node::deno_node_loading::init_ops::<PermissionsContainer>(None), // No --unstable.
|
deno_node::deno_node_loading::init_ops::<PermissionsContainer>(None), // No --unstable.
|
||||||
|
|
|
@ -2834,13 +2834,13 @@ deno_core::extension!(deno_tsc,
|
||||||
op_script_names,
|
op_script_names,
|
||||||
op_script_version,
|
op_script_version,
|
||||||
],
|
],
|
||||||
config = {
|
options = {
|
||||||
performance: Arc<Performance>
|
performance: Arc<Performance>
|
||||||
},
|
},
|
||||||
state = |state, performance| {
|
state = |state, options| {
|
||||||
state.put(State::new(
|
state.put(State::new(
|
||||||
Arc::new(StateSnapshot::default()),
|
Arc::new(StateSnapshot::default()),
|
||||||
performance,
|
options.performance,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -30,13 +30,13 @@ deno_core::extension!(deno_bench,
|
||||||
op_dispatch_bench_event,
|
op_dispatch_bench_event,
|
||||||
op_bench_now,
|
op_bench_now,
|
||||||
],
|
],
|
||||||
config = {
|
options = {
|
||||||
sender: UnboundedSender<BenchEvent>,
|
sender: UnboundedSender<BenchEvent>,
|
||||||
filter: TestFilter,
|
filter: TestFilter,
|
||||||
},
|
},
|
||||||
state = |state, sender, filter| {
|
state = |state, options| {
|
||||||
state.put(sender);
|
state.put(options.sender);
|
||||||
state.put(filter);
|
state.put(options.filter);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,11 @@ pub fn cli_exts(ps: ProcState) -> Vec<Extension> {
|
||||||
|
|
||||||
deno_core::extension!(deno_cli,
|
deno_core::extension!(deno_cli,
|
||||||
ops = [op_npm_process_state],
|
ops = [op_npm_process_state],
|
||||||
config = {
|
options = {
|
||||||
ps: ProcState,
|
ps: ProcState,
|
||||||
},
|
},
|
||||||
state = |state, ps| {
|
state = |state, options| {
|
||||||
state.put(ps);
|
state.put(options.ps);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -34,15 +34,15 @@ deno_core::extension!(deno_test,
|
||||||
op_dispatch_test_event,
|
op_dispatch_test_event,
|
||||||
op_tests_should_stop,
|
op_tests_should_stop,
|
||||||
],
|
],
|
||||||
config = {
|
options = {
|
||||||
sender: TestEventSender,
|
sender: TestEventSender,
|
||||||
fail_fast_tracker: FailFastTracker,
|
fail_fast_tracker: FailFastTracker,
|
||||||
filter: TestFilter,
|
filter: TestFilter,
|
||||||
},
|
},
|
||||||
state = |state, sender, fail_fast_tracker, filter| {
|
state = |state, options| {
|
||||||
state.put(sender);
|
state.put(options.sender);
|
||||||
state.put(fail_fast_tracker);
|
state.put(options.fail_fast_tracker);
|
||||||
state.put(filter);
|
state.put(options.filter);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ use std::collections::HashMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::rc::Rc;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
mod diagnostics;
|
mod diagnostics;
|
||||||
|
@ -829,19 +828,19 @@ pub fn exec(request: Request) -> Result<Response, AnyError> {
|
||||||
|
|
||||||
deno_core::extension!(deno_cli_tsc,
|
deno_core::extension!(deno_cli_tsc,
|
||||||
ops_fn = deno_ops,
|
ops_fn = deno_ops,
|
||||||
config = {
|
options = {
|
||||||
request: Rc<Request>,
|
request: Request,
|
||||||
root_map: HashMap<String, Url>,
|
root_map: HashMap<String, Url>,
|
||||||
remapped_specifiers: HashMap<String, Url>,
|
remapped_specifiers: HashMap<String, Url>,
|
||||||
},
|
},
|
||||||
state = |state, request, root_map, remapped_specifiers| {
|
state = |state, options| {
|
||||||
state.put(State::new(
|
state.put(State::new(
|
||||||
request.graph.clone(),
|
options.request.graph,
|
||||||
request.hash_data.clone(),
|
options.request.hash_data,
|
||||||
request.maybe_npm_resolver.clone(),
|
options.request.maybe_npm_resolver,
|
||||||
request.maybe_tsbuildinfo.clone(),
|
options.request.maybe_tsbuildinfo,
|
||||||
root_map,
|
options.root_map,
|
||||||
remapped_specifiers,
|
options.remapped_specifiers,
|
||||||
std::env::current_dir()
|
std::env::current_dir()
|
||||||
.context("Unable to get CWD")
|
.context("Unable to get CWD")
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
@ -861,7 +860,7 @@ pub fn exec(request: Request) -> Result<Response, AnyError> {
|
||||||
let mut runtime = JsRuntime::new(RuntimeOptions {
|
let mut runtime = JsRuntime::new(RuntimeOptions {
|
||||||
startup_snapshot: Some(compiler_snapshot()),
|
startup_snapshot: Some(compiler_snapshot()),
|
||||||
extensions: vec![deno_cli_tsc::init_ops(
|
extensions: vec![deno_cli_tsc::init_ops(
|
||||||
Rc::new(request),
|
request,
|
||||||
root_map,
|
root_map,
|
||||||
remapped_specifiers,
|
remapped_specifiers,
|
||||||
)],
|
)],
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub struct ExtensionFileSource {
|
||||||
}
|
}
|
||||||
pub type OpFnRef = v8::FunctionCallback;
|
pub type OpFnRef = v8::FunctionCallback;
|
||||||
pub type OpMiddlewareFn = dyn Fn(OpDecl) -> OpDecl;
|
pub type OpMiddlewareFn = dyn Fn(OpDecl) -> OpDecl;
|
||||||
pub type OpStateFn = dyn Fn(&mut OpState);
|
pub type OpStateFn = dyn FnOnce(&mut OpState);
|
||||||
pub type OpEventLoopFn = dyn Fn(Rc<RefCell<OpState>>, &mut Context) -> bool;
|
pub type OpEventLoopFn = dyn Fn(Rc<RefCell<OpState>>, &mut Context) -> bool;
|
||||||
|
|
||||||
pub struct OpDecl {
|
pub struct OpDecl {
|
||||||
|
@ -164,7 +164,7 @@ macro_rules! extension {
|
||||||
$(, esm = [ $( dir $dir_esm:literal , )? $( $esm:literal ),* $(,)? ] )?
|
$(, esm = [ $( dir $dir_esm:literal , )? $( $esm:literal ),* $(,)? ] )?
|
||||||
$(, esm_setup_script = $esm_setup_script:expr )?
|
$(, esm_setup_script = $esm_setup_script:expr )?
|
||||||
$(, js = [ $( dir $dir_js:literal , )? $( $js:literal ),* $(,)? ] )?
|
$(, js = [ $( dir $dir_js:literal , )? $( $js:literal ),* $(,)? ] )?
|
||||||
$(, config = { $( $config_id:ident : $config_type:ty ),* $(,)? } )?
|
$(, options = { $( $options_id:ident : $options_type:ty ),* $(,)? } )?
|
||||||
$(, middleware = $middleware_fn:expr )?
|
$(, middleware = $middleware_fn:expr )?
|
||||||
$(, state = $state_fn:expr )?
|
$(, state = $state_fn:expr )?
|
||||||
$(, event_loop_middleware = $event_loop_middleware_fn:ident )?
|
$(, event_loop_middleware = $event_loop_middleware_fn:ident )?
|
||||||
|
@ -227,13 +227,13 @@ macro_rules! extension {
|
||||||
// Includes the state and middleware functions, if defined.
|
// Includes the state and middleware functions, if defined.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
fn with_state_and_middleware$( < $( $param : $type + Clone + 'static ),+ > )?(ext: &mut $crate::ExtensionBuilder, $( $( $config_id : $config_type ),* )? ) {
|
fn with_state_and_middleware$( < $( $param : $type + Clone + 'static ),+ > )?(ext: &mut $crate::ExtensionBuilder, $( $( $options_id : $options_type ),* )? ) {
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
let config = $crate::extension!(! __config__ $( parameters = [ $( $param : $type ),* ] )? $( config = { $( $config_id : $config_type ),* } )? );
|
let config = $crate::extension!(! __config__ $( parameters = [ $( $param : $type ),* ] )? $( config = { $( $options_id : $options_type ),* } )? );
|
||||||
|
|
||||||
$(
|
$(
|
||||||
ext.state(move |state: &mut $crate::OpState| {
|
ext.state(move |state: &mut $crate::OpState| {
|
||||||
config.clone().call_callback(state, $state_fn)
|
config.call_callback(state, $state_fn)
|
||||||
});
|
});
|
||||||
)?
|
)?
|
||||||
|
|
||||||
|
@ -259,57 +259,78 @@ macro_rules! extension {
|
||||||
Self::with_js(&mut ext);
|
Self::with_js(&mut ext);
|
||||||
Self::with_ops $( ::<($( $param ),+)> )?(&mut ext);
|
Self::with_ops $( ::<($( $param ),+)> )?(&mut ext);
|
||||||
Self::with_customizer(&mut ext);
|
Self::with_customizer(&mut ext);
|
||||||
ext.build()
|
ext.take()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn init_ops_and_esm $( < $( $param : $type + Clone + 'static ),+ > )? ( $( $( $config_id : $config_type ),* )? ) -> $crate::Extension {
|
pub fn init_ops_and_esm $( < $( $param : $type + Clone + 'static ),+ > )? ( $( $( $options_id : $options_type ),* )? ) -> $crate::Extension {
|
||||||
let mut ext = Self::ext();
|
let mut ext = Self::ext();
|
||||||
// If esm or JS was specified, add JS files
|
// If esm or JS was specified, add JS files
|
||||||
Self::with_js(&mut ext);
|
Self::with_js(&mut ext);
|
||||||
Self::with_ops $( ::<($( $param ),+)> )?(&mut ext);
|
Self::with_ops $( ::<($( $param ),+)> )?(&mut ext);
|
||||||
Self::with_state_and_middleware $( ::<($( $param ),+)> )?(&mut ext, $( $( $config_id , )* )? );
|
Self::with_state_and_middleware $( ::<($( $param ),+)> )?(&mut ext, $( $( $options_id , )* )? );
|
||||||
Self::with_customizer(&mut ext);
|
Self::with_customizer(&mut ext);
|
||||||
ext.build()
|
ext.take()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn init_ops $( < $( $param : $type + Clone + 'static ),+ > )? ( $( $( $config_id : $config_type ),* )? ) -> $crate::Extension {
|
pub fn init_ops $( < $( $param : $type + Clone + 'static ),+ > )? ( $( $( $options_id : $options_type ),* )? ) -> $crate::Extension {
|
||||||
let mut ext = Self::ext();
|
let mut ext = Self::ext();
|
||||||
Self::with_ops $( ::<($( $param ),+)> )?(&mut ext);
|
Self::with_ops $( ::<($( $param ),+)> )?(&mut ext);
|
||||||
Self::with_state_and_middleware $( ::<($( $param ),+)> )?(&mut ext, $( $( $config_id , )* )? );
|
Self::with_state_and_middleware $( ::<($( $param ),+)> )?(&mut ext, $( $( $options_id , )* )? );
|
||||||
Self::with_customizer(&mut ext);
|
Self::with_customizer(&mut ext);
|
||||||
ext.build()
|
ext.take()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
(! __config__ $( parameters = [ $( $param:ident : $type:ident ),+ ] )? $( config = { $( $config_id:ident : $config_type:ty ),* } )? ) => {
|
// This branch of the macro generates a config object that calls the state function with itself.
|
||||||
|
(! __config__ $( parameters = [ $( $param:ident : $type:ident ),+ ] )? config = { $( $options_id:ident : $options_type:ty ),* } ) => {
|
||||||
{
|
{
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[derive(Clone)]
|
|
||||||
struct Config $( < $( $param : $type + Clone + 'static ),+ > )? {
|
struct Config $( < $( $param : $type + Clone + 'static ),+ > )? {
|
||||||
$( $( pub $config_id : $config_type , )* )?
|
$( pub $options_id : $options_type , )*
|
||||||
$( __phantom_data: ::std::marker::PhantomData<($( $param ),+)>, )?
|
$( __phantom_data: ::std::marker::PhantomData<($( $param ),+)>, )?
|
||||||
}
|
}
|
||||||
|
|
||||||
impl $( < $( $param : $type + Clone + 'static ),+ > )? Config $( < $( $param ),+ > )? {
|
impl $( < $( $param : $type + Clone + 'static ),+ > )? Config $( < $( $param ),+ > )? {
|
||||||
/// Call a function of |state, ...| using the fields of this configuration structure.
|
/// Call a function of |state, cfg| using this configuration structure.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn call_callback<F: Fn(&mut $crate::OpState, $( $( $config_type ),* )?)>(self, state: &mut $crate::OpState, f: F) {
|
fn call_callback<F: Fn(&mut $crate::OpState, Self)>(self, state: &mut $crate::OpState, f: F) {
|
||||||
f(state, $( $( self. $config_id ),* )? )
|
f(state, self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Config {
|
Config {
|
||||||
$( $( $config_id , )* )?
|
$( $options_id , )*
|
||||||
$( __phantom_data: ::std::marker::PhantomData::<($( $param ),+)>::default() )?
|
$( __phantom_data: ::std::marker::PhantomData::<($( $param ),+)>::default() )?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This branch of the macro generates an empty config object that doesn't actually make any callbacks on the state function.
|
||||||
|
(! __config__ $( parameters = [ $( $param:ident : $type:ident ),+ ] )? ) => {
|
||||||
|
{
|
||||||
|
#[doc(hidden)]
|
||||||
|
struct Config {
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Config {
|
||||||
|
/// Call a function of |state| using the fields of this configuration structure.
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[inline(always)]
|
||||||
|
fn call_callback<F: Fn(&mut $crate::OpState)>(self, state: &mut $crate::OpState, f: F) {
|
||||||
|
f(state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Config {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
(! __ops__ $ext:ident __eot__) => {
|
(! __ops__ $ext:ident __eot__) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -409,8 +430,8 @@ impl Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Allows setting up the initial op-state of an isolate at startup.
|
/// Allows setting up the initial op-state of an isolate at startup.
|
||||||
pub fn init_state(&self, state: &mut OpState) {
|
pub fn init_state(&mut self, state: &mut OpState) {
|
||||||
if let Some(op_fn) = &self.opstate_fn {
|
if let Some(op_fn) = self.opstate_fn.take() {
|
||||||
op_fn(state);
|
op_fn(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -499,7 +520,7 @@ impl ExtensionBuilder {
|
||||||
|
|
||||||
pub fn state<F>(&mut self, opstate_fn: F) -> &mut Self
|
pub fn state<F>(&mut self, opstate_fn: F) -> &mut Self
|
||||||
where
|
where
|
||||||
F: Fn(&mut OpState) + 'static,
|
F: FnOnce(&mut OpState) + 'static,
|
||||||
{
|
{
|
||||||
self.state = Some(Box::new(opstate_fn));
|
self.state = Some(Box::new(opstate_fn));
|
||||||
self
|
self
|
||||||
|
@ -521,6 +542,27 @@ impl ExtensionBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Consume the [`ExtensionBuilder`] and return an [`Extension`].
|
||||||
|
pub fn take(self) -> Extension {
|
||||||
|
let js_files = Some(self.js);
|
||||||
|
let esm_files = Some(self.esm);
|
||||||
|
let ops = Some(self.ops);
|
||||||
|
let deps = Some(self.deps);
|
||||||
|
Extension {
|
||||||
|
js_files,
|
||||||
|
esm_files,
|
||||||
|
esm_entry_point: self.esm_entry_point,
|
||||||
|
ops,
|
||||||
|
opstate_fn: self.state,
|
||||||
|
middleware_fn: self.middleware,
|
||||||
|
event_loop_middleware: self.event_loop_middleware,
|
||||||
|
initialized: false,
|
||||||
|
enabled: true,
|
||||||
|
name: self.name,
|
||||||
|
deps,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn build(&mut self) -> Extension {
|
pub fn build(&mut self) -> Extension {
|
||||||
let js_files = Some(std::mem::take(&mut self.js));
|
let js_files = Some(std::mem::take(&mut self.js));
|
||||||
let esm_files = Some(std::mem::take(&mut self.esm));
|
let esm_files = Some(std::mem::take(&mut self.esm));
|
||||||
|
|
|
@ -2731,14 +2731,14 @@ pub mod tests {
|
||||||
deno_core::extension!(
|
deno_core::extension!(
|
||||||
test_ext,
|
test_ext,
|
||||||
ops = [op_test],
|
ops = [op_test],
|
||||||
config = {
|
options = {
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
dispatch_count: Arc<AtomicUsize>,
|
dispatch_count: Arc<AtomicUsize>,
|
||||||
},
|
},
|
||||||
state = |state, mode, dispatch_count| {
|
state = |state, options| {
|
||||||
state.put(TestState {
|
state.put(TestState {
|
||||||
mode,
|
mode: options.mode,
|
||||||
dispatch_count
|
dispatch_count: options.dispatch_count
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -114,13 +114,13 @@ deno_core::extension!(deno_broadcast_channel,
|
||||||
op_broadcast_recv<BC>,
|
op_broadcast_recv<BC>,
|
||||||
],
|
],
|
||||||
esm = [ "01_broadcast_channel.js" ],
|
esm = [ "01_broadcast_channel.js" ],
|
||||||
config = {
|
options = {
|
||||||
bc: BC,
|
bc: BC,
|
||||||
unstable: bool,
|
unstable: bool,
|
||||||
},
|
},
|
||||||
state = |state, bc, unstable| {
|
state = |state, options| {
|
||||||
state.put(bc);
|
state.put(options.bc);
|
||||||
state.put(Unstable(unstable));
|
state.put(Unstable(options.unstable));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
6
ext/cache/lib.rs
vendored
6
ext/cache/lib.rs
vendored
|
@ -32,11 +32,11 @@ deno_core::extension!(deno_cache,
|
||||||
op_cache_delete<CA>,
|
op_cache_delete<CA>,
|
||||||
],
|
],
|
||||||
esm = [ "01_cache.js" ],
|
esm = [ "01_cache.js" ],
|
||||||
config = {
|
options = {
|
||||||
maybe_create_cache: Option<CreateCache<CA>>,
|
maybe_create_cache: Option<CreateCache<CA>>,
|
||||||
},
|
},
|
||||||
state = |state, maybe_create_cache| {
|
state = |state, options| {
|
||||||
if let Some(create_cache) = maybe_create_cache {
|
if let Some(create_cache) = options.maybe_create_cache {
|
||||||
state.put(create_cache);
|
state.put(create_cache);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -104,11 +104,11 @@ deno_core::extension!(deno_crypto,
|
||||||
x25519::op_export_pkcs8_x25519,
|
x25519::op_export_pkcs8_x25519,
|
||||||
],
|
],
|
||||||
esm = [ "00_crypto.js", "01_webidl.js" ],
|
esm = [ "00_crypto.js", "01_webidl.js" ],
|
||||||
config = {
|
options = {
|
||||||
maybe_seed: Option<u64>,
|
maybe_seed: Option<u64>,
|
||||||
},
|
},
|
||||||
state = |state, maybe_seed| {
|
state = |state, options| {
|
||||||
if let Some(seed) = maybe_seed {
|
if let Some(seed) = options.maybe_seed {
|
||||||
state.put(StdRng::seed_from_u64(seed));
|
state.put(StdRng::seed_from_u64(seed));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -107,19 +107,19 @@ deno_core::extension!(deno_fetch,
|
||||||
"23_response.js",
|
"23_response.js",
|
||||||
"26_fetch.js"
|
"26_fetch.js"
|
||||||
],
|
],
|
||||||
config = {
|
options = {
|
||||||
options: Options,
|
options: Options,
|
||||||
},
|
},
|
||||||
state = |state, options| {
|
state = |state, options| {
|
||||||
state.put::<Options>(options.clone());
|
state.put::<Options>(options.options.clone());
|
||||||
state.put::<reqwest::Client>({
|
state.put::<reqwest::Client>({
|
||||||
create_http_client(
|
create_http_client(
|
||||||
options.user_agent,
|
options.options.user_agent,
|
||||||
options.root_cert_store,
|
options.options.root_cert_store,
|
||||||
vec![],
|
vec![],
|
||||||
options.proxy,
|
options.options.proxy,
|
||||||
options.unsafely_ignore_certificate_errors,
|
options.options.unsafely_ignore_certificate_errors,
|
||||||
options.client_cert_chain_and_key
|
options.options.client_cert_chain_and_key
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
});
|
});
|
||||||
|
|
|
@ -112,12 +112,12 @@ deno_core::extension!(deno_ffi,
|
||||||
op_ffi_unsafe_callback_ref,
|
op_ffi_unsafe_callback_ref,
|
||||||
],
|
],
|
||||||
esm = [ "00_ffi.js" ],
|
esm = [ "00_ffi.js" ],
|
||||||
config = {
|
options = {
|
||||||
unstable: bool,
|
unstable: bool,
|
||||||
},
|
},
|
||||||
state = |state, unstable| {
|
state = |state, options| {
|
||||||
// Stolen from deno_webgpu, is there a better option?
|
// Stolen from deno_webgpu, is there a better option?
|
||||||
state.put(Unstable(unstable));
|
state.put(Unstable(options.unstable));
|
||||||
|
|
||||||
let (async_work_sender, async_work_receiver) =
|
let (async_work_sender, async_work_receiver) =
|
||||||
mpsc::unbounded::<PendingFfiAsyncWork>();
|
mpsc::unbounded::<PendingFfiAsyncWork>();
|
||||||
|
|
|
@ -1559,11 +1559,11 @@ deno_core::extension!(deno_flash,
|
||||||
op_try_flash_respond_chunked,
|
op_try_flash_respond_chunked,
|
||||||
],
|
],
|
||||||
esm = [ "01_http.js" ],
|
esm = [ "01_http.js" ],
|
||||||
config = {
|
options = {
|
||||||
unstable: bool,
|
unstable: bool,
|
||||||
},
|
},
|
||||||
state = |state, unstable| {
|
state = |state, options| {
|
||||||
state.put(Unstable(unstable));
|
state.put(Unstable(options.unstable));
|
||||||
state.put(FlashContext {
|
state.put(FlashContext {
|
||||||
next_server_id: 0,
|
next_server_id: 0,
|
||||||
join_handles: HashMap::default(),
|
join_handles: HashMap::default(),
|
||||||
|
|
|
@ -180,11 +180,11 @@ deno_core::extension!(deno_fs,
|
||||||
op_readfile_text_async<P>,
|
op_readfile_text_async<P>,
|
||||||
],
|
],
|
||||||
esm = [ "30_fs.js" ],
|
esm = [ "30_fs.js" ],
|
||||||
config = {
|
options = {
|
||||||
unstable: bool
|
unstable: bool
|
||||||
},
|
},
|
||||||
state = |state, unstable| {
|
state = |state, options| {
|
||||||
state.put(UnstableChecker { unstable });
|
state.put(UnstableChecker { unstable: options.unstable });
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -80,55 +80,53 @@ deno_core::extension!(deno_io,
|
||||||
deps = [ deno_web ],
|
deps = [ deno_web ],
|
||||||
ops = [op_read_sync, op_write_sync],
|
ops = [op_read_sync, op_write_sync],
|
||||||
esm = [ "12_io.js" ],
|
esm = [ "12_io.js" ],
|
||||||
config = {
|
options = {
|
||||||
stdio: Rc<RefCell<Option<Stdio>>>,
|
stdio: Option<Stdio>,
|
||||||
},
|
},
|
||||||
middleware = |op| match op.name {
|
middleware = |op| match op.name {
|
||||||
"op_print" => op_print::decl(),
|
"op_print" => op_print::decl(),
|
||||||
_ => op,
|
_ => op,
|
||||||
},
|
},
|
||||||
state = |state, stdio| {
|
state = |state, options| {
|
||||||
let stdio = stdio
|
if let Some(stdio) = options.stdio {
|
||||||
.borrow_mut()
|
let t = &mut state.resource_table;
|
||||||
.take()
|
|
||||||
.expect("Extension only supports being used once.");
|
|
||||||
let t = &mut state.resource_table;
|
|
||||||
|
|
||||||
let rid = t.add(StdFileResource::stdio(
|
let rid = t.add(StdFileResource::stdio(
|
||||||
match stdio.stdin {
|
match stdio.stdin {
|
||||||
StdioPipe::Inherit => StdFileResourceInner {
|
StdioPipe::Inherit => StdFileResourceInner {
|
||||||
kind: StdFileResourceKind::Stdin,
|
kind: StdFileResourceKind::Stdin,
|
||||||
file: STDIN_HANDLE.try_clone().unwrap(),
|
file: STDIN_HANDLE.try_clone().unwrap(),
|
||||||
|
},
|
||||||
|
StdioPipe::File(pipe) => StdFileResourceInner::file(pipe),
|
||||||
},
|
},
|
||||||
StdioPipe::File(pipe) => StdFileResourceInner::file(pipe),
|
"stdin",
|
||||||
},
|
));
|
||||||
"stdin",
|
assert_eq!(rid, 0, "stdin must have ResourceId 0");
|
||||||
));
|
|
||||||
assert_eq!(rid, 0, "stdin must have ResourceId 0");
|
|
||||||
|
|
||||||
let rid = t.add(StdFileResource::stdio(
|
let rid = t.add(StdFileResource::stdio(
|
||||||
match stdio.stdout {
|
match stdio.stdout {
|
||||||
StdioPipe::Inherit => StdFileResourceInner {
|
StdioPipe::Inherit => StdFileResourceInner {
|
||||||
kind: StdFileResourceKind::Stdout,
|
kind: StdFileResourceKind::Stdout,
|
||||||
file: STDOUT_HANDLE.try_clone().unwrap(),
|
file: STDOUT_HANDLE.try_clone().unwrap(),
|
||||||
|
},
|
||||||
|
StdioPipe::File(pipe) => StdFileResourceInner::file(pipe),
|
||||||
},
|
},
|
||||||
StdioPipe::File(pipe) => StdFileResourceInner::file(pipe),
|
"stdout",
|
||||||
},
|
));
|
||||||
"stdout",
|
assert_eq!(rid, 1, "stdout must have ResourceId 1");
|
||||||
));
|
|
||||||
assert_eq!(rid, 1, "stdout must have ResourceId 1");
|
|
||||||
|
|
||||||
let rid = t.add(StdFileResource::stdio(
|
let rid = t.add(StdFileResource::stdio(
|
||||||
match stdio.stderr {
|
match stdio.stderr {
|
||||||
StdioPipe::Inherit => StdFileResourceInner {
|
StdioPipe::Inherit => StdFileResourceInner {
|
||||||
kind: StdFileResourceKind::Stderr,
|
kind: StdFileResourceKind::Stderr,
|
||||||
file: STDERR_HANDLE.try_clone().unwrap(),
|
file: STDERR_HANDLE.try_clone().unwrap(),
|
||||||
|
},
|
||||||
|
StdioPipe::File(pipe) => StdFileResourceInner::file(pipe),
|
||||||
},
|
},
|
||||||
StdioPipe::File(pipe) => StdFileResourceInner::file(pipe),
|
"stderr",
|
||||||
},
|
));
|
||||||
"stderr",
|
assert_eq!(rid, 2, "stderr must have ResourceId 2");
|
||||||
));
|
}
|
||||||
assert_eq!(rid, 2, "stderr must have ResourceId 2");
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -105,18 +105,18 @@ deno_core::extension!(deno_net,
|
||||||
#[cfg(unix)] ops_unix::op_net_send_unixpacket<P>,
|
#[cfg(unix)] ops_unix::op_net_send_unixpacket<P>,
|
||||||
],
|
],
|
||||||
esm = [ "01_net.js", "02_tls.js" ],
|
esm = [ "01_net.js", "02_tls.js" ],
|
||||||
config = {
|
options = {
|
||||||
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>>,
|
||||||
},
|
},
|
||||||
state = |state, root_cert_store, unstable, unsafely_ignore_certificate_errors| {
|
state = |state, options| {
|
||||||
state.put(DefaultTlsOptions {
|
state.put(DefaultTlsOptions {
|
||||||
root_cert_store,
|
root_cert_store: options.root_cert_store,
|
||||||
});
|
});
|
||||||
state.put(UnstableChecker { unstable });
|
state.put(UnstableChecker { unstable: options.unstable });
|
||||||
state.put(UnsafelyIgnoreCertificateErrors(
|
state.put(UnsafelyIgnoreCertificateErrors(
|
||||||
unsafely_ignore_certificate_errors,
|
options.unsafely_ignore_certificate_errors,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -370,11 +370,11 @@ deno_core::extension!(deno_node_loading,
|
||||||
ops::op_require_break_on_next_statement,
|
ops::op_require_break_on_next_statement,
|
||||||
],
|
],
|
||||||
esm = ["01_node.js", "02_require.js", "module_es_shim.js"],
|
esm = ["01_node.js", "02_require.js", "module_es_shim.js"],
|
||||||
config = {
|
options = {
|
||||||
maybe_npm_resolver: Option<Rc<dyn RequireNpmResolver>>,
|
maybe_npm_resolver: Option<Rc<dyn RequireNpmResolver>>,
|
||||||
},
|
},
|
||||||
state = |state, maybe_npm_resolver| {
|
state = |state, options| {
|
||||||
if let Some(npm_resolver) = maybe_npm_resolver.clone() {
|
if let Some(npm_resolver) = options.maybe_npm_resolver {
|
||||||
state.put(npm_resolver);
|
state.put(npm_resolver);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -109,13 +109,13 @@ deno_core::extension!(deno_web,
|
||||||
"14_compression.js",
|
"14_compression.js",
|
||||||
"15_performance.js",
|
"15_performance.js",
|
||||||
],
|
],
|
||||||
config = {
|
options = {
|
||||||
blob_store: BlobStore,
|
blob_store: BlobStore,
|
||||||
maybe_location: Option<Url>,
|
maybe_location: Option<Url>,
|
||||||
},
|
},
|
||||||
state = |state, blob_store, maybe_location| {
|
state = |state, options| {
|
||||||
state.put(blob_store);
|
state.put(options.blob_store);
|
||||||
if let Some(location) = maybe_location {
|
if let Some(location) = options.maybe_location {
|
||||||
state.put(Location(location));
|
state.put(Location(location));
|
||||||
}
|
}
|
||||||
state.put(StartTime::now());
|
state.put(StartTime::now());
|
||||||
|
|
|
@ -506,17 +506,17 @@ deno_core::extension!(deno_websocket,
|
||||||
op_ws_next_event,
|
op_ws_next_event,
|
||||||
],
|
],
|
||||||
esm = [ "01_websocket.js", "02_websocketstream.js" ],
|
esm = [ "01_websocket.js", "02_websocketstream.js" ],
|
||||||
config = {
|
options = {
|
||||||
user_agent: String,
|
user_agent: String,
|
||||||
root_cert_store: Option<RootCertStore>,
|
root_cert_store: Option<RootCertStore>,
|
||||||
unsafely_ignore_certificate_errors: Option<Vec<String>>
|
unsafely_ignore_certificate_errors: Option<Vec<String>>
|
||||||
},
|
},
|
||||||
state = |state, user_agent, root_cert_store, unsafely_ignore_certificate_errors| {
|
state = |state, options| {
|
||||||
state.put::<WsUserAgent>(WsUserAgent(user_agent));
|
state.put::<WsUserAgent>(WsUserAgent(options.user_agent));
|
||||||
state.put(UnsafelyIgnoreCertificateErrors(
|
state.put(UnsafelyIgnoreCertificateErrors(
|
||||||
unsafely_ignore_certificate_errors,
|
options.unsafely_ignore_certificate_errors,
|
||||||
));
|
));
|
||||||
state.put::<WsRootStore>(WsRootStore(root_cert_store));
|
state.put::<WsRootStore>(WsRootStore(options.root_cert_store));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,11 @@ deno_core::extension!(deno_webstorage,
|
||||||
op_webstorage_iterate_keys,
|
op_webstorage_iterate_keys,
|
||||||
],
|
],
|
||||||
esm = [ "01_webstorage.js" ],
|
esm = [ "01_webstorage.js" ],
|
||||||
config = {
|
options = {
|
||||||
origin_storage_dir: Option<PathBuf>
|
origin_storage_dir: Option<PathBuf>
|
||||||
},
|
},
|
||||||
state = |state, origin_storage_dir| {
|
state = |state, options| {
|
||||||
if let Some(origin_storage_dir) = origin_storage_dir {
|
if let Some(origin_storage_dir) = options.origin_storage_dir {
|
||||||
state.put(OriginStorageDir(origin_storage_dir));
|
state.put(OriginStorageDir(origin_storage_dir));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,9 +17,7 @@ mod startup_snapshot {
|
||||||
use deno_core::snapshot_util::*;
|
use deno_core::snapshot_util::*;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
use deno_core::ExtensionFileSource;
|
use deno_core::ExtensionFileSource;
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::rc::Rc;
|
|
||||||
|
|
||||||
fn transpile_ts_for_snapshotting(
|
fn transpile_ts_for_snapshotting(
|
||||||
file_source: &ExtensionFileSource,
|
file_source: &ExtensionFileSource,
|
||||||
|
@ -292,9 +290,7 @@ mod startup_snapshot {
|
||||||
deno_tls::deno_tls::init_ops_and_esm(),
|
deno_tls::deno_tls::init_ops_and_esm(),
|
||||||
deno_napi::deno_napi::init_ops_and_esm::<Permissions>(),
|
deno_napi::deno_napi::init_ops_and_esm::<Permissions>(),
|
||||||
deno_http::deno_http::init_ops_and_esm(),
|
deno_http::deno_http::init_ops_and_esm(),
|
||||||
deno_io::deno_io::init_ops_and_esm(Rc::new(RefCell::new(Some(
|
deno_io::deno_io::init_ops_and_esm(Default::default()),
|
||||||
Default::default(),
|
|
||||||
)))),
|
|
||||||
deno_fs::deno_fs::init_ops_and_esm::<Permissions>(false),
|
deno_fs::deno_fs::init_ops_and_esm::<Permissions>(false),
|
||||||
deno_flash::deno_flash::init_ops_and_esm::<Permissions>(false), // No --unstable
|
deno_flash::deno_flash::init_ops_and_esm::<Permissions>(false), // No --unstable
|
||||||
runtime::init_ops_and_esm(),
|
runtime::init_ops_and_esm(),
|
||||||
|
|
|
@ -42,11 +42,11 @@ deno_core::ops!(
|
||||||
deno_core::extension!(
|
deno_core::extension!(
|
||||||
deno_os,
|
deno_os,
|
||||||
ops_fn = deno_ops,
|
ops_fn = deno_ops,
|
||||||
config = {
|
options = {
|
||||||
exit_code: ExitCode,
|
exit_code: ExitCode,
|
||||||
},
|
},
|
||||||
state = |state, exit_code| {
|
state = |state, options| {
|
||||||
state.put::<ExitCode>(exit_code);
|
state.put::<ExitCode>(options.exit_code);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ use deno_core::OpState;
|
||||||
deno_core::extension!(
|
deno_core::extension!(
|
||||||
deno_runtime,
|
deno_runtime,
|
||||||
ops = [op_main_module],
|
ops = [op_main_module],
|
||||||
config = { main_module: ModuleSpecifier },
|
options = { main_module: ModuleSpecifier },
|
||||||
state = |state, main_module| {
|
state = |state, options| {
|
||||||
state.put::<ModuleSpecifier>(main_module);
|
state.put::<ModuleSpecifier>(options.main_module);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -96,27 +96,27 @@ deno_core::extension!(
|
||||||
op_host_recv_ctrl,
|
op_host_recv_ctrl,
|
||||||
op_host_recv_message,
|
op_host_recv_message,
|
||||||
],
|
],
|
||||||
config = {
|
options = {
|
||||||
create_web_worker_cb: Arc<CreateWebWorkerCb>,
|
create_web_worker_cb: Arc<CreateWebWorkerCb>,
|
||||||
preload_module_cb: Arc<WorkerEventCb>,
|
preload_module_cb: Arc<WorkerEventCb>,
|
||||||
pre_execute_module_cb: Arc<WorkerEventCb>,
|
pre_execute_module_cb: Arc<WorkerEventCb>,
|
||||||
format_js_error_fn: Option<Arc<FormatJsErrorFn>>,
|
format_js_error_fn: Option<Arc<FormatJsErrorFn>>,
|
||||||
},
|
},
|
||||||
state = |state, create_web_worker_cb, preload_module_cb, pre_execute_module_cb, format_js_error_fn| {
|
state = |state, options| {
|
||||||
state.put::<WorkersTable>(WorkersTable::default());
|
state.put::<WorkersTable>(WorkersTable::default());
|
||||||
state.put::<WorkerId>(WorkerId::default());
|
state.put::<WorkerId>(WorkerId::default());
|
||||||
|
|
||||||
let create_web_worker_cb_holder =
|
let create_web_worker_cb_holder =
|
||||||
CreateWebWorkerCbHolder(create_web_worker_cb.clone());
|
CreateWebWorkerCbHolder(options.create_web_worker_cb);
|
||||||
state.put::<CreateWebWorkerCbHolder>(create_web_worker_cb_holder);
|
state.put::<CreateWebWorkerCbHolder>(create_web_worker_cb_holder);
|
||||||
let preload_module_cb_holder =
|
let preload_module_cb_holder =
|
||||||
PreloadModuleCbHolder(preload_module_cb.clone());
|
PreloadModuleCbHolder(options.preload_module_cb);
|
||||||
state.put::<PreloadModuleCbHolder>(preload_module_cb_holder);
|
state.put::<PreloadModuleCbHolder>(preload_module_cb_holder);
|
||||||
let pre_execute_module_cb_holder =
|
let pre_execute_module_cb_holder =
|
||||||
PreExecuteModuleCbHolder(pre_execute_module_cb.clone());
|
PreExecuteModuleCbHolder(options.pre_execute_module_cb);
|
||||||
state.put::<PreExecuteModuleCbHolder>(pre_execute_module_cb_holder);
|
state.put::<PreExecuteModuleCbHolder>(pre_execute_module_cb_holder);
|
||||||
let format_js_error_fn_holder =
|
let format_js_error_fn_holder =
|
||||||
FormatJsErrorFnHolder(format_js_error_fn.clone());
|
FormatJsErrorFnHolder(options.format_js_error_fn);
|
||||||
state.put::<FormatJsErrorFnHolder>(format_js_error_fn_holder);
|
state.put::<FormatJsErrorFnHolder>(format_js_error_fn_holder);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -369,15 +369,15 @@ impl WebWorker {
|
||||||
mut options: WebWorkerOptions,
|
mut options: WebWorkerOptions,
|
||||||
) -> (Self, SendableWebWorkerHandle) {
|
) -> (Self, SendableWebWorkerHandle) {
|
||||||
deno_core::extension!(deno_permissions_web_worker,
|
deno_core::extension!(deno_permissions_web_worker,
|
||||||
config = {
|
options = {
|
||||||
permissions: PermissionsContainer,
|
permissions: PermissionsContainer,
|
||||||
unstable: bool,
|
unstable: bool,
|
||||||
enable_testing_features: bool,
|
enable_testing_features: bool,
|
||||||
},
|
},
|
||||||
state = |state, permissions, unstable, enable_testing_features| {
|
state = |state, options| {
|
||||||
state.put::<PermissionsContainer>(permissions);
|
state.put::<PermissionsContainer>(options.permissions);
|
||||||
state.put(ops::UnstableChecker { unstable });
|
state.put(ops::UnstableChecker { unstable: options.unstable });
|
||||||
state.put(ops::TestingFeaturesEnabled(enable_testing_features));
|
state.put(ops::TestingFeaturesEnabled(options.enable_testing_features));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ impl WebWorker {
|
||||||
deno_tls::deno_tls::init_ops(),
|
deno_tls::deno_tls::init_ops(),
|
||||||
deno_napi::deno_napi::init_ops::<PermissionsContainer>(),
|
deno_napi::deno_napi::init_ops::<PermissionsContainer>(),
|
||||||
deno_http::deno_http::init_ops(),
|
deno_http::deno_http::init_ops(),
|
||||||
deno_io::deno_io::init_ops(Rc::new(RefCell::new(Some(options.stdio)))),
|
deno_io::deno_io::init_ops(Some(options.stdio)),
|
||||||
deno_fs::deno_fs::init_ops::<PermissionsContainer>(unstable),
|
deno_fs::deno_fs::init_ops::<PermissionsContainer>(unstable),
|
||||||
deno_flash::deno_flash::init_ops::<PermissionsContainer>(unstable),
|
deno_flash::deno_flash::init_ops::<PermissionsContainer>(unstable),
|
||||||
deno_node::deno_node_loading::init_ops::<PermissionsContainer>(
|
deno_node::deno_node_loading::init_ops::<PermissionsContainer>(
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::atomic::AtomicI32;
|
use std::sync::atomic::AtomicI32;
|
||||||
|
@ -189,15 +188,15 @@ impl MainWorker {
|
||||||
mut options: WorkerOptions,
|
mut options: WorkerOptions,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
deno_core::extension!(deno_permissions_worker,
|
deno_core::extension!(deno_permissions_worker,
|
||||||
config = {
|
options = {
|
||||||
permissions: PermissionsContainer,
|
permissions: PermissionsContainer,
|
||||||
unstable: bool,
|
unstable: bool,
|
||||||
enable_testing_features: bool,
|
enable_testing_features: bool,
|
||||||
},
|
},
|
||||||
state = |state, permissions, unstable, enable_testing_features| {
|
state = |state, options| {
|
||||||
state.put::<PermissionsContainer>(permissions);
|
state.put::<PermissionsContainer>(options.permissions);
|
||||||
state.put(ops::UnstableChecker { unstable });
|
state.put(ops::UnstableChecker { unstable: options.unstable });
|
||||||
state.put(ops::TestingFeaturesEnabled(enable_testing_features));
|
state.put(ops::TestingFeaturesEnabled(options.enable_testing_features));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -255,7 +254,7 @@ impl MainWorker {
|
||||||
deno_tls::deno_tls::init_ops(),
|
deno_tls::deno_tls::init_ops(),
|
||||||
deno_napi::deno_napi::init_ops::<PermissionsContainer>(),
|
deno_napi::deno_napi::init_ops::<PermissionsContainer>(),
|
||||||
deno_http::deno_http::init_ops(),
|
deno_http::deno_http::init_ops(),
|
||||||
deno_io::deno_io::init_ops(Rc::new(RefCell::new(Some(options.stdio)))),
|
deno_io::deno_io::init_ops(Some(options.stdio)),
|
||||||
deno_fs::deno_fs::init_ops::<PermissionsContainer>(unstable),
|
deno_fs::deno_fs::init_ops::<PermissionsContainer>(unstable),
|
||||||
deno_flash::deno_flash::init_ops::<PermissionsContainer>(unstable),
|
deno_flash::deno_flash::init_ops::<PermissionsContainer>(unstable),
|
||||||
deno_node::deno_node_loading::init_ops::<PermissionsContainer>(
|
deno_node::deno_node_loading::init_ops::<PermissionsContainer>(
|
||||||
|
|
Loading…
Reference in a new issue