// The typed bridge exposed to the renderer as window.api. import type { AddressBook, ChatExport, ContactInfo, NewContact, Conversation, Credentials, Did, Message, OutgoingAttachment, SearchHit, Settings, SyncStatus, Theme } from './types' export interface AppState { configured: boolean username?: string settings: Settings dataDir: string dids: Did[] keyringBackend: string gvoiceNumber?: string // set when Google Voice is connected } export interface RabbitStatus { adb: boolean // adb is installed bundledVersion?: string // the Android app this build carries device?: { serial: string; model: string; installedVersion?: string } } export interface Api { getState(): Promise testCredentials(creds: Credentials): Promise saveSetup(creds: Credentials, settings: Settings): Promise updateSettings(settings: Settings): Promise setTheme(theme: Theme): Promise signOut(): Promise connectGoogleVoice(): Promise connectGoogleVoiceCookies(text: string): Promise disconnectGoogleVoice(): Promise rabbitStatus(): Promise rabbitInstall(mode?: 'full' | 'update'): Promise // update: app only, keeps its data rabbitSync(): Promise onRabbitProgress(cb: (step: string) => void): () => void listContacts(): Promise listAddressBooks(): Promise<{ books: AddressBook[]; default?: string }> addContact(c: NewContact): Promise // resolves with the book's name listConversations(): Promise getMessages(did: string, contact: string): Promise markRead(did: string, contact: string): Promise markUnread(did: string, contact: string): Promise setArchived(did: string, contact: string, archived: boolean): Promise setName(did: string, contact: string, name: string | null): Promise // Unsent composer text, by contact; kept until sent or cleared. getDrafts(): Promise> setDraft(contact: string, text: string): Promise search(query: string, scope?: { did: string; contact: string }): Promise send(did: string, contact: string, text: string, attachments?: OutgoingAttachment[]): Promise deleteFailed(id: number): Promise retryFailed(id: number): Promise saveMedia(id: number, index: number): Promise exportChat(did: string, contact: string, opts: ChatExport): Promise // false: no file chosen readMedia(id: number, index: number): Promise<{ mime: string; data: Uint8Array }> copyImage(png: Uint8Array): Promise // onto the system clipboard syncStatus(): Promise pollNow(): Promise openDataFolder(): Promise snapshotNow(): Promise chooseDataDir(): Promise onMessages(cb: (msgs: Message[]) => void): () => void onConversationsChanged(cb: () => void): () => void onSyncStatus(cb: (s: SyncStatus) => void): () => void onContactsChanged(cb: () => void): () => void onStateChanged(cb: () => void): () => void onOpenConversation(cb: (key: { did: string; contact: string }) => void): () => void }