@dxos/network-manager 0.2.3 → 0.2.4-main.cc5efc5

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.
@@ -16,6 +16,7 @@ export declare class SimplePeerTransport implements Transport {
16
16
  private readonly params;
17
17
  private readonly _peer;
18
18
  private _closed;
19
+ private _piped;
19
20
  readonly closed: Event<void>;
20
21
  readonly connected: Event<void>;
21
22
  readonly errors: ErrorStream;
@@ -1 +1 @@
1
- {"version":3,"file":"simplepeer-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/simplepeer-transport.ts"],"names":[],"mappings":";AAQA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAS,MAAM,aAAa,CAAC;AAIjD,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG1D,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC;IAC/B,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,qBAAa,mBAAoB,YAAW,SAAS;IAUvC,OAAO,CAAC,QAAQ,CAAC,MAAM;IATnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,OAAO,CAAS;IAExB,QAAQ,CAAC,MAAM,cAAe;IAC9B,QAAQ,CAAC,SAAS,cAAe;IACjC,QAAQ,CAAC,MAAM,cAAqB;IAEpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8B;gBAE7B,MAAM,EAAE,yBAAyB;IAqFxD,OAAO;IASb,MAAM,CAAC,MAAM,EAAE,MAAM;YASP,kBAAkB;CAIjC;AAED,eAAO,MAAM,gCAAgC,kBAAmB,GAAG,KAAG,gBAMpE,CAAC"}
1
+ {"version":3,"file":"simplepeer-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/simplepeer-transport.ts"],"names":[],"mappings":";AAQA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAS,MAAM,aAAa,CAAC;AAIjD,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG1D,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC;IAC/B,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,qBAAa,mBAAoB,YAAW,SAAS;IAWvC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAVnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IAEvB,QAAQ,CAAC,MAAM,cAAe;IAC9B,QAAQ,CAAC,SAAS,cAAe;IACjC,QAAQ,CAAC,MAAM,cAAqB;IAEpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8B;gBAE7B,MAAM,EAAE,yBAAyB;IAqFxD,OAAO;IAYb,MAAM,CAAC,MAAM,EAAE,MAAM;IASrB,OAAO,CAAC,kBAAkB;CAM3B;AAED,eAAO,MAAM,gCAAgC,kBAAmB,GAAG,KAAG,gBAMpE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/network-manager",
3
- "version": "0.2.3",
3
+ "version": "0.2.4-main.cc5efc5",
4
4
  "description": "Network Manager",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -31,21 +31,21 @@
31
31
  "tiny-invariant": "^1.3.1",
32
32
  "ws": "^7.4.4",
33
33
  "xor-distance": "^2.0.0",
34
- "@dxos/async": "0.2.3",
35
- "@dxos/codec-protobuf": "0.2.3",
36
- "@dxos/context": "0.2.3",
37
- "@dxos/credentials": "0.2.3",
38
- "@dxos/crypto": "0.2.3",
39
- "@dxos/debug": "0.2.3",
40
- "@dxos/invariant": "0.2.3",
41
- "@dxos/keys": "0.2.3",
42
- "@dxos/log": "0.2.3",
43
- "@dxos/messaging": "0.2.3",
44
- "@dxos/node-std": "0.2.3",
45
- "@dxos/protocols": "0.2.3",
46
- "@dxos/rpc": "0.2.3",
47
- "@dxos/teleport": "0.2.3",
48
- "@dxos/util": "0.2.3"
34
+ "@dxos/async": "0.2.4-main.cc5efc5",
35
+ "@dxos/codec-protobuf": "0.2.4-main.cc5efc5",
36
+ "@dxos/context": "0.2.4-main.cc5efc5",
37
+ "@dxos/credentials": "0.2.4-main.cc5efc5",
38
+ "@dxos/crypto": "0.2.4-main.cc5efc5",
39
+ "@dxos/debug": "0.2.4-main.cc5efc5",
40
+ "@dxos/invariant": "0.2.4-main.cc5efc5",
41
+ "@dxos/keys": "0.2.4-main.cc5efc5",
42
+ "@dxos/log": "0.2.4-main.cc5efc5",
43
+ "@dxos/messaging": "0.2.4-main.cc5efc5",
44
+ "@dxos/node-std": "0.2.4-main.cc5efc5",
45
+ "@dxos/protocols": "0.2.4-main.cc5efc5",
46
+ "@dxos/rpc": "0.2.4-main.cc5efc5",
47
+ "@dxos/teleport": "0.2.4-main.cc5efc5",
48
+ "@dxos/util": "0.2.4-main.cc5efc5"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@swc-node/register": "1.5.4",
@@ -55,7 +55,7 @@
55
55
  "earljs": "~0.1.10",
56
56
  "fast-check": "~3.3.0",
57
57
  "typescript": "^5.2.2",
58
- "@dxos/signal": "0.2.3"
58
+ "@dxos/signal": "0.2.4-main.cc5efc5"
59
59
  },
60
60
  "publishConfig": {
61
61
  "access": "public"
@@ -29,6 +29,7 @@ export type SimplePeerTransportParams = {
29
29
  export class SimplePeerTransport implements Transport {
30
30
  private readonly _peer: SimplePeer;
31
31
  private _closed = false;
32
+ private _piped = false;
32
33
 
33
34
  readonly closed = new Event();
34
35
  readonly connected = new Event();
@@ -54,13 +55,13 @@ export class SimplePeerTransport implements Transport {
54
55
  this._peer.on('connect', () => {
55
56
  log('connected');
56
57
  this.params.stream.pipe(this._peer!).pipe(this.params.stream);
58
+ this._piped = true;
57
59
  this.connected.emit();
58
60
  });
59
61
 
60
62
  this._peer.on('close', async () => {
61
63
  log('closed');
62
- await this._disconnectStreams();
63
- this.closed.emit();
64
+ await this.destroy();
64
65
  });
65
66
 
66
67
  this._peer.on('error', async (err) => {
@@ -123,8 +124,11 @@ export class SimplePeerTransport implements Transport {
123
124
 
124
125
  async destroy() {
125
126
  log('closing...');
127
+ if (this._closed) {
128
+ return;
129
+ }
126
130
  this._closed = true;
127
- await this._disconnectStreams();
131
+ this._disconnectStreams();
128
132
  this._peer!.destroy();
129
133
  this.closed.emit();
130
134
  log('closed');
@@ -139,9 +143,11 @@ export class SimplePeerTransport implements Transport {
139
143
  this._peer.signal(signal.payload.data);
140
144
  }
141
145
 
142
- private async _disconnectStreams() {
146
+ private _disconnectStreams() {
143
147
  // TODO(rzadp): Find a way of unpiping this?
144
- this.params.stream.unpipe?.(this._peer)?.unpipe?.(this.params.stream);
148
+ if (this._piped) {
149
+ this.params.stream.unpipe?.(this._peer)?.unpipe?.(this.params.stream);
150
+ }
145
151
  }
146
152
  }
147
153