browser-web-apis
npmAngular services for structured, secure, and reactive access to Browser Web APIs.
import { provideBrowserWebApis, provideCamera, provideGeolocation } from '@angular-helpers/browser-web-apis';
bootstrapApplication(AppComponent, {
providers: [
provideBrowserWebApis({
services: [provideCamera(), provideGeolocation()],
}),
],
});π· Media & Device
CameraService
Manages camera access via the MediaDevices API. Handles permission checks, stream lifecycle, and photo capture with typed constraints.
GeolocationService
Wraps the Geolocation API with typed Promises and Observables. Supports one-time position queries and continuous position watching with automatic cleanup.
MediaDevicesService
Enumerates and manages media input/output devices (cameras, microphones, speakers). Provides reactive device change detection.
MediaRecorderService
Wraps the MediaRecorder API for recording audio and video from a MediaStream. Provides start, pause, resume, and stop controls with Observable state and data streams.
VibrationService
Triggers haptic feedback patterns via the Vibration API. Includes built-in presets for common interactions (success, error, notification, double-tap).
SpeechSynthesisService
Text-to-speech via the Web Speech Synthesis API. Supports voice selection, language, pitch, rate, and volume. Exposes speaking state as an Observable.
IdleDetectorService
Detects user idle state and screen lock status using the Idle Detection API. Useful for auto-logout, presence indicators, or pausing resource-intensive tasks.
EyeDropperService
Provides access to the EyeDropper API for picking colors from anywhere on the screen. Opens a system color picker that returns the selected color in sRGB hex format.
BarcodeDetectorService
Wraps the Barcode Detection API (Shape Detection API) for scanning barcodes and QR codes from images, video frames, or canvas elements.
WebAudioService
Manages Web Audio API contexts, nodes, and audio processing. Supports oscillators, gain control, analysers for visualization, audio decoding, and playback.
GamepadService
Provides access to the Gamepad API for reading game controller input. Supports connection events, polling for button/axis state, and listing connected gamepads.
WebBluetoothService
Provides access to the Web Bluetooth API for connecting to Bluetooth Low Energy (BLE) devices. Supports device discovery, GATT service/characteristic read/write, and notifications.
WebUsbService
Provides access to the WebUSB API for communicating with USB devices from the browser. Supports device discovery, configuration, interface claiming, and data transfer.
WebNfcService
Provides access to the Web NFC API for reading and writing NFC tags. Supports NDEF message scanning and writing.
π Observer APIs
IntersectionObserverService
Wraps the IntersectionObserver API with an Observable-based interface. Detects when elements enter or leave the viewport with configurable thresholds and root margins.
ResizeObserverService
Wraps the ResizeObserver API. Emits element size information whenever the observed element changes dimensions.
MutationObserverService
Wraps the MutationObserver API with an Observable-based interface. Detects DOM mutations such as child additions, attribute changes, and text content modifications.
PerformanceObserverService
Wraps the PerformanceObserver API for monitoring performance entries such as LCP, FID, CLS, navigation timing, and resource loading metrics.
π₯ System APIs
NotificationService
Manages browser push notifications β requesting permissions and displaying notifications with typed options.
WebShareService
Wraps the Web Share API to trigger the native device share sheet. Supports sharing URLs, text, and files.
PageVisibilityService
Tracks document visibility state using the Page Visibility API. Useful for pausing background tasks when the tab is hidden.
ScreenWakeLockService
Prevents the device screen from dimming or locking via the Screen Wake Lock API. Automatically re-acquires the lock when the tab becomes visible again.
ScreenOrientationService
Reads and watches the screen orientation type and angle. Supports programmatic orientation locking for mobile applications.
FullscreenService
Manages fullscreen mode for any DOM element. Supports entering, exiting, and toggling fullscreen with webkit prefix fallback.
PaymentRequestService
Wraps the Payment Request API for initiating native payment flows. Supports payment method validation, payment sheet display, and result handling.
π Network APIs
WebSocketService
Manages WebSocket connections with automatic reconnection, heartbeat support, and typed message streams via Observables.
BroadcastChannelService
Provides Observable-based inter-tab and inter-context communication via the BroadcastChannel API. Channels are auto-closed on component destroy.
NetworkInformationService
Provides access to the Network Information API. Reports online status, connection type, effective type, downlink speed, and round-trip time.
ServerSentEventsService
Manages Server-Sent Events (SSE) connections. Supports typed message streams, custom event types, and multiple concurrent connections identified by URL.
πΎ Storage & I/O
BatteryService
Provides access to the Battery Status API, allowing you to monitor device battery level, charging state, and receive reactive updates via Observables.
ClipboardService
Provides a type-safe wrapper around the Clipboard API for reading from and writing to the system clipboard, with automatic permission verification.
WebStorageService
Type-safe wrapper for localStorage and sessionStorage with JSON serialization, optional key prefixing, and reactive change detection via Observables.
FileSystemAccessService
Provides access to the File System Access API for opening and saving files via the native OS picker. Supports single/multiple file selection, save dialogs, and directory access.
StorageManagerService
Provides access to the Storage Manager API for checking storage quotas and requesting persistent storage that is protected from automatic eviction.
CompressionService
Wraps the Compression Streams API for gzip/deflate compression and decompression of Uint8Array data. Useful for reducing transfer sizes or storing compressed data locally.
β Web Worker & Compute
WebWorkerService
Manages Web Worker lifecycle β creation, typed message passing, status tracking, and cleanup β with an Observable-based API.
WebLocksService
Coordinates exclusive or shared access to a named resource across tabs and workers using the Web Locks API. Useful for preventing concurrent operations on shared resources.
π Security & Permissions
BrowserCapabilityService
Detects browser capabilities and feature support. Allows you to check whether specific browser APIs are available before using them.
PermissionsService
Centralizes browser permission queries. Used internally by other services and directly available for custom permission checks.
CredentialManagementService
Wraps the Credential Management API for managing user credentials. Supports password credentials, public key credentials (WebAuthn/passkeys), and silent sign-in prevention.