@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.
Files changed (162) hide show
  1. package/lib/client.js +81 -40
  2. package/lib/dom.ts +7 -5
  3. package/lib/http2/browser/browser.js +168 -0
  4. package/lib/http2/browser/browserparser.js +248 -0
  5. package/lib/http2/flowcontroller.js +371 -0
  6. package/lib/http2/node/capsuleparser.js +291 -0
  7. package/lib/http2/node/client.js +239 -0
  8. package/lib/http2/node/index.js +2 -0
  9. package/lib/http2/node/server.js +499 -0
  10. package/lib/http2/node/websocketparser.js +829 -0
  11. package/lib/http2/parserbase.js +139 -0
  12. package/lib/http2/parserbasehttp2.js +128 -0
  13. package/lib/http2/session.js +225 -0
  14. package/lib/http2/stream.js +354 -0
  15. package/lib/http2/websocketcommon.js +1 -0
  16. package/lib/{index.js → index.browser.js} +6 -10
  17. package/lib/index.node.js +27 -0
  18. package/lib/server.js +252 -69
  19. package/lib/session.js +31 -68
  20. package/lib/stream.js +103 -179
  21. package/lib/types.ts +174 -87
  22. package/lib/utils.js +2 -1
  23. package/lib/webstreams.browser.js +6 -0
  24. package/lib/webstreams.js +7 -0
  25. package/lib/webtransport.browser.js +284 -0
  26. package/lib/webtransport.node.js +137 -0
  27. package/lib/{webtransport.js → webtransportbase.js} +47 -41
  28. package/old_test/test.js +31 -29
  29. package/old_test/testsuite.js +1 -1
  30. package/package.json +18 -17
  31. package/readme.md +94 -30
  32. package/test/bidirectional-streams.spec.js +51 -9
  33. package/test/datagrams.spec.js +8 -2
  34. package/test/fixtures/known-bytes.js +29 -0
  35. package/test/fixtures/read-stream.js +1 -1
  36. package/test/fixtures/reader-value.js +1 -1
  37. package/test/fixtures/server.js +24 -10
  38. package/test/fixtures/webtransport.browser.js +20 -2
  39. package/test/fixtures/webtransport.js +1 -1
  40. package/test/index.js +33 -6
  41. package/test/pw-no-https-errors.json +5 -0
  42. package/test/session.spec.js +71 -52
  43. package/test/unidirectional-streams.spec.js +20 -4
  44. package/CMakeLists.txt +0 -991
  45. package/LICENSE.chromium +0 -27
  46. package/LICENSE.envoy +0 -207
  47. package/build.js +0 -313
  48. package/dist/lib/client.d.ts +0 -78
  49. package/dist/lib/client.d.ts.map +0 -1
  50. package/dist/lib/dom.d.ts +0 -87
  51. package/dist/lib/dom.d.ts.map +0 -1
  52. package/dist/lib/error.d.ts +0 -8
  53. package/dist/lib/error.d.ts.map +0 -1
  54. package/dist/lib/event-loop.d.ts +0 -33
  55. package/dist/lib/event-loop.d.ts.map +0 -1
  56. package/dist/lib/index.d.ts +0 -79
  57. package/dist/lib/index.d.ts.map +0 -1
  58. package/dist/lib/native.d.ts +0 -2
  59. package/dist/lib/native.d.ts.map +0 -1
  60. package/dist/lib/server.d.ts +0 -92
  61. package/dist/lib/server.d.ts.map +0 -1
  62. package/dist/lib/session.d.ts +0 -298
  63. package/dist/lib/session.d.ts.map +0 -1
  64. package/dist/lib/stream.d.ts +0 -135
  65. package/dist/lib/stream.d.ts.map +0 -1
  66. package/dist/lib/transport.d.ts +0 -34
  67. package/dist/lib/transport.d.ts.map +0 -1
  68. package/dist/lib/types.d.ts +0 -212
  69. package/dist/lib/types.d.ts.map +0 -1
  70. package/dist/lib/utils.d.ts +0 -11
  71. package/dist/lib/utils.d.ts.map +0 -1
  72. package/dist/lib/webtransport.d.ts +0 -47
  73. package/dist/lib/webtransport.d.ts.map +0 -1
  74. package/dist/test/bidirectional-streams.spec.d.ts +0 -5
  75. package/dist/test/bidirectional-streams.spec.d.ts.map +0 -1
  76. package/dist/test/datagrams.spec.d.ts +0 -5
  77. package/dist/test/datagrams.spec.d.ts.map +0 -1
  78. package/dist/test/event-loop.node.d.ts +0 -2
  79. package/dist/test/event-loop.node.d.ts.map +0 -1
  80. package/dist/test/fixtures/certificate.d.ts +0 -21
  81. package/dist/test/fixtures/certificate.d.ts.map +0 -1
  82. package/dist/test/fixtures/chai.d.ts +0 -2
  83. package/dist/test/fixtures/chai.d.ts.map +0 -1
  84. package/dist/test/fixtures/known-bytes.d.ts +0 -6
  85. package/dist/test/fixtures/known-bytes.d.ts.map +0 -1
  86. package/dist/test/fixtures/p-timeout.d.ts +0 -8
  87. package/dist/test/fixtures/p-timeout.d.ts.map +0 -1
  88. package/dist/test/fixtures/read-cert-hash.d.ts +0 -6
  89. package/dist/test/fixtures/read-cert-hash.d.ts.map +0 -1
  90. package/dist/test/fixtures/read-stream.d.ts +0 -19
  91. package/dist/test/fixtures/read-stream.d.ts.map +0 -1
  92. package/dist/test/fixtures/reader-value.d.ts +0 -22
  93. package/dist/test/fixtures/reader-value.d.ts.map +0 -1
  94. package/dist/test/fixtures/server.d.ts +0 -5
  95. package/dist/test/fixtures/server.d.ts.map +0 -1
  96. package/dist/test/fixtures/webtransport.browser.d.ts +0 -3
  97. package/dist/test/fixtures/webtransport.browser.d.ts.map +0 -1
  98. package/dist/test/fixtures/webtransport.d.ts +0 -3
  99. package/dist/test/fixtures/webtransport.d.ts.map +0 -1
  100. package/dist/test/fixtures/write-stream.d.ts +0 -10
  101. package/dist/test/fixtures/write-stream.d.ts.map +0 -1
  102. package/dist/test/index.d.ts +0 -2
  103. package/dist/test/index.d.ts.map +0 -1
  104. package/dist/test/session.spec.d.ts +0 -5
  105. package/dist/test/session.spec.d.ts.map +0 -1
  106. package/dist/test/unidirectional-streams.spec.d.ts +0 -2
  107. package/dist/test/unidirectional-streams.spec.d.ts.map +0 -1
  108. package/failslogolicensereadme.txt +0 -4
  109. package/lib/event-loop.js +0 -88
  110. package/lib/native.js +0 -28
  111. package/lib/transport.js +0 -82
  112. package/platform/icufix/fakedata.cpp +0 -8
  113. package/platform/quiche/quic/core/io/socket_win.inc +0 -3
  114. package/platform/quiche_platform_impl/quiche_bug_tracker_impl.h +0 -7
  115. package/platform/quiche_platform_impl/quiche_client_stats_impl.h +0 -7
  116. package/platform/quiche_platform_impl/quiche_command_line_flags_impl.h +0 -7
  117. package/platform/quiche_platform_impl/quiche_containers_impl.h +0 -7
  118. package/platform/quiche_platform_impl/quiche_event_loop_impl.h +0 -7
  119. package/platform/quiche_platform_impl/quiche_export_impl.h +0 -6
  120. package/platform/quiche_platform_impl/quiche_flag_utils_impl.h +0 -11
  121. package/platform/quiche_platform_impl/quiche_flags_impl.h +0 -8
  122. package/platform/quiche_platform_impl/quiche_iovec_impl.h +0 -10
  123. package/platform/quiche_platform_impl/quiche_logging_impl.h +0 -21
  124. package/platform/quiche_platform_impl/quiche_mem_slice_impl.h +0 -2
  125. package/platform/quiche_platform_impl/quiche_mutex_impl.h +0 -8
  126. package/platform/quiche_platform_impl/quiche_prefetch_impl.h +0 -11
  127. package/platform/quiche_platform_impl/quiche_reference_counted_impl.h +0 -16
  128. package/platform/quiche_platform_impl/quiche_server_stats_impl.h +0 -7
  129. package/platform/quiche_platform_impl/quiche_stack_trace_impl.h +0 -12
  130. package/platform/quiche_platform_impl/quiche_stream_buffer_allocator_impl.h +0 -8
  131. package/platform/quiche_platform_impl/quiche_testvalue_impl.h +0 -1
  132. package/platform/quiche_platform_impl/quiche_thread_local_impl.h +0 -6
  133. package/platform/quiche_platform_impl/quiche_time_utils_impl.h +0 -13
  134. package/platform/quiche_platform_impl/quiche_udp_socket_platform_impl.h +0 -39
  135. package/src/http3backendresponse.cc +0 -36
  136. package/src/http3backendresponse.h +0 -109
  137. package/src/http3client.cc +0 -1529
  138. package/src/http3client.h +0 -557
  139. package/src/http3clientsession.cc +0 -65
  140. package/src/http3clientsession.h +0 -60
  141. package/src/http3clientstream.cc +0 -52
  142. package/src/http3clientstream.h +0 -42
  143. package/src/http3dispatcher.cc +0 -62
  144. package/src/http3dispatcher.h +0 -57
  145. package/src/http3eventloop.cc +0 -1107
  146. package/src/http3eventloop.h +0 -316
  147. package/src/http3server.cc +0 -514
  148. package/src/http3server.h +0 -151
  149. package/src/http3serverbackend.cc +0 -105
  150. package/src/http3serverbackend.h +0 -98
  151. package/src/http3serversession.cc +0 -123
  152. package/src/http3serversession.h +0 -95
  153. package/src/http3serverstream.cc +0 -463
  154. package/src/http3serverstream.h +0 -114
  155. package/src/http3sessioncache.cc +0 -85
  156. package/src/http3sessioncache.h +0 -59
  157. package/src/http3wtsessionvisitor.cc +0 -46
  158. package/src/http3wtsessionvisitor.h +0 -397
  159. package/src/http3wtstreamvisitor.cc +0 -155
  160. package/src/http3wtstreamvisitor.h +0 -404
  161. package/test/event-loop.node.js +0 -24
  162. package/tsconfig.json +0 -39
package/lib/stream.js CHANGED
@@ -1,8 +1,9 @@
1
- import { ReadableStream, WritableStream } from 'node:stream/web'
1
+ import { ReadableStream, WritableStream } from './webstreams.js'
2
2
  import { logger } from './utils.js'
3
3
  import { WebTransportError } from './error.js'
4
4
 
5
- const log = logger(`webtransport:http3wtstream(${process.pid})`)
5
+ const pid = typeof process !== 'undefined' ? process.pid : 0
6
+ const log = logger(`webtransport:http3wtstream(${pid})`)
6
7
 
7
8
  /**
8
9
  * WebTransport stream events
@@ -10,24 +11,24 @@ const log = logger(`webtransport:http3wtstream(${process.pid})`)
10
11
  * @typedef {import('./types').StreamRecvSignalEvent} StreamRecvSignalEvent
11
12
  * @typedef {import('./types').StreamReadEvent} StreamReadEvent
12
13
  * @typedef {import('./types').StreamWriteEvent} StreamWriteEvent
13
- * @typedef {import('./types').StreamResetEvent} StreamResetEvent
14
14
  * @typedef {import('./types').StreamNetworkFinishEvent} StreamNetworkFinishEvent
15
15
  *
16
- * @typedef {import('./types').NativeHttp3WTStream} NativeHttp3WTStream
16
+ * @typedef {import('./types').NativeHttpWTStream} NativeHttpWTStream
17
+ * @typedef {import('./types').ReadBuffer} ReadBuffer
17
18
  *
18
19
  * @typedef {import('./dom').WebTransportReceiveStream} WebTransportReceiveStream
19
20
  * @typedef {import('./dom').WebTransportSendStream} WebTransportSendStream
20
21
  *
21
- * @typedef {import('./session').Http3WTSession} Http3WTSession
22
+ * @typedef {import('./session').HttpWTSession} HttpWTSession
22
23
  *
23
24
  * @typedef {import('stream/web').WritableStreamDefaultController} WritableStreamDefaultController
24
25
  */
25
26
 
26
- export class Http3WTStream {
27
+ export class HttpWTStream {
27
28
  /**
28
29
  * @param {object} args
29
- * @param {NativeHttp3WTStream} args.object
30
- * @param {Http3WTSession} args.parentobj
30
+ * @param {NativeHttpWTStream} args.object
31
+ * @param {HttpWTSession} args.parentobj
31
32
  * @param {object} args.transport
32
33
  * @param {boolean} args.bidirectional
33
34
  * @param {boolean} args.incoming
@@ -41,6 +42,10 @@ export class Http3WTStream {
41
42
  this.incoming = args.incoming
42
43
  this.closed = false
43
44
 
45
+ if (this.objint.sendInitialParameters) {
46
+ this.objint.sendInitialParameters()
47
+ }
48
+
44
49
  /** @type {Promise<void> | null} */
45
50
  this.pendingoperation = null
46
51
  this.pendingres = null
@@ -55,12 +60,6 @@ export class Http3WTStream {
55
60
  this.pendingresRead = null
56
61
 
57
62
  if (this.bidirectional || this.incoming) {
58
- /** @type {Number} */
59
- this.incomingbufferfilled = 0
60
- /** @type {Number} */
61
- this.incomingbufferreadpos = 0
62
- if (!this.objint.readbuffer)
63
- throw new Error('No readbuffer for read stream')
64
63
  /** @type {WebTransportReceiveStream} */
65
64
  // @ts-expect-error `getStats` property is missing from ReadableStream
66
65
  this.readable = new ReadableStream(
@@ -78,16 +77,11 @@ export class Http3WTStream {
78
77
  return Promise.resolve()
79
78
  }
80
79
 
81
- /** @type {Uint8Array} */
82
- if (this.incomingbufferfilled === 0) {
83
- this.pendingoperationRead = new Promise((resolve, reject) => {
84
- this.pendingresRead = resolve
85
- })
86
- await this.pendingoperationRead
87
- }
88
- if (this.incomingbufferfilled === 0) return Promise.resolve()
89
-
90
- this.drainBuffer()
80
+ this.pendingoperationRead = new Promise((resolve, reject) => {
81
+ this.pendingresRead = resolve
82
+ })
83
+ this.objint.startReading()
84
+ await this.pendingoperationRead
91
85
  },
92
86
  cancel: (/** @type {{ code: number; }} */ reason) => {
93
87
  /** @type {Promise<void>} */
@@ -131,14 +125,18 @@ export class Http3WTStream {
131
125
  if (this.writableclosed) {
132
126
  return Promise.resolve()
133
127
  }
134
- if (chunk instanceof Uint8Array) {
128
+ let wchunk = chunk
129
+ if (wchunk instanceof ArrayBuffer) {
130
+ wchunk = new Uint8Array(wchunk)
131
+ }
132
+ if (wchunk instanceof Uint8Array) {
135
133
  this.pendingoperation = new Promise((resolve, reject) => {
136
134
  this.pendingres = resolve
137
135
  })
138
136
  this.parentobj
139
137
  .waitForDatagramsSend()
140
138
  .finally(() => {
141
- this.objint.writeChunk(chunk)
139
+ this.objint.writeChunk(wchunk)
142
140
  })
143
141
  .catch((/** @type {any} */ err) => {
144
142
  log.error(err)
@@ -146,7 +144,9 @@ export class Http3WTStream {
146
144
  return this.pendingoperation
147
145
  } else {
148
146
  log.trace('chunk info:', chunk)
149
- throw new Error('chunk is not of instanceof Uint8Array ')
147
+ throw new Error(
148
+ 'chunk is not of instanceof Uint8Array or Arraybuffer'
149
+ )
150
150
  }
151
151
  },
152
152
  close: () => {
@@ -199,62 +199,69 @@ export class Http3WTStream {
199
199
  this.pendingres = null
200
200
  /** @type {(() => void) | null} */
201
201
  this.abortres = null
202
+
203
+ this.finaldrain_ = false
202
204
  }
203
205
 
204
- drainBuffer() {
206
+ /**
207
+ * @param {{byteSize: number}} args
208
+ * @returns {ReadBuffer}
209
+ */
210
+ getReadBuffer({ byteSize }) {
205
211
  const byob = this.readableController.byobRequest
206
- // @ts-ignore
207
- const view = byob?.view
208
- // @ts-ignore
209
- if (!(byob?.view instanceof Uint8Array))
210
- throw new Error('byob view is not a Uint8Array')
211
- let toread = Math.min(view.byteLength, this.incomingbufferfilled)
212
- let read = 0
213
- if (!this.objint.readbuffer)
214
- throw new Error('No readbuffer in read for read stream')
215
- if (
216
- this.incomingbufferreadpos + toread >
217
- this.objint.readbuffer.byteLength
218
- ) {
219
- /** @type {Number} */
220
- const firstread =
221
- this.objint.readbuffer.byteLength - this.incomingbufferreadpos
222
- read += firstread
223
- toread -= firstread
224
- const destview = new Uint8Array(
225
- view.buffer,
226
- 0 + view.byteOffset,
227
- firstread
228
- )
229
- const srcview = new Uint8Array(
230
- this.objint.readbuffer,
231
- this.incomingbufferreadpos,
232
- firstread
233
- )
234
- destview.set(srcview)
235
- this.incomingbufferreadpos = 0
212
+ if (byob) {
213
+ // @ts-ignore
214
+ const buffer = byob?.view
215
+ // @ts-ignore
216
+ if (!(buffer instanceof Uint8Array)) {
217
+ throw new Error('byob view is not a Uint8Array')
218
+ }
219
+ return { buffer, byob, readBytes: 0, fin: false }
220
+ } else {
221
+ const buffer = new Uint8Array(byteSize)
222
+ return { buffer, byob: undefined, readBytes: 0, fin: false }
236
223
  }
237
- {
238
- const destview = new Uint8Array(
239
- view.buffer,
240
- read + view.byteOffset,
241
- toread
242
- )
243
- const srcview = new Uint8Array(
244
- this.objint.readbuffer,
245
- this.incomingbufferreadpos,
246
- toread
247
- )
248
- destview.set(srcview)
249
- read += toread
250
- this.incomingbufferreadpos =
251
- (this.incomingbufferreadpos + toread) %
252
- this.objint.readbuffer.byteLength
224
+ }
225
+
226
+ /**
227
+ * @param {ReadBuffer} args
228
+ */
229
+ commitReadBuffer({ buffer, byob, drained, readBytes, fin }) {
230
+ if (!this.readableclosed) {
231
+ if (byob && readBytes !== undefined) {
232
+ byob.respond(readBytes)
233
+ } else if (buffer) {
234
+ this.readableController.enqueue(buffer)
235
+ }
253
236
  }
254
- // @ts-ignore
255
- byob.respond(read)
256
- this.incomingbufferfilled -= read
257
- this.objint.updateReadPos(read, this.incomingbufferreadpos)
237
+ const retObj = {}
238
+
239
+ if (readBytes !== undefined && readBytes > 0 && !this.readableclosed) {
240
+ log.trace('commitReadbuffer', readBytes)
241
+ // console.log('stream read received', args.data, Date.now())
242
+ if (this.pendingoperationRead && drained) {
243
+ if (this.readableController.desiredSize != null && !this.finaldrain_) {
244
+ if (this.readableController.desiredSize < 0) retObj.stopReading = true
245
+ }
246
+ // this.readableController.enqueue(data)
247
+ const res = this.pendingresRead
248
+ this.pendingoperationRead = null
249
+ this.pendingresRead = null
250
+ if (res) res()
251
+ }
252
+ }
253
+ if (fin) {
254
+ if (this.cancelres) {
255
+ const res = this.cancelres
256
+ this.cancelres = null
257
+ res()
258
+ }
259
+ if (!this.readableclosed) {
260
+ this.readableController.close()
261
+ this.readableclosed = true
262
+ }
263
+ }
264
+ return retObj
258
265
  }
259
266
 
260
267
  /**
@@ -262,7 +269,7 @@ export class Http3WTStream {
262
269
  * @returns {void}
263
270
  */
264
271
  onStreamRecvSignal(args) {
265
- log('callback', args?.purpose, args?.nettask)
272
+ log('callback', args?.nettask)
266
273
  log.trace('onStreamRecvSignal', args)
267
274
  // check if transport is closed
268
275
  let parentcleanup = true
@@ -274,6 +281,7 @@ export class Http3WTStream {
274
281
  switch (args.nettask) {
275
282
  case 'resetStream':
276
283
  if (this.readable) {
284
+ this.finalDrain()
277
285
  if (parentcleanup)
278
286
  this.parentobj.removeReceiveStream(
279
287
  this.readable,
@@ -326,46 +334,9 @@ export class Http3WTStream {
326
334
  }
327
335
  }
328
336
 
329
- /**
330
- * @param {StreamReadEvent} args
331
- * @returns {void}
332
- */
333
- onStreamRead(args) {
334
- if (args.buffergrow && !this.readableclosed) {
335
- log.trace('stream read received', args.buffergrow)
336
- this.incomingbufferfilled += args.buffergrow
337
- // console.log('stream read received', args.data, Date.now())
338
- if (this.pendingoperationRead) {
339
- // this.readableController.enqueue(data)
340
- const res = this.pendingresRead
341
- this.pendingoperationRead = null
342
- this.pendingresRead = null
343
- if (res) res()
344
- }
345
- if (
346
- this.readableController.desiredSize != null &&
347
- this.readableController.desiredSize < 0
348
- )
349
- this.objint.stopReading()
350
- }
351
- if (args.fin) {
352
- if (this.incomingbufferfilled > 0) {
353
- log.trace('Warning buffer filled and we got a fin')
354
- if (this.pendingoperationRead || this.pendingresRead)
355
- throw new Error('We have pendingoperationRead and a filled buffer?')
356
-
357
- this.drainBuffer()
358
- }
359
- if (this.cancelres) {
360
- const res = this.cancelres
361
- this.cancelres = null
362
- res()
363
- }
364
- if (!this.readableclosed) {
365
- this.readableController.close()
366
- this.readableclosed = true
367
- }
368
- }
337
+ finalDrain() {
338
+ this.finaldrain_ = true
339
+ this.objint.drainReads()
369
340
  }
370
341
 
371
342
  /**
@@ -383,29 +354,11 @@ export class Http3WTStream {
383
354
  }
384
355
  }
385
356
 
386
- /**
387
- * @param {StreamResetEvent} args
388
- */
389
- onStreamReset(args) {
390
- if (this.abortres) {
391
- this.abortres()
392
- if (this.readable)
393
- this.parentobj.removeReceiveStream(
394
- this.readable,
395
- this.readableController
396
- )
397
- if (this.writable)
398
- this.parentobj.removeSendStream(this.writable, this.writableController)
399
- this.readableclosed = true
400
- this.parentobj.removeStreamObj(this)
401
- }
402
- }
403
-
404
357
  /**
405
358
  * @param {StreamNetworkFinishEvent} args
406
359
  */
407
360
  onStreamNetworkFinish(args) {
408
- log('callback', args?.purpose)
361
+ log('callback', args?.nettask)
409
362
  log.trace('networkfinish args', args)
410
363
  switch (args.nettask) {
411
364
  case 'stopSending':
@@ -421,6 +374,18 @@ export class Http3WTStream {
421
374
  const res = this.abortres
422
375
  this.abortres = null
423
376
  res()
377
+ if (this.readable)
378
+ this.parentobj.removeReceiveStream(
379
+ this.readable,
380
+ this.readableController
381
+ )
382
+ if (this.writable)
383
+ this.parentobj.removeSendStream(
384
+ this.writable,
385
+ this.writableController
386
+ )
387
+ this.readableclosed = true
388
+ this.parentobj.removeStreamObj(this)
424
389
  }
425
390
 
426
391
  break
@@ -440,45 +405,4 @@ export class Http3WTStream {
440
405
  }
441
406
  // we could differentiate....
442
407
  }
443
-
444
- /**
445
- * @param {StreamRecvSignalEvent | StreamReadEvent | StreamWriteEvent | StreamResetEvent | StreamNetworkFinishEvent} args
446
- */
447
- static callback(args) {
448
- log('callback', args?.purpose)
449
- log.trace(log)
450
- if (!args || !args.object || !args.object.jsobj)
451
- throw new Error('Stream callback without jsobj')
452
- const visitor = args.object.jsobj
453
- if (args.purpose) {
454
- switch (args.purpose) {
455
- case 'StreamRecvSignal':
456
- visitor.onStreamRecvSignal(args)
457
- break
458
- case 'StreamRead':
459
- if (
460
- visitor &&
461
- Object.prototype.hasOwnProperty.call(args, 'buffergrow')
462
- ) {
463
- visitor.onStreamRead(args)
464
- } else {
465
- throw new Error('Malformed StreamRead')
466
- }
467
- break
468
- case 'StreamWrite':
469
- visitor.onStreamWrite(args)
470
- break
471
- case 'StreamReset':
472
- visitor.onStreamReset(args)
473
- break
474
- case 'StreamNetworkFinish':
475
- visitor.onStreamNetworkFinish(args)
476
-
477
- break
478
- default: {
479
- throw new Error('unknown purpose Streamcb')
480
- }
481
- }
482
- } else throw new Error('no purpose Streamcb')
483
- }
484
408
  }