nerdbank-streams 2.10.22-alpha → 2.10.37-alpha
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/js/Channel.d.ts +9 -8
- package/js/Channel.js +21 -14
- package/js/Channel.js.map +1 -1
- package/js/ControlCode.d.ts +6 -6
- package/js/ControlCode.js +6 -6
- package/js/ControlCode.js.map +1 -1
- package/js/Deferred.js.map +1 -1
- package/js/FrameHeader.d.ts +2 -2
- package/js/FrameHeader.js +2 -2
- package/js/FrameHeader.js.map +1 -1
- package/js/FullDuplexStream.d.ts +1 -1
- package/js/FullDuplexStream.js +2 -0
- package/js/FullDuplexStream.js.map +1 -1
- package/js/MultiplexingStream.d.ts +19 -19
- package/js/MultiplexingStream.js +67 -63
- package/js/MultiplexingStream.js.map +1 -1
- package/js/MultiplexingStreamFormatters.d.ts +9 -7
- package/js/MultiplexingStreamFormatters.js +44 -20
- package/js/MultiplexingStreamFormatters.js.map +1 -1
- package/js/MultiplexingStreamOptions.d.ts +1 -1
- package/js/QualifiedChannelId.js +10 -4
- package/js/QualifiedChannelId.js.map +1 -1
- package/js/Utilities.d.ts +3 -3
- package/js/Utilities.js +10 -10
- package/js/Utilities.js.map +1 -1
- package/js/index.d.ts +8 -8
- package/js/index.js.map +1 -1
- package/package.json +16 -6
- package/src/AcceptanceParameters.ts +2 -2
- package/src/Channel.ts +279 -277
- package/src/ChannelOptions.ts +2 -2
- package/src/ControlCode.ts +25 -25
- package/src/Deferred.ts +61 -61
- package/src/FrameHeader.ts +35 -35
- package/src/FullDuplexStream.ts +25 -23
- package/src/IChannelOfferEventArgs.ts +12 -12
- package/src/IDisposableObservable.ts +2 -2
- package/src/MultiplexingStream.ts +731 -727
- package/src/MultiplexingStreamFormatters.ts +355 -332
- package/src/MultiplexingStreamOptions.ts +16 -16
- package/src/OfferParameters.ts +4 -4
- package/src/QualifiedChannelId.ts +27 -21
- package/src/Utilities.ts +159 -162
- package/src/index.ts +8 -8
package/js/Channel.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { QualifiedChannelId } from
|
|
2
|
+
import { AcceptanceParameters } from './AcceptanceParameters';
|
|
3
|
+
import { ChannelOptions } from './ChannelOptions';
|
|
4
|
+
import { IDisposableObservable } from './IDisposableObservable';
|
|
5
|
+
import { MultiplexingStreamClass } from './MultiplexingStream';
|
|
6
|
+
import { OfferParameters } from './OfferParameters';
|
|
7
|
+
import { QualifiedChannelId } from './QualifiedChannelId';
|
|
8
8
|
export declare abstract class Channel implements IDisposableObservable {
|
|
9
9
|
/**
|
|
10
10
|
* The id of the channel.
|
|
@@ -35,8 +35,9 @@ export declare abstract class Channel implements IDisposableObservable {
|
|
|
35
35
|
get isDisposed(): boolean;
|
|
36
36
|
/**
|
|
37
37
|
* Closes this channel.
|
|
38
|
+
* @param error An optional error to send to the remote side, if this multiplexing stream is using protocol versions >= 2.
|
|
38
39
|
*/
|
|
39
|
-
dispose(): void;
|
|
40
|
+
dispose(error?: Error | null): void;
|
|
40
41
|
}
|
|
41
42
|
export declare class ChannelClass extends Channel {
|
|
42
43
|
readonly name: string;
|
|
@@ -64,6 +65,6 @@ export declare class ChannelClass extends Channel {
|
|
|
64
65
|
onAccepted(acceptanceParameter: AcceptanceParameters): boolean;
|
|
65
66
|
onContent(buffer: Buffer | null): void;
|
|
66
67
|
onContentProcessed(bytesProcessed: number): void;
|
|
67
|
-
dispose(): void;
|
|
68
|
+
dispose(error?: Error | null): void;
|
|
68
69
|
private onTransmittingBytes;
|
|
69
70
|
}
|
package/js/Channel.js
CHANGED
|
@@ -29,8 +29,9 @@ class Channel {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Closes this channel.
|
|
32
|
+
* @param error An optional error to send to the remote side, if this multiplexing stream is using protocol versions >= 2.
|
|
32
33
|
*/
|
|
33
|
-
dispose() {
|
|
34
|
+
dispose(error) {
|
|
34
35
|
// The interesting stuff is in the derived class.
|
|
35
36
|
this._isDisposed = true;
|
|
36
37
|
}
|
|
@@ -61,7 +62,7 @@ class ChannelClass extends Channel {
|
|
|
61
62
|
this.localWindowSize = offerParameters.remoteWindowSize;
|
|
62
63
|
break;
|
|
63
64
|
default:
|
|
64
|
-
throw new Error(
|
|
65
|
+
throw new Error('Channel source not recognized.');
|
|
65
66
|
}
|
|
66
67
|
this._multiplexingStream = multiplexingStream;
|
|
67
68
|
this.remoteWindowHasCapacity = new Deferred_1.Deferred();
|
|
@@ -80,12 +81,12 @@ class ChannelClass extends Channel {
|
|
|
80
81
|
if (self._multiplexingStream.backpressureSupportEnabled) {
|
|
81
82
|
await self.remoteWindowHasCapacity.promise;
|
|
82
83
|
if (!self.remoteWindowSize) {
|
|
83
|
-
throw new Error(
|
|
84
|
+
throw new Error('Remote window size unknown.');
|
|
84
85
|
}
|
|
85
86
|
bytesTransmitted = Math.min(self.remoteWindowSize - self.remoteWindowFilled, bytesTransmitted);
|
|
86
87
|
}
|
|
87
88
|
self.onTransmittingBytes(bytesTransmitted);
|
|
88
|
-
const header = new FrameHeader_1.FrameHeader(ControlCode_1.ControlCode.
|
|
89
|
+
const header = new FrameHeader_1.FrameHeader(ControlCode_1.ControlCode.content, id);
|
|
89
90
|
await multiplexingStream.sendFrameAsync(header, payload.slice(0, bytesTransmitted));
|
|
90
91
|
payload = payload.slice(bytesTransmitted);
|
|
91
92
|
}
|
|
@@ -131,9 +132,10 @@ class ChannelClass extends Channel {
|
|
|
131
132
|
}
|
|
132
133
|
tryAcceptOffer(options) {
|
|
133
134
|
if (this._acceptance.resolve()) {
|
|
134
|
-
this.localWindowSize =
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
this.localWindowSize =
|
|
136
|
+
(options === null || options === void 0 ? void 0 : options.channelReceivingWindowSize) !== undefined
|
|
137
|
+
? Math.max(this._multiplexingStream.defaultChannelReceivingWindowSize, options === null || options === void 0 ? void 0 : options.channelReceivingWindowSize)
|
|
138
|
+
: this._multiplexingStream.defaultChannelReceivingWindowSize;
|
|
137
139
|
return true;
|
|
138
140
|
}
|
|
139
141
|
return false;
|
|
@@ -167,10 +169,10 @@ class ChannelClass extends Channel {
|
|
|
167
169
|
}
|
|
168
170
|
onContentProcessed(bytesProcessed) {
|
|
169
171
|
if (bytesProcessed < 0) {
|
|
170
|
-
throw new Error(
|
|
172
|
+
throw new Error('A non-negative number is required.');
|
|
171
173
|
}
|
|
172
174
|
if (bytesProcessed > this.remoteWindowFilled) {
|
|
173
|
-
throw new Error(
|
|
175
|
+
throw new Error('More bytes processed than we thought were in the window.');
|
|
174
176
|
}
|
|
175
177
|
if (this.remoteWindowSize === undefined) {
|
|
176
178
|
throw new Error("Unexpected content processed message given we don't know the remote window size.");
|
|
@@ -180,10 +182,10 @@ class ChannelClass extends Channel {
|
|
|
180
182
|
this.remoteWindowHasCapacity.resolve();
|
|
181
183
|
}
|
|
182
184
|
}
|
|
183
|
-
dispose() {
|
|
185
|
+
dispose(error) {
|
|
184
186
|
if (!this.isDisposed) {
|
|
185
187
|
super.dispose();
|
|
186
|
-
if (this._acceptance.reject(new cancellationtoken_1.default.CancellationError(
|
|
188
|
+
if (this._acceptance.reject(new cancellationtoken_1.default.CancellationError('disposed'))) {
|
|
187
189
|
// Don't crash node due to an unnoticed rejection when dispose was explicitly called.
|
|
188
190
|
caught(this.acceptance);
|
|
189
191
|
}
|
|
@@ -191,15 +193,20 @@ class ChannelClass extends Channel {
|
|
|
191
193
|
// The completion will propagate when it's ready to.
|
|
192
194
|
this._duplex.end();
|
|
193
195
|
this._duplex.push(null);
|
|
194
|
-
|
|
196
|
+
if (error) {
|
|
197
|
+
this._completion.reject(error);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
this._completion.resolve();
|
|
201
|
+
}
|
|
195
202
|
// Send the notification, but we can't await the result of this.
|
|
196
|
-
caught(this._multiplexingStream.onChannelDisposed(this));
|
|
203
|
+
caught(this._multiplexingStream.onChannelDisposed(this, error !== null && error !== void 0 ? error : null));
|
|
197
204
|
}
|
|
198
205
|
}
|
|
199
206
|
onTransmittingBytes(transmittedBytes) {
|
|
200
207
|
if (this._multiplexingStream.backpressureSupportEnabled) {
|
|
201
208
|
if (transmittedBytes < 0) {
|
|
202
|
-
throw new Error(
|
|
209
|
+
throw new Error('Negative byte count transmitted.');
|
|
203
210
|
}
|
|
204
211
|
this.remoteWindowFilled += transmittedBytes;
|
|
205
212
|
if (this.remoteWindowFilled === this.remoteWindowSize) {
|
package/js/Channel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Channel.js","sourceRoot":"","sources":["../src/Channel.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Channel.js","sourceRoot":"","sources":["../src/Channel.ts"],"names":[],"mappings":";;;AAAA,yDAAiD;AACjD,mCAA+B;AAG/B,+CAA2C;AAC3C,yCAAqC;AACrC,+CAA2C;AAE3C,6DAAkF;AAElF,6DAAwE;AACxE,iCAAiC;AAEjC,MAAsB,OAAO;IA+B5B,YAAY,EAAsB;QAF1B,gBAAW,GAAY,KAAK,CAAA;QAGnC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;IACtB,CAAC;IAhCD;;;OAGG;IACH,IAAW,EAAE;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC,EAAE,CAAA;IAC3B,CAAC;IA4BD;;OAEG;IACH,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,WAAW,CAAA;IACxB,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,KAAoB;QAClC,iDAAiD;QACjD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;IACxB,CAAC;CACD;AAlDD,0BAkDC;AAED,gDAAgD;AAChD,MAAa,YAAa,SAAQ,OAAO;IAkBxC,YAAY,kBAA2C,EAAE,EAAsB,EAAE,eAAgC;QAChH,K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10
|
* A channel proposal has been accepted.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
offerAccepted = 1,
|
|
13
13
|
/**
|
|
14
14
|
* The payload of the frame is a payload intended for channel consumption.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
content = 2,
|
|
17
17
|
/**
|
|
18
18
|
* Sent after all bytes have been transmitted on a given channel. Either or both sides may send this.
|
|
19
19
|
* A channel may be automatically closed when each side has both transmitted and received this message.
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
contentWritingCompleted = 3,
|
|
22
22
|
/**
|
|
23
23
|
* Sent when a channel is closed, an incoming offer is rejected, or an outgoing offer is canceled.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
channelTerminated = 4,
|
|
26
26
|
/**
|
|
27
27
|
* Sent when a channel has finished processing data received from the remote party, allowing them to send more data.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
contentProcessed = 5
|
|
30
30
|
}
|
package/js/ControlCode.js
CHANGED
|
@@ -9,27 +9,27 @@ var ControlCode;
|
|
|
9
9
|
/**
|
|
10
10
|
* A channel is proposed to the remote party.
|
|
11
11
|
*/
|
|
12
|
-
ControlCode[ControlCode["
|
|
12
|
+
ControlCode[ControlCode["offer"] = 0] = "offer";
|
|
13
13
|
/**
|
|
14
14
|
* A channel proposal has been accepted.
|
|
15
15
|
*/
|
|
16
|
-
ControlCode[ControlCode["
|
|
16
|
+
ControlCode[ControlCode["offerAccepted"] = 1] = "offerAccepted";
|
|
17
17
|
/**
|
|
18
18
|
* The payload of the frame is a payload intended for channel consumption.
|
|
19
19
|
*/
|
|
20
|
-
ControlCode[ControlCode["
|
|
20
|
+
ControlCode[ControlCode["content"] = 2] = "content";
|
|
21
21
|
/**
|
|
22
22
|
* Sent after all bytes have been transmitted on a given channel. Either or both sides may send this.
|
|
23
23
|
* A channel may be automatically closed when each side has both transmitted and received this message.
|
|
24
24
|
*/
|
|
25
|
-
ControlCode[ControlCode["
|
|
25
|
+
ControlCode[ControlCode["contentWritingCompleted"] = 3] = "contentWritingCompleted";
|
|
26
26
|
/**
|
|
27
27
|
* Sent when a channel is closed, an incoming offer is rejected, or an outgoing offer is canceled.
|
|
28
28
|
*/
|
|
29
|
-
ControlCode[ControlCode["
|
|
29
|
+
ControlCode[ControlCode["channelTerminated"] = 4] = "channelTerminated";
|
|
30
30
|
/**
|
|
31
31
|
* Sent when a channel has finished processing data received from the remote party, allowing them to send more data.
|
|
32
32
|
*/
|
|
33
|
-
ControlCode[ControlCode["
|
|
33
|
+
ControlCode[ControlCode["contentProcessed"] = 5] = "contentProcessed";
|
|
34
34
|
})(ControlCode = exports.ControlCode || (exports.ControlCode = {}));
|
|
35
35
|
//# sourceMappingURL=ControlCode.js.map
|
package/js/ControlCode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControlCode.js","sourceRoot":"","sources":["../src/ControlCode.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,WA+BX;AA/BD,WAAY,WAAW;
|
|
1
|
+
{"version":3,"file":"ControlCode.js","sourceRoot":"","sources":["../src/ControlCode.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,WA+BX;AA/BD,WAAY,WAAW;IACtB;;OAEG;IACH,+CAAK,CAAA;IAEL;;OAEG;IACH,+DAAa,CAAA;IAEb;;OAEG;IACH,mDAAO,CAAA;IAEP;;;OAGG;IACH,mFAAuB,CAAA;IAEvB;;OAEG;IACH,uEAAiB,CAAA;IAEjB;;OAEG;IACH,qEAAgB,CAAA;AACjB,CAAC,EA/BW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA+BtB"}
|
package/js/Deferred.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Deferred.js","sourceRoot":"","sources":["../src/Deferred.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,QAAQ;
|
|
1
|
+
{"version":3,"file":"Deferred.js","sourceRoot":"","sources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uEC"}
|
package/js/FrameHeader.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ControlCode } from
|
|
2
|
-
import { QualifiedChannelId } from
|
|
1
|
+
import { ControlCode } from './ControlCode';
|
|
2
|
+
import { QualifiedChannelId } from './QualifiedChannelId';
|
|
3
3
|
export declare class FrameHeader {
|
|
4
4
|
readonly code: ControlCode;
|
|
5
5
|
private _channel?;
|
package/js/FrameHeader.js
CHANGED
|
@@ -11,7 +11,7 @@ class FrameHeader {
|
|
|
11
11
|
constructor(code, channel) {
|
|
12
12
|
this.code = code;
|
|
13
13
|
if (channel) {
|
|
14
|
-
(0, Utilities_1.requireInteger)(
|
|
14
|
+
(0, Utilities_1.requireInteger)('channelId', channel.id, 4, 'signed');
|
|
15
15
|
}
|
|
16
16
|
this.code = code;
|
|
17
17
|
this._channel = channel;
|
|
@@ -27,7 +27,7 @@ class FrameHeader {
|
|
|
27
27
|
if (this.channel) {
|
|
28
28
|
return this.channel;
|
|
29
29
|
}
|
|
30
|
-
throw new Error(
|
|
30
|
+
throw new Error('Expected channel not present in frame header.');
|
|
31
31
|
}
|
|
32
32
|
/** Changes the channel.source property to reflect the opposite perspective (i.e. remote and local values switch). */
|
|
33
33
|
flipChannelPerspective() {
|
package/js/FrameHeader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrameHeader.js","sourceRoot":"","sources":["../src/FrameHeader.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"FrameHeader.js","sourceRoot":"","sources":["../src/FrameHeader.ts"],"names":[],"mappings":";;;AACA,2CAA4C;AAG5C,MAAa,WAAW;IAGvB;;;;OAIG;IACH,YAA4B,IAAiB,EAAE,OAA4B;QAA/C,SAAI,GAAJ,IAAI,CAAa;QAC5C,IAAI,OAAO,EAAE;YACZ,IAAA,0BAAc,EAAC,WAAW,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAA;SACpD;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,sEAAsE;IACtE,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,QAAQ,CAAA;IACrB,CAAC;IAED;;OAEG;IACH,IAAW,eAAe;QACzB,IAAI,IAAI,CAAC,OAAO,EAAE;YACjB,OAAO,IAAI,CAAC,OAAO,CAAA;SACnB;QAED,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;IACjE,CAAC;IAED,qHAAqH;IAC9G,sBAAsB;QAC5B,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,QAAQ,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAA;SAC3E;IACF,CAAC;CACD;AAvCD,kCAuCC"}
|
package/js/FullDuplexStream.d.ts
CHANGED
package/js/FullDuplexStream.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FullDuplexStream = void 0;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
5
|
class FullDuplexStream {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
6
7
|
static CreatePair() {
|
|
7
8
|
const pass1 = new stream_1.PassThrough();
|
|
8
9
|
const pass2 = new stream_1.PassThrough();
|
|
@@ -11,6 +12,7 @@ class FullDuplexStream {
|
|
|
11
12
|
second: FullDuplexStream.Splice(pass2, pass1),
|
|
12
13
|
};
|
|
13
14
|
}
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
14
16
|
static Splice(readable, writable) {
|
|
15
17
|
const duplex = new stream_1.Duplex({
|
|
16
18
|
write(chunk, encoding, callback) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FullDuplexStream.js","sourceRoot":"","sources":["../src/FullDuplexStream.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"FullDuplexStream.js","sourceRoot":"","sources":["../src/FullDuplexStream.ts"],"names":[],"mappings":";;;AAAA,mCAA4C;AAE5C,MAAa,gBAAgB;IAC5B,gEAAgE;IACzD,MAAM,CAAC,UAAU;QACvB,MAAM,KAAK,GAAG,IAAI,oBAAW,EAAE,CAAA;QAC/B,MAAM,KAAK,GAAG,IAAI,oBAAW,EAAE,CAAA;QAC/B,OAAO;YACN,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC;YAC5C,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC;SAC7C,CAAA;IACF,CAAC;IAED,gEAAgE;IACzD,MAAM,CAAC,MAAM,CAAC,QAA+B,EAAE,QAA+B;QACpF,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;YACzB,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ;gBAC9B,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;YAC1C,CAAC;YAED,KAAK,CAAC,QAAQ;gBACb,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YACvB,CAAC;SACD,CAAC,CAAA;QAEF,+DAA+D;QAC/D,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC1C,MAAM,CAAC,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAQ,CAAA;QAE7C,OAAO,MAAM,CAAA;IACd,CAAC;CACD;AA7BD,4CA6BC"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import CancellationToken from
|
|
3
|
-
import { Channel, ChannelClass } from
|
|
4
|
-
import { ChannelOptions } from
|
|
5
|
-
import { ControlCode } from
|
|
6
|
-
import { Deferred } from
|
|
7
|
-
import { FrameHeader } from
|
|
8
|
-
import { IChannelOfferEventArgs } from
|
|
9
|
-
import { IDisposableObservable } from
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import { QualifiedChannelId } from
|
|
2
|
+
import CancellationToken from 'cancellationtoken';
|
|
3
|
+
import { Channel, ChannelClass } from './Channel';
|
|
4
|
+
import { ChannelOptions } from './ChannelOptions';
|
|
5
|
+
import { ControlCode } from './ControlCode';
|
|
6
|
+
import { Deferred } from './Deferred';
|
|
7
|
+
import { FrameHeader } from './FrameHeader';
|
|
8
|
+
import { IChannelOfferEventArgs } from './IChannelOfferEventArgs';
|
|
9
|
+
import { IDisposableObservable } from './IDisposableObservable';
|
|
10
|
+
import { MultiplexingStreamFormatter } from './MultiplexingStreamFormatters';
|
|
11
|
+
import './MultiplexingStreamOptions';
|
|
12
|
+
import { MultiplexingStreamOptions } from './MultiplexingStreamOptions';
|
|
13
|
+
import { QualifiedChannelId } from './QualifiedChannelId';
|
|
14
14
|
export declare abstract class MultiplexingStream implements IDisposableObservable {
|
|
15
|
+
protected readonly formatter: MultiplexingStreamFormatter;
|
|
15
16
|
private readonly isOdd;
|
|
16
17
|
/**
|
|
17
18
|
* The maximum length of a frame's payload.
|
|
@@ -20,7 +21,6 @@ export declare abstract class MultiplexingStream implements IDisposableObservabl
|
|
|
20
21
|
private static readonly recommendedDefaultChannelReceivingWindowSize;
|
|
21
22
|
/** The default window size used for new channels that do not specify a value for ChannelOptions.ChannelReceivingWindowSize. */
|
|
22
23
|
readonly defaultChannelReceivingWindowSize: number;
|
|
23
|
-
protected readonly formatter: MultiplexingStreamFormatter;
|
|
24
24
|
protected get disposalToken(): CancellationToken;
|
|
25
25
|
/**
|
|
26
26
|
* Gets a promise that is resolved or rejected based on how this stream is disposed or fails.
|
|
@@ -98,7 +98,7 @@ export declare abstract class MultiplexingStream implements IDisposableObservabl
|
|
|
98
98
|
protected readonly protocolMajorVersion: number;
|
|
99
99
|
private readonly eventEmitter;
|
|
100
100
|
private disposalTokenSource;
|
|
101
|
-
protected constructor(
|
|
101
|
+
protected constructor(formatter: MultiplexingStreamFormatter, isOdd: boolean | undefined, options: MultiplexingStreamOptions);
|
|
102
102
|
/**
|
|
103
103
|
* Creates an anonymous channel that may be accepted by <see cref="AcceptChannel(int, ChannelOptions)"/>.
|
|
104
104
|
* Its existance must be communicated by other means (typically another, existing channel) to encourage acceptance.
|
|
@@ -151,9 +151,9 @@ export declare abstract class MultiplexingStream implements IDisposableObservabl
|
|
|
151
151
|
* Disposes the stream.
|
|
152
152
|
*/
|
|
153
153
|
dispose(): void;
|
|
154
|
-
on(event:
|
|
155
|
-
off(event:
|
|
156
|
-
once(event:
|
|
154
|
+
on(event: 'channelOffered', listener: (args: IChannelOfferEventArgs) => void): void;
|
|
155
|
+
off(event: 'channelOffered', listener: (args: IChannelOfferEventArgs) => void): void;
|
|
156
|
+
once(event: 'channelOffered', listener: (args: IChannelOfferEventArgs) => void): void;
|
|
157
157
|
protected raiseChannelOffered(id: number, name: string, isAccepted: boolean): void;
|
|
158
158
|
protected abstract sendFrameAsync(header: FrameHeader, payload: Buffer, cancellationToken: CancellationToken): Promise<void>;
|
|
159
159
|
protected abstract sendFrame(code: ControlCode, channelId: QualifiedChannelId): Promise<void>;
|
|
@@ -190,7 +190,7 @@ export declare abstract class MultiplexingStream implements IDisposableObservabl
|
|
|
190
190
|
export declare class MultiplexingStreamClass extends MultiplexingStream {
|
|
191
191
|
protected lastOfferedChannelId: number;
|
|
192
192
|
private readonly sendingSemaphore;
|
|
193
|
-
constructor(
|
|
193
|
+
constructor(formatter: MultiplexingStreamFormatter, isOdd: boolean | undefined, options: MultiplexingStreamOptions);
|
|
194
194
|
get backpressureSupportEnabled(): boolean;
|
|
195
195
|
sendFrameAsync(header: FrameHeader, payload?: Buffer, cancellationToken?: CancellationToken): Promise<void>;
|
|
196
196
|
/**
|
|
@@ -202,7 +202,7 @@ export declare class MultiplexingStreamClass extends MultiplexingStream {
|
|
|
202
202
|
*/
|
|
203
203
|
sendFrame(code: ControlCode, channelId: QualifiedChannelId): Promise<void>;
|
|
204
204
|
onChannelWritingCompleted(channel: ChannelClass): void;
|
|
205
|
-
onChannelDisposed(channel: ChannelClass): Promise<void>;
|
|
205
|
+
onChannelDisposed(channel: ChannelClass, error: Error | null): Promise<void>;
|
|
206
206
|
localContentExamined(channel: ChannelClass, bytesConsumed: number): void;
|
|
207
207
|
private readFromStream;
|
|
208
208
|
private onOffer;
|