@moq/net 0.4.7 → 0.22.0

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 (664) hide show
  1. package/README.md +7 -1
  2. package/announce.d.ts +1 -1
  3. package/announce.d.ts.map +1 -1
  4. package/announce.js +1 -2
  5. package/announce.js.map +1 -1
  6. package/announced.d.ts +51 -47
  7. package/announced.d.ts.map +1 -1
  8. package/announced.js +183 -32
  9. package/announced.js.map +1 -1
  10. package/announced.test-util.d.ts +2 -0
  11. package/announced.test-util.d.ts.map +1 -0
  12. package/announced.test-util.js +27 -0
  13. package/announced.test-util.js.map +1 -0
  14. package/auth.d.ts +64 -0
  15. package/auth.d.ts.map +1 -0
  16. package/auth.js +20 -0
  17. package/auth.js.map +1 -0
  18. package/auth_gate.d.ts +2 -0
  19. package/auth_gate.d.ts.map +1 -0
  20. package/auth_gate.js +24 -0
  21. package/auth_gate.js.map +1 -0
  22. package/auth_session.d.ts +49 -0
  23. package/auth_session.d.ts.map +1 -0
  24. package/auth_session.js +1097 -0
  25. package/auth_session.js.map +1 -0
  26. package/bandwidth.d.ts +129 -25
  27. package/bandwidth.d.ts.map +1 -1
  28. package/bandwidth.js +410 -139
  29. package/bandwidth.js.map +1 -1
  30. package/bandwidth_api.d.ts +1 -1
  31. package/bandwidth_api.d.ts.map +1 -1
  32. package/bandwidth_api.js +1 -2
  33. package/bandwidth_api.js.map +1 -1
  34. package/broadcast.d.ts +64 -38
  35. package/broadcast.d.ts.map +1 -1
  36. package/broadcast.js +556 -173
  37. package/broadcast.js.map +1 -1
  38. package/cache.d.ts +103 -0
  39. package/cache.d.ts.map +1 -0
  40. package/cache.js +254 -0
  41. package/cache.js.map +1 -0
  42. package/claim.test-util.d.ts +5 -0
  43. package/claim.test-util.d.ts.map +1 -0
  44. package/claim.test-util.js +13 -0
  45. package/claim.test-util.js.map +1 -0
  46. package/connection/accept.d.ts +21 -13
  47. package/connection/accept.d.ts.map +1 -1
  48. package/connection/accept.js +97 -130
  49. package/connection/accept.js.map +1 -1
  50. package/connection/browser.d.ts.map +1 -1
  51. package/connection/browser.js +28 -20
  52. package/connection/browser.js.map +1 -1
  53. package/connection/connect.d.ts +120 -24
  54. package/connection/connect.d.ts.map +1 -1
  55. package/connection/connect.js +535 -217
  56. package/connection/connect.js.map +1 -1
  57. package/connection/dials.d.ts +45 -0
  58. package/connection/dials.d.ts.map +1 -0
  59. package/connection/dials.js +109 -0
  60. package/connection/dials.js.map +1 -0
  61. package/connection/endpoint.d.ts +60 -0
  62. package/connection/endpoint.d.ts.map +1 -0
  63. package/connection/endpoint.js +114 -0
  64. package/connection/endpoint.js.map +1 -0
  65. package/connection/forward.d.ts +7 -1
  66. package/connection/forward.d.ts.map +1 -1
  67. package/connection/forward.js +265 -81
  68. package/connection/forward.js.map +1 -1
  69. package/connection/goaway.d.ts +16 -9
  70. package/connection/goaway.d.ts.map +1 -1
  71. package/connection/goaway.js +22 -95
  72. package/connection/goaway.js.map +1 -1
  73. package/connection/handshake.d.ts +34 -8
  74. package/connection/handshake.d.ts.map +1 -1
  75. package/connection/handshake.js +97 -21
  76. package/connection/handshake.js.map +1 -1
  77. package/connection/index.d.ts +4 -7
  78. package/connection/index.d.ts.map +1 -1
  79. package/connection/index.js +1 -3
  80. package/connection/index.js.map +1 -1
  81. package/connection/liveness.d.ts +14 -0
  82. package/connection/liveness.d.ts.map +1 -0
  83. package/connection/liveness.js +30 -0
  84. package/connection/liveness.js.map +1 -0
  85. package/connection/pool.d.ts +142 -63
  86. package/connection/pool.d.ts.map +1 -1
  87. package/connection/pool.js +281 -118
  88. package/connection/pool.js.map +1 -1
  89. package/connection/reload.d.ts +60 -12
  90. package/connection/reload.d.ts.map +1 -1
  91. package/connection/reload.js +859 -234
  92. package/connection/reload.js.map +1 -1
  93. package/connection/session.d.ts +91 -0
  94. package/connection/session.d.ts.map +1 -0
  95. package/connection/session.js +2 -0
  96. package/connection/session.js.map +1 -0
  97. package/connection/stats.d.ts +20 -11
  98. package/connection/stats.d.ts.map +1 -1
  99. package/connection/stats.js +64 -9
  100. package/connection/stats.js.map +1 -1
  101. package/connection/ticker.d.ts +4 -0
  102. package/connection/ticker.d.ts.map +1 -0
  103. package/connection/ticker.js +66 -0
  104. package/connection/ticker.js.map +1 -0
  105. package/connection/tokens.d.ts +2 -0
  106. package/connection/tokens.d.ts.map +1 -0
  107. package/connection/tokens.js +404 -0
  108. package/connection/tokens.js.map +1 -0
  109. package/connection/transport.d.ts.map +1 -1
  110. package/connection/transport.js +4 -5
  111. package/connection/transport.js.map +1 -1
  112. package/connection/withdrawal.d.ts +2 -0
  113. package/connection/withdrawal.d.ts.map +1 -0
  114. package/connection/withdrawal.js +23 -0
  115. package/connection/withdrawal.js.map +1 -0
  116. package/consume.js +213 -47
  117. package/consume.js.map +1 -1
  118. package/cover.d.ts +59 -0
  119. package/cover.d.ts.map +1 -0
  120. package/cover.js +375 -0
  121. package/cover.js.map +1 -0
  122. package/datagram.d.ts +70 -11
  123. package/datagram.d.ts.map +1 -1
  124. package/datagram.js +317 -2
  125. package/datagram.js.map +1 -1
  126. package/datagram_stream.d.ts +18 -0
  127. package/datagram_stream.d.ts.map +1 -0
  128. package/datagram_stream.js +67 -0
  129. package/datagram_stream.js.map +1 -0
  130. package/defined.test-util.d.ts +2 -0
  131. package/defined.test-util.d.ts.map +1 -0
  132. package/defined.test-util.js +7 -0
  133. package/defined.test-util.js.map +1 -0
  134. package/delivered.d.ts +75 -0
  135. package/delivered.d.ts.map +1 -0
  136. package/delivered.js +228 -0
  137. package/delivered.js.map +1 -0
  138. package/demand.d.ts +173 -0
  139. package/demand.d.ts.map +1 -0
  140. package/demand.js +582 -0
  141. package/demand.js.map +1 -0
  142. package/drops.d.ts +93 -0
  143. package/drops.d.ts.map +1 -0
  144. package/drops.js +283 -0
  145. package/drops.js.map +1 -0
  146. package/error.d.ts +120 -21
  147. package/error.d.ts.map +1 -1
  148. package/error.js +230 -38
  149. package/error.js.map +1 -1
  150. package/errors.d.ts +2 -2
  151. package/errors.d.ts.map +1 -1
  152. package/errors.js +2 -3
  153. package/errors.js.map +1 -1
  154. package/fill.d.ts +174 -0
  155. package/fill.d.ts.map +1 -0
  156. package/fill.js +760 -0
  157. package/fill.js.map +1 -0
  158. package/flate/decoder.d.ts +2 -0
  159. package/flate/decoder.d.ts.map +1 -0
  160. package/flate/decoder.js +63 -0
  161. package/flate/decoder.js.map +1 -0
  162. package/flate/encoder.d.ts +2 -0
  163. package/flate/encoder.d.ts.map +1 -0
  164. package/flate/encoder.js +64 -0
  165. package/flate/encoder.js.map +1 -0
  166. package/flate/group.d.ts +34 -0
  167. package/flate/group.d.ts.map +1 -0
  168. package/flate/group.js +140 -0
  169. package/flate/group.js.map +1 -0
  170. package/frame.d.ts +80 -0
  171. package/frame.d.ts.map +1 -0
  172. package/frame.js +296 -0
  173. package/frame.js.map +1 -0
  174. package/frame.test-util.d.ts +5 -0
  175. package/frame.test-util.d.ts.map +1 -0
  176. package/frame.test-util.js +9 -0
  177. package/frame.test-util.js.map +1 -0
  178. package/group.d.ts +108 -45
  179. package/group.d.ts.map +1 -1
  180. package/group.js +1616 -308
  181. package/group.js.map +1 -1
  182. package/group_api.d.ts +7 -0
  183. package/group_api.d.ts.map +1 -0
  184. package/group_api.js +7 -0
  185. package/group_api.js.map +1 -0
  186. package/hop.d.ts +62 -76
  187. package/hop.d.ts.map +1 -1
  188. package/hop.js +92 -65
  189. package/hop.js.map +1 -1
  190. package/identity.d.ts +39 -0
  191. package/identity.d.ts.map +1 -0
  192. package/identity.js +47 -0
  193. package/identity.js.map +1 -0
  194. package/ietf/active_count.d.ts +2 -0
  195. package/ietf/active_count.d.ts.map +1 -0
  196. package/ietf/active_count.js +30 -0
  197. package/ietf/active_count.js.map +1 -0
  198. package/ietf/aliases.js +69 -36
  199. package/ietf/aliases.js.map +1 -1
  200. package/ietf/cluster.d.ts +3 -3
  201. package/ietf/cluster.js +14 -55
  202. package/ietf/cluster.js.map +1 -1
  203. package/ietf/connection.d.ts +1 -31
  204. package/ietf/connection.d.ts.map +1 -1
  205. package/ietf/connection.js +305 -144
  206. package/ietf/connection.js.map +1 -1
  207. package/ietf/datagram.d.ts +60 -0
  208. package/ietf/datagram.d.ts.map +1 -0
  209. package/ietf/datagram.js +152 -0
  210. package/ietf/datagram.js.map +1 -0
  211. package/ietf/error.d.ts +3 -3
  212. package/ietf/error.js +82 -101
  213. package/ietf/error.js.map +1 -1
  214. package/ietf/fetch.d.ts +93 -37
  215. package/ietf/fetch.d.ts.map +1 -1
  216. package/ietf/fetch.js +172 -94
  217. package/ietf/fetch.js.map +1 -1
  218. package/ietf/filter.d.ts +21 -31
  219. package/ietf/filter.d.ts.map +1 -1
  220. package/ietf/filter.js +140 -172
  221. package/ietf/filter.js.map +1 -1
  222. package/ietf/goaway.d.ts +12 -10
  223. package/ietf/goaway.d.ts.map +1 -1
  224. package/ietf/goaway.js +22 -36
  225. package/ietf/goaway.js.map +1 -1
  226. package/ietf/hidden.js +1 -2
  227. package/ietf/hidden.js.map +1 -1
  228. package/ietf/index.d.ts +8 -20
  229. package/ietf/index.d.ts.map +1 -1
  230. package/ietf/index.js +4 -15
  231. package/ietf/index.js.map +1 -1
  232. package/ietf/join.d.ts +7 -0
  233. package/ietf/join.d.ts.map +1 -0
  234. package/ietf/join.js +234 -0
  235. package/ietf/join.js.map +1 -0
  236. package/ietf/message.d.ts +18 -2
  237. package/ietf/message.d.ts.map +1 -1
  238. package/ietf/message.js +60 -41
  239. package/ietf/message.js.map +1 -1
  240. package/ietf/message.test-util.d.ts +6 -0
  241. package/ietf/message.test-util.d.ts.map +1 -0
  242. package/ietf/message.test-util.js +13 -0
  243. package/ietf/message.test-util.js.map +1 -0
  244. package/ietf/namespace.d.ts +19 -5
  245. package/ietf/namespace.d.ts.map +1 -1
  246. package/ietf/namespace.js +78 -27
  247. package/ietf/namespace.js.map +1 -1
  248. package/ietf/object.d.ts +195 -33
  249. package/ietf/object.d.ts.map +1 -1
  250. package/ietf/object.js +405 -179
  251. package/ietf/object.js.map +1 -1
  252. package/ietf/parameters.d.ts +25 -45
  253. package/ietf/parameters.d.ts.map +1 -1
  254. package/ietf/parameters.js +260 -473
  255. package/ietf/parameters.js.map +1 -1
  256. package/ietf/priority.d.ts +17 -2
  257. package/ietf/priority.d.ts.map +1 -1
  258. package/ietf/priority.js +19 -5
  259. package/ietf/priority.js.map +1 -1
  260. package/ietf/properties.d.ts +6 -5
  261. package/ietf/properties.d.ts.map +1 -1
  262. package/ietf/properties.js +78 -49
  263. package/ietf/properties.js.map +1 -1
  264. package/ietf/publish.d.ts +25 -33
  265. package/ietf/publish.d.ts.map +1 -1
  266. package/ietf/publish.js +45 -140
  267. package/ietf/publish.js.map +1 -1
  268. package/ietf/publish_namespace.d.ts +49 -72
  269. package/ietf/publish_namespace.d.ts.map +1 -1
  270. package/ietf/publish_namespace.js +66 -185
  271. package/ietf/publish_namespace.js.map +1 -1
  272. package/ietf/publisher.js +1800 -601
  273. package/ietf/publisher.js.map +1 -1
  274. package/ietf/range.d.ts +2 -0
  275. package/ietf/range.d.ts.map +1 -0
  276. package/ietf/range.js +222 -0
  277. package/ietf/range.js.map +1 -0
  278. package/ietf/request.d.ts +6 -30
  279. package/ietf/request.d.ts.map +1 -1
  280. package/ietf/request.js +41 -79
  281. package/ietf/request.js.map +1 -1
  282. package/ietf/request_stream.d.ts +1 -6
  283. package/ietf/request_stream.d.ts.map +1 -1
  284. package/ietf/request_stream.js +306 -17
  285. package/ietf/request_stream.js.map +1 -1
  286. package/ietf/session.d.ts +41 -0
  287. package/ietf/session.d.ts.map +1 -0
  288. package/ietf/session.js +65 -0
  289. package/ietf/session.js.map +1 -0
  290. package/ietf/setup.d.ts +5 -30
  291. package/ietf/setup.d.ts.map +1 -1
  292. package/ietf/setup.js +6 -118
  293. package/ietf/setup.js.map +1 -1
  294. package/ietf/setup_options.d.ts +31 -0
  295. package/ietf/setup_options.d.ts.map +1 -0
  296. package/ietf/setup_options.js +138 -0
  297. package/ietf/setup_options.js.map +1 -0
  298. package/ietf/solicit.js +4 -15
  299. package/ietf/solicit.js.map +1 -1
  300. package/ietf/subscribe.d.ts +52 -45
  301. package/ietf/subscribe.d.ts.map +1 -1
  302. package/ietf/subscribe.js +118 -240
  303. package/ietf/subscribe.js.map +1 -1
  304. package/ietf/subscribe_namespace.d.ts +16 -79
  305. package/ietf/subscribe_namespace.d.ts.map +1 -1
  306. package/ietf/subscribe_namespace.js +30 -202
  307. package/ietf/subscribe_namespace.js.map +1 -1
  308. package/ietf/subscriber.js +1839 -537
  309. package/ietf/subscriber.js.map +1 -1
  310. package/ietf/token.js +105 -28
  311. package/ietf/token.js.map +1 -1
  312. package/ietf/track.d.ts +27 -24
  313. package/ietf/track.d.ts.map +1 -1
  314. package/ietf/track.js +48 -62
  315. package/ietf/track.js.map +1 -1
  316. package/ietf/version.d.ts +13 -42
  317. package/ietf/version.d.ts.map +1 -1
  318. package/ietf/version.js +22 -49
  319. package/ietf/version.js.map +1 -1
  320. package/implementation.d.ts +2 -0
  321. package/implementation.d.ts.map +1 -0
  322. package/implementation.js +5 -0
  323. package/implementation.js.map +1 -0
  324. package/index.d.ts +34 -19
  325. package/index.d.ts.map +1 -1
  326. package/index.js +19 -7
  327. package/index.js.map +1 -1
  328. package/internal.d.ts +1515 -67
  329. package/internal.d.ts.map +1 -1
  330. package/internal.js +557 -80
  331. package/internal.js.map +1 -1
  332. package/ledger.d.ts +23 -0
  333. package/ledger.d.ts.map +1 -0
  334. package/ledger.js +247 -0
  335. package/ledger.js.map +1 -0
  336. package/listing.d.ts +132 -0
  337. package/listing.d.ts.map +1 -0
  338. package/listing.js +486 -0
  339. package/listing.js.map +1 -0
  340. package/lite/announce.d.ts +127 -66
  341. package/lite/announce.d.ts.map +1 -1
  342. package/lite/announce.js +384 -159
  343. package/lite/announce.js.map +1 -1
  344. package/lite/announce_stream.d.ts +2 -0
  345. package/lite/announce_stream.d.ts.map +1 -0
  346. package/lite/announce_stream.js +92 -0
  347. package/lite/announce_stream.js.map +1 -0
  348. package/lite/answer.d.ts +22 -0
  349. package/lite/answer.d.ts.map +1 -0
  350. package/lite/answer.js +301 -0
  351. package/lite/answer.js.map +1 -0
  352. package/lite/auth.d.ts +45 -0
  353. package/lite/auth.d.ts.map +1 -0
  354. package/lite/auth.js +204 -0
  355. package/lite/auth.js.map +1 -0
  356. package/lite/compat.d.ts +31 -0
  357. package/lite/compat.d.ts.map +1 -0
  358. package/lite/compat.js +86 -0
  359. package/lite/compat.js.map +1 -0
  360. package/lite/connection.d.ts +1 -45
  361. package/lite/connection.d.ts.map +1 -1
  362. package/lite/connection.js +360 -78
  363. package/lite/connection.js.map +1 -1
  364. package/lite/datagram-end.d.ts +26 -0
  365. package/lite/datagram-end.d.ts.map +1 -0
  366. package/lite/datagram-end.js +30 -0
  367. package/lite/datagram-end.js.map +1 -0
  368. package/lite/datagram.d.ts +73 -8
  369. package/lite/datagram.d.ts.map +1 -1
  370. package/lite/datagram.js +144 -10
  371. package/lite/datagram.js.map +1 -1
  372. package/lite/duration.d.ts +6 -0
  373. package/lite/duration.d.ts.map +1 -0
  374. package/lite/duration.js +14 -0
  375. package/lite/duration.js.map +1 -0
  376. package/lite/error.d.ts +9 -0
  377. package/lite/error.d.ts.map +1 -0
  378. package/lite/error.js +24 -0
  379. package/lite/error.js.map +1 -0
  380. package/lite/fills.d.ts +162 -0
  381. package/lite/fills.d.ts.map +1 -0
  382. package/lite/fills.js +486 -0
  383. package/lite/fills.js.map +1 -0
  384. package/lite/fit.d.ts +49 -0
  385. package/lite/fit.d.ts.map +1 -0
  386. package/lite/fit.js +305 -0
  387. package/lite/fit.js.map +1 -0
  388. package/lite/goaway.d.ts +2 -2
  389. package/lite/goaway.d.ts.map +1 -1
  390. package/lite/goaway.js +5 -14
  391. package/lite/goaway.js.map +1 -1
  392. package/lite/group.d.ts +67 -16
  393. package/lite/group.d.ts.map +1 -1
  394. package/lite/group.js +108 -31
  395. package/lite/group.js.map +1 -1
  396. package/lite/identity.d.ts +25 -0
  397. package/lite/identity.d.ts.map +1 -0
  398. package/lite/identity.js +79 -0
  399. package/lite/identity.js.map +1 -0
  400. package/lite/index.d.ts +14 -13
  401. package/lite/index.d.ts.map +1 -1
  402. package/lite/index.js +2 -2
  403. package/lite/index.js.map +1 -1
  404. package/lite/message.d.ts +10 -2
  405. package/lite/message.d.ts.map +1 -1
  406. package/lite/message.js +28 -45
  407. package/lite/message.js.map +1 -1
  408. package/lite/priority.d.ts +9 -2
  409. package/lite/priority.d.ts.map +1 -1
  410. package/lite/priority.js +11 -106
  411. package/lite/priority.js.map +1 -1
  412. package/lite/probe.d.ts +2 -2
  413. package/lite/probe.d.ts.map +1 -1
  414. package/lite/probe.js +9 -1
  415. package/lite/probe.js.map +1 -1
  416. package/lite/publisher.d.ts +10 -1
  417. package/lite/publisher.d.ts.map +1 -1
  418. package/lite/publisher.js +2548 -438
  419. package/lite/publisher.js.map +1 -1
  420. package/lite/routed.d.ts +59 -0
  421. package/lite/routed.d.ts.map +1 -0
  422. package/lite/routed.js +564 -0
  423. package/lite/routed.js.map +1 -0
  424. package/lite/session.d.ts +2 -28
  425. package/lite/session.d.ts.map +1 -1
  426. package/lite/session.js +0 -100
  427. package/lite/session.js.map +1 -1
  428. package/lite/setup.d.ts +32 -5
  429. package/lite/setup.d.ts.map +1 -1
  430. package/lite/setup.js +95 -22
  431. package/lite/setup.js.map +1 -1
  432. package/lite/stream.d.ts +5 -11
  433. package/lite/stream.d.ts.map +1 -1
  434. package/lite/stream.js +5 -2
  435. package/lite/stream.js.map +1 -1
  436. package/lite/subscribe.d.ts +478 -78
  437. package/lite/subscribe.d.ts.map +1 -1
  438. package/lite/subscribe.js +1373 -143
  439. package/lite/subscribe.js.map +1 -1
  440. package/lite/subscriber.d.ts +7 -44
  441. package/lite/subscriber.d.ts.map +1 -1
  442. package/lite/subscriber.js +3290 -516
  443. package/lite/subscriber.js.map +1 -1
  444. package/lite/track.d.ts +27 -12
  445. package/lite/track.d.ts.map +1 -1
  446. package/lite/track.js +116 -38
  447. package/lite/track.js.map +1 -1
  448. package/lite/tracks.d.ts +55 -0
  449. package/lite/tracks.d.ts.map +1 -0
  450. package/lite/tracks.js +114 -0
  451. package/lite/tracks.js.map +1 -0
  452. package/lite/version.d.ts +132 -24
  453. package/lite/version.d.ts.map +1 -1
  454. package/lite/version.js +378 -34
  455. package/lite/version.js.map +1 -1
  456. package/meta.d.ts +77 -0
  457. package/meta.d.ts.map +1 -0
  458. package/meta.js +130 -0
  459. package/meta.js.map +1 -0
  460. package/meta_api.d.ts +7 -0
  461. package/meta_api.d.ts.map +1 -0
  462. package/meta_api.js +7 -0
  463. package/meta_api.js.map +1 -0
  464. package/mint.d.ts +28 -0
  465. package/mint.d.ts.map +1 -0
  466. package/mint.js +66 -0
  467. package/mint.js.map +1 -0
  468. package/open.d.ts +63 -0
  469. package/open.d.ts.map +1 -0
  470. package/open.js +250 -0
  471. package/open.js.map +1 -0
  472. package/origin.d.ts +394 -142
  473. package/origin.d.ts.map +1 -1
  474. package/origin.js +2533 -687
  475. package/origin.js.map +1 -1
  476. package/package.json +8 -13
  477. package/path.d.ts +51 -51
  478. package/path.d.ts.map +1 -1
  479. package/path.js +210 -58
  480. package/path.js.map +1 -1
  481. package/payload.d.ts +33 -0
  482. package/payload.d.ts.map +1 -0
  483. package/payload.js +65 -0
  484. package/payload.js.map +1 -0
  485. package/prefix.d.ts +152 -0
  486. package/prefix.d.ts.map +1 -0
  487. package/prefix.js +349 -0
  488. package/prefix.js.map +1 -0
  489. package/priority.d.ts +8 -0
  490. package/priority.d.ts.map +1 -0
  491. package/priority.js +185 -0
  492. package/priority.js.map +1 -0
  493. package/queue.d.ts +2 -0
  494. package/queue.d.ts.map +1 -0
  495. package/queue.js +46 -0
  496. package/queue.js.map +1 -0
  497. package/ranges.d.ts +36 -0
  498. package/ranges.d.ts.map +1 -0
  499. package/ranges.js +312 -0
  500. package/ranges.js.map +1 -0
  501. package/rescale.d.ts +24 -0
  502. package/rescale.d.ts.map +1 -0
  503. package/rescale.js +39 -0
  504. package/rescale.js.map +1 -0
  505. package/resume.d.ts +55 -0
  506. package/resume.d.ts.map +1 -0
  507. package/resume.js +4173 -0
  508. package/resume.js.map +1 -0
  509. package/resume.test-util.d.ts +2 -0
  510. package/resume.test-util.d.ts.map +1 -0
  511. package/resume.test-util.js +25 -0
  512. package/resume.test-util.js.map +1 -0
  513. package/skips.d.ts +48 -0
  514. package/skips.d.ts.map +1 -0
  515. package/skips.js +182 -0
  516. package/skips.js.map +1 -0
  517. package/stream.d.ts +78 -40
  518. package/stream.d.ts.map +1 -1
  519. package/stream.js +236 -93
  520. package/stream.js.map +1 -1
  521. package/subscription.test-util.d.ts +2 -0
  522. package/subscription.test-util.d.ts.map +1 -0
  523. package/subscription.test-util.js +49 -0
  524. package/subscription.test-util.js.map +1 -0
  525. package/tail.d.ts +23 -14
  526. package/tail.d.ts.map +1 -1
  527. package/tail.js +224 -98
  528. package/tail.js.map +1 -1
  529. package/time.d.ts +41 -102
  530. package/time.d.ts.map +1 -1
  531. package/time.js +129 -92
  532. package/time.js.map +1 -1
  533. package/timed.d.ts +21 -0
  534. package/timed.d.ts.map +1 -0
  535. package/timed.js +2 -0
  536. package/timed.js.map +1 -0
  537. package/track.d.ts +578 -246
  538. package/track.d.ts.map +1 -1
  539. package/track.js +7306 -772
  540. package/track.js.map +1 -1
  541. package/track_api.d.ts +7 -0
  542. package/track_api.d.ts.map +1 -0
  543. package/track_api.js +7 -0
  544. package/track_api.js.map +1 -0
  545. package/util/abort.d.ts +1 -0
  546. package/util/abort.d.ts.map +1 -1
  547. package/util/abort.js +23 -2
  548. package/util/abort.js.map +1 -1
  549. package/util/announce.d.ts +4 -0
  550. package/util/announce.d.ts.map +1 -0
  551. package/util/announce.js +11 -0
  552. package/util/announce.js.map +1 -0
  553. package/util/bigint.d.ts +3 -0
  554. package/util/bigint.d.ts.map +1 -0
  555. package/util/bigint.js +8 -0
  556. package/util/bigint.js.map +1 -0
  557. package/util/change.d.ts +12 -0
  558. package/util/change.d.ts.map +1 -0
  559. package/util/change.js +18 -0
  560. package/util/change.js.map +1 -0
  561. package/util/deadline.d.ts +2 -0
  562. package/util/deadline.d.ts.map +1 -0
  563. package/util/deadline.js +108 -0
  564. package/util/deadline.js.map +1 -0
  565. package/util/decode_error.d.ts +3 -0
  566. package/util/decode_error.d.ts.map +1 -0
  567. package/util/decode_error.js +11 -0
  568. package/util/decode_error.js.map +1 -0
  569. package/util/demand.d.ts +8 -0
  570. package/util/demand.d.ts.map +1 -0
  571. package/util/demand.js +24 -0
  572. package/util/demand.js.map +1 -0
  573. package/util/given_up.d.ts +2 -0
  574. package/util/given_up.d.ts.map +1 -0
  575. package/util/given_up.js +101 -0
  576. package/util/given_up.js.map +1 -0
  577. package/util/hex.d.ts +6 -0
  578. package/util/hex.d.ts.map +1 -1
  579. package/util/hex.js +19 -5
  580. package/util/hex.js.map +1 -1
  581. package/util/key.d.ts +15 -0
  582. package/util/key.d.ts.map +1 -0
  583. package/util/key.js +38 -0
  584. package/util/key.js.map +1 -0
  585. package/util/limits.d.ts +2 -0
  586. package/util/limits.d.ts.map +1 -0
  587. package/util/limits.js +76 -0
  588. package/util/limits.js.map +1 -0
  589. package/util/observed.d.ts +23 -0
  590. package/util/observed.d.ts.map +1 -0
  591. package/util/observed.js +122 -0
  592. package/util/observed.js.map +1 -0
  593. package/util/sorted.d.ts +2 -0
  594. package/util/sorted.d.ts.map +1 -0
  595. package/util/sorted.js +149 -0
  596. package/util/sorted.js.map +1 -0
  597. package/util/timeout.d.ts +2 -1
  598. package/util/timeout.d.ts.map +1 -1
  599. package/util/timeout.js +13 -10
  600. package/util/timeout.js.map +1 -1
  601. package/util/timer.d.ts +2 -0
  602. package/util/timer.d.ts.map +1 -0
  603. package/util/timer.js +19 -0
  604. package/util/timer.js.map +1 -0
  605. package/util/u64.js +0 -1
  606. package/util/utf8.d.ts +2 -0
  607. package/util/utf8.d.ts.map +1 -1
  608. package/util/utf8.js +7 -2
  609. package/util/utf8.js.map +1 -1
  610. package/util/varint.d.ts.map +1 -1
  611. package/util/varint.js +8 -2
  612. package/util/varint.js.map +1 -1
  613. package/util/watch.d.ts +8 -0
  614. package/util/watch.d.ts.map +1 -0
  615. package/util/watch.js +38 -0
  616. package/util/watch.js.map +1 -0
  617. package/util/yield.d.ts +2 -0
  618. package/util/yield.d.ts.map +1 -0
  619. package/util/yield.js +31 -0
  620. package/util/yield.js.map +1 -0
  621. package/varint.d.ts +0 -29
  622. package/varint.d.ts.map +1 -1
  623. package/varint.js +7 -29
  624. package/varint.js.map +1 -1
  625. package/varint_api.d.ts +7 -0
  626. package/varint_api.d.ts.map +1 -0
  627. package/varint_api.js +7 -0
  628. package/varint_api.js.map +1 -0
  629. package/version.d.ts +2 -0
  630. package/version.d.ts.map +1 -0
  631. package/version.js +4 -0
  632. package/version.js.map +1 -0
  633. package/window.d.ts +570 -0
  634. package/window.d.ts.map +1 -0
  635. package/window.js +1677 -0
  636. package/window.js.map +1 -0
  637. package/wire.d.ts +150 -35
  638. package/wire.d.ts.map +1 -1
  639. package/wire.js +27 -1
  640. package/wire.js.map +1 -1
  641. package/connection/established.d.ts +0 -53
  642. package/connection/established.d.ts.map +0 -1
  643. package/connection/established.js +0 -3
  644. package/connection/established.js.map +0 -1
  645. package/ietf/adapter.d.ts +0 -75
  646. package/ietf/adapter.d.ts.map +0 -1
  647. package/ietf/adapter.js +0 -700
  648. package/ietf/adapter.js.map +0 -1
  649. package/lite/datagram_stream.d.ts +0 -8
  650. package/lite/datagram_stream.d.ts.map +0 -1
  651. package/lite/datagram_stream.js +0 -44
  652. package/lite/datagram_stream.js.map +0 -1
  653. package/lite/fetch.d.ts +0 -28
  654. package/lite/fetch.d.ts.map +0 -1
  655. package/lite/fetch.js +0 -79
  656. package/lite/fetch.js.map +0 -1
  657. package/util/log.d.ts +0 -5
  658. package/util/log.d.ts.map +0 -1
  659. package/util/log.js +0 -17
  660. package/util/log.js.map +0 -1
  661. package/zod.d.ts +0 -13
  662. package/zod.d.ts.map +0 -1
  663. package/zod.js +0 -19
  664. package/zod.js.map +0 -1
package/ietf/adapter.js DELETED
@@ -1,700 +0,0 @@
1
- /* @ts-self-types="./adapter.d.ts" */
2
- import { Once } from "@moq/signals";
3
- import { Mutex } from "async-mutex";
4
- import { error, ProtocolViolation } from "../error.js";
5
- import { Reader, Stream } from "../stream.js";
6
- import * as Varint from "../varint.js";
7
- import { GoAway } from "./goaway.js";
8
- import * as Namespace from "./namespace.js";
9
- import { Version } from "./version.js";
10
- /**
11
- * v17 native session — thin wrapper around WebTransport.
12
- * Each request gets its own real bidi stream; no control stream multiplexing.
13
- */
14
- export class NativeSession {
15
- #quic;
16
- // moq-transport reserves even request IDs for the client and odd for the server,
17
- // so the two peers' ID spaces never overlap.
18
- #requestId;
19
- version;
20
- constructor(quic, version, client) {
21
- this.#quic = quic;
22
- this.version = version;
23
- this.#requestId = client ? 0n : 1n;
24
- }
25
- async openBi() {
26
- return Stream.open(this.#quic, { version: this.version });
27
- }
28
- async acceptBi() {
29
- return Stream.accept(this.#quic, this.version);
30
- }
31
- async nextRequestId() {
32
- const id = this.#requestId;
33
- this.#requestId += 2n;
34
- return id;
35
- }
36
- /** Closes the underlying WebTransport session. */
37
- close() {
38
- this.#quic.close();
39
- }
40
- }
41
- // Route classification for control stream messages.
42
- const Route = {
43
- NewRequest: 0, // Create virtual bidi stream, push initial message
44
- Response: 1, // Push message to existing stream (keep open)
45
- ErrorResponse: 2, // Push a final message to existing stream, then close
46
- CloseStream: 3, // Close stream recv (no bytes pushed)
47
- FollowUp: 4, // Push follow-up message to existing stream
48
- MaxRequestId: 5, // Update flow control
49
- Ignore: 6, // Connection-level, no routing
50
- GoAway: 7, // Terminal
51
- };
52
- /**
53
- * Converts v14-v16 control stream multiplexing into virtual bidi streams.
54
- *
55
- * Reads control messages, classifies them, and routes to virtual Stream objects.
56
- * Each request/response pair gets its own virtual Stream, making all versions
57
- * look like v17's stream-per-request model.
58
- */
59
- export class ControlStreamAdapter {
60
- // WebTransport session (for opening real bidi streams in v16)
61
- #quic;
62
- // Control stream
63
- #reader;
64
- #writer;
65
- #writeMutex = new Mutex();
66
- version;
67
- /** The peer's GOAWAY, which draft-14 to -16 carry on the shared control stream. */
68
- goaway = new Once();
69
- // Virtual streams keyed by requestId
70
- #streams = new Map();
71
- // Namespace → requestId reverse lookups for v14/v15 namespace-keyed messages.
72
- // DONE names an incoming announcement and CANCEL names an outgoing one, so a relay
73
- // may legitimately hold the same namespace in both maps at once.
74
- #incomingNamespaces = new Map();
75
- #outgoingNamespaces = new Map();
76
- // requestId → namespace reverse lookup, one entry per request including a refused
77
- // duplicate, so #forget can clean up whichever request goes away.
78
- #namespacesByRequestId = new Map();
79
- // SubscribeNamespace requestIds — for routing 0x08/0x0E entries that lack requestId (v14/v15)
80
- #subscribeNamespaces = new Set();
81
- // Incoming stream queue (for acceptBi)
82
- #incomingQueue = [];
83
- #incomingWaiters = [];
84
- // Request ID flow control. moq-transport reserves even request IDs for the
85
- // client and odd for the server, so the two peers' ID spaces never overlap.
86
- // This matters here because a single `#streams` map routes every request by
87
- // ID: overlapping spaces would let an inbound request clobber the routing
88
- // entry of an outbound one with the same number (e.g. an inbound
89
- // PUBLISH_NAMESPACE stealing a pending SUBSCRIBE's slot, so SUBSCRIBE_OK is
90
- // delivered to the wrong virtual stream).
91
- #requestId;
92
- #maxRequestId;
93
- #maxRequestIdResolves = [];
94
- #closed = false;
95
- // Whether this side opened the session. Only a server may name a redirect.
96
- #client;
97
- constructor(quic, controlStream, version, maxRequestId, client) {
98
- this.#quic = quic;
99
- this.#reader = controlStream.reader;
100
- this.#reader.version = version;
101
- this.#writer = controlStream.writer;
102
- this.#writer.version = version;
103
- this.version = version;
104
- this.#maxRequestId = maxRequestId;
105
- this.#requestId = client ? 0n : 1n;
106
- this.#client = client;
107
- }
108
- /**
109
- * Accept the next incoming virtual bidi stream.
110
- * Blocks until a new request arrives on the control stream.
111
- */
112
- async acceptBi() {
113
- if (this.#closed)
114
- return undefined;
115
- const queued = this.#incomingQueue.shift();
116
- if (queued)
117
- return queued;
118
- return new Promise((resolve) => {
119
- this.#incomingWaiters.push(resolve);
120
- });
121
- }
122
- /**
123
- * Open an outgoing virtual bidi stream.
124
- * Buffers writes until the first full message is available, parses the
125
- * requestId (and namespace for PublishNamespace), self-registers, then
126
- * flushes. Subsequent writes go directly to the control stream.
127
- */
128
- openBi() {
129
- let controller;
130
- let registeredRequestId;
131
- const readable = new ReadableStream({
132
- start(c) {
133
- controller = c;
134
- },
135
- cancel: () => {
136
- if (registeredRequestId !== undefined) {
137
- this.#forget(registeredRequestId);
138
- }
139
- },
140
- });
141
- let buffer = new Uint8Array(0);
142
- let registered = false;
143
- const sendWritable = new WritableStream({
144
- write: async (chunk) => {
145
- // Always accumulate bytes and flush only complete messages
146
- // to prevent interleaving of partial messages from concurrent virtual streams.
147
- const newBuf = new Uint8Array(buffer.length + chunk.length);
148
- newBuf.set(buffer);
149
- newBuf.set(chunk, buffer.length);
150
- buffer = newBuf;
151
- // Try to flush complete messages from the buffer
152
- for (;;) {
153
- const boundary = this.#messageSize(buffer);
154
- if (boundary === undefined)
155
- break;
156
- const toFlush = buffer.subarray(0, boundary);
157
- buffer = buffer.subarray(boundary);
158
- if (!registered) {
159
- // First message: extract requestId and register before flushing
160
- const parsed = await this.#tryParseOutgoing(toFlush);
161
- if (parsed) {
162
- registeredRequestId = parsed.requestId;
163
- this.#streams.set(parsed.requestId, { controller });
164
- registered = true;
165
- }
166
- }
167
- await this.#writeMutex.runExclusive(() => this.#writer.write(toFlush));
168
- }
169
- },
170
- });
171
- const stream = new Stream({ readable, writable: sendWritable, version: this.version });
172
- return stream;
173
- }
174
- /**
175
- * Open a real WebTransport bidi stream (for v16 SubscribeNamespace).
176
- */
177
- async openNativeBi() {
178
- return Stream.open(this.#quic, { version: this.version });
179
- }
180
- /**
181
- * Allocate the next request ID, blocking if flow control limit reached.
182
- */
183
- async nextRequestId() {
184
- for (;;) {
185
- if (this.#closed)
186
- return undefined;
187
- const id = this.#requestId;
188
- if (id < this.#maxRequestId) {
189
- this.#requestId += 2n;
190
- return id;
191
- }
192
- await new Promise((resolve) => {
193
- this.#maxRequestIdResolves.push(resolve);
194
- });
195
- }
196
- }
197
- /**
198
- * Main run loop — reads control stream messages and routes to virtual streams.
199
- * Must be called after construction. Runs until the control stream closes.
200
- */
201
- async run() {
202
- // Why the virtual streams end: undefined only for a GOAWAY, which is not a failure.
203
- let cause;
204
- try {
205
- // v16: also accept real bidi streams (for SubscribeNamespace)
206
- if (this.version === Version.DRAFT_16) {
207
- void this.#acceptNativeBidis();
208
- }
209
- for (;;) {
210
- const done = await this.#reader.done();
211
- if (done) {
212
- cause = new ProtocolViolation("control stream closed");
213
- break;
214
- }
215
- const typeId = await this.#reader.u53();
216
- const size = await this.#reader.u16();
217
- const body = await this.#reader.read(size);
218
- const classified = await this.#classify(typeId, body);
219
- if (classified.route === Route.GoAway) {
220
- // The session keeps serving: a GOAWAY asks us to migrate, not to stop reading.
221
- const msg = await GoAway.decodeBody(body, this.version);
222
- if (this.goaway.peek() !== undefined)
223
- throw new ProtocolViolation("duplicate GOAWAY");
224
- // A client may leave, but only the server may name where to go.
225
- if (!this.#client && msg.newSessionUri !== "") {
226
- throw new ProtocolViolation("client GOAWAY must not name a redirect");
227
- }
228
- this.goaway.set(msg.drain());
229
- continue;
230
- }
231
- const { route, requestId } = classified;
232
- switch (route) {
233
- case Route.NewRequest:
234
- this.#newRequest(typeId, size, body, requestId);
235
- break;
236
- case Route.Response:
237
- this.#pushMessage(requestId, typeId, size, body);
238
- break;
239
- case Route.ErrorResponse:
240
- this.#pushMessage(requestId, typeId, size, body);
241
- this.#closeStream(requestId);
242
- break;
243
- case Route.CloseStream:
244
- this.#closeStream(requestId);
245
- break;
246
- case Route.FollowUp:
247
- this.#pushMessage(requestId, typeId, size, body);
248
- break;
249
- case Route.MaxRequestId:
250
- this.#maxRequestId = requestId;
251
- for (const resolve of this.#maxRequestIdResolves)
252
- resolve();
253
- this.#maxRequestIdResolves = [];
254
- break;
255
- }
256
- }
257
- }
258
- catch (err) {
259
- cause = error(err);
260
- throw err;
261
- }
262
- finally {
263
- this.close(cause);
264
- }
265
- }
266
- /** Accept real WebTransport bidi streams and queue them for acceptBi (v16). */
267
- async #acceptNativeBidis() {
268
- try {
269
- for (;;) {
270
- const stream = await Stream.accept(this.#quic, this.version);
271
- if (!stream)
272
- break;
273
- const waiter = this.#incomingWaiters.shift();
274
- if (waiter) {
275
- waiter(stream);
276
- }
277
- else {
278
- this.#incomingQueue.push(stream);
279
- }
280
- }
281
- }
282
- catch {
283
- // Session closed
284
- }
285
- }
286
- #newRequest(typeId, size, body, requestId) {
287
- let controller;
288
- const readable = new ReadableStream({
289
- start(c) {
290
- controller = c;
291
- },
292
- cancel: () => {
293
- this.#forget(requestId);
294
- },
295
- });
296
- const sendWritable = this.#createSendWritable();
297
- const stream = new Stream({ readable, writable: sendWritable, version: this.version });
298
- this.#streams.set(requestId, { controller });
299
- // Push initial message bytes so the dispatcher can read typeId + decode
300
- controller.enqueue(this.#encodeRaw(typeId, size, body));
301
- // Queue for acceptBi
302
- const waiter = this.#incomingWaiters.shift();
303
- if (waiter) {
304
- waiter(stream);
305
- }
306
- else {
307
- this.#incomingQueue.push(stream);
308
- }
309
- }
310
- #pushMessage(requestId, typeId, size, body) {
311
- const entry = this.#streams.get(requestId);
312
- if (!entry) {
313
- console.warn(`adapter: no stream for requestId=${requestId} typeId=0x${typeId.toString(16)}`);
314
- return;
315
- }
316
- try {
317
- entry.controller.enqueue(this.#encodeRaw(typeId, size, body));
318
- }
319
- catch {
320
- // Stream already closed
321
- }
322
- }
323
- #closeStream(requestId) {
324
- const entry = this.#streams.get(requestId);
325
- this.#forget(requestId);
326
- if (!entry)
327
- return;
328
- console.debug(`adapter: closing stream requestId=${requestId}`);
329
- try {
330
- entry.controller.close();
331
- }
332
- catch {
333
- // Already closed
334
- }
335
- }
336
- /**
337
- * Drop every routing entry a request owns, keeping the two namespace maps in step.
338
- *
339
- * Runs even when the virtual stream is already gone, so a request that was torn down
340
- * locally still gives its namespace back.
341
- */
342
- #forget(requestId) {
343
- this.#streams.delete(requestId);
344
- this.#subscribeNamespaces.delete(requestId);
345
- const registered = this.#namespacesByRequestId.get(requestId);
346
- if (registered === undefined)
347
- return;
348
- this.#namespacesByRequestId.delete(requestId);
349
- const namespaces = this.#namespaceRequests(registered.direction);
350
- // Only the request holding the live announcement may retract it. A refused duplicate
351
- // carries the same name, and letting its close withdraw the name would strand the
352
- // original: its own DONE would then resolve to nothing.
353
- if (namespaces.get(registered.namespace) === requestId)
354
- namespaces.delete(registered.namespace);
355
- }
356
- /**
357
- * Returns the total byte size of the first complete message in buffer,
358
- * or undefined if the buffer doesn't contain a complete message yet.
359
- * Message format: [typeId varint][size u16 BE][body of `size` bytes]
360
- */
361
- #messageSize(buffer) {
362
- if (buffer.length === 0)
363
- return undefined;
364
- const typeSize = 1 << ((buffer[0] & 0xc0) >> 6);
365
- if (buffer.length < typeSize)
366
- return undefined;
367
- const [, afterType] = Varint.decode(buffer);
368
- if (afterType.length < 2)
369
- return undefined;
370
- const size = (afterType[0] << 8) | afterType[1];
371
- const totalSize = buffer.length - afterType.length + 2 + size;
372
- if (buffer.length < totalSize)
373
- return undefined;
374
- return totalSize;
375
- }
376
- /**
377
- * Try to parse the first outgoing message from accumulated bytes.
378
- * Returns the requestId if enough data is available, undefined otherwise.
379
- */
380
- async #tryParseOutgoing(buffer) {
381
- if (buffer.length === 0)
382
- return undefined;
383
- // Check typeId varint size before decoding
384
- const typeSize = 1 << ((buffer[0] & 0xc0) >> 6);
385
- if (buffer.length < typeSize)
386
- return undefined;
387
- const [typeId, afterType] = Varint.decode(buffer);
388
- // Need 2 bytes for u16 size
389
- if (afterType.length < 2)
390
- return undefined;
391
- const size = (afterType[0] << 8) | afterType[1];
392
- const bodyStart = afterType.subarray(2);
393
- // Need full body
394
- if (bodyStart.length < size)
395
- return undefined;
396
- const body = bodyStart.subarray(0, size);
397
- // Decode requestId from body (QUIC varint)
398
- const [reqId] = Varint.decode(body);
399
- const requestId = BigInt(reqId);
400
- // PublishNamespace (0x06): also parse namespace for v14/v15 reverse lookup
401
- if (typeId === 0x06) {
402
- try {
403
- await this.#registerNamespace(body, "outgoing");
404
- }
405
- catch {
406
- // Non-critical: only needed for v14/v15 PublishNamespaceDone/Cancel
407
- }
408
- }
409
- // SubscribeNamespace (0x11): register for follow-up routing
410
- if (typeId === 0x11) {
411
- this.#subscribeNamespaces.add(requestId);
412
- }
413
- return { requestId };
414
- }
415
- /**
416
- * Decode a PublishNamespace body and register its namespace for the v14/v15
417
- * namespace-keyed withdrawals. Returns the request ID it carried.
418
- *
419
- * The one decode site for both directions: outgoing announcements go through
420
- * #tryParseOutgoing and incoming ones through #classify. The direction selects the
421
- * map that the peer's DONE or CANCEL will later consult.
422
- */
423
- async #registerNamespace(body, direction) {
424
- const r = new Reader(undefined, body, this.version);
425
- const requestId = await r.u62();
426
- const namespace = await Namespace.decode(r);
427
- const namespaces = this.#namespaceRequests(direction);
428
- this.#namespacesByRequestId.set(requestId, { namespace, direction });
429
- // First announcement in this direction wins. A duplicate is refused with 409, and
430
- // overwriting here would point the first request's withdrawal at the refused one,
431
- // which has no stream left, leaving the namespace announced forever.
432
- if (!namespaces.has(namespace))
433
- namespaces.set(namespace, requestId);
434
- return requestId;
435
- }
436
- #namespaceRequests(direction) {
437
- return direction === "incoming" ? this.#incomingNamespaces : this.#outgoingNamespaces;
438
- }
439
- /** Create a WritableStream that buffers and writes complete messages to the control stream under mutex. */
440
- #createSendWritable() {
441
- let buffer = new Uint8Array(0);
442
- return new WritableStream({
443
- write: async (chunk) => {
444
- const newBuf = new Uint8Array(buffer.length + chunk.length);
445
- newBuf.set(buffer);
446
- newBuf.set(chunk, buffer.length);
447
- buffer = newBuf;
448
- for (;;) {
449
- const boundary = this.#messageSize(buffer);
450
- if (boundary === undefined)
451
- break;
452
- const toFlush = buffer.subarray(0, boundary);
453
- buffer = buffer.subarray(boundary);
454
- await this.#writeMutex.runExclusive(() => this.#writer.write(toFlush));
455
- }
456
- },
457
- });
458
- }
459
- /** Encode raw message bytes: [typeId varint][size u16 BE][body] */
460
- #encodeRaw(typeId, size, body) {
461
- // v14-v16 always use QUIC varint
462
- const typeIdBytes = Varint.encodeTo(new ArrayBuffer(9), typeId);
463
- const result = new Uint8Array(typeIdBytes.byteLength + 2 + body.byteLength);
464
- result.set(typeIdBytes, 0);
465
- const sizeView = new DataView(result.buffer, typeIdBytes.byteLength, 2);
466
- sizeView.setUint16(0, size);
467
- result.set(body, typeIdBytes.byteLength + 2);
468
- return result;
469
- }
470
- /**
471
- * Classify a control message and extract its requestId for routing.
472
- */
473
- async #classify(typeId, body) {
474
- const readRequestId = async () => {
475
- const r = new Reader(undefined, body, this.version);
476
- return await r.u62();
477
- };
478
- // v14/v15 name their withdrawals instead of numbering them. A name we have no
479
- // announcement for is dropped, not fatal: it belongs to a duplicate we already
480
- // refused, or to a request that is already gone, so there is nothing left to close.
481
- // The mapping itself is released by #forget when the stream goes.
482
- const readNamespaceRequestId = async (direction) => {
483
- const r = new Reader(undefined, body, this.version);
484
- const namespace = await Namespace.decode(r);
485
- const namespaces = this.#namespaceRequests(direction);
486
- const requestId = namespaces.get(namespace);
487
- if (requestId === undefined)
488
- console.warn(`adapter: no announcement for namespace: ${namespace}`);
489
- return requestId;
490
- };
491
- switch (typeId) {
492
- // === FollowUp: route to existing stream ===
493
- case 0x02: {
494
- // SubscribeUpdate / REQUEST_UPDATE
495
- const requestId = await readRequestId();
496
- return { route: Route.FollowUp, requestId };
497
- }
498
- // === NewRequest: create virtual stream ===
499
- case 0x03: // Subscribe
500
- case 0x16: // Fetch
501
- case 0x1d: // Publish
502
- case 0x0d: {
503
- // TrackStatusRequest
504
- const requestId = await readRequestId();
505
- return { route: Route.NewRequest, requestId };
506
- }
507
- case 0x06: {
508
- // PublishNamespace: also store the namespace for v14/v15 reverse lookup
509
- const requestId = await this.#registerNamespace(body, "incoming");
510
- return { route: Route.NewRequest, requestId };
511
- }
512
- case 0x11: {
513
- // SubscribeNamespace (v14/v15 only on control stream)
514
- if (this.version !== Version.DRAFT_14 && this.version !== Version.DRAFT_15) {
515
- throw new Error("unexpected SubscribeNamespace on control stream");
516
- }
517
- const requestId = await readRequestId();
518
- return { route: Route.NewRequest, requestId };
519
- }
520
- // === Response: push bytes, keep stream open ===
521
- case 0x04: {
522
- // SubscribeOk
523
- const requestId = await readRequestId();
524
- return { route: Route.Response, requestId };
525
- }
526
- case 0x18: {
527
- // FetchOk
528
- const requestId = await readRequestId();
529
- return { route: Route.Response, requestId };
530
- }
531
- case 0x1e: {
532
- // PublishOk
533
- const requestId = await readRequestId();
534
- return { route: Route.Response, requestId };
535
- }
536
- case 0x07: {
537
- // v14: PublishNamespaceOk, v15+: RequestOk
538
- const requestId = await readRequestId();
539
- return { route: Route.Response, requestId };
540
- }
541
- case 0x12: {
542
- // SubscribeNamespaceOk (v14 only)
543
- if (this.version !== Version.DRAFT_14)
544
- throw new Error("unexpected SubscribeNamespaceOk");
545
- const requestId = await readRequestId();
546
- return { route: Route.Response, requestId };
547
- }
548
- // === ErrorResponse: push bytes + close ===
549
- case 0x05: {
550
- // SubscribeError (v14) / RequestError (v15+)
551
- const requestId = await readRequestId();
552
- return { route: Route.ErrorResponse, requestId };
553
- }
554
- case 0x19: {
555
- // FetchError (v14 only)
556
- if (this.version !== Version.DRAFT_14)
557
- throw new Error("unexpected FetchError");
558
- const requestId = await readRequestId();
559
- return { route: Route.ErrorResponse, requestId };
560
- }
561
- case 0x1f: {
562
- // PublishError (v14 only)
563
- if (this.version !== Version.DRAFT_14)
564
- throw new Error("unexpected PublishError");
565
- const requestId = await readRequestId();
566
- return { route: Route.ErrorResponse, requestId };
567
- }
568
- case 0x08: {
569
- if (this.version === Version.DRAFT_14) {
570
- // PublishNamespaceError
571
- const requestId = await readRequestId();
572
- return { route: Route.ErrorResponse, requestId };
573
- }
574
- // v15: Namespace entry (no requestId) — route to SubscribeNamespace stream
575
- const subNs08 = this.#subscribeNamespaces.values().next().value;
576
- if (subNs08 === undefined)
577
- throw new Error("unexpected message 0x08: no SubscribeNamespace stream");
578
- return { route: Route.FollowUp, requestId: subNs08 };
579
- }
580
- case 0x0e: {
581
- if (this.version === Version.DRAFT_14 || this.version === Version.DRAFT_15) {
582
- throw new Error("unexpected message 0x0e");
583
- }
584
- // v16+: NamespaceDone entry (no requestId) — route to SubscribeNamespace stream
585
- const subNs0e = this.#subscribeNamespaces.values().next().value;
586
- if (subNs0e === undefined)
587
- throw new Error("unexpected message 0x0e: no SubscribeNamespace stream");
588
- return { route: Route.FollowUp, requestId: subNs0e };
589
- }
590
- case 0x13: {
591
- // SubscribeNamespaceError (v14 only)
592
- if (this.version !== Version.DRAFT_14)
593
- throw new Error("unexpected SubscribeNamespaceError");
594
- const requestId = await readRequestId();
595
- return { route: Route.ErrorResponse, requestId };
596
- }
597
- // === CloseStream: close recv (no bytes pushed) ===
598
- case 0x0a: {
599
- // Unsubscribe
600
- const requestId = await readRequestId();
601
- return { route: Route.CloseStream, requestId };
602
- }
603
- case 0x0b: {
604
- // PublishDone: the subscriber reads its status and stream count before the end.
605
- const requestId = await readRequestId();
606
- return { route: Route.ErrorResponse, requestId };
607
- }
608
- case 0x17: {
609
- // FetchCancel
610
- const requestId = await readRequestId();
611
- return { route: Route.CloseStream, requestId };
612
- }
613
- case 0x09: {
614
- // PublishNamespaceDone: v16 uses requestId, v14/v15 names the incoming
615
- // announcement its sender is withdrawing.
616
- if (this.version === Version.DRAFT_16) {
617
- const requestId = await readRequestId();
618
- return { route: Route.CloseStream, requestId };
619
- }
620
- const requestId = await readNamespaceRequestId("incoming");
621
- if (requestId === undefined)
622
- return { route: Route.Ignore, requestId: 0n };
623
- return { route: Route.CloseStream, requestId };
624
- }
625
- case 0x0c: {
626
- // PublishNamespaceCancel: v16 uses requestId, v14/v15 names the outgoing
627
- // announcement its sender is rejecting.
628
- if (this.version === Version.DRAFT_16) {
629
- const requestId = await readRequestId();
630
- return { route: Route.CloseStream, requestId };
631
- }
632
- const requestId = await readNamespaceRequestId("outgoing");
633
- if (requestId === undefined)
634
- return { route: Route.Ignore, requestId: 0n };
635
- return { route: Route.CloseStream, requestId };
636
- }
637
- case 0x14: {
638
- // UnsubscribeNamespace (v14/v15 only)
639
- if (this.version !== Version.DRAFT_14 && this.version !== Version.DRAFT_15) {
640
- throw new Error("unexpected UnsubscribeNamespace");
641
- }
642
- const requestId = await readRequestId();
643
- return { route: Route.CloseStream, requestId };
644
- }
645
- // === Utility ===
646
- case 0x15: {
647
- // MaxRequestId
648
- const requestId = await readRequestId();
649
- return { route: Route.MaxRequestId, requestId };
650
- }
651
- case 0x1a: {
652
- // RequestsBlocked — connection-level, consume and ignore
653
- await readRequestId();
654
- return { route: Route.Ignore, requestId: 0n };
655
- }
656
- // === Terminal ===
657
- case 0x10: // GoAway
658
- return { route: Route.GoAway };
659
- default:
660
- throw new Error(`unknown control message type: 0x${typeId.toString(16)}`);
661
- }
662
- }
663
- /**
664
- * Ends every virtual stream: cleanly for a deliberate close, or with `err` when the
665
- * control stream died under them, since every request riding it was cut off.
666
- */
667
- close(err) {
668
- if (this.#closed)
669
- return;
670
- this.#closed = true;
671
- console.debug("adapter: close() called");
672
- for (const entry of this.#streams.values()) {
673
- try {
674
- if (err)
675
- entry.controller.error(err);
676
- else
677
- entry.controller.close();
678
- }
679
- catch {
680
- // Already closed
681
- }
682
- }
683
- this.#streams.clear();
684
- // Resolve any waiting acceptBi callers
685
- for (const waiter of this.#incomingWaiters) {
686
- waiter(undefined);
687
- }
688
- this.#incomingWaiters = [];
689
- // Clear namespace mappings
690
- this.#incomingNamespaces.clear();
691
- this.#outgoingNamespaces.clear();
692
- this.#namespacesByRequestId.clear();
693
- this.#subscribeNamespaces.clear();
694
- // Unblock maxRequestId waiters
695
- for (const resolve of this.#maxRequestIdResolves)
696
- resolve();
697
- this.#maxRequestIdResolves = [];
698
- }
699
- }
700
- //# sourceMappingURL=adapter.js.map