200265fbd6
Adds a bundled local ASR model catalog for the macOS app with one-click Sherpa Qwen3 / SenseVoice downloads (pause/resume, inline actions) and a shared model storage directory used by MLX Qwen3. Fixes the light-mode sidebar material and makes the menu-bar icon follow the system appearance with a refreshed status mark. Renames the built product to OSGKeyboard.app. Bumps version to 0.5.2 (build 19).
33 lines
1.4 KiB
Swift
33 lines
1.4 KiB
Swift
// LocalASRInstalledManifestIO.swift
|
|
// OSGKeyboard · Shared
|
|
|
|
import Foundation
|
|
|
|
public enum LocalASRInstalledManifestIO {
|
|
|
|
public static func manifestURL(fileManager: FileManager = .default) -> URL {
|
|
let appSupport = fileManager.urls(for: .applicationSupportDirectory, in: .userDomainMask).first!
|
|
return appSupport
|
|
.appendingPathComponent("OSGKeyboard/LocalASRModels/installed-manifest.json")
|
|
}
|
|
|
|
public static func load(defaultModelId: String, fileManager: FileManager = .default) -> LocalASRInstalledManifest {
|
|
let url = manifestURL(fileManager: fileManager)
|
|
guard let data = try? Data(contentsOf: url),
|
|
let manifest = try? JSONDecoder().decode(LocalASRInstalledManifest.self, from: data) else {
|
|
return LocalASRInstalledManifest(selectedModelId: defaultModelId)
|
|
}
|
|
return manifest
|
|
}
|
|
|
|
public static func save(_ manifest: LocalASRInstalledManifest, fileManager: FileManager = .default) throws {
|
|
let url = manifestURL(fileManager: fileManager)
|
|
try fileManager.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
|
|
let encoder = JSONEncoder()
|
|
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
|
|
encoder.dateEncodingStrategy = .iso8601
|
|
let data = try encoder.encode(manifest)
|
|
try data.write(to: url, options: .atomic)
|
|
}
|
|
}
|