Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): support plugins that are defined in app crate (#8781)
* feat(build): support plugins that are defined in app crate * dx
- Loading branch information
1 parent
052e8b4
commit edb11c1
Showing
10 changed files
with
170 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'tauri-build': patch:enhance | ||
--- | ||
|
||
Added `Attributes::plugin()` to register a plugin that is inlined in the application crate. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[default] | ||
description = "Default permissions for the plugin" | ||
permissions = ["allow-toggle", "allow-popup"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
|
||
use tauri::{ | ||
command, | ||
plugin::{Builder, TauriPlugin}, | ||
Runtime, | ||
}; | ||
|
||
#[cfg(not(target_os = "macos"))] | ||
#[command] | ||
pub fn toggle<R: tauri::Runtime>(window: tauri::Window<R>) { | ||
if window.is_menu_visible().unwrap_or_default() { | ||
let _ = window.hide_menu(); | ||
} else { | ||
let _ = window.show_menu(); | ||
} | ||
} | ||
|
||
#[cfg(target_os = "macos")] | ||
#[command] | ||
pub fn toggle<R: tauri::Runtime>( | ||
app: tauri::AppHandle<R>, | ||
app_menu: tauri::State<'_, crate::AppMenu<R>>, | ||
) { | ||
if let Some(menu) = app.remove_menu().unwrap() { | ||
app_menu.0.lock().unwrap().replace(menu); | ||
} else { | ||
app | ||
.set_menu(app_menu.0.lock().unwrap().clone().expect("no app menu")) | ||
.unwrap(); | ||
} | ||
} | ||
|
||
#[command] | ||
pub fn popup<R: tauri::Runtime>( | ||
window: tauri::Window<R>, | ||
popup_menu: tauri::State<'_, crate::PopupMenu<R>>, | ||
) { | ||
window.popup_menu(&popup_menu.0).unwrap(); | ||
} | ||
|
||
pub fn init<R: Runtime>() -> TauriPlugin<R> { | ||
Builder::new("app-menu") | ||
.invoke_handler(tauri::generate_handler![popup, toggle]) | ||
.build() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters