import type { FileTransferChunk, FileMetadata, FileTransferStatus } from "./data"; import type { OnMessage } from "../dependencies"; export interface FileTransferProgress { fileId: string; fileName: string; status?: FileTransferStatus; progress: number; transferredBytes: number; totalBytes: number; transferredChunks: number; totalChunks: number; receivedChunks?: number; receivedBytes?: number; } export interface FileTransferResult { fileId: string; fileName: string; success: boolean; transferredBytes: number; totalBytes: number; duration: number; hash?: string; fileKey?: string; blob?: Blob; } export interface FileTransferError { fileId: string; fileName: string; error: string; code: string; } export interface FileTransferOptions { fileId?: string; timeout?: number; onProgress?: (progress: FileTransferProgress) => void; onComplete?: (result: FileTransferResult) => void; onError?: (error: FileTransferError) => void; } export interface FileTransferSendState { fileId: string; file: File; chunks: FileTransferChunk[]; metadata: FileMetadata; sentChunks: Set; startTime: number; options: FileTransferOptions; } export interface FileTransferControl { fileId: string; cancel: () => Promise; promise: Promise; } export interface FileTransferReceiveState { fileId: string; fileName: string; totalChunks: number; receivedChunks: Map; receivedBytes: number; metadata?: Record; encrypted?: boolean; encryptionKey?: string; startTime: number; options: FileTransferOptions; } export interface FileTransferIncomingMessage { type: string; message: { action: string; value: Record; }; schemaVersion?: string; } export interface FileReceiverAPI { handleFileTransferMessage: (data: FileTransferIncomingMessage, onMessage?: OnMessage) => Promise; setReceiveOptions: (fileId: string, options: FileTransferOptions) => void; getActiveTransfers: () => string[]; cancelReceive: (fileId: string) => void; }