UNPKG

drab

Version:

Interactivity for You

32 lines (31 loc) 1.46 kB
import { Base, type BaseAttributes } from "../base/index.js"; export type WakeLockAttributes = BaseAttributes & { "auto-lock"?: boolean; locked?: boolean; }; /** * `WakeLock` uses the [WakeLock API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API) to ensure the screen does not turn off when viewing the page on supported devices. Use your best judgement for when this is necessary, for example, if you have a timer that needs to stay on, or you are displaying a QR code. * * - WakeLock can be toggled with a `trigger`, or will be requested if the element has a `locked` attribute when connected. * - Use `content` and `swap` elements to adjust the UI based on the current state. * - `request` and `release` methods are provided to set the WakeLock with JavaScript. * - `trigger` is disabled if not supported. * - WakeLock is released when the element is removed from the DOM. * * `auto-lock` * * - By default, the WakeLock will be released when the tab is not active. Use the `auto-lock` attribute to automatically request the WakeLock when the user views the tab again. * * */ export declare class WakeLock extends Base { #private; wakeLock: WakeLockSentinel | null; constructor(); /** Requests WakeLock on the current page. */ request(): Promise<void>; /** Releases the WakeLock, sets `this.wakeLock` to null. */ release(): Promise<void>; mount(): void; destroy(): void; }