@@ -8,7 +8,7 @@ import Foundation
88import ReadiumInternal
99
1010/// https://github.com/readium/architecture/tree/master/locators
11- public struct Locator : Hashable , CustomStringConvertible , Loggable {
11+ public struct Locator : Hashable , CustomStringConvertible , Loggable , Sendable {
1212 /// The URI of the resource that the Locator Object points to.
1313 public var href : String // URI
1414
@@ -36,7 +36,7 @@ public struct Locator: Hashable, CustomStringConvertible, Loggable {
3636 if json == nil {
3737 return nil
3838 }
39- guard let jsonObject = json as? [ String : Any ] ,
39+ guard let jsonObject = json as? JSONDictionary . Wrapped ,
4040 let href = jsonObject [ " href " ] as? String ,
4141 let type = jsonObject [ " type " ] as? String
4242 else {
@@ -82,7 +82,7 @@ public struct Locator: Hashable, CustomStringConvertible, Loggable {
8282 @available ( * , unavailable, message: " This may create an incorrect `Locator` if the link `type` is missing. Use `publication.locate(Link)` instead. " )
8383 public init ( link: Link ) { fatalError ( ) }
8484
85- public var json : [ String : Any ] {
85+ public var json : JSONDictionary . Wrapped {
8686 makeJSON ( [
8787 " href " : href,
8888 " type " : type,
@@ -120,7 +120,7 @@ public struct Locator: Hashable, CustomStringConvertible, Loggable {
120120 ///
121121 /// Properties are mutable for convenience when making a copy, but the `locations` property
122122 /// is immutable in `Locator`, for safety.
123- public struct Locations : Hashable , Loggable , WarningLogger {
123+ public struct Locations : Hashable , Loggable , WarningLogger , Sendable {
124124 /// Contains one or more fragment in the resource referenced by the `Locator`.
125125 public var fragments : [ String ]
126126 /// Progression in the resource expressed as a percentage (between 0 and 1).
@@ -131,15 +131,15 @@ public struct Locator: Hashable, CustomStringConvertible, Loggable {
131131 public var position : Int ?
132132
133133 /// Additional locations for extensions.
134- public var otherLocations : [ String : Any ] {
134+ public var otherLocations : JSONDictionary . Wrapped {
135135 get { otherLocationsJSON. json }
136136 set { otherLocationsJSON = JSONDictionary ( newValue) ?? JSONDictionary ( ) }
137137 }
138138
139139 // Trick to keep the struct equatable despite [String: Any]
140140 private var otherLocationsJSON : JSONDictionary
141141
142- public init ( fragments: [ String ] = [ ] , progression: Double ? = nil , totalProgression: Double ? = nil , position: Int ? = nil , otherLocations: [ String : Any ] = [ : ] ) {
142+ public init ( fragments: [ String ] = [ ] , progression: Double ? = nil , totalProgression: Double ? = nil , position: Int ? = nil , otherLocations: JSONDictionary . Wrapped = [ : ] ) {
143143 self . fragments = fragments
144144 self . progression = progression
145145 self . totalProgression = totalProgression
@@ -181,7 +181,7 @@ public struct Locator: Hashable, CustomStringConvertible, Loggable {
181181
182182 public var isEmpty : Bool { json. isEmpty }
183183
184- public var json : [ String : Any ] {
184+ public var json : JSONDictionary . Wrapped {
185185 makeJSON ( [
186186 " fragments " : encodeIfNotEmpty ( fragments) ,
187187 " progression " : encodeIfNotNil ( progression) ,
@@ -197,7 +197,7 @@ public struct Locator: Hashable, CustomStringConvertible, Loggable {
197197 public subscript( key: String ) -> Any ? { otherLocations [ key] }
198198 }
199199
200- public struct Text : Hashable , Loggable {
200+ public struct Text : Hashable , Loggable , Sendable {
201201 public var after : String ?
202202 public var before : String ?
203203 public var highlight : String ?
@@ -213,7 +213,7 @@ public struct Locator: Hashable, CustomStringConvertible, Loggable {
213213 self . init ( )
214214 return
215215 }
216- guard let jsonObject = json as? [ String : Any ] else {
216+ guard let jsonObject = json as? JSONDictionary . Wrapped else {
217217 warnings? . log ( " Invalid Text object " , model: Self . self, source: json)
218218 throw JSONError . parsing ( Self . self)
219219 }
@@ -234,7 +234,7 @@ public struct Locator: Hashable, CustomStringConvertible, Loggable {
234234 }
235235 }
236236
237- public var json : [ String : Any ] {
237+ public var json : JSONDictionary . Wrapped {
238238 makeJSON ( [
239239 " after " : encodeIfNotNil ( after) ,
240240 " before " : encodeIfNotNil ( before) ,
@@ -286,15 +286,15 @@ public extension Array where Element == Locator {
286286 /// Parses multiple JSON locators into an array of `Locator`.
287287 init ( json: Any ? , warnings: WarningLogger ? = nil ) {
288288 self . init ( )
289- guard let json = json as? [ Any ] else {
289+ guard let json = json as? [ JSONDictionary . Wrapped ] else {
290290 return
291291 }
292292
293293 let links = json. compactMap { try ? Locator ( json: $0, warnings: warnings) }
294294 append ( contentsOf: links)
295295 }
296296
297- var json : [ [ String : Any ] ] {
297+ var json : [ JSONDictionary . Wrapped ] {
298298 map ( \. json)
299299 }
300300}
@@ -320,7 +320,7 @@ public struct _LocatorCollection: Hashable {
320320 if json == nil {
321321 return nil
322322 }
323- guard let jsonObject = json as? [ String : Any ] else {
323+ guard let jsonObject = json as? JSONDictionary . Wrapped else {
324324 warnings? . log ( " Not a JSON object " , model: Self . self, source: json)
325325 return nil
326326 }
@@ -331,7 +331,7 @@ public struct _LocatorCollection: Hashable {
331331 )
332332 }
333333
334- public var json : [ String : Any ] {
334+ public var json : JSONDictionary . Wrapped {
335335 makeJSON ( [
336336 " metadata " : encodeIfNotEmpty ( metadata. json) ,
337337 " links " : encodeIfNotEmpty ( links. json) ,
@@ -348,7 +348,7 @@ public struct _LocatorCollection: Hashable {
348348 public var numberOfItems : Int ?
349349
350350 /// Additional properties for extensions.
351- public var otherMetadata : [ String : Any ] {
351+ public var otherMetadata : JSONDictionary . Wrapped {
352352 get { otherMetadataJSON. json }
353353 set { otherMetadataJSON = JSONDictionary ( newValue) ?? JSONDictionary ( ) }
354354 }
@@ -359,7 +359,7 @@ public struct _LocatorCollection: Hashable {
359359 public init (
360360 title: LocalizedStringConvertible ? = nil ,
361361 numberOfItems: Int ? = nil ,
362- otherMetadata: [ String : Any ] = [ : ]
362+ otherMetadata: JSONDictionary . Wrapped = [ : ]
363363 ) {
364364 localizedTitle = title? . localizedString
365365 self . numberOfItems = numberOfItems
@@ -379,7 +379,7 @@ public struct _LocatorCollection: Hashable {
379379 }
380380 }
381381
382- public var json : [ String : Any ] {
382+ public var json : JSONDictionary . Wrapped {
383383 makeJSON ( [
384384 " title " : encodeIfNotNil ( localizedTitle? . json) ,
385385 " numberOfItems " : encodeIfNotNil ( numberOfItems) ,
0 commit comments