@dxos/teleport 0.3.9-main.c2ac8a5 → 0.3.9-main.cdfefb1
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.
- package/dist/lib/browser/{chunk-M7U4KJA7.mjs → chunk-CZZOJEEL.mjs} +16 -25
- package/dist/lib/browser/chunk-CZZOJEEL.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-GVV33WCQ.cjs → chunk-SJ6CXLWF.cjs} +16 -25
- package/dist/lib/node/chunk-SJ6CXLWF.cjs.map +7 -0
- package/dist/lib/node/index.cjs +11 -11
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +6 -6
- package/dist/lib/node/testing/index.cjs.map +1 -1
- package/dist/types/src/muxing/muxer.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/muxing/muxer.ts +2 -11
- package/dist/lib/browser/chunk-M7U4KJA7.mjs.map +0 -7
- package/dist/lib/node/chunk-GVV33WCQ.cjs.map +0 -7
|
@@ -325,7 +325,7 @@ var encodeFrame = (payload) => {
|
|
|
325
325
|
|
|
326
326
|
// packages/core/mesh/teleport/src/muxing/muxer.ts
|
|
327
327
|
import { Duplex as Duplex2 } from "@dxos/node-std/stream";
|
|
328
|
-
import { scheduleTaskInterval as scheduleTaskInterval2, Event as Event3, Trigger } from "@dxos/async";
|
|
328
|
+
import { scheduleTaskInterval as scheduleTaskInterval2, Event as Event3, Trigger, asyncTimeout as asyncTimeout2 } from "@dxos/async";
|
|
329
329
|
import { Context as Context2 } from "@dxos/context";
|
|
330
330
|
import { failUndefined } from "@dxos/debug";
|
|
331
331
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
@@ -742,23 +742,14 @@ var Muxer = class {
|
|
|
742
742
|
});
|
|
743
743
|
await this._dispose(err2);
|
|
744
744
|
});
|
|
745
|
-
await
|
|
746
|
-
new Promise((_resolve, reject) => {
|
|
747
|
-
setTimeout(() => {
|
|
748
|
-
reject(new TimeoutError("gracefully closing muxer"));
|
|
749
|
-
}, GRACEFUL_CLOSE_TIMEOUT);
|
|
750
|
-
}),
|
|
751
|
-
(async () => {
|
|
752
|
-
await this._dispose(err);
|
|
753
|
-
})()
|
|
754
|
-
]);
|
|
745
|
+
await asyncTimeout2(this._dispose(err), GRACEFUL_CLOSE_TIMEOUT, new TimeoutError("gracefully closing muxer"));
|
|
755
746
|
}
|
|
756
747
|
// force close without confirmation
|
|
757
748
|
async destroy(err) {
|
|
758
749
|
if (this._destroying) {
|
|
759
750
|
log4("already destroying, ignoring destroy request", void 0, {
|
|
760
751
|
F: __dxlog_file4,
|
|
761
|
-
L:
|
|
752
|
+
L: 298,
|
|
762
753
|
S: this,
|
|
763
754
|
C: (f, a) => f(...a)
|
|
764
755
|
});
|
|
@@ -769,7 +760,7 @@ var Muxer = class {
|
|
|
769
760
|
if (this._closing) {
|
|
770
761
|
log4("destroy cancelling graceful close", void 0, {
|
|
771
762
|
F: __dxlog_file4,
|
|
772
|
-
L:
|
|
763
|
+
L: 304,
|
|
773
764
|
S: this,
|
|
774
765
|
C: (f, a) => f(...a)
|
|
775
766
|
});
|
|
@@ -784,7 +775,7 @@ var Muxer = class {
|
|
|
784
775
|
err: err2
|
|
785
776
|
}, {
|
|
786
777
|
F: __dxlog_file4,
|
|
787
|
-
L:
|
|
778
|
+
L: 317,
|
|
788
779
|
S: this,
|
|
789
780
|
C: (f, a) => f(...a)
|
|
790
781
|
});
|
|
@@ -795,7 +786,7 @@ var Muxer = class {
|
|
|
795
786
|
err: err2
|
|
796
787
|
}, {
|
|
797
788
|
F: __dxlog_file4,
|
|
798
|
-
L:
|
|
789
|
+
L: 322,
|
|
799
790
|
S: this,
|
|
800
791
|
C: (f, a) => f(...a)
|
|
801
792
|
});
|
|
@@ -806,7 +797,7 @@ var Muxer = class {
|
|
|
806
797
|
if (this._disposed) {
|
|
807
798
|
log4("already destroyed, ignoring dispose request", void 0, {
|
|
808
799
|
F: __dxlog_file4,
|
|
809
|
-
L:
|
|
800
|
+
L: 330,
|
|
810
801
|
S: this,
|
|
811
802
|
C: (f, a) => f(...a)
|
|
812
803
|
});
|
|
@@ -829,7 +820,7 @@ var Muxer = class {
|
|
|
829
820
|
cmd
|
|
830
821
|
}, {
|
|
831
822
|
F: __dxlog_file4,
|
|
832
|
-
L:
|
|
823
|
+
L: 353,
|
|
833
824
|
S: this,
|
|
834
825
|
C: (f, a) => f(...a)
|
|
835
826
|
});
|
|
@@ -839,7 +830,7 @@ var Muxer = class {
|
|
|
839
830
|
if (!this._closing) {
|
|
840
831
|
log4("received peer close, initiating my own graceful close", void 0, {
|
|
841
832
|
F: __dxlog_file4,
|
|
842
|
-
L:
|
|
833
|
+
L: 359,
|
|
843
834
|
S: this,
|
|
844
835
|
C: (f, a) => f(...a)
|
|
845
836
|
});
|
|
@@ -847,7 +838,7 @@ var Muxer = class {
|
|
|
847
838
|
} else {
|
|
848
839
|
log4("received close from peer, already closing", void 0, {
|
|
849
840
|
F: __dxlog_file4,
|
|
850
|
-
L:
|
|
841
|
+
L: 362,
|
|
851
842
|
S: this,
|
|
852
843
|
C: (f, a) => f(...a)
|
|
853
844
|
});
|
|
@@ -876,7 +867,7 @@ var Muxer = class {
|
|
|
876
867
|
tag: stream.tag
|
|
877
868
|
}, {
|
|
878
869
|
F: __dxlog_file4,
|
|
879
|
-
L:
|
|
870
|
+
L: 391,
|
|
880
871
|
S: this,
|
|
881
872
|
C: (f, a) => f(...a)
|
|
882
873
|
});
|
|
@@ -891,7 +882,7 @@ var Muxer = class {
|
|
|
891
882
|
cmd
|
|
892
883
|
}, {
|
|
893
884
|
F: __dxlog_file4,
|
|
894
|
-
L:
|
|
885
|
+
L: 400,
|
|
895
886
|
S: this,
|
|
896
887
|
C: (f, a) => f(...a)
|
|
897
888
|
});
|
|
@@ -939,7 +930,7 @@ var Muxer = class {
|
|
|
939
930
|
threshold: MAX_SAFE_FRAME_SIZE
|
|
940
931
|
}, {
|
|
941
932
|
F: __dxlog_file4,
|
|
942
|
-
L:
|
|
933
|
+
L: 441,
|
|
943
934
|
S: this,
|
|
944
935
|
C: (f, a) => f(...a)
|
|
945
936
|
});
|
|
@@ -1555,7 +1546,7 @@ var TestConnection = class {
|
|
|
1555
1546
|
};
|
|
1556
1547
|
|
|
1557
1548
|
// packages/core/mesh/teleport/src/testing/test-extension.ts
|
|
1558
|
-
import { asyncTimeout as
|
|
1549
|
+
import { asyncTimeout as asyncTimeout3, Trigger as Trigger2 } from "@dxos/async";
|
|
1559
1550
|
import { invariant as invariant6 } from "@dxos/invariant";
|
|
1560
1551
|
import { log as log7 } from "@dxos/log";
|
|
1561
1552
|
import { schema as schema3 } from "@dxos/protocols";
|
|
@@ -1639,7 +1630,7 @@ var TestExtension = class {
|
|
|
1639
1630
|
await this.open.wait({
|
|
1640
1631
|
timeout: 1500
|
|
1641
1632
|
});
|
|
1642
|
-
const res = await
|
|
1633
|
+
const res = await asyncTimeout3(this._rpc.rpc.TestService.testCall({
|
|
1643
1634
|
data: message
|
|
1644
1635
|
}), 1500);
|
|
1645
1636
|
invariant6(res.data === message, void 0, {
|
|
@@ -1932,4 +1923,4 @@ export {
|
|
|
1932
1923
|
TestExtension,
|
|
1933
1924
|
TestExtensionWithStreams
|
|
1934
1925
|
};
|
|
1935
|
-
//# sourceMappingURL=chunk-
|
|
1926
|
+
//# sourceMappingURL=chunk-CZZOJEEL.mjs.map
|
|
@@ -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.info('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,SAAsBA,gBAAgB;AAEtC,SAASC,aAAAA,kBAAiB;AAC1B,SAASC,aAAAA,kBAAiB;AAC1B,SAASC,OAAAA,YAAW;;;ACFpB,SAASC,mBAAmBC,cAAcC,oBAAgC;AAC1E,SAASC,WAAAA,gBAAe;AACxB,SAASC,iBAAAA,sBAAqB;AAC9B,SAASC,aAAAA,kBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,OAAAA,MAAKC,WAAAA,gBAAe;AAC7B,SAASC,kBAAAA,iBAAgBC,gBAAAA,qBAAoB;;;ACR7C,SAASC,cAAcC,sBAAsBC,gBAAgBC,yBAAyB;AACtF,SAASC,eAAe;AAExB,SAASC,WAAW;AACpB,SAASC,QAAQC,sBAAsB;AAEvC,SAASC,0BAA6C;AACtD,SAASC,gBAAgB;;AAIzB,IAAMC,4BAA4B;AAY3B,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;AACdA,kBAAY,UAAUjB,YAAY,CAAA,EAAGoF,SAAS,KAAA,CAAA;IAChD;AACA,UAAM,EAAExC,KAAI,IAAK,MAAM,KAAKiB,KAAKwB,IAAIpB,uBAAuBI,kBAAkB;MAC5EzB,MAAM3B;MACNsD;MACAC;IACF,CAAA;AACAtE,IAAAA,WAAU0C,SAAS3B,WAAAA,QAAAA;;;;;;;;;AAEnB,UAAM,KAAKD,YAAYC,WAAWsD,oBAAoBC,mBAAAA;AACtD,WAAOvD;EACT;EAEA,MAAMqE,YAAYrE,WAA6C;AAC7D,UAAM,KAAKR,KAAK0E,KAAK;MAAET,SAAS;IAAK,CAAA;AACrC,UAAM,EAAE9B,MAAMnB,WAAWC,eAAeC,YAAYC,eAAe8B,YAAW,IAC5E,MAAM,KAAKG,KAAKwB,IAAIpB,uBAAuBQ,gBAAgB;MACzD7B,MAAM3B;IACR,CAAA;AAEFf,IAAAA,WAAU0C,SAAS3B,WAAAA,QAAAA;;;;;;;;;AAEnB,UAAMsE,QAAQ,KAAKnC,aAAanC,SAAAA;AAEhC,WAAO;MACLA;MACAuE,OAAO;QACLD;QACAE,QAAQ;UACNhE;UACAC;UACAC;UACAC;UACA8B;QACF;MACF;IACF;EACF;;;;EAKA,MAAMgC,gBAAgBrD,KAAa;AACjC,SAAKtB,kBAAkBgE,MAAM1C,GAAAA;EAC/B;AACF;",
|
|
6
|
+
"names": ["pipeline", "invariant", "PublicKey", "log", "runInContextAsync", "synchronized", "scheduleTask", "Context", "failUndefined", "invariant", "PublicKey", "log", "logInfo", "RpcClosedError", "TimeoutError", "asyncTimeout", "scheduleTaskInterval", "TimeoutError", "AsyncTimeoutError", "Context", "log", "schema", "RpcClosedError", "createProtoRpcPeer", "Callback", "HEARTBEAT_RTT_WARN_THRESH", "ControlExtension", "constructor", "opts", "localPeerId", "remotePeerId", "_ctx", "onError", "err", "_extensionContext", "close", "onExtensionRegistered", "registerExtension", "name", "_rpc", "rpc", "Control", "onOpen", "extensionContext", "requested", "getService", "exposed", "handlers", "request", "call", "heartbeat", "ts", "requestTimestamp", "truncate", "port", "createPort", "contentType", "timeout", "heartbeatTimeout", "open", "reqTS", "Date", "resp", "now", "getTime", "warn", "rtt", "delay", "onTimeout", "info", "heartbeatInterval", "onClose", "dispose", "onAbort", "abort", "Duplex", "Event", "invariant", "log", "FRAME_LENGTH_SIZE", "Framer", "_messageCb", "undefined", "_subscribeCb", "_buffer", "_sendCallbacks", "_bytesSent", "_bytesReceived", "_writable", "drain", "_stream", "objectMode", "read", "_processResponseQueue", "write", "chunk", "encoding", "callback", "length", "Buffer", "concat", "_popFrames", "port", "send", "message", "Promise", "resolve", "frame", "encodeFrame", "push", "subscribe", "stream", "bytesSent", "bytesReceived", "writable", "responseQueue", "emit", "forEach", "cb", "offset", "decodeFrame", "bytesConsumed", "payload", "subarray", "destroy", "readableLength", "info", "writableLength", "warn", "buffer", "frameLength", "readUInt16BE", "allocUnsafe", "writeUInt16BE", "set", "Duplex", "scheduleTaskInterval", "Event", "Trigger", "asyncTimeout", "Context", "failUndefined", "invariant", "log", "logInfo", "schema", "TimeoutError", "varint", "Event", "invariant", "log", "MAX_CHUNK_SIZE", "Balancer", "constructor", "_sysChannelId", "_lastCallerIndex", "_channels", "_framer", "Framer", "_sendBuffers", "Map", "_receiveBuffers", "_sending", "incomingData", "Event", "stream", "push", "port", "subscribe", "_processIncomingMessage", "bind", "bytesSent", "bytesReceived", "buffersCount", "size", "addChannel", "channel", "pushData", "data", "trigger", "channelId", "_enqueueChunk", "_sendChunks", "catch", "err", "log", "destroy", "info", "clear", "msg", "dataLength", "chunk", "decodeChunk", "has", "length", "set", "buffer", "Buffer", "from", "msgLength", "emit", "channelBuffer", "get", "concat", "delete", "_getNextCallerId", "index", "includes", "Error", "sendBuffer", "chunks", "idx", "subarray", "forEach", "encodeChunk", "undefined", "_getNextChunk", "shift", "writable", "drain", "waitForCount", "send", "wake", "throw", "invariant", "channelTagLength", "encodingLength", "dataLengthLength", "message", "allocUnsafe", "varint", "encode", "withLength", "decode", "offset", "bytes", "Command", "schema", "getCodecForType", "DEFAULT_SEND_COMMAND_TIMEOUT", "DESTROY_COMMAND_SEND_TIMEOUT", "STATS_INTERVAL", "MAX_SAFE_FRAME_SIZE", "SYSTEM_CHANNEL_ID", "GRACEFUL_CLOSE_TIMEOUT", "Muxer", "constructor", "_balancer", "Balancer", "_channelsByLocalId", "Map", "_channelsByTag", "_ctx", "Context", "_nextId", "_closing", "_destroying", "_disposed", "_lastStats", "undefined", "_lastChannelStats", "afterClosed", "Event", "statsUpdated", "stream", "incomingData", "on", "msg", "_handleCommand", "decode", "setSessionId", "sessionId", "_sessionId", "sessionIdString", "truncate", "createStream", "tag", "opts", "channel", "_getOrCreateStream", "contentType", "invariant", "push", "Duplex", "write", "data", "encoding", "callback", "_sendData", "then", "catch", "read", "stats", "bytesReceived", "length", "destroy", "err", "listeners", "_sendCommand", "openChannel", "id", "_destroyChannel", "createPort", "inboundBuffer", "port", "send", "timeout", "subscribe", "cb", "close", "log", "error", "message", "_dispose", "asyncTimeout", "TimeoutError", "dispose", "values", "_emitStats", "emit", "clear", "cmd", "warn", "Error", "remoteId", "buffer", "channelId", "get", "failUndefined", "info", "trigger", "Trigger", "pushData", "encode", "wait", "params", "size", "scheduleTaskInterval", "bytesSent", "set", "addChannel", "threshold", "delete", "lastStats", "readBufferSize", "writeBufferSize", "c", "channels", "now", "Date", "interval", "timestamp", "calculateThroughput", "current", "last", "bytesSentRate", "bytesReceivedRate", "Array", "from", "map", "readableLength", "writableLength", "logInfo", "CONTROL_HEARTBEAT_INTERVAL", "CONTROL_HEARTBEAT_TIMEOUT", "Teleport", "constructor", "initiator", "localPeerId", "remotePeerId", "_ctx", "Context", "onError", "err", "destroy", "catch", "log", "error", "_muxer", "Muxer", "_extensions", "Map", "_remoteExtensions", "Set", "_open", "_destroying", "_aborting", "invariant", "PublicKey", "isPublicKey", "_control", "ControlExtension", "heartbeatInterval", "heartbeatTimeout", "onTimeout", "info", "abort", "TimeoutError", "onExtensionRegistered", "set", "name", "has", "add", "_openExtension", "stream", "on", "statsUpdated", "stats", "trace", "bytesSent", "bytesSentRate", "bytesReceived", "bytesReceivedRate", "channels", "sessionIdString", "_sessionId", "truncate", "open", "sessionId", "random", "_setExtension", "setSessionId", "close", "disposed", "dispose", "extension", "values", "onAbort", "onClose", "addExtension", "Error", "scheduleTask", "registerExtension", "RpcClosedError", "extensionName", "includes", "get", "failUndefined", "context", "createPort", "channelName", "opts", "createStream", "runInContextAsync", "onOpen", "logInfo", "synchronized", "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", "asyncTimeout", "Trigger", "invariant", "log", "schema", "createProtoRpcPeer", "TestExtension", "constructor", "callbacks", "open", "closed", "aborted", "remotePeerId", "extensionContext", "onOpen", "context", "localPeerId", "_rpc", "port", "createPort", "contentType", "requested", "TestService", "getService", "exposed", "handlers", "voidCall", "request", "testCall", "data", "timeout", "wake", "onClose", "err", "close", "onAbort", "abort", "test", "message", "wait", "res", "rpc", "closeConnection", "randomBytes", "Trigger", "invariant", "log", "schema", "createProtoRpcPeer", "TestExtensionWithStreams", "constructor", "callbacks", "open", "closed", "aborted", "_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", "reportingTimer", "setInterval", "trace", "from", "localPeerId", "to", "_closeStream", "stream", "get", "clearTimeout", "destroy", "delete", "runningTime", "onOpen", "context", "_rpc", "port", "createPort", "requested", "TestServiceWithStreams", "getService", "exposed", "handlers", "requestTestStream", "request", "streamLoadInterval", "streamLoadChunkSize", "closeTestStream", "timeout", "wake", "onClose", "Object", "entries", "close", "onAbort", "abort", "addNewStream", "wait", "toString", "rpc", "closeStream", "local", "stats", "remote", "closeConnection"]
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytes":18208,"imports":[{"path":"@dxos/node-std/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":23861,"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":52096,"imports":[{"path":"@dxos/node-std/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":957,"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":17373,"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":15696,"imports":[{"path":"@dxos/node-std/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":9934,"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":27099,"imports":[{"path":"@dxos/node-std/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":6061,"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/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3028},"packages/core/mesh/teleport/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/browser/chunk-M7U4KJA7.mjs","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":1853},"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-M7U4KJA7.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-M7U4KJA7.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":91752},"packages/core/mesh/teleport/dist/lib/browser/chunk-M7U4KJA7.mjs":{"imports":[{"path":"@dxos/node-std/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":"@dxos/node-std/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":"@dxos/node-std/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":"@dxos/node-std/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":4958},"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":4632},"packages/core/mesh/teleport/src/muxing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytesInOutput":13856},"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":7354}},"bytes":54552}}}
|
|
1
|
+
{"inputs":{"packages/core/mesh/teleport/src/muxing/framer.ts":{"bytes":18208,"imports":[{"path":"@dxos/node-std/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":23861,"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":"@dxos/node-std/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":957,"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":17373,"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":15696,"imports":[{"path":"@dxos/node-std/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":9934,"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":27099,"imports":[{"path":"@dxos/node-std/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":6061,"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/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3028},"packages/core/mesh/teleport/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/core/mesh/teleport/dist/lib/browser/chunk-CZZOJEEL.mjs","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":1853},"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-CZZOJEEL.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-CZZOJEEL.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":91457},"packages/core/mesh/teleport/dist/lib/browser/chunk-CZZOJEEL.mjs":{"imports":[{"path":"@dxos/node-std/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":"@dxos/node-std/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":"@dxos/node-std/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":"@dxos/node-std/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":4958},"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":4632},"packages/core/mesh/teleport/src/muxing/index.ts":{"bytesInOutput":0},"packages/core/mesh/teleport/src/muxing/muxer.ts":{"bytesInOutput":13724},"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":7354}},"bytes":54420}}}
|
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_SJ6CXLWF_exports = {};
|
|
30
|
+
__export(chunk_SJ6CXLWF_exports, {
|
|
31
31
|
Framer: () => Framer,
|
|
32
32
|
Muxer: () => Muxer,
|
|
33
33
|
Teleport: () => Teleport,
|
|
@@ -39,7 +39,7 @@ __export(chunk_GVV33WCQ_exports, {
|
|
|
39
39
|
decodeFrame: () => decodeFrame,
|
|
40
40
|
encodeFrame: () => encodeFrame
|
|
41
41
|
});
|
|
42
|
-
module.exports = __toCommonJS(
|
|
42
|
+
module.exports = __toCommonJS(chunk_SJ6CXLWF_exports);
|
|
43
43
|
var import_node_stream = require("node:stream");
|
|
44
44
|
var import_invariant = require("@dxos/invariant");
|
|
45
45
|
var import_keys = require("@dxos/keys");
|
|
@@ -778,23 +778,14 @@ var Muxer = class {
|
|
|
778
778
|
});
|
|
779
779
|
await this._dispose(err2);
|
|
780
780
|
});
|
|
781
|
-
await
|
|
782
|
-
new Promise((_resolve, reject) => {
|
|
783
|
-
setTimeout(() => {
|
|
784
|
-
reject(new import_protocols3.TimeoutError("gracefully closing muxer"));
|
|
785
|
-
}, GRACEFUL_CLOSE_TIMEOUT);
|
|
786
|
-
}),
|
|
787
|
-
(async () => {
|
|
788
|
-
await this._dispose(err);
|
|
789
|
-
})()
|
|
790
|
-
]);
|
|
781
|
+
await (0, import_async4.asyncTimeout)(this._dispose(err), GRACEFUL_CLOSE_TIMEOUT, new import_protocols3.TimeoutError("gracefully closing muxer"));
|
|
791
782
|
}
|
|
792
783
|
// force close without confirmation
|
|
793
784
|
async destroy(err) {
|
|
794
785
|
if (this._destroying) {
|
|
795
786
|
(0, import_log5.log)("already destroying, ignoring destroy request", void 0, {
|
|
796
787
|
F: __dxlog_file4,
|
|
797
|
-
L:
|
|
788
|
+
L: 298,
|
|
798
789
|
S: this,
|
|
799
790
|
C: (f, a) => f(...a)
|
|
800
791
|
});
|
|
@@ -805,7 +796,7 @@ var Muxer = class {
|
|
|
805
796
|
if (this._closing) {
|
|
806
797
|
(0, import_log5.log)("destroy cancelling graceful close", void 0, {
|
|
807
798
|
F: __dxlog_file4,
|
|
808
|
-
L:
|
|
799
|
+
L: 304,
|
|
809
800
|
S: this,
|
|
810
801
|
C: (f, a) => f(...a)
|
|
811
802
|
});
|
|
@@ -820,7 +811,7 @@ var Muxer = class {
|
|
|
820
811
|
err: err2
|
|
821
812
|
}, {
|
|
822
813
|
F: __dxlog_file4,
|
|
823
|
-
L:
|
|
814
|
+
L: 317,
|
|
824
815
|
S: this,
|
|
825
816
|
C: (f, a) => f(...a)
|
|
826
817
|
});
|
|
@@ -831,7 +822,7 @@ var Muxer = class {
|
|
|
831
822
|
err: err2
|
|
832
823
|
}, {
|
|
833
824
|
F: __dxlog_file4,
|
|
834
|
-
L:
|
|
825
|
+
L: 322,
|
|
835
826
|
S: this,
|
|
836
827
|
C: (f, a) => f(...a)
|
|
837
828
|
});
|
|
@@ -842,7 +833,7 @@ var Muxer = class {
|
|
|
842
833
|
if (this._disposed) {
|
|
843
834
|
(0, import_log5.log)("already destroyed, ignoring dispose request", void 0, {
|
|
844
835
|
F: __dxlog_file4,
|
|
845
|
-
L:
|
|
836
|
+
L: 330,
|
|
846
837
|
S: this,
|
|
847
838
|
C: (f, a) => f(...a)
|
|
848
839
|
});
|
|
@@ -865,7 +856,7 @@ var Muxer = class {
|
|
|
865
856
|
cmd
|
|
866
857
|
}, {
|
|
867
858
|
F: __dxlog_file4,
|
|
868
|
-
L:
|
|
859
|
+
L: 353,
|
|
869
860
|
S: this,
|
|
870
861
|
C: (f, a) => f(...a)
|
|
871
862
|
});
|
|
@@ -875,7 +866,7 @@ var Muxer = class {
|
|
|
875
866
|
if (!this._closing) {
|
|
876
867
|
(0, import_log5.log)("received peer close, initiating my own graceful close", void 0, {
|
|
877
868
|
F: __dxlog_file4,
|
|
878
|
-
L:
|
|
869
|
+
L: 359,
|
|
879
870
|
S: this,
|
|
880
871
|
C: (f, a) => f(...a)
|
|
881
872
|
});
|
|
@@ -883,7 +874,7 @@ var Muxer = class {
|
|
|
883
874
|
} else {
|
|
884
875
|
(0, import_log5.log)("received close from peer, already closing", void 0, {
|
|
885
876
|
F: __dxlog_file4,
|
|
886
|
-
L:
|
|
877
|
+
L: 362,
|
|
887
878
|
S: this,
|
|
888
879
|
C: (f, a) => f(...a)
|
|
889
880
|
});
|
|
@@ -912,7 +903,7 @@ var Muxer = class {
|
|
|
912
903
|
tag: stream.tag
|
|
913
904
|
}, {
|
|
914
905
|
F: __dxlog_file4,
|
|
915
|
-
L:
|
|
906
|
+
L: 391,
|
|
916
907
|
S: this,
|
|
917
908
|
C: (f, a) => f(...a)
|
|
918
909
|
});
|
|
@@ -927,7 +918,7 @@ var Muxer = class {
|
|
|
927
918
|
cmd
|
|
928
919
|
}, {
|
|
929
920
|
F: __dxlog_file4,
|
|
930
|
-
L:
|
|
921
|
+
L: 400,
|
|
931
922
|
S: this,
|
|
932
923
|
C: (f, a) => f(...a)
|
|
933
924
|
});
|
|
@@ -975,7 +966,7 @@ var Muxer = class {
|
|
|
975
966
|
threshold: MAX_SAFE_FRAME_SIZE
|
|
976
967
|
}, {
|
|
977
968
|
F: __dxlog_file4,
|
|
978
|
-
L:
|
|
969
|
+
L: 441,
|
|
979
970
|
S: this,
|
|
980
971
|
C: (f, a) => f(...a)
|
|
981
972
|
});
|
|
@@ -1949,4 +1940,4 @@ var TestExtensionWithStreams = class {
|
|
|
1949
1940
|
decodeFrame,
|
|
1950
1941
|
encodeFrame
|
|
1951
1942
|
});
|
|
1952
|
-
//# sourceMappingURL=chunk-
|
|
1943
|
+
//# sourceMappingURL=chunk-SJ6CXLWF.cjs.map
|