UNPKG

@sv-use/core

Version:

A collection of Svelte 5 utilities.

40 lines (39 loc) 1.61 kB
import type { CleanupFunction } from '../__internal__/types.js'; export interface BatteryManager extends EventTarget { readonly charging: number; readonly chargingTime: number; readonly dischargingTime: number; readonly level: number; } type GetBatteryOptions = { /** * Whether to auto-cleanup the event listener or not. * * If set to `true`, it must run in the component initialization lifecycle. * @default true */ autoCleanup?: boolean; }; type GetBatteryReturn = { /** Whether the {@link https://developer.mozilla.org/en-US/docs/Web/API/Battery_Status_API | Battery Status API} is supported by the browser or not. */ readonly isSupported: boolean; /** Whether the battery is currently being charged or not. */ readonly charging: number; /** The remaining time in seconds until the battery is fully charged, or 0 if the battery is already fully charged. */ readonly chargingTime: number; /** The remaining time in seconds until the battery is completely discharged and the system suspends. */ readonly dischargingTime: number; /** The system's battery charge level scaled to a value between 0.0 and 1.0. */ readonly level: number; /** * Cleans up the event listeners. * @note Is called automatically if `options.autoCleanup` is set to `true`. */ cleanup: CleanupFunction; }; /** * Retrieves information about the battery. * @see https://svelte-librarian.github.io/sv-use/docs/core/get-battery */ export declare function getBattery(options?: GetBatteryOptions): GetBatteryReturn; export {};