diff options
| author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-04-16 23:40:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-16 23:40:29 +0200 |
| commit | d359789c529d3c7b5fab5471309eaa4b75fc0bfd (patch) | |
| tree | d9e9d45c2d65054c382a5bea1d818ea049b832bd /cli/web_worker.rs | |
| parent | 1cd1f7de70b8ee68d2f6757f2b38a712ea1f3876 (diff) | |
feat: support Deno namespace in Worker API (#4784)
Diffstat (limited to 'cli/web_worker.rs')
| -rw-r--r-- | cli/web_worker.rs | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/cli/web_worker.rs b/cli/web_worker.rs index 795409175..24318fc59 100644 --- a/cli/web_worker.rs +++ b/cli/web_worker.rs @@ -77,10 +77,16 @@ pub struct WebWorker { event_loop_idle: bool, terminate_rx: mpsc::Receiver<()>, handle: WebWorkerHandle, + pub has_deno_namespace: bool, } impl WebWorker { - pub fn new(name: String, startup_data: StartupData, state: State) -> Self { + pub fn new( + name: String, + startup_data: StartupData, + state: State, + has_deno_namespace: bool, + ) -> Self { let state_ = state.clone(); let mut worker = Worker::new(name, startup_data, state_); @@ -105,6 +111,7 @@ impl WebWorker { event_loop_idle: false, terminate_rx, handle, + has_deno_namespace, }; let handle = web_worker.thread_safe_handle(); @@ -124,6 +131,22 @@ impl WebWorker { ops::errors::init(isolate, &state); ops::timers::init(isolate, &state); ops::fetch::init(isolate, &state); + + if has_deno_namespace { + let op_registry = isolate.op_registry.clone(); + ops::runtime_compiler::init(isolate, &state); + ops::fs::init(isolate, &state); + ops::fs_events::init(isolate, &state); + ops::plugins::init(isolate, &state, op_registry); + ops::net::init(isolate, &state); + ops::tls::init(isolate, &state); + ops::os::init(isolate, &state); + ops::permissions::init(isolate, &state); + ops::process::init(isolate, &state); + ops::random::init(isolate, &state); + ops::signal::init(isolate, &state); + ops::tty::init(isolate, &state); + } } web_worker @@ -238,8 +261,11 @@ mod tests { "TEST".to_string(), startup_data::deno_isolate_init(), state, + false, ); - worker.execute("bootstrapWorkerRuntime(\"TEST\")").unwrap(); + worker + .execute("bootstrapWorkerRuntime(\"TEST\", false)") + .unwrap(); worker } #[test] |
