import type { TurboModule } from 'react-native'; import { TurboModuleRegistry } from 'react-native'; export interface Device { deviceAddress: string; deviceName: string; isGroupOwner: boolean; primaryDeviceType: string | null; secondaryDeviceType: string | null; status: number; } export interface ConnectionArgs { deviceAddress: string; groupOwnerIntent?: number; } export interface GroupInfo { interface: string; networkName: string; passphrase: string; clientList: Device[]; owner: { deviceAddress: string; deviceName: string; primaryDeviceType: string | null; secondaryDeviceType: string | null; status: number; } | null; } export interface WifiP2pInfo { groupOwnerAddress: { hostAddress: string; isLoopbackAddress: boolean; } | null; groupFormed: boolean; isGroupOwner: boolean; } export interface FileTransferResult { file: string; time: number; } export interface MessageTransferResult { message: string; time: number; } export interface Message { message: T; fromAddress: string; fromHostName: string; fromPort: number; localAddress: string; localPort: number; receivedAt: number; messageSize: number; threadName: string; connectionId: string; } export interface Config { notificationTitle: string; sendingMessageText: string; channelName: string; } export interface Spec extends TurboModule { // Inicialização init(): Promise; stop(): Promise; // Configuração setConfig(config: Config): void; getConfig(): Promise; // Descoberta e conexão discoverPeers(): Promise; stopPeerDiscovery(): Promise; getAvailablePeersList(): Promise<{ devices: Device[] }>; connectWithConfig(config: ConnectionArgs): Promise; cancelConnect(): Promise; createGroup(): Promise; removeGroup(): Promise; // Informações getConnectionInfo(): Promise; getGroupInfo(): Promise; // Arquivos sendFile(path: string): Promise; sendFileTo(path: string, address: string): Promise; receiveFile( folder: string, fileName: string, forceToScanGallery: boolean ): Promise; // Mensagens sendMessage(message: string): Promise; sendMessageTo( message: string, address: string ): Promise; startReceivingMessage(props?: { meta?: boolean }): Promise; stopReceivingMessage(): void; } export default TurboModuleRegistry.getEnforcing('RnWifiP2P');