@dxos/network-manager 0.1.53-next.e9dc2bc → 0.1.54-main.270ec56

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.
@@ -1,15 +1,18 @@
1
1
  import { Event } from '@dxos/async';
2
2
  import { PublicKey } from '@dxos/keys';
3
- import { TestExtension } from '@dxos/teleport';
3
+ import { TestExtension, TestExtensionWithStreams, type TestStreamStats } from '@dxos/teleport';
4
4
  import { ComplexMap } from '@dxos/util';
5
5
  export declare class TestWireProtocol {
6
6
  readonly peerId: PublicKey;
7
7
  readonly connections: ComplexMap<PublicKey, TestExtension>;
8
+ readonly streamConnections: ComplexMap<PublicKey, TestExtensionWithStreams>;
8
9
  readonly connected: Event<PublicKey>;
9
10
  readonly disconnected: Event<PublicKey>;
10
11
  constructor(peerId: PublicKey);
11
12
  readonly factory: import("../wire-protocol").WireProtocolProvider;
12
13
  waitForConnection(peerId: PublicKey): Promise<TestExtension>;
13
14
  testConnection(peerId: PublicKey, message?: string): Promise<void>;
15
+ startStream(peerId: PublicKey, streamTag: string, streamLoadInterval: number, streamLoadChunkSize: number): Promise<string>;
16
+ closeStream(peerId: PublicKey, streamTag: string): Promise<TestStreamStats>;
14
17
  }
15
18
  //# sourceMappingURL=test-wire-protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"test-wire-protocol.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-wire-protocol.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIxC,qBAAa,gBAAgB;aAKC,MAAM,EAAE,SAAS;IAJ7C,SAAgB,WAAW,uCAA4D;IACvF,SAAgB,SAAS,mBAA0B;IACnD,SAAgB,YAAY,mBAA0B;gBAE1B,MAAM,EAAE,SAAS;IAE7C,QAAQ,CAAC,OAAO,kDAWb;IAEG,iBAAiB,CAAC,MAAM,EAAE,SAAS;IAanC,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM;CAIzD"}
1
+ {"version":3,"file":"test-wire-protocol.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-wire-protocol.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIxC,qBAAa,gBAAgB;aAOC,MAAM,EAAE,SAAS;IAN7C,SAAgB,WAAW,uCAA4D;IACvF,SAAgB,iBAAiB,kDAAuE;IAExG,SAAgB,SAAS,mBAA0B;IACnD,SAAgB,YAAY,mBAA0B;gBAE1B,MAAM,EAAE,SAAS;IAE7C,QAAQ,CAAC,OAAO,kDAmBb;IAEG,iBAAiB,CAAC,MAAM,EAAE,SAAS;IAanC,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM;IAKlD,WAAW,CACf,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,EAC1B,mBAAmB,EAAE,MAAM,GAC1B,OAAO,CAAC,MAAM,CAAC;IAQZ,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAOlF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/network-manager",
3
- "version": "0.1.53-next.e9dc2bc",
3
+ "version": "0.1.54-main.270ec56",
4
4
  "description": "Network Manager",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -26,21 +26,21 @@
26
26
  "tiny-invariant": "^1.3.1",
27
27
  "ws": "^7.4.4",
28
28
  "xor-distance": "^2.0.0",
29
- "@dxos/async": "0.1.53-next.e9dc2bc",
30
- "@dxos/codec-protobuf": "0.1.53-next.e9dc2bc",
31
- "@dxos/context": "0.1.53-next.e9dc2bc",
32
- "@dxos/credentials": "0.1.53-next.e9dc2bc",
33
- "@dxos/crypto": "0.1.53-next.e9dc2bc",
34
- "@dxos/debug": "0.1.53-next.e9dc2bc",
35
- "@dxos/errors": "0.1.53-next.e9dc2bc",
36
- "@dxos/keys": "0.1.53-next.e9dc2bc",
37
- "@dxos/log": "0.1.53-next.e9dc2bc",
38
- "@dxos/messaging": "0.1.53-next.e9dc2bc",
39
- "@dxos/node-std": "0.1.53-next.e9dc2bc",
40
- "@dxos/protocols": "0.1.53-next.e9dc2bc",
41
- "@dxos/rpc": "0.1.53-next.e9dc2bc",
42
- "@dxos/teleport": "0.1.53-next.e9dc2bc",
43
- "@dxos/util": "0.1.53-next.e9dc2bc"
29
+ "@dxos/codec-protobuf": "0.1.54-main.270ec56",
30
+ "@dxos/async": "0.1.54-main.270ec56",
31
+ "@dxos/context": "0.1.54-main.270ec56",
32
+ "@dxos/credentials": "0.1.54-main.270ec56",
33
+ "@dxos/crypto": "0.1.54-main.270ec56",
34
+ "@dxos/debug": "0.1.54-main.270ec56",
35
+ "@dxos/errors": "0.1.54-main.270ec56",
36
+ "@dxos/keys": "0.1.54-main.270ec56",
37
+ "@dxos/messaging": "0.1.54-main.270ec56",
38
+ "@dxos/log": "0.1.54-main.270ec56",
39
+ "@dxos/node-std": "0.1.54-main.270ec56",
40
+ "@dxos/protocols": "0.1.54-main.270ec56",
41
+ "@dxos/rpc": "0.1.54-main.270ec56",
42
+ "@dxos/teleport": "0.1.54-main.270ec56",
43
+ "@dxos/util": "0.1.54-main.270ec56"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@swc-node/register": "1.5.4",
@@ -50,7 +50,7 @@
50
50
  "earljs": "~0.1.10",
51
51
  "fast-check": "~3.3.0",
52
52
  "typescript": "^5.0.4",
53
- "@dxos/signal": "0.1.53-next.e9dc2bc"
53
+ "@dxos/signal": "0.1.54-main.270ec56"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"
@@ -5,13 +5,15 @@
5
5
  import { asyncTimeout, Event } from '@dxos/async';
6
6
  import { PublicKey } from '@dxos/keys';
7
7
  import { log } from '@dxos/log';
8
- import { TestExtension } from '@dxos/teleport';
8
+ import { TestExtension, TestExtensionWithStreams, type TestStreamStats } from '@dxos/teleport';
9
9
  import { ComplexMap } from '@dxos/util';
10
10
 
11
11
  import { createTeleportProtocolFactory } from '../wire-protocol';
12
12
 
13
13
  export class TestWireProtocol {
14
14
  public readonly connections = new ComplexMap<PublicKey, TestExtension>(PublicKey.hash);
15
+ public readonly streamConnections = new ComplexMap<PublicKey, TestExtensionWithStreams>(PublicKey.hash);
16
+
15
17
  public readonly connected = new Event<PublicKey>();
16
18
  public readonly disconnected = new Event<PublicKey>();
17
19
 
@@ -28,6 +30,14 @@ export class TestWireProtocol {
28
30
  this.connections.set(teleport.remotePeerId, extension);
29
31
  teleport.addExtension('test', extension);
30
32
  this.connected.emit(teleport.remotePeerId);
33
+
34
+ const streamExtension = new TestExtensionWithStreams({
35
+ onClose: async () => {
36
+ this.streamConnections.delete(teleport.remotePeerId);
37
+ },
38
+ });
39
+ this.streamConnections.set(teleport.remotePeerId, streamExtension);
40
+ teleport.addExtension('test-stream', streamExtension);
31
41
  });
32
42
 
33
43
  async waitForConnection(peerId: PublicKey) {
@@ -47,4 +57,25 @@ export class TestWireProtocol {
47
57
  const connection = await this.waitForConnection(peerId);
48
58
  await connection.test(message);
49
59
  }
60
+
61
+ async startStream(
62
+ peerId: PublicKey,
63
+ streamTag: string,
64
+ streamLoadInterval: number,
65
+ streamLoadChunkSize: number,
66
+ ): Promise<string> {
67
+ if (!this.streamConnections.has(peerId)) {
68
+ throw new Error('Connection does not exist.');
69
+ }
70
+ const connection = this.streamConnections.get(peerId)!;
71
+ return connection.addNewStream(streamLoadInterval, streamLoadChunkSize, streamTag);
72
+ }
73
+
74
+ async closeStream(peerId: PublicKey, streamTag: string): Promise<TestStreamStats> {
75
+ if (!this.streamConnections.has(peerId)) {
76
+ throw new Error('Connection does not exist.');
77
+ }
78
+ const connection = this.streamConnections.get(peerId)!;
79
+ return connection.closeStream(streamTag);
80
+ }
50
81
  }