diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2022-05-17 21:27:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 22:27:17 +0200 |
commit | 330c820ae8d7826dfe3d88c01ba07728121fa021 (patch) | |
tree | a5c0216f5cba4ea503e9cba3b0abdd8d4290c123 /runtime/web_worker.rs | |
parent | f57aac77ff9ce514730504066daca0a61a959d32 (diff) |
BREAKING(unstable): Enable Deno namespace in workers by default (#14581)
This commit removes "WorkerOptions.deno" option as a boolean,
as well as "WorkerOptions.deno.namespace" settings. Starting
with this commit all workers have access to "Deno" namespace
by default.
Diffstat (limited to 'runtime/web_worker.rs')
-rw-r--r-- | runtime/web_worker.rs | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index 9582d0f7f..a2f2ffc5d 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -312,7 +312,6 @@ pub struct WebWorker { pub js_runtime: JsRuntime, pub name: String, internal_handle: WebWorkerInternalHandle, - pub use_deno_namespace: bool, pub worker_type: WebWorkerType, pub main_module: ModuleSpecifier, poll_for_messages_fn: Option<v8::Global<v8::Value>>, @@ -329,7 +328,6 @@ pub struct WebWorkerOptions { pub preload_module_cb: Arc<ops::worker_host::PreloadModuleCb>, pub format_js_error_fn: Option<Arc<FormatJsErrorFn>>, pub source_map_getter: Option<Box<dyn SourceMapGetter>>, - pub use_deno_namespace: bool, pub worker_type: WebWorkerType, pub maybe_inspector_server: Option<Arc<InspectorServer>>, pub get_error_class_fn: Option<GetErrorClassFn>, @@ -413,30 +411,28 @@ impl WebWorker { options.format_js_error_fn.clone(), ), // Extensions providing Deno.* features - ops::fs_events::init().enabled(options.use_deno_namespace), - ops::fs::init().enabled(options.use_deno_namespace), + ops::fs_events::init(), + ops::fs::init(), ops::io::init(), - ops::io::init_stdio(options.stdio).enabled(options.use_deno_namespace), - deno_tls::init().enabled(options.use_deno_namespace), + ops::io::init_stdio(options.stdio), + deno_tls::init(), deno_net::init::<Permissions>( options.root_cert_store.clone(), unstable, options.unsafely_ignore_certificate_errors.clone(), - ) - .enabled(options.use_deno_namespace), + ), ops::os::init(Some( options .maybe_exit_code .expect("Worker has access to OS ops but exit code was not passed."), - )) - .enabled(options.use_deno_namespace), - ops::permissions::init().enabled(options.use_deno_namespace), - ops::process::init().enabled(options.use_deno_namespace), - ops::spawn::init().enabled(options.use_deno_namespace), - ops::signal::init().enabled(options.use_deno_namespace), - ops::tty::init().enabled(options.use_deno_namespace), - deno_http::init().enabled(options.use_deno_namespace), - ops::http::init().enabled(options.use_deno_namespace), + )), + ops::permissions::init(), + ops::process::init(), + ops::spawn::init(), + ops::signal::init(), + ops::tty::init(), + deno_http::init(), + ops::http::init(), // Permissions ext (worker specific state) perm_ext, ]; @@ -479,7 +475,6 @@ impl WebWorker { js_runtime, name, internal_handle, - use_deno_namespace: options.use_deno_namespace, worker_type: options.worker_type, main_module, poll_for_messages_fn: None, @@ -492,10 +487,9 @@ impl WebWorker { // Instead of using name for log we use `worker-${id}` because // WebWorkers can have empty string as name. let script = format!( - "bootstrap.workerRuntime({}, \"{}\", {}, \"{}\")", + "bootstrap.workerRuntime({}, \"{}\", \"{}\")", options.as_json(), self.name, - self.use_deno_namespace, self.id ); self |