v1.7.0
What's Changed
- Refactor the basic data type from String to Unicode.Scalar. by @ShikiSuen in #82
- Add Chopper and PinyinTrie. by @ShikiSuen in #83
差異總結(v1.6.0 → v1.7.0)
重大變更(可能造成不相容)
- 公開 API 改以
Unicode.Scalar為核心型別:Tekkon.allowedConsonants/allowedSemivowels/allowedVowels/allowedIntonations/allowedPhonabets改為[Unicode.Scalar](原為[String])。Tekkon.Phonabet以Unicode.Scalar儲存值;新增init(_ input: Unicode.Scalar),value由scalarValue計算。- 多數內部處理與對外方法改以
Unicode.Scalar參數(如translate、handleETen26/…/handleAlvinLiu、receiveKey的部分多載),原以String傳入注音符號的路徑有所調整。
Tekkon.Composer多數屬性改為public internal(set):consonant、semivowel、vowel、intonation、romajiBuffer、parser等對外唯讀,需改用對應方法變更狀態。- 移除或取代舊有以
String作為單個注音輸入的介面:改用receiveKey(fromPhonabet: Unicode.Scalar?)等新介面。
新功能與能力
- 新增
Chopper與PinyinTrie(#83):PinyinTrie:提供chop(…)字首切分與deductChoppedPinyinToZhuyin(…)由拼音切片推導注音候選,支援類似智能簡拼切分的能力。
- 注音/拼音處理的資料流更一致,拼音模式下的簡拼切分與候選推導更容易擴充。
修正
- 修正
deductChoppedPinyinToZhuyin()的處理問題。 - 修正一處並行/併發相關問題。
- 移除未使用的
parentID。
重構與維護性提升
- 大幅重構核心型別由
String→Unicode.Scalar(#82),降低字串切割與比較成本,避免多字元誤用。 - 整理並合併
Chopper相關 API 至單一檔案,結構更清晰。 - 更新程式碼格式化與靜態檢查設定:移除有問題的
SwiftLint設定、更新SwiftFormat設定。
授權與文件
- 授權自 MIT-NTL 變更為 LGPL v3.0 or later,新增
CUSTOM_LGPLv3_EXCEPTION.md,README 同步更新並標明可商業雙授權選項。 LICENSE檔更新,README 說明更清楚(包括開發者與多語版本註記)。
建置與環境
- Swift Tools 版本由 5.3 提升至 5.7(
Package.swift)。 - 其他平台需求不變(macOS 10.11+)。
測試
- 測試重構與精簡:大量舊的鍵位測試檔移除(
KeyTest_*.swift),新增與整併為:Tests/TekkonTests/TekkonTests_Arrangements.swiftTests/TekkonTests/TekkonTests_Basic.swiftTests/TekkonTests/TekkonTests_Pinyin.swift(原 BasicTests.swift 更名)Tests/TestAssets_Tekkon/Tekkon_TestData.swift(集中測資)
- 總測資結構更集中,維護成本降低。
雜項
- 更新版權年份。
.editorconfig、.gitignore等輕微調整。
升級指引摘要
- 若外部程式碼使用到公開常數陣列或依賴
String型別的注音單元,需改以Unicode.Scalar處理。 - 直接寫入
Composer的欄位需改用對應的輸入路徑(receiveKey/receiveSequence等),或依新唯讀規則調整。 - 若有自建的拼音切分與注音推導,建議改用
PinyinTrie的chop與deductChoppedPinyinToZhuyin。
Full Changelog: v1.6.0...v1.7.0