Skip to main content

tauri_plugin_ambient_fs/
lib.rs

1// tauri plugin for ambient-fs daemon integration
2//
3// this plugin bridges ambient-fsd to tauri apps via IPC commands
4// and forwards daemon events to the frontend as tauri events.
5
6mod config;
7mod state;
8mod commands;
9mod events;
10
11pub use config::AmbientFsConfig;
12
13use tauri::Manager;
14use tauri::plugin::Builder;
15use tauri::Wry;
16use state::PluginState;
17
18/// initialize the ambient-fs plugin
19///
20/// usage in tauri app:
21/// ```text
22/// tauri::Builder::default()
23///     .plugin(tauri_plugin_ambient_fs::init())
24///     .run(tauri::generate_context!())
25///     .expect("error while running tauri application");
26/// ```
27pub fn init() -> tauri::plugin::TauriPlugin<Wry> {
28    Builder::new("ambient-fs")
29        .invoke_handler(tauri::generate_handler![
30            commands::watch_project,
31            commands::unwatch_project,
32            commands::query_events,
33            commands::query_awareness,
34            commands::query_tree,
35            commands::attribute,
36            commands::query_agents,
37            commands::subscribe,
38            commands::unsubscribe,
39            commands::get_status,
40        ])
41        .setup(|app, _api| {
42            let state = PluginState::new(app.clone());
43            app.manage(state);
44            Ok(())
45        })
46        .build()
47}
48
49#[cfg(test)]
50mod tests {
51    use super::*;
52
53    #[test]
54    fn init_creates_plugin() {
55        // we can't fully test the plugin without a tauri runtime,
56        // but we can verify the init function exists and compiles
57        let _plugin_name = "ambient-fs";
58    }
59}