///
/**
* Battery information for the device.
* Can be extended in the future with additional battery properties (charging, times, etc.)
*/
interface BatteryInfo {
/**
* Battery level as a percentage (0-100).
* null if battery data is not available.
*/
percentage: number | null;
}
/**
* Interface for accessing battery information.
*/
interface BatteryInterface {
/**
* Get the current battery information for the device.
* Returns the last known battery information, or null if not available.
* Battery information is updated via Battery Status API events.
*
* @returns Battery information including percentage.
*/
getBatteryInfo(): BatteryInfo;
}
/**
* Device information payload to be sent from main thread to worker.
*/
interface DeviceInfo {
isTablet: boolean;
batteryInfo: BatteryInfo;
}
/**
* Web implementation of BatteryInterface that uses browser APIs to detect battery status.
* This class runs on the main thread and manages battery information.
*
* Use the static `create()` method to properly initialize the instance.
* Call `dispose()` when done to clean up event listeners.
*/
declare class WebBatteryInterface implements BatteryInterface {
private batteryManager;
private currentBatteryPercentage;
private batteryChangeListeners;
private handleOnLevelChange;
private constructor();
/**
* Creates and initializes a new WebBatteryInterface instance.
* Asynchronously initializes battery manager.
*
* @returns Promise resolving to an initialized WebBatteryInterface instance
*/
static create(): Promise;
/**
* Register a listener to be called when battery level changes.
* @param listener Function to call when battery changes
*/
addBatteryChangeListener(listener: (batteryInfo: BatteryInfo) => void): void;
/**
* Unregister a battery change listener.
* @param listener The listener to remove
*/
removeBatteryChangeListener(listener: (batteryInfo: BatteryInfo) => void): void;
/**
* Dispose of the WebDeviceInterface and remove all event listeners.
* Call this when you're done using the interface to avoid memory leaks.
*/
dispose(): void;
private notifyBatteryChange;
private onLevelChange;
/**
* Get the current battery information for the device.
* Returns the last known battery percentage, or null if not available.
* Battery data is updated via Battery Status API events.
*
* @returns Battery information with percentage, or null if unavailable.
*/
getBatteryInfo(): BatteryInfo;
private initializeBatteryManager;
}
export { type BatteryInfo, type BatteryInterface, type DeviceInfo, WebBatteryInterface };