@dxos/network-manager 2.33.5-dev.0a40e013 → 2.33.5-dev.0d84e06f

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 (36) hide show
  1. package/dist/browser-mocha/bundle.js +245 -303
  2. package/dist/src/network-manager.blueprint-test.d.ts +1 -1
  3. package/dist/src/network-manager.blueprint-test.d.ts.map +1 -1
  4. package/dist/src/network-manager.blueprint-test.js +6 -6
  5. package/dist/src/network-manager.blueprint-test.js.map +1 -1
  6. package/dist/src/network-manager.test.js +2 -2
  7. package/dist/src/network-manager.test.js.map +1 -1
  8. package/dist/src/protocol-factory.d.ts +1 -1
  9. package/dist/src/protocol-factory.d.ts.map +1 -1
  10. package/dist/src/protocol-factory.js +10 -18
  11. package/dist/src/protocol-factory.js.map +1 -1
  12. package/dist/src/signal/signal-api.test.js +1 -1
  13. package/dist/src/signal/signal-api.test.js.map +1 -1
  14. package/dist/src/testing/test-protocol.d.ts.map +1 -1
  15. package/dist/src/testing/test-protocol.js +5 -9
  16. package/dist/src/testing/test-protocol.js.map +1 -1
  17. package/dist/src/topology/mmst-topology.js +1 -3
  18. package/dist/src/topology/mmst-topology.js.map +1 -1
  19. package/dist/src/transport/in-memory-transport.js +6 -8
  20. package/dist/src/transport/in-memory-transport.js.map +1 -1
  21. package/dist/src/transport/in-memory-transport.test.js +2 -2
  22. package/dist/src/transport/in-memory-transport.test.js.map +1 -1
  23. package/dist/src/transport/webrtc-transport.d.ts.map +1 -1
  24. package/dist/src/transport/webrtc-transport.js +1 -3
  25. package/dist/src/transport/webrtc-transport.js.map +1 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +10 -10
  28. package/src/network-manager.blueprint-test.ts +6 -6
  29. package/src/network-manager.test.ts +2 -2
  30. package/src/protocol-factory.ts +10 -18
  31. package/src/signal/signal-api.test.ts +1 -1
  32. package/src/testing/test-protocol.ts +5 -9
  33. package/src/topology/mmst-topology.ts +1 -3
  34. package/src/transport/in-memory-transport.test.ts +2 -2
  35. package/src/transport/in-memory-transport.ts +6 -8
  36. package/src/transport/webrtc-transport.ts +10 -12
@@ -59,26 +59,18 @@ export interface Plugin {
59
59
  createExtension: () => Extension;
60
60
  }
61
61
 
62
- export function createProtocolFactory (topic: PublicKey, peerId: PublicKey, plugins: Plugin[]) {
63
- return protocolFactory({
64
- getTopics: () => {
65
- return [topic.asBuffer()];
66
- },
67
- session: { peerId: keyToString(peerId.asBuffer()) },
68
- plugins
69
- });
70
- }
62
+ export const createProtocolFactory = (topic: PublicKey, peerId: PublicKey, plugins: Plugin[]) => protocolFactory({
63
+ getTopics: () => [topic.asBuffer()],
64
+ session: { peerId: keyToString(peerId.asBuffer()) },
65
+ plugins
66
+ });
71
67
 
72
68
  /**
73
69
  * Creates a ProtocolProvider for simple transport connections with only one protocol plugin.
74
70
  * @deprecated Use `createProtocolFactory`.
75
71
  */
76
- export const transportProtocolProvider = (rendezvousKey: Buffer, peerId: Buffer, protocolPlugin: any): ProtocolProvider => {
77
- return protocolFactory({
78
- getTopics: () => {
79
- return [rendezvousKey];
80
- },
81
- session: { peerId: keyToString(peerId) },
82
- plugins: [protocolPlugin]
83
- });
84
- };
72
+ export const transportProtocolProvider = (rendezvousKey: Buffer, peerId: Buffer, protocolPlugin: any): ProtocolProvider => protocolFactory({
73
+ getTopics: () => [rendezvousKey],
74
+ session: { peerId: keyToString(peerId) },
75
+ plugins: [protocolPlugin]
76
+ });
@@ -28,7 +28,7 @@ describe('SignalApi', () => {
28
28
  const signalApiPort2 = randomInt(10000, 50000);
29
29
  const signalApiUrl2 = 'http://0.0.0.0:' + signalApiPort2;
30
30
 
31
- before(async function () {
31
+ before(async () => {
32
32
  broker = await createTestBroker(signalApiPort);
33
33
  // code broker2 = await createTestBroker(signalApiPort2);
34
34
  });
@@ -149,12 +149,8 @@ export class TestProtocolPlugin extends EventEmitter {
149
149
  * @return {ProtocolProvider}
150
150
  */
151
151
  // TODO(dboreham): Try to encapsulate swarmKey, nodeId.
152
- export const testProtocolProvider = (swarmKey: Buffer, nodeId: Buffer, protocolPlugin: any) => {
153
- return protocolFactory({
154
- getTopics: () => {
155
- return [swarmKey];
156
- },
157
- session: { peerId: keyToString(nodeId) },
158
- plugins: [protocolPlugin]
159
- });
160
- };
152
+ export const testProtocolProvider = (swarmKey: Buffer, nodeId: Buffer, protocolPlugin: any) => protocolFactory({
153
+ getTopics: () => [swarmKey],
154
+ session: { peerId: keyToString(nodeId) },
155
+ plugins: [protocolPlugin]
156
+ });
@@ -111,6 +111,4 @@ export class MMSTTopology implements Topology {
111
111
  }
112
112
  }
113
113
 
114
- function sortByXorDistance (keys: PublicKey[], reference: PublicKey): PublicKey[] {
115
- return keys.sort((a, b) => distance.gt(distance(a.asBuffer(), reference.asBuffer()), distance(b.asBuffer(), reference.asBuffer())));
116
- }
114
+ const sortByXorDistance = (keys: PublicKey[], reference: PublicKey): PublicKey[] => keys.sort((a, b) => distance.gt(distance(a.asBuffer(), reference.asBuffer()), distance(b.asBuffer(), reference.asBuffer())));
@@ -17,7 +17,7 @@ import { InMemoryTransport } from './in-memory-transport';
17
17
  // Cannot log after tests are done. Did you forget to wait for something async in your test?
18
18
  // Attempted to log "Ignoring unsupported ICE candidate.".
19
19
 
20
- function createPair () {
20
+ const createPair = () => {
21
21
  const topic = PublicKey.random();
22
22
  const peer1Id = PublicKey.random();
23
23
  const peer2Id = PublicKey.random();
@@ -50,7 +50,7 @@ function createPair () {
50
50
  afterTest(() => connection2.errors.assertNoUnhandledErrors());
51
51
 
52
52
  return { connection1, connection2, plugin1, plugin2, peer1Id, peer2Id, topic };
53
- }
53
+ };
54
54
 
55
55
  describe('InMemoryTransport', () => {
56
56
  it('establish connection and send data through with protocol', async () => {
@@ -123,11 +123,9 @@ export const inMemoryTransportFactory: TransportFactory = opts => new InMemoryTr
123
123
  /**
124
124
  * Creates a binary stream that delays data being sent through the stream by the specified amount of time.
125
125
  */
126
- const createStreamDelay = (delay: number): NodeJS.ReadWriteStream => {
127
- return new Transform({
128
- objectMode: true,
129
- transform: (chunk, enc, cb) => {
130
- setTimeout(() => cb(null, chunk), delay);
131
- }
132
- });
133
- };
126
+ const createStreamDelay = (delay: number): NodeJS.ReadWriteStream => new Transform({
127
+ objectMode: true,
128
+ transform: (chunk, enc, cb) => {
129
+ setTimeout(() => cb(null, chunk), delay);
130
+ }
131
+ });
@@ -105,15 +105,13 @@ export class WebrtcTransport implements Transport {
105
105
  }
106
106
  }
107
107
 
108
- export const createWebRtcTransportFactory = (webrtcConfig?: any): TransportFactory => {
109
- return opts => new WebrtcTransport(
110
- opts.initiator,
111
- opts.stream,
112
- opts.ownId,
113
- opts.remoteId,
114
- opts.sessionId,
115
- opts.topic,
116
- opts.sendSignal,
117
- webrtcConfig
118
- );
119
- };
108
+ export const createWebRtcTransportFactory = (webrtcConfig?: any): TransportFactory => opts => new WebrtcTransport(
109
+ opts.initiator,
110
+ opts.stream,
111
+ opts.ownId,
112
+ opts.remoteId,
113
+ opts.sessionId,
114
+ opts.topic,
115
+ opts.sendSignal,
116
+ webrtcConfig
117
+ );