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:
Elijah Kuntz 2026-11-02 15:14:40 -07:00
parent a3c05e9062
commit 7d0803481b
39 changed files with 1191 additions and 230 deletions

View file

@ -7,6 +7,16 @@ import type { UnlistenFn } from '@tauri-apps/api/event';
export const isNative = typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window;
/** The host OS, known synchronously from the web view (WebView2, WKWebView, WebKitGTK). */
export const hostOS: 'windows' | 'macos' | 'linux' =
typeof navigator !== 'undefined' && /Macintosh|Mac OS X/.test(navigator.userAgent) ? 'macos' : typeof navigator !== 'undefined' && /Linux|X11/.test(navigator.userAgent) ? 'linux' : 'windows';
export const isMac = hostOS === 'macos';
/** A shortcut with the platform's command key: "⌘K" on macOS, "Ctrl + K" elsewhere. */
export const shortcut = (key: string) => (isMac ? `⌘${key}` : `Ctrl + ${key}`);
/** How the window enters full screen from the keyboard. */
export const fullscreenShortcut = isMac ? '⌃⌘F' : 'F11';
export async function invoke<T>(cmd: string, args?: Record<string, unknown>): Promise<T> {
if (!isNative) throw new Error(`${cmd} is only available in the desktop app.`);
const { invoke } = await import('@tauri-apps/api/core');
@ -47,6 +57,7 @@ export interface AppInfo {
dataDir: string;
defaultDownloadDir: string;
platform: string;
osVersion: string;
deviceName: string;
/** Graphics adapters by name (empty where not reported). */
gpus: string[];
@ -57,7 +68,7 @@ export async function appInfo(): Promise<AppInfo> {
if (info) return info;
info = isNative
? await invoke<AppInfo>('app_info')
: { version: '0.1.0-dev', dataDir: '', defaultDownloadDir: '', platform: 'browser', deviceName: 'Browser preview', gpus: [] };
: { version: '0.1.0-dev', dataDir: '', defaultDownloadDir: '', platform: 'browser', osVersion: '', deviceName: 'Browser preview', gpus: [] };
return info;
}
@ -107,6 +118,10 @@ export const win = {
await w.setFocus();
}
},
/** The OS's own window buttons (the macOS traffic lights); elsewhere the page draws them. */
async setButtonsVisible(visible: boolean) {
if (isNative && isMac) await invoke('window_buttons', { visible }).catch(() => {});
},
async onResized(cb: () => void): Promise<UnlistenFn> {
if (!isNative) {
window.addEventListener('resize', cb);