frontend fixes & db rewrite with serde

This commit is contained in:
Priler 2026-01-04 09:00:51 +05:00
parent 61b7a79455
commit 091a41ac33
37 changed files with 910 additions and 663 deletions

49
Cargo.lock generated
View file

@ -324,7 +324,7 @@ dependencies = [
"anyhow", "anyhow",
"arrayvec", "arrayvec",
"log", "log",
"nom", "nom 8.0.0",
"num-rational", "num-rational",
"v_frame", "v_frame",
] ]
@ -481,6 +481,12 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "bytesize"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e93abca9e28e0a1b9877922aacb20576e05d4679ffa78c3d6dc22a26a216659"
[[package]] [[package]]
name = "cairo-rs" name = "cairo-rs"
version = "0.18.5" version = "0.18.5"
@ -2641,6 +2647,7 @@ dependencies = [
"kira", "kira",
"log", "log",
"once_cell", "once_cell",
"parking_lot",
"platform-dirs", "platform-dirs",
"pv_recorder", "pv_recorder",
"rand 0.8.5", "rand 0.8.5",
@ -2658,12 +2665,16 @@ name = "jarvis-gui"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"jarvis-core", "jarvis-core",
"lazy_static",
"log", "log",
"once_cell", "once_cell",
"parking_lot",
"peak_alloc",
"platform-dirs", "platform-dirs",
"serde", "serde",
"serde_json", "serde_json",
"simple-log", "simple-log",
"systemstat",
"tauri", "tauri",
"tauri-build", "tauri-build",
"tauri-plugin-dialog", "tauri-plugin-dialog",
@ -3073,6 +3084,12 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.8.9" version = "0.8.9"
@ -3193,6 +3210,16 @@ version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
[[package]]
name = "nom"
version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
"memchr",
"minimal-lexical",
]
[[package]] [[package]]
name = "nom" name = "nom"
version = "8.0.0" version = "8.0.0"
@ -3922,6 +3949,12 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
[[package]]
name = "peak_alloc"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccc90935a8dd139fdf341762773687a1e361d3f54b396a55d9dd1f7001e484bb"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.3.2" version = "2.3.2"
@ -5702,6 +5735,20 @@ dependencies = [
"version-compare", "version-compare",
] ]
[[package]]
name = "systemstat"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5021f5184d44b26fb184acd689671bbe1e4bbd24bbdaa6bc7ec383fad32d2033"
dependencies = [
"bytesize",
"lazy_static",
"libc",
"nom 7.1.3",
"time",
"winapi",
]
[[package]] [[package]]
name = "tao" name = "tao"
version = "0.34.5" version = "0.34.5"

View file

@ -28,4 +28,5 @@ kira = "0.11"
pv_recorder = { git = "https://github.com/Priler/pvrecorder" } pv_recorder = { git = "https://github.com/Priler/pvrecorder" }
vosk = "0.3" vosk = "0.3"
rustpotter = { git = "https://github.com/Priler/rustpotter" } rustpotter = { git = "https://github.com/Priler/rustpotter" }
image = "0.25" image = "0.25"
parking_lot = "0.12.5"

View file

@ -19,9 +19,14 @@ platform-dirs.workspace = true
rodio.workspace = true rodio.workspace = true
kira.workspace = true kira.workspace = true
pv_recorder.workspace = true pv_recorder.workspace = true
vosk.workspace = true
rustpotter.workspace = true rustpotter.workspace = true
parking_lot.workspace = true
# pv_recorder = { workspace = true, optional = true }
vosk = { version = "0.3.1", optional = true }
# rustpotter = { workspace = true, optional = true }
[features] [features]
default = ["jarvis_app"] default = ["jarvis_app"]
jarvis_app = [] jarvis_app = ["vosk"]

View file

@ -68,8 +68,12 @@ pub fn play_sound(filename: &PathBuf) {
} }
pub fn get_sound_directory() -> Option<PathBuf> { pub fn get_sound_directory() -> Option<PathBuf> {
let voice = DB.get().unwrap().voice.as_str(); let db = DB.get()?;
let voice_path = SOUND_DIR.join(voice);
let voice_path = {
let s = db.read();
SOUND_DIR.join(&s.voice)
};
match voice_path.exists() && voice_path.cmp(&SOUND_DIR) != Ordering::Equal { match voice_path.exists() && voice_path.cmp(&SOUND_DIR) != Ordering::Equal {
true => Some(voice_path), true => Some(voice_path),

View file

@ -14,7 +14,7 @@ impl fmt::Display for WakeWordEngine {
} }
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug, Clone)]
pub enum SpeechToTextEngine { pub enum SpeechToTextEngine {
Vosk, Vosk,
} }

View file

@ -49,10 +49,10 @@ pub fn save_settings(settings: &structs::Settings) -> Result<(), std::io::Error>
let db_file_path = get_db_file_path(); let db_file_path = get_db_file_path();
std::fs::write( std::fs::write(
db_file_path, &db_file_path,
serde_json::to_string_pretty(&settings).unwrap(), serde_json::to_string_pretty(&settings).unwrap(),
)?; )?;
info!("Settings saved."); info!("Settings saved to: {:#}", db_file_path.display());
Ok(()) Ok(())
} }

View file

@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use crate::config::structs::SpeechToTextEngine; use crate::config::structs::SpeechToTextEngine;
use crate::config::structs::WakeWordEngine; use crate::config::structs::WakeWordEngine;
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Settings { pub struct Settings {
pub microphone: i32, pub microphone: i32,
pub voice: String, pub voice: String,
@ -32,7 +32,7 @@ impl Default for Settings {
} }
} }
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ApiKeys { pub struct ApiKeys {
pub picovoice: String, pub picovoice: String,
pub openai: String, pub openai: String,

View file

@ -1,4 +1,6 @@
use once_cell::sync::{Lazy, OnceCell}; use once_cell::sync::{Lazy, OnceCell};
use parking_lot::RwLock;
use std::sync::Arc;
use platform_dirs::AppDirs; use platform_dirs::AppDirs;
use std::path::PathBuf; use std::path::PathBuf;
@ -9,8 +11,13 @@ pub mod audio;
pub mod commands; pub mod commands;
pub mod config; pub mod config;
pub mod db; pub mod db;
#[cfg(feature = "jarvis_app")]
pub mod listener; pub mod listener;
pub mod recorder; pub mod recorder;
#[cfg(feature = "jarvis_app")]
pub mod stt; pub mod stt;
// shared statics // shared statics
@ -19,7 +26,7 @@ pub static SOUND_DIR: Lazy<PathBuf> = Lazy::new(|| APP_DIR.clone().join("sound")
pub static APP_DIRS: OnceCell<AppDirs> = OnceCell::new(); pub static APP_DIRS: OnceCell<AppDirs> = OnceCell::new();
pub static APP_CONFIG_DIR: OnceCell<PathBuf> = OnceCell::new(); pub static APP_CONFIG_DIR: OnceCell<PathBuf> = OnceCell::new();
pub static APP_LOG_DIR: OnceCell<PathBuf> = OnceCell::new(); pub static APP_LOG_DIR: OnceCell<PathBuf> = OnceCell::new();
pub static DB: OnceCell<db::structs::Settings> = OnceCell::new(); pub static DB: OnceCell<Arc<RwLock<db::structs::Settings>>> = OnceCell::new();
pub static COMMANDS_LIST: OnceCell<Vec<commands::AssistantCommand>> = OnceCell::new(); pub static COMMANDS_LIST: OnceCell<Vec<commands::AssistantCommand>> = OnceCell::new();
// re-exports // re-exports

View file

@ -1,4 +1,5 @@
mod pvrecorder; mod pvrecorder;
// mod cpal; // mod cpal;
// mod portaudio; // mod portaudio;
@ -122,29 +123,37 @@ pub fn stop_recording() -> Result<(), ()> {
} }
pub fn get_selected_microphone_index() -> i32 { pub fn get_selected_microphone_index() -> i32 {
DB.get().unwrap().microphone DB.get().unwrap().read().microphone
} }
pub fn get_audio_devices() -> Vec<String> { pub fn get_audio_devices() -> Vec<String> {
match RECORDER_TYPE.get().unwrap() { match RECORDER_TYPE.get() {
RecorderType::PvRecorder => pvrecorder::list_audio_devices(), Some(RecorderType::PvRecorder) => pvrecorder::list_audio_devices(),
RecorderType::PortAudio => { Some(RecorderType::PortAudio) => {
todo!(); todo!();
} }
RecorderType::Cpal => { Some(RecorderType::Cpal) => {
todo!(); todo!();
} }
None => {
// not initialized yet, default to pvrecorder
pvrecorder::list_audio_devices()
}
} }
} }
pub fn get_audio_device_name(idx: i32) -> String { pub fn get_audio_device_name(idx: i32) -> String {
match RECORDER_TYPE.get().unwrap() { match RECORDER_TYPE.get() {
RecorderType::PvRecorder => pvrecorder::get_audio_device_name(idx), Some(RecorderType::PvRecorder) => pvrecorder::get_audio_device_name(idx),
RecorderType::PortAudio => { Some(RecorderType::PortAudio) => {
todo!(); todo!();
} }
RecorderType::Cpal => { Some(RecorderType::Cpal) => {
todo!(); todo!();
} }
None => {
// not initialized yet, default to pvrecorder
pvrecorder::get_audio_device_name(idx)
}
} }
} }

View file

@ -1,3 +1,4 @@
#[cfg(feature = "vosk")]
mod vosk; mod vosk;
use crate::config; use crate::config;

View file

@ -7,22 +7,27 @@ repository.workspace = true
edition.workspace = true edition.workspace = true
[dependencies] [dependencies]
jarvis-core = { path = "../jarvis-core", default-features = true } jarvis-core = { path = "../jarvis-core", default-features = false }
tauri = { version = "2", features = [] } # v1: "shell-open", "dialog-message", "path-all" tauri = { version = "2", features = [] } # v1: "shell-open", "dialog-message", "path-all"
tauri-plugin-shell = "2" tauri-plugin-shell = "2"
tauri-plugin-dialog = "2" tauri-plugin-dialog = "2"
tauri-plugin-fs = "2" tauri-plugin-fs = "2"
peak_alloc = "0.3.0"
systemstat = "0.2"
lazy_static = "1.4"
once_cell.workspace = true once_cell.workspace = true
log.workspace = true log.workspace = true
simple-log = "2.4" simple-log = "2.4"
serde.workspace = true serde.workspace = true
serde_json.workspace = true serde_json.workspace = true
platform-dirs.workspace = true platform-dirs.workspace = true
parking_lot.workspace = true
[build-dependencies] [build-dependencies]
tauri-build = { version = "2", features = [] } tauri-build = { version = "2", features = [] }
[features] [features]
default = ["custom-protocol"] default = ["custom-protocol"]
custom-protocol = ["tauri/custom-protocol"] custom-protocol = ["tauri/custom-protocol"]

View file

@ -3,12 +3,20 @@
use jarvis_core::{config, db, APP_CONFIG_DIR, APP_LOG_DIR, DB}; use jarvis_core::{config, db, APP_CONFIG_DIR, APP_LOG_DIR, DB};
use parking_lot::RwLock;
use std::sync::Arc;
#[macro_use] #[macro_use]
extern crate simple_log; extern crate simple_log;
mod events; mod events;
// mod tauri_commands; mod tauri_commands;
#[derive(Clone)]
pub struct AppState {
pub db: Arc<RwLock<db::structs::Settings>>,
}
fn main() { fn main() {
config::init_dirs().expect("Failed to init dirs"); config::init_dirs().expect("Failed to init dirs");
@ -16,14 +24,43 @@ fn main() {
// basic logging setup (simpler for GUI) // basic logging setup (simpler for GUI)
simple_log::quick!("info"); simple_log::quick!("info");
let _ = DB.set(db::init_settings()); // init db
let settings = db::init_settings();
DB.set(Arc::new(RwLock::new(settings)))
.expect("DB already initialized");
let db_arc = DB.get().unwrap().clone();
tauri::Builder::default() tauri::Builder::default()
.manage(AppState { db: db_arc })
.plugin(tauri_plugin_shell::init()) .plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_fs::init()) .plugin(tauri_plugin_fs::init())
.invoke_handler(tauri::generate_handler![ .invoke_handler(tauri::generate_handler![
// commands will be added here after tauri_commands module is fixed // audio
tauri_commands::pv_get_audio_devices,
tauri_commands::pv_get_audio_device_name,
tauri_commands::play_sound,
// db
tauri_commands::db_read,
tauri_commands::db_write,
// etc
tauri_commands::get_app_version,
tauri_commands::get_author_name,
tauri_commands::get_repository_link,
tauri_commands::get_tg_official_link,
tauri_commands::get_feedback_link,
// fs
tauri_commands::get_log_file_path,
tauri_commands::show_in_folder,
// sys
tauri_commands::get_current_ram_usage,
tauri_commands::get_peak_ram_usage,
tauri_commands::get_cpu_temp,
tauri_commands::get_cpu_usage,
]) ])
.run(tauri::generate_context!()) .run(tauri::generate_context!())
.expect("error while running tauri application"); .expect("error while running tauri application");

View file

@ -1,27 +1,24 @@
// import AUDIO commands
mod audio;
pub use audio::*;
// import DB related commands // import DB related commands
mod db; mod db;
pub use db::*; pub use db::*;
// import RECORDER commands // import LISTENER commands
mod audio; // @REMOVED: gui not listens anymore
pub use audio::*; // mod listener;
// pub use listener::*;
// import PORCUPINE commands // import ETC commands
mod listener; mod etc;
pub use listener::*; pub use etc::*;
// import SYS commands
mod sys;
pub use sys::*;
// import VOICE commands
mod voice;
pub use voice::*;
// import FS commands // import FS commands
mod fs; mod fs;
pub use fs::*; pub use fs::*;
// import ETC commands // import SYS commands
mod etc; mod sys;
pub use etc::*; pub use sys::*;

View file

@ -1,33 +1,20 @@
use pv_recorder::RecorderBuilder; use jarvis_core::recorder;
// use rodio::{Decoder, OutputStream, Sink};
use std::path::PathBuf;
use jarvis_core::audio;
#[tauri::command] #[tauri::command]
pub fn pv_get_audio_devices() -> Vec<String> { pub fn pv_get_audio_devices() -> Vec<String> {
let audio_devices = RecorderBuilder::default().get_audio_devices(); recorder::get_audio_devices()
match audio_devices {
Ok(audio_devices) => audio_devices,
Err(err) => panic!("Failed to get audio devices: {}", err),
}
} }
#[tauri::command] #[tauri::command]
pub fn pv_get_audio_device_name(idx: i32) -> String { pub fn pv_get_audio_device_name(idx: i32) -> String {
let audio_devices = RecorderBuilder::default().get_audio_devices(); recorder::get_audio_device_name(idx)
let mut first_device: String = String::new(); }
match audio_devices {
Ok(audio_devices) => { #[tauri::command(async)]
for (_idx, device) in audio_devices.iter().enumerate() { pub fn play_sound(filename: &str) {
if idx as usize == _idx { let path = PathBuf::from(filename);
return device.to_string(); audio::play_sound(&path);
}
if _idx == 0 {
first_device = device.to_string()
}
}
}
Err(err) => panic!("Failed to get audio devices: {}", err),
};
// return first device as default, if none were matched
first_device
} }

View file

@ -1,19 +1,62 @@
use crate::DB; use jarvis_core::{db, DB};
use crate::AppState;
#[tauri::command] #[tauri::command]
pub fn db_read(key: &str) -> String { pub fn db_read(state: tauri::State<'_, AppState>, key: &str) -> String {
if let Some(value) = DB.lock().unwrap().get::<String>(key) { let settings = state.db.read();
return value
}
String::from("") match key {
"selected_microphone" => settings.microphone.to_string(),
"assistant_voice" => settings.voice.clone(),
"selected_wake_word_engine" => format!("{:?}", settings.wake_word_engine),
"speech_to_text_engine" => format!("{:?}", settings.speech_to_text_engine),
"api_key__picovoice" => settings.api_keys.picovoice.clone(),
"api_key__openai" => settings.api_keys.openai.clone(),
_ => String::new(),
}
} }
#[tauri::command] #[tauri::command]
pub fn db_write(key: &str, val: &str) -> bool { pub fn db_write(state: tauri::State<'_, AppState>, key: &str, val: &str) -> bool {
if let Ok(_) = DB.lock().unwrap().set(key, &val) { let snapshot = {
true let mut settings = state.db.write();
} else {
false match key {
"selected_microphone" => {
if let Ok(v) = val.parse::<i32>() {
// info!("MICROPHONE changed: {}", v);
settings.microphone = v;
} else {
return false;
}
}
"assistant_voice" => {
settings.voice = val.to_string();
}
"selected_wake_word_engine" => {
match val.to_lowercase().as_str() {
"rustpotter" => settings.wake_word_engine = jarvis_core::config::structs::WakeWordEngine::Rustpotter,
"vosk" => settings.wake_word_engine = jarvis_core::config::structs::WakeWordEngine::Vosk,
"porcupine" => settings.wake_word_engine = jarvis_core::config::structs::WakeWordEngine::Porcupine,
_ => return false,
}
}
"api_key__picovoice" => {
settings.api_keys.picovoice = val.to_string();
}
"api_key__openai" => {
settings.api_keys.openai = val.to_string();
}
_ => return false,
}
settings.clone()
};
// save to disk
if let Err(e) = db::save_settings(&snapshot) {
info!("SETTINGS NOT SAVED");
} }
true
} }

View file

@ -1,5 +1,4 @@
use crate::config; use jarvis_core::{config, APP_LOG_DIR};
use crate::APP_LOG_DIR;
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
@ -50,5 +49,7 @@ pub fn get_feedback_link() -> String {
#[tauri::command] #[tauri::command]
pub fn get_log_file_path() -> String { pub fn get_log_file_path() -> String {
format!("{}", APP_LOG_DIR.lock().unwrap()) APP_LOG_DIR.get()
.map(|p| p.display().to_string())
.unwrap_or_else(|| "unknown".to_string())
} }

View file

@ -1,3 +1,8 @@
#[cfg(target_os = "linux")]
use std::fs::metadata;
#[cfg(target_os = "linux")]
use std::path::PathBuf;
use std::process::Command; use std::process::Command;
// taken from https://github.com/tauri-apps/tauri/issues/4062#issuecomment-1338048169 // taken from https://github.com/tauri-apps/tauri/issues/4062#issuecomment-1338048169

View file

@ -7,6 +7,7 @@ extern crate systemstat;
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;
use systemstat::{Platform, System}; use systemstat::{Platform, System};
use lazy_static::lazy_static;
lazy_static! { lazy_static! {
static ref SYS: System = System::new(); static ref SYS: System = System::new();

View file

@ -1,29 +0,0 @@
use std::fs::File;
use std::io::BufReader;
use rodio::{Decoder, OutputStream, Sink};
#[tauri::command(async)]
pub fn play_sound(filename: &str, sleep: bool) {
// Get a output stream handle to the default physical sound device
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
let sink = Sink::try_new(&stream_handle).unwrap();
// Load a sound from a file, using a path relative to Cargo.toml
// let filepath = format!("{PUBLIC_PATH}/sound/{filename}.wav");
let filepath = filename;
let file = BufReader::new(File::open(&filepath).unwrap());
// Decode that sound file into a source
let source = Decoder::new(file).unwrap();
// Play the sound directly on the device
println!("Playing {} ...", filepath);
// stream_handle.play_raw(source.convert_samples());
sink.append(source);
if sleep {
// The sound plays in a separate thread. This call will block the current thread until the sink
// has finished playing all its queued sounds.
sink.sleep_until_end();
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,15 +1,13 @@
{ {
"name": "jarvis-app", "name": "jarvis-app",
"private": true, "private": true,
"version": "0.0.3", "version": "0.1.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "routify -c dev:vite", "dev": "vite",
"dev:routify": "routify", "build": "svelte-check --ignore '.routify' --no-tsconfig && vite build",
"dev:vite": "vite",
"build": "svelte-check && routify -b && vite build",
"preview": "vite preview", "preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json", "check": "svelte-check --ignore '.routify' --tsconfig ./tsconfig.json",
"tauri": "tauri" "tauri": "tauri"
}, },
"dependencies": { "dependencies": {
@ -17,26 +15,27 @@
"@svelteuidev/core": "^0.15.7", "@svelteuidev/core": "^0.15.7",
"@svelteuidev/motion": "^0.15.7", "@svelteuidev/motion": "^0.15.7",
"@tauri-apps/api": "^2", "@tauri-apps/api": "^2",
"@tauri-apps/plugin-shell": "^2",
"@tauri-apps/plugin-dialog": "^2", "@tauri-apps/plugin-dialog": "^2",
"@tauri-apps/plugin-fs": "^2", "@tauri-apps/plugin-fs": "^2",
"@tauri-apps/plugin-shell": "^2",
"howler": "^2.2.4", "howler": "^2.2.4",
"radix-icons-svelte": "^1.2.1", "radix-icons-svelte": "^1.2.1",
"worker-timers": "^8.0.27" "worker-timers": "^8.0.27"
}, },
"devDependencies": { "devDependencies": {
"@roxi/routify": "^3.6.4", "@roxi/routify": "^3.6.4",
"@sveltejs/vite-plugin-svelte": "^6.2.1", "@sveltejs/vite-plugin-svelte": "^3.1.0",
"@tauri-apps/cli": "^2", "@tauri-apps/cli": "^2",
"@tsconfig/svelte": "^5.0.6", "@tsconfig/svelte": "^5.0.6",
"@types/howler": "^2.2.12",
"@types/node": "^25.0.3", "@types/node": "^25.0.3",
"sass": "^1.97.1", "sass": "^1.97.1",
"svelte": "^5.46.1", "svelte": "^4.2.18",
"svelte-check": "^4.3.5", "svelte-check": "^3.8.0",
"svelte-preprocess": "^6.0.3", "svelte-preprocess": "^5.1.4",
"tslib": "^2.8.1", "tslib": "^2.8.1",
"typescript": "^5.9.3", "typescript": "^5.9.3",
"vite": "^7.3.0", "vite": "^5.4.0",
"vite-tsconfig-paths": "^6.0.3" "vite-tsconfig-paths": "^4.3.2"
} }
} }

View file

@ -1,15 +1,15 @@
<!-- src/App.svelte --> <!-- src/App.svelte -->
<script> <script>
import { Router } from "@roxi/routify"; import { Router } from "@roxi/routify";
import { routes } from "../.routify/routes"; import routes from "../.routify/routes.default.js";
import { SvelteUIProvider } from '@svelteuidev/core'; import { SvelteUIProvider } from '@svelteuidev/core';
import Events from "./Events.svelte"; import Events from "./Events.svelte";
/** START LISTENING **/ /** START LISTENING **/
import { startListening } from "./functions"; // import { startListening } from "./functions";
startListening(); // startListening();
</script> </script>
<SvelteUIProvider themeObserver='dark' withNormalizeCSS withGlobalStyles> <SvelteUIProvider themeObserver='dark' withNormalizeCSS withGlobalStyles>

View file

@ -8,7 +8,7 @@
let assistant_voice_val = "jarvis-og"; let assistant_voice_val = "jarvis-og";
import { assistant_voice } from "@/stores" import { assistant_voice } from "@/stores"
import { invoke } from '@tauri-apps/api/tauri'; import { invoke } from "@tauri-apps/api/core";
assistant_voice.subscribe(value => { assistant_voice.subscribe(value => {
assistant_voice_val = value; assistant_voice_val = value;
}); });
@ -34,11 +34,11 @@
}); });
await listen('assistant-greet', (event) => { await listen('assistant-greet', (event) => {
document.getElementById("arc-reactor").classList.add("active"); document.getElementById("arc-reactor")?.classList.add("active");
}); });
await listen('assistant-waiting', (event) => { await listen('assistant-waiting', (event) => {
document.getElementById("arc-reactor").classList.remove("active"); document.getElementById("arc-reactor")?.classList.remove("active");
}); });
}); });
</script> </script>

View file

@ -1,5 +1,5 @@
<script> <script>
import { invoke } from "@tauri-apps/api/tauri" import { invoke } from "@tauri-apps/api/core"
import { tg_official_link, github_repository_link } from "@/stores"; import { tg_official_link, github_repository_link } from "@/stores";

View file

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { invoke } from "@tauri-apps/api/tauri" import { invoke } from "@tauri-apps/api/core"
import { Dashboard, Gear } from 'radix-icons-svelte' import { Dashboard, Gear } from 'radix-icons-svelte'
import {isActive} from '@roxi/routify' import {isActive} from '@roxi/routify'

View file

@ -1,6 +1,6 @@
<script> <script>
// IMPORTS // IMPORTS
import { invoke } from "@tauri-apps/api/tauri" import { invoke } from "@tauri-apps/api/core"
import { onMount } from 'svelte' import { onMount } from 'svelte'
import { capitalizeFirstLetter } from "@/functions"; import { capitalizeFirstLetter } from "@/functions";

View file

@ -2,13 +2,13 @@ import { invoke } from "@tauri-apps/api/core"
import { is_listening, isListening } from "@/stores" import { is_listening, isListening } from "@/stores"
import { clearInterval, clearTimeout, setInterval, setTimeout } from 'worker-timers'; import { clearInterval, clearTimeout, setInterval, setTimeout } from 'worker-timers';
setInterval(() => { // setInterval(() => {
(async () => { // (async () => {
is_listening.set(await invoke("is_listening")); // is_listening.set(await invoke("is_listening"));
})().catch(err => { // })().catch(err => {
console.error(err); // console.error(err);
}); // });
}, 1000); // }, 1000);
export function startListening() { export function startListening() {
(async () => { (async () => {
@ -26,7 +26,7 @@ export function startListening() {
}); });
} }
export function stopListening(callback) { export function stopListening(callback: () => void) {
(async () => { (async () => {
invoke('stop_listening') invoke('stop_listening')
.then((message) => { .then((message) => {
@ -43,11 +43,11 @@ export function stopListening(callback) {
}); });
} }
export function capitalizeFirstLetter(string) { export function capitalizeFirstLetter(string: string) {
return string.charAt(0).toUpperCase() + string.slice(1); return string.charAt(0).toUpperCase() + string.slice(1);
} }
export function showInExplorer(path) { export function showInExplorer(path: any) {
(async () => { (async () => {
invoke('show_in_folder', {path: path}) invoke('show_in_folder', {path: path})
.then((message) => {}) .then((message) => {})

View file

@ -7,7 +7,7 @@ import "./css/styles.scss";
// deploy app // deploy app
import App from "./App.svelte"; import App from "./App.svelte";
const app = new App({ const app = new App({
target: document.getElementById("app"), target: document.getElementById("app")!,
}); });
export default app; export default app;

View file

@ -1,10 +1,10 @@
<script lang="ts"> <script lang="ts">
// IMPORTS // IMPORTS
import { invoke } from "@tauri-apps/api/tauri" import { invoke } from "@tauri-apps/api/core"
import { goto } from '@roxi/routify' import { goto } from '@roxi/routify'
import { onMount } from 'svelte' import { onMount } from 'svelte'
import { startListening, stopListening, showInExplorer } from "@/functions"; import { startListening, stopListening, showInExplorer } from "@/functions";
import { setTimeout } from 'worker-timers'; // import { setTimeout } from 'worker-timers';
import { feedback_link, log_file_path } from "@/stores"; import { feedback_link, log_file_path } from "@/stores";
@ -17,7 +17,7 @@
// VARIABLES // VARIABLES
let available_microphones = []; let available_microphones: { label: string; value: number }[] = [];
let settings_saved = false; let settings_saved = false;
let save_button_disabled = false; let save_button_disabled = false;
@ -70,10 +70,10 @@
let _available_microphones: Array<Number> = await invoke("pv_get_audio_devices"); let _available_microphones: Array<Number> = await invoke("pv_get_audio_devices");
Object.entries(_available_microphones).forEach(entry => { Object.entries(_available_microphones).forEach(entry => {
const [k, v] = entry; const [k, v] = entry;
available_microphones.push({ available_microphones.push({
label: v, label: String(v),
value: k value: Number(k)
}); });
}); });
@ -134,9 +134,9 @@
<Space h="sm" /> <Space h="sm" />
<NativeSelect data={[ <NativeSelect data={[
{ label: 'Rustpotter', value: 'rustpotter' }, { label: 'Rustpotter', value: 'Rustpotter' },
{ label: 'Vosk (медленный)', value: 'vosk' }, { label: 'Vosk (медленный)', value: 'Vosk' },
{ label: 'Picovoice Porcupine (требует API ключ)', value: 'picovoice' } { label: 'Picovoice Porcupine (требует API ключ)', value: 'Picovoice' }
]} ]}
label="Распознавание активационной фразы (Wake Word)" label="Распознавание активационной фразы (Wake Word)"
description="Выберите, какая нейросеть будет отвечать за распознавание активационной фразы." description="Выберите, какая нейросеть будет отвечать за распознавание активационной фразы."

View file

@ -20,5 +20,9 @@
}, },
}, },
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"], "include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
"references": [{ "path": "./tsconfig.node.json" }] "references": [{ "path": "./tsconfig.node.json" }],
"exclude": [
"node_modules",
".routify"
]
} }

View file

@ -4,5 +4,6 @@
"module": "ESNext", "module": "ESNext",
"moduleResolution": "Node" "moduleResolution": "Node"
}, },
"include": ["vite.config.ts"] "include": ["vite.config.ts"],
"exclude": [".routify"]
} }

View file

@ -2,9 +2,9 @@ import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte"; import { svelte } from "@sveltejs/vite-plugin-svelte";
import sveltePreprocess from "svelte-preprocess"; import sveltePreprocess from "svelte-preprocess";
import tsconfigPaths from 'vite-tsconfig-paths' import tsconfigPaths from 'vite-tsconfig-paths'
import routify from '@roxi/routify/vite-plugin'
// https://vitejs.dev/config/ export default defineConfig({
export default defineConfig(async () => ({
plugins: [ plugins: [
svelte({ svelte({
preprocess: [ preprocess: [
@ -20,26 +20,19 @@ export default defineConfig(async () => ({
handler(warning); handler(warning);
}, },
}), }),
routify(),
tsconfigPaths() tsconfigPaths()
], ],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
// prevent vite from obscuring rust errors
clearScreen: false, clearScreen: false,
// tauri expects a fixed port, fail if that port is not available
server: { server: {
port: 1420, port: 1420,
strictPort: true, strictPort: true,
}, },
// to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
envPrefix: ["VITE_", "TAURI_"], envPrefix: ["VITE_", "TAURI_"],
build: { build: {
// Tauri supports es2021
target: process.env.TAURI_PLATFORM == "windows" ? "chrome105" : "safari13", target: process.env.TAURI_PLATFORM == "windows" ? "chrome105" : "safari13",
// don't minify for debug builds
minify: !process.env.TAURI_DEBUG ? "esbuild" : false, minify: !process.env.TAURI_DEBUG ? "esbuild" : false,
// produce sourcemaps for debug builds
sourcemap: !!process.env.TAURI_DEBUG, sourcemap: !!process.env.TAURI_DEBUG,
}, },
})); });

View file

@ -1,46 +0,0 @@
// vite.config.ts
import { defineConfig } from "file:///D:/Rust/jarvis-app/gui/node_modules/vite/dist/node/index.js";
import { svelte } from "file:///D:/Rust/jarvis-app/gui/node_modules/@sveltejs/vite-plugin-svelte/src/index.js";
import sveltePreprocess from "file:///D:/Rust/jarvis-app/gui/node_modules/svelte-preprocess/dist/index.js";
import tsconfigPaths from "file:///D:/Rust/jarvis-app/gui/node_modules/vite-tsconfig-paths/dist/index.mjs";
var vite_config_default = defineConfig(async () => ({
plugins: [
svelte({
preprocess: [
sveltePreprocess({
typescript: true
})
],
onwarn: (warning, handler) => {
const { code, frame } = warning;
if (code === "css-unused-selector")
return;
handler(warning);
}
}),
tsconfigPaths()
],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
// prevent vite from obscuring rust errors
clearScreen: false,
// tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true
},
// to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
envPrefix: ["VITE_", "TAURI_"],
build: {
// Tauri supports es2021
target: process.env.TAURI_PLATFORM == "windows" ? "chrome105" : "safari13",
// don't minify for debug builds
minify: !process.env.TAURI_DEBUG ? "esbuild" : false,
// produce sourcemaps for debug builds
sourcemap: !!process.env.TAURI_DEBUG
}
}));
export {
vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCJEOlxcXFxSdXN0XFxcXGphcnZpcy1hcHBcXFxcZ3VpXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWd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