iOS: alias canvas.* invoke commands

main
Peter Steinberger 2025-12-18 01:57:31 +01:00
parent 86225d0eb6
commit f8bea661fc
1 changed files with 11 additions and 3 deletions

View File

@ -265,7 +265,15 @@ final class NodeAppModel {
} }
private func handleInvoke(_ req: BridgeInvokeRequest) async -> BridgeInvokeResponse { private func handleInvoke(_ req: BridgeInvokeRequest) async -> BridgeInvokeResponse {
if req.command.hasPrefix("screen.") || req.command.hasPrefix("camera."), self.isBackgrounded { // Alias for "canvas" capability: accept canvas.* commands and map them to screen.*.
let command =
if req.command.hasPrefix("canvas.") {
"screen." + req.command.dropFirst("canvas.".count)
} else {
req.command
}
if command.hasPrefix("screen.") || command.hasPrefix("camera."), self.isBackgrounded {
return BridgeInvokeResponse( return BridgeInvokeResponse(
id: req.id, id: req.id,
ok: false, ok: false,
@ -274,7 +282,7 @@ final class NodeAppModel {
message: "NODE_BACKGROUND_UNAVAILABLE: screen/camera commands require foreground")) message: "NODE_BACKGROUND_UNAVAILABLE: screen/camera commands require foreground"))
} }
if req.command.hasPrefix("camera."), !self.isCameraEnabled() { if command.hasPrefix("camera."), !self.isCameraEnabled() {
return BridgeInvokeResponse( return BridgeInvokeResponse(
id: req.id, id: req.id,
ok: false, ok: false,
@ -284,7 +292,7 @@ final class NodeAppModel {
} }
do { do {
switch req.command { switch command {
case ClawdisScreenCommand.show.rawValue: case ClawdisScreenCommand.show.rawValue:
return BridgeInvokeResponse(id: req.id, ok: true) return BridgeInvokeResponse(id: req.id, ok: true)