# WebPlatformService

- File ID: file:qt46oq:webplatformservice-cs
- Path: NexusReader.Web.Client/Services/WebPlatformService.cs
- Role: service
- Layer: infrastructure

## Purpose

Concrete Web platform implementation of IPlatformService for the Blazor Web client: exposes device context and a vibration API via JS interop, returning FluentResults for error propagation.

## Key Details

Provides browser-specific platform features for the Blazor client via IJSRuntime with simple try/catch error mapping to FluentResults; default device type is Desktop and vibrations call navigator.vibrate.

## Symbols

- WebPlatformService: Concrete Web platform implementation of IPlatformService for the Blazor Web client: exposes device context and a vibration API via JS interop, returning FluentResults for error propagation.
- VibrateSuccessAsync(): Convenience method to trigger a short success vibration (100ms) by delegating to VibrateAsync.
- VibrateErrorAsync(): Convenience method to trigger a longer error vibration (300ms) by delegating to VibrateAsync.
- VibrateAsync(): Attempts to vibrate the user's device for the specified duration via JS interop, returning Ok on success or Fail with the exception message on error.
- GetDeviceContext(): Provides a DeviceContext describing the running platform (hardcoded for browser/web) wrapped in a FluentResults Result.

## Dependencies

- No resolved dependencies.

## Calls

- No resolved calls.

## Unresolved References

- dependency-target: NexusReader.Application.Abstractions.Services (IPlatformService)
- dependency-target: Microsoft.JSInterop (IJSRuntime) - framework
- dependency-target: FluentResults (Result) - library
- dependency-target: DeviceContext, DeviceType, DisplayOrientation (types referenced; source not in this file)
- call-target: self
- call-target: self
- interaction-target: _jsRuntime.InvokeVoidAsync("navigator.vibrate", milliseconds) -- external/framework call to IJSRuntime (browser)

## Coverage

- Symbols: 5
- Executable symbols: 4
- Executable symbols with control flow: 4
- Grounded edges: 5
- Unresolved references: 7
- Control-flow fragments: 4
- Unresolved jumps: 0
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 3

## Control Flow Fragments

- VibrateSuccessAsync: 5 nodes, 4 edges, 1 jumps, 0 unsupported constructs
- VibrateErrorAsync: 5 nodes, 4 edges, 1 jumps, 0 unsupported constructs
- VibrateAsync: 10 nodes, 9 edges, 0 jumps, 0 unsupported constructs
- GetDeviceContext: 5 nodes, 4 edges, 0 jumps, 0 unsupported constructs

## Diagrams

### WebPlatformService Neighborhood

```mermaid
flowchart LR
    class_fhmi44_webplatformservice("WebPlatformService")
    file_qt46oq_webplatformservice_cs("WebPlatformService")
    method_1lfokb3_vibrateasync[["VibrateAsync()"]]
    method_eown21_vibrateerrorasync[["VibrateErrorAsync()"]]
    method_ev8hjj_vibratesuccessasync[["VibrateSuccessAsync()"]]
    method_fmgrt8_getdevicecontext[["GetDeviceContext()"]]
```

### WebPlatformService Execution Overview

```mermaid
flowchart TD
    class_fhmi44_webplatformservice("WebPlatformService")
    method_1lfokb3_vibrateasync[["VibrateAsync()"]]
    method_eown21_vibrateerrorasync[["VibrateErrorAsync()"]]
    method_ev8hjj_vibratesuccessasync[["VibrateSuccessAsync()"]]
    method_fmgrt8_getdevicecontext[["GetDeviceContext()"]]
    unresolved_unresolved_8hn5ke_interaction_target{"Unresolved: _jsRuntime.InvokeVoidAsync(\\"navigator.vibrate\\", milliseconds) -- external/framework call to IJSRuntime (browser)"}
    unresolved_unresolved_9rmie_call_target{"Unresolved: VibrateAsync"}
    unresolved_unresolved_sd6wy6_call_target{"Unresolved: VibrateAsync"}
    class_fhmi44_webplatformservice -->|contains| method_1lfokb3_vibrateasync
    class_fhmi44_webplatformservice -->|contains| method_eown21_vibrateerrorasync
    class_fhmi44_webplatformservice -->|contains| method_ev8hjj_vibratesuccessasync
    class_fhmi44_webplatformservice -->|contains| method_fmgrt8_getdevicecontext
    class_fhmi44_webplatformservice -->|unresolved interaction| unresolved_unresolved_8hn5ke_interaction_target
    method_eown21_vibrateerrorasync -->|unresolved call| unresolved_unresolved_sd6wy6_call_target
    method_ev8hjj_vibratesuccessasync -->|unresolved call| unresolved_unresolved_9rmie_call_target
```

### VibrateAsync() Control Flow

```mermaid
flowchart TD
    method_1lfokb3_vibrateasync__action_21_try_catch_21__linear("Handles JS invocation errors")
    method_1lfokb3_vibrateasync__action_21_vibrateasync_try_21_0__try("Begins protected execution")
    method_1lfokb3_vibrateasync__action_23_vibrateasync_await_23_1__await[["Waits for async work"]]
    method_1lfokb3_vibrateasync__action_26_vibrateasync_catch_26_3__catch("catch Exception ex")
    method_1lfokb3_vibrateasync__entry(["VibrateAsync entry"])
    method_1lfokb3_vibrateasync__action_23_external_call_23__linear("Invokes browser vibration via JS interop")
    method_1lfokb3_vibrateasync__action_24_return_24__return(["Success path"])
    method_1lfokb3_vibrateasync__action_24_vibrateasync_return_24_2__return(["Returns result"])
    method_1lfokb3_vibrateasync__action_28_return_28__return(["Failure path"])
    method_1lfokb3_vibrateasync__action_28_vibrateasync_return_28_4__return(["Returns result"])
    method_1lfokb3_vibrateasync__action_21_try_catch_21__linear -->|next| method_1lfokb3_vibrateasync__action_21_vibrateasync_try_21_0__try
    method_1lfokb3_vibrateasync__action_21_vibrateasync_try_21_0__try -->|next| method_1lfokb3_vibrateasync__action_23_vibrateasync_await_23_1__await
    method_1lfokb3_vibrateasync__action_23_external_call_23__linear -->|return| method_1lfokb3_vibrateasync__action_24_return_24__return
    method_1lfokb3_vibrateasync__action_23_vibrateasync_await_23_1__await -->|next| method_1lfokb3_vibrateasync__action_23_external_call_23__linear
    method_1lfokb3_vibrateasync__action_24_return_24__return -->|return| method_1lfokb3_vibrateasync__action_24_vibrateasync_return_24_2__return
    method_1lfokb3_vibrateasync__action_24_vibrateasync_return_24_2__return -->|exception| method_1lfokb3_vibrateasync__action_26_vibrateasync_catch_26_3__catch
    method_1lfokb3_vibrateasync__action_26_vibrateasync_catch_26_3__catch -->|return| method_1lfokb3_vibrateasync__action_28_vibrateasync_return_28_4__return
    method_1lfokb3_vibrateasync__action_28_vibrateasync_return_28_4__return -->|return| method_1lfokb3_vibrateasync__action_28_return_28__return
    method_1lfokb3_vibrateasync__entry -->|next| method_1lfokb3_vibrateasync__action_21_try_catch_21__linear
```

## Diagram Validation

- Status: pass
