@moq/net 0.4.8 → 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 (662) 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 -1
  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 -31
  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 -138
  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 -1
  33. package/bandwidth_api.js.map +1 -1
  34. package/broadcast.d.ts +62 -36
  35. package/broadcast.d.ts.map +1 -1
  36. package/broadcast.js +556 -172
  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 +20 -12
  47. package/connection/accept.d.ts.map +1 -1
  48. package/connection/accept.js +97 -129
  49. package/connection/accept.js.map +1 -1
  50. package/connection/browser.d.ts.map +1 -1
  51. package/connection/browser.js +28 -19
  52. package/connection/browser.js.map +1 -1
  53. package/connection/connect.d.ts +119 -23
  54. package/connection/connect.d.ts.map +1 -1
  55. package/connection/connect.js +535 -216
  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 -80
  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 -108
  72. package/connection/goaway.js.map +1 -1
  73. package/connection/handshake.d.ts +32 -6
  74. package/connection/handshake.d.ts.map +1 -1
  75. package/connection/handshake.js +97 -20
  76. package/connection/handshake.js.map +1 -1
  77. package/connection/index.d.ts +3 -6
  78. package/connection/index.d.ts.map +1 -1
  79. package/connection/index.js +1 -2
  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 +137 -58
  86. package/connection/pool.d.ts.map +1 -1
  87. package/connection/pool.js +281 -117
  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 -233
  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 -8
  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 -4
  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 -46
  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 -1
  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 -37
  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 -2
  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 -307
  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 -64
  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 -35
  199. package/ietf/aliases.js.map +1 -1
  200. package/ietf/cluster.d.ts +3 -3
  201. package/ietf/cluster.js +14 -62
  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 -143
  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 -100
  213. package/ietf/error.js.map +1 -1
  214. package/ietf/fetch.d.ts +91 -35
  215. package/ietf/fetch.d.ts.map +1 -1
  216. package/ietf/fetch.js +172 -93
  217. package/ietf/fetch.js.map +1 -1
  218. package/ietf/filter.d.ts +20 -30
  219. package/ietf/filter.d.ts.map +1 -1
  220. package/ietf/filter.js +140 -171
  221. package/ietf/filter.js.map +1 -1
  222. package/ietf/goaway.d.ts +11 -9
  223. package/ietf/goaway.d.ts.map +1 -1
  224. package/ietf/goaway.js +22 -35
  225. package/ietf/goaway.js.map +1 -1
  226. package/ietf/hidden.js +1 -1
  227. package/ietf/hidden.js.map +1 -1
  228. package/ietf/index.d.ts +2 -14
  229. package/ietf/index.d.ts.map +1 -1
  230. package/ietf/index.js +4 -14
  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 -40
  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 +17 -3
  245. package/ietf/namespace.d.ts.map +1 -1
  246. package/ietf/namespace.js +78 -26
  247. package/ietf/namespace.js.map +1 -1
  248. package/ietf/object.d.ts +194 -32
  249. package/ietf/object.d.ts.map +1 -1
  250. package/ietf/object.js +405 -178
  251. package/ietf/object.js.map +1 -1
  252. package/ietf/parameters.d.ts +22 -42
  253. package/ietf/parameters.d.ts.map +1 -1
  254. package/ietf/parameters.js +260 -472
  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 -4
  259. package/ietf/priority.js.map +1 -1
  260. package/ietf/properties.d.ts +5 -4
  261. package/ietf/properties.d.ts.map +1 -1
  262. package/ietf/properties.js +78 -48
  263. package/ietf/properties.js.map +1 -1
  264. package/ietf/publish.d.ts +22 -30
  265. package/ietf/publish.d.ts.map +1 -1
  266. package/ietf/publish.js +45 -139
  267. package/ietf/publish.js.map +1 -1
  268. package/ietf/publish_namespace.d.ts +46 -69
  269. package/ietf/publish_namespace.d.ts.map +1 -1
  270. package/ietf/publish_namespace.js +66 -184
  271. package/ietf/publish_namespace.js.map +1 -1
  272. package/ietf/publisher.js +1800 -600
  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 +3 -27
  279. package/ietf/request.d.ts.map +1 -1
  280. package/ietf/request.js +41 -78
  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 -16
  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 +4 -29
  291. package/ietf/setup.d.ts.map +1 -1
  292. package/ietf/setup.js +6 -117
  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 -14
  299. package/ietf/solicit.js.map +1 -1
  300. package/ietf/subscribe.d.ts +48 -41
  301. package/ietf/subscribe.d.ts.map +1 -1
  302. package/ietf/subscribe.js +118 -239
  303. package/ietf/subscribe.js.map +1 -1
  304. package/ietf/subscribe_namespace.d.ts +13 -76
  305. package/ietf/subscribe_namespace.d.ts.map +1 -1
  306. package/ietf/subscribe_namespace.js +30 -201
  307. package/ietf/subscribe_namespace.js.map +1 -1
  308. package/ietf/subscriber.js +1839 -536
  309. package/ietf/subscriber.js.map +1 -1
  310. package/ietf/token.js +105 -27
  311. package/ietf/token.js.map +1 -1
  312. package/ietf/track.d.ts +25 -22
  313. package/ietf/track.d.ts.map +1 -1
  314. package/ietf/track.js +48 -61
  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 -48
  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 +25 -10
  325. package/index.d.ts.map +1 -1
  326. package/index.js +19 -6
  327. package/index.js.map +1 -1
  328. package/internal.d.ts +1512 -64
  329. package/internal.d.ts.map +1 -1
  330. package/internal.js +557 -79
  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 +124 -63
  341. package/lite/announce.d.ts.map +1 -1
  342. package/lite/announce.js +384 -158
  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 -77
  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 -9
  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 +1 -1
  389. package/lite/goaway.d.ts.map +1 -1
  390. package/lite/goaway.js +5 -13
  391. package/lite/goaway.js.map +1 -1
  392. package/lite/group.d.ts +64 -13
  393. package/lite/group.d.ts.map +1 -1
  394. package/lite/group.js +108 -30
  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 +2 -1
  401. package/lite/index.d.ts.map +1 -1
  402. package/lite/index.js +2 -1
  403. package/lite/index.js.map +1 -1
  404. package/lite/message.d.ts +9 -1
  405. package/lite/message.d.ts.map +1 -1
  406. package/lite/message.js +28 -44
  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 -105
  411. package/lite/priority.js.map +1 -1
  412. package/lite/probe.d.ts.map +1 -1
  413. package/lite/probe.js +9 -0
  414. package/lite/probe.js.map +1 -1
  415. package/lite/publisher.d.ts +10 -1
  416. package/lite/publisher.d.ts.map +1 -1
  417. package/lite/publisher.js +2548 -437
  418. package/lite/publisher.js.map +1 -1
  419. package/lite/routed.d.ts +59 -0
  420. package/lite/routed.d.ts.map +1 -0
  421. package/lite/routed.js +564 -0
  422. package/lite/routed.js.map +1 -0
  423. package/lite/session.d.ts +1 -27
  424. package/lite/session.d.ts.map +1 -1
  425. package/lite/session.js +0 -99
  426. package/lite/session.js.map +1 -1
  427. package/lite/setup.d.ts +29 -2
  428. package/lite/setup.d.ts.map +1 -1
  429. package/lite/setup.js +95 -21
  430. package/lite/setup.js.map +1 -1
  431. package/lite/stream.d.ts +5 -11
  432. package/lite/stream.d.ts.map +1 -1
  433. package/lite/stream.js +5 -1
  434. package/lite/stream.js.map +1 -1
  435. package/lite/subscribe.d.ts +475 -75
  436. package/lite/subscribe.d.ts.map +1 -1
  437. package/lite/subscribe.js +1373 -142
  438. package/lite/subscribe.js.map +1 -1
  439. package/lite/subscriber.d.ts +7 -44
  440. package/lite/subscriber.d.ts.map +1 -1
  441. package/lite/subscriber.js +3290 -515
  442. package/lite/subscriber.js.map +1 -1
  443. package/lite/track.d.ts +24 -9
  444. package/lite/track.d.ts.map +1 -1
  445. package/lite/track.js +116 -37
  446. package/lite/track.js.map +1 -1
  447. package/lite/tracks.d.ts +55 -0
  448. package/lite/tracks.d.ts.map +1 -0
  449. package/lite/tracks.js +114 -0
  450. package/lite/tracks.js.map +1 -0
  451. package/lite/version.d.ts +132 -24
  452. package/lite/version.d.ts.map +1 -1
  453. package/lite/version.js +378 -33
  454. package/lite/version.js.map +1 -1
  455. package/meta.d.ts +77 -0
  456. package/meta.d.ts.map +1 -0
  457. package/meta.js +130 -0
  458. package/meta.js.map +1 -0
  459. package/meta_api.d.ts +7 -0
  460. package/meta_api.d.ts.map +1 -0
  461. package/meta_api.js +7 -0
  462. package/meta_api.js.map +1 -0
  463. package/mint.d.ts +28 -0
  464. package/mint.d.ts.map +1 -0
  465. package/mint.js +66 -0
  466. package/mint.js.map +1 -0
  467. package/open.d.ts +63 -0
  468. package/open.d.ts.map +1 -0
  469. package/open.js +250 -0
  470. package/open.js.map +1 -0
  471. package/origin.d.ts +392 -140
  472. package/origin.d.ts.map +1 -1
  473. package/origin.js +2533 -686
  474. package/origin.js.map +1 -1
  475. package/package.json +8 -13
  476. package/path.d.ts +51 -51
  477. package/path.d.ts.map +1 -1
  478. package/path.js +210 -57
  479. package/path.js.map +1 -1
  480. package/payload.d.ts +33 -0
  481. package/payload.d.ts.map +1 -0
  482. package/payload.js +65 -0
  483. package/payload.js.map +1 -0
  484. package/prefix.d.ts +152 -0
  485. package/prefix.d.ts.map +1 -0
  486. package/prefix.js +349 -0
  487. package/prefix.js.map +1 -0
  488. package/priority.d.ts +8 -0
  489. package/priority.d.ts.map +1 -0
  490. package/priority.js +185 -0
  491. package/priority.js.map +1 -0
  492. package/queue.d.ts +2 -0
  493. package/queue.d.ts.map +1 -0
  494. package/queue.js +46 -0
  495. package/queue.js.map +1 -0
  496. package/ranges.d.ts +36 -0
  497. package/ranges.d.ts.map +1 -0
  498. package/ranges.js +312 -0
  499. package/ranges.js.map +1 -0
  500. package/rescale.d.ts +24 -0
  501. package/rescale.d.ts.map +1 -0
  502. package/rescale.js +39 -0
  503. package/rescale.js.map +1 -0
  504. package/resume.d.ts +55 -0
  505. package/resume.d.ts.map +1 -0
  506. package/resume.js +4173 -0
  507. package/resume.js.map +1 -0
  508. package/resume.test-util.d.ts +2 -0
  509. package/resume.test-util.d.ts.map +1 -0
  510. package/resume.test-util.js +25 -0
  511. package/resume.test-util.js.map +1 -0
  512. package/skips.d.ts +48 -0
  513. package/skips.d.ts.map +1 -0
  514. package/skips.js +182 -0
  515. package/skips.js.map +1 -0
  516. package/stream.d.ts +75 -37
  517. package/stream.d.ts.map +1 -1
  518. package/stream.js +236 -92
  519. package/stream.js.map +1 -1
  520. package/subscription.test-util.d.ts +2 -0
  521. package/subscription.test-util.d.ts.map +1 -0
  522. package/subscription.test-util.js +49 -0
  523. package/subscription.test-util.js.map +1 -0
  524. package/tail.d.ts +23 -14
  525. package/tail.d.ts.map +1 -1
  526. package/tail.js +224 -97
  527. package/tail.js.map +1 -1
  528. package/time.d.ts +41 -102
  529. package/time.d.ts.map +1 -1
  530. package/time.js +129 -91
  531. package/time.js.map +1 -1
  532. package/timed.d.ts +21 -0
  533. package/timed.d.ts.map +1 -0
  534. package/timed.js +2 -0
  535. package/timed.js.map +1 -0
  536. package/track.d.ts +577 -245
  537. package/track.d.ts.map +1 -1
  538. package/track.js +7306 -771
  539. package/track.js.map +1 -1
  540. package/track_api.d.ts +7 -0
  541. package/track_api.d.ts.map +1 -0
  542. package/track_api.js +7 -0
  543. package/track_api.js.map +1 -0
  544. package/util/abort.d.ts +1 -0
  545. package/util/abort.d.ts.map +1 -1
  546. package/util/abort.js +23 -1
  547. package/util/abort.js.map +1 -1
  548. package/util/announce.d.ts +4 -0
  549. package/util/announce.d.ts.map +1 -0
  550. package/util/announce.js +11 -0
  551. package/util/announce.js.map +1 -0
  552. package/util/bigint.d.ts +3 -0
  553. package/util/bigint.d.ts.map +1 -0
  554. package/util/bigint.js +8 -0
  555. package/util/bigint.js.map +1 -0
  556. package/util/change.d.ts +12 -0
  557. package/util/change.d.ts.map +1 -0
  558. package/util/change.js +18 -0
  559. package/util/change.js.map +1 -0
  560. package/util/deadline.d.ts +2 -0
  561. package/util/deadline.d.ts.map +1 -0
  562. package/util/deadline.js +108 -0
  563. package/util/deadline.js.map +1 -0
  564. package/util/decode_error.d.ts +3 -0
  565. package/util/decode_error.d.ts.map +1 -0
  566. package/util/decode_error.js +11 -0
  567. package/util/decode_error.js.map +1 -0
  568. package/util/demand.d.ts +8 -0
  569. package/util/demand.d.ts.map +1 -0
  570. package/util/demand.js +24 -0
  571. package/util/demand.js.map +1 -0
  572. package/util/given_up.d.ts +2 -0
  573. package/util/given_up.d.ts.map +1 -0
  574. package/util/given_up.js +101 -0
  575. package/util/given_up.js.map +1 -0
  576. package/util/hex.d.ts +6 -0
  577. package/util/hex.d.ts.map +1 -1
  578. package/util/hex.js +19 -4
  579. package/util/hex.js.map +1 -1
  580. package/util/key.d.ts +15 -0
  581. package/util/key.d.ts.map +1 -0
  582. package/util/key.js +38 -0
  583. package/util/key.js.map +1 -0
  584. package/util/limits.d.ts +2 -0
  585. package/util/limits.d.ts.map +1 -0
  586. package/util/limits.js +76 -0
  587. package/util/limits.js.map +1 -0
  588. package/util/observed.d.ts +23 -0
  589. package/util/observed.d.ts.map +1 -0
  590. package/util/observed.js +122 -0
  591. package/util/observed.js.map +1 -0
  592. package/util/sorted.d.ts +2 -0
  593. package/util/sorted.d.ts.map +1 -0
  594. package/util/sorted.js +149 -0
  595. package/util/sorted.js.map +1 -0
  596. package/util/timeout.d.ts +2 -1
  597. package/util/timeout.d.ts.map +1 -1
  598. package/util/timeout.js +13 -9
  599. package/util/timeout.js.map +1 -1
  600. package/util/timer.d.ts +2 -0
  601. package/util/timer.d.ts.map +1 -0
  602. package/util/timer.js +19 -0
  603. package/util/timer.js.map +1 -0
  604. package/util/utf8.d.ts +2 -0
  605. package/util/utf8.d.ts.map +1 -1
  606. package/util/utf8.js +7 -1
  607. package/util/utf8.js.map +1 -1
  608. package/util/varint.d.ts.map +1 -1
  609. package/util/varint.js +8 -1
  610. package/util/varint.js.map +1 -1
  611. package/util/watch.d.ts +8 -0
  612. package/util/watch.d.ts.map +1 -0
  613. package/util/watch.js +38 -0
  614. package/util/watch.js.map +1 -0
  615. package/util/yield.d.ts +2 -0
  616. package/util/yield.d.ts.map +1 -0
  617. package/util/yield.js +31 -0
  618. package/util/yield.js.map +1 -0
  619. package/varint.d.ts +0 -29
  620. package/varint.d.ts.map +1 -1
  621. package/varint.js +7 -28
  622. package/varint.js.map +1 -1
  623. package/varint_api.d.ts +7 -0
  624. package/varint_api.d.ts.map +1 -0
  625. package/varint_api.js +7 -0
  626. package/varint_api.js.map +1 -0
  627. package/version.d.ts +2 -0
  628. package/version.d.ts.map +1 -0
  629. package/version.js +4 -0
  630. package/version.js.map +1 -0
  631. package/window.d.ts +570 -0
  632. package/window.d.ts.map +1 -0
  633. package/window.js +1677 -0
  634. package/window.js.map +1 -0
  635. package/wire.d.ts +145 -30
  636. package/wire.d.ts.map +1 -1
  637. package/wire.js +27 -0
  638. package/wire.js.map +1 -1
  639. package/connection/established.d.ts +0 -53
  640. package/connection/established.d.ts.map +0 -1
  641. package/connection/established.js +0 -2
  642. package/connection/established.js.map +0 -1
  643. package/ietf/adapter.d.ts +0 -75
  644. package/ietf/adapter.d.ts.map +0 -1
  645. package/ietf/adapter.js +0 -699
  646. package/ietf/adapter.js.map +0 -1
  647. package/lite/datagram_stream.d.ts +0 -8
  648. package/lite/datagram_stream.d.ts.map +0 -1
  649. package/lite/datagram_stream.js +0 -43
  650. package/lite/datagram_stream.js.map +0 -1
  651. package/lite/fetch.d.ts +0 -28
  652. package/lite/fetch.d.ts.map +0 -1
  653. package/lite/fetch.js +0 -78
  654. package/lite/fetch.js.map +0 -1
  655. package/util/log.d.ts +0 -5
  656. package/util/log.d.ts.map +0 -1
  657. package/util/log.js +0 -16
  658. package/util/log.js.map +0 -1
  659. package/zod.d.ts +0 -13
  660. package/zod.d.ts.map +0 -1
  661. package/zod.js +0 -18
  662. package/zod.js.map +0 -1
package/lite/fit.js ADDED
@@ -0,0 +1,305 @@
1
+ // Widening a lite-07 subscription's ranges until they fit the message that carries them. Mirrors
2
+ // the Rust `lite/subscriber/fit.rs`.
3
+ //
4
+ // A relay asks its upstream for the union of every viewer's ranges, and each viewer's request
5
+ // fits one message while the union need not. Rather than give back the copy every viewer reads
6
+ // through, the relay asks for a covering superset: the narrowest gaps close first, so the fewest
7
+ // unwanted groups are asked for. Each viewer still reads only its own ranges from the copy.
8
+ import { runsFrom } from "../internal.js";
9
+ import { max } from "../util/key.js";
10
+ import { MAX_MESSAGE_SIZE } from "./message.js";
11
+ import { rangeSize, subscriptionPolicy, varintSize, withPolicy } from "./subscribe.js";
12
+ /**
13
+ * The most a SUBSCRIBE_UPDATE's fields besides its ranges take, size prefix included: nine
14
+ * varints of at most nine bytes, and the priority byte.
15
+ */
16
+ export const UPDATE_FIELDS = 9 * 9 + 1;
17
+ /**
18
+ * The most one range takes besides its Range ID: its priority and order, each end's type, then at
19
+ * most three varints of nine bytes for a start and two for an end.
20
+ */
21
+ const RANGE_FIELDS = 2 + 2 + 5 * 9;
22
+ /**
23
+ * The budget for ranges a subscription takes Range IDs from `next` for, whose SUBSCRIBE carries
24
+ * `fields` bytes besides its ranges, `count` the most ranges it asks for.
25
+ *
26
+ * Half a message, so that the ranges sent last, retired by Range ID, and the ranges replacing
27
+ * them fit one SUBSCRIBE_UPDATE however little the two share: a relay never narrows its ask in
28
+ * between, which would reset group streams still arriving. Never more than leaves room in a
29
+ * SUBSCRIBE for one range past it, which {@link fitAfter} takes.
30
+ *
31
+ * A live range the update retunes instead, its policy or a live join's max changed in place,
32
+ * costs its Range ID, two bytes, and its max, never more than the range as the update asks for it:
33
+ * the ranges replacing the last pay for their retunes as they do for their additions.
34
+ */
35
+ export function budget(fields, next, count) {
36
+ const half = Math.floor((MAX_MESSAGE_SIZE - UPDATE_FIELDS) / 2);
37
+ const largest = next + BigInt(count);
38
+ // Past the varint's reach it takes the most a varint can.
39
+ const id = largest >= 1n << 64n ? 9 : varintSize(largest);
40
+ return {
41
+ bytes: Math.min(half, Math.max(0, MAX_MESSAGE_SIZE - fields - RANGE_FIELDS - id)),
42
+ id,
43
+ };
44
+ }
45
+ /** What `range` costs, or undefined when it can't go out. */
46
+ function cost(budget, range) {
47
+ try {
48
+ return rangeSize(range) + budget.id;
49
+ }
50
+ catch {
51
+ // Past the varint's reach, which encoding refuses too.
52
+ return undefined;
53
+ }
54
+ }
55
+ /**
56
+ * As many of `ranges`, in order, as fit `budget` beside the `spent` ones, at least the first: one
57
+ * range past them still fits the message, which the budget leaves room for. Mirrors the Rust
58
+ * `Budget::fit_after`.
59
+ */
60
+ export function fitAfter(budget, spent, ranges) {
61
+ let used = spent.reduce((total, range) => total + (cost(budget, range) ?? Number.POSITIVE_INFINITY), 0);
62
+ const taken = [];
63
+ for (const range of ranges) {
64
+ used += cost(budget, range) ?? Number.POSITIVE_INFINITY;
65
+ if (used > budget.bytes && taken.length > 0)
66
+ break;
67
+ taken.push(range);
68
+ }
69
+ return taken;
70
+ }
71
+ /** What `a` and `b` ask as one range: the more urgent, newest first on a tie unless both are not. */
72
+ function top(a, b) {
73
+ return subscriptionPolicy([withPolicy({}, a ?? {}), withPolicy({}, b ?? {})]);
74
+ }
75
+ function spanCost(budget, span) {
76
+ const range = { start: { absolute: span.start } };
77
+ if (span.end !== undefined)
78
+ range.end = { absolute: span.end };
79
+ return cost(budget, range) ?? Number.POSITIVE_INFINITY;
80
+ }
81
+ /**
82
+ * The groups `range` asks for when it starts at one. A time is a group's start, inclusive as an
83
+ * end; any other end is taken as open.
84
+ */
85
+ function groupSpan(range) {
86
+ const start = range.start?.absolute ?? range.start?.time;
87
+ if (start === undefined)
88
+ return undefined;
89
+ const end = range.end?.absolute ?? (range.end?.time === undefined ? undefined : range.end.time + 1n);
90
+ const policy = subscriptionPolicy([range]);
91
+ return end === undefined ? { start, policy } : { start, end, policy };
92
+ }
93
+ /**
94
+ * `demand`'s ranges and the `fills` groups, each widened only as far as both must be to fit
95
+ * `budget`, as the same arrays when nothing must. A gap between fills closes across `avoid`,
96
+ * sorted, disjoint groups the fills leave out on purpose, only once every other gap has. A
97
+ * widened demand range names its groups by time, as the demand's own do, at the most urgent
98
+ * policy among the ranges it covers, so no group goes out later than one of them asked.
99
+ *
100
+ * Throws when even one range per kind of start would not fit, which only a broadcast path or
101
+ * track name filling the message leaves.
102
+ */
103
+ export function fit(demand, fills, avoid, budget) {
104
+ let sum = 0;
105
+ for (const range of [...demand, ...fills.map(fillRange)]) {
106
+ const bytes = cost(budget, range);
107
+ // One that can't go out fails when it is encoded, as it would unfitted.
108
+ if (bytes === undefined)
109
+ return { ranges: demand, fills };
110
+ sum += bytes;
111
+ }
112
+ if (sum <= budget.bytes)
113
+ return { ranges: demand, fills };
114
+ const starts = [];
115
+ let others = [];
116
+ for (const range of demand) {
117
+ const span = groupSpan(range);
118
+ if (span)
119
+ starts.push(span);
120
+ else
121
+ others.push(range);
122
+ }
123
+ const spans = new Spans(starts, budget, () => false);
124
+ const runs = new Spans(fills.map((run) => ({ ...run })), budget, (gap) => {
125
+ const index = runsFrom(avoid, gap.start);
126
+ return index < avoid.length && avoid[index].start < gap.end;
127
+ });
128
+ // The other ranges have no time start, so no gap between them is measured: when even one span per
129
+ // list leaves them no room, they collapse to one range per kind covering them.
130
+ const costOf = (ranges) => ranges.reduce((sum, range) => sum + (cost(budget, range) ?? Number.POSITIVE_INFINITY), 0);
131
+ if (costOf(others) + spans.least() + runs.least() > budget.bytes)
132
+ others = collapse(others);
133
+ const rest = costOf(others);
134
+ const total = () => rest + spans.total + runs.total;
135
+ // Close the narrowest gaps first, of either list, until everything fits.
136
+ const gaps = [...spans.gaps(false), ...runs.gaps(true)].sort(byGap);
137
+ for (const gap of gaps) {
138
+ if (total() <= budget.bytes)
139
+ break;
140
+ (gap.fill ? runs : spans).join(gap.index);
141
+ }
142
+ if (total() > budget.bytes)
143
+ throw new Error("too many ranges for one SUBSCRIBE");
144
+ const ranges = spans.ranges().map(({ start, end, policy }) => {
145
+ const range = { start: { time: start } };
146
+ if (end !== undefined)
147
+ range.end = { time: end - 1n };
148
+ return withPolicy(range, policy ?? {});
149
+ });
150
+ ranges.push(...others);
151
+ return { ranges, fills: runs.ranges().map(({ start, end }) => ({ start, end: bounded(end) })) };
152
+ }
153
+ /** The range a fill's run takes on the wire, as `RangeFills` asks it. */
154
+ function fillRange(run) {
155
+ return { start: { absolute: run.start }, end: { absolute: run.end } };
156
+ }
157
+ /** A gap's end: only the last span is open, and no gap follows it. */
158
+ function bounded(end) {
159
+ if (end === undefined)
160
+ throw new Error("only the last span is open");
161
+ return end;
162
+ }
163
+ function byGap(a, b) {
164
+ if (a.late !== b.late)
165
+ return a.late ? 1 : -1;
166
+ if (a.width !== b.width)
167
+ return a.width < b.width ? -1 : 1;
168
+ if (a.fill !== b.fill)
169
+ return a.fill ? 1 : -1;
170
+ return a.index - b.index;
171
+ }
172
+ /** Disjoint spans in order, each the run of the input spans from one start to its chain's end. */
173
+ class Spans {
174
+ #spans = [];
175
+ // The last span of the chain starting at each chain's first, and the first of the chain ending
176
+ // at each chain's last.
177
+ #end;
178
+ #start;
179
+ // Whether the gap after each span closes only once every other gap has.
180
+ #late = [];
181
+ #budget;
182
+ total = 0;
183
+ constructor(input, budget, late) {
184
+ this.#budget = budget;
185
+ input.sort(bySpan);
186
+ // Spans that overlap or touch cost less as one, and ask for nothing more.
187
+ for (const span of input) {
188
+ const last = this.#spans.at(-1);
189
+ if (last && (last.end === undefined || last.end >= span.start)) {
190
+ last.end = last.end === undefined || span.end === undefined ? undefined : max(last.end, span.end);
191
+ last.policy = top(last.policy, span.policy);
192
+ }
193
+ else {
194
+ this.#spans.push({ ...span });
195
+ }
196
+ }
197
+ for (let index = 0; index + 1 < this.#spans.length; index++)
198
+ this.#late.push(late({ start: bounded(this.#spans[index].end), end: this.#spans[index + 1].start }));
199
+ for (const span of this.#spans)
200
+ this.total += spanCost(budget, span);
201
+ this.#end = this.#spans.map((_, index) => index);
202
+ this.#start = this.#spans.map((_, index) => index);
203
+ }
204
+ /** What the one span covering every span costs, or nothing when there are none. */
205
+ least() {
206
+ const first = this.#spans.at(0);
207
+ const last = this.#spans.at(-1);
208
+ if (!first || !last)
209
+ return 0;
210
+ return spanCost(this.#budget, { start: first.start, end: last.end });
211
+ }
212
+ /** Every gap, tagged with whether this list is the fills'. */
213
+ gaps(fill) {
214
+ return this.#late.map((late, index) => ({
215
+ late,
216
+ width: this.#spans[index + 1].start - bounded(this.#spans[index].end),
217
+ fill,
218
+ index,
219
+ }));
220
+ }
221
+ /** Close the gap after span `index`, joining the chains on either side. */
222
+ join(index) {
223
+ const first = this.#start[index];
224
+ const last = this.#end[index + 1];
225
+ const spans = this.#spans;
226
+ this.total -= spanCost(this.#budget, { start: spans[first].start, end: spans[index].end });
227
+ this.total -= spanCost(this.#budget, { start: spans[index + 1].start, end: spans[last].end });
228
+ this.total += spanCost(this.#budget, { start: spans[first].start, end: spans[last].end });
229
+ this.#end[first] = last;
230
+ this.#start[last] = first;
231
+ }
232
+ /** Each chain as the one span covering it, at the most urgent policy among its spans. */
233
+ ranges() {
234
+ const ranges = [];
235
+ for (let first = 0; first < this.#spans.length; first = this.#end[first] + 1) {
236
+ const last = this.#end[first];
237
+ let policy = this.#spans[first].policy;
238
+ for (let index = first + 1; index <= last; index++)
239
+ policy = top(policy, this.#spans[index].policy);
240
+ const span = { start: this.#spans[first].start, end: this.#spans[last].end };
241
+ if (policy !== undefined)
242
+ span.policy = policy;
243
+ ranges.push(span);
244
+ }
245
+ return ranges;
246
+ }
247
+ }
248
+ /** By start, an open end before any bound one, then by end. */
249
+ function bySpan(a, b) {
250
+ if (a.start !== b.start)
251
+ return a.start < b.start ? -1 : 1;
252
+ if (a.end === b.end)
253
+ return 0;
254
+ if (a.end === undefined)
255
+ return -1;
256
+ if (b.end === undefined)
257
+ return 1;
258
+ return a.end < b.end ? -1 : 1;
259
+ }
260
+ /**
261
+ * One range per kind of start covering every range of that kind, from the earliest start to the
262
+ * latest end. A time or absolute start is a span, so only ranges with no start and live joins are
263
+ * left: those with no start all start at the same group, and the join reaching furthest back,
264
+ * under the widest max, delivers what each of the others does. Each takes the most urgent policy
265
+ * among those it covers. Mirrors the Rust `collapse`.
266
+ */
267
+ function collapse(ranges) {
268
+ const kinds = [];
269
+ const kind = (range) => (range.start?.live ? 1 : range.start?.joined ? 2 : 0);
270
+ const widest = (a, b) => (a === null || b === null ? null : Math.max(a, b));
271
+ for (const range of ranges) {
272
+ const live = range.start?.live;
273
+ const joined = range.start?.joined;
274
+ const index = kinds.findIndex((cover) => kind(cover) === kind(range));
275
+ if (index < 0) {
276
+ kinds.push({ ...range });
277
+ continue;
278
+ }
279
+ kinds[index] = withPolicy(kinds[index], subscriptionPolicy([kinds[index], range]));
280
+ const cover = kinds[index];
281
+ // The join reaching furthest back, none past one with no lag limit, under the widest max,
282
+ // delivers what each of the others does.
283
+ const held = cover.start?.live;
284
+ if (held !== undefined && live !== undefined)
285
+ cover.start = { live: { min: widest(held.min, live.min), max: widest(held.max, live.max) } };
286
+ // The join placed earliest, under the widest max.
287
+ const placed = cover.start?.joined;
288
+ if (placed !== undefined && joined !== undefined) {
289
+ const earlier = joined.absolute < placed.absolute ||
290
+ (joined.absolute === placed.absolute && joined.frame < placed.frame);
291
+ const at = earlier ? joined : placed;
292
+ cover.start = { joined: { absolute: at.absolute, frame: at.frame, max: widest(placed.max, joined.max) } };
293
+ }
294
+ const [a, b] = [cover.end, range.end];
295
+ if (a?.absolute !== undefined && b?.absolute !== undefined)
296
+ cover.end = { absolute: max(a.absolute, b.absolute) };
297
+ else if (a?.time !== undefined && b?.time !== undefined)
298
+ cover.end = { time: max(a.time, b.time) };
299
+ // An exclusive and an inclusive end, or an open one: follow the edge.
300
+ else
301
+ delete cover.end;
302
+ }
303
+ return kinds;
304
+ }
305
+ //# sourceMappingURL=fit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fit.js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C,GAAG,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;aAClD,IAAI,CAAC,EAAE,IAAI,KAAK,SAAS,IAAI,CAAC,EAAE,IAAI,KAAK,SAAS;YAAE,KAAK,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QACnG,sEAAsE;;YACjE,OAAO,KAAK,CAAC,GAAG,CAAC;IACvB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["// Widening a lite-07 subscription's ranges until they fit the message that carries them. Mirrors\n// the Rust `lite/subscriber/fit.rs`.\n//\n// A relay asks its upstream for the union of every viewer's ranges, and each viewer's request\n// fits one message while the union need not. Rather than give back the copy every viewer reads\n// through, the relay asks for a covering superset: the narrowest gaps close first, so the fewest\n// unwanted groups are asked for. Each viewer still reads only its own ranges from the copy.\n\nimport { type Run, runsFrom } from \"../internal.ts\";\nimport { max } from \"../util/key.ts\";\nimport { MAX_MESSAGE_SIZE } from \"./message.ts\";\nimport { type Policy, rangeSize, subscriptionPolicy, varintSize, type WireRange, withPolicy } from \"./subscribe.ts\";\n\n/**\n * The most a SUBSCRIBE_UPDATE's fields besides its ranges take, size prefix included: nine\n * varints of at most nine bytes, and the priority byte.\n */\nexport const UPDATE_FIELDS = 9 * 9 + 1;\n\n/**\n * The most one range takes besides its Range ID: its priority and order, each end's type, then at\n * most three varints of nine bytes for a start and two for an end.\n */\nconst RANGE_FIELDS = 2 + 2 + 5 * 9;\n\n/** What lite-07 ranges may take on the wire. */\nexport interface Budget {\n\t/** The bytes every range and its Range ID may take together. */\n\tbytes: number;\n\t/** The bytes the largest Range ID any of the ranges may take. */\n\tid: number;\n}\n\n/**\n * The budget for ranges a subscription takes Range IDs from `next` for, whose SUBSCRIBE carries\n * `fields` bytes besides its ranges, `count` the most ranges it asks for.\n *\n * Half a message, so that the ranges sent last, retired by Range ID, and the ranges replacing\n * them fit one SUBSCRIBE_UPDATE however little the two share: a relay never narrows its ask in\n * between, which would reset group streams still arriving. Never more than leaves room in a\n * SUBSCRIBE for one range past it, which {@link fitAfter} takes.\n *\n * A live range the update retunes instead, its policy or a live join's max changed in place,\n * costs its Range ID, two bytes, and its max, never more than the range as the update asks for it:\n * the ranges replacing the last pay for their retunes as they do for their additions.\n */\nexport function budget(fields: number, next: bigint, count: number): Budget {\n\tconst half = Math.floor((MAX_MESSAGE_SIZE - UPDATE_FIELDS) / 2);\n\tconst largest = next + BigInt(count);\n\t// Past the varint's reach it takes the most a varint can.\n\tconst id = largest >= 1n << 64n ? 9 : varintSize(largest);\n\treturn {\n\t\tbytes: Math.min(half, Math.max(0, MAX_MESSAGE_SIZE - fields - RANGE_FIELDS - id)),\n\t\tid,\n\t};\n}\n\n/** What `range` costs, or undefined when it can't go out. */\nfunction cost(budget: Budget, range: WireRange): number | undefined {\n\ttry {\n\t\treturn rangeSize(range) + budget.id;\n\t} catch {\n\t\t// Past the varint's reach, which encoding refuses too.\n\t\treturn undefined;\n\t}\n}\n\n/**\n * As many of `ranges`, in order, as fit `budget` beside the `spent` ones, at least the first: one\n * range past them still fits the message, which the budget leaves room for. Mirrors the Rust\n * `Budget::fit_after`.\n */\nexport function fitAfter(budget: Budget, spent: readonly WireRange[], ranges: readonly WireRange[]): WireRange[] {\n\tlet used = spent.reduce((total, range) => total + (cost(budget, range) ?? Number.POSITIVE_INFINITY), 0);\n\tconst taken: WireRange[] = [];\n\tfor (const range of ranges) {\n\t\tused += cost(budget, range) ?? Number.POSITIVE_INFINITY;\n\t\tif (used > budget.bytes && taken.length > 0) break;\n\t\ttaken.push(range);\n\t}\n\treturn taken;\n}\n\n/** Groups from `start`, up to the exclusive `end` or open, asked at `policy`. */\ninterface Span {\n\tstart: bigint;\n\tend?: bigint;\n\tpolicy?: Policy;\n}\n\n/** What `a` and `b` ask as one range: the more urgent, newest first on a tie unless both are not. */\nfunction top(a: Policy | undefined, b: Policy | undefined): Policy {\n\treturn subscriptionPolicy([withPolicy({}, a ?? {}), withPolicy({}, b ?? {})]);\n}\n\nfunction spanCost(budget: Budget, span: Span): number {\n\tconst range: WireRange = { start: { absolute: span.start } };\n\tif (span.end !== undefined) range.end = { absolute: span.end };\n\treturn cost(budget, range) ?? Number.POSITIVE_INFINITY;\n}\n\n/**\n * The groups `range` asks for when it starts at one. A time is a group's start, inclusive as an\n * end; any other end is taken as open.\n */\nfunction groupSpan(range: WireRange): Span | undefined {\n\tconst start = range.start?.absolute ?? range.start?.time;\n\tif (start === undefined) return undefined;\n\tconst end = range.end?.absolute ?? (range.end?.time === undefined ? undefined : range.end.time + 1n);\n\tconst policy = subscriptionPolicy([range]);\n\treturn end === undefined ? { start, policy } : { start, end, policy };\n}\n\n/**\n * `demand`'s ranges and the `fills` groups, each widened only as far as both must be to fit\n * `budget`, as the same arrays when nothing must. A gap between fills closes across `avoid`,\n * sorted, disjoint groups the fills leave out on purpose, only once every other gap has. A\n * widened demand range names its groups by time, as the demand's own do, at the most urgent\n * policy among the ranges it covers, so no group goes out later than one of them asked.\n *\n * Throws when even one range per kind of start would not fit, which only a broadcast path or\n * track name filling the message leaves.\n */\nexport function fit(\n\tdemand: readonly WireRange[],\n\tfills: readonly Run[],\n\tavoid: readonly Run[],\n\tbudget: Budget,\n): { ranges: readonly WireRange[]; fills: readonly Run[] } {\n\tlet sum = 0;\n\tfor (const range of [...demand, ...fills.map(fillRange)]) {\n\t\tconst bytes = cost(budget, range);\n\t\t// One that can't go out fails when it is encoded, as it would unfitted.\n\t\tif (bytes === undefined) return { ranges: demand, fills };\n\t\tsum += bytes;\n\t}\n\tif (sum <= budget.bytes) return { ranges: demand, fills };\n\n\tconst starts: Span[] = [];\n\tlet others: WireRange[] = [];\n\tfor (const range of demand) {\n\t\tconst span = groupSpan(range);\n\t\tif (span) starts.push(span);\n\t\telse others.push(range);\n\t}\n\tconst spans = new Spans(starts, budget, () => false);\n\tconst runs = new Spans(\n\t\tfills.map((run) => ({ ...run })),\n\t\tbudget,\n\t\t(gap) => {\n\t\t\tconst index = runsFrom(avoid, gap.start);\n\t\t\treturn index < avoid.length && avoid[index].start < gap.end;\n\t\t},\n\t);\n\n\t// The other ranges have no time start, so no gap between them is measured: when even one span per\n\t// list leaves them no room, they collapse to one range per kind covering them.\n\tconst costOf = (ranges: readonly WireRange[]) =>\n\t\tranges.reduce((sum, range) => sum + (cost(budget, range) ?? Number.POSITIVE_INFINITY), 0);\n\tif (costOf(others) + spans.least() + runs.least() > budget.bytes) others = collapse(others);\n\tconst rest = costOf(others);\n\tconst total = () => rest + spans.total + runs.total;\n\n\t// Close the narrowest gaps first, of either list, until everything fits.\n\tconst gaps = [...spans.gaps(false), ...runs.gaps(true)].sort(byGap);\n\tfor (const gap of gaps) {\n\t\tif (total() <= budget.bytes) break;\n\t\t(gap.fill ? runs : spans).join(gap.index);\n\t}\n\tif (total() > budget.bytes) throw new Error(\"too many ranges for one SUBSCRIBE\");\n\n\tconst ranges: WireRange[] = spans.ranges().map(({ start, end, policy }) => {\n\t\tconst range: WireRange = { start: { time: start } };\n\t\tif (end !== undefined) range.end = { time: end - 1n };\n\t\treturn withPolicy(range, policy ?? {});\n\t});\n\tranges.push(...others);\n\treturn { ranges, fills: runs.ranges().map(({ start, end }) => ({ start, end: bounded(end) })) };\n}\n\n/** The range a fill's run takes on the wire, as `RangeFills` asks it. */\nfunction fillRange(run: Run): WireRange {\n\treturn { start: { absolute: run.start }, end: { absolute: run.end } };\n}\n\n/** A gap's end: only the last span is open, and no gap follows it. */\nfunction bounded(end: bigint | undefined): bigint {\n\tif (end === undefined) throw new Error(\"only the last span is open\");\n\treturn end;\n}\n\n/** A gap between two spans: how late it closes, which list it is in, and the span before it. */\ninterface Gap {\n\tlate: boolean;\n\twidth: bigint;\n\tfill: boolean;\n\tindex: number;\n}\n\nfunction byGap(a: Gap, b: Gap): number {\n\tif (a.late !== b.late) return a.late ? 1 : -1;\n\tif (a.width !== b.width) return a.width < b.width ? -1 : 1;\n\tif (a.fill !== b.fill) return a.fill ? 1 : -1;\n\treturn a.index - b.index;\n}\n\n/** Disjoint spans in order, each the run of the input spans from one start to its chain's end. */\nclass Spans {\n\treadonly #spans: Span[] = [];\n\t// The last span of the chain starting at each chain's first, and the first of the chain ending\n\t// at each chain's last.\n\treadonly #end: number[];\n\treadonly #start: number[];\n\t// Whether the gap after each span closes only once every other gap has.\n\treadonly #late: boolean[] = [];\n\treadonly #budget: Budget;\n\ttotal = 0;\n\n\tconstructor(input: Span[], budget: Budget, late: (gap: Run) => boolean) {\n\t\tthis.#budget = budget;\n\t\tinput.sort(bySpan);\n\t\t// Spans that overlap or touch cost less as one, and ask for nothing more.\n\t\tfor (const span of input) {\n\t\t\tconst last = this.#spans.at(-1);\n\t\t\tif (last && (last.end === undefined || last.end >= span.start)) {\n\t\t\t\tlast.end = last.end === undefined || span.end === undefined ? undefined : max(last.end, span.end);\n\t\t\t\tlast.policy = top(last.policy, span.policy);\n\t\t\t} else {\n\t\t\t\tthis.#spans.push({ ...span });\n\t\t\t}\n\t\t}\n\t\tfor (let index = 0; index + 1 < this.#spans.length; index++)\n\t\t\tthis.#late.push(late({ start: bounded(this.#spans[index].end), end: this.#spans[index + 1].start }));\n\t\tfor (const span of this.#spans) this.total += spanCost(budget, span);\n\t\tthis.#end = this.#spans.map((_, index) => index);\n\t\tthis.#start = this.#spans.map((_, index) => index);\n\t}\n\n\t/** What the one span covering every span costs, or nothing when there are none. */\n\tleast(): number {\n\t\tconst first = this.#spans.at(0);\n\t\tconst last = this.#spans.at(-1);\n\t\tif (!first || !last) return 0;\n\t\treturn spanCost(this.#budget, { start: first.start, end: last.end });\n\t}\n\n\t/** Every gap, tagged with whether this list is the fills'. */\n\tgaps(fill: boolean): Gap[] {\n\t\treturn this.#late.map((late, index) => ({\n\t\t\tlate,\n\t\t\twidth: this.#spans[index + 1].start - bounded(this.#spans[index].end),\n\t\t\tfill,\n\t\t\tindex,\n\t\t}));\n\t}\n\n\t/** Close the gap after span `index`, joining the chains on either side. */\n\tjoin(index: number): void {\n\t\tconst first = this.#start[index];\n\t\tconst last = this.#end[index + 1];\n\t\tconst spans = this.#spans;\n\t\tthis.total -= spanCost(this.#budget, { start: spans[first].start, end: spans[index].end });\n\t\tthis.total -= spanCost(this.#budget, { start: spans[index + 1].start, end: spans[last].end });\n\t\tthis.total += spanCost(this.#budget, { start: spans[first].start, end: spans[last].end });\n\t\tthis.#end[first] = last;\n\t\tthis.#start[last] = first;\n\t}\n\n\t/** Each chain as the one span covering it, at the most urgent policy among its spans. */\n\tranges(): Span[] {\n\t\tconst ranges: Span[] = [];\n\t\tfor (let first = 0; first < this.#spans.length; first = this.#end[first] + 1) {\n\t\t\tconst last = this.#end[first];\n\t\t\tlet policy = this.#spans[first].policy;\n\t\t\tfor (let index = first + 1; index <= last; index++) policy = top(policy, this.#spans[index].policy);\n\t\t\tconst span: Span = { start: this.#spans[first].start, end: this.#spans[last].end };\n\t\t\tif (policy !== undefined) span.policy = policy;\n\t\t\tranges.push(span);\n\t\t}\n\t\treturn ranges;\n\t}\n}\n\n/** By start, an open end before any bound one, then by end. */\nfunction bySpan(a: Span, b: Span): number {\n\tif (a.start !== b.start) return a.start < b.start ? -1 : 1;\n\tif (a.end === b.end) return 0;\n\tif (a.end === undefined) return -1;\n\tif (b.end === undefined) return 1;\n\treturn a.end < b.end ? -1 : 1;\n}\n\n/**\n * One range per kind of start covering every range of that kind, from the earliest start to the\n * latest end. A time or absolute start is a span, so only ranges with no start and live joins are\n * left: those with no start all start at the same group, and the join reaching furthest back,\n * under the widest max, delivers what each of the others does. Each takes the most urgent policy\n * among those it covers. Mirrors the Rust `collapse`.\n */\nfunction collapse(ranges: readonly WireRange[]): WireRange[] {\n\tconst kinds: WireRange[] = [];\n\tconst kind = (range: WireRange) => (range.start?.live ? 1 : range.start?.joined ? 2 : 0);\n\tconst widest = (a: number | null, b: number | null) => (a === null || b === null ? null : Math.max(a, b));\n\tfor (const range of ranges) {\n\t\tconst live = range.start?.live;\n\t\tconst joined = range.start?.joined;\n\t\tconst index = kinds.findIndex((cover) => kind(cover) === kind(range));\n\t\tif (index < 0) {\n\t\t\tkinds.push({ ...range });\n\t\t\tcontinue;\n\t\t}\n\t\tkinds[index] = withPolicy(kinds[index], subscriptionPolicy([kinds[index], range]));\n\t\tconst cover = kinds[index];\n\t\t// The join reaching furthest back, none past one with no lag limit, under the widest max,\n\t\t// delivers what each of the others does.\n\t\tconst held = cover.start?.live;\n\t\tif (held !== undefined && live !== undefined)\n\t\t\tcover.start = { live: { min: widest(held.min, live.min), max: widest(held.max, live.max) } };\n\t\t// The join placed earliest, under the widest max.\n\t\tconst placed = cover.start?.joined;\n\t\tif (placed !== undefined && joined !== undefined) {\n\t\t\tconst earlier =\n\t\t\t\tjoined.absolute < placed.absolute ||\n\t\t\t\t(joined.absolute === placed.absolute && joined.frame < placed.frame);\n\t\t\tconst at = earlier ? joined : placed;\n\t\t\tcover.start = { joined: { absolute: at.absolute, frame: at.frame, max: widest(placed.max, joined.max) } };\n\t\t}\n\t\tconst [a, b] = [cover.end, range.end];\n\t\tif (a?.absolute !== undefined && b?.absolute !== undefined)\n\t\t\tcover.end = { absolute: max(a.absolute, b.absolute) };\n\t\telse if (a?.time !== undefined && b?.time !== undefined) cover.end = { time: max(a.time, b.time) };\n\t\t// An exclusive and an inclusive end, or an open one: follow the edge.\n\t\telse delete cover.end;\n\t}\n\treturn kinds;\n}\n"]}
package/lite/goaway.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Reader, Writer } from "../stream.ts";
2
- import { Version } from "./version.ts";
2
+ import { type Version } from "./version.ts";
3
3
  export declare class Goaway {
4
4
  #private;
5
5
  uri: string;
@@ -1 +1 @@
1
- {"version":3,"file":"goaway.d.ts","sourceRoot":"","sources":["../../src/lite/goaway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAgBvC,qBAAa,MAAM;;IAClB,GAAG,EAAE,MAAM,CAAC;IAEZ,YAAY,GAAG,EAAE,MAAM,EAEtB;IAgBK,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvD;IAED,OAAa,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAGhE;CACD"}
1
+ {"version":3,"file":"goaway.d.ts","sourceRoot":"","sources":["../../src/lite/goaway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAKvD,qBAAa,MAAM;;IAClB,GAAG,EAAE,MAAM,CAAC;IAEZ,YAAY,GAAG,EAAE,MAAM,EAEtB;IAgBK,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvD;IAED,OAAa,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAGhE;CACD"}
package/lite/goaway.js CHANGED
@@ -1,15 +1,5 @@
1
1
  import * as Message from "./message.js";
2
- import { Version } from "./version.js";
3
- function guardGoaway(version) {
4
- switch (version) {
5
- case Version.DRAFT_01:
6
- case Version.DRAFT_02:
7
- case Version.DRAFT_03:
8
- throw new Error("goaway not supported for this version");
9
- default:
10
- break;
11
- }
12
- }
2
+ import { hasGoaway } from "./version.js";
13
3
  /// Sent to gracefully shut down a session and optionally redirect to a new URI.
14
4
  ///
15
5
  /// Lite04+ only.
@@ -31,11 +21,13 @@ export class Goaway {
31
21
  return new Goaway(uri);
32
22
  }
33
23
  async encode(w, version) {
34
- guardGoaway(version);
24
+ if (!hasGoaway(version))
25
+ throw new Error("goaway not supported for this version");
35
26
  return Message.encode(w, this.#encode.bind(this));
36
27
  }
37
28
  static async decode(r, version) {
38
- guardGoaway(version);
29
+ if (!hasGoaway(version))
30
+ throw new Error("goaway not supported for this version");
39
31
  return Message.decode(r, Goaway.#decode);
40
32
  }
41
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"goaway.js","sourceRoot":"","sources":["../../src/lite/goaway.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,SAAS,WAAW,CAAC,OAAgB;IACpC,QAAQ,OAAO,EAAE,CAAC;QACjB,KAAK,OAAO,CAAC,QAAQ,CAAC;QACtB,KAAK,OAAO,CAAC,QAAQ,CAAC;QACtB,KAAK,OAAO,CAAC,QAAQ;YACpB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC1D;YACC,MAAM;IACR,CAAC;AACF,CAAC;AAED,gFAAgF;AAChF,GAAG;AACH,iBAAiB;AACjB,MAAM,OAAO,MAAM;IAClB,GAAG,CAAS;IAEZ,YAAY,GAAW;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,CAAS;QACtB,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAS;QAC7B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;QAC7B,wEAAwE;QACxE,iDAAiD;QACjD,IAAI,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,GAAG,IAAI,EAAE,CAAC;YACrD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,OAAgB;QACvC,WAAW,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,OAAgB;QAC9C,WAAW,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;CACD","sourcesContent":["import type { Reader, Writer } from \"../stream.ts\";\nimport * as Message from \"./message.ts\";\nimport { Version } from \"./version.ts\";\n\nfunction guardGoaway(version: Version) {\n\tswitch (version) {\n\t\tcase Version.DRAFT_01:\n\t\tcase Version.DRAFT_02:\n\t\tcase Version.DRAFT_03:\n\t\t\tthrow new Error(\"goaway not supported for this version\");\n\t\tdefault:\n\t\t\tbreak;\n\t}\n}\n\n/// Sent to gracefully shut down a session and optionally redirect to a new URI.\n///\n/// Lite04+ only.\nexport class Goaway {\n\turi: string;\n\n\tconstructor(uri: string) {\n\t\tthis.uri = uri;\n\t}\n\n\tasync #encode(w: Writer) {\n\t\tawait w.string(this.uri);\n\t}\n\n\tstatic async #decode(r: Reader): Promise<Goaway> {\n\t\tconst uri = await r.string();\n\t\t// The URI is capped at 8,192 bytes, matching the IETF wire and the Rust\n\t\t// decoder; a longer one is a protocol violation.\n\t\tif (new TextEncoder().encode(uri).byteLength > 8192) {\n\t\t\tthrow new Error(\"GOAWAY URI exceeds 8,192 bytes\");\n\t\t}\n\t\treturn new Goaway(uri);\n\t}\n\n\tasync encode(w: Writer, version: Version): Promise<void> {\n\t\tguardGoaway(version);\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, version: Version): Promise<Goaway> {\n\t\tguardGoaway(version);\n\t\treturn Message.decode(r, Goaway.#decode);\n\t}\n}\n"]}
1
+ {"version":3,"file":"goaway.js","sourceRoot":"","sources":["../../src/lite/goaway.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAgB,MAAM,cAAc,CAAC;AAEvD,gFAAgF;AAChF,GAAG;AACH,iBAAiB;AACjB,MAAM,OAAO,MAAM;IAClB,GAAG,CAAS;IAEZ,YAAY,GAAW;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,CAAS;QACtB,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAS;QAC7B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;QAC7B,wEAAwE;QACxE,iDAAiD;QACjD,IAAI,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,GAAG,IAAI,EAAE,CAAC;YACrD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,OAAgB;QACvC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAClF,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAS,EAAE,OAAgB;QAC9C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAClF,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;CACD","sourcesContent":["import type { Reader, Writer } from \"../stream.ts\";\nimport * as Message from \"./message.ts\";\nimport { hasGoaway, type Version } from \"./version.ts\";\n\n/// Sent to gracefully shut down a session and optionally redirect to a new URI.\n///\n/// Lite04+ only.\nexport class Goaway {\n\turi: string;\n\n\tconstructor(uri: string) {\n\t\tthis.uri = uri;\n\t}\n\n\tasync #encode(w: Writer) {\n\t\tawait w.string(this.uri);\n\t}\n\n\tstatic async #decode(r: Reader): Promise<Goaway> {\n\t\tconst uri = await r.string();\n\t\t// The URI is capped at 8,192 bytes, matching the IETF wire and the Rust\n\t\t// decoder; a longer one is a protocol violation.\n\t\tif (new TextEncoder().encode(uri).byteLength > 8192) {\n\t\t\tthrow new Error(\"GOAWAY URI exceeds 8,192 bytes\");\n\t\t}\n\t\treturn new Goaway(uri);\n\t}\n\n\tasync encode(w: Writer, version: Version): Promise<void> {\n\t\tif (!hasGoaway(version)) throw new Error(\"goaway not supported for this version\");\n\t\treturn Message.encode(w, this.#encode.bind(this));\n\t}\n\n\tstatic async decode(r: Reader, version: Version): Promise<Goaway> {\n\t\tif (!hasGoaway(version)) throw new Error(\"goaway not supported for this version\");\n\t\treturn Message.decode(r, Goaway.#decode);\n\t}\n}\n"]}
package/lite/group.d.ts CHANGED
@@ -1,36 +1,87 @@
1
1
  import type * as netGroup from "../group.ts";
2
+ import { type WirePayload } from "../payload.ts";
2
3
  import type { Cursor, Reader, Writer } from "../stream.ts";
3
4
  import { type Version } from "./version.ts";
4
5
  export declare class Group {
5
6
  #private;
6
7
  subscribe: bigint;
7
- sequence: number;
8
+ key: bigint;
8
9
  /**
9
10
  * The index of the first frame on this stream within the group.
10
11
  *
11
12
  * 0 (the common case) means the stream carries the group from its beginning. A
12
- * higher value means the leading frames are not here, either because the
13
- * subscription started partway into the group or because the publisher only holds
14
- * the tail. Lite-06+; older versions always start at 0.
13
+ * higher value means the leading frames are not here, because the subscription started
14
+ * partway into the group. Lite-06+ only; older versions always start at 0.
15
15
  */
16
16
  frameStart: number;
17
- constructor({ subscribe, sequence, frameStart, }: {
17
+ constructor({ subscribe, key: sequence, frameStart, }: {
18
18
  subscribe: bigint;
19
- sequence: number;
19
+ key: bigint;
20
20
  frameStart?: number;
21
21
  });
22
22
  encode(w: Writer, version: Version): Promise<void>;
23
23
  static decode(r: Reader, version: Version): Promise<Group>;
24
24
  static decodeMaybe(r: Reader, version: Version): Promise<Group | undefined>;
25
25
  }
26
+ /** A decoded frame, whose payload may still be a stored slice or follow on the stream. */
27
+ export interface WireFrame extends WirePayload {
28
+ /** The declared plain size on a compressed track. */
29
+ inflated?: number;
30
+ /** A metadata FRAME: its header alone, `size` being the plain size, with no payload. */
31
+ header?: boolean;
32
+ }
33
+ /** Lite-07 GROUP_END: the group is whole, ending at `end` in the track's timescale. */
34
+ export interface GroupEnd {
35
+ end: bigint;
36
+ }
37
+ /** How {@link frameDecoder} reads each frame's optional fields. */
38
+ export interface FrameFormat {
39
+ /** The wire timescale; non-zero means every frame carries a delta timestamp. */
40
+ scale: number;
41
+ /**
42
+ * The group's start: lite-07's frame 0 sits there, a later stream's first timestamp delta counts
43
+ * from it, and so does a GROUP_END's End when the stream carries no timestamp. Before lite-07
44
+ * the first delta counts from 0.
45
+ */
46
+ start?: bigint;
47
+ /**
48
+ * The index of the stream's first frame, from its GROUP header: on lite-07, frame 0 carries no
49
+ * delta, and a GROUP_END before any frame is malformed only for a stream from frame 0.
50
+ * {@link readFrames} defaults it to where its group begins.
51
+ */
52
+ frameStart?: number;
53
+ /** Whether every frame declares its plain size ahead of a stored slice. */
54
+ compress?: boolean;
55
+ /**
56
+ * Whether every frame leads with its `Payload Length`, the payload size plus one (lite-07),
57
+ * rather than ending its header with the size. Lite-07 also carries unsigned timestamp deltas;
58
+ * earlier versions carry zigzag ones that a receiver reads and drops.
59
+ */
60
+ lengthFirst?: boolean;
61
+ /**
62
+ * Whether every frame is its header alone, as a metadata subscription delivers it (lite-07): its
63
+ * `Payload Length` is the plain size plus one, with no Inflated Size and no payload, compressed
64
+ * track or not. {@link readFrames} takes it from the group it writes.
65
+ */
66
+ meta?: boolean;
67
+ }
26
68
  /**
27
- * A synchronous decode for one frame of a group or FETCH response stream.
69
+ * Decode one frame, with timestamp deltas when stamped and declared plain sizes when compressed,
70
+ * or a lite-07 GROUP_END. Lite-07 leads with the size plus one, 0 for GROUP_END, where stream end
71
+ * closes the group; before it the size ends the header, and stream end at the frame's first field
72
+ * ends the group.
28
73
  *
29
- * A non-zero `scale` means every frame is prefixed with a zigzag-delta timestamp (the lite-05
30
- * FRAME format), decoded into a Timestamp at that scale. Scale 0 (pre-lite-05) carries no
31
- * timestamp, so frames are wall-clock stamped on arrival.
74
+ * On lite-07 frame 0 carries no delta, sitting at the group's `start`; every other delta is an
75
+ * unsigned offset from the prior frame, or from `start` for a stream that begins later, and
76
+ * GROUP_END's End counts from the last frame's timestamp, or from `start` when the stream carried
77
+ * none. Before lite-07 every delta is read and dropped: a publisher may stamp send times there. Mirrors the Rust `FrameIngest`.
78
+ */
79
+ export declare function frameDecoder({ scale, start, frameStart, compress, lengthFirst, meta, }: FrameFormat): (c: Cursor) => WireFrame | GroupEnd;
80
+ /**
81
+ * Write a group stream's frames into `producer` until the stream ends or the producer closes.
82
+ * Resolves with where a lite-07 GROUP_END said the group ends, or undefined when the stream ended
83
+ * without one: the caller finishes the group at that end, and a bare FIN only closes it. Anything
84
+ * after GROUP_END is malformed.
32
85
  */
33
- export declare function frameDecoder(scale: number): (c: Cursor) => netGroup.Frame;
34
- /** Write a group stream's frames into `producer` until the stream ends or the producer closes. */
35
- export declare function readFrames(stream: Reader, producer: netGroup.Producer, scale: number): Promise<void>;
86
+ export declare function readFrames(stream: Reader, producer: netGroup.Producer, format: FrameFormat): Promise<bigint | undefined>;
36
87
  //# sourceMappingURL=group.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../src/lite/group.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,QAAQ,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3D,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5D,qBAAa,KAAK;;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;;;OAOG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB,YAAY,EACX,SAAS,EACT,QAAQ,EACR,UAAc,GACd,EAAE;QACF,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;KACpB,EAIA;IAoBK,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvD;IAED,OAAa,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAE/D;IAED,OAAa,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAEhF;CACD;AAOD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,QAAQ,CAAC,KAAK,CAczE;AAED,kGAAkG;AAClG,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAW1G"}
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