Sync source edition with VCC Plus 3.7.0 build 63
This commit is contained in:
1 parent
c652a5276d
commit
b2ecec4d87
86 files changed
+10519
-472
No files matched your search
@@ -48,7 +48,7 @@ enum CompanionTransport {
|
||||
}
|
||||
|
||||
enum Failure: LocalizedError {
|
||||
case unavailable, busy, untrustedPeer, unsafeEndpoint, unsupportedVersion, malformedFrame, tooLarge, timedOut
|
||||
case unavailable, busy, untrustedPeer, unsafeEndpoint, unsupportedVersion, malformedFrame, tooLarge, timedOut, startupTimedOut
|
||||
case remote(String)
|
||||
var errorDescription: String? {
|
||||
switch self {
|
||||
@@ -60,11 +60,36 @@ enum CompanionTransport {
|
||||
case .malformedFrame: "The companion service returned an invalid response."
|
||||
case .tooLarge: "The companion request or response exceeds the supported size."
|
||||
case .timedOut: "The companion operation timed out."
|
||||
case .startupTimedOut: "VCC Plus did not finish starting. Check for a macOS permission prompt, then try opening the Software Library again."
|
||||
case .remote(let message): message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Launch Services can return before a cold app finishes macOS startup
|
||||
/// checks. Retry only a missing listener, with a monotonic deadline and
|
||||
/// cancellation; identity/protocol/permission failures remain immediate.
|
||||
static func waitForService(timeout: TimeInterval = 45, retryInterval: TimeInterval = 0.1,
|
||||
now: () -> TimeInterval = { ProcessInfo.processInfo.systemUptime },
|
||||
sleep: (TimeInterval) async throws -> Void = { try await Task.sleep(for: .seconds($0)) },
|
||||
probe: (TimeInterval) async throws -> Void) async throws {
|
||||
let deadline = now() + timeout
|
||||
while true {
|
||||
try Task.checkCancellation()
|
||||
let remaining = deadline - now()
|
||||
guard remaining > 0 else { throw Failure.startupTimedOut }
|
||||
do {
|
||||
try await probe(remaining)
|
||||
try Task.checkCancellation()
|
||||
return
|
||||
} catch Failure.unavailable {
|
||||
let remaining = deadline - now()
|
||||
guard remaining > 0 else { throw Failure.startupTimedOut }
|
||||
try await sleep(min(retryInterval, remaining))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct Request: Codable {
|
||||
let version: Int
|
||||
let id: UUID
|
||||
|
||||
Reference in new issue
Block a user