From 8e5826d148348238eca570397938702a8339723a Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Tue, 2 Sep 2025 10:32:56 -0700 Subject: [PATCH] StructuredQueries 0.16 support Just a minor change to the Reminders demo, which defined a custom query representation. --- .../xcshareddata/swiftpm/Package.resolved | 4 +- Examples/Reminders/Helpers.swift | 40 ++++++++++++------- Package.resolved | 18 ++++----- Package.swift | 2 +- 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/Examples/Examples.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Examples/Examples.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index bf1fd701..adf158ba 100644 --- a/Examples/Examples.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Examples/Examples.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -123,8 +123,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-structured-queries", "state" : { - "revision" : "e53cd5c87b31eeba77a801eec9a7e82c6d7faaab", - "version" : "0.15.0" + "revision" : "14f79c6dad72e385c564c66dbe333522a11eaa48", + "version" : "0.16.0" } }, { diff --git a/Examples/Reminders/Helpers.swift b/Examples/Reminders/Helpers.swift index 97fdea7f..6b61b4e0 100644 --- a/Examples/Reminders/Helpers.swift +++ b/Examples/Reminders/Helpers.swift @@ -2,26 +2,18 @@ import SharingGRDB import SwiftUI extension Color { - public struct HexRepresentation: QueryBindable, QueryRepresentable { + public struct HexRepresentation: QueryRepresentable { public var queryOutput: Color - public var queryBinding: QueryBinding { - guard let hexValue else { - struct InvalidColor: Error {} - return .invalid(InvalidColor()) - } - return .int(hexValue) - } public init(queryOutput: Color) { self.queryOutput = queryOutput } - public init(decoder: inout some QueryDecoder) throws { - let hex = try Int(decoder: &decoder) + public init(hexValue: Int64) { self.init( queryOutput: Color( - red: Double((hex >> 24) & 0xFF) / 0xFF, - green: Double((hex >> 16) & 0xFF) / 0xFF, - blue: Double((hex >> 8) & 0xFF) / 0xFF, - opacity: Double(hex & 0xFF) / 0xFF + red: Double((hexValue >> 24) & 0xFF) / 0xFF, + green: Double((hexValue >> 16) & 0xFF) / 0xFF, + blue: Double((hexValue >> 8) & 0xFF) / 0xFF, + opacity: Double(hexValue & 0xFF) / 0xFF ) ) } @@ -36,3 +28,23 @@ extension Color { } } } + +extension Color.HexRepresentation: QueryBindable { + public init?(queryBinding: StructuredQueriesCore.QueryBinding) { + guard case .int(let hexValue) = queryBinding else { return nil } + self.init(hexValue: hexValue) + } + public var queryBinding: QueryBinding { + guard let hexValue else { + struct InvalidColor: Error {} + return .invalid(InvalidColor()) + } + return .int(hexValue) + } +} + +extension Color.HexRepresentation: QueryDecodable { + public init(decoder: inout some QueryDecoder) throws { + try self.init(hexValue: Int64(decoder: &decoder)) + } +} diff --git a/Package.resolved b/Package.resolved index a28c3596..40558cc0 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "96fc55dd49af697ce0e0bf306c46a68e5c589a1cabb04749621327771c159fb5", + "originHash" : "bf7f65a97bc0744011b5a84033dae2413dabad76028eccac59d6837fd798cf8a", "pins" : [ { "identity" : "combine-schedulers", @@ -42,8 +42,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-concurrency-extras", "state" : { - "revision" : "82a4ae7170d98d8538ec77238b7eb8e7199ef2e8", - "version" : "1.3.1" + "revision" : "5a3825302b1a0d744183200915a47b508c828e6f", + "version" : "1.3.2" } }, { @@ -96,8 +96,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-perception", "state" : { - "revision" : "7d3509c7f4de78ad3eb3d804e036fb62e3585141", - "version" : "2.0.5" + "revision" : "59b00dfa5548b5b91ebbda6d94d6328d82ca00fe", + "version" : "2.0.6" } }, { @@ -105,8 +105,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-sharing", "state" : { - "revision" : "530c98ac2c3e393615616bd6d8fc604600c99f6f", - "version" : "2.7.2" + "revision" : "aaf605733bd93126d1a3658b4021146d95c94cb6", + "version" : "2.7.3" } }, { @@ -123,8 +123,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-structured-queries", "state" : { - "revision" : "e53cd5c87b31eeba77a801eec9a7e82c6d7faaab", - "version" : "0.15.0" + "revision" : "14f79c6dad72e385c564c66dbe333522a11eaa48", + "version" : "0.16.0" } }, { diff --git a/Package.swift b/Package.swift index 41c5f830..c664a0ca 100644 --- a/Package.swift +++ b/Package.swift @@ -39,7 +39,7 @@ let package = Package( .package(url: "https://github.com/pointfreeco/xctest-dynamic-overlay", from: "1.5.0"), .package(url: "https://github.com/pointfreeco/swift-sharing", from: "2.3.0"), .package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.18.4"), - .package(url: "https://github.com/pointfreeco/swift-structured-queries", from: "0.15.0"), + .package(url: "https://github.com/pointfreeco/swift-structured-queries", from: "0.16.0"), ], targets: [ .target(