forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpwa.ts
More file actions
23 lines (20 loc) · 798 Bytes
/
Copy pathpwa.ts
File metadata and controls
23 lines (20 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
* pwa.ts — Issue #487
* Typed contracts for the PWA install prompt lifecycle.
*/
/** Typed wrapper around the `BeforeInstallPromptEvent` (not yet in TS lib). */
export interface BeforeInstallPromptEvent extends Event {
readonly platforms: string[];
prompt(): Promise<void>;
readonly userChoice: Promise<{ outcome: 'accepted' | 'dismissed'; platform: string }>;
}
/** Possible outcomes after calling `prompt()`. */
export type InstallOutcome = 'accepted' | 'dismissed';
/** Public API surface returned by `usePWA`. */
export interface PWAHook {
isOnline: boolean;
/** True when a deferred install prompt is available. */
canInstall: boolean;
/** Trigger the browser's install prompt. Resolves to the user's outcome. */
installApp: () => Promise<InstallOutcome | null>;
}