Skip to content

Commit 70b232d

Browse files
committed
Update import
1 parent 83a6855 commit 70b232d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+861
-549
lines changed

.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.0.3

Justfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
build-wasm-docker:
2+
docker run \
3+
--platform linux/arm64 \
4+
--rm \
5+
-v ./:/workspace \
6+
-w /workspace \
7+
ghcr.io/swiftwasm/swift:5.10-focal \
8+
bash -cl "swift build -c release --triple wasm32-unknown-wasi"
9+
10+
format:
11+
swift format --in-place --recursive .
12+
113
build:
214
swift build -c debug --triple wasm32-unknown-wasi
315

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.10
1+
// swift-tools-version:6.0
22

33
import PackageDescription
44

Sources/Compute/Cache.swift

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
//
22
// Cache.swift
3-
//
3+
//
44
//
55
// Created by Andrew Barba on 9/13/23.
66
//
77

88
public struct Cache: Sendable {
99

10-
public static func getOrSet(_ key: String, _ handler: () async throws -> (FetchResponse, CachePolicy)) async throws -> Entry {
10+
public static func getOrSet(
11+
_ key: String, _ handler: () async throws -> (FetchResponse, CachePolicy)
12+
) async throws -> Entry {
1113
let trx = try await Fastly.Cache.getOrSet(key) {
1214
let (res, cachePolicy) = try await handler()
1315
let length = res.headers[.contentLength].flatMap(Int.init)
@@ -16,31 +18,39 @@ public struct Cache: Sendable {
1618
return try .init(trx)
1719
}
1820

19-
public static func getOrSet(_ key: String, _ handler: () async throws -> ([UInt8], CachePolicy)) async throws -> Entry {
21+
public static func getOrSet(_ key: String, _ handler: () async throws -> ([UInt8], CachePolicy))
22+
async throws -> Entry
23+
{
2024
let trx = try await Fastly.Cache.getOrSet(key) {
2125
let (bytes, cachePolicy) = try await handler()
2226
return (.bytes(bytes), cachePolicy)
2327
}
2428
return try .init(trx)
2529
}
2630

27-
public static func getOrSet(_ key: String, _ handler: () async throws -> (String, CachePolicy)) async throws -> Entry {
31+
public static func getOrSet(_ key: String, _ handler: () async throws -> (String, CachePolicy))
32+
async throws -> Entry
33+
{
2834
let trx = try await Fastly.Cache.getOrSet(key) {
2935
let (text, cachePolicy) = try await handler()
3036
return (.bytes(.init(text.utf8)), cachePolicy)
3137
}
3238
return try .init(trx)
3339
}
3440

35-
public static func getOrSet(_ key: String, _ handler: () async throws -> (Data, CachePolicy)) async throws -> Entry {
41+
public static func getOrSet(_ key: String, _ handler: () async throws -> (Data, CachePolicy))
42+
async throws -> Entry
43+
{
3644
let trx = try await Fastly.Cache.getOrSet(key) {
3745
let (data, cachePolicy) = try await handler()
3846
return (.bytes(data.bytes), cachePolicy)
3947
}
4048
return try .init(trx)
4149
}
4250

43-
public static func getOrSet(_ key: String, _ handler: () async throws -> ([String: Sendable], CachePolicy)) async throws -> Entry {
51+
public static func getOrSet(
52+
_ key: String, _ handler: () async throws -> ([String: Sendable], CachePolicy)
53+
) async throws -> Entry {
4454
let trx = try await Fastly.Cache.getOrSet(key) {
4555
let (json, cachePolicy) = try await handler()
4656
let data = try JSONSerialization.data(withJSONObject: json)
@@ -49,7 +59,9 @@ public struct Cache: Sendable {
4959
return try .init(trx)
5060
}
5161

52-
public static func getOrSet(_ key: String, _ handler: () async throws -> ([Sendable], CachePolicy)) async throws -> Entry {
62+
public static func getOrSet(
63+
_ key: String, _ handler: () async throws -> ([Sendable], CachePolicy)
64+
) async throws -> Entry {
5365
let trx = try await Fastly.Cache.getOrSet(key) {
5466
let (json, cachePolicy) = try await handler()
5567
let data = try JSONSerialization.data(withJSONObject: json)

Sources/Compute/Concurrency.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Concurrency.swift
3-
//
3+
//
44
//
55
// Created by Andrew Barba on 11/27/22.
66
//
@@ -10,7 +10,7 @@ extension Data: @unchecked Sendable {}
1010
extension URL: @unchecked Sendable {}
1111

1212
#if !arch(wasm32)
13-
extension HTTPURLResponse: @unchecked Sendable {}
13+
extension HTTPURLResponse: @unchecked Sendable {}
1414
#endif
1515

1616
extension Task where Success == Never, Failure == Never {

Sources/Compute/ConfigStore.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// ConfigStore.swift
3-
//
3+
//
44
//
55
// Created by Andrew Barba on 11/27/22.
66
//

Sources/Compute/Console.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Console.swift
3-
//
3+
//
44
//
55
// Created by Andrew Barba on 3/23/22.
66
//
@@ -35,7 +35,7 @@ public struct Console: Sendable {
3535
}
3636
}
3737

38-
fileprivate struct StandardErrorOutputStream: TextOutputStream {
38+
private struct StandardErrorOutputStream: TextOutputStream {
3939

4040
private let stderr = FileHandle.standardError
4141

Sources/Compute/Crypto.swift

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Crypto.swift
3-
//
3+
//
44
//
55
// Created by Andrew Barba on 2/8/23.
66
//
@@ -13,15 +13,18 @@ public enum Crypto {}
1313

1414
extension Crypto {
1515

16-
public static func hash<T>(_ input: String, using hash: T.Type) -> T.Digest where T: HashFunction {
16+
public static func hash<T>(_ input: String, using hash: T.Type) -> T.Digest
17+
where T: HashFunction {
1718
return T.hash(data: Data(input.utf8))
1819
}
1920

20-
public static func hash<T>(_ input: [UInt8], using hash: T.Type) -> T.Digest where T: HashFunction {
21+
public static func hash<T>(_ input: [UInt8], using hash: T.Type) -> T.Digest
22+
where T: HashFunction {
2123
return T.hash(data: Data(input))
2224
}
2325

24-
public static func hash<T>(_ input: Data, using hash: T.Type) -> T.Digest where T: HashFunction {
26+
public static func hash<T>(_ input: Data, using hash: T.Type) -> T.Digest
27+
where T: HashFunction {
2528
return T.hash(data: input)
2629
}
2730

@@ -92,7 +95,9 @@ extension Crypto {
9295
}
9396
}
9497

95-
public static func verify(_ input: String, signature: Data, secret: String, using hash: Hash) -> Bool {
98+
public static func verify(
99+
_ input: String, signature: Data, secret: String, using hash: Hash
100+
) -> Bool {
96101
let computed = code(for: input, secret: secret, using: hash)
97102
return computed.toHexString() == signature.toHexString()
98103
}
@@ -109,7 +114,9 @@ extension Crypto {
109114
case p521
110115
}
111116

112-
public static func signature(for input: String, secret: String, using algorithm: Algorithm) throws -> Data {
117+
public static func signature(for input: String, secret: String, using algorithm: Algorithm)
118+
throws -> Data
119+
{
113120
switch algorithm {
114121
case .p256:
115122
let pk = try P256.Signing.PrivateKey(pemRepresentation: secret)
@@ -123,7 +130,9 @@ extension Crypto {
123130
}
124131
}
125132

126-
public static func verify(_ input: String, signature: Data, key: String, using algorithm: Algorithm) throws -> Bool {
133+
public static func verify(
134+
_ input: String, signature: Data, key: String, using algorithm: Algorithm
135+
) throws -> Bool {
127136
switch algorithm {
128137
case .p256:
129138
let publicKey = try P256.Signing.PublicKey(pemRepresentation: key)
@@ -154,7 +163,7 @@ extension DataProtocol {
154163
}
155164

156165
public func toHexString() -> String {
157-
return reduce("") {$0 + String(format: "%02x", $1)}
166+
return reduce("") { $0 + String(format: "%02x", $1) }
158167
}
159168
}
160169

@@ -168,7 +177,7 @@ extension Digest {
168177
}
169178

170179
public func toHexString() -> String {
171-
return reduce("") {$0 + String(format: "%02x", $1)}
180+
return reduce("") { $0 + String(format: "%02x", $1) }
172181
}
173182
}
174183

@@ -182,7 +191,7 @@ extension HashedAuthenticationCode {
182191
}
183192

184193
public func toHexString() -> String {
185-
return reduce("") {$0 + String(format: "%02x", $1)}
194+
return reduce("") { $0 + String(format: "%02x", $1) }
186195
}
187196
}
188197

@@ -192,6 +201,6 @@ extension Array where Element == UInt8 {
192201
}
193202

194203
public func toHexString() -> String {
195-
return reduce("") {$0 + String(format: "%02x", $1)}
204+
return reduce("") { $0 + String(format: "%02x", $1) }
196205
}
197206
}

Sources/Compute/Fanout/FanoutClient.swift

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// FanoutClient.swift
3-
//
3+
//
44
//
55
// Created by Andrew Barba on 2/1/23.
66
//
@@ -19,19 +19,24 @@ public struct FanoutClient: Sendable {
1919
"https://\(hostname)/service/\(service)/publish/"
2020
}
2121

22-
public init(service: String = Fastly.Environment.serviceId, token: String, hostname: String = "api.fastly.com") {
22+
public init(
23+
service: String = Fastly.Environment.serviceId, token: String,
24+
hostname: String = "api.fastly.com"
25+
) {
2326
self.service = service
2427
self.token = token
2528
self.hostname = hostname
2629
}
2730

2831
@discardableResult
2932
public func publish(_ message: PublishMessage) async throws -> FetchResponse {
30-
return try await fetch(publishEndpoint, .options(
31-
method: .post,
32-
body: .json(message),
33-
headers: ["Fastly-Key": token]
34-
))
33+
return try await fetch(
34+
publishEndpoint,
35+
.options(
36+
method: .post,
37+
body: .json(message),
38+
headers: ["Fastly-Key": token]
39+
))
3540
}
3641

3742
@discardableResult
@@ -43,7 +48,9 @@ public struct FanoutClient: Sendable {
4348
}
4449

4550
@discardableResult
46-
public func publish<T: Encodable>(_ value: T, encoder: JSONEncoder = .init(), to channel: String) async throws -> FetchResponse {
51+
public func publish<T: Encodable>(
52+
_ value: T, encoder: JSONEncoder = .init(), to channel: String
53+
) async throws -> FetchResponse {
4754
let content = try encoder.encode(value)
4855
return try await publish(content, to: channel)
4956
}
@@ -56,7 +63,9 @@ public struct FanoutClient: Sendable {
5663
}
5764

5865
@discardableResult
59-
public func publish(_ jsonObject: [String: Any], to channel: String) async throws -> FetchResponse {
66+
public func publish(_ jsonObject: [String: Any], to channel: String) async throws
67+
-> FetchResponse
68+
{
6069
let data = try JSONSerialization.data(withJSONObject: jsonObject)
6170
let content = String(data: data, encoding: .utf8)
6271
return try await publish(content, to: channel)

Sources/Compute/Fanout/FanoutMessage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// FanoutMessage.swift
3-
//
3+
//
44
//
55
// Created by Andrew Barba on 1/31/23.
66
//

0 commit comments

Comments
 (0)