mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 11:55:47 -06:00
ae55a4090c
* refactor(canvas): retire legacy host and commands * refactor(apple): narrow shared Canvas contracts * refactor(macos): keep Canvas as widget presenter * refactor(ios): remove Canvas client * refactor(android): remove Canvas client * refactor(linux): remove Canvas client * fix(ci): isolate native locale artifacts * fix(linux): regenerate companion lockfile * fix(canvas): refresh native tool display metadata * test(canvas): align coverage with presenter surface * test(canvas): remove obsolete asset root seam * test(canvas): stabilize retirement CI coverage * refactor(swift): remove orphaned resource wrapper * test(ios): remove retired canvas layout assertion * fix(macos): reserve retired canvas command namespace * refactor(macos): isolate canvas command policy * fix(canvas): select only eligible macOS panels * fix(canvas): keep panel selection plugin-owned
34 lines
1.4 KiB
Swift
34 lines
1.4 KiB
Swift
import Foundation
|
|
|
|
struct MacNodeCanvasHostedSurfaceResolver: Sendable {
|
|
private let currentSurfaceURL: @Sendable () async -> String?
|
|
private let refreshSurfaceURL: @Sendable (String?) async -> String?
|
|
|
|
init(
|
|
currentSurfaceURL: @escaping @Sendable () async -> String?,
|
|
refreshSurfaceURL: @escaping @Sendable (String?) async -> String?)
|
|
{
|
|
self.currentSurfaceURL = currentSurfaceURL
|
|
self.refreshSurfaceURL = refreshSurfaceURL
|
|
}
|
|
|
|
func resolveTarget(_ target: String?) async throws -> URL? {
|
|
guard let target, CanvasHostedURLResolver.isHostedTarget(target) else { return nil }
|
|
let observedSurface = await currentSurfaceURL()
|
|
if let refreshedSurface = await refreshSurfaceURL(observedSurface),
|
|
let resolved = CanvasHostedURLResolver.resolve(surfaceURL: refreshedSurface, target: target)
|
|
{
|
|
return resolved
|
|
}
|
|
// A failed refresh can mean the route changed while it was in flight.
|
|
// Re-read so the replacement gateway's capability wins over the stale observation.
|
|
let currentSurface = await currentSurfaceURL()
|
|
if let resolved = CanvasHostedURLResolver.resolve(surfaceURL: currentSurface, target: target) {
|
|
return resolved
|
|
}
|
|
throw NSError(domain: "Canvas", code: 32, userInfo: [
|
|
NSLocalizedDescriptionKey: "CANVAS_HOST_NOT_CONFIGURED: gateway did not advertise canvas host",
|
|
])
|
|
}
|
|
}
|