@fails-components/webtransport 0.1.7 → 0.2.1
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/CMakeLists.txt +2 -2
- package/build.js +4 -4
- package/dist/lib/dom.d.ts +2 -2
- package/dist/lib/dom.d.ts.map +1 -1
- package/dist/lib/session.d.ts +13 -3
- package/dist/lib/session.d.ts.map +1 -1
- package/dist/lib/stream.d.ts +9 -1
- package/dist/lib/stream.d.ts.map +1 -1
- package/dist/lib/types.d.ts +11 -2
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/test/bidirectional-streams.spec.d.ts.map +1 -1
- package/dist/test/datagrams.spec.d.ts.map +1 -1
- package/dist/test/fixtures/p-timeout.d.ts +8 -0
- package/dist/test/fixtures/p-timeout.d.ts.map +1 -0
- package/dist/test/fixtures/read-stream.d.ts.map +1 -1
- package/dist/test/unidirectional-streams.spec.d.ts.map +1 -1
- package/lib/dom.ts +2 -2
- package/lib/session.js +44 -3
- package/lib/stream.js +115 -11
- package/lib/types.ts +12 -2
- package/package.json +4 -3
- package/platform/base/strings/utf_ostream_operators.h +5 -0
- package/src/http3clientsession.cc +51 -42
- package/src/http3clientsession.h +41 -37
- package/src/http3eventloop.cc +46 -13
- package/src/http3eventloop.h +8 -2
- package/src/http3server.cc +1 -1
- package/src/http3serversession.h +8 -7
- package/src/http3wtsessionvisitor.h +19 -0
- package/src/http3wtstreamvisitor.cc +35 -8
- package/src/http3wtstreamvisitor.h +81 -3
- package/test/bidirectional-streams.spec.js +15 -7
- package/test/datagrams.spec.js +30 -20
- package/test/fixtures/p-timeout.js +33 -0
- package/test/fixtures/read-stream.js +4 -1
- package/test/unidirectional-streams.spec.js +23 -15
package/CMakeLists.txt
CHANGED
|
@@ -108,12 +108,12 @@ platform/quiche_platform_impl/quiche_flag_utils_impl.h
|
|
|
108
108
|
third_party/googleurl/base/debug/crash_logging.cc
|
|
109
109
|
third_party/googleurl/base/debug/crash_logging.h
|
|
110
110
|
third_party/googleurl/base/strings/string_util_constants.cc
|
|
111
|
-
third_party/googleurl/base/strings/string_piece.cc
|
|
112
|
-
third_party/googleurl/base/strings/string_piece.h
|
|
113
111
|
third_party/googleurl/base/strings/string_util.cc
|
|
114
112
|
third_party/googleurl/base/strings/string_util.h
|
|
115
113
|
third_party/googleurl/base/strings/utf_string_conversions.cc
|
|
116
114
|
third_party/googleurl/base/strings/utf_string_conversions.h
|
|
115
|
+
#third_party/googleurl/base/strings/utf_ostream_operators.cc
|
|
116
|
+
#third_party/googleurl/base/strings/utf_ostream_operators.h
|
|
117
117
|
third_party/googleurl/url/url_canon.cc
|
|
118
118
|
third_party/googleurl/url/url_canon_internal.cc
|
|
119
119
|
third_party/googleurl/url/url_canon_path.cc
|
package/build.js
CHANGED
|
@@ -83,8 +83,7 @@ const extractthirdparty = async () => {
|
|
|
83
83
|
'third_party/zlib',
|
|
84
84
|
'third_party/googleurl',
|
|
85
85
|
'third_party/libevent',
|
|
86
|
-
'third_party/protobuf'
|
|
87
|
-
'third_party/icu'
|
|
86
|
+
'third_party/protobuf'
|
|
88
87
|
]
|
|
89
88
|
for (let mod in submodules) {
|
|
90
89
|
const sub = submodules[mod]
|
|
@@ -255,11 +254,12 @@ if (argv.length > 2) {
|
|
|
255
254
|
try {
|
|
256
255
|
// if we do not succeed, we have to build it ourselves
|
|
257
256
|
await extractthirdparty()
|
|
257
|
+
await execbuild(['build', ...platformargs])
|
|
258
258
|
} catch (error) {
|
|
259
259
|
console.error('Building binary failed: ', error)
|
|
260
|
+
process.exit(1)
|
|
260
261
|
}
|
|
261
|
-
}
|
|
262
|
-
// eslint-disable-next-line no-fallthrough
|
|
262
|
+
} break
|
|
263
263
|
case 'build':
|
|
264
264
|
try {
|
|
265
265
|
await execbuild(['build', ...platformargs])
|
package/dist/lib/dom.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ export interface WebTransportDatagramDuplexStream {
|
|
|
27
27
|
writable: WritableStream<Uint8Array>;
|
|
28
28
|
}
|
|
29
29
|
export interface WebTransportBidirectionalStream {
|
|
30
|
-
readonly readable:
|
|
31
|
-
readonly writable:
|
|
30
|
+
readonly readable: WebTransportReceiveStream;
|
|
31
|
+
readonly writable: WebTransportSendStream;
|
|
32
32
|
}
|
|
33
33
|
export interface WebTransportSendStreamStats {
|
|
34
34
|
timestamp: number;
|
package/dist/lib/dom.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../lib/dom.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,yBAAyB,EAAE,MAAM,CAAA;IACjC,yBAAyB,EAAE,MAAM,CAAA;IACjC,aAAa,EAAE,MAAM,CAAA;IACrB,eAAe,EAAE,MAAM,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,yBAAyB,CAAA;CACrC;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;IACpC,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;CAMrC;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../lib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,CAAA;CAClF;AAED,oBAAY,2BAA2B,GAAG,SAAS,GAAG,eAAe,GAAG,qBAAqB,CAAA;AAC7F,oBAAY,6BAA6B,GAAG,SAAS,GAAG,YAAY,GAAG,aAAa,CAAC"}
|
package/dist/lib/session.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @typedef {import('./types').SessionCloseEvent} SessionCloseEvent
|
|
7
7
|
* @typedef {import('./types').DatagramReceivedEvent} DatagramReceivedEvent
|
|
8
8
|
* @typedef {import('./types').DatagramSendEvent} DatagramSendEvent
|
|
9
|
+
* @typedef {import('./types').GoawayReceivedEvent} GoawayReceivedEvent
|
|
9
10
|
* @typedef {import('./types').NewStreamEvent} NewStreamEvent
|
|
10
11
|
*
|
|
11
12
|
* @typedef {import('./dom').WebTransportCloseInfo} WebTransportCloseInfo
|
|
@@ -33,9 +34,9 @@
|
|
|
33
34
|
*/
|
|
34
35
|
export class Http3WTSession implements WebTransportSessionEventHandler, WebTransportSession {
|
|
35
36
|
/**
|
|
36
|
-
* @param {SessionReadyEvent | SessionCloseEvent | DatagramReceivedEvent | DatagramSendEvent | NewStreamEvent} args
|
|
37
|
+
* @param {SessionReadyEvent | SessionCloseEvent | DatagramReceivedEvent | DatagramSendEvent | GoawayReceivedEvent | NewStreamEvent} args
|
|
37
38
|
*/
|
|
38
|
-
static callback(args: SessionReadyEvent | SessionCloseEvent | DatagramReceivedEvent | DatagramSendEvent | NewStreamEvent): void;
|
|
39
|
+
static callback(args: SessionReadyEvent | SessionCloseEvent | DatagramReceivedEvent | DatagramSendEvent | GoawayReceivedEvent | NewStreamEvent): void;
|
|
39
40
|
/**
|
|
40
41
|
* @param {object} args
|
|
41
42
|
* @param {import('./types').NativeHttp3WTSession} [args.object]
|
|
@@ -86,7 +87,7 @@ export class Http3WTSession implements WebTransportSessionEventHandler, WebTrans
|
|
|
86
87
|
writeDatagramProm: Array<Promise<void>>;
|
|
87
88
|
/** @type {WebTransportDatagramDuplexStream} */
|
|
88
89
|
datagrams: WebTransportDatagramDuplexStream;
|
|
89
|
-
incomDatagramController:
|
|
90
|
+
incomDatagramController: import("stream/web").ReadableByteStreamController;
|
|
90
91
|
outgoDatagramController: import("stream/web").WritableStreamDefaultController;
|
|
91
92
|
/** @type {Array<(stream: WebTransportBidirectionalStream) => void>} */
|
|
92
93
|
resolveBiDi: ((stream: WebTransportBidirectionalStream) => void)[];
|
|
@@ -130,6 +131,7 @@ export class Http3WTSession implements WebTransportSessionEventHandler, WebTrans
|
|
|
130
131
|
};
|
|
131
132
|
}>;
|
|
132
133
|
waitForDatagramsSend(): Promise<void>;
|
|
134
|
+
notifySessionDraining(): void;
|
|
133
135
|
/**
|
|
134
136
|
* @param {Http3WTStream} stream
|
|
135
137
|
*/
|
|
@@ -193,6 +195,10 @@ export class Http3WTSession implements WebTransportSessionEventHandler, WebTrans
|
|
|
193
195
|
* @param {DatagramSendEvent} args
|
|
194
196
|
*/
|
|
195
197
|
onDatagramSend(args: DatagramSendEvent): void;
|
|
198
|
+
/**
|
|
199
|
+
* @param {GoawayReceivedEvent} args
|
|
200
|
+
*/
|
|
201
|
+
onGoAwayReceived(args: GoawayReceivedEvent): void;
|
|
196
202
|
}
|
|
197
203
|
/**
|
|
198
204
|
* WebTransport session events
|
|
@@ -214,6 +220,10 @@ export type DatagramReceivedEvent = import('./types').DatagramReceivedEvent;
|
|
|
214
220
|
* WebTransport session events
|
|
215
221
|
*/
|
|
216
222
|
export type DatagramSendEvent = import('./types').DatagramSendEvent;
|
|
223
|
+
/**
|
|
224
|
+
* WebTransport session events
|
|
225
|
+
*/
|
|
226
|
+
export type GoawayReceivedEvent = import('./types').GoawayReceivedEvent;
|
|
217
227
|
/**
|
|
218
228
|
* WebTransport session events
|
|
219
229
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../lib/session.js"],"names":[],"mappings":";AAGA
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRo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,iBAAiB,QAW3B;IAED;;OAEG;IACH,uBAFW,mBAAmB,QAK7B;CA0CF;;;;8CA9eY,OAAO,SAAS,EAAE,+BAA+B;;;;gCACjD,OAAO,SAAS,EAAE,iBAAiB;;;;gCACnC,OAAO,SAAS,EAAE,iBAAiB;;;;oCACnC,OAAO,SAAS,EAAE,qBAAqB;;;;gCACvC,OAAO,SAAS,EAAE,iBAAiB;;;;kCACnC,OAAO,SAAS,EAAE,mBAAmB;;;;6BACrC,OAAO,SAAS,EAAE,cAAc;;;;oCAEhC,OAAO,OAAO,EAAE,qBAAqB;;;;8CACrC,OAAO,OAAO,EAAE,+BAA+B;;;;qCAC/C,OAAO,OAAO,EAAE,sBAAsB;;;;wCACtC,OAAO,OAAO,EAAE,yBAAyB;;;;+CACzC,OAAO,OAAO,EAAE,gCAAgC;;;;0CAChD,OAAO,OAAO,EAAE,2BAA2B;;;;4CAC3C,OAAO,OAAO,EAAE,6BAA6B;;;;gCAC7C,OAAO,OAAO,EAAE,iBAAiB;;;;mCAEjC,OAAO,SAAS,EAAE,oBAAoB;;;;kCAGtC,OAAO,SAAS,EAAE,mBAAmB;;;;0BAErC,OAAO,UAAU,EAAE,WAAW;;;;0BAC9B,OAAO,UAAU,EAAE,WAAW;;;;8CAE9B,OAAO,YAAY,EAAE,+BAA+B"}
|
package/dist/lib/stream.d.ts
CHANGED
|
@@ -43,15 +43,23 @@ export class Http3WTStream {
|
|
|
43
43
|
/** @type {Promise<void> | null} */
|
|
44
44
|
pendingoperation: Promise<void> | null;
|
|
45
45
|
pendingres: (() => void) | null;
|
|
46
|
+
/** @type {Promise<void> | null} */
|
|
47
|
+
pendingoperationRead: Promise<void> | null;
|
|
48
|
+
pendingresRead: ((value: void | PromiseLike<void>) => void) | null;
|
|
49
|
+
/** @type {Number} */
|
|
50
|
+
incomingbufferfilled: number;
|
|
51
|
+
/** @type {Number} */
|
|
52
|
+
incomingbufferreadpos: number;
|
|
46
53
|
/** @type {WebTransportReceiveStream} */
|
|
47
54
|
readable: WebTransportReceiveStream;
|
|
48
|
-
readableController:
|
|
55
|
+
readableController: import("stream/web").ReadableByteStreamController;
|
|
49
56
|
cancelres: (() => void) | null;
|
|
50
57
|
readableclosed: boolean;
|
|
51
58
|
/** @type {WebTransportSendStream} */
|
|
52
59
|
writable: WebTransportSendStream;
|
|
53
60
|
writableController: import("stream/web").WritableStreamDefaultController;
|
|
54
61
|
abortres: (() => void) | null;
|
|
62
|
+
drainBuffer(): void;
|
|
55
63
|
/**
|
|
56
64
|
* @param {import('./types').StreamRecvSignalEvent} args
|
|
57
65
|
* @returns {void}
|
package/dist/lib/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../lib/stream.js"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;GAcG;AAEH;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../lib/stream.js"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;GAcG;AAEH;IA6YE;;OAEG;IACH,sBAFW,qBAAqB,GAAG,eAAe,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,wBAAwB,QAsClH;IAnbD;;;;;;;OAOG;IACH;QANqC,MAAM,EAAhC,mBAAmB;QACE,SAAS,EAA9B,cAAc;QACD,SAAS,EAAtB,MAAM;QACQ,aAAa,EAA3B,OAAO;QACO,QAAQ,EAAtB,OAAO;OA+JjB;IA5JC,8CAAyB;IAEzB,8CAA+B;IAC/B,kBAA+B;IAC/B,uBAAuC;IACvC,kBAA6B;IAC7B,gBAAmB;IAEnB,mCAAmC;IACnC,kBADW,QAAQ,IAAI,CAAC,GAAG,IAAI,CACH;IAC5B,mBA8IkB,IAAI,SA9IA;IAEtB,mCAAmC;IACnC,sBADW,QAAQ,IAAI,CAAC,GAAG,IAAI,CACC;IAChC,mEAA0B;IAGxB,qBAAqB;IACrB,6BAA6B;IAC7B,qBAAqB;IACrB,8BAA8B;IAI9B,wCAAwC;IACxC,oCA+CC;IA1CK,sEAAoC;IA0BlC,kBA8FQ,IAAI,SA9FY;IAQ1B,wBAA0B;IAmBhC,qCAAqC;IACrC,iCAuDC;IApDK,yEAAoC;IA6ClC,iBAsBQ,IAAI,SAtBW;IA0BnC,oBAsDC;IAED;;;OAGG;IACH,yBAHW,OAAO,SAAS,EAAE,qBAAqB,GACrC,IAAI,CAwDhB;IAxBO,oCAA0B;IA0BlC;;;OAGG;IACH,mBAHW,eAAe,GACb,IAAI,CAqChB;IAED;;OAEG;IACH,oBAFW,gBAAgB,QAY1B;IAED;;OAEG;IACH,oBAFW,gBAAgB,QAe1B;IAED;;OAEG;IACH,4BAFW,wBAAwB,QAoClC;IAzBK,qCAA2B;CAmElC;;;;6CAncY,OAAO,SAAS,EAAE,8BAA8B;;;;oCAChD,OAAO,SAAS,EAAE,qBAAqB;;;;8BACvC,OAAO,SAAS,EAAE,eAAe;;;;+BACjC,OAAO,SAAS,EAAE,gBAAgB;;;;+BAClC,OAAO,SAAS,EAAE,gBAAgB;;;;uCAClC,OAAO,SAAS,EAAE,wBAAwB;;;;kCAE1C,OAAO,SAAS,EAAE,mBAAmB;;;;6BAErC,OAAO,WAAW,EAAE,cAAc;;;;8CAElC,OAAO,YAAY,EAAE,+BAA+B"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface NativeHttp3WTSession {
|
|
|
7
7
|
writeDatagram: (chunk: Uint8Array) => void;
|
|
8
8
|
orderUnidiStream: () => void;
|
|
9
9
|
orderBidiStream: () => void;
|
|
10
|
+
notifySessionDraining(): () => void;
|
|
10
11
|
close: (arg: {
|
|
11
12
|
code: number;
|
|
12
13
|
reason: string;
|
|
@@ -16,7 +17,9 @@ export interface NativeHttp3WTSession {
|
|
|
16
17
|
* Native Http3WTStream counterpart
|
|
17
18
|
*/
|
|
18
19
|
export interface NativeHttp3WTStream {
|
|
20
|
+
updateReadPos(bytesread: Number, pos: Number): unknown;
|
|
19
21
|
jsobj: WebTransportStreamEventHandler;
|
|
22
|
+
readbuffer: Uint8Array | undefined;
|
|
20
23
|
startReading: () => void;
|
|
21
24
|
stopReading: () => void;
|
|
22
25
|
stopSending: (code: number) => void;
|
|
@@ -35,8 +38,9 @@ export interface StreamRecvSignalEvent {
|
|
|
35
38
|
export interface StreamReadEvent {
|
|
36
39
|
object: NativeHttp3WTStream;
|
|
37
40
|
purpose: 'StreamRead';
|
|
38
|
-
|
|
41
|
+
buffergrow?: number;
|
|
39
42
|
fin?: boolean;
|
|
43
|
+
success?: boolean;
|
|
40
44
|
}
|
|
41
45
|
export interface StreamWriteEvent {
|
|
42
46
|
object: NativeHttp3WTStream;
|
|
@@ -77,6 +81,10 @@ export interface DatagramSendEvent {
|
|
|
77
81
|
object: NativeHttp3WTSession;
|
|
78
82
|
purpose: 'DatagramSend';
|
|
79
83
|
}
|
|
84
|
+
export interface GoawayReceivedEvent {
|
|
85
|
+
object: NativeHttp3WTSession;
|
|
86
|
+
purpose: 'GoawayReceived';
|
|
87
|
+
}
|
|
80
88
|
export interface NewStreamEvent {
|
|
81
89
|
object: NativeHttp3WTSession;
|
|
82
90
|
purpose: 'Http3WTStreamVisitor';
|
|
@@ -90,6 +98,7 @@ export interface WebTransportSessionEventHandler {
|
|
|
90
98
|
onClose: (evt: SessionCloseEvent) => void;
|
|
91
99
|
onDatagramReceived: (evt: DatagramReceivedEvent) => void;
|
|
92
100
|
onDatagramSend: (evt: DatagramSendEvent) => void;
|
|
101
|
+
onGoAwayReceived: (evt: GoawayReceivedEvent) => void;
|
|
93
102
|
onStream: (evt: NewStreamEvent) => void;
|
|
94
103
|
closeHook?: (() => void) | null;
|
|
95
104
|
}
|
|
@@ -150,7 +159,7 @@ export interface Deferred<T = unknown> {
|
|
|
150
159
|
resolve: (value?: T) => void;
|
|
151
160
|
reject: (reason?: any) => void;
|
|
152
161
|
}
|
|
153
|
-
export declare type WebTransportSessionState = 'connected' | 'closed' | 'failed';
|
|
162
|
+
export declare type WebTransportSessionState = 'connected' | 'draining' | 'closed' | 'failed';
|
|
154
163
|
export interface WebTransportSession extends WebTransport {
|
|
155
164
|
state: WebTransportSessionState;
|
|
156
165
|
}
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEzC;;GAEG;AACF,MAAM,WAAW,oBAAoB;IACpC,KAAK,EAAE,+BAA+B,CAAA;IACtC,aAAa,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IAC1C,gBAAgB,EAAE,MAAM,IAAI,CAAA;IAC5B,eAAe,EAAE,MAAM,IAAI,CAAA;IAE3B,KAAK,EAAE,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,8BAA8B,CAAA;IACrC,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,WAAW,EAAE,MAAM,IAAI,CAAA;IACvB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,UAAU,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAA;IACrC,WAAW,EAAE,MAAM,IAAI,CAAA;CACxB;AAED,oBAAY,OAAO,GAAG,kBAAkB,GAAG,YAAY,GAAG,aAAa,GAAG,aAAa,GAAG,qBAAqB,CAAA;AAC/G,oBAAY,OAAO,GAAG,aAAa,GAAG,aAAa,GAAG,aAAa,CAAA;AAEnE,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,mBAAmB,CAAA;IAC3B,OAAO,EAAE,kBAAk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AiB,KAAK,IAAI,CAAA;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,OAAO;IACnC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACnB,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;IAC5B,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;CAC/B;AAED,oBAAY,wBAAwB,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAErF,MAAM,WAAW,mBAAoB,SAAQ,YAAY;IACvD,KAAK,EAAE,wBAAwB,CAAA;CAChC;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bidirectional-streams.spec.d.ts","sourceRoot":"","sources":["../../test/bidirectional-streams.spec.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"bidirectional-streams.spec.d.ts","sourceRoot":"","sources":["../../test/bidirectional-streams.spec.js"],"names":[],"mappings":";;;0BAaa,OAAO,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datagrams.spec.d.ts","sourceRoot":"","sources":["../../test/datagrams.spec.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"datagrams.spec.d.ts","sourceRoot":"","sources":["../../test/datagrams.spec.js"],"names":[],"mappings":";;;0BAaa,OAAO,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"p-timeout.d.ts","sourceRoot":"","sources":["../../../test/fixtures/p-timeout.js"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,0DAHW,MAAM,cAkBhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-stream.d.ts","sourceRoot":"","sources":["../../../test/fixtures/read-stream.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,
|
|
1
|
+
{"version":3,"file":"read-stream.d.ts","sourceRoot":"","sources":["../../../test/fixtures/read-stream.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wGA8BC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unidirectional-streams.spec.d.ts","sourceRoot":"","sources":["../../test/unidirectional-streams.spec.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"unidirectional-streams.spec.d.ts","sourceRoot":"","sources":["../../test/unidirectional-streams.spec.js"],"names":[],"mappings":";;;0BAaa,OAAO,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC"}
|
package/lib/dom.ts
CHANGED
|
@@ -39,8 +39,8 @@ export interface WebTransportDatagramDuplexStream {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export interface WebTransportBidirectionalStream {
|
|
42
|
-
readonly readable:
|
|
43
|
-
readonly writable:
|
|
42
|
+
readonly readable: WebTransportReceiveStream
|
|
43
|
+
readonly writable: WebTransportSendStream
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export interface WebTransportSendStreamStats {
|
package/lib/session.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Http3WTStream } from './stream.js'
|
|
|
8
8
|
* @typedef {import('./types').SessionCloseEvent} SessionCloseEvent
|
|
9
9
|
* @typedef {import('./types').DatagramReceivedEvent} DatagramReceivedEvent
|
|
10
10
|
* @typedef {import('./types').DatagramSendEvent} DatagramSendEvent
|
|
11
|
+
* @typedef {import('./types').GoawayReceivedEvent} GoawayReceivedEvent
|
|
11
12
|
* @typedef {import('./types').NewStreamEvent} NewStreamEvent
|
|
12
13
|
*
|
|
13
14
|
* @typedef {import('./dom').WebTransportCloseInfo} WebTransportCloseInfo
|
|
@@ -102,12 +103,14 @@ export class Http3WTSession {
|
|
|
102
103
|
|
|
103
104
|
/** @type {WebTransportDatagramDuplexStream} */
|
|
104
105
|
this.datagrams = {
|
|
106
|
+
/** @type {ReadableStream<Uint8Array>} */
|
|
105
107
|
readable: new ReadableStream({
|
|
106
108
|
start: (
|
|
107
|
-
/** @type {
|
|
109
|
+
/** @type {import("stream/web").ReadableByteStreamController} */ controller
|
|
108
110
|
) => {
|
|
109
111
|
this.incomDatagramController = controller
|
|
110
|
-
}
|
|
112
|
+
},
|
|
113
|
+
type: 'bytes'
|
|
111
114
|
}),
|
|
112
115
|
writable: new WritableStream({
|
|
113
116
|
start: (controller) => {
|
|
@@ -200,6 +203,13 @@ export class Http3WTSession {
|
|
|
200
203
|
}
|
|
201
204
|
}
|
|
202
205
|
|
|
206
|
+
notifySessionDraining() {
|
|
207
|
+
if (this.objint == null) {
|
|
208
|
+
throw new Error('this.objint not set')
|
|
209
|
+
}
|
|
210
|
+
this.objint.notifySessionDraining()
|
|
211
|
+
}
|
|
212
|
+
|
|
203
213
|
/**
|
|
204
214
|
* @param {Http3WTStream} stream
|
|
205
215
|
*/
|
|
@@ -402,6 +412,26 @@ export class Http3WTSession {
|
|
|
402
412
|
*/
|
|
403
413
|
onDatagramReceived(args) {
|
|
404
414
|
// console.log('datagram received', args.datagram, Date.now())
|
|
415
|
+
if (this.incomDatagramController.byobRequest) {
|
|
416
|
+
/** @type {ReadableStreamBYOBRequest} */
|
|
417
|
+
const byob = this.incomDatagramController.byobRequest
|
|
418
|
+
/** @type {Uint8Array} */
|
|
419
|
+
// @ts-ignore
|
|
420
|
+
const view = byob?.view
|
|
421
|
+
// @ts-ignore
|
|
422
|
+
if (!(view instanceof Uint8Array))
|
|
423
|
+
throw new Error('byob view is not a Uint8Array')
|
|
424
|
+
if (view.byteLength < args.datagram.byteLength) {
|
|
425
|
+
throw new Error('supplied view is not large enough.')
|
|
426
|
+
}
|
|
427
|
+
const destview = new Uint8Array(
|
|
428
|
+
view.buffer,
|
|
429
|
+
0 + view.byteOffset,
|
|
430
|
+
args.datagram.byteLength
|
|
431
|
+
)
|
|
432
|
+
destview.set(args.datagram)
|
|
433
|
+
byob.respond(args.datagram.byteLength)
|
|
434
|
+
}
|
|
405
435
|
this.incomDatagramController.enqueue(args.datagram)
|
|
406
436
|
}
|
|
407
437
|
|
|
@@ -420,7 +450,15 @@ export class Http3WTSession {
|
|
|
420
450
|
}
|
|
421
451
|
|
|
422
452
|
/**
|
|
423
|
-
* @param {
|
|
453
|
+
* @param {GoawayReceivedEvent} args
|
|
454
|
+
*/
|
|
455
|
+
onGoAwayReceived(args) {
|
|
456
|
+
if (this.drainingResolve) this.drainingResolve(undefined)
|
|
457
|
+
this.state = 'draining'
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* @param {SessionReadyEvent | SessionCloseEvent | DatagramReceivedEvent | DatagramSendEvent | GoawayReceivedEvent | NewStreamEvent} args
|
|
424
462
|
*/
|
|
425
463
|
static callback(args) {
|
|
426
464
|
// console.log('Session callback called', args)
|
|
@@ -442,6 +480,9 @@ export class Http3WTSession {
|
|
|
442
480
|
case 'DatagramSend':
|
|
443
481
|
if (visitor) visitor.onDatagramSend(args)
|
|
444
482
|
break
|
|
483
|
+
case 'GoawayReceived':
|
|
484
|
+
visitor.onGoAwayReceived(args)
|
|
485
|
+
break
|
|
445
486
|
case 'Http3WTStreamVisitor':
|
|
446
487
|
if (
|
|
447
488
|
visitor &&
|
package/lib/stream.js
CHANGED
|
@@ -38,25 +38,46 @@ export class Http3WTStream {
|
|
|
38
38
|
this.pendingoperation = null
|
|
39
39
|
this.pendingres = null
|
|
40
40
|
|
|
41
|
+
/** @type {Promise<void> | null} */
|
|
42
|
+
this.pendingoperationRead = null
|
|
43
|
+
this.pendingresRead = null
|
|
44
|
+
|
|
41
45
|
if (this.bidirectional || this.incoming) {
|
|
42
|
-
|
|
46
|
+
/** @type {Number} */
|
|
47
|
+
this.incomingbufferfilled = 0
|
|
48
|
+
/** @type {Number} */
|
|
49
|
+
this.incomingbufferreadpos = 0
|
|
50
|
+
if (!this.objint.readbuffer)
|
|
51
|
+
throw new Error('No readbuffer for read stream')
|
|
52
|
+
// @ts-expect-error `getStats` property is missing from ReadableStream
|
|
43
53
|
/** @type {WebTransportReceiveStream} */
|
|
44
54
|
this.readable = new ReadableStream(
|
|
45
55
|
{
|
|
46
56
|
start: (
|
|
47
|
-
/** @type {
|
|
57
|
+
/** @type {import("stream/web").ReadableByteStreamController} */ controller
|
|
48
58
|
) => {
|
|
49
59
|
this.readableController = controller
|
|
50
60
|
this.parentobj.addReceiveStream(this.readable, controller)
|
|
51
61
|
this.objint.startReading()
|
|
52
62
|
},
|
|
53
|
-
pull: (
|
|
54
|
-
/** @type {
|
|
63
|
+
pull: async (
|
|
64
|
+
/** @type {import("stream/web").ReadableByteStreamController} */ controller
|
|
55
65
|
) => {
|
|
56
66
|
if (this.readableclosed) {
|
|
57
67
|
return Promise.resolve()
|
|
58
68
|
}
|
|
59
|
-
|
|
69
|
+
|
|
70
|
+
/** @type {Uint8Array} */
|
|
71
|
+
if (this.incomingbufferfilled === 0) {
|
|
72
|
+
this.pendingoperationRead = new Promise((resolve, reject) => {
|
|
73
|
+
this.pendingresRead = resolve
|
|
74
|
+
})
|
|
75
|
+
await this.pendingoperationRead
|
|
76
|
+
}
|
|
77
|
+
if (this.incomingbufferfilled === 0)
|
|
78
|
+
throw new Error('error reading')
|
|
79
|
+
|
|
80
|
+
this.drainBuffer()
|
|
60
81
|
},
|
|
61
82
|
cancel: (/** @type {{ code: number; }} */ reason) => {
|
|
62
83
|
/** @type {Promise<void>} */
|
|
@@ -72,9 +93,11 @@ export class Http3WTStream {
|
|
|
72
93
|
this.readableclosed = true
|
|
73
94
|
this.objint.stopSending(code)
|
|
74
95
|
return promise
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
96
|
+
},
|
|
97
|
+
type: 'bytes',
|
|
98
|
+
autoAllocateChunkSize: 4096 // lets take this as buffer size
|
|
99
|
+
}
|
|
100
|
+
// TODO fix stretegy
|
|
78
101
|
)
|
|
79
102
|
this.readable.getStats = () => {
|
|
80
103
|
return Promise.resolve({
|
|
@@ -161,6 +184,62 @@ export class Http3WTStream {
|
|
|
161
184
|
this.abortres = null
|
|
162
185
|
}
|
|
163
186
|
|
|
187
|
+
drainBuffer() {
|
|
188
|
+
const byob = this.readableController.byobRequest
|
|
189
|
+
// @ts-ignore
|
|
190
|
+
const view = byob?.view
|
|
191
|
+
// @ts-ignore
|
|
192
|
+
if (!(byob?.view instanceof Uint8Array))
|
|
193
|
+
throw new Error('byob view is not a Uint8Array')
|
|
194
|
+
let toread = Math.min(view.byteLength, this.incomingbufferfilled)
|
|
195
|
+
let read = 0
|
|
196
|
+
if (!this.objint.readbuffer)
|
|
197
|
+
throw new Error('No readbuffer in read for read stream')
|
|
198
|
+
if (
|
|
199
|
+
this.incomingbufferreadpos + toread >
|
|
200
|
+
this.objint.readbuffer.byteLength
|
|
201
|
+
) {
|
|
202
|
+
/** @type {Number} */
|
|
203
|
+
const firstread =
|
|
204
|
+
this.objint.readbuffer.byteLength - this.incomingbufferreadpos
|
|
205
|
+
read += firstread
|
|
206
|
+
toread -= firstread
|
|
207
|
+
const destview = new Uint8Array(
|
|
208
|
+
view.buffer,
|
|
209
|
+
0 + view.byteOffset,
|
|
210
|
+
firstread
|
|
211
|
+
)
|
|
212
|
+
const srcview = new Uint8Array(
|
|
213
|
+
this.objint.readbuffer,
|
|
214
|
+
this.incomingbufferreadpos,
|
|
215
|
+
firstread
|
|
216
|
+
)
|
|
217
|
+
destview.set(srcview)
|
|
218
|
+
this.incomingbufferreadpos = 0
|
|
219
|
+
}
|
|
220
|
+
{
|
|
221
|
+
const destview = new Uint8Array(
|
|
222
|
+
view.buffer,
|
|
223
|
+
read + view.byteOffset,
|
|
224
|
+
toread
|
|
225
|
+
)
|
|
226
|
+
const srcview = new Uint8Array(
|
|
227
|
+
this.objint.readbuffer,
|
|
228
|
+
this.incomingbufferreadpos,
|
|
229
|
+
toread
|
|
230
|
+
)
|
|
231
|
+
destview.set(srcview)
|
|
232
|
+
read += toread
|
|
233
|
+
this.incomingbufferreadpos =
|
|
234
|
+
(this.incomingbufferreadpos + toread) %
|
|
235
|
+
this.objint.readbuffer.byteLength
|
|
236
|
+
}
|
|
237
|
+
// @ts-ignore
|
|
238
|
+
byob.respond(read)
|
|
239
|
+
this.incomingbufferfilled -= read
|
|
240
|
+
this.objint.updateReadPos(read, this.incomingbufferreadpos)
|
|
241
|
+
}
|
|
242
|
+
|
|
164
243
|
/**
|
|
165
244
|
* @param {import('./types').StreamRecvSignalEvent} args
|
|
166
245
|
* @returns {void}
|
|
@@ -211,6 +290,14 @@ export class Http3WTStream {
|
|
|
211
290
|
res()
|
|
212
291
|
}
|
|
213
292
|
}
|
|
293
|
+
if (this.pendingoperationRead) {
|
|
294
|
+
const res = this.pendingresRead
|
|
295
|
+
this.pendingoperationRead = null
|
|
296
|
+
this.pendingresRead = null
|
|
297
|
+
if (res != null) {
|
|
298
|
+
res()
|
|
299
|
+
}
|
|
300
|
+
}
|
|
214
301
|
}
|
|
215
302
|
|
|
216
303
|
/**
|
|
@@ -218,9 +305,16 @@ export class Http3WTStream {
|
|
|
218
305
|
* @returns {void}
|
|
219
306
|
*/
|
|
220
307
|
onStreamRead(args) {
|
|
221
|
-
if (args.
|
|
308
|
+
if (args.buffergrow && !this.readableclosed) {
|
|
309
|
+
this.incomingbufferfilled += args.buffergrow
|
|
222
310
|
// console.log('stream read received', args.data, Date.now())
|
|
223
|
-
this.
|
|
311
|
+
if (this.pendingoperationRead) {
|
|
312
|
+
// this.readableController.enqueue(data)
|
|
313
|
+
const res = this.pendingresRead
|
|
314
|
+
this.pendingoperationRead = null
|
|
315
|
+
this.pendingresRead = null
|
|
316
|
+
if (res) res()
|
|
317
|
+
}
|
|
224
318
|
if (
|
|
225
319
|
this.readableController.desiredSize != null &&
|
|
226
320
|
this.readableController.desiredSize < 0
|
|
@@ -228,6 +322,13 @@ export class Http3WTStream {
|
|
|
228
322
|
this.objint.stopReading()
|
|
229
323
|
}
|
|
230
324
|
if (args.fin) {
|
|
325
|
+
if (this.incomingbufferfilled > 0) {
|
|
326
|
+
console.log('Warning buffer filled and we got a fin')
|
|
327
|
+
if (this.pendingoperationRead || this.pendingresRead)
|
|
328
|
+
throw new Error('We have pendingoperationRead and a filled buffer?')
|
|
329
|
+
|
|
330
|
+
this.drainBuffer()
|
|
331
|
+
}
|
|
231
332
|
if (this.cancelres) {
|
|
232
333
|
const res = this.cancelres
|
|
233
334
|
this.cancelres = null
|
|
@@ -326,7 +427,10 @@ export class Http3WTStream {
|
|
|
326
427
|
visitor.onStreamRecvSignal(args)
|
|
327
428
|
break
|
|
328
429
|
case 'StreamRead':
|
|
329
|
-
if (
|
|
430
|
+
if (
|
|
431
|
+
visitor &&
|
|
432
|
+
Object.prototype.hasOwnProperty.call(args, 'buffergrow')
|
|
433
|
+
) {
|
|
330
434
|
visitor.onStreamRead(args)
|
|
331
435
|
} else {
|
|
332
436
|
console.log('Stream callback called', visitor, args)
|
package/lib/types.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { WebTransport } from './dom'
|
|
|
9
9
|
orderUnidiStream: () => void
|
|
10
10
|
orderBidiStream: () => void
|
|
11
11
|
// orderStats: () => void
|
|
12
|
+
notifySessionDraining(): () => void
|
|
12
13
|
close: (arg: { code: number, reason: string }) => void
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -16,7 +17,9 @@ import type { WebTransport } from './dom'
|
|
|
16
17
|
* Native Http3WTStream counterpart
|
|
17
18
|
*/
|
|
18
19
|
export interface NativeHttp3WTStream {
|
|
20
|
+
updateReadPos(bytesread: Number, pos: Number): unknown
|
|
19
21
|
jsobj: WebTransportStreamEventHandler
|
|
22
|
+
readbuffer: Uint8Array | undefined
|
|
20
23
|
startReading: () => void
|
|
21
24
|
stopReading: () => void
|
|
22
25
|
stopSending: (code: number) => void
|
|
@@ -38,8 +41,9 @@ export interface StreamRecvSignalEvent {
|
|
|
38
41
|
export interface StreamReadEvent {
|
|
39
42
|
object: NativeHttp3WTStream
|
|
40
43
|
purpose: 'StreamRead'
|
|
41
|
-
|
|
44
|
+
buffergrow?: number
|
|
42
45
|
fin?: boolean
|
|
46
|
+
success?: boolean
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
export interface StreamWriteEvent {
|
|
@@ -89,6 +93,11 @@ export interface DatagramSendEvent {
|
|
|
89
93
|
purpose: 'DatagramSend'
|
|
90
94
|
}
|
|
91
95
|
|
|
96
|
+
export interface GoawayReceivedEvent {
|
|
97
|
+
object: NativeHttp3WTSession
|
|
98
|
+
purpose: 'GoawayReceived'
|
|
99
|
+
}
|
|
100
|
+
|
|
92
101
|
export interface NewStreamEvent {
|
|
93
102
|
object: NativeHttp3WTSession
|
|
94
103
|
purpose: 'Http3WTStreamVisitor'
|
|
@@ -103,6 +112,7 @@ export interface WebTransportSessionEventHandler {
|
|
|
103
112
|
onClose: (evt: SessionCloseEvent) => void
|
|
104
113
|
onDatagramReceived: (evt: DatagramReceivedEvent) => void
|
|
105
114
|
onDatagramSend: (evt: DatagramSendEvent) => void
|
|
115
|
+
onGoAwayReceived: (evt: GoawayReceivedEvent) => void
|
|
106
116
|
onStream: (evt: NewStreamEvent) => void
|
|
107
117
|
closeHook?: (() => void) | null
|
|
108
118
|
}
|
|
@@ -175,7 +185,7 @@ export interface Deferred<T = unknown> {
|
|
|
175
185
|
reject: (reason?: any) => void
|
|
176
186
|
}
|
|
177
187
|
|
|
178
|
-
export type WebTransportSessionState = 'connected' | 'closed' | 'failed'
|
|
188
|
+
export type WebTransportSessionState = 'connected' | 'draining' | 'closed' | 'failed'
|
|
179
189
|
|
|
180
190
|
export interface WebTransportSession extends WebTransport {
|
|
181
191
|
state: WebTransportSessionState
|