-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-maki-reference
- Loading branch information
Showing
18 changed files
with
288 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
binary "https://api.mapbox.com/downloads/v2/carthage/search-core-sdk/MapboxCoreSearch.xcframework.json" == 2.0.0-alpha.14 | ||
binary "https://api.mapbox.com/downloads/v2/carthage/mapbox-common/MapboxCommon.json" == 24.0.0 | ||
binary "https://api.mapbox.com/downloads/v2/carthage/mapbox-common/MapboxCommon.json" == 24.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
binary "https://api.mapbox.com/downloads/v2/carthage/mapbox-common/MapboxCommon.json" "24.0.0" | ||
binary "https://api.mapbox.com/downloads/v2/carthage/mapbox-common/MapboxCommon.json" "24.2.0" | ||
binary "https://api.mapbox.com/downloads/v2/carthage/search-core-sdk/MapboxCoreSearch.xcframework.json" "2.0.0-alpha.14" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 53 additions & 4 deletions
57
Sources/MapboxSearch/InternalAPI/CoreSearchEngineStatics.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,60 @@ | ||
import Foundation | ||
|
||
enum CoreSearchEngineStatics { | ||
static func createTilesetDescriptor(dataset: String, version: String) -> MapboxCommon.TilesetDescriptor { | ||
CoreSearchEngine.createTilesetDescriptor(forDataset: dataset, version: version) | ||
enum Constants { | ||
static let delimiter = "_" | ||
} | ||
|
||
static func createPlacesTilesetDescriptor(dataset: String, version: String) -> MapboxCommon.TilesetDescriptor { | ||
CoreSearchEngine.createPlacesTilesetDescriptor(forDataset: dataset, version: version) | ||
static func createTilesetDescriptor(dataset: String, version: String, language: String? = nil) -> MapboxCommon | ||
.TilesetDescriptor { | ||
let identifier: String | ||
if let language { | ||
if ISOLanguages.contains(language: language) { | ||
identifier = dataset + Constants.delimiter + language | ||
} else { | ||
_Logger.searchSDK | ||
.warning( | ||
"Provided language code '\(language)' for tileset is non-ISO. Dataset '\(dataset)' without language will be used." | ||
) | ||
identifier = dataset | ||
} | ||
} else { | ||
identifier = dataset | ||
} | ||
return CoreSearchEngine.createTilesetDescriptor(forDataset: identifier, version: version) | ||
} | ||
|
||
static func createPlacesTilesetDescriptor(dataset: String, version: String, language: String? = nil) -> MapboxCommon | ||
.TilesetDescriptor { | ||
let identifier: String | ||
if let language { | ||
if ISOLanguages.contains(language: language) { | ||
identifier = dataset + Constants.delimiter + language | ||
} else { | ||
_Logger.searchSDK | ||
.warning( | ||
"Provided language code '\(language)' for places tileset is non-ISO. Dataset '\(dataset)' without language will be used." | ||
) | ||
identifier = dataset | ||
} | ||
} else { | ||
identifier = dataset | ||
} | ||
return CoreSearchEngine.createPlacesTilesetDescriptor(forDataset: identifier, version: version) | ||
} | ||
} | ||
|
||
enum ISOLanguages { | ||
static func contains(language: String) -> Bool { | ||
var validLanguage: Bool | ||
if #available(iOS 16, *) { | ||
validLanguage = Locale.LanguageCode.isoLanguageCodes | ||
.map(\.identifier) | ||
.contains(language) | ||
} else { | ||
validLanguage = Locale.isoLanguageCodes | ||
.contains(language) | ||
} | ||
return validLanguage | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Sources/MapboxSearch/InternalAPI/Offline/CoreOfflineIndexChangeEventType.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright © 2024 Mapbox. All rights reserved. | ||
|
||
import Foundation | ||
|
||
extension CoreOfflineIndexChangeEventType: CustomDebugStringConvertible { | ||
public var debugDescription: String { | ||
switch self { | ||
case .added: | ||
return "Added" | ||
case .removed: | ||
return "Removed" | ||
case .updated: | ||
return "Updated" | ||
@unknown default: | ||
return "Unknown" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Sources/MapboxSearch/PublicAPI/Offline/OfflineIndexObserver.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright © 2024 Mapbox. All rights reserved. | ||
|
||
import Foundation | ||
|
||
class OfflineIndexObserver: CoreOfflineIndexObserver { | ||
enum Types { | ||
typealias indexChangedBlock = (CoreOfflineIndexChangeEvent) -> Void | ||
typealias errorBlock = (CoreOfflineIndexError) -> Void | ||
} | ||
|
||
private var onIndexChangedBlock: Types.indexChangedBlock | ||
private var onErrorBlock: Types.errorBlock | ||
|
||
init( | ||
onIndexChangedBlock: @escaping Types.indexChangedBlock = { _ in }, | ||
onErrorBlock: @escaping Types.errorBlock = { _ in } | ||
) { | ||
self.onIndexChangedBlock = onIndexChangedBlock | ||
self.onErrorBlock = onErrorBlock | ||
} | ||
|
||
func onIndexChanged(for event: CoreOfflineIndexChangeEvent) { | ||
onIndexChangedBlock(event) | ||
} | ||
|
||
func onError(forError error: CoreOfflineIndexError) { | ||
onErrorBlock(error) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.