Expand description
Authoritative platform detection for the renderer.
Frontend code used to lean on navigator.userAgent, which lies on
Linux WebViews that masquerade as Mac/Safari for compatibility.
Rust knows the host OS for certain via std::env::consts::OS, so
this module exposes it as a Tauri command and the renderer caches
the result through its usePlatform() hook.
Structs§
- Platform
Capabilities - Behavioural capability flags the renderer branches on, so each platform-gated feature is decided once here rather than re-derived from the raw platform string in every component.
Functions§
- capabilities_
for 🔒 - Derive the capability flags for a given target-OS string and whether
the session is Wayland. Kept pure and parameterised so every branch
is unit-testable on a single host; the
#[tauri::command]wrapper feeds it the real target and session type. - get_
arch - Return the host CPU architecture as the value of
std::env::consts::ARCH("aarch64","x86_64", …). Compiled into the binary, so it reflects the build target the user is running — exactly the build the Download button should offer them. The browser can’t see this reliably (WKWebView masks Apple Silicon as Intel), so the renderer asks Rust and normalises the answer throughnormaliseArchinlib/platform.ts. - get_
locale - Return the OS’s preferred locale as a BCP-47 tag (e.g.
"en-GB","nb-NO"). The renderer formats the pause-picker date withIntlusing this. The WebView’s own locale is unreliable — a non-localised app falls back to en-US even when the OS region differs — so it’s read natively. - get_
platform - Return the host platform string as known to Rust:
"macos","linux","windows", etc. — the value ofstd::env::consts::OS. The renderer normalises this throughnormalisePlatforminlib/platform.ts. - get_
platform_ capabilities - Return the host’s platform capability flags, derived from the
compile-time target OS and the runtime session type. The renderer
caches the result through its
usePlatformCapabilities()hook. - is_
wayland_ 🔒session - Whether the current session is Wayland. Thin shim that reads the host
OS and session env vars and defers to
wayland_session_from_env. - locale_
or_ 🔒default - Normalise an optional OS locale into a BCP-47 tag the renderer can hand
to
Intl. Falls back to"en-US"when the OS reports nothing usable. Pure so the fallback is unit-testable without the platform locale source. - wayland_
session_ 🔒from_ env - Whether the given OS + session env signals a Wayland session. Off
Linux the Wayland env vars are irrelevant to video detection, so this
is always false there. On Linux it mirrors the probe in
video.rs/overlay.rs:XDG_SESSION_TYPE=waylandor aWAYLAND_DISPLAYset. Kept pure (OS + env passed in) so every branch — including the off-Linux short-circuit — is unit-testable on the single Linux coverage runner.