@dxos/network-manager 0.8.4-main.84f28bd → 0.8.4-main.ae835ea

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.
Files changed (76) hide show
  1. package/dist/lib/browser/{chunk-HQNQOWFA.mjs → chunk-E3P563GT.mjs} +329 -230
  2. package/dist/lib/browser/chunk-E3P563GT.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/testing/index.mjs +65 -46
  6. package/dist/lib/browser/testing/index.mjs.map +3 -3
  7. package/dist/lib/browser/transport/tcp/index.mjs +3 -5
  8. package/dist/lib/browser/transport/tcp/index.mjs.map +1 -1
  9. package/dist/lib/node-esm/{chunk-JPPMRZTH.mjs → chunk-PKBROUZV.mjs} +329 -230
  10. package/dist/lib/node-esm/chunk-PKBROUZV.mjs.map +7 -0
  11. package/dist/lib/node-esm/index.mjs +1 -1
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/lib/node-esm/testing/index.mjs +65 -46
  14. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  15. package/dist/lib/node-esm/transport/tcp/index.mjs +8 -7
  16. package/dist/lib/node-esm/transport/tcp/index.mjs.map +2 -2
  17. package/dist/types/src/connection-log.d.ts.map +1 -1
  18. package/dist/types/src/index.d.ts +1 -1
  19. package/dist/types/src/index.d.ts.map +1 -1
  20. package/dist/types/src/network-manager.d.ts.map +1 -1
  21. package/dist/types/src/signal/index.d.ts +2 -2
  22. package/dist/types/src/signal/index.d.ts.map +1 -1
  23. package/dist/types/src/signal/swarm-messenger.d.ts +1 -1
  24. package/dist/types/src/signal/swarm-messenger.d.ts.map +1 -1
  25. package/dist/types/src/swarm/peer.d.ts +2 -2
  26. package/dist/types/src/swarm/peer.d.ts.map +1 -1
  27. package/dist/types/src/swarm/swarm.d.ts +3 -3
  28. package/dist/types/src/swarm/swarm.d.ts.map +1 -1
  29. package/dist/types/src/testing/test-builder.d.ts +1 -1
  30. package/dist/types/src/testing/test-builder.d.ts.map +1 -1
  31. package/dist/types/src/testing/test-wire-protocol.d.ts +1 -1
  32. package/dist/types/src/testing/test-wire-protocol.d.ts.map +1 -1
  33. package/dist/types/src/tests/basic-test-suite.d.ts.map +1 -1
  34. package/dist/types/src/topology/index.d.ts +1 -1
  35. package/dist/types/src/topology/index.d.ts.map +1 -1
  36. package/dist/types/src/transport/webrtc/rtc-peer-connection.d.ts +2 -2
  37. package/dist/types/src/transport/webrtc/rtc-peer-connection.d.ts.map +1 -1
  38. package/dist/types/src/transport/webrtc/rtc-transport-channel.d.ts +1 -1
  39. package/dist/types/src/transport/webrtc/rtc-transport-channel.d.ts.map +1 -1
  40. package/dist/types/src/transport/webrtc/rtc-transport-factory.d.ts.map +1 -1
  41. package/dist/types/src/transport/webrtc/rtc-transport-service.d.ts +1 -1
  42. package/dist/types/src/transport/webrtc/rtc-transport-service.d.ts.map +1 -1
  43. package/dist/types/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +23 -29
  45. package/src/connection-log.ts +1 -1
  46. package/src/index.ts +1 -1
  47. package/src/network-manager.ts +1 -1
  48. package/src/signal/ice.test.ts +1 -1
  49. package/src/signal/index.ts +2 -2
  50. package/src/signal/integration.node.test.ts +2 -2
  51. package/src/signal/swarm-messenger.node.test.ts +1 -1
  52. package/src/signal/swarm-messenger.ts +1 -1
  53. package/src/swarm/connection.test.ts +2 -1
  54. package/src/swarm/connection.ts +4 -4
  55. package/src/swarm/peer.ts +3 -2
  56. package/src/swarm/swarm-mapper.ts +1 -1
  57. package/src/swarm/swarm.test.ts +5 -4
  58. package/src/swarm/swarm.ts +5 -4
  59. package/src/testing/test-builder.ts +12 -4
  60. package/src/testing/test-wire-protocol.ts +2 -2
  61. package/src/tests/basic-test-suite.ts +3 -2
  62. package/src/tests/memory-transport.test.ts +4 -2
  63. package/src/tests/tcp-transport.node.test.ts +4 -2
  64. package/src/tests/webrtc-transport.test.ts +2 -1
  65. package/src/topology/index.ts +1 -1
  66. package/src/transport/tcp/tcp-transport.ts +1 -1
  67. package/src/transport/webrtc/rtc-connection-factory.ts +1 -1
  68. package/src/transport/webrtc/rtc-peer-connection.ts +4 -3
  69. package/src/transport/webrtc/rtc-transport-channel.test.ts +3 -1
  70. package/src/transport/webrtc/rtc-transport-channel.ts +2 -1
  71. package/src/transport/webrtc/rtc-transport-factory.ts +3 -2
  72. package/src/transport/webrtc/rtc-transport-proxy.test.ts +5 -3
  73. package/src/transport/webrtc/rtc-transport-service.ts +6 -5
  74. package/src/transport/webrtc/rtc-transport.test.ts +4 -3
  75. package/dist/lib/browser/chunk-HQNQOWFA.mjs.map +0 -7
  76. package/dist/lib/node-esm/chunk-JPPMRZTH.mjs.map +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/network-manager",
3
- "version": "0.8.4-main.84f28bd",
3
+ "version": "0.8.4-main.ae835ea",
4
4
  "description": "Network Manager",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -20,6 +20,7 @@
20
20
  "default": "node-datachannel/*"
21
21
  },
22
22
  "#tcp-transport": {
23
+ "source": "./src/transport/tcp/index.ts",
23
24
  "types": "./dist/types/src/transport/tcp/index.d.ts",
24
25
  "browser": "./dist/lib/browser/transport/tcp/index.mjs",
25
26
  "node": "./dist/lib/node-esm/transport/tcp/index.mjs",
@@ -29,16 +30,19 @@
29
30
  },
30
31
  "exports": {
31
32
  ".": {
33
+ "source": "./src/index.ts",
32
34
  "types": "./dist/types/src/index.d.ts",
33
35
  "browser": "./dist/lib/browser/index.mjs",
34
36
  "node": "./dist/lib/node-esm/index.mjs"
35
37
  },
36
38
  "./testing": {
39
+ "source": "./src/testing/index.ts",
37
40
  "types": "./dist/types/src/testing/index.d.ts",
38
41
  "browser": "./dist/lib/browser/testing/index.mjs",
39
42
  "node": "./dist/lib/node-esm/testing/index.mjs"
40
43
  },
41
44
  "./transport/tcp": {
45
+ "source": "./src/transport/tcp/index.ts",
42
46
  "types": "./dist/types/src/transport/tcp/index.d.ts",
43
47
  "browser": "./dist/lib/browser/transport/tcp/index.mjs",
44
48
  "node": "./dist/lib/node-esm/transport/tcp/index.mjs"
@@ -66,37 +70,27 @@
66
70
  "src"
67
71
  ],
68
72
  "dependencies": {
69
- "isomorphic-ws": "^5.0.0",
70
- "nanomessage-rpc": "^3.0.0",
71
- "node-datachannel": "^0.9.2",
72
- "p-defer": "^3.0.0",
73
- "stream": "^0.0.3",
74
- "tiny-invariant": "^1.3.1",
75
- "ws": "^8.14.2",
76
- "xor-distance": "^2.0.0",
77
- "@dxos/async": "0.8.4-main.84f28bd",
78
- "@dxos/codec-protobuf": "0.8.4-main.84f28bd",
79
- "@dxos/debug": "0.8.4-main.84f28bd",
80
- "@dxos/context": "0.8.4-main.84f28bd",
81
- "@dxos/keys": "0.8.4-main.84f28bd",
82
- "@dxos/invariant": "0.8.4-main.84f28bd",
83
- "@dxos/log": "0.8.4-main.84f28bd",
84
- "@dxos/messaging": "0.8.4-main.84f28bd",
85
- "@dxos/node-std": "0.8.4-main.84f28bd",
86
- "@dxos/protocols": "0.8.4-main.84f28bd",
87
- "@dxos/teleport": "0.8.4-main.84f28bd",
88
- "@dxos/rpc": "0.8.4-main.84f28bd",
89
- "@dxos/tracing": "0.8.4-main.84f28bd",
90
- "@dxos/util": "0.8.4-main.84f28bd"
73
+ "node-datachannel": "^0.30.0",
74
+ "@dxos/async": "0.8.4-main.ae835ea",
75
+ "@dxos/codec-protobuf": "0.8.4-main.ae835ea",
76
+ "@dxos/invariant": "0.8.4-main.ae835ea",
77
+ "@dxos/context": "0.8.4-main.ae835ea",
78
+ "@dxos/keys": "0.8.4-main.ae835ea",
79
+ "@dxos/debug": "0.8.4-main.ae835ea",
80
+ "@dxos/log": "0.8.4-main.ae835ea",
81
+ "@dxos/node-std": "0.8.4-main.ae835ea",
82
+ "@dxos/protocols": "0.8.4-main.ae835ea",
83
+ "@dxos/rpc": "0.8.4-main.ae835ea",
84
+ "@dxos/teleport": "0.8.4-main.ae835ea",
85
+ "@dxos/messaging": "0.8.4-main.ae835ea",
86
+ "@dxos/tracing": "0.8.4-main.ae835ea",
87
+ "@dxos/util": "0.8.4-main.ae835ea"
91
88
  },
92
89
  "devDependencies": {
93
- "@swc-node/register": "1.9.1",
94
- "@types/ws": "^7.4.0",
95
- "fast-check": "^3.19.0",
96
90
  "fetch-mock": "^11.0.0",
97
- "@dxos/edge-client": "0.8.4-main.84f28bd",
98
- "@dxos/keyring": "0.8.4-main.84f28bd",
99
- "@dxos/signal": "0.8.4-main.84f28bd"
91
+ "@dxos/keyring": "0.8.4-main.ae835ea",
92
+ "@dxos/edge-client": "0.8.4-main.ae835ea",
93
+ "@dxos/signal": "0.8.4-main.ae835ea"
100
94
  },
101
95
  "publishConfig": {
102
96
  "access": "public"
@@ -5,7 +5,7 @@
5
5
  import { Event } from '@dxos/async';
6
6
  import { raise } from '@dxos/debug';
7
7
  import { PublicKey } from '@dxos/keys';
8
- import { type SwarmInfo, type ConnectionInfo } from '@dxos/protocols/proto/dxos/devtools/swarm';
8
+ import { type ConnectionInfo, type SwarmInfo } from '@dxos/protocols/proto/dxos/devtools/swarm';
9
9
  import { type MuxerStats } from '@dxos/teleport';
10
10
  import { ComplexMap } from '@dxos/util';
11
11
 
package/src/index.ts CHANGED
@@ -8,5 +8,5 @@ export * from './signal';
8
8
  export * from './swarm';
9
9
  export * from './topology';
10
10
  export * from './transport';
11
- export * from './types';
11
+ export type * from './types';
12
12
  export * from './wire-protocol';
@@ -13,7 +13,7 @@ import { ComplexMap } from '@dxos/util';
13
13
 
14
14
  import { ConnectionLog } from './connection-log';
15
15
  import { type SignalConnection } from './signal';
16
- import { Swarm, SwarmMapper, ConnectionLimiter } from './swarm';
16
+ import { ConnectionLimiter, Swarm, SwarmMapper } from './swarm';
17
17
  import { type Topology } from './topology';
18
18
  import { type TransportFactory } from './transport';
19
19
  import { type WireProtocolProvider } from './wire-protocol';
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import fetchMock from 'fetch-mock';
6
- import { afterEach, test, expect, describe } from 'vitest';
6
+ import { afterEach, describe, expect, test } from 'vitest';
7
7
 
8
8
  import { createIceProvider } from './ice';
9
9
 
@@ -4,5 +4,5 @@
4
4
 
5
5
  export * from './ice';
6
6
  export * from './swarm-messenger';
7
- export * from './signal-connection';
8
- export * from './signal-messenger';
7
+ export type * from './signal-connection';
8
+ export type * from './signal-messenger';
@@ -2,11 +2,11 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { afterAll, onTestFinished, beforeAll, describe, expect, test } from 'vitest';
5
+ import { afterAll, beforeAll, describe, expect, onTestFinished, test } from 'vitest';
6
6
 
7
7
  import { PublicKey } from '@dxos/keys';
8
8
  import { Messenger, type PeerInfo, WebsocketSignalManager } from '@dxos/messaging';
9
- import { runTestSignalServer, type SignalServerRunner } from '@dxos/signal';
9
+ import { type SignalServerRunner, runTestSignalServer } from '@dxos/signal';
10
10
 
11
11
  import { type SignalMessage } from './signal-messenger';
12
12
  import { SwarmMessenger } from './swarm-messenger';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { afterAll, beforeAll, beforeEach, describe, expect, test, onTestFinished } from 'vitest';
5
+ import { afterAll, beforeAll, beforeEach, describe, expect, onTestFinished, test } from 'vitest';
6
6
 
7
7
  import { type Awaited } from '@dxos/async';
8
8
  import { PublicKey } from '@dxos/keys';
@@ -7,7 +7,7 @@ import { Context } from '@dxos/context';
7
7
  import { invariant } from '@dxos/invariant';
8
8
  import { PublicKey } from '@dxos/keys';
9
9
  import { log } from '@dxos/log';
10
- import { type PeerInfo, type Message } from '@dxos/messaging';
10
+ import { type Message, type PeerInfo } from '@dxos/messaging';
11
11
  import { TimeoutError } from '@dxos/protocols';
12
12
  import { schema } from '@dxos/protocols/proto';
13
13
  import { type Answer, type SwarmMessage } from '@dxos/protocols/proto/dxos/mesh/swarm';
@@ -7,11 +7,12 @@ import { describe, test } from 'vitest';
7
7
  import { sleep } from '@dxos/async';
8
8
  import { PublicKey } from '@dxos/keys';
9
9
 
10
- import { Connection } from './connection';
11
10
  import { TestWireProtocol } from '../testing/test-wire-protocol';
12
11
  import { createRtcTransportFactory } from '../transport';
13
12
  import { chooseInitiatorPeer } from '../transport/webrtc/utils';
14
13
 
14
+ import { Connection } from './connection';
15
+
15
16
  describe('Connection', () => {
16
17
  test('responder opens after initiator', async () => {
17
18
  const { initiator, responder } = createPeerKeys();
@@ -2,8 +2,8 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- import { DeferredTask, Event, sleep, scheduleTask, scheduleTaskInterval, synchronized, Trigger } from '@dxos/async';
6
- import { Context, cancelWithContext, ContextDisposedError } from '@dxos/context';
5
+ import { DeferredTask, Event, Trigger, scheduleTask, scheduleTaskInterval, sleep, synchronized } from '@dxos/async';
6
+ import { Context, ContextDisposedError, cancelWithContext } from '@dxos/context';
7
7
  import { ErrorStream } from '@dxos/debug';
8
8
  import { invariant } from '@dxos/invariant';
9
9
  import { PublicKey } from '@dxos/keys';
@@ -11,9 +11,9 @@ import { log, logInfo } from '@dxos/log';
11
11
  import { type PeerInfo } from '@dxos/messaging';
12
12
  import {
13
13
  CancelledError,
14
- ProtocolError,
15
14
  ConnectionResetError,
16
15
  ConnectivityError,
16
+ ProtocolError,
17
17
  TimeoutError,
18
18
  trace,
19
19
  } from '@dxos/protocols';
@@ -414,7 +414,7 @@ export class Connection {
414
414
  invariant(msg.author.peerKey === this.remoteInfo.peerKey);
415
415
  invariant(msg.recipient.peerKey === this.localInfo.peerKey);
416
416
 
417
- const signals = msg.data.signalBatch ? msg.data.signalBatch.signals ?? [] : [msg.data.signal];
417
+ const signals = msg.data.signalBatch ? (msg.data.signalBatch.signals ?? []) : [msg.data.signal];
418
418
  for (const signal of signals) {
419
419
  if (!signal) {
420
420
  continue;
package/src/swarm/peer.ts CHANGED
@@ -11,12 +11,13 @@ import { type PeerInfo } from '@dxos/messaging';
11
11
  import { CancelledError, SystemError } from '@dxos/protocols';
12
12
  import { type Answer } from '@dxos/protocols/proto/dxos/mesh/swarm';
13
13
 
14
- import { Connection, ConnectionState } from './connection';
15
- import { type ConnectionLimiter } from './connection-limiter';
16
14
  import { type OfferMessage, type SignalMessage, type SignalMessenger } from '../signal';
17
15
  import { type TransportFactory } from '../transport';
18
16
  import { type WireProtocolProvider } from '../wire-protocol';
19
17
 
18
+ import { Connection, ConnectionState } from './connection';
19
+ import { type ConnectionLimiter } from './connection-limiter';
20
+
20
21
  export class ConnectionDisplacedError extends SystemError {
21
22
  constructor() {
22
23
  super('Connection displaced by remote initiator.');
@@ -5,7 +5,7 @@
5
5
  import { type CleanupFn, Event, SubscriptionList } from '@dxos/async';
6
6
  import { PublicKey } from '@dxos/keys';
7
7
  import { log } from '@dxos/log';
8
- import { PeerInfoHash, type PeerInfo as MessagingPeer } from '@dxos/messaging';
8
+ import { type PeerInfo as MessagingPeer, PeerInfoHash } from '@dxos/messaging';
9
9
  import { ComplexMap } from '@dxos/util';
10
10
 
11
11
  import { type ConnectionState } from './connection';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { onTestFinished, describe, expect, test } from 'vitest';
5
+ import { describe, expect, onTestFinished, test } from 'vitest';
6
6
 
7
7
  import { asyncTimeout, sleep } from '@dxos/async';
8
8
  import { PublicKey } from '@dxos/keys';
@@ -15,13 +15,14 @@ import {
15
15
  } from '@dxos/messaging';
16
16
  import { ComplexSet } from '@dxos/util';
17
17
 
18
- import { ConnectionState } from './connection';
19
- import { ConnectionLimiter } from './connection-limiter';
20
- import { Swarm } from './swarm';
21
18
  import { TestWireProtocol } from '../testing/test-wire-protocol';
22
19
  import { FullyConnectedTopology } from '../topology';
23
20
  import { createRtcTransportFactory } from '../transport';
24
21
 
22
+ import { ConnectionState } from './connection';
23
+ import { ConnectionLimiter } from './connection-limiter';
24
+ import { Swarm } from './swarm';
25
+
25
26
  type TestPeer = {
26
27
  swarm: Swarm;
27
28
  peer: PeerInfo;
@@ -8,20 +8,21 @@ import { ErrorStream } from '@dxos/debug';
8
8
  import { invariant } from '@dxos/invariant';
9
9
  import { PublicKey } from '@dxos/keys';
10
10
  import { log, logInfo } from '@dxos/log';
11
- import { type SwarmEvent, type ListeningHandle, type Messenger, type PeerInfo, PeerInfoHash } from '@dxos/messaging';
11
+ import { type ListeningHandle, type Messenger, type PeerInfo, PeerInfoHash, type SwarmEvent } from '@dxos/messaging';
12
12
  import { trace } from '@dxos/protocols';
13
13
  import { type Answer } from '@dxos/protocols/proto/dxos/mesh/swarm';
14
14
  import { ComplexMap, isNonNullable } from '@dxos/util';
15
15
 
16
- import { type Connection, ConnectionState } from './connection';
17
- import { type ConnectionLimiter } from './connection-limiter';
18
- import { Peer } from './peer';
19
16
  import { type OfferMessage, type SignalMessage, SwarmMessenger } from '../signal';
20
17
  import { type SwarmController, type Topology } from '../topology';
21
18
  import { type TransportFactory } from '../transport';
22
19
  import { type Topic } from '../types';
23
20
  import { type WireProtocolProvider } from '../wire-protocol';
24
21
 
22
+ import { type Connection, ConnectionState } from './connection';
23
+ import { type ConnectionLimiter } from './connection-limiter';
24
+ import { Peer } from './peer';
25
+
25
26
  const INITIATION_DELAY = 100;
26
27
 
27
28
  // TODO(burdon): Factor out.
@@ -13,15 +13,23 @@ import {
13
13
  import { schema } from '@dxos/protocols/proto';
14
14
  import { ConnectionState } from '@dxos/protocols/proto/dxos/client/services';
15
15
  import { type Runtime } from '@dxos/protocols/proto/dxos/config';
16
- import { createLinkedPorts, createProtoRpcPeer, type ProtoRpcPeer } from '@dxos/rpc';
16
+ import { type ProtoRpcPeer, createLinkedPorts, createProtoRpcPeer } from '@dxos/rpc';
17
17
  import { ComplexMap } from '@dxos/util';
18
18
 
19
19
  import { TcpTransportFactory } from '#tcp-transport';
20
- import { type TestTeleportExtensionFactory, TestWireProtocol } from './test-wire-protocol';
20
+
21
21
  import { SwarmNetworkManager } from '../network-manager';
22
22
  import { FullyConnectedTopology } from '../topology';
23
- import { MemoryTransportFactory, type TransportFactory, TransportKind } from '../transport';
24
- import { createRtcTransportFactory, RtcTransportProxyFactory, RtcTransportService } from '../transport';
23
+ import {
24
+ MemoryTransportFactory,
25
+ RtcTransportProxyFactory,
26
+ RtcTransportService,
27
+ type TransportFactory,
28
+ TransportKind,
29
+ createRtcTransportFactory,
30
+ } from '../transport';
31
+
32
+ import { type TestTeleportExtensionFactory, TestWireProtocol } from './test-wire-protocol';
25
33
 
26
34
  // Signal server will be started by the setup script.
27
35
  const port = process.env.SIGNAL_PORT ?? 4000;
@@ -2,11 +2,11 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { asyncTimeout, Event } from '@dxos/async';
5
+ import { Event, asyncTimeout } from '@dxos/async';
6
6
  import { PublicKey } from '@dxos/keys';
7
7
  import { log } from '@dxos/log';
8
8
  import { TestExtension, TestExtensionWithStreams } from '@dxos/teleport';
9
- import type { TestStreamStats, TeleportExtension } from '@dxos/teleport';
9
+ import type { TeleportExtension, TestStreamStats } from '@dxos/teleport';
10
10
  import { ComplexMap } from '@dxos/util';
11
11
 
12
12
  import { createTeleportProtocolFactory } from '../wire-protocol';
@@ -2,17 +2,18 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- import { onTestFinished, expect, test } from 'vitest';
5
+ import { expect, onTestFinished, test } from 'vitest';
6
6
 
7
7
  import { asyncTimeout } from '@dxos/async';
8
8
  import { PublicKey } from '@dxos/keys';
9
9
  import { log } from '@dxos/log';
10
10
  import { range } from '@dxos/util';
11
11
 
12
- import { exchangeMessages, joinSwarm, leaveSwarm, openAndCloseAfterTest } from './utils';
13
12
  import { type TestBuilder } from '../testing';
14
13
  import { FullyConnectedTopology, StarTopology } from '../topology';
15
14
 
15
+ import { exchangeMessages, joinSwarm, leaveSwarm, openAndCloseAfterTest } from './utils';
16
+
16
17
  // TODO(burdon): Use PublicKey throughout (remove conversion to strings, from buffers, etc.)
17
18
 
18
19
  /**
@@ -3,16 +3,18 @@
3
3
  //
4
4
 
5
5
  import { randomBytes } from 'node:crypto';
6
+
6
7
  import { describe, test } from 'vitest';
7
8
 
8
9
  import { PublicKey } from '@dxos/keys';
9
10
  import { range } from '@dxos/util';
10
11
 
11
- import { basicTestSuite } from './basic-test-suite';
12
- import { exchangeMessages, joinSwarm, leaveSwarm, openAndCloseAfterTest } from './utils';
13
12
  import { TestBuilder } from '../testing';
14
13
  import { FullyConnectedTopology } from '../topology';
15
14
 
15
+ import { basicTestSuite } from './basic-test-suite';
16
+ import { exchangeMessages, joinSwarm, leaveSwarm, openAndCloseAfterTest } from './utils';
17
+
16
18
  describe('Memory transport', () => {
17
19
  const testBuilder = new TestBuilder();
18
20
  basicTestSuite(testBuilder);
@@ -3,17 +3,19 @@
3
3
  //
4
4
 
5
5
  import { randomBytes } from 'node:crypto';
6
+
6
7
  import { describe, test } from 'vitest';
7
8
 
8
9
  import { PublicKey } from '@dxos/keys';
9
10
  import { range } from '@dxos/util';
10
11
 
11
- import { basicTestSuite } from './basic-test-suite';
12
- import { exchangeMessages, joinSwarm, leaveSwarm, openAndCloseAfterTest } from './utils';
13
12
  import { TestBuilder } from '../testing';
14
13
  import { FullyConnectedTopology } from '../topology';
15
14
  import { TransportKind } from '../transport';
16
15
 
16
+ import { basicTestSuite } from './basic-test-suite';
17
+ import { exchangeMessages, joinSwarm, leaveSwarm, openAndCloseAfterTest } from './utils';
18
+
17
19
  describe('Tcp transport', () => {
18
20
  const testBuilder = new TestBuilder({
19
21
  transport: TransportKind.TCP,
@@ -4,9 +4,10 @@
4
4
 
5
5
  import { describe } from 'vitest';
6
6
 
7
- import { basicTestSuite } from './basic-test-suite';
8
7
  import { TEST_SIGNAL_HOSTS, TestBuilder } from '../testing';
9
8
 
9
+ import { basicTestSuite } from './basic-test-suite';
10
+
10
11
  describe('WebRTC transport', { timeout: 10_000 }, () => {
11
12
  const testBuilder = new TestBuilder();
12
13
  basicTestSuite(testBuilder);
@@ -5,4 +5,4 @@
5
5
  export * from './fully-connected-topology';
6
6
  export * from './mmst-topology';
7
7
  export * from './star-topology';
8
- export * from './topology';
8
+ export type * from './topology';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { type AddressInfo, Socket, type Server } from 'node:net';
5
+ import { type AddressInfo, type Server, Socket } from 'node:net';
6
6
 
7
7
  import { Event } from '@dxos/async';
8
8
  import { ErrorStream } from '@dxos/debug';
@@ -38,7 +38,7 @@ class NodeRtcConnectionFactory implements RtcConnectionFactory {
38
38
  private static _cleanupMutex = new Mutex();
39
39
 
40
40
  // This should be inside the function to avoid triggering `eval` in the global scope.
41
- // eslint-disable-next-line no-new-func
41
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval
42
42
 
43
43
  // TODO(burdon): Do imports here?
44
44
  async initialize(): Promise<void> {}
@@ -2,18 +2,19 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { synchronized, Trigger, Mutex } from '@dxos/async';
5
+ import { Mutex, Trigger, synchronized } from '@dxos/async';
6
6
  import { invariant } from '@dxos/invariant';
7
7
  import { log, logInfo } from '@dxos/log';
8
8
  import { ConnectivityError } from '@dxos/protocols';
9
9
  import { type Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
10
10
  import { trace } from '@dxos/tracing';
11
11
 
12
+ import type { IceProvider } from '../../signal';
13
+ import { type TransportOptions } from '../transport';
14
+
12
15
  import { type RtcConnectionFactory } from './rtc-connection-factory';
13
16
  import { RtcTransportChannel } from './rtc-transport-channel';
14
17
  import { areSdpEqual, chooseInitiatorPeer } from './utils';
15
- import type { IceProvider } from '../../signal';
16
- import { type TransportOptions } from '../transport';
17
18
 
18
19
  export type RtcPeerChannelFactoryOptions = {
19
20
  ownPeerKey: string;
@@ -3,14 +3,16 @@
3
3
  //
4
4
 
5
5
  import { Duplex } from 'node:stream';
6
+
6
7
  import { describe, expect, test } from 'vitest';
7
8
 
8
9
  import { sleep } from '@dxos/async';
9
10
 
11
+ import { type TransportOptions } from '../transport';
12
+
10
13
  import { type RtcPeerConnection } from './rtc-peer-connection';
11
14
  import { RtcTransportChannel } from './rtc-transport-channel';
12
15
  import { handleChannelErrors } from './test-utils';
13
- import { type TransportOptions } from '../transport';
14
16
 
15
17
  describe('RtcTransportChannel', () => {
16
18
  test('transport error raised if channel creation fails', async () => {
@@ -12,9 +12,10 @@ import { log } from '@dxos/log';
12
12
  import { ConnectivityError } from '@dxos/protocols';
13
13
  import { type Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
14
14
 
15
+ import { type Transport, type TransportOptions, type TransportStats } from '../transport';
16
+
15
17
  import { type RtcPeerConnection } from './rtc-peer-connection';
16
18
  import { createRtcTransportStats, describeSelectedRemoteCandidate } from './rtc-transport-stats';
17
- import { type Transport, type TransportOptions, type TransportStats } from '../transport';
18
19
 
19
20
  // https://viblast.com/blog/2015/2/5/webrtc-data-channel-message-size
20
21
  const MAX_MESSAGE_SIZE = 64 * 1024;
@@ -2,11 +2,12 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { getRtcConnectionFactory } from './rtc-connection-factory';
6
- import { RtcPeerConnection } from './rtc-peer-connection';
7
5
  import type { IceProvider } from '../../signal';
8
6
  import type { TransportFactory } from '../transport';
9
7
 
8
+ import { getRtcConnectionFactory } from './rtc-connection-factory';
9
+ import { RtcPeerConnection } from './rtc-peer-connection';
10
+
10
11
  export const createRtcTransportFactory = (
11
12
  webrtcConfig?: RTCConfiguration,
12
13
  iceProvider?: IceProvider,
@@ -3,19 +3,21 @@
3
3
  //
4
4
 
5
5
  import { Duplex } from 'stream';
6
- import { onTestFinished, describe, test, expect } from 'vitest';
6
+
7
+ import { describe, expect, onTestFinished, test } from 'vitest';
7
8
 
8
9
  import { Event as AsyncEvent, TestStream, Trigger, sleep } from '@dxos/async';
9
10
  import { ErrorStream } from '@dxos/debug';
10
11
  import { PublicKey } from '@dxos/keys';
11
12
  import { schema } from '@dxos/protocols/proto';
12
13
  import { type BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';
13
- import { createLinkedPorts, createProtoRpcPeer, type RpcPort } from '@dxos/rpc';
14
+ import { type RpcPort, createLinkedPorts, createProtoRpcPeer } from '@dxos/rpc';
15
+
16
+ import { type Transport, type TransportFactory, type TransportOptions, type TransportStats } from '../transport';
14
17
 
15
18
  import { RtcTransportProxy } from './rtc-transport-proxy';
16
19
  import { RtcTransportService } from './rtc-transport-service';
17
20
  import { handleChannelErrors } from './test-utils';
18
- import { type Transport, type TransportFactory, type TransportOptions, type TransportStats } from '../transport';
19
21
 
20
22
  describe('RtcPeerTransportProxy', () => {
21
23
  test('open and close', async () => {
@@ -9,24 +9,25 @@ import { invariant } from '@dxos/invariant';
9
9
  import { PublicKey } from '@dxos/keys';
10
10
  import { log } from '@dxos/log';
11
11
  import {
12
+ type BridgeEvent,
12
13
  type BridgeService,
14
+ type CloseRequest,
13
15
  type ConnectionRequest,
14
- type SignalRequest,
15
- type DataRequest,
16
- type BridgeEvent,
17
16
  ConnectionState,
18
- type CloseRequest,
17
+ type DataRequest,
19
18
  type DetailsRequest,
20
19
  type DetailsResponse,
20
+ type SignalRequest,
21
21
  type StatsRequest,
22
22
  type StatsResponse,
23
23
  } from '@dxos/protocols/proto/dxos/mesh/bridge';
24
24
  import { ComplexMap } from '@dxos/util';
25
25
 
26
- import { createRtcTransportFactory } from './rtc-transport-factory';
27
26
  import { type IceProvider } from '../../signal';
28
27
  import { type Transport, type TransportFactory } from '../transport';
29
28
 
29
+ import { createRtcTransportFactory } from './rtc-transport-factory';
30
+
30
31
  type TransportState = {
31
32
  proxyId: PublicKey;
32
33
  transport: Transport;
@@ -2,16 +2,17 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { onTestFinished, describe, expect, test } from 'vitest';
5
+ import { describe, expect, onTestFinished, test } from 'vitest';
6
6
 
7
- import { sleep, TestStream } from '@dxos/async';
7
+ import { TestStream, sleep } from '@dxos/async';
8
8
  import { PublicKey } from '@dxos/keys';
9
9
 
10
+ import { type TransportOptions } from '../transport';
11
+
10
12
  import { getRtcConnectionFactory } from './rtc-connection-factory';
11
13
  import { RtcPeerConnection } from './rtc-peer-connection';
12
14
  import { type RtcTransportChannel } from './rtc-transport-channel';
13
15
  import { chooseInitiatorPeer } from './utils';
14
- import { type TransportOptions } from '../transport';
15
16
 
16
17
  const connectionFactory = getRtcConnectionFactory();
17
18