Files
chesscubing/ChessCubing.App/Services/BrowserBridge.cs

31 lines
1.3 KiB
C#

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<string?> ReadMatchJsonAsync(string storageKey, string windowNameKey)
=> jsRuntime.InvokeAsync<string?>("chesscubingStorage.getMatchState", storageKey, windowNameKey);
public ValueTask WriteMatchJsonAsync(string storageKey, string windowNameKey, string json)
=> jsRuntime.InvokeVoidAsync("chesscubingStorage.setMatchState", storageKey, windowNameKey, json);
public ValueTask ClearMatchAsync(string storageKey, string windowNameKey)
=> jsRuntime.InvokeVoidAsync("chesscubingStorage.clearMatchState", storageKey, windowNameKey);
public ValueTask<bool> PlayCubePhaseAlertAsync()
=> jsRuntime.InvokeAsync<bool>("chesscubingAudio.playCubePhaseAlert");
public ValueTask PrimeAudioAsync()
=> jsRuntime.InvokeVoidAsync("chesscubingAudio.prime");
public ValueTask ForceRefreshAsync(string path)
=> jsRuntime.InvokeVoidAsync("chesscubingBrowser.forceRefresh", path);
}