f42a812256
Replace the unclear CLM source, align release and privacy disclosures, complete third-party notices, and keep the expanded test suites deterministic for release validation.
329 lines
14 KiB
Swift
329 lines
14 KiB
Swift
// OpenSourceLicenseCatalog.swift
|
||
// OSGKeyboard · Main App
|
||
//
|
||
// Single source of truth for third-party components distributed by each
|
||
// OSGKeyboard platform. Consumed by Settings → About → Third-Party Licenses.
|
||
//
|
||
// Keep this list aligned with bundled resources and runtime downloads.
|
||
|
||
import Foundation
|
||
|
||
enum OpenSourceLicenseCatalog {
|
||
|
||
enum Platform: Hashable {
|
||
case iOS
|
||
case macOS
|
||
}
|
||
|
||
struct Entry: Identifiable, Hashable {
|
||
let id: String
|
||
let name: String
|
||
let licenseName: String
|
||
/// One-line explanation shown in the popup and above the full text.
|
||
let purpose: String
|
||
let url: URL?
|
||
/// Verbatim license body for the long-scroll disclosure page.
|
||
let licenseText: String
|
||
let platforms: Set<Platform>
|
||
}
|
||
|
||
/// Bundled libraries and runtime components referenced by the app.
|
||
private static let allEntries: [Entry] = [
|
||
.init(
|
||
id: "material-icons",
|
||
name: "Google Material Icons",
|
||
licenseName: "Apache-2.0",
|
||
purpose: "MaterialIcons-Regular.ttf bundled with the iOS app for Settings and navigation iconography.",
|
||
url: URL(string: "https://github.com/google/material-design-icons"),
|
||
licenseText: resourceText(
|
||
named: "LICENSE-MATERIAL-ICONS-APACHE",
|
||
fallback: apache2Text
|
||
),
|
||
platforms: [.iOS]
|
||
),
|
||
.init(
|
||
id: "librime-static",
|
||
name: "librime 1.17.0 + static dependencies",
|
||
licenseName: "BSD-3-Clause and others",
|
||
purpose: "Chinese typing runtime packaged by librime-xcframework 1.17.0-pack.1 (full pinyin and double pinyin). Includes complete notices for Boost, OpenCC, LevelDB, yaml-cpp, glog, marisa-trie, RapidJSON, Darts and other statically linked components.",
|
||
url: URL(string: "https://github.com/ghostflyby/librime-xcframework"),
|
||
licenseText: resourceText(
|
||
named: "LIBRIME-COMBINED-NOTICES",
|
||
fallback: bsd3Text
|
||
),
|
||
platforms: [.iOS]
|
||
),
|
||
.init(
|
||
id: "rime-pinyin-simp",
|
||
name: "rime-pinyin-simp",
|
||
licenseName: "Apache-2.0",
|
||
purpose: "Permissive Simplified-Chinese baseline dictionary used to generate OSGKeyboard's Rime Chinese typing lexicon.",
|
||
url: URL(string: "https://github.com/rime/rime-pinyin-simp"),
|
||
licenseText: resourceText(
|
||
named: "LICENSE-PINYIN-SIMP-APACHE",
|
||
fallback: apache2Text
|
||
),
|
||
platforms: [.iOS]
|
||
),
|
||
.init(
|
||
id: "jieba",
|
||
name: "Jieba",
|
||
licenseName: "MIT",
|
||
purpose: "Modern Simplified-Chinese words and frequency weights used by the generated Chinese typing dictionary.",
|
||
url: URL(string: "https://github.com/fxsjy/jieba"),
|
||
licenseText: resourceText(
|
||
named: "LICENSE-JIEBA-MIT",
|
||
fallback: mitText
|
||
),
|
||
platforms: [.iOS]
|
||
),
|
||
.init(
|
||
id: "phrase-pinyin-data",
|
||
name: "phrase-pinyin-data",
|
||
licenseName: "MIT",
|
||
purpose: "Phrase pronunciation data used to resolve polyphonic Chinese words in the typing dictionary.",
|
||
url: URL(string: "https://github.com/mozillazg/phrase-pinyin-data"),
|
||
licenseText: resourceText(
|
||
named: "LICENSE-PHRASE-PINYIN-DATA-MIT",
|
||
fallback: mitText
|
||
),
|
||
platforms: [.iOS]
|
||
),
|
||
.init(
|
||
id: "pinyin-data",
|
||
name: "pinyin-data",
|
||
licenseName: "MIT",
|
||
purpose: "Per-character Mandarin pronunciation fallback for generated Chinese dictionary entries.",
|
||
url: URL(string: "https://github.com/mozillazg/pinyin-data"),
|
||
licenseText: resourceText(
|
||
named: "LICENSE-PINYIN-DATA-MIT",
|
||
fallback: mitText
|
||
),
|
||
platforms: [.iOS]
|
||
),
|
||
.init(
|
||
id: "english-typing-lexicon",
|
||
name: "OSG English typing lexicon",
|
||
licenseName: "Project-owned notice",
|
||
purpose: "Offline English autocomplete, autocorrect, and next-word ranking (english_lexicon.bin, compiled from TSV). Log-scaled ranks derived from Peter Norvig’s public-domain n-gram counts; not GPL/LGPL dictionaries.",
|
||
url: URL(string: "https://github.com/hkgood/OSGKeyboard/blob/main/NOTICE-TYPING.md"),
|
||
licenseText: englishLexiconNoticeText,
|
||
platforms: [.iOS]
|
||
),
|
||
.init(
|
||
id: "osg-ai-tech-lexicon",
|
||
name: "OSG AI/technology speech lexicon",
|
||
licenseName: "MIT (data subset only)",
|
||
purpose: "Project-curated bilingual names and technology terms used by the iOS custom language model and Mac local-ASR prompt bias. This notice applies only to the lexicon data, not to OSGKeyboard as a whole.",
|
||
url: URL(
|
||
string: "https://github.com/hkgood/OSGKeyboard/tree/main/Scripts/lexicon/seeds"
|
||
),
|
||
licenseText: curatedLexiconNoticeText,
|
||
platforms: [.iOS, .macOS]
|
||
),
|
||
.init(
|
||
id: "mlx-audio-swift",
|
||
name: "mlx-audio-swift",
|
||
licenseName: "MIT",
|
||
purpose: "macOS local Qwen3 MLX streaming ASR (MLXAudioSTT), linked only in the Mac app target.",
|
||
url: URL(string: "https://github.com/Blaizzy/mlx-audio-swift"),
|
||
licenseText: mlxAudioMITText,
|
||
platforms: [.macOS]
|
||
),
|
||
.init(
|
||
id: "mlx-swift",
|
||
name: "mlx-swift 0.31.3",
|
||
licenseName: "MIT",
|
||
purpose: "Apple MLX tensor and neural-network runtime used transitively by mlx-audio-swift.",
|
||
url: URL(string: "https://github.com/ml-explore/mlx-swift"),
|
||
licenseText: mitLicenseText(copyright: "Copyright (c) 2023 ml-explore"),
|
||
platforms: [.macOS]
|
||
),
|
||
.init(
|
||
id: "mlx-swift-lm",
|
||
name: "mlx-swift-lm 3.31.3",
|
||
licenseName: "MIT",
|
||
purpose: "MLX language-model utilities used transitively by the Mac local speech runtime.",
|
||
url: URL(string: "https://github.com/ml-explore/mlx-swift-lm"),
|
||
licenseText: mitLicenseText(copyright: "Copyright (c) 2024 ml-explore"),
|
||
platforms: [.macOS]
|
||
),
|
||
.init(
|
||
id: "swift-transformers",
|
||
name: "swift-transformers 1.1.9",
|
||
licenseName: "Apache-2.0",
|
||
purpose: "Tokenizer and model utilities used transitively by mlx-audio-swift.",
|
||
url: URL(string: "https://github.com/huggingface/swift-transformers"),
|
||
licenseText: apacheLicenseText(copyright: "Copyright 2022 Hugging Face SAS."),
|
||
platforms: [.macOS]
|
||
),
|
||
.init(
|
||
id: "swift-huggingface",
|
||
name: "swift-huggingface 0.8.1",
|
||
licenseName: "Apache-2.0",
|
||
purpose: "Hugging Face Hub client used to download the user-selected Mac speech model.",
|
||
url: URL(string: "https://github.com/huggingface/swift-huggingface"),
|
||
licenseText: apacheLicenseText(copyright: "Copyright 2025 Hugging Face SAS."),
|
||
platforms: [.macOS]
|
||
),
|
||
.init(
|
||
id: "qwen3-asr-mlx",
|
||
name: "Qwen3-ASR 0.6B / 1.7B MLX 4-bit models",
|
||
licenseName: "Apache-2.0",
|
||
purpose: "Optional speech-model weights downloaded at runtime for on-device Mac transcription. The MLX conversions are published by mlx-community from Qwen/Qwen3-ASR.",
|
||
url: URL(string: "https://huggingface.co/collections/mlx-community/qwen3-asr"),
|
||
licenseText: qwenModelApacheText,
|
||
platforms: [.macOS]
|
||
),
|
||
]
|
||
|
||
static func entries(for platform: Platform) -> [Entry] {
|
||
allEntries.filter { $0.platforms.contains(platform) }
|
||
}
|
||
|
||
private static func resourceText(named name: String, fallback: String) -> String {
|
||
let bundles = Bundle.allFrameworks + Bundle.allBundles + [Bundle.main]
|
||
for bundle in bundles {
|
||
guard let url = bundle.url(forResource: name, withExtension: "txt"),
|
||
let text = try? String(contentsOf: url, encoding: .utf8),
|
||
!text.isEmpty else {
|
||
continue
|
||
}
|
||
return text
|
||
}
|
||
return fallback
|
||
}
|
||
|
||
// MARK: - License bodies
|
||
|
||
static let apache2Text = """
|
||
Apache License
|
||
Version 2.0, January 2004
|
||
http://www.apache.org/licenses/
|
||
|
||
Licensed under the Apache License, Version 2.0 (the "License");
|
||
you may not use this file except in compliance with the License.
|
||
You may obtain a copy of the License at
|
||
|
||
http://www.apache.org/licenses/LICENSE-2.0
|
||
|
||
Unless required by applicable law or agreed to in writing, software
|
||
distributed under the License is distributed on an "AS IS" BASIS,
|
||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||
implied. See the License for the specific language governing
|
||
permissions and limitations under the License.
|
||
"""
|
||
|
||
static let mitText = """
|
||
MIT License
|
||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||
of this software and associated documentation files (the "Software"), to deal
|
||
in the Software without restriction, including without limitation the rights
|
||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
copies of the Software, and to permit persons to whom the Software is
|
||
furnished to do so, subject to the following conditions:
|
||
|
||
The above copyright notice and this permission notice shall be included in all
|
||
copies or substantial portions of the Software.
|
||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||
SOFTWARE.
|
||
"""
|
||
|
||
static let mlxAudioMITText = """
|
||
MIT License
|
||
|
||
Copyright (c) 2025 Prince Canuma
|
||
|
||
\(mitText.components(separatedBy: "\n").dropFirst(2).joined(separator: "\n"))
|
||
"""
|
||
|
||
static let curatedLexiconNoticeText = """
|
||
OSG AI/technology speech lexicon
|
||
|
||
Copyright (c) OSGKeyboard contributors
|
||
|
||
The phrase list under Scripts/lexicon/seeds/ai_tech_brands_seed.tsv and
|
||
its generated CustomLanguageModel phrase data are made available under
|
||
the MIT License below. This grant covers only that curated data subset.
|
||
OSGKeyboard itself remains source-available under the repository LICENSE
|
||
and is not distributed under the MIT License.
|
||
|
||
\(mitText.components(separatedBy: "\n").dropFirst(2).joined(separator: "\n"))
|
||
"""
|
||
|
||
static let qwenModelApacheText = """
|
||
mlx-community/Qwen3-ASR-0.6B-4bit and Qwen3-ASR-1.7B-4bit
|
||
|
||
Converted to MLX format from Qwen/Qwen3-ASR using mlx-audio 0.3.1.
|
||
Both model cards declare license: apache-2.0. Model weights are optional
|
||
runtime downloads and are not stored in the OSGKeyboard repository.
|
||
|
||
\(apacheLicenseText(copyright: "Copyright Qwen and model contributors."))
|
||
"""
|
||
|
||
private static func mitLicenseText(copyright: String) -> String {
|
||
"""
|
||
MIT License
|
||
|
||
\(copyright)
|
||
|
||
\(mitText.components(separatedBy: "\n").dropFirst(2).joined(separator: "\n"))
|
||
"""
|
||
}
|
||
|
||
private static func apacheLicenseText(copyright: String) -> String {
|
||
let fullLicense = resourceText(
|
||
named: "LICENSE-PINYIN-SIMP-APACHE",
|
||
fallback: apache2Text
|
||
)
|
||
return "\(copyright)\n\n\(fullLicense)"
|
||
}
|
||
|
||
static let englishLexiconNoticeText = """
|
||
OSG English typing lexicon (project-owned notice)
|
||
|
||
english_lexicon.bin (compiled from english_lexicon.tsv / english_bigrams.tsv)
|
||
is the mmap ranking table for offline English autocomplete, autocorrect,
|
||
and next-word prediction.
|
||
|
||
Unigram ranks and truncated bigrams are derived from Peter Norvig’s
|
||
public-domain n-gram count files (https://norvig.com/ngrams/). OSGKeyboard
|
||
does not ship the raw corpus. Relative frequency values are log-scaled
|
||
ordering weights, not verbatim Google counts.
|
||
|
||
See NOTICE-TYPING.md in the OSGKeyboard repository for the full typing
|
||
keyboard attribution map (Chinese Rime stack vs English data).
|
||
"""
|
||
|
||
static let bsd3Text = """
|
||
BSD 3-Clause License
|
||
|
||
Copyright (c) 2014, RIME Developers
|
||
All rights reserved.
|
||
|
||
Redistribution and use in source and binary forms, with or without
|
||
modification, are permitted provided that the following conditions are met:
|
||
|
||
1. Redistributions of source code must retain the above copyright notice,
|
||
this list of conditions and the following disclaimer.
|
||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||
this list of conditions and the following disclaimer in the documentation
|
||
and/or other materials provided with the distribution.
|
||
3. Neither the name of the copyright holder nor the names of its contributors
|
||
may be used to endorse or promote products derived from this software
|
||
without specific prior written permission.
|
||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||
AND ANY EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DAMAGES ARISING IN ANY WAY
|
||
OUT OF THE USE OF THIS SOFTWARE.
|
||
"""
|
||
}
|