style(macos): swiftformat sources
This commit is contained in:
@@ -186,7 +186,7 @@ actor MacNodeBridgePairingClient {
|
||||
}
|
||||
defer { timeout.cancel() }
|
||||
return try await withTaskCancellationHandler(operation: {
|
||||
return try await task.value
|
||||
try await task.value
|
||||
}, onCancel: {
|
||||
timeout.cancel()
|
||||
})
|
||||
|
||||
@@ -271,8 +271,8 @@ actor MacNodeBridgeSession {
|
||||
}
|
||||
|
||||
private static func makeStateStream(
|
||||
for connection: NWConnection,
|
||||
) -> AsyncStream<NWConnection.State> {
|
||||
for connection: NWConnection) -> AsyncStream<NWConnection.State>
|
||||
{
|
||||
AsyncStream { continuation in
|
||||
connection.stateUpdateHandler = { state in
|
||||
continuation.yield(state)
|
||||
@@ -288,9 +288,9 @@ actor MacNodeBridgeSession {
|
||||
|
||||
private static func waitForReady(
|
||||
_ stream: AsyncStream<NWConnection.State>,
|
||||
timeoutSeconds: Double,
|
||||
) async throws {
|
||||
try await withTimeout(seconds: timeoutSeconds) {
|
||||
timeoutSeconds: Double) async throws
|
||||
{
|
||||
try await self.withTimeout(seconds: timeoutSeconds) {
|
||||
for await state in stream {
|
||||
switch state {
|
||||
case .ready:
|
||||
@@ -313,8 +313,8 @@ actor MacNodeBridgeSession {
|
||||
|
||||
private static func withTimeout<T: Sendable>(
|
||||
seconds: Double,
|
||||
operation: @escaping @Sendable () async throws -> T,
|
||||
) async throws -> T {
|
||||
operation: @escaping @Sendable () async throws -> T) async throws -> T
|
||||
{
|
||||
let task = Task { try await operation() }
|
||||
let timeout = Task {
|
||||
try await Task.sleep(nanoseconds: UInt64(seconds * 1_000_000_000))
|
||||
@@ -322,7 +322,7 @@ actor MacNodeBridgeSession {
|
||||
}
|
||||
defer { timeout.cancel() }
|
||||
return try await withTaskCancellationHandler(operation: {
|
||||
return try await task.value
|
||||
try await task.value
|
||||
}, onCancel: {
|
||||
timeout.cancel()
|
||||
})
|
||||
|
||||
@@ -185,15 +185,15 @@ final class MacNodeModeCoordinator {
|
||||
var continuation: CheckedContinuation<NWEndpoint?, Never>?
|
||||
|
||||
func finish(_ endpoint: NWEndpoint?) {
|
||||
lock.lock()
|
||||
self.lock.lock()
|
||||
defer { lock.unlock() }
|
||||
if resolved { return }
|
||||
resolved = true
|
||||
for browser in browsers {
|
||||
if self.resolved { return }
|
||||
self.resolved = true
|
||||
for browser in self.browsers {
|
||||
browser.cancel()
|
||||
}
|
||||
continuation?.resume(returning: endpoint)
|
||||
continuation = nil
|
||||
self.continuation?.resume(returning: endpoint)
|
||||
self.continuation = nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,11 +239,11 @@ enum MacNodeTokenStore {
|
||||
}
|
||||
|
||||
static func loadToken() -> String? {
|
||||
let raw = defaults.string(forKey: tokenKey)?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let raw = self.defaults.string(forKey: self.tokenKey)?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
return raw?.isEmpty == false ? raw : nil
|
||||
}
|
||||
|
||||
static func saveToken(_ token: String) {
|
||||
defaults.set(token, forKey: tokenKey)
|
||||
self.defaults.set(token, forKey: self.tokenKey)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ actor MacNodeRuntime {
|
||||
|
||||
func handleInvoke(_ req: BridgeInvokeRequest) async -> BridgeInvokeResponse {
|
||||
let command = req.command
|
||||
if (command.hasPrefix("canvas.") || command.hasPrefix("canvas.a2ui.")) && !Self.canvasEnabled() {
|
||||
if command.hasPrefix("canvas.") || command.hasPrefix("canvas.a2ui."), !Self.canvasEnabled() {
|
||||
return BridgeInvokeResponse(
|
||||
id: req.id,
|
||||
ok: false,
|
||||
@@ -199,7 +199,7 @@ actor MacNodeRuntime {
|
||||
let ready = try await CanvasManager.shared.eval(sessionKey: "main", javaScript: """
|
||||
(() => Boolean(globalThis.clawdisA2UI))
|
||||
""")
|
||||
if ready != "true" && ready != "true\n" {
|
||||
if ready != "true", ready != "true\n" {
|
||||
return Self.errorResponse(req, code: .unavailable, message: "A2UI not ready")
|
||||
}
|
||||
|
||||
@@ -332,10 +332,11 @@ actor MacNodeRuntime {
|
||||
|
||||
let out = NSImage(size: target)
|
||||
out.lockFocus()
|
||||
image.draw(in: NSRect(origin: .zero, size: target),
|
||||
from: NSRect(origin: .zero, size: size),
|
||||
operation: .copy,
|
||||
fraction: 1.0)
|
||||
image.draw(
|
||||
in: NSRect(origin: .zero, size: target),
|
||||
from: NSRect(origin: .zero, size: size),
|
||||
operation: .copy,
|
||||
fraction: 1.0)
|
||||
out.unlockFocus()
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user