[package] name = "thing" version = "26.10.2" description = "A Tauri App" authors = ["you"] edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] # The `_lib` suffix may seem redundant but it is necessary # to make the lib name unique and wouldn't conflict with the bin name. # This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 name = "thing_lib" crate-type = ["staticlib", "cdylib", "rlib"] [build-dependencies] tauri-build = { version = "2", features = [] } [dependencies] tauri = { version = "2", features = ["tray-icon"] } tauri-plugin-opener = "2" tauri-plugin-dialog = "2" tauri-plugin-snap-layout = "1" tauri-plugin-global-shortcut = "2" tauri-plugin-notification = "2" # 翻译引擎抽象:TranslateEngine 需要 Box 动态分派(多源在运行期决定), # 原生 async fn in trait 在 dyn 场景下不可用 async-trait = "0.1" serde = { version = "1", features = ["derive"] } serde_json = "1" regex = "1" # 编码统计探测(Firefox 的探测器):判断「非 UTF-8 文件到底是 Shift_JIS 还是 # GB18030」这类问题。GB18030 几乎能解码任意字节序列,「试解是否成功」不可靠, # 会把日文 Shift_JIS 误判成中文 GB18030。 chardetng = "1.0" serde_yaml = "0.9" specta = { version = "=2.0.0-rc.25", features = ["derive", "function", "serde_json"] } specta-typescript = "0.0.12" tauri-specta = { version = "=2.0.0-rc.25", features = ["typescript"] } chrono = "0.4" # blocking:音乐播放引擎在**独立 std 线程**上解码(symphonia 的 MediaSource 是同步 # Read+Seek),需要同步 HTTP 客户端去按 Range 拉 NAS 音频流。放在 std 线程上用 # blocking 是安全的(在 tokio 运行时线程里用才会 panic)。 # gzip:智能家居模块走反代(Cloudflare Tunnel)链路时,`/api/states` 是几百 KB JSON。 # **默认不开压缩就不会发 Accept-Encoding**,CF 会回未压缩响应,远端首屏流量翻 5–10 倍 # (见 doc/SMART_HOME_MODULE_PLAN.md §3.7-b)。 reqwest = { version = "0.12", features = ["json", "stream", "multipart", "blocking", "gzip"] } # `sink`:WebSocket 客户端要把流拆成读/写两半(`SinkExt` / `StreamExt`)。 # default 特性里**不含** `sink`(已核对 0.3.32 的 Cargo.toml),目前只是因为 # tokio-tungstenite 自己开了它才传递可用 —— 依赖传递特性不该被当成前提,故显式打开。 futures-util = { version = "0.3", features = ["sink"] } tokio = { version = "1", features = ["io-util", "time", "rt-multi-thread", "macros", "sync", "fs", "net"] } axum = { version = "0.7", features = ["ws"] } url = "2" zip = "2" dirs = "5" # ===== 终端模块 ===== # 字符编码转换:老服务器(CentOS 6/7 默认 LANG=zh_CN.GBK)输出 GBK 字节, # 直接按 UTF-8 解码会得到乱码。encoding_rs 是 Firefox 的实现抽出,比 iconv 绑定 # 干净(纯 Rust、无 C 依赖),且本项目依赖树里已存在(reqwest → encoding_rs 0.8.35), # 提升为直接依赖不会新增编译单元。 encoding_rs = "0.8" # SSH 客户端:纯 Rust + 原生 async,与项目 tokio 运行时契合。 # 选 russh 而非 ssh2(libssh2 绑定)的理由见 terminal/ssh/mod.rs 模块注释。 # 注意:实施时核实该 crate 已到 0.63.x(规划文档中的 0.5 已过时)。 russh = "0.63" # SSH 密钥的生成/解析/加密统一走 `russh::keys::ssh_key` re-export。 # # **不要**声明与 russh 钉住版本不同的 `ssh-key`——若声明 0.6 会引入第二个不兼容 # 版本,两边的 PrivateKey/PublicKey 无法互转(这是 P0 踩过的坑)。 # # 唯一的例外是下面这一行:必须声明**完全相同**的版本号 `=0.7.0-rc.11`。 # 原因是 russh 的 `[features]` **没有向 ssh-key 转发 `ppk`** # (只有 dsa / rsa / serde 三个转发项),而 P2 要支持 PuTTY `.ppk` 导入, # 只能由我们自己打开 `ssh-key/ppk`。 # # Cargo 会把「russh 的 `=0.7.0-rc.11`」与「这里的 `=0.7.0-rc.11`」**合并为同一个 # 依赖节点**(版本要求完全相同,不存在二选一),因此不会产生分叉。 # 已用 `cargo tree -i ssh-key` 复核:图中只有 `ssh-key v0.7.0-rc.11` 一个节点。 # # 注意:改这里之后必须重跑 `cargo tree -i ssh-key` 确认仍只有一个节点。 ssh-key = { version = "=0.7.0-rc.11", default-features = false, features = ["ppk", "encryption", "alloc"] } # 系统随机源:ssh-key 0.7 的 `getrandom` feature 默认**未启用**(russh 没开, # 我们上面的 ssh-key 声明也没开),故 `ssh_key::getrandom::SysRng` 不可见。 # 这里直接依赖 getrandom 0.4 ——它与 ssh-key 共用同一份 `rand_core 0.10`, # `UnwrapErr(SysRng)` 能直接满足 ssh-key 的 `CryptoRng`/`TryCryptoRng` 约束 # (见 terminal/keys.rs 的 sys_rng)。 getrandom = "0.4" # SFTP 客户端。**russh 本身不含 SFTP**——只是一个 SSH 传输层,SFTP 协议 # (OPEN/READ/WRITE/READDIR 等报文)由独立的 russh-sftp 实现。 # 版本配套:russh-sftp 3.0.0 的依赖是 `russh ^0.63.2`,与上面的 0.63 同源, # 共用同一份 russh 实例类型 —— 这一点关键:SFTP 通道必须从**已认证的同一个 # Session** 上开(`request_subsystem(true, "sftp")`),跨版本是做不到的。 # 另注:3.0.0 把 `russh` 列为 dev-dependency,故不会重复引入第二个 russh。 russh-sftp = "3.0" # ConPTY 之外还需要窗口/进程相关 API;Win32_System_Console 为 CreatePseudoConsole 所在 feature # 终端会话并发注册表:读多写少(每次输出批次都查表),分片锁避免各会话 I/O 互相等待 dashmap = "6" # 音频标签解析(本地曲库元数据:标题/歌手/专辑/时长/内嵌封面) lofty = "0.22" sysinfo = "0.32" rusqlite = { version = "0.32", features = ["bundled"] } base64 = "0.22" sha2 = "0.10" md-5 = "0.10" hmac = "0.12" aes = "0.8" cbc = "0.1" rsa = { version = "0.9", features = ["pem"] } rand = "0.8" # WebSocket 客户端(智能家居模块 P4 的实时推送 / 规则引擎)。 # `connect` 已随 default 启用(`cargo tree -e features -i tokio-tungstenite` 复核过: # 它由本项 + axum 的 `ws` 共同引入),这里显式写出来是为了让"要连"这件事在清单里可见。 # **TLS 默认未启用** —— 反代是 HTTPS(`wss://`,D5 已定必须支持),故补 # `rustls-tls-webpki-roots`:纯 Rust、无 C 依赖,与项目姿态一致(`native-tls` 会引入系统依赖), # 且复用依赖树里已存在的 rustls 0.23(经 russh),不新增编译单元。 # 注意:自签证书的 `wss://` 仍是缺口 —— `insecure`(危险开关)目前只覆盖 REST。 tokio-tungstenite = { version = "0.24", features = ["connect", "rustls-tls-webpki-roots"] } image = { version = "0.25", default-features = false, features = ["png", "jpeg", "webp"] } walkdir = "2" notify = { version = "6", features = [] } librqbit = "9" bytes = "1" windows-capture = "2.0.1" # 音频解码(纯 Rust)。**默认特性不含 mp3/aac/alac/isomp4**——0.6 起这几项被移出 # default,必须显式打开,否则 mp3 与 m4a 直接报「不支持的格式」。 # default 已含:flac / wav / ogg / vorbis / pcm / adpcm / mkv + 全部元数据。 # 注意:`ape` 只是**元数据**特性(symphonia-metadata/ape),没有 APE 解码器; # 也没有 opus 特性(ogg 里若是 Opus 轨道无法解码)。这两点已与用户确认接受。 symphonia = { version = "0.6", features = ["mp3", "aac", "alac", "isomp4"] } # 音频输出。Windows 走 WASAPI:cpal 的共享模式输出带 # AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | SRC_DEFAULT_QUALITY,因此**可以用源采样率 # 直接建流**,由 Windows 自己转换到设备混音格式 —— 不需要额外引入重采样库。 cpal = "0.18" # WebDAV 的 PROPFIND 响应是 XML,且命名空间前缀由服务端随意指定(D: / d: / lp1: / # 无前缀),因此只能按 local name 做宽容的事件流解析。quick-xml 是纯 Rust、无 C 依赖, # 且比 serde 反序列化更能吃下各家 NAS 不一致的字段集合(见 notes/webdav/client.rs)。 quick-xml = "0.42.0" tauri-plugin-single-instance = "2.5.1" # HDR 截图说明:windows-capture 的 Windows Graphics Capture 后端在 HDR 显示器上 # 可能输出 scRGB / rgba16F 或 HDR10(PQ) 格式的帧,与项目其余截图路径 # (GDI BitBlt,sRGB 8bit)色彩空间不一致。capture 层统一转成 sRGB 8bit # 后再交给编码器,否则 HDR 屏上截出的图会整体偏灰 / 过曝。 [target.'cfg(windows)'.dependencies] winreg = "0.52" # WebDAV 凭据加密存储(Windows 凭据管理器,DPAPI 保护) keyring = { version = "3", features = ["windows-native"] } raw-window-handle = "0.6" windows-sys = { version = "0.52", features = [ "Win32_Networking_WinInet", "Win32_Foundation", "Win32_Globalization", "Win32_Security", "Win32_System_Threading", "Win32_System_Ole", "Win32_System_Memory", "Win32_System_DataExchange", "Win32_System_SystemInformation", "Win32_UI_WindowsAndMessaging", "Win32_UI_Shell", "Win32_UI_HiDpi", "Win32_UI_Input_KeyboardAndMouse", "Win32_Graphics_Gdi", "Win32_Graphics_Dwm", "Win32_Storage_Xps", "Win32_Storage_FileSystem", "Win32_Devices_Display", # 终端模块:ConPTY(CreatePseudoConsole / ResizePseudoConsole / ClosePseudoConsole) "Win32_System_Console", # 终端模块:CreatePipe(ConPTY 的输入/输出管道) "Win32_System_Pipes", # 终端模块:ReadFile / CancelIoEx / GetOverlappedResult(ConPTY 输出读取) # 注意:0.52 起 ReadFile 定义在 Storage_FileSystem 但被 Win32_System_IO 特性门控, # 两个特性必须同时开启,否则导入会解析失败。 "Win32_System_IO", # 音乐模块「解密」:QQ音乐新版 musicex 的 ekey 不落盘,只能联网取;而 # authst 仅存在于 QQMusic.exe 运行期内存里 —— 需要进程枚举(ToolHelp: # CreateToolhelp32Snapshot / Process32FirstW)与跨进程读内存 # (Diagnostics::Debug::ReadProcessMemory + System::Memory::VirtualQueryEx)。 "Win32_System_Diagnostics_ToolHelp", "Win32_System_Diagnostics_Debug", ] } # Explorer ShellWindows COM:用于枚举已打开的资源管理器窗口并取当前路径 # (快速面板「用资源管理器打开」联动)。依赖 Win32_System_Com 特性。 windows = { version = "0.52", features = [ "Win32_Foundation", "Win32_System_Com", "Win32_System_Ole", "Win32_System_Variant", "Win32_UI_Shell", # 快速面板「保存截图后定位并进入重命名」:SHParseDisplayName / SHOpenFolderAndSelectItems # 与 ITEMIDLIST 都被 Win32_UI_Shell_Common 门控(windows 0.52 源码 cfg) "Win32_UI_Shell_Common", "Win32_UI_WindowsAndMessaging", # 翻译模块:Windows.Media.Ocr 本地识别(WinRT) # Foundation_Collections:OcrResult.Lines / OcrEngine.AvailableRecognizerLanguages 返回 IVectorView # Security_Cryptography:用 CryptographicBuffer 从内存字节构造 IBuffer(不落盘) "Foundation", "Foundation_Collections", "Globalization", "Graphics_Imaging", "Media_Ocr", # 音乐模块:系统媒体传输控件(SMTC)。Windows.Media 提供 # SystemMediaTransportControls / DisplayUpdater / MusicDisplayProperties / # TimelineProperties;Win32_System_WinRT 提供桌面应用唯一的取用入口 # ISystemMediaTransportControlsInterop::GetForWindow。 # 之所以不用前端 navigator.mediaSession 当唯一通道:WebView2 只转发标题/歌手/进度, # 专辑与封面不送达,且会话挂在浏览器进程 AUMID 上只显示「未知应用」。 "Media", "Win32_System_WinRT", # 音乐模块·手机遥控:GSMTC 全局会话管理器(Windows.Media.Control), # 枚举/监视/控制系统全部 SMTC 会话(MUSIC_REMOTE_PLAN §3.1) "Media_Control", # 手机遥控·UDP beacon:GetAdaptersAddresses 枚举各网卡 IPv4/广播地址 # (多网卡/VPN 场景下定向广播,MUSIC_REMOTE_PLAN §3.3)。 # GetAdaptersAddresses 另受 Ndis + WinSock 两个 feature 门控(windows 0.52 源码 cfg) "Win32_NetworkManagement_IpHelper", "Win32_NetworkManagement_Ndis", "Win32_Networking_WinSock", # 手机遥控·P1 系统音量:MMDevice + IAudioEndpointVolume(Endpoints 有独立 feature 门控; # IMMDevice::Activate 另需 Com_StructuredStorage) "Win32_Media_Audio", "Win32_Media_Audio_Endpoints", "Win32_System_Com_StructuredStorage", "Security_Cryptography", # 划词取词的智能路径:UIA 直读焦点元素选区(IUIAutomation / ITextProvider) "Win32_UI_Accessibility", # OCR:CryptographicBuffer / SoftwareBitmap::CreateCopyFromBuffer 的 IBuffer 属于 # Windows.Storage.Streams,缺这个 feature 会 E0599 找不到 CreateFromByteArray "Storage_Streams", # HDR 探测:DXGI 的 advanced color 查询用于判断显示器是否处于 HDR / WCG 状态, # 并读取其色域与传递函数(G2084/PQ 表示 HDR10)。截图前据此决定是否做色调映射。 # 对应 feature:Win32_Graphics_Dxgi / Win32_Graphics_Dxgi_Common。 "Win32_Graphics_Dxgi_Common", "Win32_Graphics_Gdi", ] } # 与 tauri / wry 同版本的 windows crate(**重命名**以便与上面项目自用的 0.52 并存; # 同名不同版本不能写在同一个表里)。仅用于 editor/drag_drop.rs 实现 IDropTarget: # 需要与 `WebviewWindow::hwnd()` 返回的 HWND 是同一个类型,才能直接对接。 windows62 = { package = "windows", version = "0.62", features = [ "Win32_Foundation", "Win32_Graphics_Gdi", "Win32_System_Com", # 窗口级 AppUserModelID:PROPVARIANT 在 Com\StructuredStorage 下 "Win32_System_Com_StructuredStorage", "Win32_System_Ole", "Win32_System_SystemServices", "Win32_UI_Shell", # 窗口级 AUMID:SHGetPropertyStoreForWindow / IPropertyStore(Shell\PropertiesSystem) "Win32_UI_Shell_PropertiesSystem", "Win32_UI_WindowsAndMessaging", # PKEY_AppUserModel_ID 常量声明在 Storage\EnhancedStorage 下 "Win32_Storage_EnhancedStorage", ] } # `#[implement]` 宏展开出的代码按裸名引用 `windows_core`,因此必须直接依赖同名 crate。 windows-core = "0.62" [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies] tauri-plugin-autostart = "2" # ===== 编译配置 ===== # dev profile:日常 `tauri dev` 的取舍。 # - incremental = true:增量编译,改一行代码只需重编受影响的 crate # - debug = "line-tables-only":只保留行号表,去掉完整 DWARF,交付期 # target/ 目录因此从数 GB 降到数百 MB,而 panic 回溯仍能定位到源码行。 # 注意:这里没开 opt-level。依赖 crate(尤其 tauri/wry/windows-sys) # 在 opt-level=0 下开销明显;若 dev 下界面卡顿,可只给依赖提优化。 [profile.dev] incremental = true debug = "line-tables-only" # release profile:交付构建。 # - strip = true:剥离符号信息,显著缩小产物体积 # - lto = true:全程序链接时优化,跨 crate 内联,通常带来 10~20% 性能提升, # 代价是链接时间从秒级升到分钟级。只在 release 构建付出这个代价。 # 未开 codegen-units=1:会再压榨约 5% 性能,但编译时间翻倍,不值得。 [profile.release] strip = true lto = true