Nodes: advertise canvas invoke commands
parent
54830e8401
commit
efed2ae30f
@ -1,38 +0,0 @@
|
||||
import ClawdisKit
|
||||
import Testing
|
||||
|
||||
@Suite struct CanvasCommandAliasTests {
|
||||
@Test func mapsKnownCanvasCommandsToScreen() {
|
||||
let mappings: [(ClawdisCanvasCommand, ClawdisScreenCommand)] = [
|
||||
(.show, .show),
|
||||
(.hide, .hide),
|
||||
(.setMode, .setMode),
|
||||
(.navigate, .navigate),
|
||||
(.evalJS, .evalJS),
|
||||
(.snapshot, .snapshot),
|
||||
]
|
||||
|
||||
for (canvas, screen) in mappings {
|
||||
#expect(
|
||||
ClawdisInvokeCommandAliases.canonicalizeCanvasToScreen(canvas.rawValue) ==
|
||||
screen.rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
@Test func mapsUnknownCanvasNamespaceToScreen() {
|
||||
#expect(ClawdisInvokeCommandAliases.canonicalizeCanvasToScreen("canvas.foo") == "screen.foo")
|
||||
}
|
||||
|
||||
@Test func leavesNonCanvasCommandsUnchanged() {
|
||||
#expect(
|
||||
ClawdisInvokeCommandAliases.canonicalizeCanvasToScreen(ClawdisCameraCommand.snap.rawValue) ==
|
||||
ClawdisCameraCommand.snap.rawValue)
|
||||
}
|
||||
|
||||
@Test func capabilitiesUseStableStrings() {
|
||||
#expect(ClawdisCapability.canvas.rawValue == "canvas")
|
||||
#expect(ClawdisCapability.camera.rawValue == "camera")
|
||||
#expect(ClawdisCapability.voiceWake.rawValue == "voiceWake")
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
import Foundation
|
||||
|
||||
public enum ClawdisCanvasMode: String, Codable, Sendable {
|
||||
case canvas
|
||||
case web
|
||||
}
|
||||
|
||||
public struct ClawdisCanvasNavigateParams: Codable, Sendable, Equatable {
|
||||
public var url: String
|
||||
|
||||
public init(url: String) {
|
||||
self.url = url
|
||||
}
|
||||
}
|
||||
|
||||
public struct ClawdisCanvasSetModeParams: Codable, Sendable, Equatable {
|
||||
public var mode: ClawdisCanvasMode
|
||||
|
||||
public init(mode: ClawdisCanvasMode) {
|
||||
self.mode = mode
|
||||
}
|
||||
}
|
||||
|
||||
public struct ClawdisCanvasEvalParams: Codable, Sendable, Equatable {
|
||||
public var javaScript: String
|
||||
|
||||
public init(javaScript: String) {
|
||||
self.javaScript = javaScript
|
||||
}
|
||||
}
|
||||
|
||||
public enum ClawdisCanvasSnapshotFormat: String, Codable, Sendable {
|
||||
case png
|
||||
case jpeg
|
||||
}
|
||||
|
||||
public struct ClawdisCanvasSnapshotParams: Codable, Sendable, Equatable {
|
||||
public var maxWidth: Int?
|
||||
public var quality: Double?
|
||||
public var format: ClawdisCanvasSnapshotFormat?
|
||||
|
||||
public init(maxWidth: Int? = nil, quality: Double? = nil, format: ClawdisCanvasSnapshotFormat? = nil) {
|
||||
self.maxWidth = maxWidth
|
||||
self.quality = quality
|
||||
self.format = format
|
||||
}
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
import Foundation
|
||||
|
||||
public enum ClawdisScreenMode: String, Codable, Sendable {
|
||||
case canvas
|
||||
case web
|
||||
}
|
||||
|
||||
public enum ClawdisScreenCommand: String, Codable, Sendable {
|
||||
case show = "canvas.show"
|
||||
case hide = "canvas.hide"
|
||||
case setMode = "canvas.setMode"
|
||||
case navigate = "canvas.navigate"
|
||||
case evalJS = "canvas.eval"
|
||||
case snapshot = "canvas.snapshot"
|
||||
}
|
||||
|
||||
public struct ClawdisScreenNavigateParams: Codable, Sendable, Equatable {
|
||||
public var url: String
|
||||
|
||||
public init(url: String) {
|
||||
self.url = url
|
||||
}
|
||||
}
|
||||
|
||||
public struct ClawdisScreenSetModeParams: Codable, Sendable, Equatable {
|
||||
public var mode: ClawdisScreenMode
|
||||
|
||||
public init(mode: ClawdisScreenMode) {
|
||||
self.mode = mode
|
||||
}
|
||||
}
|
||||
|
||||
public struct ClawdisScreenEvalParams: Codable, Sendable, Equatable {
|
||||
public var javaScript: String
|
||||
|
||||
public init(javaScript: String) {
|
||||
self.javaScript = javaScript
|
||||
}
|
||||
}
|
||||
|
||||
public enum ClawdisSnapshotFormat: String, Codable, Sendable {
|
||||
case png
|
||||
case jpeg
|
||||
}
|
||||
|
||||
public struct ClawdisScreenSnapshotParams: Codable, Sendable, Equatable {
|
||||
public var maxWidth: Int?
|
||||
public var quality: Double?
|
||||
public var format: ClawdisSnapshotFormat?
|
||||
|
||||
public init(maxWidth: Int? = nil, quality: Double? = nil, format: ClawdisSnapshotFormat? = nil) {
|
||||
self.maxWidth = maxWidth
|
||||
self.quality = quality
|
||||
self.format = format
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue