Port Kaleido Desktop to macOS
macOS (Apple silicon) now plays, browses and updates like Windows: - Video: libmpv's render API draws into a CAOpenGLLayer beneath the WKWebView, with the miniplayer rectangle, HDR passthrough through extended dynamic range (PQ/BT.2020) and display-sleep prevention. - Window: native traffic lights on the top bar's centre line, hidden with the player's controls; the page's caption buttons are Windows-only. - Interface: macOS shortcut labels (⌘K, ⌘[, ⌃⌘F), Plex identifies the player as a Mac, and header values are kept ASCII (Mac computer names usually contain a curly apostrophe). - The window appears without waiting for an animation frame, which WKWebView doesn't run in a hidden window. - Credentials: release builds use the Keychain and are signed with a lasting self-signed certificate so access survives updates; debug builds keep tokens in a private file to avoid prompts on every rebuild. - Bundling: scripts/fetch-libmpv.sh makes Homebrew's libmpv and its libraries self-contained; scripts/build.sh builds the .app, .dmg and signed update archive. Releases now carry both platforms: publish-release.mjs uploads each machine's build into one release, and update-manifest.mjs writes the feed from that release's assets, refusing while a platform is missing. The updater uses a new signing key (public key in tauri.conf.json), so existing installs must be reinstalled once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a3c05e9062
commit
7d0803481b
39 changed files with 1191 additions and 230 deletions
|
|
@ -13,9 +13,14 @@ fn entry(key: &str) -> Result<keyring::Entry, String> {
|
|||
keyring::Entry::new(SERVICE, key).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Secrets (Plex tokens) live in Windows Credential Manager, never in plain files.
|
||||
/// Secrets (Plex tokens) live in the OS's credential store (Windows Credential
|
||||
/// Manager, the macOS Keychain), never in plain files; except in macOS debug
|
||||
/// builds, see `dev_secrets`.
|
||||
#[tauri::command]
|
||||
pub fn secret_get(key: String) -> Result<Option<String>, String> {
|
||||
pub fn secret_get<R: Runtime>(app: AppHandle<R>, key: String) -> Result<Option<String>, String> {
|
||||
if let Some(path) = dev_secrets(&app) {
|
||||
return Ok(read_dev_secrets(&path).get(&key).and_then(|v| v.as_str()).map(String::from));
|
||||
}
|
||||
match entry(&key)?.get_password() {
|
||||
Ok(v) => Ok(Some(v)),
|
||||
Err(keyring::Error::NoEntry) => Ok(None),
|
||||
|
|
@ -24,18 +29,66 @@ pub fn secret_get(key: String) -> Result<Option<String>, String> {
|
|||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn secret_set(key: String, value: String) -> Result<(), String> {
|
||||
entry(&key)?.set_password(&value).map_err(|e| e.to_string())
|
||||
pub fn secret_set<R: Runtime>(app: AppHandle<R>, key: String, value: String) -> Result<(), String> {
|
||||
if let Some(path) = dev_secrets(&app) {
|
||||
let mut all = read_dev_secrets(&path);
|
||||
all.insert(key, Value::String(value));
|
||||
return write_dev_secrets(&path, &all);
|
||||
}
|
||||
let entry = entry(&key)?;
|
||||
match entry.set_password(&value) {
|
||||
Ok(()) => Ok(()),
|
||||
// A Keychain item left by a differently signed build can be impossible to
|
||||
// update yet still block adding; replacing it recovers.
|
||||
Err(keyring::Error::PlatformFailure(_)) if cfg!(target_os = "macos") => {
|
||||
let _ = entry.delete_credential();
|
||||
entry.set_password(&value).map_err(|e| e.to_string())
|
||||
}
|
||||
Err(e) => Err(e.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn secret_delete(key: String) -> Result<(), String> {
|
||||
pub fn secret_delete<R: Runtime>(app: AppHandle<R>, key: String) -> Result<(), String> {
|
||||
if let Some(path) = dev_secrets(&app) {
|
||||
let mut all = read_dev_secrets(&path);
|
||||
all.remove(&key);
|
||||
return write_dev_secrets(&path, &all);
|
||||
}
|
||||
match entry(&key)?.delete_credential() {
|
||||
Ok(()) | Err(keyring::Error::NoEntry) => Ok(()),
|
||||
Err(e) => Err(e.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
/// macOS ties Keychain access to the app's code signature, and every debug
|
||||
/// build is a new unsigned binary, so the Keychain would ask for permission
|
||||
/// after each rebuild. Debug builds there keep secrets in a private file in the
|
||||
/// app data folder instead (development only, like the `.env` sign-in).
|
||||
fn dev_secrets<R: Runtime>(app: &AppHandle<R>) -> Option<std::path::PathBuf> {
|
||||
if !(cfg!(debug_assertions) && cfg!(target_os = "macos")) {
|
||||
return None;
|
||||
}
|
||||
app.path().app_data_dir().ok().map(|d| d.join("dev-secrets.json"))
|
||||
}
|
||||
|
||||
fn read_dev_secrets(path: &std::path::Path) -> serde_json::Map<String, Value> {
|
||||
std::fs::read_to_string(path).ok().and_then(|t| serde_json::from_str(&t).ok()).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn write_dev_secrets(path: &std::path::Path, all: &serde_json::Map<String, Value>) -> Result<(), String> {
|
||||
use std::io::Write;
|
||||
if let Some(dir) = path.parent() {
|
||||
std::fs::create_dir_all(dir).map_err(|e| e.to_string())?;
|
||||
}
|
||||
let mut options = std::fs::OpenOptions::new();
|
||||
options.write(true).create(true).truncate(true);
|
||||
#[cfg(unix)]
|
||||
std::os::unix::fs::OpenOptionsExt::mode(&mut options, 0o600);
|
||||
let mut file = options.open(path).map_err(|e| e.to_string())?;
|
||||
file.write_all(Value::Object(all.clone()).to_string().as_bytes()).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AppInfo {
|
||||
|
|
@ -43,6 +96,7 @@ pub struct AppInfo {
|
|||
data_dir: String,
|
||||
default_download_dir: String,
|
||||
platform: String,
|
||||
os_version: String,
|
||||
device_name: String,
|
||||
/// Graphics adapters by name (decides which upscaling tiers are offered).
|
||||
gpus: Vec<String>,
|
||||
|
|
@ -63,7 +117,8 @@ pub fn app_info<R: Runtime>(app: AppHandle<R>) -> AppInfo {
|
|||
data_dir: data,
|
||||
default_download_dir: downloads,
|
||||
platform: std::env::consts::OS.to_string(),
|
||||
device_name: std::env::var("COMPUTERNAME").unwrap_or_else(|_| "Windows PC".into()),
|
||||
os_version: crate::platform::os_version(),
|
||||
device_name: crate::platform::device_name(),
|
||||
gpus: crate::platform::gpu_names(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue