import { Utils } from "@meshtastic/core"; import type { Types } from "@meshtastic/core"; export class TransportDeno implements Types.Transport { private _toDevice: WritableStream; private _fromDevice: ReadableStream; public static async create(hostname: string): Promise { const connection = await Deno.connect({ hostname, port: 4403, }); return new TransportDeno(connection); } constructor(connection: Deno.Conn) { Utils.toDeviceStream.readable.pipeTo(connection.writable); this._toDevice = Utils.toDeviceStream.writable; this._fromDevice = connection.readable.pipeThrough( Utils.fromDeviceStream(), ); } get toDevice(): WritableStream { return this._toDevice; } get fromDevice(): ReadableStream { return this._fromDevice; } }