mirror of
https://github.com/samsonjs/Peekaboo.git
synced 2026-03-25 09:25:47 +00:00
- Update to swift-tools-version 6.0 and enable StrictConcurrency - Make all data models and types Sendable for concurrency safety - Migrate commands from ParsableCommand to AsyncParsableCommand - Remove AsyncUtils.swift and synchronous bridging patterns - Update WindowBounds property names to snake_case for consistency - Ensure all error types conform to Sendable protocol - Add comprehensive Swift 6 migration documentation This migration enables full Swift 6 concurrency checking and data race safety while maintaining backward compatibility with the existing API. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
38 lines
1.3 KiB
Swift
38 lines
1.3 KiB
Swift
import Foundation
|
|
|
|
struct FileNameGenerator: Sendable {
|
|
static func generateFileName(
|
|
displayIndex: Int? = nil,
|
|
appName: String? = nil,
|
|
windowIndex: Int? = nil,
|
|
windowTitle: String? = nil,
|
|
format: ImageFormat
|
|
) -> String {
|
|
let timestamp = DateFormatter.timestamp.string(from: Date())
|
|
let ext = format.rawValue
|
|
|
|
if let displayIndex {
|
|
return "screen_\(displayIndex + 1)_\(timestamp).\(ext)"
|
|
} else if let appName {
|
|
let cleanAppName = appName.replacingOccurrences(of: " ", with: "_")
|
|
if let windowIndex {
|
|
return "\(cleanAppName)_window_\(windowIndex)_\(timestamp).\(ext)"
|
|
} else if let windowTitle {
|
|
let cleanTitle = windowTitle.replacingOccurrences(of: " ", with: "_").prefix(20)
|
|
return "\(cleanAppName)_\(cleanTitle)_\(timestamp).\(ext)"
|
|
} else {
|
|
return "\(cleanAppName)_\(timestamp).\(ext)"
|
|
}
|
|
} else {
|
|
return "capture_\(timestamp).\(ext)"
|
|
}
|
|
}
|
|
}
|
|
|
|
extension DateFormatter {
|
|
static let timestamp: DateFormatter = {
|
|
let formatter = DateFormatter()
|
|
formatter.dateFormat = "yyyyMMdd_HHmmss"
|
|
return formatter
|
|
}()
|
|
}
|