@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/README.md CHANGED
@@ -12,7 +12,7 @@ A TypeScript [Media over QUIC](https://moq.dev/) (MoQ) client for both browsers
12
12
 
13
13
  Check out [hang](../hang) for a higher-level media library that uses this package.
14
14
 
15
- > **Note:** moq-lite is a subset of moq-transport and is forwards compatible with it, so this client works with any moq-transport CDN (ex. [Cloudflare](https://moq.dev/blog/first-cdn/)). See the [compatibility docs](https://doc.moq.dev/concept/moq-lite#compatibility) for details.
15
+ > **Note:** moq-lite is a subset of moq-transport and is forwards compatible with it, so this client works with any moq-transport CDN (ex. [Cloudflare](https://moq.dev/blog/first-cdn/)). See the [compatibility docs](https://doc.moq.dev/concept/moq-lite#what-moq-lite-leaves-out) for details.
16
16
 
17
17
  ## Quick Start
18
18
 
@@ -63,6 +63,12 @@ await quicheLoaded; //This is a promise, connect after it resolves
63
63
  - **[Waiting](examples/wait.ts)** - Wait for one known broadcast to come online, and follow it
64
64
  - **[Server side usage](https://github.com/sb2702/webcodecs-examples/tree/main/src/moq-server)** - Publish from browser to a server
65
65
 
66
+ ## Integer precision
67
+
68
+ Group identities and relative group counts use `bigint`. Frame indices, timestamps,
69
+ and durations use bounded numbers and refuse unsafe wire values. See
70
+ [wire integer precision](INTEGERS.md) for the field-by-field limits.
71
+
66
72
  ## License
67
73
 
68
74
  Licensed under either:
package/announce.d.ts CHANGED
@@ -3,5 +3,5 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- export { Consumer, isActive, type Kind, type Update } from "./announced";
6
+ export { type Announce, Consumer, type Event, type Options } from "./announced.ts";
7
7
  //# sourceMappingURL=announce.d.ts.map
package/announce.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"announce.d.ts","sourceRoot":"","sources":["../src/announce.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"announce.d.ts","sourceRoot":"","sources":["../src/announce.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,QAAQ,EAAE,QAAQ,EAAE,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC"}
package/announce.js CHANGED
@@ -1,8 +1,7 @@
1
- /* @ts-self-types="./announce.d.ts" */
2
1
  /**
3
2
  * Broadcast announcement streams.
4
3
  *
5
4
  * @module
6
5
  */
7
- export { Consumer, isActive } from "./announced.js";
6
+ export { Consumer } from "./announced.js";
8
7
  //# sourceMappingURL=announce.js.map
package/announce.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"announce.js","sourceRoot":"","sources":["../src/announce.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAA0B,MAAM,gBAAgB,CAAC","sourcesContent":["/**\n * Broadcast announcement streams.\n *\n * @module\n */\nexport { Consumer, isActive, type Kind, type Update } from \"./announced.ts\";\n"]}
1
+ {"version":3,"file":"announce.js","sourceRoot":"","sources":["../src/announce.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAiB,QAAQ,EAA4B,MAAM,gBAAgB,CAAC","sourcesContent":["/**\n * Broadcast announcement streams.\n *\n * @module\n */\nexport { type Announce, Consumer, type Event, type Options } from \"./announced.ts\";\n"]}
package/announced.d.ts CHANGED
@@ -3,38 +3,43 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import { type GetPromise } from "@moq/signals";
7
- import type { Route } from "./hop.js";
6
+ import { type GetPromise, type Getter } from "@moq/signals";
7
+ import { type RouteInfo } from "./hop.ts";
8
8
  import type * as Path from "./path.js";
9
9
  /**
10
- * What an {@link Update} reports about its prefix.
11
- *
12
- * @public
13
- */
14
- export type Kind = "announced" | "updated" | "retracted";
15
- /**
16
- * A route announcement, update, or retraction.
10
+ * A route over a prefix, delivered inside an {@link Event}.
17
11
  *
18
12
  * An announcement is always a prefix, never a broadcast: a route claims that
19
13
  * {@link prefix} and every path beneath it can be served. By convention a publisher
20
14
  * announces each broadcast's exact path, so enumerating routes enumerates broadcasts;
21
- * resolve one with the origin's `request(path)`. Narrow with a {@link Path.Pattern}
22
- * locally to follow a subset.
15
+ * resolve one with the origin's `request(path)`. List a narrower prefix, or filter the
16
+ * announced paths locally, to follow a subset.
23
17
  *
24
18
  * @public
25
19
  */
26
- export interface Update {
20
+ export interface Announce {
27
21
  /**
28
22
  * The prefix the route covers, relative to the origin (for a session, its URL path).
29
23
  */
30
24
  prefix: Path.Valid;
31
- /** What the filter's wildcards stood for, when this prefix pins all of them. */
32
- captures: Path.Pattern[] | undefined;
33
- /** Whether the prefix was announced, re-priced, or retracted. */
34
- kind: Kind;
35
25
  /** Hops and cost of the route; on a retraction, its last advertised values. */
36
- route: Route;
26
+ route: RouteInfo;
37
27
  }
28
+ /**
29
+ * What an announcement listing yields: a path becoming present or absent.
30
+ *
31
+ * `present`: a route now covers the path, which was absent; it may arrive unavailable (see
32
+ * {@link RouteInfo.available}). `absent`: no route covers the path any more, whether its origin
33
+ * withdrew it or this side let go of it; carries its last advertised route.
34
+ *
35
+ * Another identity taking a path over keeps it present, and a change in availability is not
36
+ * reported: follow it with the origin's `follow(path)` to see the broadcast change.
37
+ *
38
+ * @public
39
+ */
40
+ export type Event = {
41
+ kind: "present" | "absent";
42
+ } & Announce;
38
43
  /**
39
44
  * Options for an announcement stream.
40
45
  *
@@ -43,51 +48,50 @@ export interface Update {
43
48
  export interface Options {
44
49
  /**
45
50
  * Also report hidden routes: those with a path segment starting with `.` below the
46
- * scope's literal head. Hidden routes are left out by default, so a platform can add
51
+ * listed prefix. Hidden routes are left out by default, so a platform can add
47
52
  * `.`-named broadcasts (stats, internal routes) without them turning up in apps that
48
53
  * list everything. Subscribing to a hidden path by name works either way.
49
54
  */
50
55
  hidden?: boolean;
51
- }
52
- /** Whether a route covers the path after an update of this {@link Kind}. */
53
- export declare function isActive(kind: Kind): boolean;
54
- /**
55
- * The write side of an announcement stream.
56
- *
57
- * @public
58
- */
59
- export declare class Producer {
60
- #private;
61
56
  /**
62
- * Settles once the stream closes: `null` on a clean close, or the abort {@link Error}.
63
- * Peek it synchronously (`undefined` while open), observe it reactively, or `await` it.
57
+ * Also report every route that could serve a path in scope, not just those at or beneath
58
+ * the listed prefix. A route is a prefix serving everything beneath it, so listing
59
+ * `room/lobby` still reports a route at `room`, which can serve it. A broadcast serves only
60
+ * its own path, yet is reported too, since it shadows broader routes beneath it, as in Rust. Code that routes or forwards needs these;
61
+ * listing broadcasts does not. Requests resolve through covering routes either way.
64
62
  */
65
- get closed(): GetPromise<Error | null>;
66
- /** A read handle for this announcement stream. */
67
- consume(): Consumer;
68
- /** Writes an announcement to the queue. */
69
- append(update: Update): void;
70
- /** Closes the writer. Idempotent. */
71
- close(abort?: Error): void;
63
+ covering?: boolean;
72
64
  }
73
65
  /**
74
- * The read side of an announcement stream.
66
+ * The paths announced under a scope, each reported as it becomes present or absent.
75
67
  *
76
- * Created internally: obtain one from {@link Producer.consume} or the connection's
77
- * `announced(scope)`.
68
+ * Created internally: obtain one from an origin or the connection's `announced(scope)`.
78
69
  *
79
70
  * @public
80
71
  */
81
72
  export declare class Consumer {
82
73
  #private;
83
74
  private constructor();
84
- /** Settles once the stream closes; see {@link Producer.closed}. */
75
+ /** Settles once the stream closes: `null` on a clean close, or the abort {@link Error}. */
85
76
  get closed(): GetPromise<Error | null>;
86
- /** The announcements as they arrive, until the stream closes. */
87
- [Symbol.asyncIterator](): AsyncGenerator<Update, void, undefined>;
88
- /** Returns the next announcement. */
89
- next(): Promise<Update | undefined>;
90
- /** Closes the reader. Idempotent. */
91
- close(abort?: Error): void;
77
+ /**
78
+ * Whether the listing has delivered its source's initial announcements and the reader has
79
+ * taken them, so a path not present by now is absent rather than not yet heard of.
80
+ *
81
+ * Flips once the reader asks for the event after the last of them, and is true once
82
+ * closed. Through a session, the initial set is the peer's view when it answered: exact
83
+ * on versions that count it, best-effort on the rest. Reading an origin, it is every
84
+ * attached session's initial set, so a reconnect takes it back until the new one lands.
85
+ */
86
+ get synced(): Getter<boolean>;
87
+ /** The events as they arrive, until the listing closes. */
88
+ [Symbol.asyncIterator](): AsyncGenerator<Event, void, undefined>;
89
+ /** Returns the next change to a path, or undefined once the listing or this handle closes. */
90
+ next(): Promise<Event | undefined>;
91
+ /**
92
+ * Release this handle, like dropping a Rust handle: the source sees the listing as no
93
+ * longer wanted. Idempotent.
94
+ */
95
+ close(): void;
92
96
  }
93
97
  //# sourceMappingURL=announced.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"announced.d.ts","sourceRoot":"","sources":["../src/announced.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AAEvC;;;;GAIG;AACH,MAAM,MAAM,IAAI,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,MAAM;IACtB;;OAEG;IACH,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC;IACnB,gFAAgF;IAChF,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC;IACrC,iEAAiE;IACjE,IAAI,EAAE,IAAI,CAAC;IACX,+EAA+E;IAC/E,KAAK,EAAE,KAAK,CAAC;CACb;AAED;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACvB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAE5C;AAiBD;;;;GAIG;AACH,qBAAa,QAAQ;;IAG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IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CAWnB;AA+MD;;;;;;GAMG;AACH,qBAAa,QAAQ;;IAGpB,OAAO,eAEN;IAMD,2FAA2F;IAE3F,IAAI,MAAM,IAAI,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,CAErC;IAED;;;;;;;;OAQG;IACH,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,CAE5B;IAED,2DAA2D;IACpD,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,CAMtE;IAED,8FAA8F;IACxF,IAAI,IAAI,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CASvC;IAED;;;OAGG;IACH,KAAK,SAEJ;CACD"}
package/announced.js CHANGED
@@ -1,18 +1,29 @@
1
- /* @ts-self-types="./announced.d.ts" */
2
1
  /**
3
2
  * Broadcast announcement streams: which broadcast paths are available under a scope.
4
3
  *
5
4
  * @module
6
5
  */
7
6
  import { Once, Signal } from "@moq/signals";
8
- /** Whether a route covers the path after an update of this {@link Kind}. */
9
- export function isActive(kind) {
10
- return kind !== "retracted";
11
- }
7
+ import { routeInfo } from "./hop.js";
12
8
  /** Reactive backing state shared by announcement producers and consumers. */
13
9
  class AnnounceState {
14
10
  queue = new Signal([]);
15
11
  closed = new Once();
12
+ synced = new Signal(false);
13
+ // The queued events still to read before the stream counts as synced, or undefined
14
+ // while the initial set is still arriving.
15
+ owed;
16
+ // A reader holds the last event it took before syncing until it asks for the next
17
+ // one, so whatever it does with that event lands before synced flips.
18
+ reading = false;
19
+ // Open consumer handles; the stream is wanted while any is.
20
+ consumers = 0;
21
+ wanted = new Signal(false);
22
+ }
23
+ // Synced once nothing is owed and the reader has come back for more.
24
+ function settle(state) {
25
+ if (state.owed === 0 && !state.reading)
26
+ state.synced.set(true);
16
27
  }
17
28
  // Once.set throws on a second settle, and both ends of a stream can close independently.
18
29
  function closeState(state, abort) {
@@ -22,11 +33,15 @@ function closeState(state, abort) {
22
33
  state.queue.mutate((queue) => {
23
34
  queue.length = 0;
24
35
  });
36
+ // Nothing more is coming, so nothing waiting on the boundary should hang.
37
+ state.owed = 0;
38
+ state.reading = false;
39
+ state.synced.set(true);
25
40
  }
26
41
  /**
27
- * The write side of an announcement stream.
42
+ * The write side of a route stream.
28
43
  *
29
- * @public
44
+ * @internal
30
45
  */
31
46
  export class Producer {
32
47
  #state = new AnnounceState();
@@ -39,70 +54,206 @@ export class Producer {
39
54
  }
40
55
  /** A read handle for this announcement stream. */
41
56
  consume() {
42
- return makeConsumer(this.#state);
57
+ return makeRoutes(this.#state);
58
+ }
59
+ /**
60
+ * Whether any consumer still holds the stream: false before the first {@link consume} and
61
+ * once the last one {@link Routes.close}s, which is how a reader cancels it.
62
+ */
63
+ get wanted() {
64
+ return this.#state.wanted;
43
65
  }
44
- /** Writes an announcement to the queue. */
45
- append(update) {
66
+ /** Writes an event to the queue. */
67
+ append(event) {
46
68
  if (this.#state.closed.peek() !== undefined)
47
69
  throw new Error("announcements are closed");
48
70
  this.#state.queue.mutate((queue) => {
49
- queue.push(update);
71
+ queue.push(event);
50
72
  });
51
73
  }
74
+ /**
75
+ * Marks the initial set as delivered: the stream syncs once the reader has taken
76
+ * everything queued so far. A no-op until {@link behind} once marked.
77
+ *
78
+ * @internal
79
+ */
80
+ synced() {
81
+ const state = this.#state;
82
+ if (state.owed !== undefined)
83
+ return;
84
+ state.owed = state.queue.peek().length;
85
+ settle(state);
86
+ }
87
+ /**
88
+ * Takes sync back until the next {@link synced}, as when another initial set starts.
89
+ *
90
+ * @internal
91
+ */
92
+ behind() {
93
+ const state = this.#state;
94
+ if (state.closed.peek() !== undefined)
95
+ return;
96
+ state.owed = undefined;
97
+ state.synced.set(false);
98
+ }
52
99
  /** Closes the writer. Idempotent. */
53
100
  close(abort) {
54
101
  closeState(this.#state, abort);
55
102
  }
56
103
  }
57
- // Constructs a Consumer from within this module without exposing a public constructor
104
+ // Constructs a Routes from within this module without exposing a public constructor
58
105
  // that would leak the unexported AnnounceState. Assigned in the class's static block.
59
- let makeConsumer;
106
+ let makeRoutes;
60
107
  /**
61
- * The read side of an announcement stream.
62
- *
63
- * Created internally: obtain one from {@link Producer.consume} or the connection's
64
- * `announced(scope)`.
108
+ * The read side of a route stream: every change, for code that forwards or routes them.
65
109
  *
66
- * @public
110
+ * @internal
67
111
  */
68
- export class Consumer {
112
+ export class Routes {
69
113
  #state;
114
+ // Set once this handle closes, ending its own reads and guarding the consumer count.
115
+ #released = new Signal(false);
70
116
  constructor(state) {
71
117
  this.#state = state;
118
+ state.consumers++;
119
+ state.wanted.set(true);
72
120
  }
73
- /** Settles once the stream closes; see {@link Producer.closed}. */
121
+ /** Settles once the stream closes: `null` on a clean close, or the abort {@link Error}. */
74
122
  get closed() {
75
123
  return this.#state.closed;
76
124
  }
77
125
  static {
78
- makeConsumer = (state) => new Consumer(state);
126
+ makeRoutes = (state) => new Routes(state);
127
+ }
128
+ /**
129
+ * Whether the stream has delivered its source's initial announcements and the reader has
130
+ * taken them, so a prefix not announced by now is absent rather than not yet heard of.
131
+ *
132
+ * Flips once the reader asks for the event after the last of them, and is true once
133
+ * closed. Through a session, the initial set is the peer's view when it answered: exact
134
+ * on versions that count it, best-effort on the rest. Reading an origin, it is every
135
+ * attached session's initial set, so a reconnect takes it back until the new one lands.
136
+ */
137
+ get synced() {
138
+ return this.#state.synced;
79
139
  }
80
- /** The announcements as they arrive, until the stream closes. */
140
+ /** The events as they arrive, until the stream closes. */
81
141
  async *[Symbol.asyncIterator]() {
82
142
  for (;;) {
83
- const update = await this.next();
84
- if (!update)
143
+ const event = await this.next();
144
+ if (!event)
85
145
  return;
86
- yield update;
146
+ yield event;
87
147
  }
88
148
  }
89
- /** Returns the next announcement. */
149
+ /** Returns the next event, or undefined once the stream or this handle closes. */
90
150
  async next() {
151
+ const state = this.#state;
152
+ state.reading = false;
153
+ settle(state);
91
154
  for (;;) {
92
- const announce = this.#state.queue.peek().shift();
93
- if (announce)
155
+ if (this.#released.peek())
156
+ return undefined;
157
+ const announce = state.queue.peek().shift();
158
+ if (announce) {
159
+ if (state.owed)
160
+ state.owed -= 1;
161
+ if (!state.synced.peek())
162
+ state.reading = true;
94
163
  return announce;
164
+ }
95
165
  const closed = this.#state.closed.peek();
96
166
  if (closed instanceof Error)
97
167
  throw closed;
98
168
  if (closed !== undefined)
99
169
  return undefined;
100
- await Signal.race(this.#state.queue, this.#state.closed);
170
+ await Signal.race(state.queue, state.closed, this.#released);
101
171
  }
102
172
  }
103
- /** Closes the reader. Idempotent. */
104
- close(abort) {
105
- closeState(this.#state, abort);
173
+ /**
174
+ * Release this handle, like dropping a Rust handle: other consumers keep reading, and the
175
+ * producer sees the stream as no longer wanted once the last one closes.
176
+ * Idempotent.
177
+ */
178
+ close() {
179
+ if (this.#released.peek())
180
+ return;
181
+ this.#released.set(true);
182
+ if (--this.#state.consumers === 0)
183
+ this.#state.wanted.set(false);
106
184
  }
107
185
  }
186
+ // Constructs a listing over a route stream without a public constructor. Declared before the
187
+ // class, whose static block assigns it.
188
+ let makeConsumer;
189
+ /**
190
+ * The paths announced under a scope, each reported as it becomes present or absent.
191
+ *
192
+ * Created internally: obtain one from an origin or the connection's `announced(scope)`.
193
+ *
194
+ * @public
195
+ */
196
+ export class Consumer {
197
+ #routes;
198
+ constructor(routes) {
199
+ this.#routes = routes;
200
+ }
201
+ static {
202
+ makeConsumer = (routes) => new Consumer(routes);
203
+ }
204
+ /** Settles once the stream closes: `null` on a clean close, or the abort {@link Error}. */
205
+ // fallow-ignore-next-line unused-class-member
206
+ get closed() {
207
+ return this.#routes.closed;
208
+ }
209
+ /**
210
+ * Whether the listing has delivered its source's initial announcements and the reader has
211
+ * taken them, so a path not present by now is absent rather than not yet heard of.
212
+ *
213
+ * Flips once the reader asks for the event after the last of them, and is true once
214
+ * closed. Through a session, the initial set is the peer's view when it answered: exact
215
+ * on versions that count it, best-effort on the rest. Reading an origin, it is every
216
+ * attached session's initial set, so a reconnect takes it back until the new one lands.
217
+ */
218
+ get synced() {
219
+ return this.#routes.synced;
220
+ }
221
+ /** The events as they arrive, until the listing closes. */
222
+ async *[Symbol.asyncIterator]() {
223
+ for (;;) {
224
+ const event = await this.next();
225
+ if (!event)
226
+ return;
227
+ yield event;
228
+ }
229
+ }
230
+ /** Returns the next change to a path, or undefined once the listing or this handle closes. */
231
+ async next() {
232
+ for (;;) {
233
+ const event = await this.#routes.next();
234
+ if (!event)
235
+ return undefined;
236
+ const { kind, prefix } = event;
237
+ if (kind === "update" || kind === "restart")
238
+ continue;
239
+ const route = routeInfo(event.route);
240
+ return { kind: kind === "start" ? "present" : "absent", prefix, route };
241
+ }
242
+ }
243
+ /**
244
+ * Release this handle, like dropping a Rust handle: the source sees the listing as no
245
+ * longer wanted. Idempotent.
246
+ */
247
+ close() {
248
+ this.#routes.close();
249
+ }
250
+ }
251
+ /**
252
+ * The listing over a route stream: only paths becoming present or absent.
253
+ *
254
+ * @internal
255
+ */
256
+ export function list(routes) {
257
+ return makeConsumer(routes);
258
+ }
108
259
  //# sourceMappingURL=announced.js.map
package/announced.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"announced.js","sourceRoot":"","sources":["../src/announced.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAmB,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAkD7D,4EAA4E;AAC5E,MAAM,UAAU,QAAQ,CAAC,IAAU;IAClC,OAAO,IAAI,KAAK,WAAW,CAAC;AAC7B,CAAC;AAED,6EAA6E;AAC7E,MAAM,aAAa;IAClB,KAAK,GAAG,IAAI,MAAM,CAAW,EAAE,CAAC,CAAC;IACjC,MAAM,GAAG,IAAI,IAAI,EAAgB,CAAC;CAClC;AAED,yFAAyF;AACzF,SAAS,UAAU,CAAC,KAAoB,EAAE,KAAa;IACtD,IAAI,KAAK,CAAC,MAAM,CA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C3B,CAAC;IAED;QACC,YAAY,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED,iEAAiE;IACjE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QAC5B,SAAS,CAAC;YACT,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM;gBAAE,OAAO;YACpB,MAAM,MAAM,CAAC;QACd,CAAC;IACF,CAAC;IAED,qCAAqC;IACrC,KAAK,CAAC,IAAI;QACT,SAAS,CAAC;YACT,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;YAClD,IAAI,QAAQ;gBAAE,OAAO,QAAQ,CAAC;YAE9B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACzC,IAAI,MAAM,YAAY,KAAK;gBAAE,MAAM,MAAM,CAAC;YAC1C,IAAI,MAAM,KAAK,SAAS;gBAAE,OAAO,SAAS,CAAC;YAE3C,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1D,CAAC;IACF,CAAC;IAED,qCAAqC;IACrC,KAAK,CAAC,KAAa;QAClB,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;CACD","sourcesContent":["/**\n * Broadcast announcement streams: which broadcast paths are available under a scope.\n *\n * @module\n */\nimport { type GetPromise, Once, Signal } from \"@moq/signals\";\nimport type { Route } from \"./hop.js\";\nimport type * as Path from \"./path.js\";\n\n/**\n * What an {@link Update} reports about its prefix.\n *\n * @public\n */\nexport type Kind = \"announced\" | \"updated\" | \"retracted\";\n\n/**\n * A route announcement, update, or retraction.\n *\n * An announcement is always a prefix, never a broadcast: a route claims that\n * {@link prefix} and every path beneath it can be served. By convention a publisher\n * announces each broadcast's exact path, so enumerating routes enumerates broadcasts;\n * resolve one with the origin's `request(path)`. Narrow with a {@link Path.Pattern}\n * locally to follow a subset.\n *\n * @public\n */\nexport interface Update {\n\t/**\n\t * The prefix the route covers, relative to the origin (for a session, its URL path).\n\t */\n\tprefix: Path.Valid;\n\t/** What the filter's wildcards stood for, when this prefix pins all of them. */\n\tcaptures: Path.Pattern[] | undefined;\n\t/** Whether the prefix was announced, re-priced, or retracted. */\n\tkind: Kind;\n\t/** Hops and cost of the route; on a retraction, its last advertised values. */\n\troute: Route;\n}\n\n/**\n * Options for an announcement stream.\n *\n * @public\n */\nexport interface Options {\n\t/**\n\t * Also report hidden routes: those with a path segment starting with `.` below the\n\t * scope's literal head. Hidden routes are left out by default, so a platform can add\n\t * `.`-named broadcasts (stats, internal routes) without them turning up in apps that\n\t * list everything. Subscribing to a hidden path by name works either way.\n\t */\n\thidden?: boolean;\n}\n\n/** Whether a route covers the path after an update of this {@link Kind}. */\nexport function isActive(kind: Kind): boolean {\n\treturn kind !== \"retracted\";\n}\n\n/** Reactive backing state shared by announcement producers and consumers. */\nclass AnnounceState {\n\tqueue = new Signal<Update[]>([]);\n\tclosed = new Once<Error | null>();\n}\n\n// Once.set throws on a second settle, and both ends of a stream can close independently.\nfunction closeState(state: AnnounceState, abort?: Error) {\n\tif (state.closed.peek() !== undefined) return;\n\tstate.closed.set(abort ?? null);\n\tstate.queue.mutate((queue) => {\n\t\tqueue.length = 0;\n\t});\n}\n\n/**\n * The write side of an announcement stream.\n *\n * @public\n */\nexport class Producer {\n\t#state = new AnnounceState();\n\n\t/**\n\t * Settles once the stream closes: `null` on a clean close, or the abort {@link Error}.\n\t * Peek it synchronously (`undefined` while open), observe it reactively, or `await` it.\n\t */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/** A read handle for this announcement stream. */\n\tconsume(): Consumer {\n\t\treturn makeConsumer(this.#state);\n\t}\n\n\t/** Writes an announcement to the queue. */\n\tappend(update: Update) {\n\t\tif (this.#state.closed.peek() !== undefined) throw new Error(\"announcements are closed\");\n\t\tthis.#state.queue.mutate((queue) => {\n\t\t\tqueue.push(update);\n\t\t});\n\t}\n\n\t/** Closes the writer. Idempotent. */\n\tclose(abort?: Error) {\n\t\tcloseState(this.#state, abort);\n\t}\n}\n\n// Constructs a Consumer from within this module without exposing a public constructor\n// that would leak the unexported AnnounceState. Assigned in the class's static block.\nlet makeConsumer: (state: AnnounceState) => Consumer;\n\n/**\n * The read side of an announcement stream.\n *\n * Created internally: obtain one from {@link Producer.consume} or the connection's\n * `announced(scope)`.\n *\n * @public\n */\nexport class Consumer {\n\t#state: AnnounceState;\n\n\tprivate constructor(state: AnnounceState) {\n\t\tthis.#state = state;\n\t}\n\n\t/** Settles once the stream closes; see {@link Producer.closed}. */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\tstatic {\n\t\tmakeConsumer = (state) => new Consumer(state);\n\t}\n\n\t/** The announcements as they arrive, until the stream closes. */\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<Update, void, undefined> {\n\t\tfor (;;) {\n\t\t\tconst update = await this.next();\n\t\t\tif (!update) return;\n\t\t\tyield update;\n\t\t}\n\t}\n\n\t/** Returns the next announcement. */\n\tasync next(): Promise<Update | undefined> {\n\t\tfor (;;) {\n\t\t\tconst announce = this.#state.queue.peek().shift();\n\t\t\tif (announce) return announce;\n\n\t\t\tconst closed = this.#state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\tif (closed !== undefined) return undefined;\n\n\t\t\tawait Signal.race(this.#state.queue, this.#state.closed);\n\t\t}\n\t}\n\n\t/** Closes the reader. Idempotent. */\n\tclose(abort?: Error) {\n\t\tcloseState(this.#state, abort);\n\t}\n}\n"]}
1
+ {"version":3,"file":"announced.js","sourceRoot":"","sources":["../src/announced.ts"],"names":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F;IAC3F,8CAA8C;IAC9C,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;;;;;;;OAQG;IACH,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,2DAA2D;IAC3D,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QAC5B,SAAS,CAAC;YACT,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YAChC,IAAI,CAAC,KAAK;gBAAE,OAAO;YACnB,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;IAED,8FAA8F;IAC9F,KAAK,CAAC,IAAI;QACT,SAAS,CAAC;YACT,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACxC,IAAI,CAAC,KAAK;gBAAE,OAAO,SAAS,CAAC;YAC7B,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;YAC/B,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS;gBAAE,SAAS;YACtD,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrC,OAAO,EAAE,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QACzE,CAAC;IACF,CAAC;IAED;;;OAGG;IACH,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,MAAc;IAClC,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["/**\n * Broadcast announcement streams: which broadcast paths are available under a scope.\n *\n * @module\n */\nimport { type GetPromise, type Getter, Once, Signal } from \"@moq/signals\";\nimport { type RouteInfo, routeInfo, type WireRoute } from \"./hop.ts\";\nimport type * as Path from \"./path.js\";\n\n/**\n * A route over a prefix, delivered inside an {@link Event}.\n *\n * An announcement is always a prefix, never a broadcast: a route claims that\n * {@link prefix} and every path beneath it can be served. By convention a publisher\n * announces each broadcast's exact path, so enumerating routes enumerates broadcasts;\n * resolve one with the origin's `request(path)`. List a narrower prefix, or filter the\n * announced paths locally, to follow a subset.\n *\n * @public\n */\nexport interface Announce {\n\t/**\n\t * The prefix the route covers, relative to the origin (for a session, its URL path).\n\t */\n\tprefix: Path.Valid;\n\t/** Hops and cost of the route; on a retraction, its last advertised values. */\n\troute: RouteInfo;\n}\n\n/**\n * An {@link Announce} as the origin and sessions carry it, with the route's internal metadata.\n *\n * @internal\n */\nexport type Routed = Omit<Announce, \"route\"> & { route: WireRoute };\n\n/**\n * What an announcement listing yields: a path becoming present or absent.\n *\n * `present`: a route now covers the path, which was absent; it may arrive unavailable (see\n * {@link RouteInfo.available}). `absent`: no route covers the path any more, whether its origin\n * withdrew it or this side let go of it; carries its last advertised route.\n *\n * Another identity taking a path over keeps it present, and a change in availability is not\n * reported: follow it with the origin's `follow(path)` to see the broadcast change.\n *\n * @public\n */\nexport type Event = { kind: \"present\" | \"absent\" } & Announce;\n\n/**\n * Every change to a route, for code that forwards or routes them.\n *\n * `start`: a route now covers the prefix. `update`: the route covering it changed hops, cost,\n * or availability, in place. `restart`: another identity now serves the prefix. `end`: the\n * origin withdrew it, and no route covers it any more. `offline`: this side let go of it,\n * and no route covers it any more.\n *\n * @internal\n */\nexport type RouteEvent = { kind: \"start\" | \"update\" | \"restart\" | \"end\" | \"offline\" } & Routed;\n\n/**\n * Options for an announcement stream.\n *\n * @public\n */\nexport interface Options {\n\t/**\n\t * Also report hidden routes: those with a path segment starting with `.` below the\n\t * listed prefix. Hidden routes are left out by default, so a platform can add\n\t * `.`-named broadcasts (stats, internal routes) without them turning up in apps that\n\t * list everything. Subscribing to a hidden path by name works either way.\n\t */\n\thidden?: boolean;\n\n\t/**\n\t * Also report every route that could serve a path in scope, not just those at or beneath\n\t * the listed prefix. A route is a prefix serving everything beneath it, so listing\n\t * `room/lobby` still reports a route at `room`, which can serve it. A broadcast serves only\n\t * its own path, yet is reported too, since it shadows broader routes beneath it, as in Rust. Code that routes or forwards needs these;\n\t * listing broadcasts does not. Requests resolve through covering routes either way.\n\t */\n\tcovering?: boolean;\n\n\t/**\n\t * Report only the routes that could serve the listed prefix itself, those at or above it,\n\t * and none beneath it; synced once no session owes an initial set at or above it. Implies\n\t * `covering`. For code asking whether a path is reachable, as a request resolves it, not\n\t * what lies beneath it.\n\t *\n\t * @internal\n\t */\n\texact?: boolean;\n}\n\n/**\n * Options for a route stream, which forwarding code reads.\n *\n * @internal\n */\nexport interface RouteOptions extends Options {\n\t/**\n\t * Report each origin node's claim at a path as its own route, rather than only the one the\n\t * session ranks best, so the origin it feeds ranks every candidate as rs/moq-net's does. Only\n\t * lite-07 carries more than one route per path on a stream.\n\t */\n\tclaims?: boolean;\n}\n\n/** Reactive backing state shared by announcement producers and consumers. */\nclass AnnounceState {\n\tqueue = new Signal<RouteEvent[]>([]);\n\tclosed = new Once<Error | null>();\n\tsynced = new Signal(false);\n\t// The queued events still to read before the stream counts as synced, or undefined\n\t// while the initial set is still arriving.\n\towed: number | undefined;\n\t// A reader holds the last event it took before syncing until it asks for the next\n\t// one, so whatever it does with that event lands before synced flips.\n\treading = false;\n\t// Open consumer handles; the stream is wanted while any is.\n\tconsumers = 0;\n\twanted = new Signal(false);\n}\n\n// Synced once nothing is owed and the reader has come back for more.\nfunction settle(state: AnnounceState) {\n\tif (state.owed === 0 && !state.reading) state.synced.set(true);\n}\n\n// Once.set throws on a second settle, and both ends of a stream can close independently.\nfunction closeState(state: AnnounceState, abort?: Error) {\n\tif (state.closed.peek() !== undefined) return;\n\tstate.closed.set(abort ?? null);\n\tstate.queue.mutate((queue) => {\n\t\tqueue.length = 0;\n\t});\n\t// Nothing more is coming, so nothing waiting on the boundary should hang.\n\tstate.owed = 0;\n\tstate.reading = false;\n\tstate.synced.set(true);\n}\n\n/**\n * The write side of a route stream.\n *\n * @internal\n */\nexport class Producer {\n\t#state = new AnnounceState();\n\n\t/**\n\t * Settles once the stream closes: `null` on a clean close, or the abort {@link Error}.\n\t * Peek it synchronously (`undefined` while open), observe it reactively, or `await` it.\n\t */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\t/** A read handle for this announcement stream. */\n\tconsume(): Routes {\n\t\treturn makeRoutes(this.#state);\n\t}\n\n\t/**\n\t * Whether any consumer still holds the stream: false before the first {@link consume} and\n\t * once the last one {@link Routes.close}s, which is how a reader cancels it.\n\t */\n\tget wanted(): Getter<boolean> {\n\t\treturn this.#state.wanted;\n\t}\n\n\t/** Writes an event to the queue. */\n\tappend(event: RouteEvent) {\n\t\tif (this.#state.closed.peek() !== undefined) throw new Error(\"announcements are closed\");\n\t\tthis.#state.queue.mutate((queue) => {\n\t\t\tqueue.push(event);\n\t\t});\n\t}\n\n\t/**\n\t * Marks the initial set as delivered: the stream syncs once the reader has taken\n\t * everything queued so far. A no-op until {@link behind} once marked.\n\t *\n\t * @internal\n\t */\n\tsynced() {\n\t\tconst state = this.#state;\n\t\tif (state.owed !== undefined) return;\n\t\tstate.owed = state.queue.peek().length;\n\t\tsettle(state);\n\t}\n\n\t/**\n\t * Takes sync back until the next {@link synced}, as when another initial set starts.\n\t *\n\t * @internal\n\t */\n\tbehind() {\n\t\tconst state = this.#state;\n\t\tif (state.closed.peek() !== undefined) return;\n\t\tstate.owed = undefined;\n\t\tstate.synced.set(false);\n\t}\n\n\t/** Closes the writer. Idempotent. */\n\tclose(abort?: Error) {\n\t\tcloseState(this.#state, abort);\n\t}\n}\n\n// Constructs a Routes from within this module without exposing a public constructor\n// that would leak the unexported AnnounceState. Assigned in the class's static block.\nlet makeRoutes: (state: AnnounceState) => Routes;\n\n/**\n * The read side of a route stream: every change, for code that forwards or routes them.\n *\n * @internal\n */\nexport class Routes {\n\t#state: AnnounceState;\n\t// Set once this handle closes, ending its own reads and guarding the consumer count.\n\t#released = new Signal(false);\n\n\tprivate constructor(state: AnnounceState) {\n\t\tthis.#state = state;\n\t\tstate.consumers++;\n\t\tstate.wanted.set(true);\n\t}\n\n\t/** Settles once the stream closes: `null` on a clean close, or the abort {@link Error}. */\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#state.closed;\n\t}\n\n\tstatic {\n\t\tmakeRoutes = (state) => new Routes(state);\n\t}\n\n\t/**\n\t * Whether the stream has delivered its source's initial announcements and the reader has\n\t * taken them, so a prefix not announced by now is absent rather than not yet heard of.\n\t *\n\t * Flips once the reader asks for the event after the last of them, and is true once\n\t * closed. Through a session, the initial set is the peer's view when it answered: exact\n\t * on versions that count it, best-effort on the rest. Reading an origin, it is every\n\t * attached session's initial set, so a reconnect takes it back until the new one lands.\n\t */\n\tget synced(): Getter<boolean> {\n\t\treturn this.#state.synced;\n\t}\n\n\t/** The events as they arrive, until the stream closes. */\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<RouteEvent, void, undefined> {\n\t\tfor (;;) {\n\t\t\tconst event = await this.next();\n\t\t\tif (!event) return;\n\t\t\tyield event;\n\t\t}\n\t}\n\n\t/** Returns the next event, or undefined once the stream or this handle closes. */\n\tasync next(): Promise<RouteEvent | undefined> {\n\t\tconst state = this.#state;\n\t\tstate.reading = false;\n\t\tsettle(state);\n\t\tfor (;;) {\n\t\t\tif (this.#released.peek()) return undefined;\n\t\t\tconst announce = state.queue.peek().shift();\n\t\t\tif (announce) {\n\t\t\t\tif (state.owed) state.owed -= 1;\n\t\t\t\tif (!state.synced.peek()) state.reading = true;\n\t\t\t\treturn announce;\n\t\t\t}\n\n\t\t\tconst closed = this.#state.closed.peek();\n\t\t\tif (closed instanceof Error) throw closed;\n\t\t\tif (closed !== undefined) return undefined;\n\n\t\t\tawait Signal.race(state.queue, state.closed, this.#released);\n\t\t}\n\t}\n\n\t/**\n\t * Release this handle, like dropping a Rust handle: other consumers keep reading, and the\n\t * producer sees the stream as no longer wanted once the last one closes.\n\t * Idempotent.\n\t */\n\tclose() {\n\t\tif (this.#released.peek()) return;\n\t\tthis.#released.set(true);\n\t\tif (--this.#state.consumers === 0) this.#state.wanted.set(false);\n\t}\n}\n\n// Constructs a listing over a route stream without a public constructor. Declared before the\n// class, whose static block assigns it.\nlet makeConsumer: (routes: Routes) => Consumer;\n\n/**\n * The paths announced under a scope, each reported as it becomes present or absent.\n *\n * Created internally: obtain one from an origin or the connection's `announced(scope)`.\n *\n * @public\n */\nexport class Consumer {\n\t#routes: Routes;\n\n\tprivate constructor(routes: Routes) {\n\t\tthis.#routes = routes;\n\t}\n\n\tstatic {\n\t\tmakeConsumer = (routes) => new Consumer(routes);\n\t}\n\n\t/** Settles once the stream closes: `null` on a clean close, or the abort {@link Error}. */\n\t// fallow-ignore-next-line unused-class-member\n\tget closed(): GetPromise<Error | null> {\n\t\treturn this.#routes.closed;\n\t}\n\n\t/**\n\t * Whether the listing has delivered its source's initial announcements and the reader has\n\t * taken them, so a path not present by now is absent rather than not yet heard of.\n\t *\n\t * Flips once the reader asks for the event after the last of them, and is true once\n\t * closed. Through a session, the initial set is the peer's view when it answered: exact\n\t * on versions that count it, best-effort on the rest. Reading an origin, it is every\n\t * attached session's initial set, so a reconnect takes it back until the new one lands.\n\t */\n\tget synced(): Getter<boolean> {\n\t\treturn this.#routes.synced;\n\t}\n\n\t/** The events as they arrive, until the listing closes. */\n\tasync *[Symbol.asyncIterator](): AsyncGenerator<Event, void, undefined> {\n\t\tfor (;;) {\n\t\t\tconst event = await this.next();\n\t\t\tif (!event) return;\n\t\t\tyield event;\n\t\t}\n\t}\n\n\t/** Returns the next change to a path, or undefined once the listing or this handle closes. */\n\tasync next(): Promise<Event | undefined> {\n\t\tfor (;;) {\n\t\t\tconst event = await this.#routes.next();\n\t\t\tif (!event) return undefined;\n\t\t\tconst { kind, prefix } = event;\n\t\t\tif (kind === \"update\" || kind === \"restart\") continue;\n\t\t\tconst route = routeInfo(event.route);\n\t\t\treturn { kind: kind === \"start\" ? \"present\" : \"absent\", prefix, route };\n\t\t}\n\t}\n\n\t/**\n\t * Release this handle, like dropping a Rust handle: the source sees the listing as no\n\t * longer wanted. Idempotent.\n\t */\n\tclose() {\n\t\tthis.#routes.close();\n\t}\n}\n\n/**\n * The listing over a route stream: only paths becoming present or absent.\n *\n * @internal\n */\nexport function list(routes: Routes): Consumer {\n\treturn makeConsumer(routes);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=announced.test-util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"announced.test-util.d.ts","sourceRoot":"","sources":["../src/announced.test-util.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import { Signal } from "@moq/signals";
2
+ /** A closeable announcement snapshot for tests and benchmarks. @internal */
3
+ export async function announcedView(origin, prefix, options) {
4
+ const stream = origin.routes(prefix, options);
5
+ const value = new Signal(new Map());
6
+ const done = (async () => {
7
+ for await (const event of stream)
8
+ value.update((previous) => {
9
+ const next = new Map(previous);
10
+ if (event.kind === "end" || event.kind === "offline")
11
+ next.delete(event.prefix);
12
+ else
13
+ next.set(event.prefix, event.route);
14
+ return next;
15
+ });
16
+ })();
17
+ await new Promise((resolve) => setImmediate(resolve));
18
+ return {
19
+ peek: () => value.peek(),
20
+ subscribe: value.subscribe.bind(value),
21
+ close: async () => {
22
+ stream.close();
23
+ await done;
24
+ },
25
+ };
26
+ }
27
+ //# sourceMappingURL=announced.test-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"announced.test-util.js","sourceRoot":"","sources":["../src/announced.test-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtC,4EAA4E;AAC5E,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,MAAkE,EAClE,MAAmB,EACnB,OAAiB;IAEjB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAI,MAAM,CAAqC,IAAI,GAAG,EAAE,CAAC,CAAC;IACxE,MAAM,IAAI,GAAG,CAAC,KAAK,IAAI,EAAE;QACxB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM;YAC/B,KAAK,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACzB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAC/B,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;oBAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;;oBAC3E,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;gBACzC,OAAO,IAAI,CAAC;YACb,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,EAAE,CAAC;IACL,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5D,OAAO;QACN,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE;QACxB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;QACtC,KAAK,EAAE,KAAK,IAAI,EAAE;YACjB,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,CAAC;QACZ,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { Signal } from \"@moq/signals\";\nimport type { Options, Routes } from \"./announced\";\nimport type { WireRoute } from \"./hop\";\nimport type * as Path from \"./path\";\n\n/** A closeable announcement snapshot for tests and benchmarks. @internal */\nexport async function announcedView(\n\torigin: { routes(prefix?: Path.Valid, options?: Options): Routes },\n\tprefix?: Path.Valid,\n\toptions?: Options,\n) {\n\tconst stream = origin.routes(prefix, options);\n\tconst value = new Signal<ReadonlyMap<Path.Valid, WireRoute>>(new Map());\n\tconst done = (async () => {\n\t\tfor await (const event of stream)\n\t\t\tvalue.update((previous) => {\n\t\t\t\tconst next = new Map(previous);\n\t\t\t\tif (event.kind === \"end\" || event.kind === \"offline\") next.delete(event.prefix);\n\t\t\t\telse next.set(event.prefix, event.route);\n\t\t\t\treturn next;\n\t\t\t});\n\t})();\n\tawait new Promise<void>((resolve) => setImmediate(resolve));\n\treturn {\n\t\tpeek: () => value.peek(),\n\t\tsubscribe: value.subscribe.bind(value),\n\t\tclose: async () => {\n\t\t\tstream.close();\n\t\t\tawait done;\n\t\t},\n\t};\n}\n"]}