@@ -12,7 +12,7 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener};
1212use std:: sync:: Arc ;
1313use std:: thread;
1414use std:: time:: Duration ;
15- use tauri:: Runtime ;
15+ use tauri:: { Manager , Runtime } ;
1616use tokio:: sync:: mpsc;
1717use tracing_subscriber:: layer:: SubscriberExt ;
1818use tracing_subscriber:: util:: SubscriberInitExt ;
@@ -50,6 +50,10 @@ mod ios {
5050 ) ) ;
5151}
5252
53+ pub struct Devtools {
54+ pub connection : ConnectionInfo ,
55+ }
56+
5357fn init_plugin < R : Runtime > (
5458 addr : SocketAddr ,
5559 publish_interval : Duration ,
@@ -60,6 +64,10 @@ fn init_plugin<R: Runtime>(
6064 . setup ( move |app_handle, _api| {
6165 let ( mut health_reporter, health_service) = tonic_health:: server:: health_reporter ( ) ;
6266
67+ app_handle. manage ( Devtools {
68+ connection : connection_info ( & addr) ,
69+ } ) ;
70+
6371 health_reporter
6472 . set_serving :: < TauriServer < server:: TauriService < R > > > ( )
6573 . now_or_never ( )
@@ -280,7 +288,8 @@ impl Builder {
280288 // initialize early so we don't miss any spans
281289 tracing_subscriber:: registry ( )
282290 . with ( layer. with_filter ( tracing_subscriber:: filter:: LevelFilter :: TRACE ) )
283- . try_init ( ) ?;
291+ . try_init ( )
292+ . map_err ( devtools_core:: Error :: from) ?;
284293
285294 let mut port = self . port ;
286295 if !self . strict_port && !port_is_available ( & self . host , port) {
@@ -300,16 +309,14 @@ fn port_is_available(host: &IpAddr, port: u16) -> bool {
300309 TcpListener :: bind ( SocketAddr :: new ( * host, port) ) . is_ok ( )
301310}
302311
303- fn print_link ( addr : & SocketAddr ) {
304- let url = if option_env ! ( "__DEVTOOLS_LOCAL_DEVELOPMENT" ) . is_some ( ) {
305- "http://localhost:5173/dash/"
306- } else {
307- "https://devtools.crabnebula.dev/dash/"
308- } ;
312+ pub struct ConnectionInfo {
313+ pub host : IpAddr ,
314+ pub port : u16 ,
315+ }
309316
310- let url = format ! (
311- "{url}{}/{}" ,
312- if addr. ip( ) == Ipv4Addr :: UNSPECIFIED {
317+ fn connection_info ( addr : & SocketAddr ) -> ConnectionInfo {
318+ ConnectionInfo {
319+ host : if addr. ip ( ) == Ipv4Addr :: UNSPECIFIED {
313320 #[ cfg( target_os = "ios" ) ]
314321 {
315322 local_ip_address:: list_afinet_netifas ( )
@@ -333,8 +340,19 @@ fn print_link(addr: &SocketAddr) {
333340 } else {
334341 addr. ip ( )
335342 } ,
336- addr. port( )
337- ) ;
343+ port : addr. port ( ) ,
344+ }
345+ }
346+
347+ fn print_link ( addr : & SocketAddr ) {
348+ let url = if option_env ! ( "__DEVTOOLS_LOCAL_DEVELOPMENT" ) . is_some ( ) {
349+ "http://localhost:5173/dash/"
350+ } else {
351+ "https://devtools.crabnebula.dev/dash/"
352+ } ;
353+
354+ let connection = connection_info ( addr) ;
355+ let url = format ! ( "{url}{}/{}" , connection. host, connection. port) ;
338356
339357 #[ cfg( target_os = "ios" ) ]
340358 unsafe {
0 commit comments