diff options
Diffstat (limited to 'cli/web_worker.rs')
-rw-r--r-- | cli/web_worker.rs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/cli/web_worker.rs b/cli/web_worker.rs index 9320c22d8..18d391580 100644 --- a/cli/web_worker.rs +++ b/cli/web_worker.rs @@ -8,7 +8,6 @@ use crate::metrics::Metrics; use crate::ops; use crate::permissions::Permissions; use crate::tokio_util::create_basic_runtime; -use crate::version; use deno_core::error::AnyError; use deno_core::futures::channel::mpsc; use deno_core::futures::future::poll_fn; @@ -133,10 +132,12 @@ pub struct WebWorker { } pub struct WebWorkerOptions { + /// Sets `Deno.args` in JS runtime. pub args: Vec<String>, pub debug_flag: bool, pub unstable: bool, pub ca_filepath: Option<String>, + pub user_agent: String, pub seed: Option<u64>, pub module_loader: Rc<dyn ModuleLoader>, pub create_web_worker_cb: Arc<ops::worker_host::CreateWebWorkerCb>, @@ -145,6 +146,12 @@ pub struct WebWorkerOptions { pub attach_inspector: bool, pub maybe_inspector_server: Option<Arc<InspectorServer>>, pub apply_source_maps: bool, + /// Sets `Deno.version.deno` in JS runtime. + pub runtime_version: String, + /// Sets `Deno.version.typescript` in JS runtime. + pub ts_version: String, + /// Sets `Deno.noColor` in JS runtime. + pub no_color: bool, } impl WebWorker { @@ -222,7 +229,11 @@ impl WebWorker { deno_web::op_domain_to_ascii, ); ops::io::init(js_runtime); - ops::websocket::init(js_runtime, options.ca_filepath.as_deref()); + ops::websocket::init( + js_runtime, + options.ca_filepath.as_deref(), + options.user_agent.clone(), + ); if options.use_deno_namespace { ops::fs_events::init(js_runtime); @@ -260,12 +271,12 @@ impl WebWorker { "args": options.args, "applySourceMaps": options.apply_source_maps, "debugFlag": options.debug_flag, - "denoVersion": version::deno(), - "noColor": !colors::use_color(), + "denoVersion": options.runtime_version, + "noColor": options.no_color, "pid": std::process::id(), "ppid": ops::runtime::ppid(), "target": env!("TARGET"), - "tsVersion": version::TYPESCRIPT, + "tsVersion": options.ts_version, "unstableFlag": options.unstable, "v8Version": deno_core::v8_version(), }); @@ -466,6 +477,7 @@ mod tests { debug_flag: false, unstable: false, ca_filepath: None, + user_agent: "x".to_string(), seed: None, module_loader, create_web_worker_cb, @@ -473,6 +485,9 @@ mod tests { use_deno_namespace: false, attach_inspector: false, maybe_inspector_server: None, + runtime_version: "x".to_string(), + ts_version: "x".to_string(), + no_color: true, }; let mut worker = WebWorker::from_options( |