From 3e21ffc935a139f9cfa1ddfaeffd6429d53061ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 30 Jun 2021 18:01:11 +0200 Subject: [PATCH] feat(inspector): improve inspector prompt in Chrome Devtools (#11187) This commit improves how Deno inspector presents itself in Chrome Devtools. --- runtime/inspector_server.rs | 15 ++++++++++----- runtime/web_worker.rs | 6 +++++- runtime/worker.rs | 8 ++++++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/runtime/inspector_server.rs b/runtime/inspector_server.rs index a205455fa2..793cd2866f 100644 --- a/runtime/inspector_server.rs +++ b/runtime/inspector_server.rs @@ -64,8 +64,10 @@ impl InspectorServer { &self, session_sender: UnboundedSender, deregister_rx: oneshot::Receiver<()>, + module_url: String, ) { - let info = InspectorInfo::new(self.host, session_sender, deregister_rx); + let info = + InspectorInfo::new(self.host, session_sender, deregister_rx, module_url); self.register_inspector_tx.unbounded_send(info).unwrap(); } } @@ -333,6 +335,7 @@ pub struct InspectorInfo { pub thread_name: Option, pub new_session_tx: UnboundedSender, pub deregister_rx: oneshot::Receiver<()>, + pub url: String, } impl InspectorInfo { @@ -340,6 +343,7 @@ impl InspectorInfo { host: SocketAddr, new_session_tx: mpsc::UnboundedSender, deregister_rx: oneshot::Receiver<()>, + url: String, ) -> Self { Self { host, @@ -347,6 +351,7 @@ impl InspectorInfo { thread_name: thread::current().name().map(|n| n.to_owned()), new_session_tx, deregister_rx, + url, } } @@ -358,7 +363,7 @@ impl InspectorInfo { "id": self.uuid.to_string(), "title": self.get_title(), "type": "node", - // TODO(ry): "url": "file://", + "url": self.url.to_string(), "webSocketDebuggerUrl": self.get_websocket_debugger_url(), }) } @@ -376,13 +381,13 @@ impl InspectorInfo { fn get_title(&self) -> String { format!( - "[{}] deno{}", - process::id(), + "deno{} [pid: {}]", self .thread_name .as_ref() .map(|n| format!(" - {}", n)) - .unwrap_or_default() + .unwrap_or_default(), + process::id(), ) } } diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index ac87d285b5..cc7b08fe0b 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -360,7 +360,11 @@ impl WebWorker { let inspector = js_runtime.inspector(); let session_sender = inspector.get_session_sender(); let deregister_rx = inspector.add_deregister_handler(); - server.register_inspector(session_sender, deregister_rx); + server.register_inspector( + session_sender, + deregister_rx, + main_module.to_string(), + ); } let (internal_handle, external_handle) = { diff --git a/runtime/worker.rs b/runtime/worker.rs index 091b971193..6d7d8bfca9 100644 --- a/runtime/worker.rs +++ b/runtime/worker.rs @@ -115,7 +115,7 @@ impl MainWorker { // Metrics metrics::init(), // Runtime ops - ops::runtime::init(main_module), + ops::runtime::init(main_module.clone()), ops::worker_host::init(options.create_web_worker_cb.clone()), ops::fs_events::init(), ops::fs::init(), @@ -145,7 +145,11 @@ impl MainWorker { let inspector = js_runtime.inspector(); let session_sender = inspector.get_session_sender(); let deregister_rx = inspector.add_deregister_handler(); - server.register_inspector(session_sender, deregister_rx); + server.register_inspector( + session_sender, + deregister_rx, + main_module.to_string(), + ); } Self {