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

@ -1,5 +1,5 @@
import { arr, bool, num, str } from './parse';
import { clientIdentifier, PlexError, plexRequest, PRODUCT } from './client';
import { clientIdentifier, DEVICE, PLATFORM, PlexError, plexRequest, PRODUCT } from './client';
import type { HomeUser, PlexUser, ServerConnection, ServerResource } from './types';
const TV = 'https://plex.tv/api/v2';
@ -26,8 +26,8 @@ export function authUrl(pin: Pin): string {
clientID: clientIdentifier(),
code: pin.code,
'context[device][product]': PRODUCT,
'context[device][platform]': 'Windows',
'context[device][device]': 'Windows',
'context[device][platform]': PLATFORM,
'context[device][device]': DEVICE,
});
return `https://app.plex.tv/auth#?${params.toString()}`;
}

View file

@ -1,7 +1,9 @@
import { httpFetch } from '../platform/native';
import { hostOS, httpFetch } from '../platform/native';
export const PRODUCT = 'Kaleido';
export const PLATFORM = 'Windows';
/** How Plex lists this player (Plex's own names for each OS and device). */
export const PLATFORM = hostOS === 'macos' ? 'macOS' : hostOS === 'linux' ? 'Linux' : 'Windows';
export const DEVICE = hostOS === 'macos' ? 'Mac' : hostOS === 'linux' ? 'Linux' : 'Windows';
export class PlexError extends Error {
constructor(
@ -14,7 +16,8 @@ export class PlexError extends Error {
let clientId = '';
let version = '0.1.0';
let deviceName = 'Windows PC';
let deviceName = hostOS === 'macos' ? 'Mac' : 'Windows PC';
let platformVersion = hostOS === 'windows' ? '11' : '';
/** A stable, random identifier for this installation (not secret). */
export function clientIdentifier(): string {
@ -27,9 +30,24 @@ export function clientIdentifier(): string {
return clientId;
}
export function configureClient(opts: { version?: string; deviceName?: string }) {
export function configureClient(opts: { version?: string; deviceName?: string; platformVersion?: string }) {
if (opts.version) version = opts.version;
if (opts.deviceName) deviceName = opts.deviceName;
if (opts.platformVersion) platformVersion = opts.platformVersion;
}
/**
* HTTP header values must be ASCII; Mac names usually aren't ("Elijah’s MacBook").
* Typographic punctuation becomes its plain form and accents are dropped.
*/
export function headerSafe(value: string): string {
return value
.replace(/[‘’]/g, "'")
.replace(/[“”]/g, '"')
.replace(/[–—]/g, '-')
.normalize('NFKD')
.replace(/[^\x20-\x7e]/g, '')
.trim();
}
export function plexHeaders(token?: string | null): Record<string, string> {
@ -39,9 +57,9 @@ export function plexHeaders(token?: string | null): Record<string, string> {
'X-Plex-Version': version,
'X-Plex-Client-Identifier': clientIdentifier(),
'X-Plex-Platform': PLATFORM,
'X-Plex-Platform-Version': '11',
'X-Plex-Device': 'Windows',
'X-Plex-Device-Name': `Kaleido (${deviceName})`,
'X-Plex-Platform-Version': platformVersion,
'X-Plex-Device': DEVICE,
'X-Plex-Device-Name': headerSafe(`Kaleido (${deviceName})`),
'X-Plex-Model': 'Desktop',
'X-Plex-Provides': 'player',
'X-Plex-Language': navigator.language || 'en',
@ -57,7 +75,7 @@ export function plexQuery(token?: string | null): Record<string, string> {
'X-Plex-Version': version,
'X-Plex-Client-Identifier': clientIdentifier(),
'X-Plex-Platform': PLATFORM,
'X-Plex-Device': 'Windows',
'X-Plex-Device': DEVICE,
'X-Plex-Device-Name': `Kaleido (${deviceName})`,
};
if (token) q['X-Plex-Token'] = token;

View file

@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';
import { parseItem, parseScores } from './parse';
import { isLocalAddress } from './account';
import { partAt } from './playback';
import { headerSafe } from './client';
import { duration, formatBadges, isWatched, remaining, washGradient } from '../app/format';
import { buildFeatures } from '../screens/discover';
import type { Hub } from './types';
@ -112,3 +113,10 @@ describe('features', () => {
expect(washGradient(movie().ultraBlur)).toContain('rgba(48, 97, 143');
});
});
describe('headerSafe', () => {
it('turns Mac computer names into ASCII header values', () => {
expect(headerSafe('Elijah’s MacBook Pro')).toBe("Elijah's MacBook Pro");
expect(headerSafe('Zoë’s iMac — Studio')).toBe("Zoe's iMac - Studio");
});
});