From c996174afbb00077d47466a94394e88e8bbac7fa Mon Sep 17 00:00:00 2001 From: TheMoonThatRises <58153205+TheMoonThatRises@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:25:11 -0600 Subject: [PATCH] chore: fix swiftlint --- .github/workflows/SwiftLint.yml | 19 +++ .swiftlint.yml | 3 + AKPlugin.swift | 12 +- PlayTools.xcodeproj/project.pbxproj | 4 + PlayTools/Controls/ActionDispatcher.swift | 16 +-- .../Controls/Backend/Action/PlayAction.swift | 3 +- .../Frontend/EventAdapter/EventAdapters.swift | 13 +- PlayTools/Controls/MenuController.swift | 2 +- .../Editor/Controllers/EditorController.swift | 6 +- .../Editor/Views/CircleMenu/CircleMenu.swift | 21 ++-- .../Views/CircleMenu/CircleMenuButton.swift | 12 +- .../Views/CircleMenu/CircleMenuLoader.swift | 4 +- PlayTools/MysticRunes/PlayedApple.swift | 22 ++-- PlayTools/MysticRunes/PlayedAppleDB.swift | 109 ----------------- .../MysticRunes/PlayedAppleDBConstants.swift | 115 ++++++++++++++++++ PlayTools/Utils/Toast.swift | 3 +- Plugin.swift | 10 +- 17 files changed, 205 insertions(+), 169 deletions(-) create mode 100644 .github/workflows/SwiftLint.yml create mode 100644 PlayTools/MysticRunes/PlayedAppleDBConstants.swift diff --git a/.github/workflows/SwiftLint.yml b/.github/workflows/SwiftLint.yml new file mode 100644 index 00000000..5a889549 --- /dev/null +++ b/.github/workflows/SwiftLint.yml @@ -0,0 +1,19 @@ +name: SwiftLint + +on: + # Run on PR and push to every branch + pull_request: + push: + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + SwiftLint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.0 + - name: SwiftLint + uses: norio-nomura/action-swiftlint@3.2.1 + with: + args: --strict diff --git a/.swiftlint.yml b/.swiftlint.yml index 4b06db8a..8c5ce517 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -10,3 +10,6 @@ identifier_name: type_name: allowed_symbols: ['_'] + +disabled_rules: + - todo diff --git a/AKPlugin.swift b/AKPlugin.swift index 37a45331..23ad8f2f 100644 --- a/AKPlugin.swift +++ b/AKPlugin.swift @@ -66,8 +66,10 @@ class AKPlugin: NSObject, Plugin { } private var modifierFlag: UInt = 0 - func setupKeyboard(keyboard: @escaping(UInt16, Bool, Bool, Bool) -> Bool, - swapMode: @escaping() -> Bool) { + + // swiftlint:disable:next function_body_length + func setupKeyboard(keyboard: @escaping (UInt16, Bool, Bool, Bool) -> Bool, + swapMode: @escaping () -> Bool) { func checkCmd(modifier: NSEvent.ModifierFlags) -> Bool { if modifier.contains(.command) { self.cmdPressed = true @@ -122,7 +124,7 @@ class AKPlugin: NSObject, Plugin { }) } - func setupMouseMoved(_ mouseMoved: @escaping(CGFloat, CGFloat) -> Bool) { + func setupMouseMoved(_ mouseMoved: @escaping (CGFloat, CGFloat) -> Bool) { let mask: NSEvent.EventTypeMask = [.leftMouseDragged, .otherMouseDragged, .rightMouseDragged] NSEvent.addLocalMonitorForEvents(matching: mask, handler: { event in let consumed = mouseMoved(event.deltaX, event.deltaY) @@ -138,7 +140,7 @@ class AKPlugin: NSObject, Plugin { }) } - func setupMouseButton(left: Bool, right: Bool, _ consumed: @escaping(Int, Bool) -> Bool) { + func setupMouseButton(left: Bool, right: Bool, _ consumed: @escaping (Int, Bool) -> Bool) { let downType: NSEvent.EventTypeMask = left ? .leftMouseDown : right ? .rightMouseDown : .otherMouseDown let upType: NSEvent.EventTypeMask = left ? .leftMouseUp : right ? .rightMouseUp : .otherMouseUp NSEvent.addLocalMonitorForEvents(matching: downType, handler: { event in @@ -159,7 +161,7 @@ class AKPlugin: NSObject, Plugin { }) } - func setupScrollWheel(_ onMoved: @escaping(CGFloat, CGFloat) -> Bool) { + func setupScrollWheel(_ onMoved: @escaping (CGFloat, CGFloat) -> Bool) { NSEvent.addLocalMonitorForEvents(matching: NSEvent.EventTypeMask.scrollWheel, handler: { event in var deltaX = event.scrollingDeltaX, deltaY = event.scrollingDeltaY if !event.hasPreciseScrollingDeltas { diff --git a/PlayTools.xcodeproj/project.pbxproj b/PlayTools.xcodeproj/project.pbxproj index 764f161f..6c0f2ad5 100644 --- a/PlayTools.xcodeproj/project.pbxproj +++ b/PlayTools.xcodeproj/project.pbxproj @@ -82,6 +82,7 @@ B1271729288284BE0025112B /* DiscordActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1271728288284BE0025112B /* DiscordActivity.swift */; }; B1E8CF8A28BBE2AB004340D3 /* Keymapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1E8CF8928BBE2AB004340D3 /* Keymapping.swift */; }; B46C02C72C634AB5007637AB /* BatteryLevel.m in Sources */ = {isa = PBXBuildFile; fileRef = B46C02C62C634AB5007637AB /* BatteryLevel.m */; }; + B66E65002C936EA100E48FD0 /* PlayedAppleDBConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = B66E64FF2C936E9800E48FD0 /* PlayedAppleDBConstants.swift */; }; B6D774FF2ACFC3D900C0D9D8 /* SwordRPC in Frameworks */ = {isa = PBXBuildFile; productRef = B6D774FE2ACFC3D900C0D9D8 /* SwordRPC */; }; EEB248592B81D074000C230A /* PlayedAppleDB.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEB248582B81D074000C230A /* PlayedAppleDB.swift */; }; /* End PBXBuildFile section */ @@ -181,6 +182,7 @@ B1E8CF8928BBE2AB004340D3 /* Keymapping.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Keymapping.swift; sourceTree = ""; }; B46C02C62C634AB5007637AB /* BatteryLevel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BatteryLevel.m; sourceTree = ""; }; B46C02C82C634C60007637AB /* BatteryLevel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BatteryLevel.h; sourceTree = ""; }; + B66E64FF2C936E9800E48FD0 /* PlayedAppleDBConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayedAppleDBConstants.swift; sourceTree = ""; }; EEB248582B81D074000C230A /* PlayedAppleDB.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayedAppleDB.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -530,6 +532,7 @@ ABCECEE729750BB100746595 /* MysticRunes */ = { isa = PBXGroup; children = ( + B66E64FF2C936E9800E48FD0 /* PlayedAppleDBConstants.swift */, ABCECEE529750BA600746595 /* PlayedApple.swift */, EEB248582B81D074000C230A /* PlayedAppleDB.swift */, AB7DA47429B85BFB0034ACB2 /* PlayShadow.m */, @@ -733,6 +736,7 @@ 9562D1532AB484FD002C329D /* EventAdapter.swift in Sources */, AA7197A2287A481500623C15 /* CircleMenu.swift in Sources */, 954389CE2B39F26600B063BB /* ElementView.swift in Sources */, + B66E65002C936EA100E48FD0 /* PlayedAppleDBConstants.swift in Sources */, 9562D15A2AB4FBBB002C329D /* TransparentKeyboardEventAdapter.swift in Sources */, AA71978B287A480D00623C15 /* MenuController.swift in Sources */, 9562D1732AB52416002C329D /* EditorKeyboardEventAdapter.swift in Sources */, diff --git a/PlayTools/Controls/ActionDispatcher.swift b/PlayTools/Controls/ActionDispatcher.swift index 14ecd683..eb2544bb 100644 --- a/PlayTools/Controls/ActionDispatcher.swift +++ b/PlayTools/Controls/ActionDispatcher.swift @@ -154,17 +154,19 @@ public class ActionDispatcher { } /** - Lift off (release) touch points of actions that moves freely under control of the user. (e.g. camera control action) - Would be called during every mode switching where `invalidateActions` is not called. - In such scenario button-type actions are not released, because users may continue using them across different modes. + Lift off (release) touch points of actions that moves freely under control of the + user. (e.g. camera control action) Would be called during every mode switching + where `invalidateActions` is not called. In such scenario button-type + actions are not released, because users may continue using them across different modes. (e.g. holding W while unhiding cursor to click something) - But non-button-type actions (e.g. camera control action, fake mouse action) are unlikely used across modes. - If they're not released, they would interfere with and ruin the game's camera control (becomes random zoom in zoom out) + But non-button-type actions (e.g. camera control action, fake mouse action) are unlikely + used across modes. If they're not released, they would interfere with and ruin the game's + camera control (becomes random zoom in zoom out) */ static public func invalidateNonButtonActions() { - for action in actions - where !(action as? ButtonAction != nil || action is JoystickAction){ + for action in actions + where !(action is ButtonAction || action is JoystickAction) { action.invalidate() } } diff --git a/PlayTools/Controls/Backend/Action/PlayAction.swift b/PlayTools/Controls/Backend/Action/PlayAction.swift index 1b768a8b..2ad03d0d 100644 --- a/PlayTools/Controls/Backend/Action/PlayAction.swift +++ b/PlayTools/Controls/Backend/Action/PlayAction.swift @@ -3,6 +3,7 @@ // PlayTools // +// swiftlint:disable file_length import Foundation protocol Action { @@ -332,7 +333,7 @@ class SwipeAction: Action { var location: CGPoint = CGPoint.zero private var id: Int? let timer = DispatchSource.makeTimerSource(flags: [], queue: PlayInput.touchQueue) - private let actionName: String, keyName: String; + private let actionName: String, keyName: String init(actionName: String, keyName: String) { self.actionName = actionName self.keyName = keyName diff --git a/PlayTools/Controls/Frontend/EventAdapter/EventAdapters.swift b/PlayTools/Controls/Frontend/EventAdapter/EventAdapters.swift index 95371743..cc090c6c 100644 --- a/PlayTools/Controls/Frontend/EventAdapter/EventAdapters.swift +++ b/PlayTools/Controls/Frontend/EventAdapter/EventAdapters.swift @@ -13,11 +13,9 @@ public class EventAdapters { static func keyboard(controlMode: ControlModeLiteral) -> KeyboardEventAdapter { switch controlMode { - case .OFF: fallthrough - case .TEXT_INPUT: + case .OFF, .TEXT_INPUT: return TransparentKeyboardEventAdapter() - case .CAMERA_ROTATE: fallthrough - case .ARBITRARY_CLICK: + case .CAMERA_ROTATE, .ARBITRARY_CLICK: return TouchscreenKeyboardEventAdapter() case .EDITOR: return EditorKeyboardEventAdapter() @@ -26,8 +24,7 @@ public class EventAdapters { static func mouse(controlMode: ControlModeLiteral) -> MouseEventAdapter { switch controlMode { - case .OFF: fallthrough - case .TEXT_INPUT: + case .OFF, .TEXT_INPUT: return TransparentMouseEventAdapter() case .CAMERA_ROTATE: return CameraControlMouseEventAdapter() @@ -42,9 +39,7 @@ public class EventAdapters { switch controlMode { case .OFF: return TransparentControllerEventAdapter() - case .TEXT_INPUT: fallthrough - case .CAMERA_ROTATE: fallthrough - case .ARBITRARY_CLICK: + case .TEXT_INPUT, .CAMERA_ROTATE, .ARBITRARY_CLICK: return TouchscreenControllerEventAdapter() case .EDITOR: return EditorControllerEventAdapter() diff --git a/PlayTools/Controls/MenuController.swift b/PlayTools/Controls/MenuController.swift index 7fc187e0..597bfa5f 100644 --- a/PlayTools/Controls/MenuController.swift +++ b/PlayTools/Controls/MenuController.swift @@ -101,7 +101,7 @@ var keymapping = [ NSLocalizedString("menu.keymapping.rotateDisplay", tableName: "Playtools", value: "Rotate display area", comment: ""), NSLocalizedString("menu.keymapping.toggleDebug", tableName: "Playtools", - value: "Toggle Debug Overlay", comment: ""), + value: "Toggle Debug Overlay", comment: "") ] var keymappingSelectors = [#selector(UIApplication.switchEditorMode(_:)), #selector(UIApplication.removeElement(_:)), diff --git a/PlayTools/Editor/Controllers/EditorController.swift b/PlayTools/Editor/Controllers/EditorController.swift index f64e315a..dbeeae10 100644 --- a/PlayTools/Editor/Controllers/EditorController.swift +++ b/PlayTools/Editor/Controllers/EditorController.swift @@ -82,9 +82,9 @@ class EditorController { public func setKey(_ name: String) { if editorMode { - if name != "Mouse" || focusedControl as? MouseAreaModel != nil - || focusedControl as? JoystickModel != nil - || focusedControl as? DraggableButtonModel != nil { + if name != "Mouse" || focusedControl is MouseAreaModel + || focusedControl is JoystickModel + || focusedControl is DraggableButtonModel { focusedControl?.setKey(name: name) } } diff --git a/PlayTools/Editor/Views/CircleMenu/CircleMenu.swift b/PlayTools/Editor/Views/CircleMenu/CircleMenu.swift index 82fa2601..0c9bff76 100644 --- a/PlayTools/Editor/Views/CircleMenu/CircleMenu.swift +++ b/PlayTools/Editor/Views/CircleMenu/CircleMenu.swift @@ -22,9 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -// swiftlint:disable type_body_length // swiftlint:disable file_length -// swiftlint:disable line_length import UIKit @@ -46,7 +44,8 @@ func customize(_ value: Type, block: (_ object: Type) -> Void) -> Type { Tells the delegate the circle menu is about to draw a button for a particular index. - parameter circleMenu: The circle menu object informing the delegate of this impending event. - - parameter button: A circle menu button object that circle menu is going to use when drawing the row. Don't change button.tag + - parameter button: A circle menu button object that circle menu is going to use + when drawing the row. Don't change button.tag - parameter atIndex: An button index. */ @objc optional func circleMenu(_ circleMenu: CircleMenu, willDisplay button: UIButton, atIndex: Int) @@ -86,6 +85,7 @@ func customize(_ value: Type, block: (_ object: Type) -> Void) -> Type { // MARK: CircleMenu +// swiftlint:disable type_body_length /// A Button object with pop ups buttons open class CircleMenu: UIButton { @@ -126,7 +126,8 @@ open class CircleMenu: UIButton { /** Initializes and returns a circle menu object. - - parameter frame: A rectangle specifying the initial location and size of the circle menu in its superview’€™s coordinates. + - parameter frame: A rectangle specifying the initial location and size of the circle menu in + its superview’€™s coordinates. - parameter normalIcon: The image to use for the specified normal state. - parameter selectedIcon: The image to use for the specified selected state. - parameter buttonsCount: The number of buttons. @@ -428,9 +429,9 @@ open class CircleMenu: UIButton { transform = CGAffineTransform(scaleX: 0.9, y: 0.9) UIView.animate(withDuration: duration, delay: 0, usingSpringWithDamping: 0.3, initialSpringVelocity: 5, options: UIView.AnimationOptions.curveLinear, - animations: { () -> Void in - self.transform = CGAffineTransform(scaleX: 1, y: 1) - }, + animations: { + self.transform = CGAffineTransform(scaleX: 1, y: 1) + }, completion: completion) } @@ -492,7 +493,7 @@ open class CircleMenu: UIButton { fileprivate func hideCenterButton(duration: Double, delay: Double = 0) { UIView.animate(withDuration: TimeInterval(duration), delay: TimeInterval(delay), options: UIView.AnimationOptions.curveEaseOut, - animations: { () -> Void in + animations: { self.transform = CGAffineTransform(scaleX: 0.001, y: 0.001) }, completion: nil) } @@ -500,7 +501,7 @@ open class CircleMenu: UIButton { fileprivate func showCenterButton(duration: Float, delay: Double) { UIView.animate(withDuration: TimeInterval(duration), delay: TimeInterval(delay), usingSpringWithDamping: 0.78, initialSpringVelocity: 0, options: UIView.AnimationOptions.curveLinear, - animations: { () -> Void in + animations: { self.transform = CGAffineTransform(scaleX: 1, y: 1) self.alpha = 1 }, @@ -539,6 +540,8 @@ open class CircleMenu: UIButton { } } +// swiftlint:enable type_body_length + // MARK: extension internal extension Float { diff --git a/PlayTools/Editor/Views/CircleMenu/CircleMenuButton.swift b/PlayTools/Editor/Views/CircleMenu/CircleMenuButton.swift index 728684ec..afbfefe3 100644 --- a/PlayTools/Editor/Views/CircleMenu/CircleMenuButton.swift +++ b/PlayTools/Editor/Views/CircleMenu/CircleMenuButton.swift @@ -118,7 +118,7 @@ internal class CircleMenuButton: UIButton { withDuration: duration, delay: delay, options: UIView.AnimationOptions(), - animations: { () -> Void in + animations: { container.layer.transform = rotateTransform }, completion: nil) @@ -149,11 +149,11 @@ internal extension CircleMenuButton { usingSpringWithDamping: 0.7, initialSpringVelocity: 0, options: UIView.AnimationOptions.curveLinear, - animations: { () -> Void in + animations: { self.container?.superview?.layoutIfNeeded() self.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) self.alpha = 1 - }, completion: { (_) -> Void in + }, completion: { _ in }) } @@ -167,10 +167,10 @@ internal extension CircleMenuButton { withDuration: duration, delay: delay, options: UIView.AnimationOptions.curveEaseIn, - animations: { () -> Void in + animations: { self.container?.superview?.layoutIfNeeded() self.transform = CGAffineTransform(scaleX: 0.01, y: 0.01) - }, completion: { (_) -> Void in + }, completion: { _ in self.alpha = 0 if self.container != nil { @@ -191,7 +191,7 @@ internal extension CircleMenuButton { withDuration: duration, delay: delay, options: UIView.AnimationOptions.curveEaseIn, - animations: { () -> Void in + animations: { self.container?.superview?.layoutIfNeeded() }, completion: nil) diff --git a/PlayTools/Editor/Views/CircleMenu/CircleMenuLoader.swift b/PlayTools/Editor/Views/CircleMenu/CircleMenuLoader.swift index 106884a1..f927bcb1 100644 --- a/PlayTools/Editor/Views/CircleMenu/CircleMenuLoader.swift +++ b/PlayTools/Editor/Views/CircleMenu/CircleMenuLoader.swift @@ -151,10 +151,10 @@ internal class CircleMenuLoader: UIView { withDuration: CFTimeInterval(duration), delay: delay, options: UIView.AnimationOptions.curveEaseIn, - animations: { () -> Void in + animations: { self.alpha = 0 }, - completion: { (_) -> Void in + completion: { _ in self.removeFromSuperview() completion() }) diff --git a/PlayTools/MysticRunes/PlayedApple.swift b/PlayTools/MysticRunes/PlayedApple.swift index f47e38a3..5a4a7b4e 100644 --- a/PlayTools/MysticRunes/PlayedApple.swift +++ b/PlayTools/MysticRunes/PlayedApple.swift @@ -14,7 +14,7 @@ import Security public class PlayKeychain: NSObject { static let shared = PlayKeychain() - private static let db = PlayKeychainDB.shared + private static let playChainDB = PlayKeychainDB.shared @objc public static func debugLogger(_ logContent: String) { if PlaySettings.shared.settingsData.playChainDebugging { @@ -24,8 +24,9 @@ public class PlayKeychain: NSObject { // Emulates SecItemAdd, SecItemUpdate, SecItemDelete and SecItemCopyMatching // Store the entire dictionary as a plist // SecItemAdd(CFDictionaryRef attributes, CFTypeRef *result) - @objc static public func add(_ attributes: NSDictionary, result: UnsafeMutablePointer?>?) -> OSStatus { - guard let keychainDict = db.insert(attributes) else { + @objc static public func add(_ attributes: NSDictionary, + result: UnsafeMutablePointer?>?) -> OSStatus { + guard let keychainDict = playChainDB.insert(attributes) else { debugLogger("Failed to write keychain file") return errSecIO } @@ -65,7 +66,7 @@ public class PlayKeychain: NSObject { // SecItemUpdate(CFDictionaryRef query, CFDictionaryRef attributesToUpdate) @objc static public func update(_ query: NSDictionary, attributesToUpdate: NSDictionary) -> OSStatus { - guard let keychainDict = db.query(query)?.first else { + guard let keychainDict = playChainDB.query(query)?.first else { debugLogger("Keychain item not found in db") return errSecItemNotFound } @@ -79,7 +80,7 @@ public class PlayKeychain: NSObject { for (key, value) in attributesToUpdate { newKeychainDict.setValue(value, forKey: key as! String) // swiftlint:disable:this force_cast } - guard db.update(newKeychainDict) else { + guard playChainDB.update(newKeychainDict) else { debugLogger("Failed to update keychain item to db") return errSecIO } @@ -89,11 +90,11 @@ public class PlayKeychain: NSObject { // SecItemDelete(CFDictionaryRef query) @objc static public func delete(_ query: NSDictionary) -> OSStatus { - guard db.query(query)?.first != nil else { + guard playChainDB.query(query)?.first != nil else { debugLogger("Failed to find keychain item") return errSecItemNotFound } - guard db.delete(query) else { + guard playChainDB.delete(query) else { debugLogger("Failed to delete keychain item") return errSecIO } @@ -102,9 +103,10 @@ public class PlayKeychain: NSObject { } // SecItemCopyMatching(CFDictionaryRef query, CFTypeRef *result) - @objc static public func copyMatching(_ query: NSDictionary, result: UnsafeMutablePointer?>?) - -> OSStatus { - guard let keychainDicts = db.query(query), + // swiftlint:disable:next function_body_length + @objc static public func copyMatching(_ query: NSDictionary, + result: UnsafeMutablePointer?>?) -> OSStatus { + guard let keychainDicts = playChainDB.query(query), let keychainDict = keychainDicts.first else { debugLogger("Keychain item not found in db") return errSecItemNotFound diff --git a/PlayTools/MysticRunes/PlayedAppleDB.swift b/PlayTools/MysticRunes/PlayedAppleDB.swift index 700b67c2..da0fcb92 100644 --- a/PlayTools/MysticRunes/PlayedAppleDB.swift +++ b/PlayTools/MysticRunes/PlayedAppleDB.swift @@ -306,112 +306,3 @@ class PlayKeychainDB: NSObject { } } } - -struct PlayedAppleDBConstants { - // https://developer.apple.com/documentation/security/keychain_services/keychain_items/item_class_keys_and_values - // Synchronizable does not matter. - static let primaries = [ - kSecClassGenericPassword: [ - kSecAttrAccessGroup, - kSecAttrAccount, - kSecAttrService - // kSecAttrSynchronizable - ], - kSecClassInternetPassword: [ - kSecAttrAccessGroup, - kSecAttrAccount, - kSecAttrAuthenticationType, - kSecAttrPath, - kSecAttrPort, - kSecAttrProtocol, - kSecAttrSecurityDomain, - kSecAttrServer - // kSecAttrSynchronizable - ], - kSecClassCertificate: [ - kSecAttrAccessGroup, - kSecAttrCertificateType, - kSecAttrIssuer, - kSecAttrSerialNumber - // kSecAttrSynchronizable - ], - kSecClassKey: [ - kSecAttrAccessGroup, - kSecAttrApplicationLabel, - kSecAttrApplicationTag, - kSecAttrEffectiveKeySize, - kSecAttrKeyClass, - kSecAttrKeySizeInBits, - kSecAttrKeyType - // kSecAttrSynchronizable - ], - kSecClassIdentity: [ - kSecAttrAccessGroup, - kSecAttrCertificateType, - kSecAttrIssuer, - kSecAttrSerialNumber - // kSecAttrSynchronizable - ] - ] - static let attributes = [ - kSecClassGenericPassword: [ - kSecAttrAccessControl, - kSecAttrAccessible, - kSecAttrCreationDate, - kSecAttrModificationDate, - kSecAttrDescription, - kSecAttrComment, - kSecAttrCreator, - kSecAttrType, - kSecAttrLabel, - kSecAttrIsInvisible, - kSecAttrIsNegative, - kSecAttrGeneric - ], - kSecClassInternetPassword: [ - kSecAttrAccessControl, - kSecAttrAccessible, - kSecAttrCreationDate, - kSecAttrModificationDate, - kSecAttrDescription, - kSecAttrComment, - kSecAttrCreator, - kSecAttrType, - kSecAttrLabel, - kSecAttrIsInvisible, - kSecAttrIsNegative, - kSecAttrGeneric - ], - kSecClassCertificate: [ - kSecAttrCertificateEncoding, - kSecAttrLabel, - kSecAttrSubject, - kSecAttrSubjectKeyID, - kSecAttrPublicKeyHash - ], - kSecClassKey: [ - kSecAttrAccessible, - kSecAttrLabel, - kSecAttrIsPermanent, - kSecAttrCanEncrypt, - kSecAttrCanDecrypt, - kSecAttrCanDerive, - kSecAttrCanSign, - kSecAttrCanVerify, - kSecAttrCanWrap, - kSecAttrCanUnwrap - ], - kSecClassIdentity: [ - kSecAttrCertificateEncoding, - kSecAttrLabel, - kSecAttrSubject, - kSecAttrSubjectKeyID, - kSecAttrPublicKeyHash - ] - ] - static let values = [ - kSecValueData, - kSecValueRef, - kSecValuePersistentRef - ] -} diff --git a/PlayTools/MysticRunes/PlayedAppleDBConstants.swift b/PlayTools/MysticRunes/PlayedAppleDBConstants.swift new file mode 100644 index 00000000..c1f1533d --- /dev/null +++ b/PlayTools/MysticRunes/PlayedAppleDBConstants.swift @@ -0,0 +1,115 @@ +// +// PlayedAppleDBConstants.swift +// PlayTools +// +// Created by TheMoonThatRises on 9/12/24. +// + +struct PlayedAppleDBConstants { + // https://developer.apple.com/documentation/security/keychain_services/keychain_items/item_class_keys_and_values + // Synchronizable does not matter. + static let primaries = [ + kSecClassGenericPassword: [ + kSecAttrAccessGroup, + kSecAttrAccount, + kSecAttrService + // kSecAttrSynchronizable + ], + kSecClassInternetPassword: [ + kSecAttrAccessGroup, + kSecAttrAccount, + kSecAttrAuthenticationType, + kSecAttrPath, + kSecAttrPort, + kSecAttrProtocol, + kSecAttrSecurityDomain, + kSecAttrServer + // kSecAttrSynchronizable + ], + kSecClassCertificate: [ + kSecAttrAccessGroup, + kSecAttrCertificateType, + kSecAttrIssuer, + kSecAttrSerialNumber + // kSecAttrSynchronizable + ], + kSecClassKey: [ + kSecAttrAccessGroup, + kSecAttrApplicationLabel, + kSecAttrApplicationTag, + kSecAttrEffectiveKeySize, + kSecAttrKeyClass, + kSecAttrKeySizeInBits, + kSecAttrKeyType + // kSecAttrSynchronizable + ], + kSecClassIdentity: [ + kSecAttrAccessGroup, + kSecAttrCertificateType, + kSecAttrIssuer, + kSecAttrSerialNumber + // kSecAttrSynchronizable + ] + ] + static let attributes = [ + kSecClassGenericPassword: [ + kSecAttrAccessControl, + kSecAttrAccessible, + kSecAttrCreationDate, + kSecAttrModificationDate, + kSecAttrDescription, + kSecAttrComment, + kSecAttrCreator, + kSecAttrType, + kSecAttrLabel, + kSecAttrIsInvisible, + kSecAttrIsNegative, + kSecAttrGeneric + ], + kSecClassInternetPassword: [ + kSecAttrAccessControl, + kSecAttrAccessible, + kSecAttrCreationDate, + kSecAttrModificationDate, + kSecAttrDescription, + kSecAttrComment, + kSecAttrCreator, + kSecAttrType, + kSecAttrLabel, + kSecAttrIsInvisible, + kSecAttrIsNegative, + kSecAttrGeneric + ], + kSecClassCertificate: [ + kSecAttrCertificateEncoding, + kSecAttrLabel, + kSecAttrSubject, + kSecAttrSubjectKeyID, + kSecAttrPublicKeyHash + ], + kSecClassKey: [ + kSecAttrAccessible, + kSecAttrLabel, + kSecAttrIsPermanent, + kSecAttrCanEncrypt, + kSecAttrCanDecrypt, + kSecAttrCanDerive, + kSecAttrCanSign, + kSecAttrCanVerify, + kSecAttrCanWrap, + kSecAttrCanUnwrap + ], + kSecClassIdentity: [ + kSecAttrCertificateEncoding, + kSecAttrLabel, + kSecAttrSubject, + kSecAttrSubjectKeyID, + kSecAttrPublicKeyHash + ] + ] + static let values = [ + kSecValueData, + kSecValueRef, + kSecValuePersistentRef + ] +} diff --git a/PlayTools/Utils/Toast.swift b/PlayTools/Utils/Toast.swift index e84bfaa4..6cdfc844 100644 --- a/PlayTools/Utils/Toast.swift +++ b/PlayTools/Utils/Toast.swift @@ -171,9 +171,8 @@ class Toast { notification: NSNotification.Name.playtoolsCursorWillShow) } } - - // swiftlint:disable function_body_length + // swiftlint:disable:next function_body_length private static func show(message: String, parent: UIView) { let toastContainer = UIView(frame: CGRect()) toastContainer.backgroundColor = UIColor.black.withAlphaComponent(0.6) diff --git a/Plugin.swift b/Plugin.swift index e7f0552b..0949bd2d 100644 --- a/Plugin.swift +++ b/Plugin.swift @@ -23,11 +23,11 @@ public protocol Plugin: NSObjectProtocol { func warpCursor() func unhideCursor() func terminateApplication() - func setupKeyboard(keyboard: @escaping(UInt16, Bool, Bool, Bool) -> Bool, - swapMode: @escaping() -> Bool) - func setupMouseMoved(_ mouseMoved: @escaping(CGFloat, CGFloat) -> Bool) - func setupMouseButton(left: Bool, right: Bool, _ consumed: @escaping(Int, Bool) -> Bool) - func setupScrollWheel(_ onMoved: @escaping(CGFloat, CGFloat) -> Bool) + func setupKeyboard(keyboard: @escaping (UInt16, Bool, Bool, Bool) -> Bool, + swapMode: @escaping () -> Bool) + func setupMouseMoved(_ mouseMoved: @escaping (CGFloat, CGFloat) -> Bool) + func setupMouseButton(left: Bool, right: Bool, _ consumed: @escaping (Int, Bool) -> Bool) + func setupScrollWheel(_ onMoved: @escaping (CGFloat, CGFloat) -> Bool) func urlForApplicationWithBundleIdentifier(_ value: String) -> URL? func setMenuBarVisible(_ value: Bool) }