From 409d8fa9648f0ff8d9af1b2f09afb668ab2e4157 Mon Sep 17 00:00:00 2001 From: Psychotoxical <171614930+Psychotoxical@users.noreply.github.com> Date: Fri, 8 May 2026 16:18:51 +0200 Subject: [PATCH] refactor(lib_commands): drop super::* + glob re-export in ui + cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hotspot G first slice — replace the cascade-import pattern in lib_commands/ui/ and lib_commands/cache/ with explicit per-symbol imports + per-command re-exports. ui/mod.rs no longer reaches `pub(crate) use mini::*; pub(crate) use bandsintown::*;` — instead it explicitly re-exports the 8 mini-player Tauri commands + the 3 internal helpers consumed by lib.rs + sync/tray.rs (PAUSE_RENDERING_JS, RESUME_RENDERING_JS, persist_mini_pos_throttled), and fetch_bandsintown_events. cache/mod.rs likewise lists each Tauri command from offline / hot / downloads explicitly. The only cross-crate "internal" re-export is `enqueue_analysis_seed` which analysis_runtime depends on. Inside the .rs files: every `use super::*` is replaced with the specific imports actually needed (super::offline::..., crate::audio, crate::analysis_runtime::..., tauri::Manager, etc.). Behaviour-preserving — no Tauri command name changed, no runtime behaviour shift. Just removes the leak-everything-everywhere import graph that cucadmuh's policy doc forbids. --- src-tauri/src/lib_commands/cache/downloads.rs | 4 +++- src-tauri/src/lib_commands/cache/hot.rs | 7 ++++++- src-tauri/src/lib_commands/cache/mod.rs | 19 ++++++++++++++----- src-tauri/src/lib_commands/cache/offline.rs | 8 +++++++- src-tauri/src/lib_commands/ui/mini.rs | 6 +++++- src-tauri/src/lib_commands/ui/mod.rs | 10 ++++++---- 6 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src-tauri/src/lib_commands/cache/downloads.rs b/src-tauri/src/lib_commands/cache/downloads.rs index 8ee23d28..06594a45 100644 --- a/src-tauri/src/lib_commands/cache/downloads.rs +++ b/src-tauri/src/lib_commands/cache/downloads.rs @@ -1,4 +1,6 @@ -use super::*; +use tauri::{Emitter, Manager}; + +use crate::subsonic_wire_user_agent; pub(crate) fn resolve_hot_cache_root( custom_dir: Option, diff --git a/src-tauri/src/lib_commands/cache/hot.rs b/src-tauri/src/lib_commands/cache/hot.rs index 476c5800..4b8886aa 100644 --- a/src-tauri/src/lib_commands/cache/hot.rs +++ b/src-tauri/src/lib_commands/cache/hot.rs @@ -1,4 +1,9 @@ -use super::*; +use crate::audio; +use crate::subsonic_wire_user_agent; + +use super::super::file_transfer::stream_to_file; +use super::downloads::{resolve_hot_cache_root, HotCacheDownloadResult}; +use super::offline::{enqueue_analysis_seed, enqueue_analysis_seed_from_file}; #[tauri::command] pub(crate) async fn download_track_hot_cache( diff --git a/src-tauri/src/lib_commands/cache/mod.rs b/src-tauri/src/lib_commands/cache/mod.rs index 91fa4d2b..9902244f 100644 --- a/src-tauri/src/lib_commands/cache/mod.rs +++ b/src-tauri/src/lib_commands/cache/mod.rs @@ -1,10 +1,19 @@ -use super::*; - mod fs_utils; mod offline; mod downloads; mod hot; -pub(crate) use offline::*; -pub(crate) use downloads::*; -pub(crate) use hot::*; +// Tauri commands re-exported for the lib.rs invoke_handler: +pub(crate) use offline::{ + delete_offline_track, download_track_offline, get_offline_cache_size, +}; +pub(crate) use hot::{ + delete_hot_cache_track, download_track_hot_cache, get_hot_cache_size, + promote_stream_cache_to_hot_cache, purge_hot_cache, +}; +pub(crate) use downloads::{ + check_arch_linux, download_update, download_zip, fetch_netease_lyrics, get_embedded_lyrics, + open_folder, +}; +// Internal helper consumed by analysis_runtime (used as analysis_runtime depends on it): +pub(crate) use offline::enqueue_analysis_seed; diff --git a/src-tauri/src/lib_commands/cache/offline.rs b/src-tauri/src/lib_commands/cache/offline.rs index 2e823212..1d84762d 100644 --- a/src-tauri/src/lib_commands/cache/offline.rs +++ b/src-tauri/src/lib_commands/cache/offline.rs @@ -1,4 +1,10 @@ -use super::*; +use tauri::Manager; + +use crate::analysis_cache; +use crate::analysis_runtime::{analysis_backfill_is_current_track, submit_analysis_cpu_seed}; +use crate::DownloadSemaphore; + +use super::super::file_transfer::{finalize_streamed_download, subsonic_http_client}; // ─── Offline Track Cache ────────────────────────────────────────────────────── diff --git a/src-tauri/src/lib_commands/ui/mini.rs b/src-tauri/src/lib_commands/ui/mini.rs index 78efec50..8877451a 100644 --- a/src-tauri/src/lib_commands/ui/mini.rs +++ b/src-tauri/src/lib_commands/ui/mini.rs @@ -1,4 +1,8 @@ -use super::*; +use std::sync::{Mutex, OnceLock}; + +use tauri::Manager; + +use crate::lib_commands::sync::is_tiling_wm; // ── Mini Player window ────────────────────────────────────────────────────── // Secondary always-on-top window with minimal playback controls. Uses the diff --git a/src-tauri/src/lib_commands/ui/mod.rs b/src-tauri/src/lib_commands/ui/mod.rs index 247e1aaa..f919926f 100644 --- a/src-tauri/src/lib_commands/ui/mod.rs +++ b/src-tauri/src/lib_commands/ui/mod.rs @@ -1,7 +1,9 @@ -use super::*; - mod mini; mod bandsintown; -pub(crate) use mini::*; -pub(crate) use bandsintown::*; +pub(crate) use mini::{ + close_mini_player, open_mini_player, pause_rendering, persist_mini_pos_throttled, + preload_mini_player, resize_mini_player, resume_rendering, set_mini_player_always_on_top, + show_main_window, PAUSE_RENDERING_JS, RESUME_RENDERING_JS, +}; +pub(crate) use bandsintown::fetch_bandsintown_events;