@libp2p/interface 0.0.1-7b5c54dd → 0.0.1-7debe031
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/src/connection/index.d.ts +140 -53
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection/index.js.map +1 -1
- package/dist/src/index.d.ts +6 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/stream-muxer/index.d.ts +6 -2
- package/dist/src/stream-muxer/index.d.ts.map +1 -1
- package/dist/src/stream-muxer/stream.d.ts +80 -21
- package/dist/src/stream-muxer/stream.d.ts.map +1 -1
- package/dist/src/stream-muxer/stream.js +224 -168
- package/dist/src/stream-muxer/stream.js.map +1 -1
- package/package.json +4 -8
- package/src/connection/index.ts +166 -59
- package/src/index.ts +6 -2
- package/src/stream-muxer/index.ts +7 -2
- package/src/stream-muxer/stream.ts +295 -186
- package/dist/src/connection/status.d.ts +0 -4
- package/dist/src/connection/status.d.ts.map +0 -1
- package/dist/src/connection/status.js +0 -4
- package/dist/src/connection/status.js.map +0 -1
- package/src/connection/status.ts +0 -4
|
@@ -1,40 +1,27 @@
|
|
|
1
|
-
import type * as Status from './status.js';
|
|
2
1
|
import type { AbortOptions } from '../index.js';
|
|
3
2
|
import type { PeerId } from '../peer-id/index.js';
|
|
4
3
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
5
4
|
import type { Duplex, Source } from 'it-stream-types';
|
|
6
5
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
7
6
|
export interface ConnectionTimeline {
|
|
8
|
-
open: number;
|
|
9
|
-
upgraded?: number;
|
|
10
|
-
close?: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Outbound conections are opened by the local node, inbound streams are opened by the remote
|
|
14
|
-
*/
|
|
15
|
-
export type Direction = 'inbound' | 'outbound';
|
|
16
|
-
export interface ConnectionStat {
|
|
17
|
-
/**
|
|
18
|
-
* Outbound conections are opened by the local node, inbound streams are opened by the remote
|
|
19
|
-
*/
|
|
20
|
-
direction: Direction;
|
|
21
|
-
/**
|
|
22
|
-
* Lifecycle times for the connection
|
|
23
|
-
*/
|
|
24
|
-
timeline: ConnectionTimeline;
|
|
25
7
|
/**
|
|
26
|
-
*
|
|
8
|
+
* When the connection was opened
|
|
27
9
|
*/
|
|
28
|
-
|
|
10
|
+
open: number;
|
|
29
11
|
/**
|
|
30
|
-
*
|
|
12
|
+
* When the MultiaddrConnection was upgraded to a Connection - e.g. the type
|
|
13
|
+
* of connection encryption and multiplexing was negotiated.
|
|
31
14
|
*/
|
|
32
|
-
|
|
15
|
+
upgraded?: number;
|
|
33
16
|
/**
|
|
34
|
-
*
|
|
17
|
+
* When the connection was closed.
|
|
35
18
|
*/
|
|
36
|
-
|
|
19
|
+
close?: number;
|
|
37
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Outbound connections are opened by the local node, inbound streams are opened by the remote
|
|
23
|
+
*/
|
|
24
|
+
export type Direction = 'inbound' | 'outbound';
|
|
38
25
|
export interface StreamTimeline {
|
|
39
26
|
/**
|
|
40
27
|
* A timestamp of when the stream was opened
|
|
@@ -56,21 +43,33 @@ export interface StreamTimeline {
|
|
|
56
43
|
* A timestamp of when the stream was reset
|
|
57
44
|
*/
|
|
58
45
|
reset?: number;
|
|
59
|
-
}
|
|
60
|
-
export interface StreamStat {
|
|
61
|
-
/**
|
|
62
|
-
* Outbound streams are opened by the local node, inbound streams are opened by the remote
|
|
63
|
-
*/
|
|
64
|
-
direction: Direction;
|
|
65
|
-
/**
|
|
66
|
-
* Lifecycle times for the stream
|
|
67
|
-
*/
|
|
68
|
-
timeline: StreamTimeline;
|
|
69
46
|
/**
|
|
70
|
-
*
|
|
47
|
+
* A timestamp of when the stream was aborted
|
|
71
48
|
*/
|
|
72
|
-
|
|
49
|
+
abort?: number;
|
|
73
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* The states a stream can be in
|
|
53
|
+
*/
|
|
54
|
+
export type StreamStatus = 'open' | 'closing' | 'closed' | 'aborted' | 'reset';
|
|
55
|
+
/**
|
|
56
|
+
* The states the readable end of a stream can be in
|
|
57
|
+
*
|
|
58
|
+
* ready - the readable end is ready for reading
|
|
59
|
+
* closing - the readable end is closing
|
|
60
|
+
* closed - the readable end has closed
|
|
61
|
+
*/
|
|
62
|
+
export type ReadStatus = 'ready' | 'closing' | 'closed';
|
|
63
|
+
/**
|
|
64
|
+
* The states the writable end of a stream can be in
|
|
65
|
+
*
|
|
66
|
+
* ready - the writable end is ready for writing
|
|
67
|
+
* writing - the writable end is in the process of being written to
|
|
68
|
+
* done - the source passed to the `.sink` function yielded all values without error
|
|
69
|
+
* closing - the writable end is closing
|
|
70
|
+
* closed - the writable end has closed
|
|
71
|
+
*/
|
|
72
|
+
export type WriteStatus = 'ready' | 'writing' | 'done' | 'closing' | 'closed';
|
|
74
73
|
/**
|
|
75
74
|
* A Stream is a data channel between two peers that
|
|
76
75
|
* can be written to and read from at both ends.
|
|
@@ -88,7 +87,7 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
88
87
|
*
|
|
89
88
|
* The sink and the source will return normally.
|
|
90
89
|
*/
|
|
91
|
-
close: () => void
|
|
90
|
+
close: (options?: AbortOptions) => Promise<void>;
|
|
92
91
|
/**
|
|
93
92
|
* Closes the stream for **reading**. If iterating over the source of this stream in a `for await of` loop, it will return (exit the loop) after any buffered data has been consumed.
|
|
94
93
|
*
|
|
@@ -96,13 +95,13 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
96
95
|
*
|
|
97
96
|
* The source will return normally, the sink will continue to consume.
|
|
98
97
|
*/
|
|
99
|
-
closeRead: () => void
|
|
98
|
+
closeRead: (options?: AbortOptions) => Promise<void>;
|
|
100
99
|
/**
|
|
101
100
|
* Closes the stream for **writing**. If iterating over the source of this stream in a `for await of` loop, it will return (exit the loop) after any buffered data has been consumed.
|
|
102
101
|
*
|
|
103
102
|
* The source will return normally, the sink will continue to consume.
|
|
104
103
|
*/
|
|
105
|
-
closeWrite: () => void
|
|
104
|
+
closeWrite: (options?: AbortOptions) => Promise<void>;
|
|
106
105
|
/**
|
|
107
106
|
* Closes the stream for **reading** *and* **writing**. This should be called when a *local error* has occurred.
|
|
108
107
|
*
|
|
@@ -113,26 +112,38 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
113
112
|
* The sink will return and the source will throw if an error is passed or return normally if not.
|
|
114
113
|
*/
|
|
115
114
|
abort: (err: Error) => void;
|
|
116
|
-
/**
|
|
117
|
-
* Closes the stream *immediately* for **reading** *and* **writing**. This should be called when a *remote error* has occurred.
|
|
118
|
-
*
|
|
119
|
-
* This function is called automatically by the muxer when it receives a `RESET` message from the remote.
|
|
120
|
-
*
|
|
121
|
-
* The sink will return and the source will throw.
|
|
122
|
-
*/
|
|
123
|
-
reset: () => void;
|
|
124
115
|
/**
|
|
125
116
|
* Unique identifier for a stream. Identifiers are not unique across muxers.
|
|
126
117
|
*/
|
|
127
118
|
id: string;
|
|
128
119
|
/**
|
|
129
|
-
*
|
|
120
|
+
* Outbound streams are opened by the local node, inbound streams are opened by the remote
|
|
130
121
|
*/
|
|
131
|
-
|
|
122
|
+
direction: Direction;
|
|
123
|
+
/**
|
|
124
|
+
* Lifecycle times for the stream
|
|
125
|
+
*/
|
|
126
|
+
timeline: StreamTimeline;
|
|
127
|
+
/**
|
|
128
|
+
* Once a protocol has been negotiated for this stream, it will be set on the stat object
|
|
129
|
+
*/
|
|
130
|
+
protocol?: string;
|
|
132
131
|
/**
|
|
133
132
|
* User defined stream metadata
|
|
134
133
|
*/
|
|
135
134
|
metadata: Record<string, any>;
|
|
135
|
+
/**
|
|
136
|
+
* The current status of the stream
|
|
137
|
+
*/
|
|
138
|
+
status: StreamStatus;
|
|
139
|
+
/**
|
|
140
|
+
* The current status of the readable end of the stream
|
|
141
|
+
*/
|
|
142
|
+
readStatus: ReadStatus;
|
|
143
|
+
/**
|
|
144
|
+
* The current status of the writable end of the stream
|
|
145
|
+
*/
|
|
146
|
+
writeStatus: WriteStatus;
|
|
136
147
|
}
|
|
137
148
|
export interface NewStreamOptions extends AbortOptions {
|
|
138
149
|
/**
|
|
@@ -142,6 +153,7 @@ export interface NewStreamOptions extends AbortOptions {
|
|
|
142
153
|
*/
|
|
143
154
|
maxOutboundStreams?: number;
|
|
144
155
|
}
|
|
156
|
+
export type ConnectionStatus = 'open' | 'closing' | 'closed';
|
|
145
157
|
/**
|
|
146
158
|
* A Connection is a high-level representation of a connection
|
|
147
159
|
* to a remote peer that may have been secured by encryption and
|
|
@@ -149,16 +161,67 @@ export interface NewStreamOptions extends AbortOptions {
|
|
|
149
161
|
* between which the connection is made.
|
|
150
162
|
*/
|
|
151
163
|
export interface Connection {
|
|
164
|
+
/**
|
|
165
|
+
* The unique identifier for this connection
|
|
166
|
+
*/
|
|
152
167
|
id: string;
|
|
153
|
-
|
|
168
|
+
/**
|
|
169
|
+
* The address of the remote end of the connection
|
|
170
|
+
*/
|
|
154
171
|
remoteAddr: Multiaddr;
|
|
172
|
+
/**
|
|
173
|
+
* The id of the peer at the remote end of the connection
|
|
174
|
+
*/
|
|
155
175
|
remotePeer: PeerId;
|
|
176
|
+
/**
|
|
177
|
+
* A list of tags applied to this connection
|
|
178
|
+
*/
|
|
156
179
|
tags: string[];
|
|
180
|
+
/**
|
|
181
|
+
* A list of open streams on this connection
|
|
182
|
+
*/
|
|
157
183
|
streams: Stream[];
|
|
158
|
-
|
|
184
|
+
/**
|
|
185
|
+
* Outbound conections are opened by the local node, inbound streams are opened by the remote
|
|
186
|
+
*/
|
|
187
|
+
direction: Direction;
|
|
188
|
+
/**
|
|
189
|
+
* Lifecycle times for the connection
|
|
190
|
+
*/
|
|
191
|
+
timeline: ConnectionTimeline;
|
|
192
|
+
/**
|
|
193
|
+
* Once a multiplexer has been negotiated for this stream, it will be set on the stat object
|
|
194
|
+
*/
|
|
195
|
+
multiplexer?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Once a connection encrypter has been negotiated for this stream, it will be set on the stat object
|
|
198
|
+
*/
|
|
199
|
+
encryption?: string;
|
|
200
|
+
/**
|
|
201
|
+
* The current status of the connection
|
|
202
|
+
*/
|
|
203
|
+
status: ConnectionStatus;
|
|
204
|
+
/**
|
|
205
|
+
* Create a new stream on this connection and negotiate one of the passed protocols
|
|
206
|
+
*/
|
|
207
|
+
newStream: (protocols: string | string[], options?: NewStreamOptions) => Promise<Stream>;
|
|
208
|
+
/**
|
|
209
|
+
* Add a stream to this connection
|
|
210
|
+
*/
|
|
159
211
|
addStream: (stream: Stream) => void;
|
|
212
|
+
/**
|
|
213
|
+
* Remove a stream from this connection
|
|
214
|
+
*/
|
|
160
215
|
removeStream: (id: string) => void;
|
|
161
|
-
|
|
216
|
+
/**
|
|
217
|
+
* Gracefully close the connection. All queued data will be written to the
|
|
218
|
+
* underlying transport.
|
|
219
|
+
*/
|
|
220
|
+
close: (options?: AbortOptions) => Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* Immediately close the connection, any queued data will be discarded
|
|
223
|
+
*/
|
|
224
|
+
abort: (err: Error) => void;
|
|
162
225
|
}
|
|
163
226
|
export declare const symbol: unique symbol;
|
|
164
227
|
export declare function isConnection(other: any): other is Connection;
|
|
@@ -171,8 +234,18 @@ export interface ConnectionProtector {
|
|
|
171
234
|
protect: (connection: MultiaddrConnection) => Promise<MultiaddrConnection>;
|
|
172
235
|
}
|
|
173
236
|
export interface MultiaddrConnectionTimeline {
|
|
237
|
+
/**
|
|
238
|
+
* When the connection was opened
|
|
239
|
+
*/
|
|
174
240
|
open: number;
|
|
241
|
+
/**
|
|
242
|
+
* When the MultiaddrConnection was upgraded to a Connection - the type of
|
|
243
|
+
* connection encryption and multiplexing was negotiated.
|
|
244
|
+
*/
|
|
175
245
|
upgraded?: number;
|
|
246
|
+
/**
|
|
247
|
+
* When the connection was closed.
|
|
248
|
+
*/
|
|
176
249
|
close?: number;
|
|
177
250
|
}
|
|
178
251
|
/**
|
|
@@ -181,8 +254,22 @@ export interface MultiaddrConnectionTimeline {
|
|
|
181
254
|
* without encryption or stream multiplexing.
|
|
182
255
|
*/
|
|
183
256
|
export interface MultiaddrConnection extends Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>> {
|
|
184
|
-
|
|
257
|
+
/**
|
|
258
|
+
* Gracefully close the connection. All queued data will be written to the
|
|
259
|
+
* underlying transport.
|
|
260
|
+
*/
|
|
261
|
+
close: (options?: AbortOptions) => Promise<void>;
|
|
262
|
+
/**
|
|
263
|
+
* Immediately close the connection, any queued data will be discarded
|
|
264
|
+
*/
|
|
265
|
+
abort: (err: Error) => void;
|
|
266
|
+
/**
|
|
267
|
+
* The address of the remote end of the connection
|
|
268
|
+
*/
|
|
185
269
|
remoteAddr: Multiaddr;
|
|
270
|
+
/**
|
|
271
|
+
* When connection lifecycle events occurred
|
|
272
|
+
*/
|
|
186
273
|
timeline: MultiaddrConnectionTimeline;
|
|
187
274
|
}
|
|
188
275
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,M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C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AA4QA,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AAEtD,MAAM,UAAU,YAAY,CAAE,KAAU;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AAChD,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -461,7 +461,11 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
461
461
|
*/
|
|
462
462
|
dialProtocol: (peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options?: AbortOptions) => Promise<Stream>;
|
|
463
463
|
/**
|
|
464
|
-
* Attempts to gracefully close an open connection to the given peer. If the
|
|
464
|
+
* Attempts to gracefully close an open connection to the given peer. If the
|
|
465
|
+
* connection is not closed in the grace period, it will be forcefully closed.
|
|
466
|
+
*
|
|
467
|
+
* An AbortSignal can optionally be passed to control when the connection is
|
|
468
|
+
* forcefully closed.
|
|
465
469
|
*
|
|
466
470
|
* @example
|
|
467
471
|
*
|
|
@@ -469,7 +473,7 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
469
473
|
* await libp2p.hangUp(remotePeerId)
|
|
470
474
|
* ```
|
|
471
475
|
*/
|
|
472
|
-
hangUp: (peer: PeerId | Multiaddr) => Promise<void>;
|
|
476
|
+
hangUp: (peer: PeerId | Multiaddr, options?: AbortOptions) => Promise<void>;
|
|
473
477
|
/**
|
|
474
478
|
* Sets up [multistream-select routing](https://github.com/multiformats/multistream-select) of protocols to their application handlers. Whenever a stream is opened on one of the provided protocols, the handler will be called. `handle` must be called in order to register a handler and support for a given protocol. This also informs other peers of the protocols you support.
|
|
475
479
|
*
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACpF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAA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WAAW,CAAA;CACrB;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;KAC/B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACjJ,CAAA"}
|
|
@@ -32,9 +32,13 @@ export interface StreamMuxer extends Duplex<AsyncGenerator<Uint8Array>, Source<U
|
|
|
32
32
|
/**
|
|
33
33
|
* Close or abort all tracked streams and stop the muxer
|
|
34
34
|
*/
|
|
35
|
-
close: (
|
|
35
|
+
close: (options?: AbortOptions) => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Close or abort all tracked streams and stop the muxer
|
|
38
|
+
*/
|
|
39
|
+
abort: (err: Error) => void;
|
|
36
40
|
}
|
|
37
|
-
export interface StreamMuxerInit
|
|
41
|
+
export interface StreamMuxerInit {
|
|
38
42
|
/**
|
|
39
43
|
* A callback function invoked every time an incoming stream is opened
|
|
40
44
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stream-muxer/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,kBAAkB;IACj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;IAEhB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAA;IAC1B;;;OAGG;IACH,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAEtD;;OAEG;IACH,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAEhD;;OAEG;IACH,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAA;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAE3C;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAEtC;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { Uint8ArrayList } from 'uint8arraylist';
|
|
2
|
-
import type { Direction, Stream,
|
|
2
|
+
import type { Direction, ReadStatus, Stream, StreamStatus, StreamTimeline, WriteStatus } from '../connection/index.js';
|
|
3
|
+
import type { AbortOptions } from '../index.js';
|
|
3
4
|
import type { Source } from 'it-stream-types';
|
|
5
|
+
interface Logger {
|
|
6
|
+
(formatter: any, ...args: any[]): void;
|
|
7
|
+
error: (formatter: any, ...args: any[]) => void;
|
|
8
|
+
trace: (formatter: any, ...args: any[]) => void;
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
}
|
|
4
11
|
export interface AbstractStreamInit {
|
|
5
12
|
/**
|
|
6
13
|
* A unique identifier for this stream
|
|
@@ -11,10 +18,9 @@ export interface AbstractStreamInit {
|
|
|
11
18
|
*/
|
|
12
19
|
direction: Direction;
|
|
13
20
|
/**
|
|
14
|
-
*
|
|
15
|
-
* chunked and sent in multiple data messages
|
|
21
|
+
* A Logger implementation used to log stream-specific information
|
|
16
22
|
*/
|
|
17
|
-
|
|
23
|
+
log: Logger;
|
|
18
24
|
/**
|
|
19
25
|
* User specific stream metadata
|
|
20
26
|
*/
|
|
@@ -23,31 +29,83 @@ export interface AbstractStreamInit {
|
|
|
23
29
|
* Invoked when the stream ends
|
|
24
30
|
*/
|
|
25
31
|
onEnd?: (err?: Error | undefined) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Invoked when the readable end of the stream is closed
|
|
34
|
+
*/
|
|
35
|
+
onCloseRead?: () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Invoked when the writable end of the stream is closed
|
|
38
|
+
*/
|
|
39
|
+
onCloseWrite?: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Invoked when the the stream has been reset by the remote
|
|
42
|
+
*/
|
|
43
|
+
onReset?: () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Invoked when the the stream has errored
|
|
46
|
+
*/
|
|
47
|
+
onAbort?: (err: Error) => void;
|
|
48
|
+
/**
|
|
49
|
+
* How long to wait in ms for stream data to be written to the underlying
|
|
50
|
+
* connection when closing the writable end of the stream. (default: 500)
|
|
51
|
+
*/
|
|
52
|
+
closeTimeout?: number;
|
|
26
53
|
}
|
|
27
54
|
export declare abstract class AbstractStream implements Stream {
|
|
28
55
|
id: string;
|
|
29
|
-
|
|
56
|
+
direction: Direction;
|
|
57
|
+
timeline: StreamTimeline;
|
|
58
|
+
protocol?: string;
|
|
30
59
|
metadata: Record<string, unknown>;
|
|
31
60
|
source: AsyncGenerator<Uint8ArrayList, void, unknown>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
private
|
|
37
|
-
private sinkSunk;
|
|
61
|
+
status: StreamStatus;
|
|
62
|
+
readStatus: ReadStatus;
|
|
63
|
+
writeStatus: WriteStatus;
|
|
64
|
+
private readonly sinkController;
|
|
65
|
+
private readonly sinkEnd;
|
|
38
66
|
private endErr;
|
|
39
67
|
private readonly streamSource;
|
|
40
68
|
private readonly onEnd?;
|
|
41
|
-
private readonly
|
|
69
|
+
private readonly onCloseRead?;
|
|
70
|
+
private readonly onCloseWrite?;
|
|
71
|
+
private readonly onReset?;
|
|
72
|
+
private readonly onAbort?;
|
|
73
|
+
protected readonly log: Logger;
|
|
42
74
|
constructor(init: AbstractStreamInit);
|
|
75
|
+
sink(source: Source<Uint8ArrayList | Uint8Array>): Promise<void>;
|
|
43
76
|
protected onSourceEnd(err?: Error): void;
|
|
44
77
|
protected onSinkEnd(err?: Error): void;
|
|
45
|
-
close(): void
|
|
46
|
-
closeRead(): void
|
|
47
|
-
closeWrite(): void
|
|
78
|
+
close(options?: AbortOptions): Promise<void>;
|
|
79
|
+
closeRead(options?: AbortOptions): Promise<void>;
|
|
80
|
+
closeWrite(options?: AbortOptions): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Close immediately for reading and writing and send a reset message (local
|
|
83
|
+
* error)
|
|
84
|
+
*/
|
|
48
85
|
abort(err: Error): void;
|
|
86
|
+
/**
|
|
87
|
+
* Receive a reset message - close immediately for reading and writing (remote
|
|
88
|
+
* error)
|
|
89
|
+
*/
|
|
49
90
|
reset(): void;
|
|
50
|
-
|
|
91
|
+
_closeSinkAndSource(err?: Error): void;
|
|
92
|
+
_closeSink(err?: Error): void;
|
|
93
|
+
_closeSource(err?: Error): void;
|
|
94
|
+
/**
|
|
95
|
+
* The remote closed for writing so we should expect to receive no more
|
|
96
|
+
* messages
|
|
97
|
+
*/
|
|
98
|
+
remoteCloseWrite(): void;
|
|
99
|
+
/**
|
|
100
|
+
* The remote closed for reading so we should not send any more
|
|
101
|
+
* messages
|
|
102
|
+
*/
|
|
103
|
+
remoteCloseRead(): void;
|
|
104
|
+
/**
|
|
105
|
+
* The underlying muxer has closed, no more messages can be sent or will
|
|
106
|
+
* be received, close immediately to free up resources
|
|
107
|
+
*/
|
|
108
|
+
destroy(): void;
|
|
51
109
|
/**
|
|
52
110
|
* When an extending class reads data from it's implementation-specific source,
|
|
53
111
|
* call this method to allow the stream consumer to read the data.
|
|
@@ -62,24 +120,25 @@ export declare abstract class AbstractStream implements Stream {
|
|
|
62
120
|
* Send a message to the remote muxer informing them a new stream is being
|
|
63
121
|
* opened
|
|
64
122
|
*/
|
|
65
|
-
abstract sendNewStream(): void | Promise<void>;
|
|
123
|
+
abstract sendNewStream(options?: AbortOptions): void | Promise<void>;
|
|
66
124
|
/**
|
|
67
125
|
* Send a data message to the remote muxer
|
|
68
126
|
*/
|
|
69
|
-
abstract sendData(buf: Uint8ArrayList): void | Promise<void>;
|
|
127
|
+
abstract sendData(buf: Uint8ArrayList, options?: AbortOptions): void | Promise<void>;
|
|
70
128
|
/**
|
|
71
129
|
* Send a reset message to the remote muxer
|
|
72
130
|
*/
|
|
73
|
-
abstract sendReset(): void | Promise<void>;
|
|
131
|
+
abstract sendReset(options?: AbortOptions): void | Promise<void>;
|
|
74
132
|
/**
|
|
75
133
|
* Send a message to the remote muxer, informing them no more data messages
|
|
76
134
|
* will be sent by this end of the stream
|
|
77
135
|
*/
|
|
78
|
-
abstract sendCloseWrite(): void | Promise<void>;
|
|
136
|
+
abstract sendCloseWrite(options?: AbortOptions): void | Promise<void>;
|
|
79
137
|
/**
|
|
80
138
|
* Send a message to the remote muxer, informing them no more data messages
|
|
81
139
|
* will be read by this end of the stream
|
|
82
140
|
*/
|
|
83
|
-
abstract sendCloseRead(): void | Promise<void>;
|
|
141
|
+
abstract sendCloseRead(options?: AbortOptions): void | Promise<void>;
|
|
84
142
|
}
|
|
143
|
+
export {};
|
|
85
144
|
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/stream-muxer/stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/stream-muxer/stream.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA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