this repo has no description
1use std::{ fs, sync::Mutex };
2
3use crossbeam_channel::bounded;
4use frontend_calls::*;
5
6use crate::{ osc::OSCMessage, setup::setup, utils::config::Config };
7
8mod frontend_calls;
9mod osc;
10mod setup;
11mod structs;
12mod utils;
13mod runtime;
14
15#[cfg_attr(mobile, tauri::mobile_entry_point)]
16#[tokio::main]
17pub async fn run() {
18 let container_folder = dirs::config_dir().unwrap().join("VRCMacros");
19
20 match fs::metadata(&container_folder) {
21 Ok(meta) => {
22 if meta.is_file() {
23 panic!("Cannot launch app as the container path is a file not a directory");
24 }
25 }
26 Err(_) => {
27 fs::create_dir(&container_folder).unwrap();
28 }
29 }
30
31 let conf_file = container_folder.join("conf");
32 let conf = Config::new(conf_file);
33
34 static ADDRESSES: Mutex<Vec<OSCMessage>> = Mutex::new(Vec::new());
35
36 let ( runtime_sender, runtime_receiver ) = bounded(1024);
37
38 tauri::Builder::default()
39 .plugin(tauri_plugin_dialog::init())
40 .plugin(tauri_plugin_opener::init())
41 .invoke_handler(tauri::generate_handler![
42 get_addresses::get_addresses,
43 save_graph::save_graph,
44 sync_tab::sync_tab,
45 sync_tab::discard_tab,
46 load_previous_tabs::load_previous_tabs,
47 close_app::close_app,
48
49 settings::set_hide_editor_on_app_start,
50 settings::get_hide_editor_on_app_start,
51 ])
52 .manage(conf)
53 .manage(&ADDRESSES)
54 .manage(runtime_sender)
55 .setup(|app| {
56 setup(app, &ADDRESSES, runtime_receiver);
57 Ok(())
58 })
59 .run(tauri::generate_context!())
60 .expect("error while running tauri application");
61}