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, vrchat_builtin_parameters}};
7
8mod frontend_calls;
9mod osc;
10mod runtime;
11mod setup;
12mod structs;
13mod utils;
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 mut addresses = ADDRESSES.lock().unwrap();
37 addresses.append(&mut vrchat_builtin_parameters::get_read_addresses());
38 drop(addresses);
39
40 let (runtime_sender, runtime_receiver) = bounded(1024);
41
42 tauri::Builder::default()
43 .plugin(tauri_plugin_os::init())
44 .plugin(tauri_plugin_clipboard_manager::init())
45 .plugin(tauri_plugin_dialog::init())
46 .plugin(tauri_plugin_opener::init())
47 .invoke_handler(tauri::generate_handler![
48 get_addresses::get_addresses,
49 save_graph::save_graph,
50 sync_tab::sync_tab,
51 sync_tab::discard_tab,
52 load_previous_tabs::load_previous_tabs,
53 close_app::close_app,
54 settings::set_hide_editor_on_app_start,
55 settings::get_hide_editor_on_app_start,
56 ])
57 .manage(conf)
58 .manage(&ADDRESSES)
59 .manage(runtime_sender)
60 .setup(|app| {
61 setup(app, &ADDRESSES, runtime_receiver);
62 Ok(())
63 })
64 .run(tauri::generate_context!())
65 .expect("error while running tauri application");
66}