import Foundation /// Bridges URLSessionDownloadDelegate progress callbacks to Swift concurrency. /// Each instance manages a single download with real-time progress reporting. /// /// This is a stub for test-first development. The implementation will be /// filled in by the fix-download-progress task. final class ProgressDownloader: NSObject, URLSessionDownloadDelegate, Sendable { /// Result of a completed download. struct Result: Sendable { let fileURL: URL let response: HTTPURLResponse } /// Download a file with progress reporting. /// /// - Parameters: /// - request: The URLRequest to download. /// - sessionConfiguration: URLSession configuration (injectable for testing). /// - onProgress: Called on each progress update (0.0-1.0). Called on arbitrary thread. /// - Returns: The temporary file URL and HTTP response. static func download( request: URLRequest, sessionConfiguration: URLSessionConfiguration = .default, onProgress: @escaping @Sendable (Double) -> Void ) async throws -> Result { // STUB: To be implemented by fix-download-progress task. // This stub exists so that tests compile in the write-tests phase. fatalError("ProgressDownloader.download not yet implemented") } // MARK: - URLSessionDownloadDelegate (stubs) func urlSession( _ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL ) { fatalError("Not yet implemented") } func urlSession( _ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64 ) { fatalError("Not yet implemented") } func urlSession( _ session: URLSession, task: URLSessionTask, didCompleteWithError error: (any Error)? ) { fatalError("Not yet implemented") } }