diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index 8555a41eb..ba7df14b6 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -539,10 +539,10 @@ impl Dispatch for WryDispatcher { .map_err(|_| Error::FailedToSendMessage) } - fn create_window>( + fn create_window>( &mut self, - pending: PendingWindow, - ) -> Result> { + pending: PendingWindow

, + ) -> Result> { let (tx, rx) = channel(); let label = pending.label.clone(); let context = self.context.clone(); @@ -782,10 +782,10 @@ impl Runtime for Wry { }) } - fn create_window>( + fn create_window>( &self, - pending: PendingWindow, - ) -> Result> { + pending: PendingWindow

, + ) -> Result> { let label = pending.label.clone(); let proxy = self.event_loop.create_proxy(); let webview = create_webview( @@ -1052,10 +1052,10 @@ impl Runtime for Wry { } } -fn create_webview>( +fn create_webview>( event_loop: &EventLoopWindowTarget, context: DispatcherContext, - pending: PendingWindow, + pending: PendingWindow

, ) -> Result { let PendingWindow { webview_attributes, @@ -1098,10 +1098,10 @@ fn create_webview>( } /// Create a wry rpc handler from a tauri rpc handler. -fn create_rpc_handler>( +fn create_rpc_handler>( context: DispatcherContext, - label: M::Label, - handler: WebviewRpcHandler, + label: P::Label, + handler: WebviewRpcHandler

, ) -> Box Option + 'static> { Box::new(move |window, request| { handler( @@ -1119,10 +1119,10 @@ fn create_rpc_handler>( } /// Create a wry file drop handler from a tauri file drop handler. -fn create_file_drop_handler>( +fn create_file_drop_handler>( context: DispatcherContext, - label: M::Label, - handler: FileDropHandler, + label: P::Label, + handler: FileDropHandler

, ) -> Box bool + 'static> { Box::new(move |window, event| { handler( diff --git a/core/tauri-runtime/src/webview.rs b/core/tauri-runtime/src/webview.rs index ff8976356..8a5e67662 100644 --- a/core/tauri-runtime/src/webview.rs +++ b/core/tauri-runtime/src/webview.rs @@ -177,11 +177,11 @@ pub enum FileDropEvent { } /// Rpc handler. -pub type WebviewRpcHandler = Box, RpcRequest) + Send>; +pub type WebviewRpcHandler

= Box, RpcRequest) + Send>; /// File drop handler callback /// Return `true` in the callback to block the OS' default behavior of handling a file drop. -pub type FileDropHandler = Box) -> bool + Send>; +pub type FileDropHandler

= Box) -> bool + Send>; #[derive(Deserialize)] pub struct InvokePayload { diff --git a/core/tauri-runtime/src/window.rs b/core/tauri-runtime/src/window.rs index 229fba4c5..e47880a2e 100644 --- a/core/tauri-runtime/src/window.rs +++ b/core/tauri-runtime/src/window.rs @@ -55,32 +55,32 @@ pub struct MenuEvent { } /// A webview window that has yet to be built. -pub struct PendingWindow { +pub struct PendingWindow { /// The label that the window will be named. - pub label: M::Label, + pub label: P::Label, /// The [`WindowBuilder`] that the window will be created with. - pub window_builder: <::Dispatcher as Dispatch>::WindowBuilder, + pub window_builder: <::Dispatcher as Dispatch>::WindowBuilder, /// The [`WebviewAttributes`] that the webview will be created with. pub webview_attributes: WebviewAttributes, /// How to handle RPC calls on the webview window. - pub rpc_handler: Option>, + pub rpc_handler: Option>, /// How to handle a file dropping onto the webview window. - pub file_drop_handler: Option>, + pub file_drop_handler: Option>, /// The resolved URL to load on the webview. pub url: String, } -impl PendingWindow { +impl PendingWindow

{ /// Create a new [`PendingWindow`] with a label and starting url. pub fn new( - window_builder: <::Dispatcher as Dispatch>::WindowBuilder, + window_builder: <::Dispatcher as Dispatch>::WindowBuilder, webview_attributes: WebviewAttributes, - label: M::Label, + label: P::Label, ) -> Self { Self { window_builder, @@ -96,11 +96,11 @@ impl PendingWindow { pub fn with_config( window_config: WindowConfig, webview_attributes: WebviewAttributes, - label: M::Label, + label: P::Label, ) -> Self { Self { window_builder: - <<::Dispatcher as Dispatch>::WindowBuilder>::with_config( + <<::Dispatcher as Dispatch>::WindowBuilder>::with_config( window_config, ), webview_attributes, @@ -113,15 +113,15 @@ impl PendingWindow { } /// A webview window that is not yet managed by Tauri. -pub struct DetachedWindow { +pub struct DetachedWindow { /// Name of the window - pub label: M::Label, + pub label: P::Label, /// The [`Dispatch`](crate::Dispatch) associated with the window. - pub dispatcher: ::Dispatcher, + pub dispatcher: ::Dispatcher, } -impl Clone for DetachedWindow { +impl Clone for DetachedWindow

{ fn clone(&self) -> Self { Self { label: self.label.clone(), @@ -130,15 +130,15 @@ impl Clone for DetachedWindow { } } -impl Hash for DetachedWindow { +impl Hash for DetachedWindow

{ /// Only use the [`DetachedWindow`]'s label to represent its hash. fn hash(&self, state: &mut H) { self.label.hash(state) } } -impl Eq for DetachedWindow {} -impl PartialEq for DetachedWindow { +impl Eq for DetachedWindow

{} +impl PartialEq for DetachedWindow

{ /// Only use the [`DetachedWindow`]'s label to compare equality. fn eq(&self, other: &Self) -> bool { self.label.eq(&other.label) diff --git a/core/tauri/src/app.rs b/core/tauri/src/app.rs index bfba202d7..d90dfd827 100644 --- a/core/tauri/src/app.rs +++ b/core/tauri/src/app.rs @@ -141,9 +141,9 @@ impl App

{ } #[cfg(feature = "updater")] -impl App { +impl App

{ /// Runs the updater hook with built-in dialog. - fn run_updater_dialog(&self, window: Window) { + fn run_updater_dialog(&self, window: Window

) { let updater_config = self.manager.config().tauri.updater.clone(); let package_info = self.manager.package_info().clone(); crate::async_runtime::spawn(async move { @@ -152,12 +152,12 @@ impl App { } /// Listen updater events when dialog are disabled. - fn listen_updater_events(&self, window: Window) { + fn listen_updater_events(&self, window: Window

) { let updater_config = self.manager.config().tauri.updater.clone(); updater::listener(updater_config, self.manager.package_info().clone(), &window); } - fn run_updater(&self, main_window: Option>) { + fn run_updater(&self, main_window: Option>) { if let Some(main_window) = main_window { let event_window = main_window.clone(); let updater_config = self.manager.config().tauri.updater.clone(); @@ -172,7 +172,7 @@ impl App { // invoke the Event `tauri://update` from JS or rust side. main_window.listen( updater::EVENT_CHECK_UPDATE - .parse::() + .parse::() .unwrap_or_else(|_| panic!("bad label")), move |_msg| { let window = event_window.clone(); diff --git a/core/tauri/src/endpoints.rs b/core/tauri/src/endpoints.rs index 0f7ccafb5..9b8e89940 100644 --- a/core/tauri/src/endpoints.rs +++ b/core/tauri/src/endpoints.rs @@ -57,10 +57,10 @@ enum Module { } impl Module { - fn run( + fn run( self, - window: Window, - resolver: InvokeResolver, + window: Window

, + resolver: InvokeResolver

, config: Arc, package_info: PackageInfo, ) { diff --git a/core/tauri/src/endpoints/event.rs b/core/tauri/src/endpoints/event.rs index 95fedacad..9269ef730 100644 --- a/core/tauri/src/endpoints/event.rs +++ b/core/tauri/src/endpoints/event.rs @@ -25,7 +25,7 @@ pub enum Cmd { } impl Cmd { - pub fn run(self, window: Window) -> crate::Result { + pub fn run(self, window: Window

) -> crate::Result { match self { Self::Listen { event, handler } => { let event_id = rand::random(); @@ -42,11 +42,11 @@ impl Cmd { payload, } => { // Panic if the user's `Tag` type decided to return an error while parsing. - let e: M::Event = event + let e: P::Event = event .parse() .unwrap_or_else(|_| panic!("Event module received unhandled event: {}", event)); - let window_label: Option = window_label.map(|l| { + let window_label: Option = window_label.map(|l| { l.parse() .unwrap_or_else(|_| panic!("Event module recieved unhandled window: {}", l)) }); @@ -65,7 +65,7 @@ impl Cmd { } } -pub fn unlisten_js(window: &Window, event_id: u64) -> String { +pub fn unlisten_js(window: &Window

, event_id: u64) -> String { format!( " for (var event in (window['{listeners}'] || {{}})) {{ @@ -80,8 +80,8 @@ pub fn unlisten_js(window: &Window, event_id: u64) -> String { ) } -pub fn listen_js( - window: &Window, +pub fn listen_js( + window: &Window

, event: String, event_id: u64, handler: String, diff --git a/core/tauri/src/endpoints/global_shortcut.rs b/core/tauri/src/endpoints/global_shortcut.rs index 0f309b1bf..179286cea 100644 --- a/core/tauri/src/endpoints/global_shortcut.rs +++ b/core/tauri/src/endpoints/global_shortcut.rs @@ -55,7 +55,7 @@ fn register_shortcut( #[cfg(not(global_shortcut_all))] impl Cmd { - pub fn run(self, _window: Window) -> crate::Result { + pub fn run(self, _window: Window

) -> crate::Result { Err(crate::Error::ApiNotAllowlisted( "globalShortcut > all".to_string(), )) @@ -64,7 +64,7 @@ impl Cmd { #[cfg(global_shortcut_all)] impl Cmd { - pub fn run(self, window: Window) -> crate::Result { + pub fn run(self, window: Window

) -> crate::Result { match self { Self::Register { shortcut, handler } => { let dispatcher = window.dispatcher(); diff --git a/core/tauri/src/endpoints/shell.rs b/core/tauri/src/endpoints/shell.rs index 12fa9f2d5..5ad0432ee 100644 --- a/core/tauri/src/endpoints/shell.rs +++ b/core/tauri/src/endpoints/shell.rs @@ -73,7 +73,7 @@ pub enum Cmd { impl Cmd { #[allow(unused_variables)] - pub fn run(self, window: Window) -> crate::Result { + pub fn run(self, window: Window

) -> crate::Result { match self { Self::Execute { program, diff --git a/core/tauri/src/hooks.rs b/core/tauri/src/hooks.rs index 9e16e53e3..1caa68b37 100644 --- a/core/tauri/src/hooks.rs +++ b/core/tauri/src/hooks.rs @@ -229,9 +229,9 @@ impl InvokeResolver

{ } /// An invoke message. -pub struct InvokeMessage { +pub struct InvokeMessage { /// The window that received the invoke message. - pub(crate) window: Window, + pub(crate) window: Window

, /// Application managed state. pub(crate) state: Arc, /// The RPC command. diff --git a/core/tauri/src/updater/mod.rs b/core/tauri/src/updater/mod.rs index 9de90a9c6..cdbadb851 100644 --- a/core/tauri/src/updater/mod.rs +++ b/core/tauri/src/updater/mod.rs @@ -383,10 +383,10 @@ struct UpdateManifest { } /// Check if there is any new update with builtin dialog. -pub(crate) async fn check_update_with_dialog( +pub(crate) async fn check_update_with_dialog( updater_config: UpdaterConfig, package_info: crate::api::PackageInfo, - window: Window, + window: Window

, ) { if let Some(endpoints) = updater_config.endpoints.clone() { // check updates @@ -425,17 +425,17 @@ pub(crate) async fn check_update_with_dialog( /// Experimental listener /// This function should be run on the main thread once. -pub(crate) fn listener( +pub(crate) fn listener( updater_config: UpdaterConfig, package_info: crate::api::PackageInfo, - window: &Window, + window: &Window

, ) { let isolated_window = window.clone(); // Wait to receive the event `"tauri://update"` window.listen( EVENT_CHECK_UPDATE - .parse::() + .parse::() .unwrap_or_else(|_| panic!("bad label")), move |_msg| { let window = isolated_window.clone(); @@ -469,7 +469,7 @@ pub(crate) fn listener( // Emit `tauri://update-available` let _ = window.emit( - &tauri_event::(EVENT_UPDATE_AVAILABLE), + &tauri_event::(EVENT_UPDATE_AVAILABLE), Some(UpdateManifest { body, date: updater.date.clone(), @@ -480,7 +480,7 @@ pub(crate) fn listener( // Listen for `tauri://update-install` window.once( EVENT_INSTALL_UPDATE - .parse::() + .parse::() .unwrap_or_else(|_| panic!("bad label")), move |_msg| { let window = window_isolation.clone(); @@ -522,9 +522,9 @@ pub(crate) fn listener( } // Send a status update via `tauri://update-status` event. -fn send_status_update(window: Window, status: &str, error: Option) { +fn send_status_update(window: Window

, status: &str, error: Option) { let _ = window.emit( - &tauri_event::(EVENT_STATUS_UPDATE), + &tauri_event::(EVENT_STATUS_UPDATE), Some(StatusEvent { error, status: String::from(status), diff --git a/core/tauri/src/window.rs b/core/tauri/src/window.rs index 3c516c773..01c776671 100644 --- a/core/tauri/src/window.rs +++ b/core/tauri/src/window.rs @@ -105,7 +105,7 @@ pub struct Window { manager: WindowManager

, } -impl Clone for Window { +impl Clone for Window

{ fn clone(&self) -> Self { Self { window: self.window.clone(), diff --git a/tooling/cli.js/test/jest/fixtures/app/src-tauri/src/main.rs b/tooling/cli.js/test/jest/fixtures/app/src-tauri/src/main.rs index 6f05ad621..be923f7ff 100644 --- a/tooling/cli.js/test/jest/fixtures/app/src-tauri/src/main.rs +++ b/tooling/cli.js/test/jest/fixtures/app/src-tauri/src/main.rs @@ -1,5 +1,5 @@ #[tauri::command(with_window)] -fn exit(window: tauri::Window) { +fn exit(window: tauri::Window

) { window.close().unwrap(); }