using Microsoft.JSInterop; namespace ChessCubing.App.Services; public sealed class BrowserBridge(IJSRuntime jsRuntime) { public ValueTask StartViewportAsync() => jsRuntime.InvokeVoidAsync("chesscubingViewport.start"); public ValueTask SetBodyStateAsync(string? page, string? bodyClass) => jsRuntime.InvokeVoidAsync("chesscubingPage.setBodyState", page, bodyClass ?? string.Empty); public ValueTask ReadMatchJsonAsync() => jsRuntime.InvokeAsync("chesscubingStorage.getMatchState", MatchStore.StorageKey, MatchStore.WindowNameKey); public ValueTask WriteMatchJsonAsync(string json) => jsRuntime.InvokeVoidAsync("chesscubingStorage.setMatchState", MatchStore.StorageKey, MatchStore.WindowNameKey, json); public ValueTask ClearMatchAsync() => jsRuntime.InvokeVoidAsync("chesscubingStorage.clearMatchState", MatchStore.StorageKey); public ValueTask PlayCubePhaseAlertAsync() => jsRuntime.InvokeAsync("chesscubingAudio.playCubePhaseAlert"); public ValueTask PrimeAudioAsync() => jsRuntime.InvokeVoidAsync("chesscubingAudio.prime"); public ValueTask ForceRefreshAsync(string path) => jsRuntime.InvokeVoidAsync("chesscubingBrowser.forceRefresh", path); }