@fails-components/webtransport 1.0.6 → 1.0.9

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 (158) hide show
  1. package/dist/lib/client.d.ts.map +1 -0
  2. package/dist/{main/lib → lib}/dom.d.ts +10 -2
  3. package/dist/lib/dom.d.ts.map +1 -0
  4. package/dist/lib/error.d.ts.map +1 -0
  5. package/dist/lib/features.d.ts +2 -0
  6. package/dist/lib/features.d.ts.map +1 -0
  7. package/dist/{main/lib → lib}/http2/browser/browser.d.ts +2 -0
  8. package/dist/lib/http2/browser/browser.d.ts.map +1 -0
  9. package/dist/lib/http2/browser/browserparser.d.ts.map +1 -0
  10. package/dist/{main/lib → lib}/http2/flowcontroller.d.ts +1 -1
  11. package/dist/lib/http2/flowcontroller.d.ts.map +1 -0
  12. package/dist/{main/lib → lib}/http2/node/capsuleparser.d.ts +1 -1
  13. package/dist/lib/http2/node/capsuleparser.d.ts.map +1 -0
  14. package/dist/{main/lib → lib}/http2/node/client.d.ts +2 -0
  15. package/dist/lib/http2/node/client.d.ts.map +1 -0
  16. package/dist/{main/test → lib/http2/node}/index.d.ts.map +1 -1
  17. package/dist/{main/lib → lib}/http2/node/server.d.ts +3 -0
  18. package/dist/lib/http2/node/server.d.ts.map +1 -0
  19. package/dist/{main/lib → lib}/http2/node/websocketparser.d.ts +4 -2
  20. package/dist/lib/http2/node/websocketparser.d.ts.map +1 -0
  21. package/dist/{main/lib → lib}/http2/parserbase.d.ts +26 -9
  22. package/dist/lib/http2/parserbase.d.ts.map +1 -0
  23. package/dist/lib/http2/parserbasehttp2.d.ts.map +1 -0
  24. package/dist/{main/lib → lib}/http2/session.d.ts +43 -6
  25. package/dist/lib/http2/session.d.ts.map +1 -0
  26. package/dist/{main/lib → lib}/http2/stream.d.ts +29 -7
  27. package/dist/lib/http2/stream.d.ts.map +1 -0
  28. package/dist/lib/http2/streamidmanager.d.ts +72 -0
  29. package/dist/lib/http2/streamidmanager.d.ts.map +1 -0
  30. package/dist/lib/http2/websocketcommon.d.ts.map +1 -0
  31. package/dist/lib/index.browser.d.ts.map +1 -0
  32. package/dist/lib/index.node.d.ts.map +1 -0
  33. package/dist/lib/server.d.ts.map +1 -0
  34. package/dist/{main/lib → lib}/session.d.ts +11 -4
  35. package/dist/lib/session.d.ts.map +1 -0
  36. package/dist/lib/stream.d.ts.map +1 -0
  37. package/dist/{main/lib → lib}/types.d.ts +26 -4
  38. package/dist/lib/types.d.ts.map +1 -0
  39. package/dist/lib/utils.d.ts.map +1 -0
  40. package/dist/lib/webstreams.browser.d.ts.map +1 -0
  41. package/dist/lib/webstreams.d.ts.map +1 -0
  42. package/dist/{main/lib → lib}/webtransport.browser.d.ts +12 -2
  43. package/dist/lib/webtransport.browser.d.ts.map +1 -0
  44. package/dist/lib/webtransport.node.d.ts.map +1 -0
  45. package/dist/{main/lib → lib}/webtransportbase.d.ts +14 -2
  46. package/dist/lib/webtransportbase.d.ts.map +1 -0
  47. package/lib/dom.ts +12 -2
  48. package/lib/features.js +16 -0
  49. package/lib/http2/browser/browser.js +12 -3
  50. package/lib/http2/browser/browserparser.js +36 -36
  51. package/lib/http2/flowcontroller.js +2 -2
  52. package/lib/http2/node/capsuleparser.js +58 -51
  53. package/lib/http2/node/client.js +12 -3
  54. package/lib/http2/node/server.js +53 -16
  55. package/lib/http2/node/websocketparser.js +69 -59
  56. package/lib/http2/parserbase.js +87 -12
  57. package/lib/http2/session.js +109 -34
  58. package/lib/http2/stream.js +65 -10
  59. package/lib/http2/streamidmanager.js +316 -0
  60. package/lib/session.js +47 -15
  61. package/lib/stream.js +46 -39
  62. package/lib/types.ts +20 -4
  63. package/lib/webtransport.browser.js +14 -4
  64. package/lib/webtransportbase.js +14 -4
  65. package/package.json +5 -2
  66. package/readme.md +4 -3
  67. package/test/fixtures/certificate.js +1 -2
  68. package/test/fixtures/server.js +112 -7
  69. package/test/fixtures/webtransport.browser.js +1 -1
  70. package/test/index.js +1 -1
  71. package/test/stream-limits.spec.js +247 -0
  72. package/tsconfig.json +2 -7
  73. package/dist/main/lib/client.d.ts.map +0 -1
  74. package/dist/main/lib/dom.d.ts.map +0 -1
  75. package/dist/main/lib/error.d.ts.map +0 -1
  76. package/dist/main/lib/http2/browser/browser.d.ts.map +0 -1
  77. package/dist/main/lib/http2/browser/browserparser.d.ts.map +0 -1
  78. package/dist/main/lib/http2/flowcontroller.d.ts.map +0 -1
  79. package/dist/main/lib/http2/node/capsuleparser.d.ts.map +0 -1
  80. package/dist/main/lib/http2/node/client.d.ts.map +0 -1
  81. package/dist/main/lib/http2/node/index.d.ts.map +0 -1
  82. package/dist/main/lib/http2/node/server.d.ts.map +0 -1
  83. package/dist/main/lib/http2/node/websocketparser.d.ts.map +0 -1
  84. package/dist/main/lib/http2/parserbase.d.ts.map +0 -1
  85. package/dist/main/lib/http2/parserbasehttp2.d.ts.map +0 -1
  86. package/dist/main/lib/http2/session.d.ts.map +0 -1
  87. package/dist/main/lib/http2/stream.d.ts.map +0 -1
  88. package/dist/main/lib/http2/websocketcommon.d.ts.map +0 -1
  89. package/dist/main/lib/index.browser.d.ts.map +0 -1
  90. package/dist/main/lib/index.node.d.ts.map +0 -1
  91. package/dist/main/lib/server.d.ts.map +0 -1
  92. package/dist/main/lib/session.d.ts.map +0 -1
  93. package/dist/main/lib/stream.d.ts.map +0 -1
  94. package/dist/main/lib/types.d.ts.map +0 -1
  95. package/dist/main/lib/utils.d.ts.map +0 -1
  96. package/dist/main/lib/webstreams.browser.d.ts.map +0 -1
  97. package/dist/main/lib/webstreams.d.ts.map +0 -1
  98. package/dist/main/lib/webtransport.browser.d.ts.map +0 -1
  99. package/dist/main/lib/webtransport.node.d.ts.map +0 -1
  100. package/dist/main/lib/webtransportbase.d.ts.map +0 -1
  101. package/dist/main/test/bidirectional-streams.spec.d.ts +0 -5
  102. package/dist/main/test/bidirectional-streams.spec.d.ts.map +0 -1
  103. package/dist/main/test/datagrams.spec.d.ts +0 -5
  104. package/dist/main/test/datagrams.spec.d.ts.map +0 -1
  105. package/dist/main/test/fixtures/certificate.d.ts +0 -21
  106. package/dist/main/test/fixtures/certificate.d.ts.map +0 -1
  107. package/dist/main/test/fixtures/chai.d.ts +0 -2
  108. package/dist/main/test/fixtures/chai.d.ts.map +0 -1
  109. package/dist/main/test/fixtures/known-bytes.d.ts +0 -8
  110. package/dist/main/test/fixtures/known-bytes.d.ts.map +0 -1
  111. package/dist/main/test/fixtures/p-timeout.d.ts +0 -8
  112. package/dist/main/test/fixtures/p-timeout.d.ts.map +0 -1
  113. package/dist/main/test/fixtures/read-cert-hash.d.ts +0 -6
  114. package/dist/main/test/fixtures/read-cert-hash.d.ts.map +0 -1
  115. package/dist/main/test/fixtures/read-stream.d.ts +0 -18
  116. package/dist/main/test/fixtures/read-stream.d.ts.map +0 -1
  117. package/dist/main/test/fixtures/reader-value.d.ts +0 -21
  118. package/dist/main/test/fixtures/reader-value.d.ts.map +0 -1
  119. package/dist/main/test/fixtures/server.d.ts +0 -5
  120. package/dist/main/test/fixtures/server.d.ts.map +0 -1
  121. package/dist/main/test/fixtures/webtransport.browser.d.ts +0 -4
  122. package/dist/main/test/fixtures/webtransport.browser.d.ts.map +0 -1
  123. package/dist/main/test/fixtures/webtransport.d.ts +0 -3
  124. package/dist/main/test/fixtures/webtransport.d.ts.map +0 -1
  125. package/dist/main/test/fixtures/write-stream.d.ts +0 -10
  126. package/dist/main/test/fixtures/write-stream.d.ts.map +0 -1
  127. package/dist/main/test/index.d.ts +0 -2
  128. package/dist/main/test/session.spec.d.ts +0 -5
  129. package/dist/main/test/session.spec.d.ts.map +0 -1
  130. package/dist/main/test/unidirectional-streams.spec.d.ts +0 -2
  131. package/dist/main/test/unidirectional-streams.spec.d.ts.map +0 -1
  132. package/dist/main/tsconfig.tsbuildinfo +0 -1
  133. package/dist/transports/http3-quiche/lib/clientsocket.d.ts +0 -19
  134. package/dist/transports/http3-quiche/lib/clientsocket.d.ts.map +0 -1
  135. package/dist/transports/http3-quiche/lib/index.d.ts +0 -11
  136. package/dist/transports/http3-quiche/lib/index.d.ts.map +0 -1
  137. package/dist/transports/http3-quiche/lib/serversocket.d.ts +0 -12
  138. package/dist/transports/http3-quiche/lib/serversocket.d.ts.map +0 -1
  139. package/dist/transports/http3-quiche/lib/socket.d.ts +0 -19
  140. package/dist/transports/http3-quiche/lib/socket.d.ts.map +0 -1
  141. package/dist/transports/http3-quiche/lib/types.d.ts +0 -21
  142. package/dist/transports/http3-quiche/lib/types.d.ts.map +0 -1
  143. package/dist/transports/http3-quiche/lib/utils.d.ts +0 -6
  144. package/dist/transports/http3-quiche/lib/utils.d.ts.map +0 -1
  145. /package/dist/{main/lib → lib}/client.d.ts +0 -0
  146. /package/dist/{main/lib → lib}/error.d.ts +0 -0
  147. /package/dist/{main/lib → lib}/http2/browser/browserparser.d.ts +0 -0
  148. /package/dist/{main/lib → lib}/http2/node/index.d.ts +0 -0
  149. /package/dist/{main/lib → lib}/http2/parserbasehttp2.d.ts +0 -0
  150. /package/dist/{main/lib → lib}/http2/websocketcommon.d.ts +0 -0
  151. /package/dist/{main/lib → lib}/index.browser.d.ts +0 -0
  152. /package/dist/{main/lib → lib}/index.node.d.ts +0 -0
  153. /package/dist/{main/lib → lib}/server.d.ts +0 -0
  154. /package/dist/{main/lib → lib}/stream.d.ts +0 -0
  155. /package/dist/{main/lib → lib}/utils.d.ts +0 -0
  156. /package/dist/{main/lib → lib}/webstreams.browser.d.ts +0 -0
  157. /package/dist/{main/lib → lib}/webstreams.d.ts +0 -0
  158. /package/dist/{main/lib → lib}/webtransport.node.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import type { WebTransportSession, WebTransportHash, WebTransportOptions } from './dom';
3
+ import type { WebTransportSession, WebTransportHash, WebTransportOptions, WebTransportSendGroup } from './dom';
4
4
  import type { IncomingHttpHeaders, Http2Stream } from 'http2';
5
5
  import { ParserBase } from './http2/parserbase';
6
6
  import { Http2WebTransportSession } from './http2/session';
@@ -12,8 +12,16 @@ export interface NativeHttpWTSession {
12
12
  jsobj: WebTransportSessionEventHandler;
13
13
  sendInitialParameters?: () => void;
14
14
  writeDatagram: (chunk: Uint8Array) => void;
15
- orderUnidiStream: () => void;
16
- orderBidiStream: () => void;
15
+ orderUnidiStream: (opts: {
16
+ sendGroup: WebTransportSendGroup | null;
17
+ sendOrder: number;
18
+ waitUntilAvailable: boolean;
19
+ }) => boolean;
20
+ orderBidiStream: (opts: {
21
+ sendGroup: WebTransportSendGroup | null;
22
+ sendOrder: number;
23
+ waitUntilAvailable: boolean;
24
+ }) => boolean;
17
25
  orderSessionStats: () => void;
18
26
  orderDatagramStats: () => void;
19
27
  notifySessionDraining: () => void;
@@ -45,12 +53,18 @@ export interface NativeServerOptions {
45
53
  certhttp2?: string;
46
54
  privKey: string;
47
55
  privKeyhttp2?: string;
56
+ initialBidirectionalSendStreams?: number;
57
+ initialBidirectionalReceiveStreams?: number;
58
+ initialUnidirectionalSendStreams?: number;
59
+ initialUnidirectionalReceiveStreams?: number;
48
60
  initialStreamFlowControlWindow?: number;
49
61
  streamShouldAutoTuneReceiveWindow?: boolean;
50
62
  streamFlowControlWindowSizeLimit?: number;
51
63
  initialSessionFlowControlWindow?: number;
52
64
  sessionShouldAutoTuneReceiveWindow?: boolean;
53
65
  sessionFlowControlWindowSizeLimit?: number;
66
+ initialBidirectionalStreams?: number;
67
+ initialUnidirectionalStreams?: number;
54
68
  }
55
69
  export interface NativeClientOptions {
56
70
  port: number;
@@ -59,6 +73,10 @@ export interface NativeClientOptions {
59
73
  localPort: number;
60
74
  allowPooling: boolean;
61
75
  forceIpv6: boolean;
76
+ initialBidirectionalSendStreams?: number;
77
+ initialBidirectionalReceiveStreams?: number;
78
+ initialUnidirectionalSendStreams?: number;
79
+ initialUnidirectionalReceiveStreams?: number;
62
80
  initialStreamFlowControlWindow?: number;
63
81
  streamShouldAutoTuneReceiveWindow?: boolean;
64
82
  streamFlowControlWindowSizeLimit?: number;
@@ -76,6 +94,10 @@ export interface FlowControlable {
76
94
  }) => void;
77
95
  smoothedRtt: () => number;
78
96
  }
97
+ export interface StreamIdClient {
98
+ canSendMaxStreams: () => boolean;
99
+ sendMaxStreams: (maxStreams: bigint, unidirectional: boolean) => void;
100
+ }
79
101
  export interface ReadBuffer {
80
102
  buffer?: Uint8Array;
81
103
  readBytes?: number;
@@ -271,7 +293,7 @@ export interface ParserWebsocketInit extends ParserInit {
271
293
  ws: WebSocket;
272
294
  }
273
295
  export interface ReadDataInt {
274
- data: Uint8Array;
296
+ data: Uint8Array | undefined;
275
297
  fin: boolean;
276
298
  }
277
299
  //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,+BAA+B,CAAA;IACtC,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAA;IAClC,aAAa,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IAC1C,gBAAgB,EAAE,CAAC,IAAI,EAAC;QAAC,SAAS,EAAG,qBAAqB,GAAC,IAAI,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,kBAAkB,EAAE,OAAO,CAAA;KAAC,KAAK,OAAO,CAAA;IAC5H,eAAe,EAAE,CAAC,IAAI,EAAC;QAAC,SAAS,E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C,KAAK,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;CAChD;AAED,MAAM,MAAM,oBAAoB,GAAG,CACjC,aAAa,EAAE,wBAAwB,KACpC,UAAU,CAAA;AAEf,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,OAAO,CAAA;IACjB,aAAa,EAAE,GAAG,CAAA;IAClB,6BAA6B,EAAE,MAAM,CAAA;IACrC,gCAAgC,EAAE,MAAM,CAAA;IACxC,iCAAiC,EAAE,OAAO,CAAA;IAC1C,4BAA4B,EAAE,MAAM,CAAA;CACrC;AAED,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,MAAM,EAAE,WAAW,CAAA;CACpB;AAED,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACrD,EAAE,EAAE,SAAS,CAAA;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,UAAU,GAAC,SAAS,CAAA;IAC1B,GAAG,EAAE,OAAO,CAAA;CACb"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,0EAiBC;AAED;;;GAGG;AACH,6BAHW,MAAM,GACJ,OAAO,SAAS,EAAE,MAAM,CAQpC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webstreams.browser.d.ts","sourceRoot":"","sources":["../../lib/webstreams.browser.js"],"names":[],"mappings":"AAAA,6BAA6B;AAE7B,6BAFW,cAAc,CAE8B;AACvD,6BAA6B;AAE7B,6BAFW,cAAc,CAE8B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webstreams.d.ts","sourceRoot":"","sources":["../../lib/webstreams.js"],"names":[],"mappings":"AAKA;;;;EAAgD;AAChD;;;EAAgD"}
@@ -43,12 +43,22 @@ export class WebTransportPolyfill {
43
43
  * @param {WebTransportCloseInfo} [closeinfo]
44
44
  */
45
45
  close(closeinfo?: import("./dom").WebTransportCloseInfo | undefined): void;
46
- createBidirectionalStream(): Promise<import("./dom").WebTransportBidirectionalStream>;
47
- createUnidirectionalStream(): Promise<import("./dom").WebTransportSendStream>;
46
+ /**
47
+ * @param {WebTransportSendStreamOptions} [opts]
48
+ * @returns {Promise<WebTransportBidirectionalStream>}
49
+ */
50
+ createBidirectionalStream(opts?: import("./dom").WebTransportSendStreamOptions | undefined): Promise<WebTransportBidirectionalStream>;
51
+ /**
52
+ * @param {WebTransportSendStreamOptions} [opts]
53
+ * @returns {Promise<WebTransportSendStream>}
54
+ */
55
+ createUnidirectionalStream(opts?: import("./dom").WebTransportSendStreamOptions | undefined): Promise<WebTransportSendStream>;
48
56
  }
49
57
  export type WebTransport = import('./dom').WebTransport;
50
58
  export type WebTransportCloseInfo = import('./dom').WebTransportCloseInfo;
51
59
  export type WebTransportBidirectionalStream = import('./dom').WebTransportBidirectionalStream;
60
+ export type WebTransportSendStream = import('./dom').WebTransportSendStream;
61
+ export type WebTransportSendStreamOptions = import('./dom').WebTransportSendStreamOptions;
52
62
  export type WebTransportReceiveStream = import('./dom').WebTransportReceiveStream;
53
63
  export type WebTransportError = import('./error').WebTransportError;
54
64
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webtransport.browser.d.ts","sourceRoot":"","sources":["../../lib/webtransport.browser.js"],"names":[],"mappings":"AAqDA;;;;GAIG;AACH;IAwBI,4BAA0B;CAc7B;AAED;IACE;;;OAGG;IACH,iBAHW,MAAM,0DAsLhB;IAlLC,gBAAuB;IACvB,kBAAqB;IACrB,uBAAyB;IACzB,2BAA8B;IAC9B,sDAAgB;IAEhB,qBAGE;IAFA,+BAAuB;IACvB,iCAAsB;IAGxB,oBAGE;IAFA,+BAAuB;IACvB,iCAAsB;IAGxB,uBAGE;IAFA,kCAA0B;IAC1B,oCAAyB;IAMzB,cAeW,YAAY,GAAC,oBAAoB,CAfW;IAoFzD,+DAA+D;IAE/D,WAFW,OAAO,OAAO,EAAE,gCAAgC,CAExC;IAMf,yDAAuE;IAgBvE,yDAAuE;IAa3E,6DAeE;IAZE,iHAC4D;IAahE,8DAeE;IAZE,4GAC6D;IAcnE,uEAGC;IAED,+DAGC;IAED,oCAEC;IAED,yBAGC;IAED;;OAEG;IACH,2EAGC;IAED;;;OAGG;IACH,6FAFa,QAAQ,+BAA+B,CAAC,CAKpD;IAED;;;OAGG;IACH,8FAFa,QAAQ,sBAAsB,CAAC,CAK3C;CACF;2BA/TY,OAAO,OAAO,EAAE,YAAY;oCAC5B,OAAO,OAAO,EAAE,qBAAqB;8CACrC,OAAO,OAAO,EAAE,+BAA+B;qCAC/C,OAAO,OAAO,EAAE,sBAAsB;4CACtC,OAAO,OAAO,EAAE,6BAA6B;wCAC7C,OAAO,OAAO,EAAE,yBAAyB;gCACzC,OAAO,SAAS,EAAE,iBAAiB;;;;gCAKnC,OAAO,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC;oCAkC3C,OAAO,OAAO,EAAE,YAAY"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webtransport.node.d.ts","sourceRoot":"","sources":["../../lib/webtransport.node.js"],"names":[],"mappings":"AAiDA;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AACH;CAuEC;oCAtFY,OAAO,OAAO,EAAE,qBAAqB;8CACrC,OAAO,OAAO,EAAE,+BAA+B;wCAC/C,OAAO,OAAO,EAAE,yBAAyB;;;;gCAKzC,OAAO,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC;oCAI3C,OAAO,OAAO,EAAE,YAAY"}
@@ -3,6 +3,8 @@
3
3
  * @typedef {import('./dom.js').WebTransportCloseInfo} WebTransportCloseInfo
4
4
  * @typedef {import('./dom.js').WebTransportBidirectionalStream} WebTransportBidirectionalStream
5
5
  * @typedef {import('./dom.js').WebTransportReceiveStream} WebTransportReceiveStream
6
+ * @typedef {import('./dom.js').WebTransportSendStream} WebTransportSendStream
7
+ * @typedef {import('./dom.js').WebTransportSendStreamOptions} WebTransportSendStreamOptions
6
8
  * @typedef {import('./session.js').HttpWTSession} HttpWTSession
7
9
  * @typedef { import('./session.js').HttpClient} HttpClient
8
10
  */
@@ -54,12 +56,22 @@ export class WebTransportBase implements WebTransportInterface {
54
56
  * @param {WebTransportCloseInfo} [closeinfo]
55
57
  */
56
58
  close(closeinfo?: import("./dom.js").WebTransportCloseInfo | undefined): void;
57
- createBidirectionalStream(): Promise<import("./dom.js").WebTransportBidirectionalStream>;
58
- createUnidirectionalStream(): Promise<import("./dom.js").WebTransportSendStream>;
59
+ /**
60
+ * @param {WebTransportSendStreamOptions} [opts]
61
+ * @returns {Promise<WebTransportBidirectionalStream>}
62
+ */
63
+ createBidirectionalStream(opts?: import("./dom.js").WebTransportSendStreamOptions | undefined): Promise<WebTransportBidirectionalStream>;
64
+ /**
65
+ * @param {WebTransportSendStreamOptions} [opts]
66
+ * @returns {Promise<WebTransportSendStream>}
67
+ */
68
+ createUnidirectionalStream(opts?: import("./dom.js").WebTransportSendStreamOptions | undefined): Promise<WebTransportSendStream>;
59
69
  }
60
70
  export type WebTransportCloseInfo = import('./dom.js').WebTransportCloseInfo;
61
71
  export type WebTransportBidirectionalStream = import('./dom.js').WebTransportBidirectionalStream;
62
72
  export type WebTransportReceiveStream = import('./dom.js').WebTransportReceiveStream;
73
+ export type WebTransportSendStream = import('./dom.js').WebTransportSendStream;
74
+ export type WebTransportSendStreamOptions = import('./dom.js').WebTransportSendStreamOptions;
63
75
  export type HttpWTSession = import('./session.js').HttpWTSession;
64
76
  export type HttpClient = import('./session.js').HttpClient;
65
77
  /**
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webtransportbase.d.ts","sourceRoot":"","sources":["../../lib/webtransportbase.js"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E;;;;;;;;GAQG;AAEH;;;GAGG;AAEH;;;;GAIG;AACH;IACE;;;OAGG;IACH,iBAHW,MAAM,6DA8BhB;IAdC,qBAA6B;IAC7B,0DAA+B;IAC/B,6BAAmC;IAEnC,+DAAqC;IAErC,4GAA2E;IAE3E,uGAC0C;IAE1C,iDAA4B;IAK9B;;;;OAIG;IACH,mBAJU,OAAO,YAAY,EAAE,oBAAoB,GACvC;QAAC,UAAU,EAAE,aAAa,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAC,CAK1D;IAED;;;OAGG;IACH,gDAHU;QAAC,MAAM,EAAE,UAAU,CAAC;QAAC,UAAU,EAAE,aAAa,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAC,QAKnE;IAED,kEAQC;IAED,0EAQC;IAED,oCAIC;IAED,yBAQC;IAED;;OAEG;IACH,8EASC;IAED;;;OAGG;IACH,gGAFa,QAAQ,+BAA+B,CAAC,CAWpD;IAED;;;OAGG;IACH,iGAFa,QAAQ,sBAAsB,CAAC,CAW3C;CACF;oCArJY,OAAO,UAAU,EAAE,qBAAqB;8CACxC,OAAO,UAAU,EAAE,+BAA+B;wCAClD,OAAO,UAAU,EAAE,yBAAyB;qCAC5C,OAAO,UAAU,EAAE,sBAAsB;4CACzC,OAAO,UAAU,EAAE,6BAA6B;4BAChD,OAAO,cAAc,EAAE,aAAa;yBACnC,OAAO,cAAc,EAAE,UAAU;;;;gCAKlC,OAAO,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC;oCAI3C,OAAO,UAAU,EAAE,YAAY"}
package/lib/dom.ts CHANGED
@@ -88,6 +88,16 @@ export interface WebTransportOptions {
88
88
  congestionControl?: WebTransportCongestionControl
89
89
  }
90
90
 
91
+ export interface WebTransportSendGroup {
92
+ getStats: () => Promise<WebTransportSendStreamStats>
93
+ }
94
+
95
+ export interface WebTransportSendStreamOptions {
96
+ sendGroup: WebTransportSendGroup|null
97
+ sendOrder?: number
98
+ waitUntilAvailable?: boolean
99
+ }
100
+
91
101
  export interface WebTransportSession {
92
102
  getStats: () => Promise<WebTransportStats>
93
103
  readonly ready: Promise<void>
@@ -98,11 +108,11 @@ export interface WebTransportSession {
98
108
  close: (closeInfo?: WebTransportCloseInfo) => void
99
109
  readonly datagrams: WebTransportDatagramDuplexStream
100
110
 
101
- createBidirectionalStream: () => Promise<WebTransportBidirectionalStream>
111
+ createBidirectionalStream: (opts?: WebTransportSendStreamOptions) => Promise<WebTransportBidirectionalStream>
102
112
  /* a ReadableStream of WebTransportBidirectionalStream objects */
103
113
  readonly incomingBidirectionalStreams: ReadableStream<WebTransportBidirectionalStream>
104
114
 
105
- createUnidirectionalStream: () => Promise<WebTransportSendStream>
115
+ createUnidirectionalStream: (opts?: WebTransportSendStreamOptions) => Promise<WebTransportSendStream>
106
116
  /* a ReadableStream of WebTransportReceiveStream objects */
107
117
  readonly incomingUnidirectionalStreams: ReadableStream<WebTransportReceiveStream>
108
118
  }
@@ -0,0 +1,16 @@
1
+ let canByteStream_ = true
2
+ try {
3
+ // @ts-ignore
4
+ // eslint-disable-next-line no-unused-vars
5
+ const teststream = new ReadableStream({
6
+ // @ts-ignore
7
+ start: (
8
+ /** @type {import("stream/web").ReadableByteStreamController} */ controller
9
+ ) => {},
10
+ type: 'bytes'
11
+ })
12
+ } catch (error) {
13
+ canByteStream_ = false
14
+ }
15
+
16
+ export const canByteStream = canByteStream_
@@ -17,6 +17,11 @@ export class Http2WebTransportBrowser {
17
17
  this.initialSessionFlowControlWindow =
18
18
  args?.initialSessionFlowControlWindow || 16 * 1024 // 16 KB
19
19
 
20
+ this.initialBidirectionalStreams =
21
+ args?.initialBidirectionalSendStreams || 100
22
+ this.initialUnidirectionalStreams =
23
+ args?.initialUnidirectionalSendStreams || 100
24
+
20
25
  this.streamShouldAutoTuneReceiveWindow =
21
26
  args.streamShouldAutoTuneReceiveWindow || false
22
27
  this.streamFlowControlWindowSizeLimit =
@@ -122,7 +127,7 @@ export class Http2WebTransportBrowser {
122
127
  ws: this.clientInt,
123
128
  nativesession,
124
129
  isclient: true,
125
- initialStreamSendWindowOffset: this.initialStreamFlowControlWindow,
130
+ initialStreamSendWindowOffset: 0,
126
131
  initialStreamReceiveWindowOffset:
127
132
  this.initialStreamFlowControlWindow,
128
133
  streamShouldAutoTuneReceiveWindow:
@@ -200,10 +205,14 @@ export class Http2WebTransportBrowser {
200
205
  })
201
206
  return session
202
207
  },
203
- sendWindowOffset: this.sessionFlowControlWindowSizeLimit,
208
+ sendWindowOffset: 0,
204
209
  receiveWindowOffset: this.sessionFlowControlWindowSizeLimit,
205
210
  shouldAutoTuneReceiveWindow: this.sessionShouldAutoTuneReceiveWindow,
206
- receiveWindowSizeLimit: this.sessionFlowControlWindowSizeLimit
211
+ receiveWindowSizeLimit: this.sessionFlowControlWindowSizeLimit,
212
+ initialBidirectionalSendStreams: this.initialBidirectionalStreams, // TODO, once supported by node, use initial settings
213
+ initialBidirectionalReceiveStreams: this.initialBidirectionalStreams,
214
+ initialUnidirectionalSendStreams: this.initialUnidirectionalStreams, // TODO, once supported by node, use initial settings
215
+ initialUnidirectionalReceiveStreams: this.initialUnidirectionalStreams
207
216
  }),
208
217
  reliable: true
209
218
  }
@@ -116,37 +116,48 @@ export class BrowserParser extends ParserBase {
116
116
  case ParserBase.WT_STOP_SENDING:
117
117
  {
118
118
  const streamid = readVarInt(bufferstate)
119
- const stream = this.wtstreams.get(streamid)
120
- const code = readVarInt(bufferstate)
121
- if (stream && typeof code !== 'undefined')
122
- stream.jsobj.onStreamRecvSignal({
123
- code,
124
- nettask:
119
+ if (typeof streamid !== 'undefined') {
120
+ const stream = this.wtstreams.get(streamid)
121
+ const code = readVarInt(bufferstate)
122
+ if (stream && typeof code !== 'undefined') {
123
+ stream.onStreamSignal(
125
124
  type === ParserBase.WT_RESET_STREAM
126
125
  ? 'resetStream'
127
126
  : 'stopSending'
128
- })
127
+ )
128
+ stream.jsobj.onStreamRecvSignal({
129
+ code: Number(code),
130
+ nettask:
131
+ type === ParserBase.WT_RESET_STREAM
132
+ ? 'resetStream'
133
+ : 'stopSending'
134
+ })
135
+ }
136
+ }
129
137
  }
130
138
  break
131
139
  case ParserBase.WT_STREAM_WOFIN:
132
140
  case ParserBase.WT_STREAM_WFIN:
133
141
  {
134
- const streamid = Number(readVarInt(bufferstate))
142
+ const streamid = readVarInt(bufferstate)
135
143
 
136
144
  if (typeof streamid !== 'undefined') {
137
145
  let object = this.wtstreams.get(streamid)
138
146
  if (!object) {
139
147
  object = this.newStream(streamid)
148
+ if (!object) return // stream broken
140
149
  }
141
150
  // TODO submit data
142
151
  if (offsetend - bufferstate.offset >= 0) {
152
+ const fin = type === ParserBase.WT_STREAM_WFIN
153
+ if (fin) object.onFin()
143
154
  object.recvData({
144
155
  data: new Uint8Array(
145
156
  bufferstate.buffer.buffer,
146
157
  bufferstate.buffer.byteOffset + bufferstate.offset,
147
158
  offsetend - bufferstate.offset
148
159
  ),
149
- fin: type === ParserBase.WT_STREAM_WFIN
160
+ fin
150
161
  })
151
162
  }
152
163
  }
@@ -156,46 +167,35 @@ export class BrowserParser extends ParserBase {
156
167
  this.onMaxData(readVarInt(bufferstate))
157
168
  break
158
169
  case ParserBase.WT_MAX_STREAM_DATA:
159
- this.onMaxStreamData(readVarInt(bufferstate), readVarInt(bufferstate))
170
+ {
171
+ const streamid = readVarInt(bufferstate)
172
+ const offset = readVarInt(bufferstate)
173
+ if (typeof streamid !== 'undefined' && typeof offset !== 'undefined')
174
+ this.onMaxStreamData(streamid, offset)
175
+ }
160
176
  break
161
177
  case ParserBase.WT_MAX_STREAMS_BIDI:
162
- // this.recvSession({ maxstreams: readVarInt(bufferstate), type })
178
+ this.onMaxStreamBiDi(readVarInt(bufferstate))
163
179
  break
164
180
  case ParserBase.WT_MAX_STREAMS_UNIDI:
165
- // this.recvSession({ maxstreams: readVarInt(bufferstate), type })
181
+ this.onMaxStreamUniDi(readVarInt(bufferstate))
166
182
  break
167
183
  case ParserBase.WT_DATA_BLOCKED:
168
184
  this.onDataBlocked(readVarInt(bufferstate))
169
185
  break
170
186
  case ParserBase.WT_STREAM_DATA_BLOCKED:
171
- this.onStreamDataBlocked(
172
- readVarInt(bufferstate),
173
- readVarInt(bufferstate)
174
- )
187
+ {
188
+ const streamid = readVarInt(bufferstate)
189
+ const offset = readVarInt(bufferstate)
190
+ if (typeof streamid !== 'undefined' && typeof offset !== 'undefined')
191
+ this.onStreamDataBlocked(streamid, offset)
192
+ }
175
193
  break
176
194
  case ParserBase.WT_STREAMS_BLOCKED_UNIDI:
177
- /* {
178
- const streamid = readVarInt(bufferstate)
179
- const object = this.wtstreams.get(streamid)
180
- if (object)
181
- this.recvStream({
182
- maxstreams: readVarInt(bufferstate),
183
- type,
184
- object
185
- })
186
- } */
195
+ this.onStreamsBlockedUnidi(readVarInt(bufferstate))
187
196
  break
188
197
  case ParserBase.WT_STREAMS_BLOCKED_BIDI:
189
- /* {
190
- const streamid = readVarInt(bufferstate)
191
- const object = this.wtstreams.get(streamid)
192
- if (object)
193
- this.recvStream({
194
- maxstreams: readVarInt(bufferstate),
195
- type,
196
- streamid
197
- })
198
- } */
198
+ this.onStreamsBlockedBidi(readVarInt(bufferstate))
199
199
  break
200
200
  case ParserBase.DATAGRAM:
201
201
  this.session.jsobj.onDatagramReceived({
@@ -273,7 +273,7 @@ export class FlowController {
273
273
 
274
274
  maybeSendBlocked() {
275
275
  if (
276
- this.sendWindowSize() !== 0 ||
276
+ this.sendWindowSize() !== 0n ||
277
277
  this.lastBlockedSendWindowOffset >= this.sendWindowOffset
278
278
  ) {
279
279
  return
@@ -342,7 +342,7 @@ export class FlowController {
342
342
 
343
343
  sendWindowSize() {
344
344
  if (this.bytesSent > this.sendWindowOffset) {
345
- return 0
345
+ return 0n
346
346
  }
347
347
  return this.sendWindowOffset - this.bytesSent
348
348
  }
@@ -121,28 +121,41 @@ export class Http2CapsuleParser extends ParserBaseHttp2 {
121
121
  case Http2CapsuleParser.WT_STOP_SENDING:
122
122
  {
123
123
  const streamid = readVarInt(bufferstate)
124
- const stream = this.wtstreams.get(streamid)
125
- const code = readVarInt(bufferstate)
126
- if (stream && typeof code !== 'undefined')
127
- stream.jsobj.onStreamRecvSignal({
128
- code,
129
- nettask:
124
+ if (typeof streamid !== 'undefined') {
125
+ const stream = this.wtstreams.get(streamid)
126
+ const code = readVarInt(bufferstate)
127
+ if (stream && typeof code !== 'undefined') {
128
+ stream.onStreamSignal(
130
129
  type === Http2CapsuleParser.WT_RESET_STREAM
131
130
  ? 'resetStream'
132
131
  : 'stopSending'
133
- })
132
+ )
133
+ stream.jsobj.onStreamRecvSignal({
134
+ code: Number(code),
135
+ nettask:
136
+ type === Http2CapsuleParser.WT_RESET_STREAM
137
+ ? 'resetStream'
138
+ : 'stopSending'
139
+ })
140
+ }
141
+ }
134
142
  }
135
143
  break
136
144
  case Http2CapsuleParser.WT_STREAM_WOFIN:
137
145
  case Http2CapsuleParser.WT_STREAM_WFIN:
138
- streamid = Number(readVarInt(bufferstate))
146
+ streamid = readVarInt(bufferstate)
139
147
  if (typeof streamid !== 'undefined') {
140
148
  let object = this.wtstreams.get(streamid)
141
149
  if (!object) {
142
150
  object = this.newStream(streamid)
151
+ if (!object) return // stream broken
143
152
  }
144
153
  // TODO submit data
145
154
  if (offsetend - bufferstate.offset >= 0) {
155
+ const fin =
156
+ type === Http2CapsuleParser.WT_STREAM_WFIN &&
157
+ bufferstate.size >= length + offsetbegin
158
+ if (fin) object.onFin()
146
159
  object.recvData({
147
160
  data:
148
161
  offsetend - bufferstate.offset > 0
@@ -153,9 +166,7 @@ export class Http2CapsuleParser extends ParserBaseHttp2 {
153
166
  offsetend - bufferstate.offset
154
167
  )
155
168
  : undefined,
156
- fin:
157
- type === Http2CapsuleParser.WT_STREAM_WFIN &&
158
- bufferstate.size >= length + offsetbegin
169
+ fin
159
170
  })
160
171
  }
161
172
  }
@@ -164,49 +175,41 @@ export class Http2CapsuleParser extends ParserBaseHttp2 {
164
175
  this.onMaxData(readVarInt(bufferstate))
165
176
  break
166
177
  case Http2CapsuleParser.WT_MAX_STREAM_DATA:
167
- this.onMaxStreamData(
168
- readVarInt(bufferstate),
169
- readVarInt(bufferstate)
170
- )
178
+ {
179
+ const streamid = readVarInt(bufferstate)
180
+ const offset = readVarInt(bufferstate)
181
+ if (
182
+ typeof streamid !== 'undefined' &&
183
+ typeof offset !== 'undefined'
184
+ )
185
+ this.onMaxStreamData(streamid, offset)
186
+ }
171
187
  break
172
188
  case Http2CapsuleParser.WT_MAX_STREAMS_BIDI:
173
- // this.recvSession({ maxstreams: readVarInt(bufferstate), type })
189
+ this.onMaxStreamBiDi(readVarInt(bufferstate))
174
190
  break
175
191
  case Http2CapsuleParser.WT_MAX_STREAMS_UNIDI:
176
- // this.recvSession({ maxstreams: readVarInt(bufferstate), type })
192
+ this.onMaxStreamUniDi(readVarInt(bufferstate))
177
193
  break
178
194
  case Http2CapsuleParser.WT_DATA_BLOCKED:
179
195
  this.onDataBlocked(readVarInt(bufferstate))
180
196
  break
181
197
  case Http2CapsuleParser.WT_STREAM_DATA_BLOCKED:
182
- this.onStreamDataBlocked(
183
- readVarInt(bufferstate),
184
- readVarInt(bufferstate)
185
- )
198
+ {
199
+ const streamid = readVarInt(bufferstate)
200
+ const offset = readVarInt(bufferstate)
201
+ if (
202
+ typeof streamid !== 'undefined' &&
203
+ typeof offset !== 'undefined'
204
+ )
205
+ this.onStreamDataBlocked(streamid, offset)
206
+ }
186
207
  break
187
208
  case Http2CapsuleParser.WT_STREAMS_BLOCKED_UNIDI:
188
- /* {
189
- const streamid = readVarInt(bufferstate)
190
- const object = this.wtstreams.get(streamid)
191
- if (object)
192
- this.recvStream({
193
- maxstreams: readVarInt(bufferstate),
194
- type,
195
- object
196
- })
197
- } */
209
+ this.onStreamsBlockedUnidi(readVarInt(bufferstate))
198
210
  break
199
211
  case Http2CapsuleParser.WT_STREAMS_BLOCKED_BIDI:
200
- /* {
201
- const streamid = readVarInt(bufferstate)
202
- const object = this.wtstreams.get(streamid)
203
- if (object)
204
- this.recvStream({
205
- maxstreams: readVarInt(bufferstate),
206
- type,
207
- streamid
208
- })
209
- } */
212
+ this.onStreamsBlockedBidi(readVarInt(bufferstate))
210
213
  break
211
214
  case Http2CapsuleParser.DATAGRAM:
212
215
  this.session.jsobj.onDatagramReceived({
@@ -241,17 +244,21 @@ export class Http2CapsuleParser extends ParserBaseHttp2 {
241
244
  if (this.rstreamid) {
242
245
  // TODO submitData
243
246
  const object = this.wtstreams.get(this.rstreamid)
247
+ const fin =
248
+ this.rtype === Http2CapsuleParser.WT_STREAM_WFIN &&
249
+ this.remainlength === clength
244
250
  // TODO submit data
245
- object.recvData({
246
- data: new Uint8Array(
247
- bufferstate.buffer.buffer,
248
- bufferstate.buffer.byteOffset + bufferstate.offset,
249
- clength
250
- ),
251
- fin:
252
- this.rtype === Http2CapsuleParser.WT_STREAM_WFIN &&
253
- this.remainlength === clength
254
- })
251
+ if (object) {
252
+ if (fin) object.onFin()
253
+ object.recvData({
254
+ data: new Uint8Array(
255
+ bufferstate.buffer.buffer,
256
+ bufferstate.buffer.byteOffset + bufferstate.offset,
257
+ clength
258
+ ),
259
+ fin
260
+ })
261
+ }
255
262
  }
256
263
 
257
264
  this.remainlength = this.remainlength - clength
@@ -23,6 +23,11 @@ export class Http2WebTransportClient {
23
23
  this.initialSessionFlowControlWindow =
24
24
  args?.initialSessionFlowControlWindow || 16 * 1024 // 16 KB
25
25
 
26
+ this.initialBidirectionalStreams =
27
+ args?.initialBidirectionalSendStreams || 100
28
+ this.initialUnidirectionalStreams =
29
+ args?.initialUnidirectionalSendStreams || 100
30
+
26
31
  this.streamShouldAutoTuneReceiveWindow =
27
32
  args.streamShouldAutoTuneReceiveWindow || false
28
33
  this.streamFlowControlWindowSizeLimit =
@@ -84,8 +89,8 @@ export class Http2WebTransportClient {
84
89
  0x2b61: this.initialSessionFlowControlWindow, // SETTINGS_WEBTRANSPORT_INITIAL_MAX_DATA
85
90
  0x2b62: this.initialStreamFlowControlWindow, // SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAM_DATA_UNI
86
91
  0x2b63: this.initialStreamFlowControlWindow, // SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAM_DATA_BIDI
87
- 0x2b64: 0xffffff, // SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAMS_UNI
88
- 0x2b65: 0xffffff // SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAMS_BIDI
92
+ 0x2b64: this.initialUnidirectionalStreams, // SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAMS_UNI
93
+ 0x2b65: this.initialBidirectionalStreams // SETTINGS_WEBTRANSPORT_INITIAL_MAX_STREAMS_BIDI
89
94
  }
90
95
  },
91
96
  localPort: this.localPort,
@@ -216,13 +221,17 @@ export class Http2WebTransportClient {
216
221
  stream,
217
222
  nativesession,
218
223
  isclient: true,
219
- initialStreamSendWindowOffset: this.initialStreamFlowControlWindow,
224
+ initialStreamSendWindowOffset: this.initialStreamFlowControlWindow, // TODO, once supported by node, use initial settings
220
225
  initialStreamReceiveWindowOffset:
221
226
  this.initialStreamFlowControlWindow,
222
227
  streamShouldAutoTuneReceiveWindow:
223
228
  this.streamShouldAutoTuneReceiveWindow,
224
229
  streamReceiveWindowSizeLimit: this.streamFlowControlWindowSizeLimit
225
230
  }),
231
+ initialBidirectionalSendStreams: this.initialBidirectionalStreams, // TODO, once supported by node, use initial settings
232
+ initialBidirectionalReceiveStreams: this.initialBidirectionalStreams,
233
+ initialUnidirectionalSendStreams: this.initialUnidirectionalStreams, // TODO, once supported by node, use initial settings
234
+ initialUnidirectionalReceiveStreams: this.initialUnidirectionalStreams,
226
235
  sendWindowOffset: this.sessionFlowControlWindowSizeLimit,
227
236
  receiveWindowOffset: this.sessionFlowControlWindowSizeLimit,
228
237
  shouldAutoTuneReceiveWindow: this.sessionShouldAutoTuneReceiveWindow,