@thepassle/app-tools
Version:
Collection of tools I regularly use to build apps. Maybe they're useful to somebody else. Maybe not. Most of these are thin wrappers around native API's, like the native `<dialog>` element, `fetch` API, and `URLPattern`.
41 lines (40 loc) • 1.3 kB
TypeScript
export type BeforeInstallPromptEvent = Event & {
prompt(): Promise<void>;
userChoice: Promise<{
outcome: 'accepted' | 'dismissed';
platform: string;
}>;
};
export const pwa: Pwa;
/**
* @typedef {Event & {
* prompt(): Promise<void>,
* userChoice: Promise<{
* outcome: 'accepted' | 'dismissed',
* platform: string
* }>
* }} BeforeInstallPromptEvent
*/
declare class Pwa extends EventTarget {
/** @type {boolean} */
updateAvailable: boolean;
/** @type {boolean} */
installable: boolean;
/** @type {BeforeInstallPromptEvent | undefined} */
installPrompt: BeforeInstallPromptEvent | undefined;
/** @type {ServiceWorker | undefined} */
__waitingServiceWorker: ServiceWorker | undefined;
isInstalled: boolean;
/** Triggers the install prompt, when it's available. You can call this method when the `'installable'` event has fired. */
triggerPrompt: () => Promise<void>;
/** Update */
update: () => void;
/**
* @param {string} swPath
* @param {RegistrationOptions} [opts]
* @returns {Promise<ServiceWorkerRegistration> | Promise<void>}
*/
register(swPath: string, opts?: RegistrationOptions): Promise<ServiceWorkerRegistration> | Promise<void>;
kill(): Promise<void>;
}
export {};