From ddf7232424dd4418603628202b4628381f4f3476 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Sat, 5 Jul 2025 21:29:59 +0200 Subject: [PATCH] fix: crossplatform packages --- .prettierrc | 2 +- .vscode/settings.json | 5 ++- bun.lock | 7 ++++ package.json | 1 + src-tauri/Cargo.toml | 6 ++-- src-tauri/capabilities/default.json | 56 ++++++++++++++--------------- src-tauri/src/commands.rs | 16 ++++++--- src-tauri/src/utils.rs | 10 ++++-- 8 files changed, 65 insertions(+), 38 deletions(-) diff --git a/.prettierrc b/.prettierrc index 18dae0c..badd21e 100644 --- a/.prettierrc +++ b/.prettierrc @@ -9,7 +9,7 @@ "tabWidth": 2, "useTabs": false, "bracketSpacing": true, - "plugins": ["prettier-plugin-svelte"], + "plugins": ["prettier-plugin-svelte", "prettier-plugin-rust"], "overrides": [ { "files": "*.svelte", diff --git a/.vscode/settings.json b/.vscode/settings.json index 0e6f27d..0949f69 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ { "svelte.enable-ts-plugin": true, - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "esbenp.prettier-vscode", + "[rust]":{ + "editor.defaultFormatter": "rust-lang.rust-analyzer" + } } diff --git a/bun.lock b/bun.lock index 07d79f3..12cfa8b 100644 --- a/bun.lock +++ b/bun.lock @@ -22,6 +22,7 @@ "lucide-svelte": "0.523.0", "osu-classes": "3.1.0", "osu-parsers": "4.1.7", + "prettier-plugin-rust": "^0.1.9", "radix-icons-svelte": "1.2.1", "svelte-confetti": "^2.0.0", }, @@ -503,6 +504,8 @@ "jackspeak": ["jackspeak@3.4.3", "", { "dependencies": { "@isaacs/cliui": "^8.0.2" }, "optionalDependencies": { "@pkgjs/parseargs": "^0.11.0" } }, "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw=="], + "jinx-rust": ["jinx-rust@0.1.6", "", {}, "sha512-qP+wtQL1PrDDFwtPKhNGtjWOmijCrKdfUHWTV2G/ikxfjrh+cjdvkQTmny9RAsVF0jiui9m+F0INWu4cuRcZeQ=="], + "jiti": ["jiti@1.21.7", "", { "bin": { "jiti": "bin/jiti.js" } }, "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A=="], "js-yaml": ["js-yaml@4.1.0", "", { "dependencies": { "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA=="], @@ -629,6 +632,8 @@ "prettier": ["prettier@3.6.1", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-5xGWRa90Sp2+x1dQtNpIpeOQpTDBs9cZDmA/qs2vDNN2i18PdapqY7CmBeyLlMuGqXJRIOPaCaVZTLNQRWUH/A=="], + "prettier-plugin-rust": ["prettier-plugin-rust@0.1.9", "", { "dependencies": { "jinx-rust": "0.1.6", "prettier": "^2.7.1" } }, "sha512-n1DTTJQaHMdnoG/+nKUvBm3EKsMVWsYES2UPCiOPiZdBrmuAO/pX++m7L3+Hz3uuhtddpH0HRKHB2F3jbtJBOQ=="], + "prettier-plugin-svelte": ["prettier-plugin-svelte@3.4.0", "", { "peerDependencies": { "prettier": "^3.0.0", "svelte": "^3.2.0 || ^4.0.0-next.0 || ^5.0.0-next.0" } }, "sha512-pn1ra/0mPObzqoIQn/vUTR3ZZI6UuZ0sHqMK5x2jMLGrs53h0sXhkVuDcrlssHwIMk7FYrMjHBPoUSyyEEDlBQ=="], "punycode": ["punycode@2.3.1", "", {}, "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg=="], @@ -833,6 +838,8 @@ "postcss-load-config/yaml": ["yaml@1.10.2", "", {}, "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg=="], + "prettier-plugin-rust/prettier": ["prettier@2.8.8", "", { "bin": { "prettier": "bin-prettier.js" } }, "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q=="], + "string-width-cjs/emoji-regex": ["emoji-regex@8.0.0", "", {}, "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="], "string-width-cjs/strip-ansi": ["strip-ansi@6.0.1", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="], diff --git a/package.json b/package.json index 563288b..9522b88 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "lucide-svelte": "0.523.0", "osu-classes": "3.1.0", "osu-parsers": "4.1.7", + "prettier-plugin-rust": "^0.1.9", "radix-icons-svelte": "1.2.1", "svelte-confetti": "^2.0.0" }, diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 61f0ac1..ed5716a 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -27,15 +27,17 @@ tauri-plugin-sql = "2.3.0" tauri-plugin-dialog = "2.3.0" tauri-plugin-fs = "2.4.0" hardware-id = "0.3.0" -winreg = "0.55.0" tauri-plugin-cors-fetch = "4.1.0" sysinfo = "0.35.2" -winapi = { version = "0.3", features = ["winuser"] } reqwest = { version = "0.12.22", features = ["json", "stream"] } md5 = "0.8.0" tokio = { version = "1.46.1", features = ["full"] } open = "5.3.2" +[target.'cfg(windows)'.dependencies] +winreg = "0.55.0" +winapi = { version = "0.3", features = ["winuser"] } + [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies] tauri-plugin-single-instance = "2.3.0" diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 786384c..cf07318 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -17,59 +17,59 @@ "core:window:allow-show", "fs:default", { - "identifier": "fs:allow-write", + "identifier": "fs:allow-read", "allow": [ - { - "path": "$HOME/**/*" - } + { "path": "$HOME/.ezpplauncher" }, + { "path": "$HOME/.ezpplauncher/*" }, + { "path": "$HOME/.ezpplauncher/**/*" } ] }, { - "identifier": "fs:allow-read", + "identifier": "fs:allow-write", "allow": [ - { - "path": "$HOME/**/*" - } + { "path": "$HOME/.ezpplauncher" }, + { "path": "$HOME/.ezpplauncher/*" }, + { "path": "$HOME/.ezpplauncher/**/*" } ] }, { "identifier": "fs:allow-exists", "allow": [ - { - "path": "$HOME/**/*" - } - ] - }, - { - "identifier": "fs:allow-write-file", - "allow": [ - { - "path": "$HOME/**/*" - } + { "path": "$HOME/.ezpplauncher" }, + { "path": "$HOME/.ezpplauncher/*" }, + { "path": "$HOME/.ezpplauncher/**/*" } ] }, { "identifier": "fs:allow-read-file", "allow": [ - { - "path": "$HOME/**/*" - } + { "path": "$HOME/.ezpplauncher" }, + { "path": "$HOME/.ezpplauncher/*" }, + { "path": "$HOME/.ezpplauncher/**/*" } + ] + }, + { + "identifier": "fs:allow-write-file", + "allow": [ + { "path": "$HOME/.ezpplauncher" }, + { "path": "$HOME/.ezpplauncher/*" }, + { "path": "$HOME/.ezpplauncher/**/*" } ] }, { "identifier": "fs:allow-read-text-file", "allow": [ - { - "path": "$HOME/**/*" - } + { "path": "$HOME/.ezpplauncher" }, + { "path": "$HOME/.ezpplauncher/*" }, + { "path": "$HOME/.ezpplauncher/**/*" } ] }, { "identifier": "fs:allow-mkdir", "allow": [ - { - "path": "$HOME/**/*" - } + { "path": "$HOME/.ezpplauncher" }, + { "path": "$HOME/.ezpplauncher/*" }, + { "path": "$HOME/.ezpplauncher/**/*" } ] } ] diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index c087b6e..784a174 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -11,14 +11,12 @@ use tauri::AppHandle; use tauri::Emitter; use tokio::fs; use tokio::io::AsyncWriteExt; -use winreg::RegKey; -use winreg::enums::*; use crate::utils::{ check_folder_completeness, get_osu_config, get_osu_user_config, get_window_title_by_pid, set_osu_config_vals, set_osu_user_config_vals, }; -use std::os::windows::process::CommandExt; + #[tauri::command] pub fn get_hwid() -> String { @@ -65,8 +63,18 @@ pub fn valid_osu_folder(folder: String) -> bool { return false; } +#[cfg(not(windows))] #[tauri::command] pub fn find_osu_installation() -> Option { + None +} + +#[cfg(windows)] +#[tauri::command] +pub fn find_osu_installation() -> Option { + use winreg::RegKey; + use winreg::enums::*; + let hklm_registry_paths = ["SOFTWARE\\Classes\\osu\\DefaultIcon"]; let hkcr_registry_paths = [ @@ -142,7 +150,7 @@ pub fn find_osu_installation() -> Option { } } } - return None; + None } #[tauri::command] diff --git a/src-tauri/src/utils.rs b/src-tauri/src/utils.rs index cd5b463..8053eed 100644 --- a/src-tauri/src/utils.rs +++ b/src-tauri/src/utils.rs @@ -1,6 +1,4 @@ -use std::ffi::OsString; use std::fs; -use std::os::windows::ffi::OsStringExt; use std::path::Path; use sysinfo::Pid; @@ -178,12 +176,20 @@ pub fn get_osu_config>( return Some(config_map); } +#[cfg(not(windows))] +pub fn get_window_title_by_pid(_pid: Pid) -> String { + "".to_string() +} + +#[cfg(windows)] pub fn get_window_title_by_pid(pid: Pid) -> String { use std::sync::{Arc, Mutex}; use winapi::shared::windef::HWND; use winapi::um::winuser::{ EnumWindows, GetWindowTextW, GetWindowThreadProcessId, IsWindowVisible, }; + use std::ffi::OsString; + use std::os::windows::ffi::OsStringExt; extern "system" fn enum_windows_proc( hwnd: HWND,