Skip to content

Commit

Permalink
Updated Foundation imports to lower binary size on linux
Browse files Browse the repository at this point in the history
Fixes #54
  • Loading branch information
dimitribouniol committed Dec 26, 2024
1 parent 1394781 commit c891bd3
Show file tree
Hide file tree
Showing 29 changed files with 116 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/WebPush/Errors/BadSubscriberError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// The subscription is no longer valid and should be removed and re-registered.
///
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/Errors/Base64URLDecodingError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// An error encountered while decoding Base64 data.
public struct Base64URLDecodingError: LocalizedError, Hashable, Sendable {
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/Errors/MessageTooLargeError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// The message was too large, and could not be delivered to the push service.
///
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/Errors/PushServiceError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
//

import AsyncHTTPClient
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// An unknown Push Service error was encountered.
///
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/Errors/UserAgentKeyMaterialError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// An error encountered during ``VAPID/Configuration`` initialization or decoding.
public struct UserAgentKeyMaterialError: LocalizedError, Sendable {
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/Errors/VAPIDConfigurationError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension VAPID {
/// An error encountered during ``VAPID/Configuration`` initialization or decoding.
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/Helpers/DataProtocol+Base64URLCoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension DataProtocol {
/// The receiver as a Base64 URL encoded string.
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/Helpers/PrintLogHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Logging

/// A simple log handler that uses formatted print statements.
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/Helpers/URL+Origin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension URL {
/// Returns the origin for the receiving URL, as defined for use in signing headers for VAPID.
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/Subscriber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
//

@preconcurrency import Crypto
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// Represents a subscriber registration from the browser.
///
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/Topic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
//

@preconcurrency import Crypto
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// Topics are used to de-duplicate and overwrite messages on push services before they are delivered to a subscriber.
///
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/VAPID/VAPID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// The fully qualified name for VAPID.
public typealias VoluntaryApplicationServerIdentification = VAPID
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/VAPID/VAPIDConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension VoluntaryApplicationServerIdentification {
/// A configuration object specifying the contact information along with the keys that your application server identifies itself with.
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/VAPID/VAPIDKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
//

@preconcurrency import Crypto
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension VoluntaryApplicationServerIdentification {
/// Represents the application server's identification key that is used to confirm to a push service that the server connecting to it is the same one that was subscribed to.
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/VAPID/VAPIDToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
//

@preconcurrency import Crypto
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension VAPID {
/// An internal representation the token and authorization headers used self-identification.
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPush/WebPushManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

import AsyncHTTPClient
@preconcurrency import Crypto
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import NIOHTTP1
import Logging
import NIOCore
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPushTesting/Subscriber+Testing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
//

@preconcurrency import Crypto
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import WebPush

extension Subscriber {
Expand Down
4 changes: 4 additions & 0 deletions Sources/WebPushTesting/VAPIDConfiguration+Testing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
//

@preconcurrency import Crypto
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import WebPush

extension VAPID.Configuration {
Expand Down
4 changes: 4 additions & 0 deletions Tests/WebPushTests/Base64URLCodingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Testing
@testable import WebPush

Expand Down
4 changes: 4 additions & 0 deletions Tests/WebPushTests/BytesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Testing
@testable import WebPush

Expand Down
4 changes: 4 additions & 0 deletions Tests/WebPushTests/ErrorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
//

import AsyncHTTPClient
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Testing
@testable import WebPush

Expand Down
4 changes: 4 additions & 0 deletions Tests/WebPushTests/Helpers/VAPIDConfiguration+Testing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import WebPush

extension VAPID.Configuration {
Expand Down
4 changes: 4 additions & 0 deletions Tests/WebPushTests/SubscriberTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
//

import Crypto
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Testing
@testable import WebPush
import WebPushTesting
Expand Down
4 changes: 4 additions & 0 deletions Tests/WebPushTests/TopicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@


import Crypto
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Testing
@testable import WebPush

Expand Down
4 changes: 4 additions & 0 deletions Tests/WebPushTests/URLOriginTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
// Copyright © 2024 Mochi Development, Inc. All rights reserved.
//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Testing
@testable import WebPush

Expand Down
4 changes: 4 additions & 0 deletions Tests/WebPushTests/VAPIDConfigurationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
//

import Crypto
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Testing
@testable import WebPush
import WebPushTesting
Expand Down
4 changes: 4 additions & 0 deletions Tests/WebPushTests/VAPIDKeyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
//

import Crypto
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Testing
@testable import WebPush
import WebPushTesting
Expand Down
4 changes: 4 additions & 0 deletions Tests/WebPushTests/VAPIDTokenTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
//

import Crypto
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Testing
@testable import WebPush

Expand Down
4 changes: 4 additions & 0 deletions Tests/WebPushTests/WebPushManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

@testable import AsyncHTTPClient
@preconcurrency import Crypto
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
import Logging
import ServiceLifecycle
import Testing
Expand Down

0 comments on commit c891bd3

Please sign in to comment.