@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
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
// modifications
|
|
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
|
-
// original copyright used only portions, see LICENSE.chromium
|
|
7
|
-
// Copyright (c) 2021 The Chromium Authors. All rights reserved.
|
|
8
|
-
// Use of this source code is governed by a BSD-style license that can be
|
|
9
|
-
// found in the LICENSE file.
|
|
10
|
-
|
|
11
|
-
#ifndef HTTP3_WT_STREAM_VISITOR_H_
|
|
12
|
-
#define HTTP3_WT_STREAM_VISITOR_H_
|
|
13
|
-
|
|
14
|
-
#include <napi.h>
|
|
15
|
-
#include <uv.h>
|
|
16
|
-
|
|
17
|
-
#include <string>
|
|
18
|
-
|
|
19
|
-
#include "quiche/common/simple_buffer_allocator.h"
|
|
20
|
-
#include "quiche/quic/core/web_transport_interface.h"
|
|
21
|
-
#include "quiche/quic/platform/api/quic_logging.h"
|
|
22
|
-
#include "quiche/common/quiche_circular_deque.h"
|
|
23
|
-
|
|
24
|
-
#include "src/http3eventloop.h"
|
|
25
|
-
|
|
26
|
-
namespace quic
|
|
27
|
-
{
|
|
28
|
-
class Http3EventLoop;
|
|
29
|
-
|
|
30
|
-
class Http3WTStreamJS;
|
|
31
|
-
|
|
32
|
-
class Http3WTStream
|
|
33
|
-
{
|
|
34
|
-
friend Http3WTStreamJS;
|
|
35
|
-
|
|
36
|
-
public:
|
|
37
|
-
Http3WTStream(WebTransportStream *stream, Http3EventLoop *eventloop) :
|
|
38
|
-
stream_(stream),
|
|
39
|
-
eventloop_(eventloop),
|
|
40
|
-
js_(nullptr),
|
|
41
|
-
readpos_(0),
|
|
42
|
-
writepos_(0),
|
|
43
|
-
bufferlen_(0),
|
|
44
|
-
readbufsize_(0),
|
|
45
|
-
readbufdata_(nullptr)
|
|
46
|
-
{
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
~Http3WTStream(){/*printf("stream destruct %x\n", this);*/};
|
|
50
|
-
|
|
51
|
-
class Visitor : public WebTransportStreamVisitor
|
|
52
|
-
{
|
|
53
|
-
public:
|
|
54
|
-
Visitor(Http3WTStream *stream) : stream_(stream), lasterror(0) {}
|
|
55
|
-
|
|
56
|
-
~Visitor();
|
|
57
|
-
|
|
58
|
-
void OnCanRead() override
|
|
59
|
-
{
|
|
60
|
-
stream_->doCanRead();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
void OnCanWrite() override
|
|
64
|
-
{
|
|
65
|
-
stream_->doCanWrite();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
void OnResetStreamReceived(WebTransportStreamError error) override;
|
|
69
|
-
|
|
70
|
-
void OnStopSendingReceived(WebTransportStreamError /*error*/) override;
|
|
71
|
-
|
|
72
|
-
void OnWriteSideInDataRecvdState() override;
|
|
73
|
-
|
|
74
|
-
void OnStopReading()
|
|
75
|
-
{
|
|
76
|
-
stream_->doStopReading();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
protected:
|
|
80
|
-
Http3WTStream *stream_;
|
|
81
|
-
WebTransportStreamError lasterror;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
void doCanRead();
|
|
85
|
-
|
|
86
|
-
void doCanWrite();
|
|
87
|
-
|
|
88
|
-
void doStopReading()
|
|
89
|
-
{
|
|
90
|
-
pause_reading_ = true;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
void tryWrite()
|
|
94
|
-
{
|
|
95
|
-
if (stream_ && stream_->CanWrite())
|
|
96
|
-
{
|
|
97
|
-
doCanWrite();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
inline bool readBufferFull() {
|
|
103
|
-
return !readbufdata_ || bufferlen_ >= readbufsize_;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
void tryRead()
|
|
107
|
-
{
|
|
108
|
-
pause_reading_ = false;
|
|
109
|
-
if (stream_ && ((stream_->ReadableBytes() > 0) || can_read_pending_)
|
|
110
|
-
&& !readBufferFull())
|
|
111
|
-
{
|
|
112
|
-
can_read_pending_ = false;
|
|
113
|
-
doCanRead();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
Http3WTStreamJS *getJS()
|
|
118
|
-
{
|
|
119
|
-
return js_;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
void setJS(Http3WTStreamJS *js) {
|
|
123
|
-
js_ = js;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
bool gone() {
|
|
127
|
-
return !stream_;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
void setReadBuffer(void * data, size_t length) {
|
|
131
|
-
std::function<void()> task = [this, data, length]()
|
|
132
|
-
{
|
|
133
|
-
readbufsize_ = length;
|
|
134
|
-
readbufdata_ = data;
|
|
135
|
-
tryRead();
|
|
136
|
-
};
|
|
137
|
-
eventloop_->Schedule(task);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
protected:
|
|
142
|
-
// internal functions called by js object
|
|
143
|
-
void startReadingInt()
|
|
144
|
-
{
|
|
145
|
-
|
|
146
|
-
std::function<void()> task = [this]()
|
|
147
|
-
{ if (!stream_) return; // we do not have to cancel a promise?
|
|
148
|
-
tryRead(); };
|
|
149
|
-
eventloop_->Schedule(task);
|
|
150
|
-
}
|
|
151
|
-
void stopReadingInt()
|
|
152
|
-
{
|
|
153
|
-
std::function<void()> task = [this]()
|
|
154
|
-
{ doStopReading(); };
|
|
155
|
-
eventloop_->Schedule(task);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
void writeChunkIntJS(char *buffer, size_t len, Napi::ObjectReference *bufferhandle)
|
|
159
|
-
{
|
|
160
|
-
std::function<void()> task = [this, bufferhandle, buffer, len]()
|
|
161
|
-
{ writeChunkInt(buffer, len, bufferhandle); };
|
|
162
|
-
eventloop_->Schedule(task);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
void updateReadPosIntJS(size_t readbytes, uint32_t readpos)
|
|
166
|
-
{
|
|
167
|
-
std::function<void()> task = [this, readpos, readbytes]()
|
|
168
|
-
{ updateReadPosInt(readbytes, readpos); };
|
|
169
|
-
eventloop_->Schedule(task);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
void streamFinalInt()
|
|
173
|
-
{
|
|
174
|
-
std::function<void()> task = [this]()
|
|
175
|
-
{
|
|
176
|
-
send_fin_ = true;
|
|
177
|
-
tryWrite();
|
|
178
|
-
};
|
|
179
|
-
eventloop_->Schedule(task);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
void stopSendingInt(unsigned int reason)
|
|
183
|
-
{
|
|
184
|
-
std::function<void()> task = [this, reason]()
|
|
185
|
-
{
|
|
186
|
-
if (stream_)
|
|
187
|
-
{
|
|
188
|
-
stream_->SendStopSending(reason);
|
|
189
|
-
eventloop_->informAboutStreamNetworkFinish(this, NetworkTask::stopSending);
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
eventloop_->Schedule(task);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
void resetStreamInt(unsigned int reason)
|
|
196
|
-
{
|
|
197
|
-
std::function<void()> task = [this, reason]()
|
|
198
|
-
{
|
|
199
|
-
if (stream_)
|
|
200
|
-
{
|
|
201
|
-
stream_->ResetWithUserCode(reason);
|
|
202
|
-
eventloop_->informAboutStreamNetworkFinish(this, NetworkTask::resetStream);
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
eventloop_->Schedule(task);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
WebTransportStream *stream() { return stream_; }
|
|
209
|
-
|
|
210
|
-
struct WChunks
|
|
211
|
-
{
|
|
212
|
-
char *buffer;
|
|
213
|
-
size_t len;
|
|
214
|
-
Napi::ObjectReference *bufferhandle;
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
void writeChunkInt(char *buffer, size_t len, Napi::ObjectReference *bufferhandle)
|
|
218
|
-
{
|
|
219
|
-
if (fin_was_sent_ || send_fin_)
|
|
220
|
-
{
|
|
221
|
-
cancelWrite(bufferhandle);
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
if (!stream_)
|
|
225
|
-
{
|
|
226
|
-
cancelWrite(bufferhandle);
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
WChunks cur;
|
|
230
|
-
cur.buffer = buffer;
|
|
231
|
-
cur.len = len;
|
|
232
|
-
cur.bufferhandle = bufferhandle;
|
|
233
|
-
chunks_.push_back(cur);
|
|
234
|
-
tryWrite();
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
void updateReadPosInt(size_t readbytes, uint32_t readpos)
|
|
238
|
-
{
|
|
239
|
-
if (!stream_)
|
|
240
|
-
{
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
readpos_ = readpos;
|
|
244
|
-
bufferlen_ -= readbytes;
|
|
245
|
-
tryRead();
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
void cancelWrite(Napi::ObjectReference *handle);
|
|
249
|
-
|
|
250
|
-
private:
|
|
251
|
-
|
|
252
|
-
Http3WTStreamJS *js_;
|
|
253
|
-
|
|
254
|
-
WebTransportStream *stream_;
|
|
255
|
-
Http3EventLoop *eventloop_;
|
|
256
|
-
bool send_fin_ = false;
|
|
257
|
-
bool fin_was_sent_ = false;
|
|
258
|
-
bool stop_sending_received_ = false;
|
|
259
|
-
bool pause_reading_ = false;
|
|
260
|
-
bool can_read_pending_ = false;
|
|
261
|
-
bool stream_was_reset_ = false;
|
|
262
|
-
std::deque<WChunks> chunks_;
|
|
263
|
-
|
|
264
|
-
//reading stream
|
|
265
|
-
uint32_t readpos_;
|
|
266
|
-
uint32_t writepos_;
|
|
267
|
-
uint32_t bufferlen_;
|
|
268
|
-
size_t readbufsize_;
|
|
269
|
-
void * readbufdata_;
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
class Http3WTStreamJS : public Napi::ObjectWrap<Http3WTStreamJS>, public LifetimeHelper
|
|
273
|
-
{
|
|
274
|
-
public:
|
|
275
|
-
Http3WTStreamJS(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Http3WTStreamJS>(info)
|
|
276
|
-
{
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
void init(Http3WTStream *wtstream);
|
|
280
|
-
|
|
281
|
-
// nan stuff
|
|
282
|
-
|
|
283
|
-
void startReading(const Napi::CallbackInfo &info)
|
|
284
|
-
{
|
|
285
|
-
wtstream_->startReadingInt();
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
void stopReading(const Napi::CallbackInfo &info)
|
|
289
|
-
{
|
|
290
|
-
wtstream_->stopReadingInt();
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
void writeChunk(const Napi::CallbackInfo &info)
|
|
294
|
-
{
|
|
295
|
-
// ok we have to get the buffer
|
|
296
|
-
|
|
297
|
-
const Napi::Object bufferlocal = info[0].ToObject();
|
|
298
|
-
Napi::ObjectReference *bufferhandle = new Napi::ObjectReference();
|
|
299
|
-
*bufferhandle = Napi::Persistent(bufferlocal);
|
|
300
|
-
|
|
301
|
-
char *buffer = bufferlocal.As<Napi::Buffer<char>>().Data();
|
|
302
|
-
size_t len = bufferlocal.As<Napi::Buffer<char>>().Length();
|
|
303
|
-
|
|
304
|
-
wtstream_->writeChunkIntJS(buffer, len, bufferhandle);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
void updateReadPos(const Napi::CallbackInfo &info)
|
|
308
|
-
{
|
|
309
|
-
// ok we have to get the buffer
|
|
310
|
-
uint32_t readpos = 0;
|
|
311
|
-
size_t readbytes = 0;
|
|
312
|
-
|
|
313
|
-
if (!info[0].IsUndefined())
|
|
314
|
-
{
|
|
315
|
-
Napi::Number readbytesl = info[0].ToNumber();
|
|
316
|
-
readbytes = readbytesl.Uint32Value();
|
|
317
|
-
} else {
|
|
318
|
-
return Napi::Error::New(Env(), "No readbytes passed").ThrowAsJavaScriptException();
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
if (!info[1].IsUndefined())
|
|
322
|
-
{
|
|
323
|
-
Napi::Number readposl = info[1].ToNumber();
|
|
324
|
-
readpos = readposl.Uint32Value();
|
|
325
|
-
} else {
|
|
326
|
-
return Napi::Error::New(Env(), "No readpos passed").ThrowAsJavaScriptException();
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
wtstream_->updateReadPosIntJS(readbytes, readpos);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
void streamFinal(const Napi::CallbackInfo &info)
|
|
333
|
-
{
|
|
334
|
-
wtstream_->streamFinalInt();
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
void stopSending(const Napi::CallbackInfo &info)
|
|
338
|
-
{
|
|
339
|
-
unsigned int reason = 0;
|
|
340
|
-
|
|
341
|
-
if (!info[0].IsUndefined())
|
|
342
|
-
{
|
|
343
|
-
Napi::Number reasonl = info[0].ToNumber();
|
|
344
|
-
reason = reasonl.Int32Value();
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
wtstream_->stopSendingInt(reason);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
void resetStream(const Napi::CallbackInfo &info)
|
|
351
|
-
{
|
|
352
|
-
int code = 0;
|
|
353
|
-
unsigned int reason = 0;
|
|
354
|
-
|
|
355
|
-
if (!info[0].IsUndefined())
|
|
356
|
-
{
|
|
357
|
-
Napi::Number reasonl = info[0].ToNumber();
|
|
358
|
-
reason = reasonl.Int32Value();
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
wtstream_->resetStreamInt(reason);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
static void InitExports(Napi::Env env, Napi::Object exports, Http3Constructors * constr)
|
|
365
|
-
{
|
|
366
|
-
Napi::Function tplwtsv =
|
|
367
|
-
DefineClass(env, "Http3WTStreamVisitor",
|
|
368
|
-
{InstanceMethod<&Http3WTStreamJS::writeChunk>("writeChunk",
|
|
369
|
-
static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
|
|
370
|
-
InstanceMethod<&Http3WTStreamJS::updateReadPos>("updateReadPos",
|
|
371
|
-
static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
|
|
372
|
-
InstanceMethod<&Http3WTStreamJS::resetStream>("resetStream",
|
|
373
|
-
static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
|
|
374
|
-
InstanceMethod<&Http3WTStreamJS::stopSending>("stopSending", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
|
|
375
|
-
InstanceMethod<&Http3WTStreamJS::streamFinal>("streamFinal", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
|
|
376
|
-
InstanceMethod<&Http3WTStreamJS::startReading>("startReading",
|
|
377
|
-
static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
|
|
378
|
-
InstanceMethod<&Http3WTStreamJS::stopReading>("stopReading",
|
|
379
|
-
static_cast<napi_property_attributes>(napi_writable | napi_configurable))});
|
|
380
|
-
constr->stream = Napi::Persistent(tplwtsv);
|
|
381
|
-
exports.Set("Http3WTStreamVisitor", tplwtsv);
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
void setObj(Http3WTStream *wtstream)
|
|
385
|
-
{
|
|
386
|
-
wtstream_ = std::unique_ptr<Http3WTStream>(wtstream);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
Http3WTStream *getObj()
|
|
390
|
-
{
|
|
391
|
-
return wtstream_.get();
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
void doUnref() override
|
|
395
|
-
{
|
|
396
|
-
Unref();
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
protected:
|
|
400
|
-
std::unique_ptr<Http3WTStream> wtstream_;
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
#endif
|
package/test/event-loop.node.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
|
|
3
|
-
import { expect } from './fixtures/chai.js'
|
|
4
|
-
import { Http3EventLoop } from '../lib/event-loop.js'
|
|
5
|
-
|
|
6
|
-
describe.skip('event-loop', () => {
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
if (Http3EventLoop.globalLoop != null) {
|
|
9
|
-
// shut down loop, otherwise we have to wait for
|
|
10
|
-
// it to time out which takes a long time.
|
|
11
|
-
Http3EventLoop.globalLoop.shutdownEventLoop()
|
|
12
|
-
}
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('should start and stop the event loop', () => {
|
|
16
|
-
expect(Http3EventLoop.globalLoop).to.be.null()
|
|
17
|
-
|
|
18
|
-
Http3EventLoop.createGlobalEventLoop()
|
|
19
|
-
expect(Http3EventLoop.globalLoop).to.not.be.null()
|
|
20
|
-
|
|
21
|
-
Http3EventLoop.globalLoop?.shutdownEventLoop()
|
|
22
|
-
expect(Http3EventLoop.globalLoop).to.be.null()
|
|
23
|
-
})
|
|
24
|
-
})
|
package/tsconfig.json
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"strict": true,
|
|
4
|
-
// project options
|
|
5
|
-
"outDir": "dist",
|
|
6
|
-
"allowJs": true,
|
|
7
|
-
"checkJs": true,
|
|
8
|
-
"target": "ES2020",
|
|
9
|
-
"module": "ES2022",
|
|
10
|
-
"lib": ["ES2021", "ES2021.Promise", "ES2021.String", "ES2020.BigInt", "DOM", "DOM.Iterable"],
|
|
11
|
-
"noEmit": false,
|
|
12
|
-
"noEmitOnError": true,
|
|
13
|
-
"emitDeclarationOnly": true,
|
|
14
|
-
"declaration": true,
|
|
15
|
-
"declarationMap": true,
|
|
16
|
-
"incremental": true,
|
|
17
|
-
"composite": true,
|
|
18
|
-
"isolatedModules": true,
|
|
19
|
-
"removeComments": false,
|
|
20
|
-
"sourceMap": true,
|
|
21
|
-
// module resolution
|
|
22
|
-
"esModuleInterop": true,
|
|
23
|
-
"moduleResolution": "node",
|
|
24
|
-
// linter checks
|
|
25
|
-
"noImplicitReturns": false,
|
|
26
|
-
"noFallthroughCasesInSwitch": true,
|
|
27
|
-
"noUnusedLocals": true,
|
|
28
|
-
"noUnusedParameters": false,
|
|
29
|
-
// advanced
|
|
30
|
-
"forceConsistentCasingInFileNames": true,
|
|
31
|
-
"skipLibCheck": true,
|
|
32
|
-
"stripInternal": true,
|
|
33
|
-
"resolveJsonModule": true
|
|
34
|
-
},
|
|
35
|
-
"include": [
|
|
36
|
-
"lib",
|
|
37
|
-
"test"
|
|
38
|
-
]
|
|
39
|
-
}
|