@fails-components/webtransport 0.3.1 → 1.0.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/lib/client.js +81 -40
- package/lib/dom.ts +7 -5
- package/lib/http2/browser/browser.js +168 -0
- package/lib/http2/browser/browserparser.js +248 -0
- package/lib/http2/flowcontroller.js +371 -0
- package/lib/http2/node/capsuleparser.js +291 -0
- package/lib/http2/node/client.js +239 -0
- package/lib/http2/node/index.js +2 -0
- package/lib/http2/node/server.js +499 -0
- package/lib/http2/node/websocketparser.js +829 -0
- package/lib/http2/parserbase.js +139 -0
- package/lib/http2/parserbasehttp2.js +128 -0
- package/lib/http2/session.js +225 -0
- package/lib/http2/stream.js +354 -0
- package/lib/http2/websocketcommon.js +1 -0
- package/lib/{index.js → index.browser.js} +6 -10
- package/lib/index.node.js +27 -0
- package/lib/server.js +252 -69
- package/lib/session.js +31 -68
- package/lib/stream.js +103 -179
- package/lib/types.ts +174 -87
- package/lib/utils.js +2 -1
- package/lib/webstreams.browser.js +6 -0
- package/lib/webstreams.js +7 -0
- package/lib/webtransport.browser.js +284 -0
- package/lib/webtransport.node.js +137 -0
- package/lib/{webtransport.js → webtransportbase.js} +47 -41
- package/old_test/test.js +31 -29
- package/old_test/testsuite.js +1 -1
- package/package.json +18 -17
- package/readme.md +94 -30
- package/test/bidirectional-streams.spec.js +51 -9
- package/test/datagrams.spec.js +8 -2
- package/test/fixtures/known-bytes.js +29 -0
- package/test/fixtures/read-stream.js +1 -1
- package/test/fixtures/reader-value.js +1 -1
- package/test/fixtures/server.js +24 -10
- package/test/fixtures/webtransport.browser.js +20 -2
- package/test/fixtures/webtransport.js +1 -1
- package/test/index.js +33 -6
- package/test/pw-no-https-errors.json +5 -0
- package/test/session.spec.js +71 -52
- package/test/unidirectional-streams.spec.js +20 -4
- package/CMakeLists.txt +0 -991
- package/LICENSE.chromium +0 -27
- package/LICENSE.envoy +0 -207
- package/build.js +0 -313
- package/dist/lib/client.d.ts +0 -78
- package/dist/lib/client.d.ts.map +0 -1
- package/dist/lib/dom.d.ts +0 -87
- package/dist/lib/dom.d.ts.map +0 -1
- package/dist/lib/error.d.ts +0 -8
- package/dist/lib/error.d.ts.map +0 -1
- package/dist/lib/event-loop.d.ts +0 -33
- package/dist/lib/event-loop.d.ts.map +0 -1
- package/dist/lib/index.d.ts +0 -79
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/native.d.ts +0 -2
- package/dist/lib/native.d.ts.map +0 -1
- package/dist/lib/server.d.ts +0 -92
- package/dist/lib/server.d.ts.map +0 -1
- package/dist/lib/session.d.ts +0 -298
- package/dist/lib/session.d.ts.map +0 -1
- package/dist/lib/stream.d.ts +0 -135
- package/dist/lib/stream.d.ts.map +0 -1
- package/dist/lib/transport.d.ts +0 -34
- package/dist/lib/transport.d.ts.map +0 -1
- package/dist/lib/types.d.ts +0 -212
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/utils.d.ts +0 -11
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/webtransport.d.ts +0 -47
- package/dist/lib/webtransport.d.ts.map +0 -1
- package/dist/test/bidirectional-streams.spec.d.ts +0 -5
- package/dist/test/bidirectional-streams.spec.d.ts.map +0 -1
- package/dist/test/datagrams.spec.d.ts +0 -5
- package/dist/test/datagrams.spec.d.ts.map +0 -1
- package/dist/test/event-loop.node.d.ts +0 -2
- package/dist/test/event-loop.node.d.ts.map +0 -1
- package/dist/test/fixtures/certificate.d.ts +0 -21
- package/dist/test/fixtures/certificate.d.ts.map +0 -1
- package/dist/test/fixtures/chai.d.ts +0 -2
- package/dist/test/fixtures/chai.d.ts.map +0 -1
- package/dist/test/fixtures/known-bytes.d.ts +0 -6
- package/dist/test/fixtures/known-bytes.d.ts.map +0 -1
- package/dist/test/fixtures/p-timeout.d.ts +0 -8
- package/dist/test/fixtures/p-timeout.d.ts.map +0 -1
- package/dist/test/fixtures/read-cert-hash.d.ts +0 -6
- package/dist/test/fixtures/read-cert-hash.d.ts.map +0 -1
- package/dist/test/fixtures/read-stream.d.ts +0 -19
- package/dist/test/fixtures/read-stream.d.ts.map +0 -1
- package/dist/test/fixtures/reader-value.d.ts +0 -22
- package/dist/test/fixtures/reader-value.d.ts.map +0 -1
- package/dist/test/fixtures/server.d.ts +0 -5
- package/dist/test/fixtures/server.d.ts.map +0 -1
- package/dist/test/fixtures/webtransport.browser.d.ts +0 -3
- package/dist/test/fixtures/webtransport.browser.d.ts.map +0 -1
- package/dist/test/fixtures/webtransport.d.ts +0 -3
- package/dist/test/fixtures/webtransport.d.ts.map +0 -1
- package/dist/test/fixtures/write-stream.d.ts +0 -10
- package/dist/test/fixtures/write-stream.d.ts.map +0 -1
- package/dist/test/index.d.ts +0 -2
- package/dist/test/index.d.ts.map +0 -1
- package/dist/test/session.spec.d.ts +0 -5
- package/dist/test/session.spec.d.ts.map +0 -1
- package/dist/test/unidirectional-streams.spec.d.ts +0 -2
- package/dist/test/unidirectional-streams.spec.d.ts.map +0 -1
- package/failslogolicensereadme.txt +0 -4
- package/lib/event-loop.js +0 -88
- package/lib/native.js +0 -28
- package/lib/transport.js +0 -82
- package/platform/icufix/fakedata.cpp +0 -8
- package/platform/quiche/quic/core/io/socket_win.inc +0 -3
- package/platform/quiche_platform_impl/quiche_bug_tracker_impl.h +0 -7
- package/platform/quiche_platform_impl/quiche_client_stats_impl.h +0 -7
- package/platform/quiche_platform_impl/quiche_command_line_flags_impl.h +0 -7
- package/platform/quiche_platform_impl/quiche_containers_impl.h +0 -7
- package/platform/quiche_platform_impl/quiche_event_loop_impl.h +0 -7
- package/platform/quiche_platform_impl/quiche_export_impl.h +0 -6
- package/platform/quiche_platform_impl/quiche_flag_utils_impl.h +0 -11
- package/platform/quiche_platform_impl/quiche_flags_impl.h +0 -8
- package/platform/quiche_platform_impl/quiche_iovec_impl.h +0 -10
- package/platform/quiche_platform_impl/quiche_logging_impl.h +0 -21
- package/platform/quiche_platform_impl/quiche_mem_slice_impl.h +0 -2
- package/platform/quiche_platform_impl/quiche_mutex_impl.h +0 -8
- package/platform/quiche_platform_impl/quiche_prefetch_impl.h +0 -11
- package/platform/quiche_platform_impl/quiche_reference_counted_impl.h +0 -16
- package/platform/quiche_platform_impl/quiche_server_stats_impl.h +0 -7
- package/platform/quiche_platform_impl/quiche_stack_trace_impl.h +0 -12
- package/platform/quiche_platform_impl/quiche_stream_buffer_allocator_impl.h +0 -8
- package/platform/quiche_platform_impl/quiche_testvalue_impl.h +0 -1
- package/platform/quiche_platform_impl/quiche_thread_local_impl.h +0 -6
- package/platform/quiche_platform_impl/quiche_time_utils_impl.h +0 -13
- package/platform/quiche_platform_impl/quiche_udp_socket_platform_impl.h +0 -39
- package/src/http3backendresponse.cc +0 -36
- package/src/http3backendresponse.h +0 -109
- package/src/http3client.cc +0 -1529
- package/src/http3client.h +0 -557
- package/src/http3clientsession.cc +0 -65
- package/src/http3clientsession.h +0 -60
- package/src/http3clientstream.cc +0 -52
- package/src/http3clientstream.h +0 -42
- package/src/http3dispatcher.cc +0 -62
- package/src/http3dispatcher.h +0 -57
- package/src/http3eventloop.cc +0 -1107
- package/src/http3eventloop.h +0 -316
- package/src/http3server.cc +0 -514
- package/src/http3server.h +0 -151
- package/src/http3serverbackend.cc +0 -105
- package/src/http3serverbackend.h +0 -98
- package/src/http3serversession.cc +0 -123
- package/src/http3serversession.h +0 -95
- package/src/http3serverstream.cc +0 -463
- package/src/http3serverstream.h +0 -114
- package/src/http3sessioncache.cc +0 -85
- package/src/http3sessioncache.h +0 -59
- package/src/http3wtsessionvisitor.cc +0 -46
- package/src/http3wtsessionvisitor.h +0 -397
- package/src/http3wtstreamvisitor.cc +0 -155
- package/src/http3wtstreamvisitor.h +0 -404
- package/test/event-loop.node.js +0 -24
- package/tsconfig.json +0 -39
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { FlowController } from './flowcontroller.js'
|
|
2
|
+
import { ParserBase } from './parserbase.js'
|
|
3
|
+
import { logger } from '../utils.js'
|
|
4
|
+
|
|
5
|
+
const pid = typeof process !== 'undefined' ? process.pid : 0
|
|
6
|
+
const log = logger(`webtransport:http2webtransportstream(${pid})`)
|
|
7
|
+
/**
|
|
8
|
+
* WebTransport stream events
|
|
9
|
+
* @typedef {import('../types').WebTransportStreamEventHandler} WebTransportStreamEventHandler
|
|
10
|
+
* @typedef {import('../types').StreamRecvSignalEvent} StreamRecvSignalEvent
|
|
11
|
+
* @typedef {import('../types').StreamReadEvent} StreamReadEvent
|
|
12
|
+
* @typedef {import('../types').StreamWriteEvent} StreamWriteEvent
|
|
13
|
+
* @typedef {import('../types').StreamNetworkFinishEvent} StreamNetworkFinishEvent
|
|
14
|
+
*
|
|
15
|
+
* @typedef {import('../types').ReadDataInt} ReadDataInt
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
let processnextTick = (/** @type {{ (): void; }} */ func) =>
|
|
19
|
+
setTimeout(func, 0)
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
if (typeof process !== 'undefined') processnextTick = process.nextTick
|
|
22
|
+
|
|
23
|
+
export class Http2WebTransportStream {
|
|
24
|
+
/**
|
|
25
|
+
* @param {{streamid: Number, capsuleParser: ParserBase
|
|
26
|
+
* sendWindowOffset: Number,
|
|
27
|
+
* receiveWindowOffset: Number,
|
|
28
|
+
* shouldAutoTuneReceiveWindow: boolean
|
|
29
|
+
* receiveWindowSizeLimit: Number,
|
|
30
|
+
* sessionFlowController: FlowController}} args
|
|
31
|
+
* */
|
|
32
|
+
constructor({
|
|
33
|
+
streamid,
|
|
34
|
+
capsuleParser,
|
|
35
|
+
sendWindowOffset,
|
|
36
|
+
receiveWindowOffset,
|
|
37
|
+
shouldAutoTuneReceiveWindow,
|
|
38
|
+
receiveWindowSizeLimit,
|
|
39
|
+
sessionFlowController
|
|
40
|
+
}) {
|
|
41
|
+
/** @type {import('../stream').HttpWTStream} */
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
this.jsobj = undefined // the creator will set this
|
|
44
|
+
this.streamid = streamid
|
|
45
|
+
/** @type {Array<ReadDataInt>} */
|
|
46
|
+
this.incomdata = []
|
|
47
|
+
|
|
48
|
+
this.capsuleParser = capsuleParser
|
|
49
|
+
/** @type {Array<{buf?:Uint8Array,fin:boolean}>} */
|
|
50
|
+
this.outgochunks = []
|
|
51
|
+
|
|
52
|
+
this.flowController = new FlowController({
|
|
53
|
+
tocontrol: this,
|
|
54
|
+
sendWindowOffset,
|
|
55
|
+
receiveWindowOffset,
|
|
56
|
+
shouldAutoTuneReceiveWindow,
|
|
57
|
+
receiveWindowSizeLimit,
|
|
58
|
+
sessionFlowController
|
|
59
|
+
})
|
|
60
|
+
this.sessionFlowController = sessionFlowController
|
|
61
|
+
|
|
62
|
+
this.final = false
|
|
63
|
+
this.stopReading_ = true
|
|
64
|
+
this.drainReads_ = true
|
|
65
|
+
this.recvBytes = 0
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
sendInitialParameters() {
|
|
69
|
+
this.flowController.sendWindowUpdate()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param {Object} obj
|
|
74
|
+
* @param {Uint8Array} obj.data
|
|
75
|
+
* @param {Boolean} obj.fin
|
|
76
|
+
*/
|
|
77
|
+
recvData({ data, fin }) {
|
|
78
|
+
this.incomdata.push({ data, fin })
|
|
79
|
+
if (data?.byteLength > 0) {
|
|
80
|
+
const checkstream = this.flowController.updateHighestReceivedOffset(
|
|
81
|
+
data?.byteLength
|
|
82
|
+
)
|
|
83
|
+
const checksession =
|
|
84
|
+
this.sessionFlowController.updateHighestReceivedOffset(data?.byteLength)
|
|
85
|
+
if (checksession && checkstream) {
|
|
86
|
+
// As the highest received offset has changed, check to see if this is a
|
|
87
|
+
// violation of flow control.
|
|
88
|
+
|
|
89
|
+
if (
|
|
90
|
+
this.flowController.flowControlViolation() ||
|
|
91
|
+
this.sessionFlowController.flowControlViolation()
|
|
92
|
+
) {
|
|
93
|
+
this.closeConnection({
|
|
94
|
+
code: 63 /* QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA */,
|
|
95
|
+
reason: 'Flow control violation after increasing offset'
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
this.processRead()
|
|
103
|
+
if (this.incomdata.length > 0) {
|
|
104
|
+
if (!this.stopReading_) this.processRead()
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
processRead() {
|
|
109
|
+
if (!this.jsobj) return
|
|
110
|
+
let buffer
|
|
111
|
+
let bufferoffset = 0
|
|
112
|
+
while (
|
|
113
|
+
this.incomdata.length > 0 &&
|
|
114
|
+
(!this.stopReading_ || this.drainReads_)
|
|
115
|
+
) {
|
|
116
|
+
if (!buffer) {
|
|
117
|
+
const bytes = this.incomdata.reduce(
|
|
118
|
+
(prevVal, val) => prevVal + val.data?.byteLength,
|
|
119
|
+
0
|
|
120
|
+
)
|
|
121
|
+
if (bytes > 0) {
|
|
122
|
+
buffer = this.jsobj.getReadBuffer({
|
|
123
|
+
byteSize: this.incomdata.reduce(
|
|
124
|
+
(prevVal, val) => prevVal + val.data?.byteLength,
|
|
125
|
+
0
|
|
126
|
+
)
|
|
127
|
+
})
|
|
128
|
+
buffer.readBytes = 0
|
|
129
|
+
bufferoffset = 0
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const cur = this.incomdata.shift()
|
|
133
|
+
if (cur?.data && cur.data.byteLength > 0 && buffer && buffer.buffer) {
|
|
134
|
+
const len = Math.min(
|
|
135
|
+
buffer.buffer.byteLength - bufferoffset,
|
|
136
|
+
cur.data.byteLength
|
|
137
|
+
)
|
|
138
|
+
const srcview = new Uint8Array(
|
|
139
|
+
cur.data.buffer,
|
|
140
|
+
cur.data.byteOffset,
|
|
141
|
+
len
|
|
142
|
+
)
|
|
143
|
+
const destview = new Uint8Array(buffer.buffer.buffer, bufferoffset, len)
|
|
144
|
+
destview.set(srcview)
|
|
145
|
+
bufferoffset += len
|
|
146
|
+
// @ts-ignore
|
|
147
|
+
buffer.readBytes += len
|
|
148
|
+
buffer.drained = true
|
|
149
|
+
if (cur.data.byteLength !== len) {
|
|
150
|
+
buffer.drained = false
|
|
151
|
+
this.incomdata.unshift({
|
|
152
|
+
data: new Uint8Array(
|
|
153
|
+
cur.data.buffer,
|
|
154
|
+
cur.data.byteOffset + len,
|
|
155
|
+
cur.data.byteLength - len
|
|
156
|
+
),
|
|
157
|
+
fin: false || cur.fin
|
|
158
|
+
})
|
|
159
|
+
buffer.fin = false // next round
|
|
160
|
+
} else {
|
|
161
|
+
buffer.fin ||= cur.fin
|
|
162
|
+
}
|
|
163
|
+
if (this.incomdata.length > 0) buffer.drained = false
|
|
164
|
+
if (
|
|
165
|
+
bufferoffset === buffer.buffer.byteLength ||
|
|
166
|
+
this.incomdata.length === 0
|
|
167
|
+
) {
|
|
168
|
+
this.flowController.addBytesConsumed(buffer.readBytes || 0)
|
|
169
|
+
this.sessionFlowController.addBytesConsumed(buffer.readBytes || 0)
|
|
170
|
+
const { stopReading } = this.jsobj.commitReadBuffer(buffer)
|
|
171
|
+
if (stopReading) this.stopReading_ = true
|
|
172
|
+
buffer = undefined
|
|
173
|
+
bufferoffset = 0
|
|
174
|
+
}
|
|
175
|
+
this.recvBytes += len
|
|
176
|
+
} else if (cur?.fin) {
|
|
177
|
+
this.jsobj.commitReadBuffer({ fin: true })
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
startReading() {
|
|
183
|
+
this.stopReading_ = false
|
|
184
|
+
this.processRead()
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
drainReads() {
|
|
188
|
+
this.drainReads_ = true
|
|
189
|
+
this.stopReading_ = false
|
|
190
|
+
this.processRead()
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
stopReading() {
|
|
194
|
+
this.stopReading_ = true
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @param {Number} code
|
|
199
|
+
*/
|
|
200
|
+
stopSending(code) {
|
|
201
|
+
this.capsuleParser.writeCapsule({
|
|
202
|
+
type: ParserBase.WT_STOP_SENDING,
|
|
203
|
+
headerVints: [this.streamid, code],
|
|
204
|
+
payload: undefined
|
|
205
|
+
})
|
|
206
|
+
processnextTick(() =>
|
|
207
|
+
this.jsobj.onStreamNetworkFinish({
|
|
208
|
+
nettask: 'stopSending'
|
|
209
|
+
})
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* @param {Number} code
|
|
215
|
+
*/
|
|
216
|
+
resetStream(code) {
|
|
217
|
+
this.capsuleParser.writeCapsule({
|
|
218
|
+
type: ParserBase.WT_RESET_STREAM,
|
|
219
|
+
headerVints: [this.streamid, code],
|
|
220
|
+
payload: undefined
|
|
221
|
+
})
|
|
222
|
+
processnextTick(() =>
|
|
223
|
+
this.jsobj.onStreamNetworkFinish({
|
|
224
|
+
nettask: 'resetStream'
|
|
225
|
+
})
|
|
226
|
+
)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @param {Uint8Array} buf
|
|
231
|
+
*/
|
|
232
|
+
writeChunk(buf) {
|
|
233
|
+
this.outgochunks.push({ buf, fin: false })
|
|
234
|
+
this.drainWrites()
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
drainWrites() {
|
|
238
|
+
while (
|
|
239
|
+
this.outgochunks.length > 0 &&
|
|
240
|
+
(!this.capsuleParser.blocked || this.final) &&
|
|
241
|
+
this.flowController.sendWindowSize() > 0 &&
|
|
242
|
+
this.sessionFlowController.sendWindowSize() > 0
|
|
243
|
+
) {
|
|
244
|
+
const cur = this.outgochunks.shift()
|
|
245
|
+
if (cur) {
|
|
246
|
+
let payload = cur.buf
|
|
247
|
+
if (payload) {
|
|
248
|
+
const sessWindow = this.sessionFlowController.sendWindowSize()
|
|
249
|
+
const streamWindow = this.flowController.sendWindowSize()
|
|
250
|
+
if (
|
|
251
|
+
payload?.byteLength > streamWindow ||
|
|
252
|
+
payload?.byteLength > sessWindow
|
|
253
|
+
) {
|
|
254
|
+
const len =
|
|
255
|
+
sessWindow > streamWindow
|
|
256
|
+
? Number(streamWindow)
|
|
257
|
+
: Number(sessWindow)
|
|
258
|
+
// ok we have to split
|
|
259
|
+
{
|
|
260
|
+
const src = new Uint8Array(
|
|
261
|
+
payload.buffer,
|
|
262
|
+
payload.byteOffset + len,
|
|
263
|
+
payload.byteLength - len
|
|
264
|
+
)
|
|
265
|
+
const dest = new Uint8Array(payload.byteLength - len)
|
|
266
|
+
dest.set(src)
|
|
267
|
+
this.outgochunks.unshift({ fin: cur.fin, buf: dest })
|
|
268
|
+
}
|
|
269
|
+
cur.fin = false
|
|
270
|
+
payload = cur.buf = new Uint8Array(
|
|
271
|
+
payload.buffer,
|
|
272
|
+
payload.byteOffset,
|
|
273
|
+
len
|
|
274
|
+
)
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
this.capsuleParser.writeCapsule({
|
|
278
|
+
type: cur?.fin
|
|
279
|
+
? ParserBase.WT_STREAM_WFIN
|
|
280
|
+
: ParserBase.WT_STREAM_WOFIN,
|
|
281
|
+
headerVints: [this.streamid],
|
|
282
|
+
payload
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
if (payload) {
|
|
286
|
+
this.flowController.addBytesSent(payload?.byteLength)
|
|
287
|
+
this.sessionFlowController.addBytesSent(payload?.byteLength)
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
this.jsobj.onStreamWrite({
|
|
291
|
+
success: true
|
|
292
|
+
})
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
streamFinal() {
|
|
297
|
+
this.final = true
|
|
298
|
+
this.outgochunks.push({ fin: true })
|
|
299
|
+
this.drainWrites()
|
|
300
|
+
processnextTick(() =>
|
|
301
|
+
this.jsobj.onStreamNetworkFinish({
|
|
302
|
+
nettask: 'streamFinal'
|
|
303
|
+
})
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @param {bigint} windowOffset
|
|
309
|
+
*/
|
|
310
|
+
sendWindowUpdate(windowOffset) {
|
|
311
|
+
this.capsuleParser.writeCapsule({
|
|
312
|
+
type: ParserBase.WT_MAX_STREAM_DATA,
|
|
313
|
+
headerVints: [this.streamid, windowOffset],
|
|
314
|
+
payload: undefined
|
|
315
|
+
})
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @param {bigint} windowOffset
|
|
320
|
+
*/
|
|
321
|
+
sendBlocked(windowOffset) {
|
|
322
|
+
this.capsuleParser.writeCapsule({
|
|
323
|
+
type: ParserBase.WT_STREAM_DATA_BLOCKED,
|
|
324
|
+
headerVints: [this.streamid, windowOffset],
|
|
325
|
+
payload: undefined
|
|
326
|
+
})
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* @param {bigint} pos
|
|
331
|
+
*/
|
|
332
|
+
reportBlocked(pos) {
|
|
333
|
+
log('Stream id: ', this.streamid, ' was blocked at:', pos)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
connected() {
|
|
337
|
+
return this.jsobj.parentobj.state === 'connected'
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* @param {{ code: number, reason: string }} arg
|
|
342
|
+
*/
|
|
343
|
+
closeConnection({ code, reason }) {
|
|
344
|
+
if (this.jsobj.parentobj?.objint)
|
|
345
|
+
// @ts-ignore
|
|
346
|
+
this.jsobj.parentobj.objint.closeConnection({ code, reason })
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
smoothedRtt() {
|
|
350
|
+
if (this.jsobj.parentobj?.objint)
|
|
351
|
+
// @ts-ignore
|
|
352
|
+
return this.jsobj.parentobj.objint.smoothedRtt()
|
|
353
|
+
}
|
|
354
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const supportedVersions = ['kDraft1']
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
// Use of this source code is governed by a BSD-style license that can be
|
|
4
4
|
// found in the LICENSE file.
|
|
5
5
|
|
|
6
|
-
import { Http3EventLoop } from './event-loop.js'
|
|
7
|
-
|
|
8
6
|
/**
|
|
9
7
|
* // Spec
|
|
10
8
|
* @typedef {import('./dom').WebTransportDatagramStats} WebTransportDatagramStats
|
|
@@ -21,13 +19,11 @@ import { Http3EventLoop } from './event-loop.js'
|
|
|
21
19
|
* @typedef {import('./dom').WebTransportReliabilityMode} WebTransportReliabilityMode
|
|
22
20
|
*
|
|
23
21
|
* Public API
|
|
24
|
-
* @typedef {import('./types').
|
|
25
|
-
* @typedef {import('./types').
|
|
22
|
+
* @typedef {import('./types').WebTransportSessionImpl} WebTransportSession
|
|
23
|
+
* @typedef {import('./types').HttpServerInit} HttpServerInit
|
|
26
24
|
*/
|
|
27
25
|
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export { Http3Server } from './server.js'
|
|
33
|
-
export { WebTransport } from './webtransport.js'
|
|
26
|
+
export {
|
|
27
|
+
WebTransportPonyfill,
|
|
28
|
+
WebTransportPolyfill
|
|
29
|
+
} from './webtransport.browser.js'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* eslint-disable no-prototype-builtins */
|
|
2
|
+
// Copyright (c) 2022 Marten Richter or other contributers (see commit). All rights reserved.
|
|
3
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
4
|
+
// found in the LICENSE file.
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* // Spec
|
|
8
|
+
* @typedef {import('./dom').WebTransportDatagramStats} WebTransportDatagramStats
|
|
9
|
+
* @typedef {import('./dom').WebTransportStats} WebTransportStats
|
|
10
|
+
* @typedef {import('./dom').WebTransportCloseInfo} WebTransportCloseInfo
|
|
11
|
+
* @typedef {import('./dom').WebTransportDatagramDuplexStream} WebTransportDatagramDuplexStream
|
|
12
|
+
* @typedef {import('./dom').WebTransportBidirectionalStream} WebTransportBidirectionalStream
|
|
13
|
+
* @typedef {import('./dom').WebTransportSendStreamStats} WebTransportSendStreamStats
|
|
14
|
+
* @typedef {import('./dom').WebTransportSendStream} WebTransportSendStream
|
|
15
|
+
* @typedef {import('./dom').WebTransportReceiveStreamStats} WebTransportReceiveStreamStats
|
|
16
|
+
* @typedef {import('./dom').WebTransportReceiveStream} WebTransportReceiveStream
|
|
17
|
+
* @typedef {import('./dom').WebTransportHash} WebTransportHash
|
|
18
|
+
* @typedef {import('./dom').WebTransportOptions} WebTransportOptions
|
|
19
|
+
* @typedef {import('./dom').WebTransportReliabilityMode} WebTransportReliabilityMode
|
|
20
|
+
*
|
|
21
|
+
* Public API
|
|
22
|
+
* @typedef {import('./types').WebTransportSessionImpl} WebTransportSession
|
|
23
|
+
* @typedef {import('./types').HttpServerInit} HttpServerInit
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export { HttpServer, Http3Server, Http2Server } from './server.js'
|
|
27
|
+
export { WebTransport } from './webtransport.node.js'
|