@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/ledger.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger.js","sourceRoot":"","sources":["../src/ledger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAE3C;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,QAAkB;IACvC,OAAO,QAAQ,CAAC,MAAM,EAAE,IAAI,QAAQ,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;AACvE,CAAC;AAED,8DAA8D;AAC9D,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC;AAM7B;;;;;;;GAOG;AACH,MAAM,OAAO,MAAM;IAClB,oFAAoF;IACpF,yFAAyF;IACzF,uFAAuF;IACvF,2DAA2D;IAC3D,KAAK,GAAG,IAAI,MAAM,CAAc,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7D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GAAG,IAAI,EAAE,CAAC;QAC7B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1C,IAAI,KAAK,IAAI,GAAG;gBAAE,MAAM;YACxB,IAAI,KAAK,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC;gBACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACvB,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC;gBACf,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACxB,CAAC;YACD,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;IACpB,CAAC;CACD","sourcesContent":["import { Duration, type Instant } from \"@moq/clock\";\nimport { max, min } from \"./util/key.ts\";\nimport { Sorted } from \"./util/sorted.ts\";\n\nconst compare = (a: bigint, b: bigint): number => (a < b ? -1 : a > b ? 1 : 0);\n\n/**\n * How long a subscriber waits for a group stream it cannot account for once the publisher\n * has ended the subscription.\n *\n * A group reset before its header arrived leaves no trace, and QUIC does not order streams,\n * so a stream opened before the end can still be in flight after it. This bounds the wait on\n * IETF, and on moq-lite when the subscription has no budget to bound it with.\n */\nexport const GRACE = Duration.millis(1000);\n\n/**\n * The grace for a staleness budget of `maxDelay`: how long it was willing to wait for a late group\n * anyway, or {@link GRACE} for zero or no limit, so a wire that never names a start still gives\n * every gap up in finite time. Mirrors the Rust `ledger::grace`.\n */\nexport function grace(maxDelay: Duration): Duration {\n\treturn maxDelay.isZero() || maxDelay.ge(UNLIMITED) ? GRACE : maxDelay;\n}\n\n// A budget of `NO_MAX_DELAY` milliseconds, which is no limit.\nconst UNLIMITED = Duration.millis(Number.MAX_SAFE_INTEGER);\n\n/**\n * Maximum number of disjoint runs retained in a single {@link Ledger}, bounding memory even\n * when no grace expires gaps. Past it, a ledger folds its oldest gap, and a proven one forgets\n * its lowest run (see {@link Ledger.forgotten}).\n */\nexport const MAX_RUNS = 4096;\n\n// A run of accounted keys `[start, end)`, and when the gap below it opened, which is\n// when its missing groups became late.\ntype Run = { start: bigint; end: bigint; since: Instant };\n\n/**\n * The keys a feed has accounted for, and how long each gap between them is waited for.\n *\n * A subscription's `Tail` and a track's record of live arrivals both keep one, so they\n * give up on a missing group by the same rule. Mirrors the Rust `Ledger`.\n *\n * @internal\n */\nexport class Ledger {\n\t// Disjoint, sorted, non-adjacent runs of accounted keys. A gap older than the grace\n\t// can no longer be waited for, so it folds into the runs around it, which bounds this by\n\t// the gaps opened within the grace rather than every gap ever seen. A fold is final: a\n\t// later, longer grace or a lowered floor cannot reopen it.\n\t#runs = new Sorted<bigint, Run>((run) => run.start, compare);\n\t// Demand can restart a gap below an older one. Index ages separately so expiring\n\t// one gap never scans all the younger ones. Both indexes own exactly the same runs.\n\t#ages = new Sorted<Run, Run>(\n\t\t(run) => run,\n\t\t(a, b) => a.since.cmp(b.since) || compare(a.start, b.start),\n\t);\n\t#last?: Run;\n\t// Exclude the leading gap, which has no lower run to fold into.\n\t#next?: Run;\n\t#maxRuns: number;\n\t// Lite-07: the publisher names every start, so a gap is never given up on. Folding one would\n\t// claim groups were accounted for that never were.\n\t#proven: boolean;\n\t// Below this, a proven ledger forgot runs to stay within its cap.\n\t#forgotten: bigint | undefined;\n\t// The lowest key ever accounted for, which a forgotten run never raises: where a feed that\n\t// declared no start began.\n\t#lowest: bigint | undefined;\n\n\tconstructor(options: { maxRuns?: number; proven?: boolean } = {}) {\n\t\tthis.#maxRuns = options.maxRuns ?? MAX_RUNS;\n\t\tthis.#proven = options.proven ?? false;\n\t}\n\n\t/**\n\t * The exclusive end of the runs a proven ledger forgot, undefined while it forgot none: a key\n\t * below it that the ledger does not cover may have been accounted for. Mirrors the Rust\n\t * `Ledger::forgotten`.\n\t */\n\tget forgotten(): bigint | undefined {\n\t\treturn this.#forgotten;\n\t}\n\n\t/** Make this a proven ledger from now on, keeping what it accounted for. Mirrors the Rust `Ledger::prove`. */\n\tprove(): void {\n\t\tthis.#proven = true;\n\t}\n\n\t/** The lowest key ever accounted for, even one since forgotten. Mirrors the Rust `Ledger::lowest`. */\n\tlowest(): bigint | undefined {\n\t\treturn this.#lowest;\n\t}\n\n\t/** How many disjoint runs the ledger holds. */\n\tget size(): number {\n\t\treturn this.#runs.size;\n\t}\n\n\t#insert(run: Run): void {\n\t\tthis.#runs.insert(run);\n\t\tthis.#ages.insert(run);\n\t}\n\n\t#remove(run: Run): void {\n\t\tthis.#runs.delete(run.start);\n\t\tthis.#ages.delete(run);\n\t}\n\n\t#nextExpiry(): void {\n\t\tconst oldest = this.#ages.first();\n\t\tthis.#next = oldest && oldest === this.#runs.first() ? this.#ages.higher(oldest) : oldest;\n\t}\n\n\t/** Record keys `[start, end)` as accounted for. Gaps fold only on {@link expire}. */\n\taccount(start: bigint, end: bigint, at: Instant): void {\n\t\tif (start >= end) return;\n\t\tthis.#lowest = this.#lowest === undefined ? start : min(this.#lowest, start);\n\n\t\t// An in-order feed extends the last run in place, the usual case for every arrival.\n\t\tconst last = this.#last;\n\t\tif (last && last.start <= start && start <= last.end) {\n\t\t\tlast.end = max(last.end, end);\n\t\t\treturn;\n\t\t}\n\n\t\tconst lower = this.#runs.floor(start);\n\t\tconst below = lower && lower.end >= start ? lower : undefined;\n\t\tif (below && end <= below.end) return;\n\n\t\t// Splitting a gap inherits its age; only an arrival past all runs opens a new one.\n\t\tconst run = below ?? { start, end, since: this.#runs.ceil(start)?.since ?? at };\n\t\trun.end = max(run.end, end);\n\t\tlet next = this.#runs.ceil(start);\n\t\tif (next === below) next = this.#runs.higher(start);\n\t\twhile (next && next.start <= run.end) {\n\t\t\trun.end = max(run.end, next.end);\n\t\t\tthis.#remove(next);\n\t\t\tnext = this.#runs.higher(next.start);\n\t\t}\n\t\tif (!below) this.#insert(run);\n\t\tif (!next) this.#last = run;\n\t\tthis.#nextExpiry();\n\t\twhile (this.#runs.size > this.#maxRuns && this.#giveUpOldest()) {}\n\t}\n\n\t/**\n\t * {@link account} keys `[start, end)`, of which only those from `began` on may mark where the\n\t * feed began ({@link lowest}): those under it are keys under the feed's start that its publisher\n\t * accounted for. Mirrors the Rust `Ledger::account_under`.\n\t */\n\taccountUnder(start: bigint, end: bigint, began: bigint, at: Instant): void {\n\t\tconst lowest = this.#lowest;\n\t\tthis.account(start, end, at);\n\t\tconst from = max(began, start);\n\t\tthis.#lowest = from < end ? (lowest === undefined ? from : min(lowest, from)) : lowest;\n\t}\n\n\t// Shed one run to bound the ledger, returning whether it did: fold the oldest gap, or on a\n\t// proven ledger, which never gives up on a gap, forget the lowest run, claiming less than it\n\t// was told rather than more.\n\t#giveUpOldest(): boolean {\n\t\tif (!this.#proven) return this.foldOldest() !== undefined;\n\t\tif (this.#runs.size < 2) return false;\n\t\tconst lowest = this.#runs.first();\n\t\tif (!lowest) return false;\n\t\tthis.#remove(lowest);\n\t\tif (this.#last === lowest) this.#last = undefined;\n\t\tthis.#forgotten = this.#forgotten === undefined ? lowest.end : max(this.#forgotten, lowest.end);\n\t\tthis.#nextExpiry();\n\t\treturn true;\n\t}\n\n\t/**\n\t * Fold the oldest gap into the runs around it however young, returning the keys it held;\n\t * undefined with no gap to fold, or on a proven ledger.\n\t */\n\tfoldOldest(): { start: bigint; end: bigint } | undefined {\n\t\tif (this.#proven) return undefined;\n\t\tconst run = this.#next;\n\t\tif (!run) return undefined;\n\t\tconst below = this.#runs.lower(run.start);\n\t\tif (!below) throw new Error(\"an expiring gap must have a lower run\");\n\t\tconst gap = { start: below.end, end: run.start };\n\t\tbelow.end = run.end;\n\t\tthis.#remove(run);\n\t\tif (this.#last === run) this.#last = below;\n\t\tthis.#nextExpiry();\n\t\treturn gap;\n\t}\n\n\t/** Fold every gap at least `grace` old into the runs around it. */\n\texpire(at: Instant, grace: Duration | undefined): void {\n\t\t// No grace, or a proven ledger: a gap is waited for until something accounts for it.\n\t\tif (grace === undefined || this.#proven) return;\n\t\twhile (this.#next && at.since(this.#next.since).ge(grace)) {\n\t\t\tthis.foldOldest();\n\t\t}\n\t}\n\n\t/** Whether a gap separates two runs, so {@link expire} has anything to fold. */\n\thasGaps(): boolean {\n\t\treturn this.#runs.size > 1;\n\t}\n\n\t/** The lowest key accounted for. */\n\tfirst(): bigint | undefined {\n\t\treturn this.#runs.first()?.start;\n\t}\n\n\t/** The exclusive end of the highest run starting at or below `key`. */\n\tendBelow(key: bigint): bigint | undefined {\n\t\treturn this.#runs.floor(key)?.end;\n\t}\n\n\t/** Whether every key in `[start, end)` is accounted for. */\n\tcovers(start: bigint, end: bigint): boolean {\n\t\tif (start >= end) return true;\n\t\t// Runs merge on insert, so one run covers the span or none does.\n\t\tconst run = this.#runs.floor(start);\n\t\treturn run !== undefined && end <= run.end;\n\t}\n\n\t/**\n\t * The gaps within `[start, end)`, each with when a later arrival opened it: none for the one\n\t * past the last run, which nothing has opened yet.\n\t */\n\tgaps(start: bigint, end: bigint): { start: bigint; end: bigint; since?: Instant }[] {\n\t\tconst gaps: { start: bigint; end: bigint; since?: Instant }[] = [];\n\t\tlet below = start;\n\t\tconst lower = this.#runs.floor(start);\n\t\tfor (const run of this.#runs.from(lower?.start ?? start)) {\n\t\t\tif (below >= end) return gaps;\n\t\t\tif (run.end <= below) continue;\n\t\t\tif (below < run.start) gaps.push({ start: below, end: min(run.start, end), since: run.since });\n\t\t\tbelow = run.end;\n\t\t}\n\t\tif (below < end) gaps.push({ start: below, end });\n\t\treturn gaps;\n\t}\n\n\t/** Restart the age of every gap reaching into `[start, end)`, which the demand newly asks for. */\n\tdemand(start: bigint, end: bigint, at: Instant): void {\n\t\tif (start >= end) return;\n\t\tconst lower = this.#runs.floor(start);\n\t\tlet below = lower?.end ?? 0n;\n\t\tfor (const run of this.#runs.from(start)) {\n\t\t\tif (below >= end) break;\n\t\t\tif (start < run.start) {\n\t\t\t\tthis.#ages.delete(run);\n\t\t\t\trun.since = at;\n\t\t\t\tthis.#ages.insert(run);\n\t\t\t}\n\t\t\tbelow = run.end;\n\t\t}\n\t\tthis.#nextExpiry();\n\t}\n}\n"]}
package/listing.d.ts ADDED
@@ -0,0 +1,132 @@
1
+ /**
2
+ * A broadcast's track listing: the tracks it lists, reported to each reader in order.
3
+ *
4
+ * A track is listed while its producer holds it: created by its producer (a track of groups until
5
+ * it is released, aborted, or removed, a datagram track until it ends), or answered by a
6
+ * {@link Lister}, as a session lists its peer's tracks. A track served only on request is never
7
+ * listed, and listing never requests one.
8
+ *
9
+ * Datagram tracks are a namespace apart from tracks of groups, so a name is listed at most once
10
+ * per kind.
11
+ *
12
+ * Each {@link Tracks} reader keeps its own queue, keyed by kind and name in insertion order, so a
13
+ * stalled reader holds at most one pending change per listed track: an add and a removal it has
14
+ * not reached cancel, and a removal and re-add of a track it saw collapse in place. Its state is
15
+ * bounded by the tracks it saw plus the live set, however long it stalls.
16
+ *
17
+ * @module
18
+ */
19
+ import { type GetPromise, type Getter } from "@moq/signals";
20
+ import type * as datagram from "./datagram.ts";
21
+ import type * as track from "./track.ts";
22
+ /**
23
+ * Which of a broadcast's two namespaces a listed track is in: a track of groups, or a datagram
24
+ * track. A name is unique within its kind.
25
+ *
26
+ * @public
27
+ */
28
+ export type Kind = "track" | "datagrams";
29
+ /**
30
+ * A listed track's {@link Kind} and fixed properties: a track of groups with its
31
+ * {@link track.Info}, or a datagram track with its {@link datagram.Info}.
32
+ *
33
+ * @public
34
+ */
35
+ export type Listed = {
36
+ type: "track";
37
+ info: track.Info;
38
+ } | {
39
+ type: "datagrams";
40
+ info: datagram.Info;
41
+ };
42
+ /**
43
+ * What a {@link Tracks} listing reports, in order.
44
+ *
45
+ * `added`: a track the broadcast lists, with its kind and fixed properties. `synced`: every
46
+ * track listed once the listing was complete (at once for a local broadcast, on its moq-lite
47
+ * upstream's SYNCED for a session's copy), and still listed, was reported; sent once, and later
48
+ * events are live. A session over moq-transport fails the listing instead, since that upstream
49
+ * never signals a complete list. `removed`: a track an earlier `added` reported is no longer listed,
50
+ * unfinished: its producer aborted, or the answer that listed it withdrew it; a handler may still
51
+ * serve its name on request. `finished`: a track an earlier `added` reported is no longer listed
52
+ * because it finished. A removal carries the `type` its `added` did.
53
+ *
54
+ * @public
55
+ */
56
+ export type TracksEvent = ({
57
+ kind: "added";
58
+ name: string;
59
+ } & Listed) | {
60
+ kind: "synced";
61
+ } | {
62
+ kind: "removed";
63
+ name: string;
64
+ type: Kind;
65
+ } | {
66
+ kind: "finished";
67
+ name: string;
68
+ type: Kind;
69
+ };
70
+ /**
71
+ * The tracks a broadcast lists, from its consumer's `tracks()`.
72
+ *
73
+ * Reports every track listed once the listing is complete, then `synced`, then each change as it
74
+ * happens, until the broadcast ends: a clean end comes after each track that left before it, and
75
+ * a track still listed then ends unfinished. Listing a broadcast never requests a track: subscribe to
76
+ * each listed one through the consumer's `track(name)`.
77
+ *
78
+ * @public
79
+ */
80
+ export declare class Tracks {
81
+ #private;
82
+ private constructor();
83
+ /**
84
+ * The next event, or undefined once the broadcast ended or this listing closed. Throws the
85
+ * error that ended the listing, such as the peer refusing it.
86
+ */
87
+ next(): Promise<TracksEvent | undefined>;
88
+ /** The events as they arrive; leaving the loop early closes the listing. */
89
+ [Symbol.asyncIterator](): AsyncGenerator<TracksEvent, void, undefined>;
90
+ /** Stop listing. Idempotent. */
91
+ close(): void;
92
+ }
93
+ /**
94
+ * Answers a broadcast's listings for a handler that knows the tracks it would serve, as a
95
+ * session lists its peer's. A broadcast has at most one.
96
+ *
97
+ * While it exists, readers wait for it to {@link synced} before reporting `synced`. Answer
98
+ * while {@link wanted}: list what the publisher behind it holds and keep it current, then
99
+ * {@link clear} once unwanted. {@link close} withdraws what it listed; a closed lister answers
100
+ * nothing more.
101
+ */
102
+ export declare class Lister {
103
+ #private;
104
+ private constructor();
105
+ /** Whether anyone lists the broadcast. */
106
+ get wanted(): Getter<boolean>;
107
+ /** Settles once the broadcast ended, as every listing of it does. */
108
+ get closed(): GetPromise<null>;
109
+ /** List a track of the kind `listed` says. Throws if this answer already lists that kind and name. */
110
+ add(name: string, listed: Listed): void;
111
+ /**
112
+ * Stop listing a track of `type` that left unfinished, reported as `removed`. Throws if this
113
+ * answer does not list that kind and name.
114
+ */
115
+ remove(name: string, type?: Kind): void;
116
+ /**
117
+ * Stop listing a track of `type` that finished, reported as `finished`. Throws if this answer
118
+ * does not list that kind and name.
119
+ */
120
+ finish(name: string, type?: Kind): void;
121
+ /** The answer holds everything this hop knows now; later changes are live. */
122
+ synced(): void;
123
+ /** Withdraw the answer: every track it listed, and its sync. */
124
+ clear(): void;
125
+ /** End every current reader as if the broadcast ended, and withdraw the answer. A later reader asks again. */
126
+ end(): void;
127
+ /** Fail every current reader with `err`, and withdraw the answer. A later reader asks again. */
128
+ abort(err: Error): void;
129
+ /** Stop answering: the broadcast lists only its producer's tracks from here on. Idempotent. */
130
+ close(): void;
131
+ }
132
+ //# sourceMappingURL=listing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listing.d.ts","sourceRoot":"","sources":["../src/listing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,MAAM,EAAU,MAAM,cAAc,CAAC;AACpE,OAAO,KAAK,KAAK,QAAQ,MAAM,eAAe,CAAC;AAG/C,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG,WAAW,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAA;CAAE,CAAC;AAEtG;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,GACpB,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;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,KAAK,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAItB;IAED,+FAA+F;IAC/F,KAAK,IAAI,IAAI,CAGZ;CACD"}
package/listing.js ADDED
@@ -0,0 +1,486 @@
1
+ /**
2
+ * A broadcast's track listing: the tracks it lists, reported to each reader in order.
3
+ *
4
+ * A track is listed while its producer holds it: created by its producer (a track of groups until
5
+ * it is released, aborted, or removed, a datagram track until it ends), or answered by a
6
+ * {@link Lister}, as a session lists its peer's tracks. A track served only on request is never
7
+ * listed, and listing never requests one.
8
+ *
9
+ * Datagram tracks are a namespace apart from tracks of groups, so a name is listed at most once
10
+ * per kind.
11
+ *
12
+ * Each {@link Tracks} reader keeps its own queue, keyed by kind and name in insertion order, so a
13
+ * stalled reader holds at most one pending change per listed track: an add and a removal it has
14
+ * not reached cancel, and a removal and re-add of a track it saw collapse in place. Its state is
15
+ * bounded by the tracks it saw plus the live set, however long it stalls.
16
+ *
17
+ * @module
18
+ */
19
+ import { Signal } from "@moq/signals";
20
+ import { StreamCode, StreamError } from "./error.js";
21
+ import { hooks } from "./internal.js";
22
+ /**
23
+ * Whether `own` leaves the listing as finished: it closed cleanly, or a track of groups declared
24
+ * its end and is still open, as the Rust listing counts a producer that finished but still holds
25
+ * its track.
26
+ */
27
+ function finished(own) {
28
+ if (own.type === "datagrams")
29
+ return own.producer.closed.peek() === null;
30
+ const released = hooks.trackReleased(own.producer).peek();
31
+ return released === null || (released === undefined && hooks.trackFinished(own.producer));
32
+ }
33
+ /**
34
+ * The key a listed track is held under: its kind, then its name, so the kinds never collide.
35
+ *
36
+ * @internal
37
+ */
38
+ export function keyOf(name, type) {
39
+ return (type === "datagrams" ? "d" : "t") + name;
40
+ }
41
+ /** The event for the track under `key` leaving the listing. */
42
+ function removal(key, finished) {
43
+ const kind = finished ? "finished" : "removed";
44
+ const name = key.slice(1);
45
+ return { kind, name, type: key[0] === "d" ? "datagrams" : "track" };
46
+ }
47
+ /** One reader's pending changes, keyed by kind and name in the order they happened. */
48
+ class Queue {
49
+ pending = new Map();
50
+ sync = "waiting";
51
+ /** `null` once the listing ended, or the error that ended it. */
52
+ end;
53
+ /** The reader left the listing, or a newer reader of its owner replaced it. */
54
+ detached = false;
55
+ changed = new Signal(0);
56
+ wake() {
57
+ this.changed.update((n) => n + 1);
58
+ }
59
+ add(key, listed) {
60
+ // A track is listed once at a time, so only its removal can be pending.
61
+ const pending = this.pending.get(key);
62
+ if (pending?.kind === "remove")
63
+ this.pending.set(key, { kind: "readd", finished: pending.finished, listed });
64
+ else
65
+ this.pending.set(key, { kind: "add", listed });
66
+ this.wake();
67
+ }
68
+ remove(key, finished) {
69
+ // Never read: the two cancel. Otherwise the removal replaces a pending re-add in place.
70
+ if (this.pending.get(key)?.kind === "add")
71
+ this.dequeue(key);
72
+ else
73
+ this.pending.set(key, { kind: "remove", finished });
74
+ this.wake();
75
+ }
76
+ /** Drop the change queued under `key`, so SYNCED no longer waits on it. */
77
+ dequeue(key) {
78
+ this.pending.delete(key);
79
+ if (this.sync instanceof Set)
80
+ this.sync.delete(key);
81
+ }
82
+ /** The listing synced: SYNCED goes out once what is queued now was read. */
83
+ synced() {
84
+ if (this.sync !== "waiting")
85
+ return;
86
+ this.sync = new Set(this.pending.keys());
87
+ this.wake();
88
+ }
89
+ /** The listing's answer restarted before this reader was told it synced. */
90
+ unsync() {
91
+ if (this.sync instanceof Set)
92
+ this.sync = "waiting";
93
+ }
94
+ finish(end) {
95
+ this.end ??= end;
96
+ this.detached = true;
97
+ this.wake();
98
+ }
99
+ ready() {
100
+ return this.end !== undefined || this.pending.size > 0 || this.sync instanceof Set;
101
+ }
102
+ next() {
103
+ if (this.end)
104
+ throw this.end;
105
+ if (this.end === null) {
106
+ // A clean end still reports each track that left before it, and how; an add the
107
+ // reader never read is dropped.
108
+ for (const [key, pending] of this.pending) {
109
+ this.pending.delete(key);
110
+ if (pending.kind !== "add")
111
+ return removal(key, pending.finished);
112
+ }
113
+ return undefined;
114
+ }
115
+ if (this.sync instanceof Set && this.sync.size === 0) {
116
+ this.sync = "sent";
117
+ return { kind: "synced" };
118
+ }
119
+ const first = this.pending.entries().next();
120
+ if (first.done)
121
+ throw new Error("a ready queue has a pending change");
122
+ const [key, pending] = first.value;
123
+ switch (pending.kind) {
124
+ case "add":
125
+ this.dequeue(key);
126
+ return { kind: "added", name: key.slice(1), ...pending.listed };
127
+ case "remove":
128
+ this.dequeue(key);
129
+ return removal(key, pending.finished);
130
+ case "readd":
131
+ // Setting an existing key keeps its place, so the add is read next, and SYNCED
132
+ // still waits on it if it did.
133
+ this.pending.set(key, { kind: "add", listed: pending.listed });
134
+ return removal(key, pending.finished);
135
+ }
136
+ }
137
+ }
138
+ /**
139
+ * The listing half of a broadcast's state.
140
+ *
141
+ * @internal
142
+ */
143
+ export class Listing {
144
+ /** Every listed track, in the order it was listed. */
145
+ #live = new Map();
146
+ /** The queue of every reader of the current answer. */
147
+ #readers = new Set();
148
+ /** Each owner's reader. */
149
+ #owners = new Map();
150
+ /** Whether a {@link Lister} exists. While one does, readers wait for its answer to sync. */
151
+ #lister = false;
152
+ /** Whether the lister's answer has synced. */
153
+ #answered = false;
154
+ #wanted = new Signal(false);
155
+ #closed;
156
+ constructor(closed) {
157
+ this.#closed = closed;
158
+ }
159
+ /** Whether anyone lists the broadcast. */
160
+ get wanted() {
161
+ return this.#wanted;
162
+ }
163
+ /** Settles once the broadcast ended. */
164
+ get closed() {
165
+ return this.#closed;
166
+ }
167
+ #synced() {
168
+ return !this.#lister || this.#answered;
169
+ }
170
+ #counted() {
171
+ this.#wanted.set(this.#readers.size > 0);
172
+ }
173
+ /** Re-evaluate whether the listing has synced, telling readers when it changed. */
174
+ #resync(was) {
175
+ const now = this.#synced();
176
+ if (!was && now)
177
+ for (const queue of this.#readers)
178
+ queue.synced();
179
+ if (was && !now)
180
+ for (const queue of this.#readers)
181
+ queue.unsync();
182
+ }
183
+ #insert(key, entry) {
184
+ this.#live.set(key, entry);
185
+ for (const queue of this.#readers)
186
+ queue.add(key, entry.listed);
187
+ }
188
+ /** Unlist the track under `key`, telling readers whether it `finished`. */
189
+ #remove(key, finished) {
190
+ if (!this.#live.delete(key))
191
+ return;
192
+ for (const queue of this.#readers)
193
+ queue.remove(key, finished);
194
+ }
195
+ /**
196
+ * A reader with every listed track queued, ending `owner`'s older one with CANCELLED so an
197
+ * owner's listings cost one queue per broadcast however many requests reach it.
198
+ */
199
+ read(owner) {
200
+ if (this.#closed.peek() !== undefined) {
201
+ throw new StreamError(StreamCode.Unroutable, { message: "broadcast is closed" });
202
+ }
203
+ const queue = new Queue();
204
+ for (const [key, entry] of this.#live)
205
+ queue.pending.set(key, { kind: "add", listed: entry.listed });
206
+ if (this.#synced())
207
+ queue.sync = new Set(queue.pending.keys());
208
+ this.#readers.add(queue);
209
+ if (owner) {
210
+ const older = this.#owners.get(owner);
211
+ this.#owners.set(owner, queue);
212
+ if (older) {
213
+ this.#readers.delete(older);
214
+ older.finish(new StreamError(StreamCode.Cancel, { message: "replaced by a newer listing" }));
215
+ }
216
+ }
217
+ this.#counted();
218
+ return queue;
219
+ }
220
+ /** A reader left, so it reads nothing more. A replaced or ended one already did. */
221
+ release(queue, owner) {
222
+ queue.pending.clear();
223
+ if (queue.detached)
224
+ return;
225
+ queue.finish(null);
226
+ this.#readers.delete(queue);
227
+ if (owner && this.#owners.get(owner) === queue)
228
+ this.#owners.delete(owner);
229
+ this.#counted();
230
+ }
231
+ /** List the track of groups `producer` created. */
232
+ listTrack(producer, info) {
233
+ this.#listOwn(producer.name, { type: "track", producer }, { type: "track", info });
234
+ }
235
+ /** List the datagram track `producer` created. */
236
+ listDatagrams(producer, info) {
237
+ this.#listOwn(producer.name, { type: "datagrams", producer }, { type: "datagrams", info });
238
+ }
239
+ #listOwn(name, own, listed) {
240
+ const key = keyOf(name, listed.type);
241
+ const entry = this.#live.get(key);
242
+ if (!entry) {
243
+ this.#insert(key, { listed, own, answered: false });
244
+ }
245
+ else if (entry.own && !entry.answered) {
246
+ // The earlier track of the name has not unlisted yet, but it left the table for this
247
+ // one: readers see it go, as it ended, and the new one arrive.
248
+ this.#remove(key, finished(entry.own));
249
+ this.#insert(key, { listed, own, answered: false });
250
+ }
251
+ else {
252
+ // Listed already by the answer, and it never stopped being listed: only the owner moves.
253
+ entry.own = own;
254
+ }
255
+ }
256
+ /**
257
+ * Unlist the track `producer` created, as one that `finished` or left unfinished (by default,
258
+ * as it ended), unless a later one took its name.
259
+ */
260
+ unlistOwn(producer, type = "track", done) {
261
+ const entry = this.#live.get(keyOf(producer.name, type));
262
+ if (!entry?.own || entry.own.producer !== producer)
263
+ return;
264
+ const own = entry.own;
265
+ entry.own = undefined;
266
+ if (!entry.answered)
267
+ this.#remove(keyOf(producer.name, type), done ?? finished(own));
268
+ }
269
+ /** Lister support; see {@link Lister}. */
270
+ attach() {
271
+ if (this.#lister)
272
+ throw new Error("the broadcast already has a lister");
273
+ const was = this.#synced();
274
+ this.#lister = true;
275
+ this.#resync(was);
276
+ }
277
+ detachLister() {
278
+ const was = this.#synced();
279
+ this.#lister = false;
280
+ // Synced from here on, with only the producer's tracks.
281
+ this.#unanswer();
282
+ this.#resync(was);
283
+ }
284
+ answerAdd(name, listed) {
285
+ const key = keyOf(name, listed.type);
286
+ const entry = this.#live.get(key);
287
+ if (entry?.answered)
288
+ throw new Error(`duplicate listed track: ${name}`);
289
+ if (entry)
290
+ entry.answered = true;
291
+ // Copied, so an event forwarded as the answer lends it nothing else.
292
+ else
293
+ this.#insert(key, {
294
+ listed: listed.type === "datagrams"
295
+ ? { type: "datagrams", info: listed.info }
296
+ : { type: "track", info: listed.info },
297
+ answered: true,
298
+ });
299
+ }
300
+ answerRemove(name, finished, type = "track") {
301
+ this.#answerRemove(keyOf(name, type), finished);
302
+ }
303
+ #answerRemove(key, finished) {
304
+ const entry = this.#live.get(key);
305
+ if (!entry?.answered)
306
+ throw new Error(`track not listed: ${key.slice(1)}`);
307
+ entry.answered = false;
308
+ if (!entry.own)
309
+ this.#remove(key, finished);
310
+ }
311
+ answerSynced() {
312
+ const was = this.#synced();
313
+ this.#answered = true;
314
+ this.#resync(was);
315
+ }
316
+ /** Drop the answer: every track it listed, and its sync. */
317
+ answerClear() {
318
+ const was = this.#synced();
319
+ this.#unanswer();
320
+ this.#resync(was);
321
+ }
322
+ #unanswer() {
323
+ for (const [key, entry] of [...this.#live]) {
324
+ if (entry.answered)
325
+ this.#answerRemove(key, false);
326
+ }
327
+ this.#answered = false;
328
+ }
329
+ /**
330
+ * The broadcast ended: so does every listing of it, first unlisting each of its producer's tracks
331
+ * that finished. A handler's answer of the same name does not keep it live, since the producer's
332
+ * track is what served it.
333
+ */
334
+ close() {
335
+ for (const [key, entry] of [...this.#live]) {
336
+ if (entry.own && finished(entry.own))
337
+ this.#remove(key, true);
338
+ }
339
+ this.detach(null);
340
+ }
341
+ /** End every reader with `end` and detach them. */
342
+ detach(end) {
343
+ for (const queue of this.#readers)
344
+ queue.finish(end);
345
+ this.#readers.clear();
346
+ this.#owners.clear();
347
+ this.#counted();
348
+ }
349
+ }
350
+ let makeTracks;
351
+ /**
352
+ * List a broadcast's tracks, ending `owner`'s older listing of it with CANCELLED.
353
+ *
354
+ * @internal
355
+ */
356
+ export function listTracks(listing, owner) {
357
+ return makeTracks(listing, owner);
358
+ }
359
+ /**
360
+ * The tracks a broadcast lists, from its consumer's `tracks()`.
361
+ *
362
+ * Reports every track listed once the listing is complete, then `synced`, then each change as it
363
+ * happens, until the broadcast ends: a clean end comes after each track that left before it, and
364
+ * a track still listed then ends unfinished. Listing a broadcast never requests a track: subscribe to
365
+ * each listed one through the consumer's `track(name)`.
366
+ *
367
+ * @public
368
+ */
369
+ export class Tracks {
370
+ #listing;
371
+ #queue;
372
+ #owner;
373
+ constructor(listing, owner) {
374
+ this.#listing = listing;
375
+ this.#queue = listing.read(owner);
376
+ this.#owner = owner;
377
+ }
378
+ static {
379
+ makeTracks = (listing, owner) => new Tracks(listing, owner);
380
+ }
381
+ /**
382
+ * The next event, or undefined once the broadcast ended or this listing closed. Throws the
383
+ * error that ended the listing, such as the peer refusing it.
384
+ */
385
+ async next() {
386
+ for (;;) {
387
+ if (this.#queue.ready())
388
+ return this.#queue.next();
389
+ await Signal.race(this.#queue.changed);
390
+ }
391
+ }
392
+ /** The events as they arrive; leaving the loop early closes the listing. */
393
+ async *[Symbol.asyncIterator]() {
394
+ try {
395
+ for (;;) {
396
+ const event = await this.next();
397
+ if (!event)
398
+ return;
399
+ yield event;
400
+ }
401
+ }
402
+ finally {
403
+ this.close();
404
+ }
405
+ }
406
+ /** Stop listing. Idempotent. */
407
+ close() {
408
+ this.#listing.release(this.#queue, this.#owner);
409
+ }
410
+ }
411
+ /** Make the lister attached to a broadcast's listing state. @internal */
412
+ export let makeLister;
413
+ /**
414
+ * Answers a broadcast's listings for a handler that knows the tracks it would serve, as a
415
+ * session lists its peer's. A broadcast has at most one.
416
+ *
417
+ * While it exists, readers wait for it to {@link synced} before reporting `synced`. Answer
418
+ * while {@link wanted}: list what the publisher behind it holds and keep it current, then
419
+ * {@link clear} once unwanted. {@link close} withdraws what it listed; a closed lister answers
420
+ * nothing more.
421
+ */
422
+ export class Lister {
423
+ #listing;
424
+ // The listing this lister answers into, until it closes.
425
+ #answering;
426
+ constructor(listing) {
427
+ listing.attach();
428
+ this.#listing = listing;
429
+ this.#answering = listing;
430
+ }
431
+ static {
432
+ makeLister = (listing) => new Lister(listing);
433
+ }
434
+ /** Whether anyone lists the broadcast. */
435
+ get wanted() {
436
+ return this.#listing.wanted;
437
+ }
438
+ /** Settles once the broadcast ended, as every listing of it does. */
439
+ get closed() {
440
+ return this.#listing.closed;
441
+ }
442
+ /** List a track of the kind `listed` says. Throws if this answer already lists that kind and name. */
443
+ add(name, listed) {
444
+ this.#answering?.answerAdd(name, listed);
445
+ }
446
+ /**
447
+ * Stop listing a track of `type` that left unfinished, reported as `removed`. Throws if this
448
+ * answer does not list that kind and name.
449
+ */
450
+ remove(name, type = "track") {
451
+ this.#answering?.answerRemove(name, false, type);
452
+ }
453
+ /**
454
+ * Stop listing a track of `type` that finished, reported as `finished`. Throws if this answer
455
+ * does not list that kind and name.
456
+ */
457
+ finish(name, type = "track") {
458
+ this.#answering?.answerRemove(name, true, type);
459
+ }
460
+ /** The answer holds everything this hop knows now; later changes are live. */
461
+ synced() {
462
+ this.#answering?.answerSynced();
463
+ }
464
+ /** Withdraw the answer: every track it listed, and its sync. */
465
+ clear() {
466
+ this.#answering?.answerClear();
467
+ }
468
+ /** End every current reader as if the broadcast ended, and withdraw the answer. A later reader asks again. */
469
+ end() {
470
+ const listing = this.#answering;
471
+ listing?.detach(null);
472
+ listing?.answerClear();
473
+ }
474
+ /** Fail every current reader with `err`, and withdraw the answer. A later reader asks again. */
475
+ abort(err) {
476
+ const listing = this.#answering;
477
+ listing?.detach(err);
478
+ listing?.answerClear();
479
+ }
480
+ /** Stop answering: the broadcast lists only its producer's tracks from here on. Idempotent. */
481
+ close() {
482
+ this.#answering?.detachLister();
483
+ this.#answering = undefined;
484
+ }
485
+ }
486
+ //# sourceMappingURL=listing.js.map