import { CallActive } from '@wavoip/wavoip-api'; import { CallOutgoing } from '@wavoip/wavoip-api'; import { CallPeer } from '@wavoip/wavoip-api'; import { CallStatus as CallStatus_2 } from '@wavoip/wavoip-api'; import { ConnectionStatus } from '@wavoip/wavoip-api'; import { Contact } from '@wavoip/wavoip-api'; import { DeviceStatus } from '@wavoip/wavoip-api'; import { Offer } from '@wavoip/wavoip-api'; import { Wavoip } from '@wavoip/wavoip-api'; declare type CallActiveProps = Pick; declare type CallAPI = { start: (to: string, config?: { fromTokens?: string[]; displayName?: string; }) => Promise<{ call: null; err: { message: string; devices: { token: string; reason: string; }[]; }; } | { call: { id: string; peer: CallPeer; }; err: null; }>; /** * @deprecated Use {@link CallAPI.start} instead. `startCall` will be removed in a future major release. * * @example * // Before * window.wavoip.call.startCall("5511999999999", ["token-a"]); * // After * window.wavoip.call.start("5511999999999", { fromTokens: ["token-a"] }); */ startCall: (to: string, fromTokens: string[] | null) => Promise<{ call: null; err: { message: string; devices: { token: string; reason: string; }[]; }; } | { call: { id: string; peer: CallPeer; }; err: null; }>; getCallActive: () => CallActiveProps | undefined; getCallOutgoing: () => CallOutgoingProps | undefined; getOffers: () => CallOfferProps[]; setInput: (number: string) => void; onOffer(cb: (offer: CallOfferProps) => void): void; }; declare type CallOfferProps = Pick; declare type CallOutgoingProps = Pick; declare type CallSettings = { displayName?: string; }; /** * Mirrors `CallStatus` from `@wavoip/wavoip-api` verbatim, plus `"idle"` for * the no-call resting state. Keep this in sync with the SDK's enum. */ declare type CallStatus = CallStatus_2 | "idle"; declare type DeviceAPI = { get: () => DeviceStateEntry[]; add: (token: string, persist: boolean) => void; remove: (token: string) => void; enable: (token: string) => void; disable: (token: string) => void; /** @deprecated Use {@link DeviceAPI.get} instead. */ getDevices: () => DeviceStateEntry[]; /** @deprecated Use {@link DeviceAPI.add} instead. */ addDevice: (token: string, persist: boolean) => void; /** @deprecated Use {@link DeviceAPI.remove} instead. */ removeDevice: (token: string) => void; /** @deprecated Use {@link DeviceAPI.enable} instead. */ enableDevice: (token: string) => void; /** @deprecated Use {@link DeviceAPI.disable} instead. */ disableDevice: (token: string) => void; }; declare type DeviceMenuSettings = { show?: boolean; showAddDevices?: boolean; showEnableDevicesButton?: boolean; showRemoveDevicesButton?: boolean; }; declare type DeviceStateEntry = { token: string; status: DeviceStatus; connectionStatus: ConnectionStatus; qrCode?: string; contact?: Contact; restricted: boolean; restrictedUntil: Date | null; enable: boolean; persist: boolean; }; declare type Language = "en" | "pt-BR" | "es"; declare type MiddlewareEvent = keyof MiddlewareEventMap; declare type MiddlewareEventMap = { offer: Offer; }; declare type Notification_2 = { id: string; type: NotificationType; created_at: Date; message: string; detail: string; token: string; isHidden: boolean; isRead: boolean; }; /** Caller-supplied input for `notifications.add`. `id` and `created_at` are stamped by the API. */ declare type NotificationInput = Omit; declare type NotificationsAPI = { get: () => NotificationsType[]; /** * Stamps `id` and `created_at` and inserts the notification. Returns the * stored notification so callers can reference its generated `id` (e.g. for * later `remove`). */ add: (notification: NotificationInput) => NotificationsType; remove: (id: string) => void; clear: () => void; read: () => void; /** Current browser permission for OS-level offer notifications. */ permission: () => NotificationPermission; /** Prompts the browser for OS notification permission. Must be invoked from a user gesture. */ requestPermission: () => Promise; /** @deprecated Use {@link NotificationsAPI.get} instead. */ getNotifications: () => NotificationsType[]; /** @deprecated Use {@link NotificationsAPI.add} instead. */ addNotification: (notification: NotificationInput) => NotificationsType; /** @deprecated Use {@link NotificationsAPI.remove} instead. */ removeNotification: (id: string) => void; /** @deprecated Use {@link NotificationsAPI.clear} instead. */ clearNotifications: () => void; /** @deprecated Use {@link NotificationsAPI.read} instead. */ readNotifications: () => void; }; declare type NotificationsType = Notification_2; declare type NotificationType = "INFO" | "CALL_FAILED" | "MISSED_CALL" | "DEVICE_RESTRICTED" | "DEVICE_RESTRICTION_LIFTED"; declare type OfferNotificationSettings = { /** When false, the OS notification on incoming offer is suppressed. Default: true. */ enabled?: boolean; /** When true, asks for browser notification permission on mount. Default: false. */ autoRequest?: boolean; /** Optional icon URL shown on the OS notification. */ icon?: string; }; declare type PositionAPI = { value: { x: number; y: number; }; set: (position: WebphonePosition) => void; }; /** * Public Express-style middleware callback. Call `next()` to forward the * payload to subsequent middleware (and ultimately the UI); omit it to block. */ declare type PublicMiddleware = (payload: MiddlewareEventMap[E], next: () => void) => void | Promise; declare type SettingsAPI = { showNotifications: boolean; setShowNotifications: (show: boolean) => void; showSettings: boolean; setShowSettings: (show: boolean) => void; showDevices: boolean; setShowDevices: (show: boolean) => void; showAddDevices: boolean; setShowAddDevices: (show: boolean) => void; showEnableDevices: boolean; setShowEnableDevices: (show: boolean) => void; showRemoveDevices: boolean; setShowRemoveDevices: (show: boolean) => void; showWidgetButton: boolean; setShowWidgetButton: (show: boolean) => void; }; declare type SettingsMenuSettings = { deviceMenu?: DeviceMenuSettings; }; declare type StatusBarSettings = { showNotificationsIcon?: boolean; showSettingsIcon?: boolean; }; declare type Theme = "dark" | "light" | "system"; declare type ThemeAPI = { value: Theme; set: (theme: Theme) => void; /** @deprecated Use {@link ThemeAPI.set} instead. */ setTheme: (theme: Theme) => void; }; declare const webphone: WebPhoneComponent; export default webphone; declare type WebphoneAPI = { call: CallAPI; device: DeviceAPI; notifications: NotificationsAPI; widget: WidgetAPI; theme: ThemeAPI; position: PositionAPI; settings: SettingsAPI; on: (event: K, cb: (payload: WebphoneEventMap[K]) => void) => () => void; use: (event: E, fn: PublicMiddleware) => void; }; declare class WebPhoneComponent { private container; private root; render(config?: WebphoneSettings, wavoip?: Wavoip): Promise; destroy(): void; } /** * Map of programmatic events exposed via `window.wavoip.on(...)`. Add new keys * here when introducing a lifecycle hook; the public API surface is derived * from this map. */ declare type WebphoneEventMap = { "call:started": CallOutgoingProps; "call:accepted": CallActiveProps; "call:ended": { id: string; status: CallStatus; }; "offer:received": CallOfferProps; }; declare type WebphoneEventName = keyof WebphoneEventMap; declare type WebphonePosition = "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center" | { x: number; y: number; }; declare type WebphoneSettings = { theme?: Theme; statusBar?: Partial; settingsMenu?: Partial; widget?: Partial; position?: WebphonePosition; buttonPosition?: WidgetButtonPosition; callSettings?: CallSettings; offerNotification?: OfferNotificationSettings; platform?: string; language?: Language; }; declare type WidgetAPI = { isOpen: boolean; open: () => void; close: () => void; toggle: () => void; buttonPosition: { value: { x: number; y: number; }; set: (position: WidgetButtonPosition) => void; }; }; declare type WidgetButtonPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right" | { x: number; y: number; }; declare type WidgetSettings = { showWidgetButton?: boolean; startOpen?: boolean; }; export { }