mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +02:00
feat: update setup hook to new syntax (#257)
This commit is contained in:
committed by
GitHub
parent
738636472c
commit
22f987bf24
Generated
+368
-283
File diff suppressed because it is too large
Load Diff
@@ -98,7 +98,7 @@ pub fn init<R: Runtime>(
|
||||
) -> TauriPlugin<R> {
|
||||
Builder::new("autostart")
|
||||
.invoke_handler(tauri::generate_handler![enable, disable, is_enabled])
|
||||
.setup(move |app| {
|
||||
.setup(move |app, _api| {
|
||||
let mut builder = AutoLaunchBuilder::new();
|
||||
builder.set_app_name(&app.package_info().name);
|
||||
if let Some(args) = args {
|
||||
|
||||
@@ -135,7 +135,7 @@ async fn unwatch(watchers: State<'_, WatcherCollection>, id: Id) -> Result<()> {
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
PluginBuilder::new("fs-watch")
|
||||
.invoke_handler(tauri::generate_handler![watch, unwatch])
|
||||
.setup(|app| {
|
||||
.setup(|app, _api| {
|
||||
app.manage(WatcherCollection::default());
|
||||
Ok(())
|
||||
})
|
||||
|
||||
@@ -59,7 +59,7 @@ impl Builder {
|
||||
let on_request = self.on_request.take();
|
||||
|
||||
PluginBuilder::new("localhost")
|
||||
.setup(move |app| {
|
||||
.setup(move |app, _api| {
|
||||
let asset_resolver = app.asset_resolver();
|
||||
std::thread::spawn(move || {
|
||||
let server =
|
||||
|
||||
@@ -248,7 +248,7 @@ impl Builder {
|
||||
pub fn build<R: Runtime>(mut self) -> TauriPlugin<R> {
|
||||
plugin::Builder::new("log")
|
||||
.invoke_handler(tauri::generate_handler![log])
|
||||
.setup(move |app_handle| {
|
||||
.setup(move |app_handle, _api| {
|
||||
let app_name = &app_handle.package_info().name;
|
||||
|
||||
// setup targets
|
||||
|
||||
@@ -35,7 +35,7 @@ struct Scope {
|
||||
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("persisted-scope")
|
||||
.setup(|app| {
|
||||
.setup(|app, _api| {
|
||||
let fs_scope = app.fs_scope();
|
||||
#[cfg(feature = "protocol-asset")]
|
||||
let asset_protocol_scope = app.asset_protocol_scope();
|
||||
|
||||
@@ -62,7 +62,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
plugin::Builder::new("positioner").invoke_handler(tauri::generate_handler![move_window]);
|
||||
|
||||
#[cfg(feature = "system-tray")]
|
||||
let plugin = plugin.setup(|app_handle| {
|
||||
let plugin = plugin.setup(|app_handle, _api| {
|
||||
app_handle.manage(Tray(std::sync::Mutex::new(None)));
|
||||
Ok(())
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ fn dbus_id(config: Arc<Config>) -> String {
|
||||
|
||||
pub fn init<R: Runtime>(f: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> {
|
||||
plugin::Builder::new("single-instance")
|
||||
.setup(|app| {
|
||||
.setup(|app, _api| {
|
||||
let id = dbus_id(app.config());
|
||||
let single_instance_dbus = SingleInstanceDBus {
|
||||
callback: f,
|
||||
|
||||
@@ -28,7 +28,7 @@ const WMCOPYDATA_SINGLE_INSTANCE_DATA: usize = 1542;
|
||||
|
||||
pub fn init<R: Runtime>(f: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> {
|
||||
plugin::Builder::new("single-instance")
|
||||
.setup(|app| {
|
||||
.setup(|app, _api| {
|
||||
let id = &app.config().tauri.bundle.identifier;
|
||||
|
||||
let class_name = encode_wide(format!("{id}-sic"));
|
||||
|
||||
@@ -93,7 +93,7 @@ struct DbInstances(Mutex<HashMap<String, Pool<Db>>>);
|
||||
|
||||
struct Migrations(Mutex<HashMap<String, MigrationList>>);
|
||||
|
||||
#[derive(Default, Deserialize)]
|
||||
#[derive(Default, Clone, Deserialize)]
|
||||
pub struct PluginConfig {
|
||||
#[serde(default)]
|
||||
preload: Vec<String>,
|
||||
@@ -329,10 +329,10 @@ impl Builder {
|
||||
}
|
||||
|
||||
pub fn build<R: Runtime>(mut self) -> TauriPlugin<R, Option<PluginConfig>> {
|
||||
PluginBuilder::new("sql")
|
||||
PluginBuilder::<R, Option<PluginConfig>>::new("sql")
|
||||
.invoke_handler(tauri::generate_handler![load, execute, select, close])
|
||||
.setup_with_config(|app, config: Option<PluginConfig>| {
|
||||
let config = config.unwrap_or_default();
|
||||
.setup(|app, api| {
|
||||
let config = api.config().clone().unwrap_or_default();
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
create_dir_all(app_path(app)).expect("problems creating App directory!");
|
||||
|
||||
@@ -336,7 +336,7 @@ impl Builder {
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
set, get, has, delete, clear, reset, keys, values, length, entries, load, save
|
||||
])
|
||||
.setup(move |app_handle| {
|
||||
.setup(move |app_handle, _api| {
|
||||
for (path, store) in self.stores.iter_mut() {
|
||||
// ignore loading errors, just use the default
|
||||
if let Err(err) = store.load(app_handle) {
|
||||
|
||||
@@ -409,7 +409,7 @@ impl Builder {
|
||||
let password_hash_function = self.password_hash_function;
|
||||
|
||||
PluginBuilder::new("stronghold")
|
||||
.setup(move |app| {
|
||||
.setup(move |app, _api| {
|
||||
app.manage(StrongholdCollection::default());
|
||||
app.manage(PasswordHashFunction(password_hash_function));
|
||||
Ok(())
|
||||
|
||||
@@ -163,7 +163,7 @@ async fn send(
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
PluginBuilder::new("websocket")
|
||||
.invoke_handler(tauri::generate_handler![connect, send])
|
||||
.setup(|app| {
|
||||
.setup(|app, _api| {
|
||||
app.manage(ConnectionManager::default());
|
||||
Ok(())
|
||||
})
|
||||
|
||||
@@ -269,7 +269,7 @@ impl Builder {
|
||||
pub fn build<R: Runtime>(self) -> TauriPlugin<R> {
|
||||
let flags = self.state_flags;
|
||||
PluginBuilder::new("window-state")
|
||||
.setup(|app| {
|
||||
.setup(|app, _api| {
|
||||
let cache: Arc<Mutex<HashMap<String, WindowState>>> = if let Some(app_dir) =
|
||||
app.path_resolver().app_config_dir()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user