@dxos/teleport 0.5.0 → 0.5.1-main.16a1d7d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/testing/test-builder.ts", "../../../src/teleport.ts", "../../../src/control-extension.ts", "../../../src/muxing/framer.ts", "../../../src/muxing/muxer.ts", "../../../src/muxing/balancer.ts", "../../../src/testing/test-extension.ts", "../../../src/testing/test-extension-with-streams.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Duplex, pipeline } from 'node:stream';\n\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\n\nimport { Teleport } from '../teleport';\n\ntype CreatePeerOpts<T extends TestPeer> = {\n factory: () => T;\n};\n\nexport class TestBuilder {\n private readonly _peers = new Set<TestPeer>();\n\n createPeer<T extends TestPeer>(opts: CreatePeerOpts<T>): T {\n const peer = opts.factory();\n this._peers.add(peer);\n return peer;\n }\n\n *createPeers<T extends TestPeer>(opts: CreatePeerOpts<T>): Generator<T> {\n while (true) {\n yield this.createPeer(opts);\n }\n }\n\n async destroy() {\n await Promise.all(Array.from(this._peers).map((agent) => agent.destroy()));\n }\n\n async connect(peer1: TestPeer, peer2: TestPeer) {\n invariant(peer1 !== peer2);\n invariant(this._peers.has(peer1));\n invariant(this._peers.has(peer1));\n\n const connection1 = peer1.createConnection({ initiator: true, remotePeerId: peer2.peerId });\n const connection2 = peer2.createConnection({ initiator: false, remotePeerId: peer1.peerId });\n\n pipeStreams(connection1.teleport.stream, connection2.teleport.stream);\n await Promise.all([peer1.openConnection(connection1), peer2.openConnection(connection2)]);\n\n return [connection1, connection2];\n }\n\n async disconnect(peer1: TestPeer, peer2: TestPeer) {\n invariant(peer1 !== peer2);\n invariant(this._peers.has(peer1));\n invariant(this._peers.has(peer1));\n\n const connection1 = Array.from(peer1.connections).find((connection) =>\n connection.remotePeerId.equals(peer2.peerId),\n );\n const connection2 = Array.from(peer2.connections).find((connection) =>\n connection.remotePeerId.equals(peer1.peerId),\n );\n\n invariant(connection1);\n invariant(connection2);\n\n await Promise.all([peer1.closeConnection(connection1), peer2.closeConnection(connection2)]);\n }\n}\n\nexport class TestPeer {\n public readonly connections = new Set<TestConnection>();\n\n constructor(public readonly peerId: PublicKey = PublicKey.random()) {}\n\n protected async onOpen(connection: TestConnection) {}\n protected async onClose(connection: TestConnection) {}\n\n createConnection({ initiator, remotePeerId }: { initiator: boolean; remotePeerId: PublicKey }) {\n const connection = new TestConnection(this.peerId, remotePeerId, initiator);\n this.connections.add(connection);\n return connection;\n }\n\n async openConnection(connection: TestConnection) {\n invariant(this.connections.has(connection));\n await connection.teleport.open(PublicKey.random());\n await this.onOpen(connection);\n }\n\n async closeConnection(connection: TestConnection) {\n invariant(this.connections.has(connection));\n await this.onClose(connection);\n await connection.teleport.close();\n this.connections.delete(connection);\n }\n\n async destroy() {\n for (const teleport of this.connections) {\n await this.closeConnection(teleport);\n }\n }\n}\n\nconst pipeStreams = (stream1: Duplex, stream2: Duplex) => {\n pipeline(stream1, stream2, (err) => {\n if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {\n log.catch(err);\n }\n });\n pipeline(stream2, stream1, (err) => {\n if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {\n log.catch(err);\n }\n });\n};\n\nexport class TestConnection {\n public teleport: Teleport;\n\n constructor(\n public readonly localPeerId: PublicKey,\n public readonly remotePeerId: PublicKey,\n public readonly initiator: boolean,\n ) {\n this.teleport = new Teleport({\n initiator,\n localPeerId,\n remotePeerId,\n });\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Duplex } from 'node:stream';\n\nimport { runInContextAsync, synchronized, scheduleTask, type Event } from '@dxos/async';\nimport { Context } from '@dxos/context';\nimport { failUndefined } from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey } from '@dxos/keys';\nimport { log, logInfo } from '@dxos/log';\nimport { RpcClosedError, TimeoutError } from '@dxos/protocols';\n\nimport { ControlExtension } from './control-extension';\nimport { type CreateChannelOpts, Muxer, type MuxerStats, type RpcPort } from './muxing';\n\nexport type TeleportParams = {\n initiator: boolean;\n localPeerId: PublicKey;\n remotePeerId: PublicKey;\n};\n\nconst CONTROL_HEARTBEAT_INTERVAL = 10_000;\nconst CONTROL_HEARTBEAT_TIMEOUT = 60_000;\n\n/**\n * TODO(burdon): Comment: what is this?\n */\nexport class Teleport {\n public readonly initiator: boolean;\n public readonly localPeerId: PublicKey;\n public readonly remotePeerId: PublicKey;\n public _sessionId?: PublicKey;\n\n private readonly _ctx = new Context({\n onError: (err) => {\n void this.destroy(err).catch(() => {\n log.error('Error during destroy', err);\n });\n },\n });\n\n private readonly _muxer = new Muxer();\n\n private readonly _control;\n\n private readonly _extensions = new Map<string, TeleportExtension>();\n private readonly _remoteExtensions = new Set<string>();\n\n private _open = false;\n private _destroying = false;\n private _aborting = false;\n\n constructor({ initiator, localPeerId, remotePeerId }: TeleportParams) {\n invariant(typeof initiator === 'boolean');\n invariant(PublicKey.isPublicKey(localPeerId));\n invariant(PublicKey.isPublicKey(remotePeerId));\n this.initiator = initiator;\n this.localPeerId = localPeerId;\n this.remotePeerId = remotePeerId;\n\n this._control = new ControlExtension(\n {\n heartbeatInterval: CONTROL_HEARTBEAT_INTERVAL,\n heartbeatTimeout: CONTROL_HEARTBEAT_TIMEOUT,\n onTimeout: () => {\n if (this._destroying || this._aborting) {\n return;\n }\n log.info('abort teleport due to onTimeout in ControlExtension');\n this.abort(new TimeoutError('control extension')).catch((err) => log.catch(err));\n },\n },\n this.localPeerId,\n this.remotePeerId,\n );\n\n this._control.onExtensionRegistered.set(async (name) => {\n log('remote extension', { name });\n invariant(!this._remoteExtensions.has(name), 'Remote extension already exists');\n this._remoteExtensions.add(name);\n\n if (this._extensions.has(name)) {\n try {\n await this._openExtension(name);\n } catch (err: any) {\n await this.destroy(err);\n }\n }\n });\n\n {\n // Destroy Teleport when the stream is closed.\n this._muxer.stream.on('close', async () => {\n if (this._destroying || this._aborting) {\n log('destroy teleport due to muxer stream close, skipping due to already destroying/aborting');\n return;\n }\n await this.destroy();\n });\n\n this._muxer.stream.on('error', async (err) => {\n await this.destroy(err);\n });\n }\n\n // let last: MuxerStats | undefined;\n this._muxer.statsUpdated.on((stats) => {\n log.trace('dxos.mesh.teleport.stats', {\n localPeerId,\n remotePeerId,\n bytesSent: stats.bytesSent,\n bytesSentRate: stats.bytesSentRate,\n bytesReceived: stats.bytesReceived,\n bytesReceivedRate: stats.bytesReceivedRate,\n channels: stats.channels,\n });\n\n // last = stats;\n });\n }\n\n @logInfo\n get sessionIdString(): string {\n return this._sessionId ? this._sessionId.truncate() : 'none';\n }\n\n get stream(): Duplex {\n return this._muxer.stream;\n }\n\n get stats(): Event<MuxerStats> {\n return this._muxer.statsUpdated;\n }\n\n /**\n * Blocks until the handshake is complete.\n */\n\n async open(sessionId: PublicKey = PublicKey.random()) {\n // invariant(sessionId);\n this._sessionId = sessionId;\n log('open');\n this._setExtension('dxos.mesh.teleport.control', this._control);\n await this._openExtension('dxos.mesh.teleport.control');\n this._open = true;\n this._muxer.setSessionId(sessionId);\n }\n\n async close(err?: Error) {\n // TODO(dmaretskyi): Try soft close.\n await this.destroy(err);\n }\n\n @synchronized\n async abort(err?: Error) {\n if (this._aborting || this._destroying) {\n return;\n }\n this._aborting = true;\n\n if (this._ctx.disposed) {\n return;\n }\n\n await this._ctx.dispose();\n\n for (const extension of this._extensions.values()) {\n try {\n await extension.onAbort(err);\n } catch (err: any) {\n log.catch(err);\n }\n }\n\n await this._muxer.destroy(err);\n }\n\n @synchronized\n // TODO(nf): analyze callers and consider abort instead\n async destroy(err?: Error) {\n if (this._destroying || this._aborting) {\n return;\n }\n this._destroying = true;\n if (this._ctx.disposed) {\n return;\n }\n\n await this._ctx.dispose();\n\n for (const extension of this._extensions.values()) {\n try {\n await extension.onClose(err);\n } catch (err: any) {\n log.catch(err);\n }\n }\n\n await this._muxer.close();\n }\n\n addExtension(name: string, extension: TeleportExtension) {\n if (!this._open) {\n throw new Error('Not open');\n }\n\n log('addExtension', { name });\n this._setExtension(name, extension);\n\n // Perform the registration in a separate tick as this might block while the remote side is opening the extension.\n scheduleTask(this._ctx, async () => {\n try {\n await this._control.registerExtension(name);\n } catch (err) {\n if (err instanceof RpcClosedError) {\n return;\n }\n throw err;\n }\n });\n\n if (this._remoteExtensions.has(name)) {\n // Open the extension in a separate tick.\n scheduleTask(this._ctx, async () => {\n await this._openExtension(name);\n });\n }\n }\n\n private _setExtension(extensionName: string, extension: TeleportExtension) {\n invariant(!extensionName.includes('/'), 'Invalid extension name');\n invariant(!this._extensions.has(extensionName), 'Extension already exists');\n this._extensions.set(extensionName, extension);\n }\n\n private async _openExtension(extensionName: string) {\n log('open extension', { extensionName });\n const extension = this._extensions.get(extensionName) ?? failUndefined();\n\n const context: ExtensionContext = {\n initiator: this.initiator,\n localPeerId: this.localPeerId,\n remotePeerId: this.remotePeerId,\n createPort: async (channelName: string, opts?: CreateChannelOpts) => {\n invariant(!channelName.includes('/'), 'Invalid channel name');\n return this._muxer.createPort(`${extensionName}/${channelName}`, opts);\n },\n createStream: async (channelName: string, opts?: CreateChannelOpts) => {\n invariant(!channelName.includes('/'), 'Invalid channel name');\n return this._muxer.createStream(`${extensionName}/${channelName}`, opts);\n },\n close: (err) => {\n void runInContextAsync(this._ctx, async () => {\n await this.close(err);\n });\n },\n };\n\n await extension.onOpen(context);\n log('extension opened', { extensionName });\n }\n}\n\nexport type ExtensionContext = {\n /**\n * One of the peers will be designated an initiator.\n */\n initiator: boolean;\n localPeerId: PublicKey;\n remotePeerId: PublicKey;\n createStream(tag: string, opts?: CreateChannelOpts): Promise<Duplex>;\n createPort(tag: string, opts?: CreateChannelOpts): Promise<RpcPort>;\n close(err?: Error): void;\n};\n\nexport interface TeleportExtension {\n onOpen(context: ExtensionContext): Promise<void>;\n onClose(err?: Error): Promise<void>;\n onAbort(err?: Error): Promise<void>;\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { asyncTimeout, scheduleTaskInterval, TimeoutError as AsyncTimeoutError } from '@dxos/async';\nimport { Context } from '@dxos/context';\nimport { type PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { schema, RpcClosedError } from '@dxos/protocols';\nimport { type ControlService } from '@dxos/protocols/proto/dxos/mesh/teleport/control';\nimport { createProtoRpcPeer, type ProtoRpcPeer } from '@dxos/rpc';\nimport { Callback } from '@dxos/util';\n\nimport { type ExtensionContext, type TeleportExtension } from './teleport';\n\nconst HEARTBEAT_RTT_WARN_THRESH = 10_000;\n\ntype ControlRpcBundle = {\n Control: ControlService;\n};\n\ntype ControlExtensionOpts = {\n heartbeatInterval: number;\n heartbeatTimeout: number;\n onTimeout: (err: any) => void;\n};\n\nexport class ControlExtension implements TeleportExtension {\n private readonly _ctx = new Context({\n onError: (err) => {\n this._extensionContext.close(err);\n },\n });\n\n public readonly onExtensionRegistered = new Callback<(extensionName: string) => void>();\n\n private _extensionContext!: ExtensionContext;\n private _rpc!: ProtoRpcPeer<{ Control: ControlService }>;\n\n constructor(\n private readonly opts: ControlExtensionOpts,\n private readonly localPeerId: PublicKey,\n private readonly remotePeerId: PublicKey,\n ) {}\n\n async registerExtension(name: string) {\n await this._rpc.rpc.Control.registerExtension({ name });\n }\n\n async onOpen(extensionContext: ExtensionContext): Promise<void> {\n this._extensionContext = extensionContext;\n\n this._rpc = createProtoRpcPeer<ControlRpcBundle, ControlRpcBundle>({\n requested: {\n Control: schema.getService('dxos.mesh.teleport.control.ControlService'),\n },\n exposed: {\n Control: schema.getService('dxos.mesh.teleport.control.ControlService'),\n },\n handlers: {\n Control: {\n registerExtension: async (request) => {\n this.onExtensionRegistered.call(request.name);\n },\n heartbeat: async (request) => {\n log('received heartbeat request', {\n ts: request.requestTimestamp,\n localPeerId: this.localPeerId.truncate(),\n remotePeerId: this.remotePeerId.truncate(),\n });\n return {\n requestTimestamp: request.requestTimestamp,\n };\n },\n },\n },\n port: await extensionContext.createPort('rpc', {\n contentType: 'application/x-protobuf; messageType=\"dxos.rpc.Message\"',\n }),\n timeout: this.opts.heartbeatTimeout,\n });\n\n await this._rpc.open();\n\n scheduleTaskInterval(\n this._ctx,\n async () => {\n const reqTS = new Date();\n try {\n const resp = await asyncTimeout(\n this._rpc.rpc.Control.heartbeat({ requestTimestamp: reqTS }),\n this.opts.heartbeatTimeout,\n );\n const now = Date.now();\n // TODO(nf): properly instrument\n if (resp.requestTimestamp instanceof Date) {\n if (\n now - resp.requestTimestamp.getTime() >\n (HEARTBEAT_RTT_WARN_THRESH < this.opts.heartbeatTimeout\n ? HEARTBEAT_RTT_WARN_THRESH\n : this.opts.heartbeatTimeout / 2)\n ) {\n log.warn(`heartbeat RTT for Teleport > ${HEARTBEAT_RTT_WARN_THRESH / 1000}s`, {\n rtt: now - resp.requestTimestamp.getTime(),\n localPeerId: this.localPeerId.truncate(),\n remotePeerId: this.remotePeerId.truncate(),\n });\n } else {\n log('heartbeat RTT', {\n rtt: now - resp.requestTimestamp.getTime(),\n localPeerId: this.localPeerId.truncate(),\n remotePeerId: this.remotePeerId.truncate(),\n });\n }\n }\n } catch (err: any) {\n const now = Date.now();\n if (err instanceof RpcClosedError) {\n log('ignoring RpcClosedError in heartbeat');\n return;\n }\n if (err instanceof AsyncTimeoutError) {\n log('timeout waiting for heartbeat response', { err, delay: now - reqTS.getTime() });\n this.opts.onTimeout(err);\n } else {\n log.info('other error waiting for heartbeat response', { err, delay: now - reqTS.getTime() });\n this.opts.onTimeout(err);\n }\n }\n },\n this.opts.heartbeatInterval,\n );\n }\n\n async onClose(err?: Error): Promise<void> {\n await this._ctx.dispose();\n await this._rpc.close();\n }\n\n async onAbort(err?: Error | undefined): Promise<void> {\n await this._ctx.dispose();\n await this._rpc.abort();\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { Duplex } from 'node:stream';\n\nimport { Event } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport { type RpcPort } from './rpc-port';\n\nconst FRAME_LENGTH_SIZE = 2;\n\n/**\n * Converts a stream of binary messages into a framed RpcPort.\n * Buffers are written prefixed by their length encoded as a varint.\n */\nexport class Framer {\n // private readonly _tagBuffer = Buffer.alloc(4)\n private _messageCb?: (msg: Uint8Array) => void = undefined;\n private _subscribeCb?: () => void = undefined;\n private _buffer?: Buffer = undefined; // The rest of the bytes from the previous write call.\n private _sendCallbacks: (() => void)[] = [];\n\n private _bytesSent = 0;\n private _bytesReceived = 0;\n\n private _writable = true;\n\n readonly drain = new Event();\n\n // TODO(egorgripasov): Consider using a Transform stream if it provides better backpressure handling.\n private readonly _stream = new Duplex({\n objectMode: false,\n read: () => {\n this._processResponseQueue();\n },\n write: (chunk, encoding, callback) => {\n invariant(!this._subscribeCb, 'Internal Framer bug. Concurrent writes detected.');\n\n this._bytesReceived += chunk.length;\n\n if (this._buffer && this._buffer.length > 0) {\n this._buffer = Buffer.concat([this._buffer, chunk]);\n } else {\n this._buffer = chunk;\n }\n\n if (this._messageCb) {\n this._popFrames();\n callback();\n } else {\n this._subscribeCb = () => {\n // Schedule the processing of the chunk after the peer subscribes to the messages.\n this._popFrames();\n this._subscribeCb = undefined;\n callback();\n };\n }\n },\n });\n\n public readonly port: RpcPort = {\n send: (message) => {\n // log('write', { len: message.length, frame: Buffer.from(message).toString('hex') })\n return new Promise<void>((resolve) => {\n const frame = encodeFrame(message);\n this._bytesSent += frame.length;\n this._writable = this._stream.push(frame);\n if (!this._writable) {\n this._sendCallbacks.push(resolve);\n } else {\n resolve();\n }\n });\n },\n subscribe: (callback) => {\n invariant(!this._messageCb, 'Rpc port already has a message listener.');\n this._messageCb = callback;\n this._subscribeCb?.();\n return () => {\n this._messageCb = undefined;\n };\n },\n };\n\n get stream(): Duplex {\n return this._stream;\n }\n\n get bytesSent() {\n return this._bytesSent;\n }\n\n get bytesReceived() {\n return this._bytesReceived;\n }\n\n get writable() {\n return this._writable;\n }\n\n private _processResponseQueue() {\n const responseQueue = this._sendCallbacks;\n this._sendCallbacks = [];\n this._writable = true;\n this.drain.emit();\n responseQueue.forEach((cb) => cb());\n }\n\n /**\n * Attempts to pop frames from the buffer and call the message callback.\n */\n private _popFrames() {\n let offset = 0;\n while (offset < this._buffer!.length) {\n const frame = decodeFrame(this._buffer!, offset);\n\n if (!frame) {\n break; // Couldn't read frame but there are still bytes left in the buffer.\n }\n offset += frame.bytesConsumed;\n // TODO(dmaretskyi): Possible bug if the peer unsubscribes while we're reading frames.\n // log('read', { len: frame.payload.length, frame: Buffer.from(frame.payload).toString('hex') })\n this._messageCb!(frame.payload);\n }\n\n if (offset < this._buffer!.length) {\n // Save the rest of the bytes for the next write call.\n this._buffer = this._buffer!.subarray(offset);\n } else {\n this._buffer = undefined;\n }\n }\n\n destroy() {\n // TODO(dmaretskyi): Call stream.end() instead?\n if (this._stream.readableLength > 0) {\n log('framer destroyed while there are still read bytes in the buffer.');\n }\n if (this._stream.writableLength > 0) {\n log.warn('framer destroyed while there are still write bytes in the buffer.');\n }\n this._stream.destroy();\n }\n}\n\n/**\n * Attempts to read a frame from the input buffer.\n */\nexport const decodeFrame = (buffer: Buffer, offset: number): { payload: Buffer; bytesConsumed: number } | undefined => {\n if (buffer.length < offset + FRAME_LENGTH_SIZE) {\n // Not enough bytes to read the frame length.\n return undefined;\n }\n\n const frameLength = buffer.readUInt16BE(offset);\n const bytesConsumed = FRAME_LENGTH_SIZE + frameLength;\n\n if (buffer.length < offset + bytesConsumed) {\n // Not enough bytes to read the frame.\n return undefined;\n }\n\n const payload = buffer.subarray(offset + FRAME_LENGTH_SIZE, offset + bytesConsumed);\n\n return {\n payload,\n bytesConsumed,\n };\n};\n\nexport const encodeFrame = (payload: Uint8Array): Buffer => {\n const frame = Buffer.allocUnsafe(FRAME_LENGTH_SIZE + payload.length);\n frame.writeUInt16BE(payload.length, 0);\n frame.set(payload, FRAME_LENGTH_SIZE);\n return frame;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { Duplex } from 'node:stream';\n\nimport { scheduleTaskInterval, Event, Trigger, asyncTimeout } from '@dxos/async';\nimport { Context } from '@dxos/context';\nimport { failUndefined } from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\nimport { type PublicKey } from '@dxos/keys';\nimport { log, logInfo } from '@dxos/log';\nimport { schema, TimeoutError } from '@dxos/protocols';\nimport { type ConnectionInfo } from '@dxos/protocols/proto/dxos/devtools/swarm';\nimport { Command } from '@dxos/protocols/proto/dxos/mesh/muxer';\n\nimport { Balancer } from './balancer';\nimport { type RpcPort } from './rpc-port';\n\nconst Command = schema.getCodecForType('dxos.mesh.muxer.Command');\n\nconst DEFAULT_SEND_COMMAND_TIMEOUT = 60_000;\nconst DESTROY_COMMAND_SEND_TIMEOUT = 5_000;\n\nexport type CleanupCb = void | (() => void);\n\nexport type CreateChannelOpts = {\n /**\n * MIME type of the wire content.\n *\n * Examples:\n * - application/octet-stream\n * - application/x-protobuf; messageType=\"dxos.rpc.Message\"\n */\n contentType?: string;\n};\n\nexport type MuxerStats = {\n timestamp: number;\n channels: ConnectionInfo.StreamStats[];\n bytesSent: number;\n bytesReceived: number;\n bytesSentRate?: number;\n bytesReceivedRate?: number;\n readBufferSize?: number;\n writeBufferSize?: number;\n};\n\nconst STATS_INTERVAL = 1_000;\nconst MAX_SAFE_FRAME_SIZE = 1_000_000;\nconst SYSTEM_CHANNEL_ID = 0;\nconst GRACEFUL_CLOSE_TIMEOUT = 3_000;\n\ntype Channel = {\n /**\n * Our local channel ID.\n * Incoming Data commands will have this ID.\n */\n id: number;\n tag: string;\n\n /**\n * Remote id is set when we receive an OpenChannel command.\n * The originating Data commands should carry this id.\n */\n remoteId: null | number;\n\n contentType?: string;\n\n /**\n * Send buffer.\n */\n buffer: Uint8Array[];\n\n /**\n * Set when we initialize a NodeJS stream or an RPC port consuming the channel.\n */\n push: null | ((data: Uint8Array) => void);\n\n destroy: null | ((err?: Error) => void);\n\n stats: {\n bytesSent: number;\n bytesReceived: number;\n };\n};\n\ntype CreateChannelInternalParams = {\n tag: string;\n contentType?: string;\n};\n\n/**\n * Channel based multiplexer.\n *\n * Can be used to open a number of channels represented by streams or RPC ports.\n * Performs framing for RPC ports.\n * Will buffer data until the remote peer opens the channel.\n *\n * The API will not advertise channels that as they are opened by the remote peer.\n * A higher level API (could be build on top of this muxer) for channel discovery is required.\n */\nexport class Muxer {\n private readonly _balancer = new Balancer(SYSTEM_CHANNEL_ID);\n private readonly _channelsByLocalId = new Map<number, Channel>();\n private readonly _channelsByTag = new Map<string, Channel>();\n private readonly _ctx = new Context();\n private _sessionId?: PublicKey;\n\n private _nextId = 1;\n\n private _closing = false;\n private _destroying = false;\n private _disposed = false;\n\n private _lastStats?: MuxerStats = undefined;\n private readonly _lastChannelStats = new Map<number, Channel['stats']>();\n\n public afterClosed = new Event<Error | undefined>();\n public statsUpdated = new Event<MuxerStats>();\n\n public readonly stream = this._balancer.stream;\n\n constructor() {\n // Add a channel for control messages.\n this._balancer.incomingData.on(async (msg) => {\n await this._handleCommand(Command.decode(msg));\n });\n }\n\n setSessionId(sessionId: PublicKey) {\n this._sessionId = sessionId;\n }\n\n @logInfo\n get sessionIdString(): string {\n return this._sessionId ? this._sessionId.truncate() : 'none';\n }\n\n /**\n * Creates a duplex Node.js-style stream.\n * The remote peer is expected to call `createStream` with the same tag.\n * The stream is immediately readable and writable.\n * NOTE: The data will be buffered until the stream is opened remotely with the same tag (may cause a memory leak).\n */\n async createStream(tag: string, opts: CreateChannelOpts = {}): Promise<Duplex> {\n const channel = this._getOrCreateStream({\n tag,\n contentType: opts.contentType,\n });\n invariant(!channel.push, `Channel already open: ${tag}`);\n\n const stream = new Duplex({\n write: (data, encoding, callback) => {\n this._sendData(channel, data)\n .then(() => callback())\n .catch(callback);\n // TODO(dmaretskyi): Should we error if sending data has errored?\n },\n read: () => {}, // No-op. We will push data when we receive it.\n });\n\n channel.push = (data) => {\n channel.stats.bytesReceived += data.length;\n stream.push(data);\n };\n channel.destroy = (err) => {\n // TODO(dmaretskyi): Call stream.end() instead?\n if (err) {\n if (stream.listeners('error').length > 0) {\n stream.destroy(err);\n } else {\n stream.destroy();\n }\n } else {\n stream.destroy();\n }\n };\n\n // NOTE: Make sure channel.push is set before sending the command.\n try {\n await this._sendCommand(\n {\n openChannel: {\n id: channel.id,\n tag: channel.tag,\n contentType: channel.contentType,\n },\n },\n SYSTEM_CHANNEL_ID,\n );\n } catch (err: any) {\n this._destroyChannel(channel, err);\n throw err;\n }\n\n return stream;\n }\n\n /**\n * Creates an RPC port.\n * The remote peer is expected to call `createPort` with the same tag.\n * The port is immediately usable.\n * NOTE: The data will be buffered until the stream is opened remotely with the same tag (may cause a memory leak).\n */\n async createPort(tag: string, opts: CreateChannelOpts = {}): Promise<RpcPort> {\n const channel = this._getOrCreateStream({\n tag,\n contentType: opts.contentType,\n });\n invariant(!channel.push, `Channel already open: ${tag}`);\n\n // We need to buffer incoming data until the port is subscribed to.\n let inboundBuffer: Uint8Array[] = [];\n let callback: ((data: Uint8Array) => void) | undefined;\n\n channel.push = (data) => {\n channel.stats.bytesReceived += data.length;\n if (callback) {\n callback(data);\n } else {\n inboundBuffer.push(data);\n }\n };\n\n const port: RpcPort = {\n send: async (data: Uint8Array, timeout?: number) => {\n await this._sendData(channel, data, timeout);\n // TODO(dmaretskyi): Debugging.\n // appendFileSync('log.json', JSON.stringify(schema.getCodecForType('dxos.rpc.RpcMessage').decode(data), null, 2) + '\\n')\n },\n subscribe: (cb: (data: Uint8Array) => void) => {\n invariant(!callback, 'Only one subscriber is allowed');\n callback = cb;\n for (const data of inboundBuffer) {\n cb(data);\n }\n inboundBuffer = [];\n },\n };\n\n // NOTE: Make sure channel.push is set before sending the command.\n try {\n await this._sendCommand(\n {\n openChannel: {\n id: channel.id,\n tag: channel.tag,\n contentType: channel.contentType,\n },\n },\n SYSTEM_CHANNEL_ID,\n );\n } catch (err: any) {\n this._destroyChannel(channel, err);\n throw err;\n }\n\n return port;\n }\n\n // initiate graceful close\n\n async close(err?: Error) {\n if (this._destroying) {\n log('already destroying, ignoring graceful close request');\n return;\n }\n if (this._closing) {\n log('already closing, ignoring graceful close request');\n return;\n }\n\n this._closing = true;\n\n await this._sendCommand(\n {\n close: {\n error: err?.message,\n },\n },\n SYSTEM_CHANNEL_ID,\n DESTROY_COMMAND_SEND_TIMEOUT,\n ).catch(async (err: any) => {\n log('error sending close command', { err });\n\n await this._dispose(err);\n });\n\n // don't return until close is complete or timeout\n await asyncTimeout(this._dispose(err), GRACEFUL_CLOSE_TIMEOUT, new TimeoutError('gracefully closing muxer'));\n }\n\n // force close without confirmation\n\n async destroy(err?: Error) {\n if (this._destroying) {\n log('already destroying, ignoring destroy request');\n return;\n }\n this._destroying = true;\n void this._ctx.dispose();\n if (this._closing) {\n log('destroy cancelling graceful close');\n this._closing = false;\n } else {\n // as a courtesy to the peer, send destroy command but ignore errors sending\n\n await this._sendCommand(\n {\n close: {\n error: err?.message,\n },\n },\n SYSTEM_CHANNEL_ID,\n ).catch(async (err: any) => {\n log('error sending courtesy close command', { err });\n });\n }\n\n this._dispose(err).catch((err) => {\n log('error disposing after destroy', { err });\n });\n }\n\n // complete the termination, graceful or otherwise\n\n async _dispose(err?: Error) {\n if (this._disposed) {\n log('already destroyed, ignoring dispose request');\n return;\n }\n\n void this._ctx.dispose();\n\n await this._balancer.destroy();\n\n for (const channel of this._channelsByTag.values()) {\n channel.destroy?.(err);\n }\n this._disposed = true;\n await this._emitStats();\n\n this.afterClosed.emit(err);\n\n // Make it easy for GC.\n this._channelsByLocalId.clear();\n this._channelsByTag.clear();\n }\n\n private async _handleCommand(cmd: Command) {\n if (this._disposed) {\n log.warn('Received command after disposed', { cmd });\n return;\n }\n\n if (cmd.close) {\n if (!this._closing) {\n log('received peer close, initiating my own graceful close');\n await this.close(new Error('received peer close'));\n } else {\n log('received close from peer, already closing');\n }\n\n return;\n }\n\n if (cmd.openChannel) {\n const channel = this._getOrCreateStream({\n tag: cmd.openChannel.tag,\n contentType: cmd.openChannel.contentType,\n });\n channel.remoteId = cmd.openChannel.id;\n\n // Flush any buffered data.\n for (const data of channel.buffer) {\n await this._sendCommand(\n {\n data: {\n channelId: channel.remoteId!,\n data,\n },\n },\n channel.id,\n );\n }\n channel.buffer = [];\n } else if (cmd.data) {\n const stream = this._channelsByLocalId.get(cmd.data.channelId) ?? failUndefined();\n if (!stream.push) {\n log.warn('Received data for channel before it was opened', { tag: stream.tag });\n return;\n }\n stream.push(cmd.data.data);\n }\n }\n\n private async _sendCommand(cmd: Command, channelId = -1, timeout = DEFAULT_SEND_COMMAND_TIMEOUT) {\n if (this._disposed) {\n log.info('ignoring sendCommand after disposed', { cmd });\n return;\n }\n try {\n const trigger = new Trigger<void>();\n this._balancer.pushData(Command.encode(cmd), trigger, channelId);\n await trigger.wait({ timeout });\n } catch (err: any) {\n await this.destroy(err);\n }\n }\n\n private _getOrCreateStream(params: CreateChannelInternalParams): Channel {\n if (this._channelsByTag.size === 0) {\n scheduleTaskInterval(this._ctx, async () => this._emitStats(), STATS_INTERVAL);\n }\n let channel = this._channelsByTag.get(params.tag);\n if (!channel) {\n channel = {\n id: this._nextId++,\n remoteId: null,\n tag: params.tag,\n contentType: params.contentType,\n buffer: [],\n push: null,\n destroy: null,\n stats: {\n bytesSent: 0,\n bytesReceived: 0,\n },\n };\n this._channelsByTag.set(channel.tag, channel);\n this._channelsByLocalId.set(channel.id, channel);\n this._balancer.addChannel(channel.id);\n }\n\n return channel;\n }\n\n private async _sendData(channel: Channel, data: Uint8Array, timeout?: number): Promise<void> {\n if (data.length > MAX_SAFE_FRAME_SIZE) {\n log.warn('frame size exceeds maximum safe value', { size: data.length, threshold: MAX_SAFE_FRAME_SIZE });\n }\n\n channel.stats.bytesSent += data.length;\n if (channel.remoteId === null) {\n // Remote side has not opened the channel yet.\n channel.buffer.push(data);\n return;\n }\n await this._sendCommand(\n {\n data: {\n channelId: channel.remoteId,\n data,\n },\n },\n channel.id,\n timeout,\n );\n }\n\n private _destroyChannel(channel: Channel, err?: Error) {\n if (channel.destroy) {\n channel.destroy(err);\n }\n\n this._channelsByLocalId.delete(channel.id);\n this._channelsByTag.delete(channel.tag);\n }\n\n private async _emitStats() {\n if (this._disposed || this._destroying) {\n if (!this._lastStats) {\n return;\n }\n\n // zero out counting stats to not skew metrics.\n const lastStats = this._lastStats;\n this._lastStats = undefined;\n\n lastStats.readBufferSize = 0;\n lastStats.writeBufferSize = 0;\n for (const c of lastStats.channels) {\n c.writeBufferSize = 0;\n }\n this.statsUpdated.emit(lastStats);\n\n this._lastChannelStats.clear();\n return;\n }\n\n const bytesSent = this._balancer.bytesSent;\n const bytesReceived = this._balancer.bytesReceived;\n\n const now = Date.now();\n const interval = this._lastStats ? (now - this._lastStats.timestamp) / 1_000 : 0;\n const calculateThroughput = (current: Channel['stats'], last: Channel['stats'] | undefined) =>\n last\n ? {\n bytesSentRate: interval ? (current.bytesSent - last.bytesSent) / interval : undefined,\n bytesReceivedRate: interval ? (current.bytesReceived - last.bytesReceived) / interval : undefined,\n }\n : {};\n\n this._lastStats = {\n timestamp: now,\n channels: Array.from(this._channelsByTag.values()).map((channel) => {\n const stats: ConnectionInfo.StreamStats = {\n id: channel.id,\n tag: channel.tag,\n contentType: channel.contentType,\n writeBufferSize: channel.buffer.length,\n bytesSent: channel.stats.bytesSent,\n bytesReceived: channel.stats.bytesReceived,\n ...calculateThroughput(channel.stats, this._lastChannelStats.get(channel.id)),\n };\n\n this._lastChannelStats.set(channel.id, stats);\n return stats;\n }),\n bytesSent,\n bytesReceived,\n ...calculateThroughput({ bytesSent, bytesReceived }, this._lastStats),\n readBufferSize: this._balancer.stream.readableLength,\n writeBufferSize: this._balancer.stream.writableLength,\n };\n\n this.statsUpdated.emit(this._lastStats);\n }\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport * as varint from 'varint';\n\nimport { type Trigger, Event } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport { Framer } from './framer';\n\nconst MAX_CHUNK_SIZE = 8192;\n\ntype Chunk = {\n chunk: Uint8Array;\n channelId: number;\n dataLength?: number;\n};\n\ntype ChunkEnvelope = {\n msg: Buffer;\n trigger?: Trigger;\n};\n\ntype ChannelBuffer = {\n buffer: Buffer;\n msgLength: number;\n};\n\n/**\n * Load balancer for handling asynchronous calls from multiple channels.\n *\n * Manages a queue of calls from different channels and ensures that the calls\n * are processed in a balanced manner in a round-robin fashion.\n */\nexport class Balancer {\n private _lastCallerIndex = 0;\n private _channels: number[] = [];\n\n private readonly _framer = new Framer();\n // TODO(egorgripasov): Will cause a memory leak if channels do not appreciate the backpressure.\n private readonly _sendBuffers: Map<number, ChunkEnvelope[]> = new Map();\n private readonly _receiveBuffers = new Map<number, ChannelBuffer>();\n\n private _sending = false;\n public incomingData = new Event<Uint8Array>();\n public readonly stream = this._framer.stream;\n\n constructor(private readonly _sysChannelId: number) {\n this._channels.push(_sysChannelId);\n\n // Handle incoming messages.\n this._framer.port.subscribe(this._processIncomingMessage.bind(this));\n }\n\n get bytesSent() {\n return this._framer.bytesSent;\n }\n\n get bytesReceived() {\n return this._framer.bytesReceived;\n }\n\n get buffersCount() {\n return this._sendBuffers.size;\n }\n\n addChannel(channel: number) {\n this._channels.push(channel);\n }\n\n pushData(data: Uint8Array, trigger: Trigger, channelId: number) {\n this._enqueueChunk(data, trigger, channelId);\n this._sendChunks().catch((err) => log.catch(err));\n }\n\n destroy() {\n if (this._sendBuffers.size !== 0) {\n log.info('destroying balancer with pending calls');\n }\n this._sendBuffers.clear();\n this._framer.destroy();\n }\n\n private _processIncomingMessage(msg: Uint8Array) {\n const { channelId, dataLength, chunk } = decodeChunk(msg, (channelId) => !this._receiveBuffers.has(channelId));\n if (!this._receiveBuffers.has(channelId)) {\n if (chunk.length < dataLength!) {\n this._receiveBuffers.set(channelId, {\n buffer: Buffer.from(chunk),\n msgLength: dataLength!,\n });\n } else {\n this.incomingData.emit(chunk);\n }\n } else {\n const channelBuffer = this._receiveBuffers.get(channelId)!;\n channelBuffer.buffer = Buffer.concat([channelBuffer.buffer, chunk]);\n if (channelBuffer.buffer.length < channelBuffer.msgLength) {\n return;\n }\n const msg = channelBuffer.buffer;\n this._receiveBuffers.delete(channelId);\n this.incomingData.emit(msg);\n }\n }\n\n private _getNextCallerId() {\n if (this._sendBuffers.has(this._sysChannelId)) {\n return this._sysChannelId;\n }\n\n const index = this._lastCallerIndex;\n this._lastCallerIndex = (this._lastCallerIndex + 1) % this._channels.length;\n\n return this._channels[index];\n }\n\n private _enqueueChunk(data: Uint8Array, trigger: Trigger, channelId: number) {\n if (!this._channels.includes(channelId)) {\n throw new Error(`Unknown channel ${channelId}`);\n }\n\n if (!this._sendBuffers.has(channelId)) {\n this._sendBuffers.set(channelId, []);\n }\n\n const sendBuffer = this._sendBuffers.get(channelId)!;\n\n const chunks = [];\n for (let idx = 0; idx < data.length; idx += MAX_CHUNK_SIZE) {\n chunks.push(data.subarray(idx, idx + MAX_CHUNK_SIZE));\n }\n\n chunks.forEach((chunk, index) => {\n const msg = encodeChunk({\n chunk,\n channelId,\n dataLength: index === 0 ? data.length : undefined,\n });\n sendBuffer.push({ msg, trigger: index === chunks.length - 1 ? trigger : undefined });\n });\n }\n\n // get the next chunk or null if there are no chunks remaining\n\n private _getNextChunk(): ChunkEnvelope | null {\n let chunk;\n while (this._sendBuffers.size > 0) {\n const channelId = this._getNextCallerId();\n const sendBuffer = this._sendBuffers.get(channelId);\n if (!sendBuffer) {\n continue;\n }\n\n chunk = sendBuffer.shift();\n if (!chunk) {\n continue;\n }\n if (sendBuffer.length === 0) {\n this._sendBuffers.delete(channelId);\n }\n return chunk;\n }\n return null;\n }\n\n private async _sendChunks() {\n if (this._sending) {\n return;\n }\n this._sending = true;\n let chunk: ChunkEnvelope | null;\n chunk = this._getNextChunk();\n while (chunk) {\n // TODO(nf): determine whether this is needed since we await the chunk send\n if (!this._framer.writable) {\n log('PAUSE for drain');\n await this._framer.drain.waitForCount(1);\n log('RESUME for drain');\n }\n try {\n await this._framer.port.send(chunk.msg);\n chunk.trigger?.wake();\n } catch (err: any) {\n log('Error sending chunk', { err });\n chunk.trigger?.throw(err);\n }\n chunk = this._getNextChunk();\n }\n invariant(this._sendBuffers.size === 0, 'sendBuffers not empty');\n this._sending = false;\n }\n}\n\nexport const encodeChunk = ({ channelId, dataLength, chunk }: Chunk): Buffer => {\n const channelTagLength = varint.encodingLength(channelId);\n const dataLengthLength = dataLength ? varint.encodingLength(dataLength) : 0;\n const message = Buffer.allocUnsafe(channelTagLength + dataLengthLength + chunk.length);\n varint.encode(channelId, message);\n if (dataLength) {\n varint.encode(dataLength, message, channelTagLength);\n }\n message.set(chunk, channelTagLength + dataLengthLength);\n return message;\n};\n\nexport const decodeChunk = (data: Uint8Array, withLength: (channelId: number) => boolean): Chunk => {\n const channelId = varint.decode(data);\n let dataLength: number | undefined;\n let offset = varint.decode.bytes;\n\n if (withLength(channelId)) {\n dataLength = varint.decode(data, offset);\n offset += varint.decode.bytes;\n }\n\n const chunk = data.subarray(offset);\n\n return { channelId, dataLength, chunk };\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { asyncTimeout, Trigger } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { schema } from '@dxos/protocols';\nimport { type TestService } from '@dxos/protocols/proto/example/testing/rpc';\nimport { createProtoRpcPeer, type ProtoRpcPeer } from '@dxos/rpc';\n\nimport { type ExtensionContext, type TeleportExtension } from '../teleport';\n\ninterface TestExtensionCallbacks {\n onOpen?: () => Promise<void>;\n onClose?: () => Promise<void>;\n onAbort?: () => Promise<void>;\n}\n\nexport class TestExtension implements TeleportExtension {\n public readonly open = new Trigger();\n public readonly closed = new Trigger();\n public readonly aborted = new Trigger();\n public extensionContext: ExtensionContext | undefined;\n private _rpc!: ProtoRpcPeer<{ TestService: TestService }>;\n\n constructor(public readonly callbacks: TestExtensionCallbacks = {}) {}\n\n get remotePeerId() {\n return this.extensionContext?.remotePeerId;\n }\n\n async onOpen(context: ExtensionContext) {\n log('onOpen', { localPeerId: context.localPeerId, remotePeerId: context.remotePeerId });\n this.extensionContext = context;\n this._rpc = createProtoRpcPeer<{ TestService: TestService }, { TestService: TestService }>({\n port: await context.createPort('rpc', {\n contentType: 'application/x-protobuf; messageType=\"dxos.rpc.Message\"',\n }),\n requested: {\n TestService: schema.getService('example.testing.rpc.TestService'),\n },\n exposed: {\n TestService: schema.getService('example.testing.rpc.TestService'),\n },\n handlers: {\n TestService: {\n voidCall: async (request) => {\n // Ok.\n },\n testCall: async (request) => {\n return {\n data: request.data,\n };\n },\n },\n },\n timeout: 2000,\n });\n\n await this._rpc.open();\n await this.callbacks.onOpen?.();\n\n this.open.wake();\n }\n\n async onClose(err?: Error) {\n log('onClose', { err });\n await this.callbacks.onClose?.();\n this.closed.wake();\n await this._rpc?.close();\n }\n\n async onAbort(err?: Error) {\n log('onAbort', { err });\n await this.callbacks.onAbort?.();\n this.aborted.wake();\n await this._rpc?.abort();\n }\n\n async test(message = 'test') {\n await this.open.wait({ timeout: 1500 });\n const res = await asyncTimeout(this._rpc.rpc.TestService.testCall({ data: message }), 1500);\n invariant(res.data === message);\n }\n\n /**\n * Force-close the connection.\n */\n async closeConnection(err?: Error) {\n this.extensionContext?.close(err);\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { randomBytes } from 'node:crypto';\nimport { type Duplex } from 'node:stream';\n\nimport { Trigger } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { schema } from '@dxos/protocols';\nimport { type TestServiceWithStreams } from '@dxos/protocols/proto/example/testing/rpc';\nimport { createProtoRpcPeer, type ProtoRpcPeer } from '@dxos/rpc';\n\nimport { type ExtensionContext, type TeleportExtension } from '../teleport';\n\ninterface TestExtensionWithStreamsCallbacks {\n onOpen?: () => Promise<void>;\n onClose?: () => Promise<void>;\n onAbort?: () => Promise<void>;\n}\n\nexport class TestExtensionWithStreams implements TeleportExtension {\n public readonly open = new Trigger();\n public readonly closed = new Trigger();\n public readonly aborted = new Trigger();\n private readonly _streams = new Map<string, TestStream>();\n\n public extensionContext: ExtensionContext | undefined;\n private _rpc!: ProtoRpcPeer<{ TestServiceWithStreams: TestServiceWithStreams }>;\n\n constructor(public readonly callbacks: TestExtensionWithStreamsCallbacks = {}) {}\n\n get remotePeerId() {\n return this.extensionContext?.remotePeerId;\n }\n\n private async _openStream(streamTag: string, interval = 5, chunkSize = 2048) {\n invariant(!this._streams.has(streamTag), `Stream already exists: ${streamTag}`);\n\n const networkStream = await this.extensionContext!.createStream(streamTag, {\n contentType: 'application/x-test-stream',\n });\n\n const streamEntry: TestStream = {\n networkStream,\n bytesSent: 0,\n bytesReceived: 0,\n sendErrors: 0,\n receiveErrors: 0,\n startTimestamp: Date.now(),\n };\n\n const pushChunk = () => {\n streamEntry.timer = setTimeout(() => {\n const chunk = randomBytes(chunkSize);\n\n if (\n !networkStream.write(chunk, 'binary', (err) => {\n if (!err) {\n streamEntry.bytesSent += chunk.length;\n } else {\n streamEntry.sendErrors += 1;\n }\n })\n ) {\n networkStream.once('drain', pushChunk);\n } else {\n process.nextTick(pushChunk);\n }\n }, interval);\n };\n\n pushChunk();\n\n this._streams.set(streamTag, streamEntry);\n\n networkStream.on('data', (data) => {\n streamEntry.bytesReceived += data.length;\n });\n\n networkStream.on('error', (err) => {\n streamEntry.receiveErrors += 1;\n });\n\n networkStream.on('close', () => {\n networkStream.removeAllListeners();\n });\n\n streamEntry.reportingTimer = setInterval(() => {\n const { bytesSent, bytesReceived, sendErrors, receiveErrors } = streamEntry;\n // log.info('stream stats', { streamTag, bytesSent, bytesReceived, sendErrors, receiveErrors });\n log.trace('dxos.test.stream-stats', {\n streamTag,\n bytesSent,\n bytesReceived,\n sendErrors,\n receiveErrors,\n from: this.extensionContext?.localPeerId,\n to: this.extensionContext?.remotePeerId,\n });\n }, 100);\n }\n\n private _closeStream(streamTag: string): Stats {\n invariant(this._streams.has(streamTag), `Stream does not exist: ${streamTag}`);\n\n const stream = this._streams.get(streamTag)!;\n\n clearTimeout(stream.timer);\n clearTimeout(stream.reportingTimer);\n\n const { bytesSent, bytesReceived, sendErrors, receiveErrors, startTimestamp } = stream;\n\n stream.networkStream.destroy();\n this._streams.delete(streamTag);\n\n return {\n bytesSent,\n bytesReceived,\n sendErrors,\n receiveErrors,\n runningTime: Date.now() - (startTimestamp ?? 0),\n };\n }\n\n async onOpen(context: ExtensionContext) {\n log('onOpen', { localPeerId: context.localPeerId, remotePeerId: context.remotePeerId });\n this.extensionContext = context;\n this._rpc = createProtoRpcPeer<\n { TestServiceWithStreams: TestServiceWithStreams },\n { TestServiceWithStreams: TestServiceWithStreams }\n >({\n port: await context.createPort('rpc', {\n contentType: 'application/x-protobuf; messageType=\"dxos.rpc.Message\"',\n }),\n requested: {\n TestServiceWithStreams: schema.getService('example.testing.rpc.TestServiceWithStreams'),\n },\n exposed: {\n TestServiceWithStreams: schema.getService('example.testing.rpc.TestServiceWithStreams'),\n },\n handlers: {\n TestServiceWithStreams: {\n requestTestStream: async (request) => {\n const { data: streamTag, streamLoadInterval, streamLoadChunkSize } = request;\n\n await this._openStream(streamTag, streamLoadInterval, streamLoadChunkSize);\n\n return {\n data: streamTag,\n };\n },\n closeTestStream: async (request) => {\n const streamTag = request.data;\n const { bytesSent, bytesReceived, sendErrors, receiveErrors, runningTime } = this._closeStream(streamTag);\n\n return {\n data: streamTag,\n bytesSent,\n bytesReceived,\n sendErrors,\n receiveErrors,\n runningTime,\n };\n },\n },\n },\n timeout: 2000,\n });\n\n await this._rpc.open();\n await this.callbacks.onOpen?.();\n\n this.open.wake();\n }\n\n async onClose(err?: Error) {\n log('onClose', { err });\n await this.callbacks.onClose?.();\n this.closed.wake();\n for (const [streamTag, stream] of Object.entries(this._streams)) {\n log('closing stream', { streamTag });\n clearTimeout(stream.interval);\n stream.networkStream.destroy();\n }\n await this._rpc?.close();\n }\n\n async onAbort(err?: Error) {\n log('onAbort', { err });\n await this.callbacks.onAbort?.();\n this.aborted.wake();\n await this._rpc?.abort();\n }\n\n async addNewStream(streamLoadInterval: number, streamLoadChunkSize: number, streamTag?: string): Promise<string> {\n await this.open.wait({ timeout: 1500 });\n if (!streamTag) {\n streamTag = `stream-${randomBytes(4).toString('hex')}`;\n }\n const { data } = await this._rpc.rpc.TestServiceWithStreams.requestTestStream({\n data: streamTag,\n streamLoadInterval,\n streamLoadChunkSize,\n });\n invariant(data === streamTag);\n\n await this._openStream(streamTag, streamLoadInterval, streamLoadChunkSize);\n return streamTag;\n }\n\n async closeStream(streamTag: string): Promise<TestStreamStats> {\n await this.open.wait({ timeout: 1500 });\n const { data, bytesSent, bytesReceived, sendErrors, receiveErrors, runningTime } =\n await this._rpc.rpc.TestServiceWithStreams.closeTestStream({\n data: streamTag,\n });\n\n invariant(data === streamTag);\n\n const local = this._closeStream(streamTag);\n\n return {\n streamTag,\n stats: {\n local,\n remote: {\n bytesSent,\n bytesReceived,\n sendErrors,\n receiveErrors,\n runningTime,\n },\n },\n };\n }\n\n /**\n * Force-close the connection.\n */\n async closeConnection(err?: Error) {\n this.extensionContext?.close(err);\n }\n}\n\ntype Stats = {\n bytesSent: number;\n bytesReceived: number;\n sendErrors: number;\n receiveErrors: number;\n runningTime: number;\n};\n\nexport type TestStreamStats = {\n streamTag: string;\n stats: {\n local: Stats;\n remote: Stats;\n };\n};\n\ntype TestStream = {\n networkStream: Duplex;\n bytesSent: number;\n bytesReceived: number;\n sendErrors: number;\n receiveErrors: number;\n timer?: NodeJS.Timer;\n startTimestamp?: number;\n reportingTimer?: NodeJS.Timer;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAsC;AAEtC,uBAA0B;AAC1B,kBAA0B;AAC1B,iBAAoB;ACFpB,mBAA0E;AAC1E,qBAAwB;AACxB,mBAA8B;AAC9B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G,UAAM,KAAKxQ,KAAKiL,KAAK;MAAEnL,SAAS;IAAK,CAAA;AACrC,QAAI,CAAC0Q,WAAW;AACdA,kBAAY,cAAUU,gCAAY,CAAA,EAAGmB,SAAS,KAAA,CAAA;IAChD;AACA,UAAM,EAAEvM,KAAI,IAAK,MAAM,KAAKrH,KAAKC,IAAImT,uBAAuBC,kBAAkB;MAC5EhM,MAAM0K;MACNuB;MACAC;IACF,CAAA;AACAzP,0BAAAA,WAAUuD,SAAS0K,WAAAA,QAAAA;;;;;;;;;AAEnB,UAAM,KAAKD,YAAYC,WAAWuB,oBAAoBC,mBAAAA;AACtD,WAAOxB;EACT;EAEA,MAAM8B,YAAY9B,WAA6C;AAC7D,UAAM,KAAKxQ,KAAKiL,KAAK;MAAEnL,SAAS;IAAK,CAAA;AACrC,UAAM,EAAEgG,MAAMvC,WAAWC,eAAeoN,YAAYC,eAAee,YAAW,IAC5E,MAAM,KAAKnT,KAAKC,IAAImT,uBAAuBI,gBAAgB;MACzDnM,MAAM0K;IACR,CAAA;AAEFjO,0BAAAA,WAAUuD,SAAS0K,WAAAA,QAAAA;;;;;;;;;AAEnB,UAAM+B,QAAQ,KAAKb,aAAalB,SAAAA;AAEhC,WAAO;MACLA;MACAvG,OAAO;QACLsI;QACAC,QAAQ;UACNjP;UACAC;UACAoN;UACAC;UACAe;QACF;MACF;IACF;EACF;;;;EAKA,MAAMvC,gBAAgBnR,KAAa;AACjC,SAAKW,kBAAkBT,MAAMF,GAAAA;EAC/B;AACF;",
6
+ "names": ["import_invariant", "import_keys", "import_log", "import_async", "import_context", "import_protocols", "import_node_stream", "import_debug", "import_rpc", "HEARTBEAT_RTT_WARN_THRESH", "ControlExtension", "constructor", "opts", "localPeerId", "remotePeerId", "_ctx", "Context", "onError", "err", "_extensionContext", "close", "onExtensionRegistered", "Callback", "registerExtension", "name", "_rpc", "rpc", "Control", "onOpen", "extensionContext", "createProtoRpcPeer", "requested", "schema", "getService", "exposed", "handlers", "request", "call", "heartbeat", "log", "ts", "requestTimestamp", "truncate", "port", "createPort", "contentType", "timeout", "heartbeatTimeout", "open", "scheduleTaskInterval", "reqTS", "Date", "resp", "asyncTimeout", "now", "getTime", "warn", "rtt", "RpcClosedError", "AsyncTimeoutError", "delay", "onTimeout", "info", "heartbeatInterval", "onClose", "dispose", "onAbort", "abort", "FRAME_LENGTH_SIZE", "Framer", "undefined", "_subscribeCb", "_buffer", "_sendCallbacks", "_bytesSent", "_bytesReceived", "_writable", "drain", "Event", "Duplex", "objectMode", "read", "_processResponseQueue", "write", "chunk", "encoding", "callback", "invariant", "length", "Buffer", "concat", "_messageCb", "_popFrames", "send", "message", "Promise", "resolve", "frame", "encodeFrame", "_stream", "push", "subscribe", "stream", "bytesSent", "bytesReceived", "writable", "responseQueue", "emit", "forEach", "cb", "offset", "decodeFrame", "bytesConsumed", "payload", "subarray", "destroy", "readableLength", "writableLength", "buffer", "frameLength", "readUInt16BE", "allocUnsafe", "writeUInt16BE", "set", "MAX_CHUNK_SIZE", "Balancer", "_sysChannelId", "_lastCallerIndex", "_channels", "_framer", "_sendBuffers", "Map", "_receiveBuffers", "_sending", "incomingData", "_processIncomingMessage", "bind", "buffersCount", "size", "addChannel", "channel", "pushData", "data", "trigger", "channelId", "_enqueueChunk", "_sendChunks", "catch", "clear", "msg", "dataLength", "decodeChunk", "has", "from", "msgLength", "channelBuffer", "get", "delete", "_getNextCallerId", "index", "includes", "Error", "sendBuffer", "chunks", "idx", "encodeChunk", "_getNextChunk", "shift", "waitForCount", "wake", "throw", "channelTagLength", "encodingLength", "dataLengthLength", "encode", "withLength", "decode", "bytes", "Command", "getCodecForType", "DEFAULT_SEND_COMMAND_TIMEOUT", "DESTROY_COMMAND_SEND_TIMEOUT", "STATS_INTERVAL", "MAX_SAFE_FRAME_SIZE", "SYSTEM_CHANNEL_ID", "GRACEFUL_CLOSE_TIMEOUT", "Muxer", "_balancer", "_channelsByLocalId", "_channelsByTag", "_nextId", "_closing", "_destroying", "_disposed", "_lastStats", "_lastChannelStats", "afterClosed", "statsUpdated", "on", "_handleCommand", "setSessionId", "sessionId", "_sessionId", "sessionIdString", "createStream", "tag", "_getOrCreateStream", "_sendData", "then", "stats", "listeners", "_sendCommand", "openChannel", "id", "_destroyChannel", "inboundBuffer", "error", "_dispose", "TimeoutError", "values", "_emitStats", "cmd", "remoteId", "failUndefined", "Trigger", "wait", "params", "threshold", "lastStats", "readBufferSize", "writeBufferSize", "c", "channels", "interval", "timestamp", "calculateThroughput", "current", "last", "bytesSentRate", "bytesReceivedRate", "Array", "map", "logInfo", "CONTROL_HEARTBEAT_INTERVAL", "CONTROL_HEARTBEAT_TIMEOUT", "Teleport", "initiator", "_muxer", "_extensions", "_remoteExtensions", "Set", "_open", "_aborting", "PublicKey", "isPublicKey", "_control", "add", "_openExtension", "trace", "random", "_setExtension", "disposed", "extension", "addExtension", "scheduleTask", "extensionName", "context", "channelName", "runInContextAsync", "synchronized", "TestBuilder", "_peers", "createPeer", "peer", "factory", "createPeers", "all", "agent", "connect", "peer1", "peer2", "connection1", "createConnection", "peerId", "connection2", "pipeStreams", "teleport", "openConnection", "disconnect", "connections", "find", "connection", "equals", "closeConnection", "TestPeer", "TestConnection", "stream1", "stream2", "pipeline", "code", "TestExtension", "callbacks", "closed", "aborted", "TestService", "voidCall", "testCall", "test", "res", "TestExtensionWithStreams", "_streams", "_openStream", "streamTag", "chunkSize", "networkStream", "streamEntry", "sendErrors", "receiveErrors", "startTimestamp", "pushChunk", "timer", "setTimeout", "randomBytes", "once", "process", "nextTick", "removeAllListeners", "reportingTimer", "setInterval", "to", "_closeStream", "clearTimeout", "runningTime", "TestServiceWithStreams", "requestTestStream", "streamLoadInterval", "streamLoadChunkSize", "closeTestStream", "Object", "entries", "addNewStream", "toString", "closeStream", "local", "remote"]
7
+ }
@@ -18,20 +18,20 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var node_exports = {};
20
20
  __export(node_exports, {
21
- Framer: () => import_chunk_QAEYMDIX.Framer,
22
- Muxer: () => import_chunk_QAEYMDIX.Muxer,
21
+ Framer: () => import_chunk_FLAJILAD.Framer,
22
+ Muxer: () => import_chunk_FLAJILAD.Muxer,
23
23
  RpcExtension: () => RpcExtension,
24
- Teleport: () => import_chunk_QAEYMDIX.Teleport,
25
- TestBuilder: () => import_chunk_QAEYMDIX.TestBuilder,
26
- TestConnection: () => import_chunk_QAEYMDIX.TestConnection,
27
- TestExtension: () => import_chunk_QAEYMDIX.TestExtension,
28
- TestExtensionWithStreams: () => import_chunk_QAEYMDIX.TestExtensionWithStreams,
29
- TestPeer: () => import_chunk_QAEYMDIX.TestPeer,
30
- decodeFrame: () => import_chunk_QAEYMDIX.decodeFrame,
31
- encodeFrame: () => import_chunk_QAEYMDIX.encodeFrame
24
+ Teleport: () => import_chunk_FLAJILAD.Teleport,
25
+ TestBuilder: () => import_chunk_FLAJILAD.TestBuilder,
26
+ TestConnection: () => import_chunk_FLAJILAD.TestConnection,
27
+ TestExtension: () => import_chunk_FLAJILAD.TestExtension,
28
+ TestExtensionWithStreams: () => import_chunk_FLAJILAD.TestExtensionWithStreams,
29
+ TestPeer: () => import_chunk_FLAJILAD.TestPeer,
30
+ decodeFrame: () => import_chunk_FLAJILAD.decodeFrame,
31
+ encodeFrame: () => import_chunk_FLAJILAD.encodeFrame
32
32
  });
33
33
  module.exports = __toCommonJS(node_exports);
34
- var import_chunk_QAEYMDIX = require("./chunk-QAEYMDIX.cjs");
34
+ var import_chunk_FLAJILAD = require("./chunk-FLAJILAD.cjs");
35
35
  var import_invariant = require("@dxos/invariant");
36
36
  var import_rpc = require("@dxos/rpc");
37
37
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/rpc-extension.ts";
@@ -1 +1 @@
1
- {"inputs":{"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytes":18208,"imports":[{"path":"node:stream","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/muxing/balancer.ts":{"bytes":23877,"imports":[{"path":"varint","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/muxing/framer.ts","kind":"import-statement","original":"./framer"}],"format":"esm"},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytes":51502,"imports":[{"path":"node:stream","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/muxing/balancer.ts","kind":"import-statement","original":"./balancer"}],"format":"esm"},"packages/core/mesh/teleport/src/muxing/rpc-port.ts":{"bytes":1149,"imports":[],"format":"esm"},"packages/core/mesh/teleport/src/muxing/index.ts":{"bytes":641,"imports":[{"path":"packages/core/mesh/teleport/src/muxing/framer.ts","kind":"import-statement","original":"./framer"},{"path":"packages/core/mesh/teleport/src/muxing/muxer.ts","kind":"import-statement","original":"./muxer"},{"path":"packages/core/mesh/teleport/src/muxing/rpc-port.ts","kind":"import-statement","original":"./rpc-port"}],"format":"esm"},"packages/core/mesh/teleport/src/control-extension.ts":{"bytes":17421,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/teleport.ts":{"bytes":31229,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/control-extension.ts","kind":"import-statement","original":"./control-extension"},{"path":"packages/core/mesh/teleport/src/muxing/index.ts","kind":"import-statement","original":"./muxing"}],"format":"esm"},"packages/core/mesh/teleport/src/testing/test-builder.ts":{"bytes":15752,"imports":[{"path":"node:stream","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/teleport.ts","kind":"import-statement","original":"../teleport"}],"format":"esm"},"packages/core/mesh/teleport/src/testing/test-extension.ts":{"bytes":9938,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts":{"bytes":27103,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/testing/index.ts":{"bytes":728,"imports":[{"path":"packages/core/mesh/teleport/src/testing/test-builder.ts","kind":"import-statement","original":"./test-builder"},{"path":"packages/core/mesh/teleport/src/testing/test-extension.ts","kind":"import-statement","original":"./test-extension"},{"path":"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts","kind":"import-statement","original":"./test-extension-with-streams"}],"format":"esm"},"packages/core/mesh/teleport/src/rpc-extension.ts":{"bytes":6077,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/index.ts":{"bytes":741,"imports":[{"path":"packages/core/mesh/teleport/src/muxing/index.ts","kind":"import-statement","original":"./muxing"},{"path":"packages/core/mesh/teleport/src/teleport.ts","kind":"import-statement","original":"./teleport"},{"path":"packages/core/mesh/teleport/src/testing/index.ts","kind":"import-statement","original":"./testing"},{"path":"packages/core/mesh/teleport/src/rpc-extension.ts","kind":"import-statement","original":"./rpc-extension"}],"format":"esm"}},"outputs":{"packages/core/mesh/teleport/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3032},"packages/core/mesh/teleport/dist/lib/node/index.cjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/node/chunk-QAEYMDIX.cjs","kind":"import-statement"},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"exports":["Framer","Muxer","RpcExtension","Teleport","TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer","decodeFrame","encodeFrame"],"entryPoint":"packages/core/mesh/teleport/src/index.ts","inputs":{"packages/core/mesh/teleport/src/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/rpc-extension.ts":{"bytesInOutput":1364}},"bytes":1820},"packages/core/mesh/teleport/dist/lib/node/testing/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/mesh/teleport/dist/lib/node/testing/index.cjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/node/chunk-QAEYMDIX.cjs","kind":"import-statement"}],"exports":["TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer"],"entryPoint":"packages/core/mesh/teleport/src/testing/index.ts","inputs":{},"bytes":266},"packages/core/mesh/teleport/dist/lib/node/chunk-QAEYMDIX.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":91506},"packages/core/mesh/teleport/dist/lib/node/chunk-QAEYMDIX.cjs":{"imports":[{"path":"node:stream","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"node:stream","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"node:stream","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"varint","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"exports":["Framer","Muxer","Teleport","TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer","decodeFrame","encodeFrame"],"inputs":{"packages/core/mesh/teleport/src/testing/test-builder.ts":{"bytesInOutput":4948},"packages/core/mesh/teleport/src/teleport.ts":{"bytesInOutput":9579},"packages/core/mesh/teleport/src/control-extension.ts":{"bytesInOutput":4642},"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytesInOutput":4622},"packages/core/mesh/teleport/src/muxing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytesInOutput":13714},"packages/core/mesh/teleport/src/muxing/balancer.ts":{"bytesInOutput":6007},"packages/core/mesh/teleport/src/testing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/testing/test-extension.ts":{"bytesInOutput":2662},"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts":{"bytesInOutput":7344}},"bytes":54346}}}
1
+ {"inputs":{"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytes":18171,"imports":[{"path":"node:stream","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/muxing/balancer.ts":{"bytes":23877,"imports":[{"path":"varint","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/muxing/framer.ts","kind":"import-statement","original":"./framer"}],"format":"esm"},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytes":51502,"imports":[{"path":"node:stream","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/muxing/balancer.ts","kind":"import-statement","original":"./balancer"}],"format":"esm"},"packages/core/mesh/teleport/src/muxing/rpc-port.ts":{"bytes":1149,"imports":[],"format":"esm"},"packages/core/mesh/teleport/src/muxing/index.ts":{"bytes":641,"imports":[{"path":"packages/core/mesh/teleport/src/muxing/framer.ts","kind":"import-statement","original":"./framer"},{"path":"packages/core/mesh/teleport/src/muxing/muxer.ts","kind":"import-statement","original":"./muxer"},{"path":"packages/core/mesh/teleport/src/muxing/rpc-port.ts","kind":"import-statement","original":"./rpc-port"}],"format":"esm"},"packages/core/mesh/teleport/src/control-extension.ts":{"bytes":17421,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/teleport.ts":{"bytes":31229,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/control-extension.ts","kind":"import-statement","original":"./control-extension"},{"path":"packages/core/mesh/teleport/src/muxing/index.ts","kind":"import-statement","original":"./muxing"}],"format":"esm"},"packages/core/mesh/teleport/src/testing/test-builder.ts":{"bytes":15752,"imports":[{"path":"node:stream","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/mesh/teleport/src/teleport.ts","kind":"import-statement","original":"../teleport"}],"format":"esm"},"packages/core/mesh/teleport/src/testing/test-extension.ts":{"bytes":9938,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts":{"bytes":27103,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/testing/index.ts":{"bytes":728,"imports":[{"path":"packages/core/mesh/teleport/src/testing/test-builder.ts","kind":"import-statement","original":"./test-builder"},{"path":"packages/core/mesh/teleport/src/testing/test-extension.ts","kind":"import-statement","original":"./test-extension"},{"path":"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts","kind":"import-statement","original":"./test-extension-with-streams"}],"format":"esm"},"packages/core/mesh/teleport/src/rpc-extension.ts":{"bytes":6077,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"format":"esm"},"packages/core/mesh/teleport/src/index.ts":{"bytes":741,"imports":[{"path":"packages/core/mesh/teleport/src/muxing/index.ts","kind":"import-statement","original":"./muxing"},{"path":"packages/core/mesh/teleport/src/teleport.ts","kind":"import-statement","original":"./teleport"},{"path":"packages/core/mesh/teleport/src/testing/index.ts","kind":"import-statement","original":"./testing"},{"path":"packages/core/mesh/teleport/src/rpc-extension.ts","kind":"import-statement","original":"./rpc-extension"}],"format":"esm"}},"outputs":{"packages/core/mesh/teleport/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3032},"packages/core/mesh/teleport/dist/lib/node/index.cjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/node/chunk-FLAJILAD.cjs","kind":"import-statement"},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"exports":["Framer","Muxer","RpcExtension","Teleport","TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer","decodeFrame","encodeFrame"],"entryPoint":"packages/core/mesh/teleport/src/index.ts","inputs":{"packages/core/mesh/teleport/src/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/rpc-extension.ts":{"bytesInOutput":1364}},"bytes":1820},"packages/core/mesh/teleport/dist/lib/node/testing/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/mesh/teleport/dist/lib/node/testing/index.cjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/node/chunk-FLAJILAD.cjs","kind":"import-statement"}],"exports":["TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer"],"entryPoint":"packages/core/mesh/teleport/src/testing/index.ts","inputs":{},"bytes":266},"packages/core/mesh/teleport/dist/lib/node/chunk-FLAJILAD.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":91485},"packages/core/mesh/teleport/dist/lib/node/chunk-FLAJILAD.cjs":{"imports":[{"path":"node:stream","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"node:stream","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"node:stream","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"varint","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}],"exports":["Framer","Muxer","Teleport","TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer","decodeFrame","encodeFrame"],"inputs":{"packages/core/mesh/teleport/src/testing/test-builder.ts":{"bytesInOutput":4948},"packages/core/mesh/teleport/src/teleport.ts":{"bytesInOutput":9579},"packages/core/mesh/teleport/src/control-extension.ts":{"bytesInOutput":4642},"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytesInOutput":4617},"packages/core/mesh/teleport/src/muxing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytesInOutput":13714},"packages/core/mesh/teleport/src/muxing/balancer.ts":{"bytesInOutput":6007},"packages/core/mesh/teleport/src/testing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/testing/test-extension.ts":{"bytesInOutput":2662},"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts":{"bytesInOutput":7344}},"bytes":54341}}}
@@ -18,14 +18,14 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var testing_exports = {};
20
20
  __export(testing_exports, {
21
- TestBuilder: () => import_chunk_QAEYMDIX.TestBuilder,
22
- TestConnection: () => import_chunk_QAEYMDIX.TestConnection,
23
- TestExtension: () => import_chunk_QAEYMDIX.TestExtension,
24
- TestExtensionWithStreams: () => import_chunk_QAEYMDIX.TestExtensionWithStreams,
25
- TestPeer: () => import_chunk_QAEYMDIX.TestPeer
21
+ TestBuilder: () => import_chunk_FLAJILAD.TestBuilder,
22
+ TestConnection: () => import_chunk_FLAJILAD.TestConnection,
23
+ TestExtension: () => import_chunk_FLAJILAD.TestExtension,
24
+ TestExtensionWithStreams: () => import_chunk_FLAJILAD.TestExtensionWithStreams,
25
+ TestPeer: () => import_chunk_FLAJILAD.TestPeer
26
26
  });
27
27
  module.exports = __toCommonJS(testing_exports);
28
- var import_chunk_QAEYMDIX = require("../chunk-QAEYMDIX.cjs");
28
+ var import_chunk_FLAJILAD = require("../chunk-FLAJILAD.cjs");
29
29
  // Annotate the CommonJS export names for ESM import in node:
30
30
  0 && (module.exports = {
31
31
  TestBuilder,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["index.cjs"],
4
- "sourcesContent": ["import {\n TestBuilder,\n TestConnection,\n TestExtension,\n TestExtensionWithStreams,\n TestPeer\n} from \"../chunk-QAEYMDIX.cjs\";\nexport {\n TestBuilder,\n TestConnection,\n TestExtension,\n TestExtensionWithStreams,\n TestPeer\n};\n//# sourceMappingURL=index.cjs.map\n"],
4
+ "sourcesContent": ["import {\n TestBuilder,\n TestConnection,\n TestExtension,\n TestExtensionWithStreams,\n TestPeer\n} from \"../chunk-FLAJILAD.cjs\";\nexport {\n TestBuilder,\n TestConnection,\n TestExtension,\n TestExtensionWithStreams,\n TestPeer\n};\n//# sourceMappingURL=index.cjs.map\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAMO;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/teleport",
3
- "version": "0.5.0",
3
+ "version": "0.5.1-main.16a1d7d",
4
4
  "description": "Stream muxer.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -21,23 +21,23 @@
21
21
  "dependencies": {
22
22
  "randombytes": "^2.1.0",
23
23
  "varint": "6.0.0",
24
- "@dxos/async": "0.5.0",
25
- "@dxos/invariant": "0.5.0",
26
- "@dxos/context": "0.5.0",
27
- "@dxos/debug": "0.5.0",
28
- "@dxos/log": "0.5.0",
29
- "@dxos/keys": "0.5.0",
30
- "@dxos/node-std": "0.5.0",
31
- "@dxos/protocols": "0.5.0",
32
- "@dxos/rpc": "0.5.0",
33
- "@dxos/util": "0.5.0"
24
+ "@dxos/async": "0.5.1-main.16a1d7d",
25
+ "@dxos/debug": "0.5.1-main.16a1d7d",
26
+ "@dxos/invariant": "0.5.1-main.16a1d7d",
27
+ "@dxos/keys": "0.5.1-main.16a1d7d",
28
+ "@dxos/log": "0.5.1-main.16a1d7d",
29
+ "@dxos/context": "0.5.1-main.16a1d7d",
30
+ "@dxos/node-std": "0.5.1-main.16a1d7d",
31
+ "@dxos/rpc": "0.5.1-main.16a1d7d",
32
+ "@dxos/protocols": "0.5.1-main.16a1d7d",
33
+ "@dxos/util": "0.5.1-main.16a1d7d"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/randombytes": "^2.0.0",
37
37
  "@types/varint": "6.0.0",
38
38
  "typescript": "^5.2.2",
39
39
  "wait-for-expect": "^3.0.2",
40
- "@dxos/async": "0.5.0"
40
+ "@dxos/async": "0.5.1-main.16a1d7d"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"
@@ -137,7 +137,7 @@ export class Framer {
137
137
  destroy() {
138
138
  // TODO(dmaretskyi): Call stream.end() instead?
139
139
  if (this._stream.readableLength > 0) {
140
- log.info('framer destroyed while there are still read bytes in the buffer.');
140
+ log('framer destroyed while there are still read bytes in the buffer.');
141
141
  }
142
142
  if (this._stream.writableLength > 0) {
143
143
  log.warn('framer destroyed while there are still write bytes in the buffer.');