//! Module manager commands for the main window (formerly `plugins:*`). use super::{logged, main_core, text, CommandResult}; use crate::core::app::CoreSlot; use serde_json::Value; use tauri::{State, Webview}; #[tauri::command] pub async fn core_modules_list(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult { let core = main_core(&webview, &slot)?; logged(&core, "plugins:list", core.services.modules.registry.list_installed().map(Value::Array)) } #[tauri::command] pub async fn core_modules_get_state(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult { let core = main_core(&webview, &slot)?; logged(&core, "plugins:getState", core.services.modules.get_state()) } #[tauri::command] pub async fn core_modules_check_catalog(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult { let core = main_core(&webview, &slot)?; let result = core.services.modules.check_catalog(&core).await; logged(&core, "plugins:checkCatalog", result) } #[tauri::command] pub async fn core_modules_install(webview: Webview, slot: State<'_, CoreSlot>, payload: Option) -> CommandResult { let core = main_core(&webview, &slot)?; let payload = super::payload(payload); let result = async { core.services.biometrics.require_sensitive_action().await?; core.services.modules.install(&core, text(&payload, "releaseId")).await } .await; logged(&core, "plugins:install", result) } #[tauri::command] pub async fn core_modules_uninstall(webview: Webview, slot: State<'_, CoreSlot>, payload: Option) -> CommandResult { let core = main_core(&webview, &slot)?; let payload = super::payload(payload); let result = async { core.services.biometrics.require_sensitive_action().await?; core.services.modules.uninstall(&core, text(&payload, "pluginId")).await } .await; logged(&core, "plugins:uninstall", result) } #[tauri::command] pub async fn core_modules_open(webview: Webview, slot: State<'_, CoreSlot>, payload: Option) -> CommandResult { let core = main_core(&webview, &slot)?; let payload = super::payload(payload); logged(&core, "plugins:open", core.services.modules.open(&core, text(&payload, "pluginId"))) }