export type TinyPushNotification = import('../utils.mjs').TinyPushNotification; export type BrowserNotificationOptions = { /** * - The main text of the notification, shown below the title. */ body?: string; /** * - URL of the image used as the notification icon. */ icon?: string; /** * - URL of an image shown inside the notification body. */ image?: string; /** * - Identifier used to group and replace notifications sharing the same tag. */ tag?: string; /** * - BCP 47 language tag describing the notification text. */ lang?: string; /** * - Text direction used to render the notification content. */ dir?: 'auto' | 'ltr' | 'rtl'; /** * - Whether to notify the user again when a notification with the same `tag` is replaced. */ renotify?: boolean; /** * - Whether the notification stays visible until the user interacts with it. */ requireInteraction?: boolean; /** * - Whether the notification is shown without sound or vibration feedback. */ silent?: boolean; /** * - Time the notification was created, in milliseconds since the Unix epoch. */ timestamp?: number; /** * - Vibration pattern, in milliseconds, applied on supported devices. */ vibrate?: number[]; /** * - Arbitrary payload attached to the notification for later retrieval. */ data?: Record; }; export type BrowserNotification = { /** * - The headline text displayed at the top of the notification. */ title: string; /** * - The configuration applied to the notification. */ options: BrowserNotificationOptions; }; /** @typedef {import('../utils.mjs').TinyPushNotification} TinyPushNotification */ /** * Options accepted by the page level `Notification` constructor. * * @typedef {Object} BrowserNotificationOptions * @property {string} [body] - The main text of the notification, shown below the title. * @property {string} [icon] - URL of the image used as the notification icon. * @property {string} [image] - URL of an image shown inside the notification body. * @property {string} [tag] - Identifier used to group and replace notifications sharing the same tag. * @property {string} [lang] - BCP 47 language tag describing the notification text. * @property {'auto'|'ltr'|'rtl'} [dir] - Text direction used to render the notification content. * @property {boolean} [renotify] - Whether to notify the user again when a notification with the same `tag` is replaced. * @property {boolean} [requireInteraction] - Whether the notification stays visible until the user interacts with it. * @property {boolean} [silent] - Whether the notification is shown without sound or vibration feedback. * @property {number} [timestamp] - Time the notification was created, in milliseconds since the Unix epoch. * @property {number[]} [vibrate] - Vibration pattern, in milliseconds, applied on supported devices. * @property {Record} [data] - Arbitrary payload attached to the notification for later retrieval. */ /** * A notification already adapted to the page environment. * * @typedef {Object} BrowserNotification * @property {string} title - The headline text displayed at the top of the notification. * @property {BrowserNotificationOptions} options - The configuration applied to the notification. */ /** * Adapts notification descriptors between the Service Worker and the page. * * The class is a static-only utility and is never instantiated. It normalizes * the payload in both directions: a descriptor produced by the Service Worker * can be safely handed to the page level `Notification` constructor through * {@link TinyNotificationAdapter.toBrowser}, and a page level notification can * be converted back into a Service Worker payload through * {@link TinyNotificationAdapter.toServiceWorker}. * * @beta */ declare class TinyNotificationAdapter { #private; static PUSH_TYPE: Readonly<{ NOTIFICATION: "notification"; DATA: "data"; SYNC: "sync"; COMMAND: "command"; UNKNOWN: "unknown"; }>; /** * SW -> Browser. Use before `new Notification(...)`. * * @param {TinyPushNotification|null} notification - Descriptor sent by the Service Worker. * @param {Partial} [overrides] - Values that win over the descriptor. * @returns {BrowserNotification} The notification adapted for the page environment. * @throws {TypeError} If `notification` is neither `null` nor a non-null object. */ static toBrowser(notification: TinyPushNotification | null, overrides?: Partial): BrowserNotification; /** * Browser -> SW. Use before sending a click/close back to the Service Worker. * * @param {BrowserNotification} notification - The value returned by {@link TinyNotificationAdapter.toBrowser}. * @param {Partial} [overrides] - Values that win over the descriptor. * @returns {{ title: string, body: string, options: BrowserNotificationOptions }} The payload shaped for the Service Worker, with a guaranteed string `body`. * @throws {TypeError} If `notification` is not a non-null object. */ static toServiceWorker(notification: BrowserNotification, overrides?: Partial): { title: string; body: string; options: BrowserNotificationOptions; }; } export default TinyNotificationAdapter; //# sourceMappingURL=TinyNotificationAdapter.d.mts.map