fix(ios): refine canvas and screen handling

This commit is contained in:
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>
<string>_clawdis-bridge._tcp</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
<key>NSCameraUsageDescription</key>
<string>Clawdis can capture photos or short video clips when requested via the bridge.</string>
<key>NSLocalNetworkUsageDescription</key>

View File

@@ -365,7 +365,7 @@ final class NodeAppModel {
private func handleInvoke(_ req: BridgeInvokeRequest) async -> BridgeInvokeResponse {
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
{
return BridgeInvokeResponse(

View File

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

View File

@@ -10,12 +10,12 @@ final class ScreenRecordService {
var errorDescription: String? {
switch self {
case let .invalidScreenIndex(idx):
return "Invalid screen index \(idx)"
case let .invalidScreenIndex(idx):
"Invalid screen index \(idx)"
case let .captureFailed(msg):
return msg
msg
case let .writeFailed(msg):
return msg
msg
}
}
}
@@ -111,7 +111,8 @@ final class ScreenRecordService {
}
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)
writer = w
@@ -180,8 +181,8 @@ final class ScreenRecordService {
}
private nonisolated static func clampDurationMs(_ ms: Int?) -> Int {
let v = ms ?? 10_000
return min(60_000, max(250, v))
let v = ms ?? 10000
return min(60000, max(250, v))
}
private nonisolated static func clampFps(_ fps: Double?) -> Double {
@@ -189,5 +190,4 @@ final class ScreenRecordService {
if !v.isFinite { return 10 }
return min(30, max(1, v))
}
}