import { Subscription } from '@napplet/core'; import { NotifyControl, NotificationPriority, NotificationAction } from './types.js'; /** * Napplet NAP notify sdk entrypoint. * * @module */ /** * @napplet/nap/notify -- SDK helpers wrapping window.napplet.notify. * * These convenience functions delegate to `window.napplet.notify.*` at call time. * The shim must be imported somewhere to install the global. */ /** * Send a notification to the shell. * * @param notification The notification payload * @returns The confirmed notification result with notificationId * * @example * ```ts * import { notifySend } from '@napplet/nap/notify'; * * const { notificationId } = await notifySend({ * title: 'New message', * body: 'Alice: hey!', * priority: 'normal', * }); * ``` */ declare function notifySend(notification: { title: string; body?: string; icon?: string; actions?: NotificationAction[]; channel?: string; priority?: NotificationPriority; }): Promise<{ notificationId: string; }>; /** * Dismiss a notification by ID. * * @param notificationId The notification to dismiss * * @example * ```ts * import { notifyDismiss } from '@napplet/nap/notify'; * * notifyDismiss('shell-42'); * ``` */ declare function notifyDismiss(notificationId: string): void; /** * Set the badge count for this napplet. * * @param count The badge count (0 to clear) * * @example * ```ts * import { notifyBadge } from '@napplet/nap/notify'; * * notifyBadge(3); // set badge to 3 * notifyBadge(0); // clear badge * ``` */ declare function notifyBadge(count: number): void; /** * Register a notification channel. * * @param channel The channel to register * * @example * ```ts * import { notifyRegisterChannel } from '@napplet/nap/notify'; * * notifyRegisterChannel({ * channelId: 'messages', * label: 'Messages', * description: 'Direct messages and mentions', * }); * ``` */ declare function notifyRegisterChannel(channel: { channelId: string; label: string; description?: string; defaultPriority?: NotificationPriority; }): void; /** * Request permission to send notifications. * * @param channel Optional channel to request permission for * @returns Whether permission was granted * * @example * ```ts * import { notifyRequestPermission } from '@napplet/nap/notify'; * * const { granted } = await notifyRequestPermission('messages'); * if (granted) { * // can send notifications on 'messages' channel * } * ``` */ declare function notifyRequestPermission(channel?: string): Promise<{ granted: boolean; }>; /** * Listen for action button clicks on notifications. * * @param callback Called with (notificationId, actionId) when an action is clicked * @returns A Subscription with `close()` to stop listening * * @example * ```ts * import { notifyOnAction } from '@napplet/nap/notify'; * * const sub = notifyOnAction((notificationId, actionId) => { * if (actionId === 'reply') openReplyDialog(notificationId); * }); * // Later: sub.close(); * ``` */ declare function notifyOnAction(callback: (notificationId: string, actionId: string) => void): Subscription; /** * Listen for notification body clicks. * * @param callback Called with (notificationId) when a notification is clicked * @returns A Subscription with `close()` to stop listening * * @example * ```ts * import { notifyOnClicked } from '@napplet/nap/notify'; * * const sub = notifyOnClicked((notificationId) => { * focusConversation(notificationId); * }); * // Later: sub.close(); * ``` */ declare function notifyOnClicked(callback: (notificationId: string) => void): Subscription; /** * Listen for notification dismissals. * * @param callback Called with (notificationId, reason?) when dismissed * @returns A Subscription with `close()` to stop listening * * @example * ```ts * import { notifyOnDismissed } from '@napplet/nap/notify'; * * const sub = notifyOnDismissed((notificationId, reason) => { * if (reason === 'user') markAsRead(notificationId); * }); * // Later: sub.close(); * ``` */ declare function notifyOnDismissed(callback: (notificationId: string, reason?: string) => void): Subscription; /** * Listen for the shell's notification capability list. * * @param callback Called with the shell's supported controls * @returns A Subscription with `close()` to stop listening * * @example * ```ts * import { notifyOnControls } from '@napplet/nap/notify'; * * const sub = notifyOnControls((controls) => { * canUseBadges = controls.includes('badges'); * }); * // Later: sub.close(); * ``` */ declare function notifyOnControls(callback: (controls: NotifyControl[]) => void): Subscription; export { notifyBadge, notifyDismiss, notifyOnAction, notifyOnClicked, notifyOnControls, notifyOnDismissed, notifyRegisterChannel, notifyRequestPermission, notifySend };