@dxos/teleport 0.1.55-main.fc12f7c → 0.1.55-main.ff36828

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.
@@ -524,7 +524,6 @@ var Teleport = class {
524
524
  invariant3(typeof initiator === "boolean");
525
525
  invariant3(PublicKey.isPublicKey(localPeerId));
526
526
  invariant3(PublicKey.isPublicKey(remotePeerId));
527
- invariant3(typeof initiator === "boolean");
528
527
  this.initiator = initiator;
529
528
  this.localPeerId = localPeerId;
530
529
  this.remotePeerId = remotePeerId;
@@ -533,7 +532,7 @@ var Teleport = class {
533
532
  name
534
533
  }, {
535
534
  F: __dxlog_file2,
536
- L: 65,
535
+ L: 64,
537
536
  S: this,
538
537
  C: (f, a) => f(...a)
539
538
  });
@@ -584,7 +583,7 @@ var Teleport = class {
584
583
  } catch (err2) {
585
584
  log2.catch(err2, void 0, {
586
585
  F: __dxlog_file2,
587
- L: 125,
586
+ L: 124,
588
587
  S: this,
589
588
  C: (f, a) => f(...a)
590
589
  });
@@ -600,7 +599,7 @@ var Teleport = class {
600
599
  name
601
600
  }, {
602
601
  F: __dxlog_file2,
603
- L: 137,
602
+ L: 136,
604
603
  S: this,
605
604
  C: (f, a) => f(...a)
606
605
  });
@@ -632,7 +631,7 @@ var Teleport = class {
632
631
  extensionName
633
632
  }, {
634
633
  F: __dxlog_file2,
635
- L: 167,
634
+ L: 166,
636
635
  S: this,
637
636
  C: (f, a) => f(...a)
638
637
  });
@@ -660,7 +659,7 @@ var Teleport = class {
660
659
  extensionName
661
660
  }, {
662
661
  F: __dxlog_file2,
663
- L: 190,
662
+ L: 189,
664
663
  S: this,
665
664
  C: (f, a) => f(...a)
666
665
  });
@@ -1142,4 +1141,4 @@ export {
1142
1141
  TestExtension,
1143
1142
  TestExtensionWithStreams
1144
1143
  };
1145
- //# sourceMappingURL=chunk-ELGCMVAN.mjs.map
1144
+ //# sourceMappingURL=chunk-HCC6HY7F.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/testing/test-builder.ts", "../../../src/teleport.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 { Duplex, pipeline } from 'node:stream';\nimport invariant from 'tiny-invariant';\n\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();\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 { Duplex } from 'node:stream';\nimport invariant from 'tiny-invariant';\n\nimport { asyncTimeout, scheduleTaskInterval, runInContextAsync, synchronized, scheduleTask, Event } from '@dxos/async';\nimport { Context } from '@dxos/context';\nimport { failUndefined } from '@dxos/debug';\nimport { PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { schema, RpcClosedError } from '@dxos/protocols';\nimport { ConnectionInfo } from '@dxos/protocols/proto/dxos/devtools/swarm';\nimport { ControlService } from '@dxos/protocols/proto/dxos/mesh/teleport/control';\nimport { createProtoRpcPeer, ProtoRpcPeer } from '@dxos/rpc';\nimport { Callback } from '@dxos/util';\n\nimport { CreateChannelOpts, Muxer, RpcPort } from './muxing';\n\nexport type TeleportParams = {\n initiator: boolean;\n localPeerId: PublicKey;\n remotePeerId: PublicKey;\n};\n\nexport class Teleport {\n public readonly initiator: boolean;\n public readonly localPeerId: PublicKey;\n public readonly remotePeerId: 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 = new ControlExtension({\n heartbeatInterval: 10_000,\n heartbeatTimeout: 10_000,\n onTimeout: () => {\n this.destroy(new Error('Connection timed out')).catch((err) => log.catch(err));\n },\n });\n\n private readonly _extensions = new Map<string, TeleportExtension>();\n private readonly _remoteExtensions = new Set<string>();\n\n private _open = 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.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 await this.destroy();\n });\n\n this._muxer.stream.on('error', async (err) => {\n await this.destroy(err);\n });\n }\n }\n\n get stream(): Duplex {\n return this._muxer.stream;\n }\n\n get stats(): Event<ConnectionInfo.StreamStats[]> {\n return this._muxer.statsUpdated;\n }\n\n /**\n * Blocks until the handshake is complete.\n */\n async open() {\n this._setExtension('dxos.mesh.teleport.control', this._control);\n await this._openExtension('dxos.mesh.teleport.control');\n this._open = true;\n }\n\n async close(err?: Error) {\n // TODO(dmaretskyi): Try soft close.\n\n await this.destroy(err);\n }\n\n @synchronized\n async destroy(err?: Error) {\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 this._muxer.destroy(err);\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}\n\ntype ControlExtensionOpts = {\n heartbeatInterval: number;\n heartbeatTimeout: number;\n onTimeout: () => void;\n};\n\nclass ControlExtension implements TeleportExtension {\n private readonly _ctx = new Context({\n onError: (err) => {\n this._extensionContext.close(err);\n },\n });\n\n private _extensionContext!: ExtensionContext;\n private _rpc!: ProtoRpcPeer<{ Control: ControlService }>;\n\n public readonly onExtensionRegistered = new Callback<(extensionName: string) => void>();\n\n constructor(private readonly opts: ControlExtensionOpts) {}\n\n async onOpen(extensionContext: ExtensionContext): Promise<void> {\n this._extensionContext = extensionContext;\n\n // NOTE: Make sure that RPC timeout is greater than the heartbeat timeout.\n // TODO(dmaretskyi): Allow overwriting the timeout on individual RPC calls?\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 // Ok.\n },\n },\n },\n port: await extensionContext.createPort('rpc', {\n contentType: 'application/x-protobuf; messagType=\"dxos.rpc.Message\"',\n }),\n });\n\n await this._rpc.open();\n\n scheduleTaskInterval(\n this._ctx,\n async () => {\n try {\n await asyncTimeout(this._rpc.rpc.Control.heartbeat(), this.opts.heartbeatTimeout);\n } catch (err: any) {\n this.opts.onTimeout();\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 registerExtension(name: string) {\n await this._rpc.rpc.Control.registerExtension({ name });\n }\n}\n\ntype ControlRpcBundle = {\n Control: ControlService;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { Duplex } from 'node:stream';\nimport invariant from 'tiny-invariant';\nimport * as varint from 'varint';\n\nimport { RpcPort } from './rpc-port';\n\n/**\n * Framer that turns a stream of binary messages into a framed RpcPort.\n *\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;\n private _subscribeCb?: () => void;\n private _buffer?: Buffer; // The rest of the bytes from the previous write call.\n private _responseQueue: (() => void)[] = [];\n\n private readonly _stream = new Duplex({\n objectMode: false,\n read: () => {},\n write: (chunk, encoding, callback) => {\n invariant(!this._subscribeCb, 'Internal Framer bug. Concurrent writes detected.');\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 canContinue = this._stream.push(encodeFrame(message));\n if (!canContinue) {\n this._responseQueue.push(resolve);\n } else {\n process.nextTick(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 constructor() {\n this.stream.on('drain', this._processResponseQueue.bind(this));\n }\n\n private _processResponseQueue() {\n const responseQueue = this._responseQueue;\n this._responseQueue = [];\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 this._stream.removeAllListeners('drain');\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 try {\n const frameLength = varint.decode(buffer, offset);\n const tagLength = varint.decode.bytes;\n\n if (buffer.length < offset + tagLength + frameLength) {\n // Not enough bytes to read the frame.\n return undefined;\n }\n\n const payload = buffer.subarray(offset + tagLength, offset + tagLength + frameLength);\n\n return {\n payload,\n bytesConsumed: tagLength + frameLength,\n };\n } catch (err) {\n if (err instanceof RangeError) {\n // Not enough bytes to read the tag.\n return undefined;\n } else {\n throw err;\n }\n }\n};\n\nexport const encodeFrame = (payload: Uint8Array): Buffer => {\n const tagLength = varint.encodingLength(payload.length);\n const frame = Buffer.allocUnsafe(tagLength + payload.length);\n varint.encode(payload.length, frame);\n frame.set(payload, tagLength);\n return frame;\n};\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { Duplex } from 'node:stream';\nimport invariant from 'tiny-invariant';\n\nimport { scheduleTaskInterval, Event, Trigger } from '@dxos/async';\nimport { Context } from '@dxos/context';\nimport { failUndefined } from '@dxos/debug';\nimport { log } from '@dxos/log';\nimport { schema } from '@dxos/protocols';\nimport { ConnectionInfo } from '@dxos/protocols/proto/dxos/devtools/swarm';\nimport { Command } from '@dxos/protocols/proto/dxos/mesh/muxer';\n\nimport { Balancer } from './balancer';\nimport { Framer } from './framer';\nimport { RpcPort } from './rpc-port';\n\nconst Command = schema.getCodecForType('dxos.mesh.muxer.Command');\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\nconst STATS_INTERVAL = 1000;\n\nconst SYSTEM_CHANNEL_ID = -1;\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 _framer = new Framer();\n private readonly _balancer = new Balancer(this._framer.port, SYSTEM_CHANNEL_ID);\n public readonly stream = this._framer.stream;\n\n private readonly _channelsByLocalId = new Map<number, Channel>();\n private readonly _channelsByTag = new Map<string, Channel>();\n\n private _nextId = 0;\n private _destroyed = false;\n private _destroying = false;\n\n public close = new Event<Error | undefined>();\n\n public statsUpdated = new Event<ConnectionInfo.StreamStats[]>();\n\n private readonly _ctx = new Context();\n\n constructor() {\n // Add a channel for control messages.\n this._framer.port.subscribe(async (msg) => {\n await this._handleCommand(Command.decode(msg));\n });\n\n scheduleTaskInterval(this._ctx, async () => this._emitStats(), STATS_INTERVAL);\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 stream.destroy(err);\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) => {\n await this._sendData(channel, data);\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 /**\n * Force-close with optional error.\n */\n destroy(err?: Error) {\n if (this._destroying) {\n return;\n }\n this._destroying = true;\n\n this._sendCommand(\n {\n destroy: {\n error: err?.message,\n },\n },\n SYSTEM_CHANNEL_ID,\n )\n .then(() => {\n this._dispose();\n })\n .catch((err: any) => {\n this._dispose(err);\n });\n void this._ctx.dispose();\n }\n\n private _dispose(err?: Error) {\n if (this._destroyed) {\n return;\n }\n\n this._destroyed = true;\n this._balancer.destroy();\n this._framer.destroy();\n\n for (const channel of this._channelsByTag.values()) {\n channel.destroy?.(err);\n }\n\n this.close.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 log('Received command', { cmd });\n\n if (this._destroyed || this._destroying) {\n log.warn('Received command after destroy', { cmd });\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 } else if (cmd.destroy) {\n this._dispose();\n }\n }\n\n private async _sendCommand(cmd: Command, channelId = -1) {\n try {\n const trigger = new Trigger<void>();\n this._balancer.pushChunk(Command.encode(cmd), trigger, channelId);\n await trigger.wait();\n } catch (err: any) {\n this.destroy(err);\n }\n }\n\n private _getOrCreateStream(params: CreateChannelInternalParams): Channel {\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 return channel;\n }\n\n private async _sendData(channel: Channel, data: Uint8Array): Promise<void> {\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 );\n }\n\n private _destroyChannel(channel: Channel, err?: Error) {\n if (channel.destroy) {\n channel.destroy(err);\n }\n this._channelsByLocalId.delete(channel.id);\n this._channelsByTag.delete(channel.tag);\n }\n\n private async _emitStats() {\n if (this._destroyed || this._destroying) {\n return;\n }\n\n this.statsUpdated.emit(\n Array.from(this._channelsByTag.values()).map((channel) => ({\n id: channel.id,\n tag: channel.tag,\n bytesSent: channel.stats.bytesSent,\n bytesReceived: channel.stats.bytesReceived,\n })),\n );\n }\n}\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// Copyright 2023 DXOS.org\n//\n\nimport { Trigger } from '@dxos/async';\n\n// TODO(egorgripasov): Is BinaryPort a better name?\nimport { RpcPort } from './rpc-port';\n\ntype Chunk = {\n msg: Uint8Array;\n trigger: Trigger;\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 // TODO(egorgripasov): Will cause a memory leak if channels do not appreciate the backpressure.\n private readonly _calls: Map<number, Chunk[]> = new Map();\n\n constructor(private readonly _port: RpcPort, private readonly _sysChannelId: number) {\n this._channels.push(_sysChannelId);\n }\n\n addChannel(channel: number) {\n this._channels.push(channel);\n }\n\n pushChunk(msg: Uint8Array, trigger: Trigger, channelId: number) {\n const noCalls = this._calls.size === 0;\n\n if (!this._channels.includes(channelId)) {\n throw new Error(`Unknown channel ${channelId}`);\n }\n\n if (!this._calls.has(channelId)) {\n this._calls.set(channelId, []);\n }\n\n const channelCalls = this._calls.get(channelId)!;\n channelCalls.push({ msg, trigger });\n\n // Start processing calls if this is the first call.\n if (noCalls) {\n process.nextTick(async () => {\n await this._processCalls();\n });\n }\n }\n\n destroy() {\n this._calls.clear();\n }\n\n private _getNextCallerId() {\n if (this._calls.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 _getNextCall(): Chunk {\n let call;\n while (!call) {\n const channelId = this._getNextCallerId();\n const channelCalls = this._calls.get(channelId);\n if (!channelCalls) {\n continue;\n }\n\n call = channelCalls.shift();\n if (channelCalls.length === 0) {\n this._calls.delete(channelId);\n }\n }\n return call;\n }\n\n private async _processCalls() {\n if (this._calls.size === 0) {\n return;\n }\n\n const call = this._getNextCall();\n\n try {\n await this._port.send(call.msg);\n call.trigger.wake();\n } catch (err: any) {\n call.trigger.throw(err);\n }\n\n await this._processCalls();\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport invariant from 'tiny-invariant';\n\nimport { asyncTimeout, Trigger } from '@dxos/async';\nimport { log } from '@dxos/log';\nimport { schema } from '@dxos/protocols';\nimport { TestService } from '@dxos/protocols/proto/example/testing/rpc';\nimport { createProtoRpcPeer, ProtoRpcPeer } from '@dxos/rpc';\n\nimport { ExtensionContext, TeleportExtension } from '../teleport';\n\ninterface TestExtensionCallbacks {\n onOpen?: () => Promise<void>;\n onClose?: () => Promise<void>;\n}\n\nexport class TestExtension implements TeleportExtension {\n public readonly open = new Trigger();\n public readonly closed = 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 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 assert from 'node:assert';\nimport { randomBytes } from 'node:crypto';\nimport { Duplex } from 'node:stream';\n\nimport { Trigger } from '@dxos/async';\nimport { log } from '@dxos/log';\nimport { schema } from '@dxos/protocols';\nimport { TestServiceWithStreams } from '@dxos/protocols/proto/example/testing/rpc';\nimport { createProtoRpcPeer, ProtoRpcPeer } from '@dxos/rpc';\n\nimport { ExtensionContext, TeleportExtension } from '../teleport';\n\ninterface TestExtensionWithStreamsCallbacks {\n onOpen?: () => Promise<void>;\n onClose?: () => Promise<void>;\n}\n\nexport class TestExtensionWithStreams implements TeleportExtension {\n public readonly open = new Trigger();\n public readonly closed = 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 assert(!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\n private _closeStream(streamTag: string): Stats {\n assert(this._streams.has(streamTag), `Stream does not exist: ${streamTag}`);\n\n const stream = this._streams.get(streamTag)!;\n\n clearTimeout(stream.timer);\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 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 assert(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 assert(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};\n"],
5
+ "mappings": ";;;AAIA,SAAiBA,gBAAgB;AACjC,OAAOC,gBAAe;AAEtB,SAASC,aAAAA,kBAAiB;AAC1B,SAASC,OAAAA,YAAW;;;ACHpB,OAAOC,gBAAe;AAEtB,SAASC,cAAcC,wBAAAA,uBAAsBC,mBAAmBC,cAAcC,oBAA2B;AACzG,SAASC,WAAAA,gBAAe;AACxB,SAASC,iBAAAA,sBAAqB;AAC9B,SAASC,iBAAiB;AAC1B,SAASC,OAAAA,YAAW;AACpB,SAASC,UAAAA,SAAQC,sBAAsB;AAGvC,SAASC,0BAAwC;AACjD,SA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,UAAM,KAAKD,YAAYC,WAAWiD,oBAAoBC,mBAAAA;AACtD,WAAOlD;EACT;EAEA,MAAM8D,YAAY9D,WAA6C;AAC7D,UAAM,KAAKP,KAAKkE,KAAK;MAAEP,SAAS;IAAK,CAAA;AACrC,UAAM,EAAEzB,MAAMnB,WAAWC,eAAeC,YAAYC,eAAewB,YAAW,IAC5E,MAAM,KAAKI,KAAKsB,IAAIlB,uBAAuBQ,gBAAgB;MACzDxB,MAAM3B;IACR,CAAA;AAEFhB,WAAO2C,SAAS3B,SAAAA;AAEhB,UAAM+D,QAAQ,KAAKlC,aAAa7B,SAAAA;AAEhC,WAAO;MACLA;MACAgE,OAAO;QACLD;QACAE,QAAQ;UACNzD;UACAC;UACAC;UACAC;UACAwB;QACF;MACF;IACF;EACF;;;;EAKA,MAAM+B,gBAAgB9C,KAAa;AAzNrC;AA0NI,eAAKtB,qBAAL,mBAAuB2D,MAAMrC;EAC/B;AACF;",
6
+ "names": ["pipeline", "invariant", "PublicKey", "log", "invariant", "asyncTimeout", "scheduleTaskInterval", "runInContextAsync", "synchronized", "scheduleTask", "Context", "failUndefined", "PublicKey", "log", "schema", "RpcClosedError", "createProtoRpcPeer", "Callback", "Duplex", "invariant", "varint", "Framer", "constructor", "_responseQueue", "_stream", "Duplex", "objectMode", "read", "write", "chunk", "encoding", "callback", "invariant", "_subscribeCb", "_buffer", "length", "Buffer", "concat", "_messageCb", "_popFrames", "undefined", "port", "send", "message", "Promise", "resolve", "canContinue", "push", "encodeFrame", "process", "nextTick", "subscribe", "stream", "on", "_processResponseQueue", "bind", "responseQueue", "forEach", "cb", "offset", "frame", "decodeFrame", "bytesConsumed", "payload", "subarray", "destroy", "removeAllListeners", "buffer", "frameLength", "decode", "tagLength", "bytes", "err", "RangeError", "encodingLength", "allocUnsafe", "varint", "encode", "set", "Duplex", "invariant", "scheduleTaskInterval", "Event", "Trigger", "Context", "failUndefined", "log", "schema", "Balancer", "constructor", "_port", "_sysChannelId", "_lastCallerIndex", "_channels", "_calls", "Map", "push", "addChannel", "channel", "pushChunk", "msg", "trigger", "channelId", "noCalls", "size", "includes", "Error", "has", "set", "channelCalls", "get", "process", "nextTick", "_processCalls", "destroy", "clear", "_getNextCallerId", "index", "length", "_getNextCall", "call", "shift", "delete", "send", "wake", "err", "throw", "Command", "schema", "getCodecForType", "STATS_INTERVAL", "SYSTEM_CHANNEL_ID", "Muxer", "constructor", "_framer", "Framer", "_balancer", "Balancer", "port", "stream", "_channelsByLocalId", "Map", "_channelsByTag", "_nextId", "_destroyed", "_destroying", "close", "Event", "statsUpdated", "_ctx", "Context", "subscribe", "msg", "_handleCommand", "decode", "scheduleTaskInterval", "_emitStats", "createStream", "tag", "opts", "channel", "_getOrCreateStream", "contentType", "invariant", "push", "Duplex", "write", "data", "encoding", "callback", "_sendData", "then", "catch", "read", "stats", "bytesReceived", "length", "destroy", "err", "_sendCommand", "openChannel", "id", "_destroyChannel", "createPort", "inboundBuffer", "send", "cb", "error", "message", "_dispose", "dispose", "values", "emit", "clear", "cmd", "log", "warn", "remoteId", "buffer", "channelId", "get", "failUndefined", "trigger", "Trigger", "pushChunk", "encode", "wait", "params", "bytesSent", "set", "addChannel", "delete", "Array", "from", "map", "Teleport", "constructor", "initiator", "localPeerId", "remotePeerId", "_ctx", "Context", "onError", "err", "destroy", "catch", "log", "error", "_muxer", "Muxer", "_control", "ControlExtension", "heartbeatInterval", "heartbeatTimeout", "onTimeout", "Error", "_extensions", "Map", "_remoteExtensions", "Set", "_open", "invariant", "PublicKey", "isPublicKey", "onExtensionRegistered", "set", "name", "has", "add", "_openExtension", "stream", "on", "stats", "statsUpdated", "open", "_setExtension", "close", "disposed", "dispose", "extension", "values", "onClose", "addExtension", "scheduleTask", "registerExtension", "RpcClosedError", "extensionName", "includes", "get", "failUndefined", "context", "createPort", "channelName", "opts", "createStream", "runInContextAsync", "onOpen", "synchronized", "_extensionContext", "Callback", "extensionContext", "_rpc", "createProtoRpcPeer", "requested", "Control", "schema", "getService", "exposed", "handlers", "request", "call", "heartbeat", "port", "contentType", "scheduleTaskInterval", "asyncTimeout", "rpc", "TestBuilder", "_peers", "Set", "createPeer", "opts", "peer", "factory", "add", "createPeers", "destroy", "Promise", "all", "Array", "from", "map", "agent", "connect", "peer1", "peer2", "invariant", "has", "connection1", "createConnection", "initiator", "remotePeerId", "peerId", "connection2", "pipeStreams", "teleport", "stream", "openConnection", "disconnect", "connections", "find", "connection", "equals", "closeConnection", "TestPeer", "constructor", "PublicKey", "random", "onOpen", "onClose", "TestConnection", "open", "close", "delete", "stream1", "stream2", "pipeline", "err", "code", "log", "catch", "localPeerId", "Teleport", "invariant", "asyncTimeout", "Trigger", "log", "schema", "createProtoRpcPeer", "TestExtension", "constructor", "callbacks", "open", "closed", "remotePeerId", "extensionContext", "onOpen", "context", "localPeerId", "_rpc", "port", "createPort", "contentType", "requested", "TestService", "getService", "exposed", "handlers", "voidCall", "request", "testCall", "data", "timeout", "wake", "onClose", "err", "close", "test", "message", "wait", "res", "rpc", "closeConnection", "assert", "randomBytes", "Trigger", "log", "schema", "createProtoRpcPeer", "TestExtensionWithStreams", "constructor", "callbacks", "open", "closed", "_streams", "Map", "remotePeerId", "extensionContext", "_openStream", "streamTag", "interval", "chunkSize", "has", "networkStream", "createStream", "contentType", "streamEntry", "bytesSent", "bytesReceived", "sendErrors", "receiveErrors", "startTimestamp", "Date", "now", "pushChunk", "timer", "setTimeout", "chunk", "write", "err", "length", "once", "process", "nextTick", "set", "on", "data", "removeAllListeners", "_closeStream", "stream", "get", "clearTimeout", "destroy", "delete", "runningTime", "onOpen", "context", "localPeerId", "_rpc", "port", "createPort", "requested", "TestServiceWithStreams", "getService", "exposed", "handlers", "requestTestStream", "request", "streamLoadInterval", "streamLoadChunkSize", "closeTestStream", "timeout", "wake", "onClose", "Object", "entries", "close", "addNewStream", "wait", "toString", "rpc", "closeStream", "local", "stats", "remote", "closeConnection"]
7
+ }
@@ -10,7 +10,7 @@ import {
10
10
  TestPeer,
11
11
  decodeFrame,
12
12
  encodeFrame
13
- } from "./chunk-ELGCMVAN.mjs";
13
+ } from "./chunk-HCC6HY7F.mjs";
14
14
 
15
15
  // packages/core/mesh/teleport/src/rpc-extension.ts
16
16
  import invariant from "tiny-invariant";
@@ -1 +1 @@
1
- {"inputs":{"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytes":15181,"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"tiny-invariant","kind":"import-statement","external":true},{"path":"varint","kind":"import-statement","external":true}]},"packages/core/mesh/teleport/src/muxing/balancer.ts":{"bytes":9187,"imports":[]},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytes":33140,"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"tiny-invariant","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/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"},{"path":"packages/core/mesh/teleport/src/muxing/framer.ts","kind":"import-statement","original":"./framer"}]},"packages/core/mesh/teleport/src/muxing/rpc-port.ts":{"bytes":925,"imports":[]},"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"}]},"packages/core/mesh/teleport/src/teleport.ts":{"bytes":28571,"imports":[{"path":"tiny-invariant","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/keys","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":"packages/core/mesh/teleport/src/muxing/index.ts","kind":"import-statement","original":"./muxing"}]},"packages/core/mesh/teleport/src/testing/test-builder.ts":{"bytes":13693,"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"tiny-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"}]},"packages/core/mesh/teleport/src/testing/test-extension.ts":{"bytes":8708,"imports":[{"path":"tiny-invariant","kind":"import-statement","external":true},{"path":"@dxos/async","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}]},"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts":{"bytes":23120,"imports":[{"path":"@dxos/node-std/assert","kind":"import-statement","external":true},{"path":"@dxos/node-std/crypto","kind":"import-statement","external":true},{"path":"@dxos/async","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}]},"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"}]},"packages/core/mesh/teleport/src/rpc-extension.ts":{"bytes":5423,"imports":[{"path":"tiny-invariant","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}]},"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"}]}},"outputs":{"packages/core/mesh/teleport/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2813},"packages/core/mesh/teleport/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/browser/chunk-ELGCMVAN.mjs","kind":"import-statement"},{"path":"tiny-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":1099}},"bytes":1588},"packages/core/mesh/teleport/dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/mesh/teleport/dist/lib/browser/testing/index.mjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/browser/chunk-ELGCMVAN.mjs","kind":"import-statement"}],"exports":["TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer"],"entryPoint":"packages/core/mesh/teleport/src/testing/index.ts","inputs":{},"bytes":299},"packages/core/mesh/teleport/dist/lib/browser/chunk-ELGCMVAN.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":65517},"packages/core/mesh/teleport/dist/lib/browser/chunk-ELGCMVAN.mjs":{"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"tiny-invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"tiny-invariant","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/keys","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":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"tiny-invariant","kind":"import-statement","external":true},{"path":"varint","kind":"import-statement","external":true},{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"tiny-invariant","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/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"tiny-invariant","kind":"import-statement","external":true},{"path":"@dxos/async","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/node-std/assert","kind":"import-statement","external":true},{"path":"@dxos/node-std/crypto","kind":"import-statement","external":true},{"path":"@dxos/async","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":3607},"packages/core/mesh/teleport/src/teleport.ts":{"bytesInOutput":7532},"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytesInOutput":3164},"packages/core/mesh/teleport/src/muxing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytesInOutput":7536},"packages/core/mesh/teleport/src/muxing/balancer.ts":{"bytesInOutput":1788},"packages/core/mesh/teleport/src/testing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/testing/test-extension.ts":{"bytesInOutput":2462},"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts":{"bytesInOutput":6152}},"bytes":33046}}}
1
+ {"inputs":{"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytes":15181,"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"tiny-invariant","kind":"import-statement","external":true},{"path":"varint","kind":"import-statement","external":true}]},"packages/core/mesh/teleport/src/muxing/balancer.ts":{"bytes":9187,"imports":[]},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytes":33140,"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"tiny-invariant","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/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"},{"path":"packages/core/mesh/teleport/src/muxing/framer.ts","kind":"import-statement","original":"./framer"}]},"packages/core/mesh/teleport/src/muxing/rpc-port.ts":{"bytes":925,"imports":[]},"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"}]},"packages/core/mesh/teleport/src/teleport.ts":{"bytes":28424,"imports":[{"path":"tiny-invariant","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/keys","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":"packages/core/mesh/teleport/src/muxing/index.ts","kind":"import-statement","original":"./muxing"}]},"packages/core/mesh/teleport/src/testing/test-builder.ts":{"bytes":13693,"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"tiny-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"}]},"packages/core/mesh/teleport/src/testing/test-extension.ts":{"bytes":8708,"imports":[{"path":"tiny-invariant","kind":"import-statement","external":true},{"path":"@dxos/async","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}]},"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts":{"bytes":23120,"imports":[{"path":"@dxos/node-std/assert","kind":"import-statement","external":true},{"path":"@dxos/node-std/crypto","kind":"import-statement","external":true},{"path":"@dxos/async","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}]},"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"}]},"packages/core/mesh/teleport/src/rpc-extension.ts":{"bytes":5423,"imports":[{"path":"tiny-invariant","kind":"import-statement","external":true},{"path":"@dxos/rpc","kind":"import-statement","external":true}]},"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"}]}},"outputs":{"packages/core/mesh/teleport/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2813},"packages/core/mesh/teleport/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/browser/chunk-HCC6HY7F.mjs","kind":"import-statement"},{"path":"tiny-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":1099}},"bytes":1588},"packages/core/mesh/teleport/dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/mesh/teleport/dist/lib/browser/testing/index.mjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/browser/chunk-HCC6HY7F.mjs","kind":"import-statement"}],"exports":["TestBuilder","TestConnection","TestExtension","TestExtensionWithStreams","TestPeer"],"entryPoint":"packages/core/mesh/teleport/src/testing/index.ts","inputs":{},"bytes":299},"packages/core/mesh/teleport/dist/lib/browser/chunk-HCC6HY7F.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":65433},"packages/core/mesh/teleport/dist/lib/browser/chunk-HCC6HY7F.mjs":{"imports":[{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"tiny-invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"tiny-invariant","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/keys","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":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"tiny-invariant","kind":"import-statement","external":true},{"path":"varint","kind":"import-statement","external":true},{"path":"@dxos/node-std/stream","kind":"import-statement","external":true},{"path":"tiny-invariant","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/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"tiny-invariant","kind":"import-statement","external":true},{"path":"@dxos/async","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/node-std/assert","kind":"import-statement","external":true},{"path":"@dxos/node-std/crypto","kind":"import-statement","external":true},{"path":"@dxos/async","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":3607},"packages/core/mesh/teleport/src/teleport.ts":{"bytesInOutput":7484},"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytesInOutput":3164},"packages/core/mesh/teleport/src/muxing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytesInOutput":7536},"packages/core/mesh/teleport/src/muxing/balancer.ts":{"bytesInOutput":1788},"packages/core/mesh/teleport/src/testing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/testing/test-extension.ts":{"bytesInOutput":2462},"packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts":{"bytesInOutput":6152}},"bytes":32998}}}
@@ -5,7 +5,7 @@ import {
5
5
  TestExtension,
6
6
  TestExtensionWithStreams,
7
7
  TestPeer
8
- } from "../chunk-ELGCMVAN.mjs";
8
+ } from "../chunk-HCC6HY7F.mjs";
9
9
  export {
10
10
  TestBuilder,
11
11
  TestConnection,
@@ -560,7 +560,6 @@ var Teleport = class {
560
560
  (0, import_tiny_invariant3.default)(typeof initiator === "boolean");
561
561
  (0, import_tiny_invariant3.default)(import_keys.PublicKey.isPublicKey(localPeerId));
562
562
  (0, import_tiny_invariant3.default)(import_keys.PublicKey.isPublicKey(remotePeerId));
563
- (0, import_tiny_invariant3.default)(typeof initiator === "boolean");
564
563
  this.initiator = initiator;
565
564
  this.localPeerId = localPeerId;
566
565
  this.remotePeerId = remotePeerId;
@@ -569,7 +568,7 @@ var Teleport = class {
569
568
  name
570
569
  }, {
571
570
  F: __dxlog_file2,
572
- L: 65,
571
+ L: 64,
573
572
  S: this,
574
573
  C: (f, a) => f(...a)
575
574
  });
@@ -620,7 +619,7 @@ var Teleport = class {
620
619
  } catch (err2) {
621
620
  import_log2.log.catch(err2, void 0, {
622
621
  F: __dxlog_file2,
623
- L: 125,
622
+ L: 124,
624
623
  S: this,
625
624
  C: (f, a) => f(...a)
626
625
  });
@@ -636,7 +635,7 @@ var Teleport = class {
636
635
  name
637
636
  }, {
638
637
  F: __dxlog_file2,
639
- L: 137,
638
+ L: 136,
640
639
  S: this,
641
640
  C: (f, a) => f(...a)
642
641
  });
@@ -668,7 +667,7 @@ var Teleport = class {
668
667
  extensionName
669
668
  }, {
670
669
  F: __dxlog_file2,
671
- L: 167,
670
+ L: 166,
672
671
  S: this,
673
672
  C: (f, a) => f(...a)
674
673
  });
@@ -696,7 +695,7 @@ var Teleport = class {
696
695
  extensionName
697
696
  }, {
698
697
  F: __dxlog_file2,
699
- L: 190,
698
+ L: 189,
700
699
  S: this,
701
700
  C: (f, a) => f(...a)
702
701
  });