//! IPC commands of `ide_host::ops::run` (the shared implementation). use crate::state::AppState; use ide_core::{IdeResult, RunId}; #[allow(unused_imports)] pub use ide_host::ops::run::*; use ide_run::{OutputChunk, RunConfig, RunInfo}; use tauri::ipc::Channel; use tauri::{State, Window}; #[tauri::command] #[specta::specta] pub async fn run_dotnet_resolve( window: Window, state: State<'_, AppState>, config: RunConfig, debug: bool, ) -> IdeResult { ide_host::ops::run::run_dotnet_resolve(&state.host, window.label(), config, debug).await } #[tauri::command] #[specta::specta] pub async fn run_application_build( window: Window, state: State<'_, AppState>, config: RunConfig, module: std::path::PathBuf, ) -> IdeResult { ide_host::ops::run::run_application_build(&state.host, window.label(), config, module).await } #[tauri::command] #[specta::specta] pub async fn run_application_publish( window: Window, state: State<'_, AppState>, config: RunConfig, class_paths: Vec, main_class: String, ) -> IdeResult<()> { ide_host::ops::run::run_application_publish(&state.host, window.label(), config, class_paths, main_class).await } /// Detected configs followed by user-defined ones (user ids win on conflict). #[tauri::command] #[specta::specta] pub async fn run_configs(window: Window, state: State<'_, AppState>) -> IdeResult> { // Detection reads build files (and Spring Boot sources): off the command thread. let (host, label) = (state.host.clone(), window.label().to_owned()); tauri::async_runtime::spawn_blocking(move || ide_host::ops::run::configs(&host, &label)) .await .map_err(|e| ide_core::IdeError::internal(e.to_string()))? } #[tauri::command] #[specta::specta] pub fn run_save_configs( window: Window, state: State<'_, AppState>, configs: Vec, removed_detected_ids: Option>, ) -> IdeResult<()> { ide_host::ops::run::save_configs(&state.host, window.label(), &configs, &removed_detected_ids.unwrap_or_default()) } /// Temporary configurations as they are kept between sessions: without what settings derived. #[tauri::command] #[specta::specta] pub async fn run_without_derived( window: Window, state: State<'_, AppState>, configs: Vec, ) -> IdeResult> { let (host, label) = (state.host.clone(), window.label().to_owned()); tauri::async_runtime::spawn_blocking(move || ide_host::ops::run::without_derived(&host, &label, configs)) .await .map_err(|e| ide_core::IdeError::internal(e.to_string()))? } /// Kept temporary configurations with the current settings applied. #[tauri::command] #[specta::specta] pub async fn run_apply_settings( window: Window, state: State<'_, AppState>, configs: Vec, ) -> IdeResult> { let (host, label) = (state.host.clone(), window.label().to_owned()); tauri::async_runtime::spawn_blocking(move || ide_host::ops::run::apply_settings(&host, &label, configs)) .await .map_err(|e| ide_core::IdeError::internal(e.to_string()))? } #[tauri::command] #[specta::specta] pub async fn run_start( window: Window, state: State<'_, AppState>, config: RunConfig, on_output: Channel, ) -> IdeResult { let emit = std::sync::Arc::new(move |chunk| { let _ = on_output.send(chunk); }); ide_host::ops::run::start(&state.host, window.label(), config, emit).await } #[tauri::command] #[specta::specta] pub fn run_stop(window: Window, state: State<'_, AppState>, id: RunId) -> IdeResult<()> { ide_host::ops::run::stop(&state.host, window.label(), id) } #[tauri::command] #[specta::specta] pub fn run_stdin(state: State<'_, AppState>, id: RunId, data: String) -> IdeResult<()> { ide_host::ops::run::stdin(&state.host, id, &data) } /// Terminal size of a run started with "Emulate terminal in output console". #[tauri::command] #[specta::specta] pub fn run_resize(state: State<'_, AppState>, id: RunId, cols: u16, rows: u16) -> IdeResult<()> { ide_host::ops::run::resize(&state.host, id, cols, rows) } #[tauri::command] #[specta::specta] pub fn run_list(state: State<'_, AppState>) -> Vec { ide_host::ops::run::list(&state.host) } #[tauri::command] #[specta::specta] pub fn run_close_stdin(state: State<'_, AppState>, id: RunId) -> IdeResult<()> { ide_host::ops::run::close_stdin(&state.host, id) } /// Configuration templates: per-type defaults applied to new configurations. #[tauri::command] #[specta::specta] pub fn run_templates(window: Window, state: State<'_, AppState>) -> IdeResult> { ide_host::ops::run::run_templates(&state.host, window.label()) } #[tauri::command] #[specta::specta] pub fn run_save_templates(window: Window, state: State<'_, AppState>, templates: Vec) -> IdeResult<()> { ide_host::ops::run::run_save_templates(&state.host, window.label(), templates) } /// Project files run configurations can be imported from (`.vscode/launch.json`). #[tauri::command] #[specta::specta] pub fn run_import_sources( window: Window, state: State<'_, AppState>, ) -> IdeResult> { ide_host::ops::run::run_import_sources(&state.host, window.label()) } /// Configurations read from `source`, not saved; names already in `existing` are skipped. #[tauri::command] #[specta::specta] pub fn run_import_configs( window: Window, state: State<'_, AppState>, source: ide_run::import::RunImportSource, existing: Vec, ) -> IdeResult { ide_host::ops::run::run_import_configs(&state.host, window.label(), source, existing) } /// The environment runs inherit when "Include system environment variables" is on. #[tauri::command] #[specta::specta] pub fn run_system_env(state: State<'_, AppState>) -> std::collections::BTreeMap { ide_host::ops::run::run_system_env(&state.host, "") } /// Writes the Gradle init script adding `jvm_args` to the JVMs the build forks; returns its path. #[tauri::command] #[specta::specta] pub async fn run_gradle_jvm_args_script( window: Window, state: State<'_, AppState>, jvm_args: Vec, ) -> IdeResult { ide_host::ops::run::run_gradle_jvm_args_script(&state.host, window.label(), jvm_args).await } /// Results from the JUnit XML reports (Surefire, Failsafe, Gradle) of the module at /// `module` (relative to the project root) written since `since_ms` (Unix epoch, ms). #[tauri::command] #[specta::specta] pub async fn run_test_reports( window: Window, state: State<'_, AppState>, module: Option, since_ms: f64, ) -> IdeResult> { ide_host::ops::run::run_test_reports(&state.host, window.label(), module, since_ms).await } #[tauri::command] #[specta::specta] pub async fn run_tomcat_home( window: Window, state: State<'_, AppState>, home: String, ) -> IdeResult { ide_host::ops::run::run_tomcat_home(&state.host, window.label(), home).await } #[tauri::command] #[specta::specta] pub async fn run_tomcat_artifacts( window: Window, state: State<'_, AppState>, ) -> IdeResult> { ide_host::ops::run::run_tomcat_artifacts(&state.host, window.label()).await } #[tauri::command] #[specta::specta] pub async fn run_tomcat_build( window: Window, state: State<'_, AppState>, config: RunConfig, ) -> IdeResult> { ide_host::ops::run::run_tomcat_build(&state.host, window.label(), config).await } #[tauri::command] #[specta::specta] pub async fn run_tomcat_sync( window: Window, state: State<'_, AppState>, config: RunConfig, module: std::path::PathBuf, class_paths: Vec, resources_only: bool, ) -> IdeResult { ide_host::ops::run::run_tomcat_sync(&state.host, window.label(), config, module, class_paths, resources_only).await } #[tauri::command] #[specta::specta] pub async fn run_tomcat_update( window: Window, state: State<'_, AppState>, config: RunConfig, mode: String, ) -> IdeResult<()> { ide_host::ops::run::run_tomcat_update(&state.host, window.label(), config, mode).await }