mod commands; mod error; mod graph_stream; mod recents; mod repository_actor; mod workspace; pub use error::Error; pub use graph_stream::GraphEvent; pub use recents::{RecentRepository, RecentsHandle}; pub use workspace::{OpenedRepository, RepositoryId, WorkspaceHandle}; use tauri::Manager; /// Where the recents list lives, under the platform's config directory. const RECENTS_FILE: &str = "recent-repositories.json"; #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { tauri::Builder::default() .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_dialog::init()) .setup(|app| { // The config directory is only knowable from the app handle, which // is why the actors start here rather than before the builder. let file = app.path().app_config_dir()?.join(RECENTS_FILE); let (recents, remembering) = RecentsHandle::new(file); let (workspace, serving) = WorkspaceHandle::new(recents.clone()); tauri::async_runtime::spawn(remembering); tauri::async_runtime::spawn(serving); // The only shared state is two channel senders. Nothing is behind a // lock. app.manage(recents); app.manage(workspace); Ok(()) }) .invoke_handler(tauri::generate_handler![ commands::open_repository, commands::close_repository, commands::repository_summary, commands::list_references, commands::stream_graph, commands::request_more_rows, commands::list_recent_repositories, commands::forget_recent_repository, ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); }