fix: harden AXorcist command handling
This commit is contained in:
parent
931e59e80c
commit
b6df8b09e5
@ -5,6 +5,7 @@ All notable changes to AXorcist will be documented in this file.
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
- Unsupported command dispatch now returns an `unknown_command` error instead of trapping, and JSON path hint parsing no longer writes warnings to stdout for unknown attributes.
|
||||
- Preserve CFRange-backed AXValue attributes such as selected text ranges instead of misclassifying raw value 4 as a boolean. Thanks @WinnCook.
|
||||
|
||||
## [0.1.2] - 2026-04-28
|
||||
|
||||
@ -198,7 +198,9 @@ public class AXorcist {
|
||||
case let .observe(observeCommand):
|
||||
handleObserve(command: observeCommand)
|
||||
default:
|
||||
fatalError("Unsupported command type: \(envelope.command)")
|
||||
.errorResponse(
|
||||
message: "Unsupported command type: \(envelope.command.type)",
|
||||
code: .unknownCommand)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -67,13 +67,7 @@ public struct JSONPathHintComponent: Codable, Sendable {
|
||||
|
||||
/// Converts this component to a simple criteria dictionary for use with existing matching logic.
|
||||
public var simpleCriteria: [String: String]? {
|
||||
guard let resolvedAttributeName = axAttributeName else {
|
||||
// Log a warning here if this component is used, as it means an invalid attribute type was provided.
|
||||
// GlobalAXLogger.shared.log(...) or axWarningLog(...) - Requires importing/access
|
||||
// For now, just return nil. The calling code should handle this.
|
||||
print("WARNING: JSONPathHintComponent has unrecognized attribute type: \(self.attribute)")
|
||||
return nil
|
||||
}
|
||||
guard let resolvedAttributeName = axAttributeName else { return nil }
|
||||
return [resolvedAttributeName: self.value]
|
||||
}
|
||||
|
||||
|
||||
@ -6,10 +6,8 @@
|
||||
//
|
||||
|
||||
import ApplicationServices
|
||||
import Foundation
|
||||
#if canImport(AppKit)
|
||||
import AppKit
|
||||
#endif
|
||||
import Foundation
|
||||
#if canImport(CoreGraphics)
|
||||
import CoreGraphics // Added for CGWindowListCopyWindowInfo
|
||||
#endif
|
||||
@ -49,12 +47,7 @@ public struct RunningApplicationHelper {
|
||||
|
||||
/// Get the current application
|
||||
public static var currentApplication: NSRunningApplication {
|
||||
#if canImport(AppKit)
|
||||
return NSRunningApplication.current
|
||||
#else
|
||||
// Fallback - create a minimal implementation
|
||||
fatalError("NSRunningApplication.current not available on this platform")
|
||||
#endif
|
||||
NSRunningApplication.current
|
||||
}
|
||||
|
||||
/// Get the current application's process info
|
||||
|
||||
Loading…
Reference in New Issue
Block a user