macOS: add screen record + safer camera defaults

This commit is contained in:
Peter Steinberger
2025-12-19 00:29:38 +01:00
parent 7831e0040e
commit 3772a29557
6 changed files with 364 additions and 7 deletions

View File

@@ -132,6 +132,7 @@ public enum Request: Sendable {
case nodeInvoke(nodeId: String, command: String, paramsJSON: String?)
case cameraSnap(facing: CameraFacing?, maxWidth: Int?, quality: Double?, outPath: String?)
case cameraClip(facing: CameraFacing?, durationMs: Int?, includeAudio: Bool, outPath: String?)
case screenRecord(screenIndex: Int?, durationMs: Int?, fps: Double?, outPath: String?)
}
// MARK: - Responses
@@ -162,6 +163,8 @@ extension Request: Codable {
case path
case javaScript
case outPath
case screenIndex
case fps
case canvasA2UICommand
case jsonl
case facing
@@ -192,6 +195,7 @@ extension Request: Codable {
case nodeInvoke
case cameraSnap
case cameraClip
case screenRecord
}
public func encode(to encoder: Encoder) throws {
@@ -284,6 +288,13 @@ extension Request: Codable {
try container.encodeIfPresent(durationMs, forKey: .durationMs)
try container.encode(includeAudio, forKey: .includeAudio)
try container.encodeIfPresent(outPath, forKey: .outPath)
case let .screenRecord(screenIndex, durationMs, fps, outPath):
try container.encode(Kind.screenRecord, forKey: .type)
try container.encodeIfPresent(screenIndex, forKey: .screenIndex)
try container.encodeIfPresent(durationMs, forKey: .durationMs)
try container.encodeIfPresent(fps, forKey: .fps)
try container.encodeIfPresent(outPath, forKey: .outPath)
}
}
@@ -378,6 +389,13 @@ extension Request: Codable {
let includeAudio = (try? container.decode(Bool.self, forKey: .includeAudio)) ?? true
let outPath = try container.decodeIfPresent(String.self, forKey: .outPath)
self = .cameraClip(facing: facing, durationMs: durationMs, includeAudio: includeAudio, outPath: outPath)
case .screenRecord:
let screenIndex = try container.decodeIfPresent(Int.self, forKey: .screenIndex)
let durationMs = try container.decodeIfPresent(Int.self, forKey: .durationMs)
let fps = try container.decodeIfPresent(Double.self, forKey: .fps)
let outPath = try container.decodeIfPresent(String.self, forKey: .outPath)
self = .screenRecord(screenIndex: screenIndex, durationMs: durationMs, fps: fps, outPath: outPath)
}
}
}