feat: enable InternalImportsByDefault feature flag

This commit is contained in:
Miwa / Ensan
2025-06-15 19:30:51 +09:00
parent 4d4e54691c
commit 543f6d93be
16 changed files with 53 additions and 50 deletions

View File

@ -7,6 +7,7 @@ import Foundation
let swiftSettings: [SwiftSetting] = [
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("MemberImportVisibility"),
.enableUpcomingFeature("InternalImportsByDefault"),
.interoperabilityMode(.Cxx, .when(traits: ["Zenzai"]))
]

View File

@ -2,8 +2,8 @@ import KanaKanjiConverterModuleWithDefaultDictionary
import ArgumentParser
@main
public struct Anco: AsyncParsableCommand {
public static let configuration = CommandConfiguration(
struct Anco: AsyncParsableCommand {
static let configuration = CommandConfiguration(
abstract: "Anco is A(zooKey) Kana-Ka(n)ji (co)nverter",
subcommands: [
Subcommands.Run.self,
@ -17,5 +17,5 @@ public struct Anco: AsyncParsableCommand {
defaultSubcommand: Subcommands.Run.self
)
public init() {}
init() {}
}

View File

@ -74,9 +74,9 @@ extension Subcommands {
if stable {
result.execution_time = 0
result.timestamp = 0
result.items.mutatingForeach {
result.items.mutatingForEach {
$0.entropy = Double(Int($0.entropy * 10)) / 10
$0.outputs.mutatingForeach {
$0.outputs.mutatingForEach {
$0.score = Double(Int($0.score))
}
}

View File

@ -69,8 +69,8 @@ extension Subcommands {
if stable {
result.execution_time = 0
result.timestamp = 0
result.items.mutatingForeach {
$0.outputs.mutatingForeach {
result.items.mutatingForEach {
$0.outputs.mutatingForEach {
$0.score = Double(Int($0.score))
}
}

View File

@ -6,7 +6,7 @@
// Copyright © 2022 ensan. All rights reserved.
//
import Foundation
public import Foundation
public struct ConvertRequestOptions: Sendable {
///

View File

@ -7,7 +7,7 @@
//
import Algorithms
import Foundation
package import Foundation
import SwiftUtils
import EfficientNGram
@ -19,7 +19,7 @@ import EfficientNGram
}
private var converter = Kana2Kanji()
public static let defaultSpecialCandidateProviders: [any SpecialCandidateProvider] = [
nonisolated public static let defaultSpecialCandidateProviders: [any SpecialCandidateProvider] = [
CalendarSpecialCandidateProvider(),
EmailAddressSpecialCandidateProvider(),
UnicodeSpecialCandidateProvider(),
@ -582,7 +582,7 @@ import EfficientNGram
result.append(contentsOf: clause_candidates)
result.append(contentsOf: word_candidates)
result.mutatingForeach { item in
result.mutatingForEach { item in
item.withActions(self.getAppropriateActions(item))
item.parseTemplate()
}

View File

@ -125,7 +125,7 @@ public final class DicdataStore {
self.closeKeyboard()
case .importOSUserDict(let dicdata), .importDynamicUserDict(let dicdata):
self.dynamicUserDict = dicdata
self.dynamicUserDict.mutatingForeach {
self.dynamicUserDict.mutatingForEach {
$0.metadata = .isFromUserDictionary
}
case let .forgetMemory(candidate):
@ -258,12 +258,12 @@ public final class DicdataStore {
data.append(contentsOf: LOUDS.getDataForLoudstxt3(identifier + "\(key)", indices: value.map {$0 & 2047}, cache: self.loudstxts[identifier + "\(key)"], option: self.requestOptions))
}
if identifier == "memory" {
data.mutatingForeach {
data.mutatingForEach {
$0.metadata = .isLearned
}
}
if identifier == "user" {
data.mutatingForeach {
data.mutatingForEach {
$0.metadata = .isFromUserDictionary
}
}

View File

@ -6,7 +6,7 @@
// Copyright © 2020 ensan. All rights reserved.
//
import Foundation
package import Foundation
import SwiftUtils
extension LOUDS {

View File

@ -6,7 +6,7 @@
// Copyright © 2023 ensan. All rights reserved.
//
import Foundation
public import Foundation
import SwiftUtils
/// `TextReplacer`

View File

@ -6,7 +6,7 @@
// Copyright © 2020 ensan. All rights reserved.
//
import Foundation
public import Foundation
import SwiftUtils
public struct TemplateData: Codable, Sendable {

View File

@ -1,4 +1,4 @@
import Foundation
package import Foundation
import SwiftUtils
import EfficientNGram

View File

@ -1,5 +1,5 @@
@_exported import KanaKanjiConverterModule
import Foundation
@_exported public import KanaKanjiConverterModule
public import Foundation
public extension ConvertRequestOptions {
static func withDefaultDictionary(

View File

@ -5,20 +5,20 @@
// Created by ensan on 2023/04/30.
//
import Algorithms
package import Algorithms
import Foundation
public extension Sequence {
package extension Sequence {
/// Returns a sequence that contains the elements of this sequence followed by the elements of the given sequence.
/// - Parameters:
/// - sequence: A sequence of elements to chain.
/// - Returns: A sequence that contains the elements of this sequence followed by the elements of the given sequence.
@inlinable func chained<S: Sequence<Element>>(_ sequence: S) -> Chain2Sequence<Self, S> {
func chained<S: Sequence<Element>>(_ sequence: S) -> Chain2Sequence<Self, S> {
chain(self, sequence)
}
}
public extension Collection {
package extension Collection {
/// Returns a `Set` containing the elements of this sequence with transformed values.
/// - Parameters:
/// - transform: A closure that transforms each element of this sequence into a value that can be hashed.
@ -60,18 +60,18 @@ public extension Collection {
}
}
public extension MutableCollection {
package extension MutableCollection {
/// Calls the given closure with a pointer to the array's mutable contiguous storage.
/// - Parameter
/// - transform: A closure that takes a pointer to the array's mutable contiguous storage.
@inlinable mutating func mutatingForeach(transform closure: (inout Element) throws -> Void) rethrows {
@inlinable mutating func mutatingForEach(transform closure: (inout Element) throws -> Void) rethrows {
for index in self.indices {
try closure(&self[index])
}
}
}
public extension Collection {
package extension Collection {
/// Returns a SubSequence containing the elements of this sequence up to the first element that does not satisfy the given predicate.
/// - Parameters:
/// - condition: A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element should be included.
@ -85,7 +85,7 @@ public extension Collection {
}
}
public extension Collection where Self.Element: Equatable {
package extension Collection where Self.Element: Equatable {
/// Returns a Bool value indicating whether the collection has the given prefix.
/// - Parameters:
/// - prefix: A collection to search for at the start of this collection.

View File

@ -8,7 +8,7 @@
import Foundation
public enum CharacterUtils {
package enum CharacterUtils {
///
private static let kogakiKana: Set<Character> = [
"", "", "", "", "", "", "", "", "", "", "", "",
@ -26,12 +26,12 @@ public enum CharacterUtils {
}
/// (a-z, A-Z)
@inlinable public static func isRomanLetter(_ character: Character) -> Bool {
@inlinable package static func isRomanLetter(_ character: Character) -> Bool {
character.isASCII && character.isCased
}
///
public static func kogaki(_ character: Character) -> Character {
package static func kogaki(_ character: Character) -> Character {
switch character {
case "": return ""
case "": return ""
@ -62,7 +62,7 @@ public enum CharacterUtils {
}
///
public static func ogaki(_ character: Character) -> Character {
package static func ogaki(_ character: Character) -> Character {
switch character {
case "": return ""
case "": return ""
@ -93,11 +93,11 @@ public enum CharacterUtils {
}
///
public static func isDakuten(_ character: Character) -> Bool {
package static func isDakuten(_ character: Character) -> Bool {
dakutenKana.contains(character)
}
///
public static func dakuten(_ character: Character) -> Character {
package static func dakuten(_ character: Character) -> Character {
switch character {
case"": return ""
case"": return ""
@ -145,7 +145,7 @@ public enum CharacterUtils {
}
}
///
public static func mudakuten(_ character: Character) -> Character {
package static func mudakuten(_ character: Character) -> Character {
switch character {
case"": return ""
case"": return ""
@ -193,14 +193,14 @@ public enum CharacterUtils {
}
}
///
public static func isHandakuten(_ character: Character) -> Bool {
package static func isHandakuten(_ character: Character) -> Bool {
[
"", "", "", "", "",
"", "", "", "", ""
].contains(character)
}
///
public static func handakuten(_ character: Character) -> Character {
package static func handakuten(_ character: Character) -> Character {
switch character {
case"": return ""
case"": return ""
@ -216,7 +216,7 @@ public enum CharacterUtils {
}
}
///
public static func muhandakuten(_ character: Character) -> Character {
package static func muhandakuten(_ character: Character) -> Character {
switch character {
case"": return ""
case"": return ""
@ -233,7 +233,7 @@ public enum CharacterUtils {
}
///
public static func requestChange(_ character: Character) -> String {
package static func requestChange(_ character: Character) -> String {
if character.isLowercase {
return character.uppercased()
}
@ -285,7 +285,7 @@ public enum CharacterUtils {
}
}
public extension Character {
package extension Character {
/// Returns the Katakanized version of the character.
@inlinable func toKatakana() -> Character {
if self.unicodeScalars.count != 1 {

View File

@ -6,14 +6,14 @@
// Copyright © 2022 ensan. All rights reserved.
//
import Foundation
package import Foundation
extension Data {
package extension Data {
/// Converts this data to an array of the given type.
/// - Parameter:
/// - type: The type to convert this data to.
/// - Returns: An array of the given type.
@inlinable public func toArray<T>(of type: T.Type) -> [T] {
func toArray<T>(of type: T.Type) -> [T] {
self.withUnsafeBytes {pointer -> [T] in
Array(
UnsafeBufferPointer(

View File

@ -8,16 +8,16 @@
import Foundation
public extension StringProtocol {
package extension StringProtocol {
///
/// - note: `false`
@inlinable
@usableFromInline
var onlyRomanAlphabetOrNumber: Bool {
!isEmpty && range(of: "[^a-zA-Z0-9]", options: .regularExpression) == nil
}
///
/// - note: `false`
@inlinable
@usableFromInline
var onlyRomanAlphabet: Bool {
!isEmpty && range(of: "[^a-zA-Z]", options: .regularExpression) == nil
}
@ -35,20 +35,21 @@ public extension StringProtocol {
}
///
/// - note: `false`
@inlinable
@usableFromInline
var isEnglishSentence: Bool {
!isEmpty && range(of: "[^0-9a-zA-Z\n !'_<>\\[\\]{}*@`\\^|~=\"#$%&\\+\\(\\),\\-\\./:;?\\\\]", options: .regularExpression) == nil
}
///
@inlinable
@usableFromInline
var isKana: Bool {
!isEmpty && range(of: "[^ぁ-ゖァ-ヶ]", options: .regularExpression) == nil
}
/// Returns a String value in which Hiraganas are all converted to Katakana.
/// - Returns: A String value in which Hiraganas are all converted to Katakana.
@inlinable func toKatakana() -> String {
@usableFromInline
func toKatakana() -> String {
// utf162utf16
let result = self.utf16.map { scalar -> UInt16 in
if 0x3041 <= scalar && scalar <= 0x3096 {
@ -62,7 +63,8 @@ public extension StringProtocol {
/// Returns a String value in which Katakana are all converted to Hiragana.
/// - Returns: A String value in which Katakana are all converted to Hiragana.
@inlinable func toHiragana() -> String {
@usableFromInline
func toHiragana() -> String {
// utf162utf16
let result = self.utf16.map { scalar -> UInt16 in
if 0x30A1 <= scalar && scalar <= 0x30F6 {