Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions apps/marketing/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,22 @@ const mobileEndorsementRows = [

type Platform = { os: "mac" | "win" | "linux"; label: string; arch?: string };

function detectPlatform(): Platform | null {
async function detectPlatform(): Promise<Platform | null> {
const ua = navigator.userAgent;
if (/Win/i.test(ua)) return { os: "win", label: "Download for Windows" };
if (/Mac/i.test(ua)) {
return { os: "mac", label: "Download for macOS", arch: "arm64" };
let arch = "arm64";
try {
const uad = (navigator as { userAgentData?: { getHighEntropyValues: (hints: string[]) => Promise<{ architecture?: string }> } }).userAgentData;
if (uad?.getHighEntropyValues) {
const values = await uad.getHighEntropyValues(["architecture"]);
if (values.architecture === "x86") arch = "x64";
}
} catch {
// UA-based fallback is unreliable — all macOS UAs report "Intel Mac OS X",
// even on Apple Silicon. Default to arm64 (majority of modern Macs).
}
return { os: "mac", label: "Download for macOS", arch };
}
if (/Linux/i.test(ua)) return { os: "linux", label: "Download for Linux" };
return null;
Expand Down Expand Up @@ -415,7 +426,7 @@ const mobileEndorsementRows = [
const ctaLabel = document.getElementById("cta-download-label");
const kbd = document.getElementById("pr-button-kbd");

const platform = detectPlatform();
const platform = await detectPlatform();
if (!platform) return;
document.documentElement.dataset.platform = platform.os;
if (label) label.textContent = platform.label;
Expand Down
Loading