Share Vault, persistence, SSH/SFTP, forwarding, and SwiftUI components across platforms. Add mobile editors, terminal input, standalone Assistant, Metrics navigation, transfers, and a unified Live Activity with host system icons. Validation: 35 iOS tests and 100 focused macOS tests pass; formatting and zh-Hans checks pass. The full macOS run reports 14 issues in the documented timing, Keychain, and popover suites. Remaining Assistant tool and CloudKit work is tracked in Memory/MOBILE_ROLLOUT.md.
37 lines
1.3 KiB
Swift
37 lines
1.3 KiB
Swift
import Foundation
|
|
import TermindDomain
|
|
|
|
public nonisolated struct LinuxDistributionIconEntry: Codable, Hashable, Sendable {
|
|
public var title: String
|
|
public var asset: String
|
|
public var ids: [String]
|
|
public var hex: String
|
|
}
|
|
|
|
public nonisolated struct LinuxDistributionIconCatalog: Codable, Sendable {
|
|
public var entries: [LinuxDistributionIconEntry]
|
|
|
|
private static let bundled: Self? = {
|
|
guard
|
|
let url = Bundle.main.url(
|
|
forResource: "LinuxDistributionIcons", withExtension: "json"
|
|
), let data = try? Data(contentsOf: url)
|
|
else { return nil }
|
|
return try? JSONDecoder().decode(Self.self, from: data)
|
|
}()
|
|
|
|
public static func entry(for distribution: DetectedDistribution?) -> LinuxDistributionIconEntry? {
|
|
guard let distribution, let catalog = bundled else { return nil }
|
|
return catalog.entry(matching: distribution)
|
|
}
|
|
|
|
public func entry(matching distribution: DetectedDistribution) -> LinuxDistributionIconEntry? {
|
|
let byID = Dictionary(
|
|
entries.flatMap { entry in entry.ids.map { ($0.lowercased(), entry) } },
|
|
uniquingKeysWith: { first, _ in first }
|
|
)
|
|
if let exact = byID[distribution.id] { return exact }
|
|
return distribution.likeIDs.lazy.compactMap { byID[$0] }.first
|
|
}
|
|
}
|