Skip to content

Commit 01a9ac5

Browse files
authored
Merge branch 'main' into hd-sco-0002
2 parents c394c2a + df161c8 commit 01a9ac5

File tree

97 files changed

+2221
-11516
lines changed

Some content is hidden

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

97 files changed

+2221
-11516
lines changed

Package.swift

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ import Foundation
99

1010
let defaultTraits: Set<String> = [
1111
"JSONSupport"
12-
13-
// Disabled due to a bug in SwiftPM with traits that pull in an external dependency.
14-
// Once that's fixed in Swift 6.2.x, we can enable these traits by default.
15-
// Open fix: https://github.com/swiftlang/swift-package-manager/pull/9136
16-
// "LoggingSupport",
17-
// "ReloadingSupport",
1812
]
1913

2014
var traits: Set<Trait> = [
@@ -146,9 +140,6 @@ let package = Package(
146140
"ConfigReaderTests/ConfigSnapshotReaderMethodTestsGet1.swift.gyb",
147141
"ConfigReaderTests/ConfigSnapshotReaderMethodTestsGet2.swift.gyb",
148142
"ConfigReaderTests/ConfigSnapshotReaderMethodTestsGet3.swift.gyb",
149-
],
150-
resources: [
151-
.copy("Resources")
152143
]
153144
),
154145

@@ -188,7 +179,11 @@ for target in package.targets {
188179
// https://docs.swift.org/compiler/documentation/diagnostics/nonisolated-nonsending-by-default/
189180
settings.append(.enableUpcomingFeature("NonisolatedNonsendingByDefault"))
190181

191-
settings.append(.enableExperimentalFeature("AvailabilityMacro=Configuration 1.0:macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0"))
182+
settings.append(
183+
.enableExperimentalFeature(
184+
"AvailabilityMacro=Configuration 1.0:macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0"
185+
)
186+
)
192187

193188
if enableAllCIFlags {
194189
// Ensure all public types are explicitly annotated as Sendable or not Sendable.

Sources/Configuration/ConfigKey.swift

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
///
2121
/// Keys can include additional context information that some providers use to
2222
/// refine value lookups or provide more specific results.
23+
@available(Configuration 1.0, *)
2324
public struct ConfigKey: Sendable {
2425

2526
/// The hierarchical components that make up this configuration key.
@@ -42,10 +43,23 @@ public struct ConfigKey: Sendable {
4243
self.components = components
4344
self.context = context
4445
}
46+
47+
/// Creates a new configuration key.
48+
/// - Parameters:
49+
/// - string: The string represenation of the key path, for example `"http.timeout"`.
50+
/// - context: Additional context information for the key.
51+
public init(_ string: String, context: [String: ConfigContextValue] = [:]) {
52+
self = DotSeparatorKeyDecoder.decode(string, context: context)
53+
}
4554
}
4655

56+
@available(Configuration 1.0, *)
4757
extension ConfigKey: Equatable {}
58+
59+
@available(Configuration 1.0, *)
4860
extension ConfigKey: Hashable {}
61+
62+
@available(Configuration 1.0, *)
4963
extension ConfigKey: Comparable {
5064
// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
5165
public static func < (lhs: ConfigKey, rhs: ConfigKey) -> Bool {
@@ -67,6 +81,7 @@ extension ConfigKey: Comparable {
6781
}
6882
}
6983

84+
@available(Configuration 1.0, *)
7085
extension ConfigKey: CustomStringConvertible {
7186
// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
7287
public var description: String {
@@ -79,6 +94,15 @@ extension ConfigKey: CustomStringConvertible {
7994
}
8095
}
8196

97+
@available(Configuration 1.0, *)
98+
extension ConfigKey: ExpressibleByStringLiteral {
99+
// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
100+
public init(stringLiteral value: String) {
101+
self = DotSeparatorKeyDecoder.decode(value, context: [:])
102+
}
103+
}
104+
105+
@available(Configuration 1.0, *)
82106
extension ConfigKey: ExpressibleByArrayLiteral {
83107
// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
84108
public init(arrayLiteral elements: String...) {
@@ -94,6 +118,7 @@ extension ConfigKey: ExpressibleByArrayLiteral {
94118
///
95119
/// Like relative keys, absolute keys consist of hierarchical components and
96120
/// optional context information.
121+
@available(Configuration 1.0, *)
97122
public struct AbsoluteConfigKey: Sendable {
98123

99124
/// The hierarchical components that make up this absolute configuration key.
@@ -118,8 +143,13 @@ public struct AbsoluteConfigKey: Sendable {
118143
}
119144
}
120145

146+
@available(Configuration 1.0, *)
121147
extension AbsoluteConfigKey: Equatable {}
148+
149+
@available(Configuration 1.0, *)
122150
extension AbsoluteConfigKey: Hashable {}
151+
152+
@available(Configuration 1.0, *)
123153
extension AbsoluteConfigKey: Comparable {
124154
// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
125155
public static func < (lhs: AbsoluteConfigKey, rhs: AbsoluteConfigKey) -> Bool {
@@ -141,6 +171,7 @@ extension AbsoluteConfigKey: Comparable {
141171
}
142172
}
143173

174+
@available(Configuration 1.0, *)
144175
extension AbsoluteConfigKey: CustomStringConvertible {
145176
// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
146177
public var description: String {
@@ -153,6 +184,7 @@ extension AbsoluteConfigKey: CustomStringConvertible {
153184
}
154185
}
155186

187+
@available(Configuration 1.0, *)
156188
extension AbsoluteConfigKey {
157189

158190
/// Creates a new absolute configuration key from a relative key.
@@ -162,6 +194,7 @@ extension AbsoluteConfigKey {
162194
}
163195
}
164196

197+
@available(Configuration 1.0, *)
165198
extension AbsoluteConfigKey? {
166199
/// Returns a new absolute configuration key by appending the given relative key.
167200
/// - Parameter relative: The relative configuration key to append to this key.
@@ -178,6 +211,7 @@ extension AbsoluteConfigKey? {
178211
}
179212
}
180213

214+
@available(Configuration 1.0, *)
181215
extension AbsoluteConfigKey {
182216
/// Returns a new absolute configuration key by prepending the given relative key.
183217
/// - Parameter prefix: The relative configuration key to prepend to this key.
@@ -201,6 +235,15 @@ extension AbsoluteConfigKey {
201235
}
202236
}
203237

238+
@available(Configuration 1.0, *)
239+
extension AbsoluteConfigKey: ExpressibleByStringLiteral {
240+
// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
241+
public init(stringLiteral value: String) {
242+
self = .init(DotSeparatorKeyDecoder.decode(value, context: [:]))
243+
}
244+
}
245+
246+
@available(Configuration 1.0, *)
204247
extension AbsoluteConfigKey: ExpressibleByArrayLiteral {
205248
// swift-format-ignore: AllPublicDeclarationsHaveDocumentation
206249
public init(arrayLiteral elements: String...) {

Sources/Configuration/ConfigProvider.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public protocol ConfigProvider: Sendable {
9797
/// - updatesHandler: The closure that processes the async sequence of value updates.
9898
/// - Throws: Provider-specific errors or errors thrown by the handler closure.
9999
/// - Returns: The value returned by the closure.
100-
func watchValue<Return>(
100+
func watchValue<Return: ~Copyable>(
101101
forKey key: AbsoluteConfigKey,
102102
type: ConfigType,
103103
updatesHandler: (
@@ -128,7 +128,7 @@ public protocol ConfigProvider: Sendable {
128128
/// - Parameter updatesHandler: The closure that processes the asynchronous sequence of snapshot updates.
129129
/// - Throws: Provider-specific errors or errors thrown by the handler closure.
130130
/// - Returns: The value returned by the closure.
131-
func watchSnapshot<Return>(
131+
func watchSnapshot<Return: ~Copyable>(
132132
updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshot, Never>) async throws -> Return
133133
) async throws -> Return
134134
}

Sources/Configuration/ConfigProviderHelpers.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extension ConfigProvider {
4343
/// - Returns: The value returned by the handler closure.
4444
/// - Throws: Provider-specific errors or errors thrown by the handler.
4545
nonisolated(nonsending)
46-
public func watchValueFromValue<Return>(
46+
public func watchValueFromValue<Return: ~Copyable>(
4747
forKey key: AbsoluteConfigKey,
4848
type: ConfigType,
4949
updatesHandler: (
@@ -85,7 +85,7 @@ extension ConfigProvider {
8585
/// - Parameter updatesHandler: The closure that processes the async sequence of snapshot updates.
8686
/// - Returns: The value returned by the handler closure.
8787
/// - Throws: Provider-specific errors or errors thrown by the handler.
88-
nonisolated(nonsending) public func watchSnapshotFromSnapshot<Return>(
88+
nonisolated(nonsending) public func watchSnapshotFromSnapshot<Return: ~Copyable>(
8989
updatesHandler: (ConfigUpdatesAsyncSequence<any ConfigSnapshot, Never>) async throws -> Return
9090
) async throws -> Return {
9191
let (stream, continuation) = AsyncStream<any ConfigSnapshot>

Sources/Configuration/ConfigReader+internalHelpers.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ extension ConfigReader {
637637
/// - updatesHandler: A closure that handles the stream of updates, emits `nil` when no value is found.
638638
/// - Throws: An error if the watch operation fails.
639639
/// - Returns: The value returned by the updates handler.
640-
internal func watchValue<Value: Sendable, Return>(
640+
internal func watchValue<Value: Sendable, Return: ~Copyable>(
641641
forKey key: ConfigKey,
642642
type: ConfigType,
643643
isSecret: Bool,
@@ -713,7 +713,7 @@ extension ConfigReader {
713713
/// - updatesHandler: A closure that handles the stream of updates, emits the default when no value is found.
714714
/// - Throws: An error if the watch operation fails.
715715
/// - Returns: The value returned by the updates handler.
716-
internal func watchValue<Value: Sendable, Return>(
716+
internal func watchValue<Value: Sendable, Return: ~Copyable>(
717717
forKey key: ConfigKey,
718718
type: ConfigType,
719719
isSecret: Bool,
@@ -790,7 +790,7 @@ extension ConfigReader {
790790
/// or the value cannot be unwrapped.
791791
/// - Throws: An error if the watch operation fails.
792792
/// - Returns: The value returned by the updates handler.
793-
internal func watchRequiredValue<Value: Sendable, Return>(
793+
internal func watchRequiredValue<Value: Sendable, Return: ~Copyable>(
794794
forKey key: ConfigKey,
795795
type: ConfigType,
796796
isSecret: Bool,

0 commit comments

Comments
 (0)