fix(ios): refine canvas and screen handling

main
Peter Steinberger 2025-12-19 12:39:58 +01:00
parent 6795e78edf
commit 22f9322905
4 changed files with 11 additions and 16 deletions

View File

@ -26,11 +26,6 @@
<array> <array>
<string>_clawdis-bridge._tcp</string> <string>_clawdis-bridge._tcp</string>
</array> </array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
<key>NSCameraUsageDescription</key> <key>NSCameraUsageDescription</key>
<string>Clawdis can capture photos or short video clips when requested via the bridge.</string> <string>Clawdis can capture photos or short video clips when requested via the bridge.</string>
<key>NSLocalNetworkUsageDescription</key> <key>NSLocalNetworkUsageDescription</key>

View File

@ -365,7 +365,7 @@ final class NodeAppModel {
private func handleInvoke(_ req: BridgeInvokeRequest) async -> BridgeInvokeResponse { private func handleInvoke(_ req: BridgeInvokeRequest) async -> BridgeInvokeResponse {
let command = req.command let command = req.command
if (command.hasPrefix("canvas.") || command.hasPrefix("camera.") || command.hasPrefix("screen.")), if command.hasPrefix("canvas.") || command.hasPrefix("camera.") || command.hasPrefix("screen."),
self.isBackgrounded self.isBackgrounded
{ {
return BridgeInvokeResponse( return BridgeInvokeResponse(

View File

@ -195,11 +195,11 @@ final class ScreenController {
?? bundle.url(forResource: name, withExtension: ext) ?? bundle.url(forResource: name, withExtension: ext)
} }
private static let canvasScaffoldURL: URL? = Self.bundledResourceURL( private static let canvasScaffoldURL: URL? = ScreenController.bundledResourceURL(
name: "scaffold", name: "scaffold",
ext: "html", ext: "html",
subdirectory: "CanvasScaffold") subdirectory: "CanvasScaffold")
private static let a2uiIndexURL: URL? = Self.bundledResourceURL( private static let a2uiIndexURL: URL? = ScreenController.bundledResourceURL(
name: "index", name: "index",
ext: "html", ext: "html",
subdirectory: "CanvasA2UI") subdirectory: "CanvasA2UI")

View File

@ -10,12 +10,12 @@ final class ScreenRecordService {
var errorDescription: String? { var errorDescription: String? {
switch self { switch self {
case let .invalidScreenIndex(idx): case let .invalidScreenIndex(idx):
return "Invalid screen index \(idx)" "Invalid screen index \(idx)"
case let .captureFailed(msg): case let .captureFailed(msg):
return msg msg
case let .writeFailed(msg): case let .writeFailed(msg):
return msg msg
} }
} }
} }
@ -111,7 +111,8 @@ final class ScreenRecordService {
} }
guard w.startWriting() else { guard w.startWriting() else {
throw ScreenRecordError.writeFailed(w.error?.localizedDescription ?? "Failed to start writer") throw ScreenRecordError
.writeFailed(w.error?.localizedDescription ?? "Failed to start writer")
} }
w.startSession(atSourceTime: pts) w.startSession(atSourceTime: pts)
writer = w writer = w
@ -180,8 +181,8 @@ final class ScreenRecordService {
} }
private nonisolated static func clampDurationMs(_ ms: Int?) -> Int { private nonisolated static func clampDurationMs(_ ms: Int?) -> Int {
let v = ms ?? 10_000 let v = ms ?? 10000
return min(60_000, max(250, v)) return min(60000, max(250, v))
} }
private nonisolated static func clampFps(_ fps: Double?) -> Double { private nonisolated static func clampFps(_ fps: Double?) -> Double {
@ -189,5 +190,4 @@ final class ScreenRecordService {
if !v.isFinite { return 10 } if !v.isFinite { return 10 }
return min(30, max(1, v)) return min(30, max(1, v))
} }
} }