lisn.js
Version:
Simply handle user gestures and actions. Includes widgets.
74 lines • 3.1 kB
TypeScript
/**
* @module Utils
*/
import { NonNullableReturnType } from "../globals/types.js";
/**
* Returns a Promise that is resolved when the given `checkFn` function returns
* a value other than `null` or `undefined`.
*
* The Promise is resolved with `checkFn`'s return value.
*
* The function is called initially, and then every time there are changes to
* the DOM children. Uses
* {@link https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver | MutationObserver}.
*
* @param timeout If given, then if no such element is present after this many
* milliseconds, the promise will resolve to `null`.
*
* @category DOM: Events
*/
export declare const waitForElement: <F extends () => unknown, T extends number | undefined = undefined>(checkFn: F, timeout?: number) => Promise<T extends undefined ? NonNullableReturnType<F> : NonNullableReturnType<F> | null>;
/**
* Returns a Promise that is resolved when the given `checkFn` function returns
* a value other than `null` or `undefined` or the
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState | Document:readyState}
* becomes "interactive".
*
* It always calls the given `checkFn` first before examining the `readyState`.
*
* If the `readyState` became interactive before the element was found, the
* Promise resolves to `null`. Otherwise the Promise is resolved with `checkFn`'s
* return value.
*
* The function is called initially, and then every time there are changes to
* the DOM children. Uses
* {@link https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver | MutationObserver}.
*
* @category DOM: Events
*/
export declare const waitForElementOrInteractive: <F extends () => unknown>(checkFn: F) => Promise<NonNullableReturnType<F> | null>;
/**
* Returns a Promise that is resolved when the
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState | Document:readyState}
* is "interactive" (or if it's already "interactive" or "complete", the
* Promise is fulfilled immediately).
*
* @category DOM: Events
*/
export declare const waitForInteractive: () => Promise<void>;
/**
* Returns a Promise that is resolved when the
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState | Document:readyState}
* is "complete" (or if it's already "complete", the Promise is fulfilled
* immediately).
*
* @category DOM: Events
*/
export declare const waitForComplete: () => Promise<void>;
/**
* Returns a Promise that is resolved either when the
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState | Document:readyState}
* is "complete" or the `readyState` is "interactive" and at least
* {@link settings.pageLoadTimeout} milliseconds have passed (if > 0) since it
* became "interactive".
*
* @category DOM: Events
*/
export declare const waitForPageReady: () => Promise<void>;
/**
* Returns true if the page is "ready". See {@link waitForPageReady}.
*
* @category DOM: Events
*/
export declare const isPageReady: () => boolean;
//# sourceMappingURL=dom-events.d.ts.map