feat: create platform utility using Tauri OS plugin

This commit is contained in:
Afonso Jorge Ramos committed 2026-04-03 13:58:08 +02:00
1 parent 5d115277a5
commit e089417ab5
1 file changed
+23
+23
View File
@@ -0,0 +1,23 @@
/**
* Platform detection via @tauri-apps/plugin-os.
*
* `platform()` is synchronous (compile-time constant baked into the binary).
* Falls back to 'linux' in non-Tauri environments (vitest, SSR, svelte-check).
*
* NOTE: The `macos` CSS class on `<html>` is set separately by an inline
* script in app.html for FOUC prevention — that is intentionally kept.
*/
import { platform as tauriPlatform } from '@tauri-apps/plugin-os';
type Platform = 'macos' | 'linux';
let detectedPlatform: Platform;
try {
detectedPlatform = tauriPlatform() as Platform;
} catch {
// Fallback for non-Tauri environments (vitest, SSR, svelte-check)
detectedPlatform = 'linux';
}
export const platform: Platform = detectedPlatform;