chore: share bonjour escapes + refresh webchat bundle
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
import Foundation
|
||||
|
||||
enum BonjourEscapeDecoder {
|
||||
static func decode(_ input: String) -> String {
|
||||
// mDNS / DNS-SD commonly escapes bytes in instance names as `\\DDD`
|
||||
// (decimal-encoded), e.g. spaces are `\\032`.
|
||||
var out = ""
|
||||
var i = input.startIndex
|
||||
while i < input.endIndex {
|
||||
if input[i] == "\\",
|
||||
let d0 = input.index(i, offsetBy: 1, limitedBy: input.index(before: input.endIndex)),
|
||||
let d1 = input.index(i, offsetBy: 2, limitedBy: input.index(before: input.endIndex)),
|
||||
let d2 = input.index(i, offsetBy: 3, limitedBy: input.index(before: input.endIndex)),
|
||||
input[d0].isNumber,
|
||||
input[d1].isNumber,
|
||||
input[d2].isNumber
|
||||
{
|
||||
let digits = String(input[d0...d2])
|
||||
if let value = Int(digits),
|
||||
let scalar = UnicodeScalar(value)
|
||||
{
|
||||
out.append(Character(scalar))
|
||||
i = input.index(i, offsetBy: 4)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
out.append(input[i])
|
||||
i = input.index(after: i)
|
||||
}
|
||||
return out
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ final class BridgeDiscoveryModel: ObservableObject {
|
||||
self.bridges = results.compactMap { result -> DiscoveredBridge? in
|
||||
switch result.endpoint {
|
||||
case let .service(name, _, _, _):
|
||||
let decodedName = BonjourEscapeDecoder.decode(name)
|
||||
let decodedName = BonjourEscapes.decode(name)
|
||||
return DiscoveredBridge(
|
||||
name: decodedName,
|
||||
endpoint: result.endpoint,
|
||||
@@ -75,6 +75,6 @@ final class BridgeDiscoveryModel: ObservableObject {
|
||||
}
|
||||
|
||||
private static func prettyEndpointDebugID(_ endpoint: NWEndpoint) -> String {
|
||||
BonjourEscapeDecoder.decode(String(describing: endpoint))
|
||||
BonjourEscapes.decode(String(describing: endpoint))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ actor BridgeSession {
|
||||
private static func prettyRemoteEndpoint(_ endpoint: NWEndpoint) -> String? {
|
||||
switch endpoint {
|
||||
case let .hostPort(host, port):
|
||||
return "\(host):\(port)".replacingOccurrences(of: "::ffff:", with: "")
|
||||
"\(host):\(port)".replacingOccurrences(of: "::ffff:", with: "")
|
||||
default:
|
||||
return String(describing: endpoint)
|
||||
String(describing: endpoint)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ final class NodeAppModel: ObservableObject {
|
||||
self.bridgeStatusText = "Connecting…"
|
||||
self.bridgeServerName = nil
|
||||
self.bridgeRemoteAddress = nil
|
||||
self.connectedBridgeDebugID = BonjourEscapeDecoder.decode(String(describing: endpoint))
|
||||
self.connectedBridgeDebugID = BonjourEscapes.decode(String(describing: endpoint))
|
||||
|
||||
self.bridgeTask = Task {
|
||||
do {
|
||||
@@ -71,13 +71,14 @@ final class NodeAppModel: ObservableObject {
|
||||
platform: platform,
|
||||
version: version),
|
||||
onConnected: { [weak self] serverName in
|
||||
guard let self else { return }
|
||||
await MainActor.run {
|
||||
self?.bridgeStatusText = "Connected"
|
||||
self?.bridgeServerName = serverName
|
||||
self.bridgeStatusText = "Connected"
|
||||
self.bridgeServerName = serverName
|
||||
}
|
||||
if let addr = await self.bridge.currentRemoteAddress() {
|
||||
await MainActor.run {
|
||||
self?.bridgeRemoteAddress = addr
|
||||
self.bridgeRemoteAddress = addr
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -28,8 +28,8 @@ private final class AudioBufferQueue: @unchecked Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
private extension AVAudioPCMBuffer {
|
||||
func deepCopy() -> AVAudioPCMBuffer? {
|
||||
extension AVAudioPCMBuffer {
|
||||
fileprivate func deepCopy() -> AVAudioPCMBuffer? {
|
||||
let format = self.format
|
||||
let frameLength = self.frameLength
|
||||
guard let copy = AVAudioPCMBuffer(pcmFormat: format, frameCapacity: frameLength) else {
|
||||
|
||||
Reference in New Issue
Block a user