diff --git a/Package.swift b/Package.swift index 57422ca..20d0f51 100644 --- a/Package.swift +++ b/Package.swift @@ -5,6 +5,14 @@ import PackageDescription let package = Package( name: "ArriClient", + // platforms: [ + // .iOS("13.0"), + // .macCatalyst("13.0"), + // .macOS("10.15"), + // .tvOS("13.0"), + // .visionOS("1.0"), + // .watchOS("6.0") + // ], products: [ // Products define the executables and libraries a package produces, making them visible to other packages. .library( diff --git a/Sources/ArriClient/ArriClient.swift b/Sources/ArriClient/ArriClient.swift index 2c17ffa..7b108f0 100644 --- a/Sources/ArriClient/ArriClient.swift +++ b/Sources/ArriClient/ArriClient.swift @@ -10,6 +10,7 @@ import NIOFoundationCompat let jsonEncoder = JSONEncoder() let jsonDecoder = JSONDecoder() +@available(macOS 10.15, iOS 13, tvOS 13, macCatalyst 13, *) public func parsedArriHttpRequest( delegate: ArriRequestDelegate, url: String, @@ -238,12 +239,12 @@ public func serializeAny(input: JSON) -> String { //// Request Delegate //// - +@available(macOS 10.15, iOS 13, tvOS 13, macCatalyst 13, *) public protocol ArriRequestDelegate { func handleHTTPRequest(request: ArriHTTPRequest) async throws -> ArriHTTPResponse func handleHTTPEventStreamRequest(request: ArriHTTPRequest) async throws -> ArriSSEResponse } - +@available(macOS 10.15, iOS 13, tvOS 13, macCatalyst 13, *) public struct DefaultRequestDelegate: ArriRequestDelegate { var maxBodyBytes: Int = 1024 * 1024 public init() {} @@ -307,6 +308,7 @@ public struct DefaultRequestDelegate: ArriRequestDelegate { } } +@available(macOS 10.15, iOS 13, tvOS 13, macCatalyst 13, *) public enum ArriSSEResponse { case ok(ArriHTTPResponse) case error(ArriHTTPResponse) @@ -386,6 +388,7 @@ public enum ArriResponseErrors: Error { } extension URLSession { + @available(macOS 10.15, iOS 13, tvOS 13, macCatalyst 13, *) func asyncData(with: URLRequest) async throws -> (Data?, HTTPURLResponse) { return try await withCheckedThrowingContinuation { continuation in URLSession.shared.dataTask(with: with) {data, response, error in @@ -596,10 +599,12 @@ public func sseEventListFromString(input: String, debug: Bool) -> ([RawSSEEvent] return (events, String(leftover)) } +@available(macOS 10.15, iOS 13, tvOS 13, macCatalyst 13, *) public protocol ArriCancellable { mutating func cancel() -> () } +@available(macOS 10.15, iOS 13, tvOS 13, macCatalyst 13, *) public struct EventSourceOptions { public var onMessage: (T, inout EventSource) -> () public var onRequest: ((ArriHTTPRequest, inout EventSource) -> ()) = { _, __ in } @@ -666,6 +671,7 @@ public struct EventSourceOptions { } } +@available(macOS 10.15, iOS 13, tvOS 13, macCatalyst 13, *) public struct EventSource: ArriCancellable { var url: String var method: String @@ -701,6 +707,7 @@ public struct EventSource: ArriCancellable { self.cancelled = true } + @available(macOS 10.15, iOS 13, tvOS 13, macCatalyst 13, *) public mutating func sendRequest() async { var urlComponents = URLComponents(string: self.url) if urlComponents == nil { diff --git a/package.json b/package.json index 2d19d60..90171e8 100644 --- a/package.json +++ b/package.json @@ -17,5 +17,6 @@ "fs-extra": "^11.2.0", "jiti": "^1.21.6", "prettier": "^3.3.3" - } + }, + "packageManager": "pnpm@9.6.0" }