@moq/net 0.4.8 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (662) hide show
  1. package/README.md +7 -1
  2. package/announce.d.ts +1 -1
  3. package/announce.d.ts.map +1 -1
  4. package/announce.js +1 -1
  5. package/announce.js.map +1 -1
  6. package/announced.d.ts +51 -47
  7. package/announced.d.ts.map +1 -1
  8. package/announced.js +183 -31
  9. package/announced.js.map +1 -1
  10. package/announced.test-util.d.ts +2 -0
  11. package/announced.test-util.d.ts.map +1 -0
  12. package/announced.test-util.js +27 -0
  13. package/announced.test-util.js.map +1 -0
  14. package/auth.d.ts +64 -0
  15. package/auth.d.ts.map +1 -0
  16. package/auth.js +20 -0
  17. package/auth.js.map +1 -0
  18. package/auth_gate.d.ts +2 -0
  19. package/auth_gate.d.ts.map +1 -0
  20. package/auth_gate.js +24 -0
  21. package/auth_gate.js.map +1 -0
  22. package/auth_session.d.ts +49 -0
  23. package/auth_session.d.ts.map +1 -0
  24. package/auth_session.js +1097 -0
  25. package/auth_session.js.map +1 -0
  26. package/bandwidth.d.ts +129 -25
  27. package/bandwidth.d.ts.map +1 -1
  28. package/bandwidth.js +410 -138
  29. package/bandwidth.js.map +1 -1
  30. package/bandwidth_api.d.ts +1 -1
  31. package/bandwidth_api.d.ts.map +1 -1
  32. package/bandwidth_api.js +1 -1
  33. package/bandwidth_api.js.map +1 -1
  34. package/broadcast.d.ts +62 -36
  35. package/broadcast.d.ts.map +1 -1
  36. package/broadcast.js +556 -172
  37. package/broadcast.js.map +1 -1
  38. package/cache.d.ts +103 -0
  39. package/cache.d.ts.map +1 -0
  40. package/cache.js +254 -0
  41. package/cache.js.map +1 -0
  42. package/claim.test-util.d.ts +5 -0
  43. package/claim.test-util.d.ts.map +1 -0
  44. package/claim.test-util.js +13 -0
  45. package/claim.test-util.js.map +1 -0
  46. package/connection/accept.d.ts +20 -12
  47. package/connection/accept.d.ts.map +1 -1
  48. package/connection/accept.js +97 -129
  49. package/connection/accept.js.map +1 -1
  50. package/connection/browser.d.ts.map +1 -1
  51. package/connection/browser.js +28 -19
  52. package/connection/browser.js.map +1 -1
  53. package/connection/connect.d.ts +119 -23
  54. package/connection/connect.d.ts.map +1 -1
  55. package/connection/connect.js +535 -216
  56. package/connection/connect.js.map +1 -1
  57. package/connection/dials.d.ts +45 -0
  58. package/connection/dials.d.ts.map +1 -0
  59. package/connection/dials.js +109 -0
  60. package/connection/dials.js.map +1 -0
  61. package/connection/endpoint.d.ts +60 -0
  62. package/connection/endpoint.d.ts.map +1 -0
  63. package/connection/endpoint.js +114 -0
  64. package/connection/endpoint.js.map +1 -0
  65. package/connection/forward.d.ts +7 -1
  66. package/connection/forward.d.ts.map +1 -1
  67. package/connection/forward.js +265 -80
  68. package/connection/forward.js.map +1 -1
  69. package/connection/goaway.d.ts +16 -9
  70. package/connection/goaway.d.ts.map +1 -1
  71. package/connection/goaway.js +22 -108
  72. package/connection/goaway.js.map +1 -1
  73. package/connection/handshake.d.ts +32 -6
  74. package/connection/handshake.d.ts.map +1 -1
  75. package/connection/handshake.js +97 -20
  76. package/connection/handshake.js.map +1 -1
  77. package/connection/index.d.ts +3 -6
  78. package/connection/index.d.ts.map +1 -1
  79. package/connection/index.js +1 -2
  80. package/connection/index.js.map +1 -1
  81. package/connection/liveness.d.ts +14 -0
  82. package/connection/liveness.d.ts.map +1 -0
  83. package/connection/liveness.js +30 -0
  84. package/connection/liveness.js.map +1 -0
  85. package/connection/pool.d.ts +137 -58
  86. package/connection/pool.d.ts.map +1 -1
  87. package/connection/pool.js +281 -117
  88. package/connection/pool.js.map +1 -1
  89. package/connection/reload.d.ts +60 -12
  90. package/connection/reload.d.ts.map +1 -1
  91. package/connection/reload.js +859 -233
  92. package/connection/reload.js.map +1 -1
  93. package/connection/session.d.ts +91 -0
  94. package/connection/session.d.ts.map +1 -0
  95. package/connection/session.js +2 -0
  96. package/connection/session.js.map +1 -0
  97. package/connection/stats.d.ts +20 -11
  98. package/connection/stats.d.ts.map +1 -1
  99. package/connection/stats.js +64 -8
  100. package/connection/stats.js.map +1 -1
  101. package/connection/ticker.d.ts +4 -0
  102. package/connection/ticker.d.ts.map +1 -0
  103. package/connection/ticker.js +66 -0
  104. package/connection/ticker.js.map +1 -0
  105. package/connection/tokens.d.ts +2 -0
  106. package/connection/tokens.d.ts.map +1 -0
  107. package/connection/tokens.js +404 -0
  108. package/connection/tokens.js.map +1 -0
  109. package/connection/transport.d.ts.map +1 -1
  110. package/connection/transport.js +4 -4
  111. package/connection/transport.js.map +1 -1
  112. package/connection/withdrawal.d.ts +2 -0
  113. package/connection/withdrawal.d.ts.map +1 -0
  114. package/connection/withdrawal.js +23 -0
  115. package/connection/withdrawal.js.map +1 -0
  116. package/consume.js +213 -46
  117. package/consume.js.map +1 -1
  118. package/cover.d.ts +59 -0
  119. package/cover.d.ts.map +1 -0
  120. package/cover.js +375 -0
  121. package/cover.js.map +1 -0
  122. package/datagram.d.ts +70 -11
  123. package/datagram.d.ts.map +1 -1
  124. package/datagram.js +317 -1
  125. package/datagram.js.map +1 -1
  126. package/datagram_stream.d.ts +18 -0
  127. package/datagram_stream.d.ts.map +1 -0
  128. package/datagram_stream.js +67 -0
  129. package/datagram_stream.js.map +1 -0
  130. package/defined.test-util.d.ts +2 -0
  131. package/defined.test-util.d.ts.map +1 -0
  132. package/defined.test-util.js +7 -0
  133. package/defined.test-util.js.map +1 -0
  134. package/delivered.d.ts +75 -0
  135. package/delivered.d.ts.map +1 -0
  136. package/delivered.js +228 -0
  137. package/delivered.js.map +1 -0
  138. package/demand.d.ts +173 -0
  139. package/demand.d.ts.map +1 -0
  140. package/demand.js +582 -0
  141. package/demand.js.map +1 -0
  142. package/drops.d.ts +93 -0
  143. package/drops.d.ts.map +1 -0
  144. package/drops.js +283 -0
  145. package/drops.js.map +1 -0
  146. package/error.d.ts +120 -21
  147. package/error.d.ts.map +1 -1
  148. package/error.js +230 -37
  149. package/error.js.map +1 -1
  150. package/errors.d.ts +2 -2
  151. package/errors.d.ts.map +1 -1
  152. package/errors.js +2 -2
  153. package/errors.js.map +1 -1
  154. package/fill.d.ts +174 -0
  155. package/fill.d.ts.map +1 -0
  156. package/fill.js +760 -0
  157. package/fill.js.map +1 -0
  158. package/flate/decoder.d.ts +2 -0
  159. package/flate/decoder.d.ts.map +1 -0
  160. package/flate/decoder.js +63 -0
  161. package/flate/decoder.js.map +1 -0
  162. package/flate/encoder.d.ts +2 -0
  163. package/flate/encoder.d.ts.map +1 -0
  164. package/flate/encoder.js +64 -0
  165. package/flate/encoder.js.map +1 -0
  166. package/flate/group.d.ts +34 -0
  167. package/flate/group.d.ts.map +1 -0
  168. package/flate/group.js +140 -0
  169. package/flate/group.js.map +1 -0
  170. package/frame.d.ts +80 -0
  171. package/frame.d.ts.map +1 -0
  172. package/frame.js +296 -0
  173. package/frame.js.map +1 -0
  174. package/frame.test-util.d.ts +5 -0
  175. package/frame.test-util.d.ts.map +1 -0
  176. package/frame.test-util.js +9 -0
  177. package/frame.test-util.js.map +1 -0
  178. package/group.d.ts +108 -45
  179. package/group.d.ts.map +1 -1
  180. package/group.js +1616 -307
  181. package/group.js.map +1 -1
  182. package/group_api.d.ts +7 -0
  183. package/group_api.d.ts.map +1 -0
  184. package/group_api.js +7 -0
  185. package/group_api.js.map +1 -0
  186. package/hop.d.ts +62 -76
  187. package/hop.d.ts.map +1 -1
  188. package/hop.js +92 -64
  189. package/hop.js.map +1 -1
  190. package/identity.d.ts +39 -0
  191. package/identity.d.ts.map +1 -0
  192. package/identity.js +47 -0
  193. package/identity.js.map +1 -0
  194. package/ietf/active_count.d.ts +2 -0
  195. package/ietf/active_count.d.ts.map +1 -0
  196. package/ietf/active_count.js +30 -0
  197. package/ietf/active_count.js.map +1 -0
  198. package/ietf/aliases.js +69 -35
  199. package/ietf/aliases.js.map +1 -1
  200. package/ietf/cluster.d.ts +3 -3
  201. package/ietf/cluster.js +14 -62
  202. package/ietf/cluster.js.map +1 -1
  203. package/ietf/connection.d.ts +1 -31
  204. package/ietf/connection.d.ts.map +1 -1
  205. package/ietf/connection.js +305 -143
  206. package/ietf/connection.js.map +1 -1
  207. package/ietf/datagram.d.ts +60 -0
  208. package/ietf/datagram.d.ts.map +1 -0
  209. package/ietf/datagram.js +152 -0
  210. package/ietf/datagram.js.map +1 -0
  211. package/ietf/error.d.ts +3 -3
  212. package/ietf/error.js +82 -100
  213. package/ietf/error.js.map +1 -1
  214. package/ietf/fetch.d.ts +91 -35
  215. package/ietf/fetch.d.ts.map +1 -1
  216. package/ietf/fetch.js +172 -93
  217. package/ietf/fetch.js.map +1 -1
  218. package/ietf/filter.d.ts +20 -30
  219. package/ietf/filter.d.ts.map +1 -1
  220. package/ietf/filter.js +140 -171
  221. package/ietf/filter.js.map +1 -1
  222. package/ietf/goaway.d.ts +11 -9
  223. package/ietf/goaway.d.ts.map +1 -1
  224. package/ietf/goaway.js +22 -35
  225. package/ietf/goaway.js.map +1 -1
  226. package/ietf/hidden.js +1 -1
  227. package/ietf/hidden.js.map +1 -1
  228. package/ietf/index.d.ts +2 -14
  229. package/ietf/index.d.ts.map +1 -1
  230. package/ietf/index.js +4 -14
  231. package/ietf/index.js.map +1 -1
  232. package/ietf/join.d.ts +7 -0
  233. package/ietf/join.d.ts.map +1 -0
  234. package/ietf/join.js +234 -0
  235. package/ietf/join.js.map +1 -0
  236. package/ietf/message.d.ts +18 -2
  237. package/ietf/message.d.ts.map +1 -1
  238. package/ietf/message.js +60 -40
  239. package/ietf/message.js.map +1 -1
  240. package/ietf/message.test-util.d.ts +6 -0
  241. package/ietf/message.test-util.d.ts.map +1 -0
  242. package/ietf/message.test-util.js +13 -0
  243. package/ietf/message.test-util.js.map +1 -0
  244. package/ietf/namespace.d.ts +17 -3
  245. package/ietf/namespace.d.ts.map +1 -1
  246. package/ietf/namespace.js +78 -26
  247. package/ietf/namespace.js.map +1 -1
  248. package/ietf/object.d.ts +194 -32
  249. package/ietf/object.d.ts.map +1 -1
  250. package/ietf/object.js +405 -178
  251. package/ietf/object.js.map +1 -1
  252. package/ietf/parameters.d.ts +22 -42
  253. package/ietf/parameters.d.ts.map +1 -1
  254. package/ietf/parameters.js +260 -472
  255. package/ietf/parameters.js.map +1 -1
  256. package/ietf/priority.d.ts +17 -2
  257. package/ietf/priority.d.ts.map +1 -1
  258. package/ietf/priority.js +19 -4
  259. package/ietf/priority.js.map +1 -1
  260. package/ietf/properties.d.ts +5 -4
  261. package/ietf/properties.d.ts.map +1 -1
  262. package/ietf/properties.js +78 -48
  263. package/ietf/properties.js.map +1 -1
  264. package/ietf/publish.d.ts +22 -30
  265. package/ietf/publish.d.ts.map +1 -1
  266. package/ietf/publish.js +45 -139
  267. package/ietf/publish.js.map +1 -1
  268. package/ietf/publish_namespace.d.ts +46 -69
  269. package/ietf/publish_namespace.d.ts.map +1 -1
  270. package/ietf/publish_namespace.js +66 -184
  271. package/ietf/publish_namespace.js.map +1 -1
  272. package/ietf/publisher.js +1800 -600
  273. package/ietf/publisher.js.map +1 -1
  274. package/ietf/range.d.ts +2 -0
  275. package/ietf/range.d.ts.map +1 -0
  276. package/ietf/range.js +222 -0
  277. package/ietf/range.js.map +1 -0
  278. package/ietf/request.d.ts +3 -27
  279. package/ietf/request.d.ts.map +1 -1
  280. package/ietf/request.js +41 -78
  281. package/ietf/request.js.map +1 -1
  282. package/ietf/request_stream.d.ts +1 -6
  283. package/ietf/request_stream.d.ts.map +1 -1
  284. package/ietf/request_stream.js +306 -16
  285. package/ietf/request_stream.js.map +1 -1
  286. package/ietf/session.d.ts +41 -0
  287. package/ietf/session.d.ts.map +1 -0
  288. package/ietf/session.js +65 -0
  289. package/ietf/session.js.map +1 -0
  290. package/ietf/setup.d.ts +4 -29
  291. package/ietf/setup.d.ts.map +1 -1
  292. package/ietf/setup.js +6 -117
  293. package/ietf/setup.js.map +1 -1
  294. package/ietf/setup_options.d.ts +31 -0
  295. package/ietf/setup_options.d.ts.map +1 -0
  296. package/ietf/setup_options.js +138 -0
  297. package/ietf/setup_options.js.map +1 -0
  298. package/ietf/solicit.js +4 -14
  299. package/ietf/solicit.js.map +1 -1
  300. package/ietf/subscribe.d.ts +48 -41
  301. package/ietf/subscribe.d.ts.map +1 -1
  302. package/ietf/subscribe.js +118 -239
  303. package/ietf/subscribe.js.map +1 -1
  304. package/ietf/subscribe_namespace.d.ts +13 -76
  305. package/ietf/subscribe_namespace.d.ts.map +1 -1
  306. package/ietf/subscribe_namespace.js +30 -201
  307. package/ietf/subscribe_namespace.js.map +1 -1
  308. package/ietf/subscriber.js +1839 -536
  309. package/ietf/subscriber.js.map +1 -1
  310. package/ietf/token.js +105 -27
  311. package/ietf/token.js.map +1 -1
  312. package/ietf/track.d.ts +25 -22
  313. package/ietf/track.d.ts.map +1 -1
  314. package/ietf/track.js +48 -61
  315. package/ietf/track.js.map +1 -1
  316. package/ietf/version.d.ts +13 -42
  317. package/ietf/version.d.ts.map +1 -1
  318. package/ietf/version.js +22 -48
  319. package/ietf/version.js.map +1 -1
  320. package/implementation.d.ts +2 -0
  321. package/implementation.d.ts.map +1 -0
  322. package/implementation.js +5 -0
  323. package/implementation.js.map +1 -0
  324. package/index.d.ts +25 -10
  325. package/index.d.ts.map +1 -1
  326. package/index.js +19 -6
  327. package/index.js.map +1 -1
  328. package/internal.d.ts +1512 -64
  329. package/internal.d.ts.map +1 -1
  330. package/internal.js +557 -79
  331. package/internal.js.map +1 -1
  332. package/ledger.d.ts +23 -0
  333. package/ledger.d.ts.map +1 -0
  334. package/ledger.js +247 -0
  335. package/ledger.js.map +1 -0
  336. package/listing.d.ts +132 -0
  337. package/listing.d.ts.map +1 -0
  338. package/listing.js +486 -0
  339. package/listing.js.map +1 -0
  340. package/lite/announce.d.ts +124 -63
  341. package/lite/announce.d.ts.map +1 -1
  342. package/lite/announce.js +384 -158
  343. package/lite/announce.js.map +1 -1
  344. package/lite/announce_stream.d.ts +2 -0
  345. package/lite/announce_stream.d.ts.map +1 -0
  346. package/lite/announce_stream.js +92 -0
  347. package/lite/announce_stream.js.map +1 -0
  348. package/lite/answer.d.ts +22 -0
  349. package/lite/answer.d.ts.map +1 -0
  350. package/lite/answer.js +301 -0
  351. package/lite/answer.js.map +1 -0
  352. package/lite/auth.d.ts +45 -0
  353. package/lite/auth.d.ts.map +1 -0
  354. package/lite/auth.js +204 -0
  355. package/lite/auth.js.map +1 -0
  356. package/lite/compat.d.ts +31 -0
  357. package/lite/compat.d.ts.map +1 -0
  358. package/lite/compat.js +86 -0
  359. package/lite/compat.js.map +1 -0
  360. package/lite/connection.d.ts +1 -45
  361. package/lite/connection.d.ts.map +1 -1
  362. package/lite/connection.js +360 -77
  363. package/lite/connection.js.map +1 -1
  364. package/lite/datagram-end.d.ts +26 -0
  365. package/lite/datagram-end.d.ts.map +1 -0
  366. package/lite/datagram-end.js +30 -0
  367. package/lite/datagram-end.js.map +1 -0
  368. package/lite/datagram.d.ts +73 -8
  369. package/lite/datagram.d.ts.map +1 -1
  370. package/lite/datagram.js +144 -9
  371. package/lite/datagram.js.map +1 -1
  372. package/lite/duration.d.ts +6 -0
  373. package/lite/duration.d.ts.map +1 -0
  374. package/lite/duration.js +14 -0
  375. package/lite/duration.js.map +1 -0
  376. package/lite/error.d.ts +9 -0
  377. package/lite/error.d.ts.map +1 -0
  378. package/lite/error.js +24 -0
  379. package/lite/error.js.map +1 -0
  380. package/lite/fills.d.ts +162 -0
  381. package/lite/fills.d.ts.map +1 -0
  382. package/lite/fills.js +486 -0
  383. package/lite/fills.js.map +1 -0
  384. package/lite/fit.d.ts +49 -0
  385. package/lite/fit.d.ts.map +1 -0
  386. package/lite/fit.js +305 -0
  387. package/lite/fit.js.map +1 -0
  388. package/lite/goaway.d.ts +1 -1
  389. package/lite/goaway.d.ts.map +1 -1
  390. package/lite/goaway.js +5 -13
  391. package/lite/goaway.js.map +1 -1
  392. package/lite/group.d.ts +64 -13
  393. package/lite/group.d.ts.map +1 -1
  394. package/lite/group.js +108 -30
  395. package/lite/group.js.map +1 -1
  396. package/lite/identity.d.ts +25 -0
  397. package/lite/identity.d.ts.map +1 -0
  398. package/lite/identity.js +79 -0
  399. package/lite/identity.js.map +1 -0
  400. package/lite/index.d.ts +2 -1
  401. package/lite/index.d.ts.map +1 -1
  402. package/lite/index.js +2 -1
  403. package/lite/index.js.map +1 -1
  404. package/lite/message.d.ts +9 -1
  405. package/lite/message.d.ts.map +1 -1
  406. package/lite/message.js +28 -44
  407. package/lite/message.js.map +1 -1
  408. package/lite/priority.d.ts +9 -2
  409. package/lite/priority.d.ts.map +1 -1
  410. package/lite/priority.js +11 -105
  411. package/lite/priority.js.map +1 -1
  412. package/lite/probe.d.ts.map +1 -1
  413. package/lite/probe.js +9 -0
  414. package/lite/probe.js.map +1 -1
  415. package/lite/publisher.d.ts +10 -1
  416. package/lite/publisher.d.ts.map +1 -1
  417. package/lite/publisher.js +2548 -437
  418. package/lite/publisher.js.map +1 -1
  419. package/lite/routed.d.ts +59 -0
  420. package/lite/routed.d.ts.map +1 -0
  421. package/lite/routed.js +564 -0
  422. package/lite/routed.js.map +1 -0
  423. package/lite/session.d.ts +1 -27
  424. package/lite/session.d.ts.map +1 -1
  425. package/lite/session.js +0 -99
  426. package/lite/session.js.map +1 -1
  427. package/lite/setup.d.ts +29 -2
  428. package/lite/setup.d.ts.map +1 -1
  429. package/lite/setup.js +95 -21
  430. package/lite/setup.js.map +1 -1
  431. package/lite/stream.d.ts +5 -11
  432. package/lite/stream.d.ts.map +1 -1
  433. package/lite/stream.js +5 -1
  434. package/lite/stream.js.map +1 -1
  435. package/lite/subscribe.d.ts +475 -75
  436. package/lite/subscribe.d.ts.map +1 -1
  437. package/lite/subscribe.js +1373 -142
  438. package/lite/subscribe.js.map +1 -1
  439. package/lite/subscriber.d.ts +7 -44
  440. package/lite/subscriber.d.ts.map +1 -1
  441. package/lite/subscriber.js +3290 -515
  442. package/lite/subscriber.js.map +1 -1
  443. package/lite/track.d.ts +24 -9
  444. package/lite/track.d.ts.map +1 -1
  445. package/lite/track.js +116 -37
  446. package/lite/track.js.map +1 -1
  447. package/lite/tracks.d.ts +55 -0
  448. package/lite/tracks.d.ts.map +1 -0
  449. package/lite/tracks.js +114 -0
  450. package/lite/tracks.js.map +1 -0
  451. package/lite/version.d.ts +132 -24
  452. package/lite/version.d.ts.map +1 -1
  453. package/lite/version.js +378 -33
  454. package/lite/version.js.map +1 -1
  455. package/meta.d.ts +77 -0
  456. package/meta.d.ts.map +1 -0
  457. package/meta.js +130 -0
  458. package/meta.js.map +1 -0
  459. package/meta_api.d.ts +7 -0
  460. package/meta_api.d.ts.map +1 -0
  461. package/meta_api.js +7 -0
  462. package/meta_api.js.map +1 -0
  463. package/mint.d.ts +28 -0
  464. package/mint.d.ts.map +1 -0
  465. package/mint.js +66 -0
  466. package/mint.js.map +1 -0
  467. package/open.d.ts +63 -0
  468. package/open.d.ts.map +1 -0
  469. package/open.js +250 -0
  470. package/open.js.map +1 -0
  471. package/origin.d.ts +392 -140
  472. package/origin.d.ts.map +1 -1
  473. package/origin.js +2533 -686
  474. package/origin.js.map +1 -1
  475. package/package.json +8 -13
  476. package/path.d.ts +51 -51
  477. package/path.d.ts.map +1 -1
  478. package/path.js +210 -57
  479. package/path.js.map +1 -1
  480. package/payload.d.ts +33 -0
  481. package/payload.d.ts.map +1 -0
  482. package/payload.js +65 -0
  483. package/payload.js.map +1 -0
  484. package/prefix.d.ts +152 -0
  485. package/prefix.d.ts.map +1 -0
  486. package/prefix.js +349 -0
  487. package/prefix.js.map +1 -0
  488. package/priority.d.ts +8 -0
  489. package/priority.d.ts.map +1 -0
  490. package/priority.js +185 -0
  491. package/priority.js.map +1 -0
  492. package/queue.d.ts +2 -0
  493. package/queue.d.ts.map +1 -0
  494. package/queue.js +46 -0
  495. package/queue.js.map +1 -0
  496. package/ranges.d.ts +36 -0
  497. package/ranges.d.ts.map +1 -0
  498. package/ranges.js +312 -0
  499. package/ranges.js.map +1 -0
  500. package/rescale.d.ts +24 -0
  501. package/rescale.d.ts.map +1 -0
  502. package/rescale.js +39 -0
  503. package/rescale.js.map +1 -0
  504. package/resume.d.ts +55 -0
  505. package/resume.d.ts.map +1 -0
  506. package/resume.js +4173 -0
  507. package/resume.js.map +1 -0
  508. package/resume.test-util.d.ts +2 -0
  509. package/resume.test-util.d.ts.map +1 -0
  510. package/resume.test-util.js +25 -0
  511. package/resume.test-util.js.map +1 -0
  512. package/skips.d.ts +48 -0
  513. package/skips.d.ts.map +1 -0
  514. package/skips.js +182 -0
  515. package/skips.js.map +1 -0
  516. package/stream.d.ts +75 -37
  517. package/stream.d.ts.map +1 -1
  518. package/stream.js +236 -92
  519. package/stream.js.map +1 -1
  520. package/subscription.test-util.d.ts +2 -0
  521. package/subscription.test-util.d.ts.map +1 -0
  522. package/subscription.test-util.js +49 -0
  523. package/subscription.test-util.js.map +1 -0
  524. package/tail.d.ts +23 -14
  525. package/tail.d.ts.map +1 -1
  526. package/tail.js +224 -97
  527. package/tail.js.map +1 -1
  528. package/time.d.ts +41 -102
  529. package/time.d.ts.map +1 -1
  530. package/time.js +129 -91
  531. package/time.js.map +1 -1
  532. package/timed.d.ts +21 -0
  533. package/timed.d.ts.map +1 -0
  534. package/timed.js +2 -0
  535. package/timed.js.map +1 -0
  536. package/track.d.ts +577 -245
  537. package/track.d.ts.map +1 -1
  538. package/track.js +7306 -771
  539. package/track.js.map +1 -1
  540. package/track_api.d.ts +7 -0
  541. package/track_api.d.ts.map +1 -0
  542. package/track_api.js +7 -0
  543. package/track_api.js.map +1 -0
  544. package/util/abort.d.ts +1 -0
  545. package/util/abort.d.ts.map +1 -1
  546. package/util/abort.js +23 -1
  547. package/util/abort.js.map +1 -1
  548. package/util/announce.d.ts +4 -0
  549. package/util/announce.d.ts.map +1 -0
  550. package/util/announce.js +11 -0
  551. package/util/announce.js.map +1 -0
  552. package/util/bigint.d.ts +3 -0
  553. package/util/bigint.d.ts.map +1 -0
  554. package/util/bigint.js +8 -0
  555. package/util/bigint.js.map +1 -0
  556. package/util/change.d.ts +12 -0
  557. package/util/change.d.ts.map +1 -0
  558. package/util/change.js +18 -0
  559. package/util/change.js.map +1 -0
  560. package/util/deadline.d.ts +2 -0
  561. package/util/deadline.d.ts.map +1 -0
  562. package/util/deadline.js +108 -0
  563. package/util/deadline.js.map +1 -0
  564. package/util/decode_error.d.ts +3 -0
  565. package/util/decode_error.d.ts.map +1 -0
  566. package/util/decode_error.js +11 -0
  567. package/util/decode_error.js.map +1 -0
  568. package/util/demand.d.ts +8 -0
  569. package/util/demand.d.ts.map +1 -0
  570. package/util/demand.js +24 -0
  571. package/util/demand.js.map +1 -0
  572. package/util/given_up.d.ts +2 -0
  573. package/util/given_up.d.ts.map +1 -0
  574. package/util/given_up.js +101 -0
  575. package/util/given_up.js.map +1 -0
  576. package/util/hex.d.ts +6 -0
  577. package/util/hex.d.ts.map +1 -1
  578. package/util/hex.js +19 -4
  579. package/util/hex.js.map +1 -1
  580. package/util/key.d.ts +15 -0
  581. package/util/key.d.ts.map +1 -0
  582. package/util/key.js +38 -0
  583. package/util/key.js.map +1 -0
  584. package/util/limits.d.ts +2 -0
  585. package/util/limits.d.ts.map +1 -0
  586. package/util/limits.js +76 -0
  587. package/util/limits.js.map +1 -0
  588. package/util/observed.d.ts +23 -0
  589. package/util/observed.d.ts.map +1 -0
  590. package/util/observed.js +122 -0
  591. package/util/observed.js.map +1 -0
  592. package/util/sorted.d.ts +2 -0
  593. package/util/sorted.d.ts.map +1 -0
  594. package/util/sorted.js +149 -0
  595. package/util/sorted.js.map +1 -0
  596. package/util/timeout.d.ts +2 -1
  597. package/util/timeout.d.ts.map +1 -1
  598. package/util/timeout.js +13 -9
  599. package/util/timeout.js.map +1 -1
  600. package/util/timer.d.ts +2 -0
  601. package/util/timer.d.ts.map +1 -0
  602. package/util/timer.js +19 -0
  603. package/util/timer.js.map +1 -0
  604. package/util/utf8.d.ts +2 -0
  605. package/util/utf8.d.ts.map +1 -1
  606. package/util/utf8.js +7 -1
  607. package/util/utf8.js.map +1 -1
  608. package/util/varint.d.ts.map +1 -1
  609. package/util/varint.js +8 -1
  610. package/util/varint.js.map +1 -1
  611. package/util/watch.d.ts +8 -0
  612. package/util/watch.d.ts.map +1 -0
  613. package/util/watch.js +38 -0
  614. package/util/watch.js.map +1 -0
  615. package/util/yield.d.ts +2 -0
  616. package/util/yield.d.ts.map +1 -0
  617. package/util/yield.js +31 -0
  618. package/util/yield.js.map +1 -0
  619. package/varint.d.ts +0 -29
  620. package/varint.d.ts.map +1 -1
  621. package/varint.js +7 -28
  622. package/varint.js.map +1 -1
  623. package/varint_api.d.ts +7 -0
  624. package/varint_api.d.ts.map +1 -0
  625. package/varint_api.js +7 -0
  626. package/varint_api.js.map +1 -0
  627. package/version.d.ts +2 -0
  628. package/version.d.ts.map +1 -0
  629. package/version.js +4 -0
  630. package/version.js.map +1 -0
  631. package/window.d.ts +570 -0
  632. package/window.d.ts.map +1 -0
  633. package/window.js +1677 -0
  634. package/window.js.map +1 -0
  635. package/wire.d.ts +145 -30
  636. package/wire.d.ts.map +1 -1
  637. package/wire.js +27 -0
  638. package/wire.js.map +1 -1
  639. package/connection/established.d.ts +0 -53
  640. package/connection/established.d.ts.map +0 -1
  641. package/connection/established.js +0 -2
  642. package/connection/established.js.map +0 -1
  643. package/ietf/adapter.d.ts +0 -75
  644. package/ietf/adapter.d.ts.map +0 -1
  645. package/ietf/adapter.js +0 -699
  646. package/ietf/adapter.js.map +0 -1
  647. package/lite/datagram_stream.d.ts +0 -8
  648. package/lite/datagram_stream.d.ts.map +0 -1
  649. package/lite/datagram_stream.js +0 -43
  650. package/lite/datagram_stream.js.map +0 -1
  651. package/lite/fetch.d.ts +0 -28
  652. package/lite/fetch.d.ts.map +0 -1
  653. package/lite/fetch.js +0 -78
  654. package/lite/fetch.js.map +0 -1
  655. package/util/log.d.ts +0 -5
  656. package/util/log.d.ts.map +0 -1
  657. package/util/log.js +0 -16
  658. package/util/log.js.map +0 -1
  659. package/zod.d.ts +0 -13
  660. package/zod.d.ts.map +0 -1
  661. package/zod.js +0 -18
  662. package/zod.js.map +0 -1
@@ -1,48 +1,55 @@
1
1
  /**
2
- * A reconnecting, shareable connection: one origin and one reconnect loop per relay URL.
2
+ * A reconnecting, shareable connection: one origin and reconnect loop per URL and version list.
3
3
  *
4
4
  * @module
5
5
  */
6
- import { Effect, Once, Signal } from "@moq/signals";
7
- import * as Announce from "../announced.js";
6
+ import { Duration } from "@moq/clock";
7
+ import { Derived, Effect, Once, Signal } from "@moq/signals";
8
+ import { Producer as AnnounceProducer, list } from "../announced.js";
8
9
  import * as Origin from "../origin.js";
9
10
  import * as Path from "../path.js";
10
- import * as Time from "../time.js";
11
+ import { closeUnwanted } from "../util/announce.js";
12
+ import { Follow } from "../util/observed.js";
13
+ import { after } from "../util/timer.js";
11
14
  import { accept } from "./accept.js";
12
15
  import { isWebTransportSupported } from "./browser.js";
13
- import { certificateHash, connect, } from "./connect.js";
14
- import { Reload } from "./reload.js";
16
+ import { certificateHash, checkVersions, connect, normalizeVersions, } from "./connect.js";
17
+ import { Dials as DialsClass } from "./dials.js";
18
+ import { DISCOVERY_REMOVED } from "./forward.js";
19
+ import { pumpAnnounced, Reload } from "./reload.js";
15
20
  /** How long an unreferenced shared connection lingers before it actually closes. */
16
- const LINGER_MS = Time.Milli(2000);
21
+ const LINGER = Duration.millis(2000);
17
22
  /**
18
23
  * A cloneable handle on a MoQ connection: `new Connection({ url })` reconnects and, by
19
- * default, shares one origin and one reconnect loop with every other handle on that URL.
24
+ * default, shares one origin and reconnect loop with handles using the same URL and versions.
20
25
  *
21
26
  * The shared {@link origin} is wired to both directions. Everything the relay announces
22
27
  * lands in it, a publish into it is announced to the relay, and a page that publishes and
23
28
  * watches the same path resolves it locally with no round trip.
24
29
  *
25
- * {@link close} releases this handle; the connection survives its last handle by a short
26
- * linger window (see {@link ConnectionProps.linger}), so a component torn down and rebuilt
27
- * reuses the warm connection instead of redialing.
30
+ * {@link close} releases this handle; the connection survives its last handle by a two-second
31
+ * linger window, so a component torn down and rebuilt reuses the warm connection instead of redialing.
28
32
  *
29
33
  * The loop reconnects for as long as a handle holds it, so an outage of any length recovers
30
34
  * on its own. An auth rejection stops retrying those credentials and retires the shared
31
35
  * connection so the next handle dials fresh; a new URL on this handle starts another
32
- * sequence. {@link closed} settles only when this handle is released.
36
+ * key. {@link closed} settles only when this handle is released.
33
37
  *
34
38
  * A relay's GOAWAY migrates rather than drops: the replacement dials at once while the old
35
39
  * session finishes its groups, and the handle and its origin carry across. A redirect the
36
- * {@link ConnectionProps.goaway} policy refuses stops the loop like an auth rejection does.
40
+ * `goaway` policy refuses stops the loop like an auth rejection does.
37
41
  *
38
- * Options the pool cannot honor (transport options, discovery, delay, goaway, a pinned
39
- * certificate, caller-owned origins) use a private loop. An explicit `share: true`
42
+ * Options the pool cannot honor (transport options, backoff, timeout, goaway, tokens, a credential
43
+ * in the URL, a pinned certificate, caller-owned origins) use a private loop. An explicit `share: true`
40
44
  * refuses them. A supplied transport cannot reconnect at all; pass it to {@link Connection.connect}
41
45
  * instead.
42
46
  *
43
47
  * @public
44
48
  */
45
49
  export class Connection {
50
+ /** Tokens a connection asks for at each dial: pass one as `tokens` and answer its {@link Dials.next} dials. */
51
+ // fallow-ignore-next-line unused-class-member
52
+ static Dials = DialsClass;
46
53
  /** Establish a one-shot session; a supplied transport belongs here, not in the reconnect loop. */
47
54
  static connect = connect;
48
55
  /** Accept a one-shot session on an already-open transport. */
@@ -51,8 +58,12 @@ export class Connection {
51
58
  static certificateHash = certificateHash;
52
59
  /** Whether this runtime can connect with WebTransport. */
53
60
  static isWebTransportSupported = isWebTransportSupported;
61
+ /** Copy a version list that can be offered, throwing a `TypeError` if it is empty or has an unsupported or duplicate name. */
62
+ static checkVersions = checkVersions;
54
63
  /** Relay URL to connect to; updating it reconnects to that URL. */
55
64
  url;
65
+ /** Protocol versions to offer, or undefined for the defaults; updating it reconnects with that list. */
66
+ versions;
56
67
  /** Whether to hold a connection at all; clearing it releases this handle's share. */
57
68
  enabled;
58
69
  /** Current status of the connection. */
@@ -60,10 +71,16 @@ export class Connection {
60
71
  /**
61
72
  * The failure that stopped retrying the current URL, or undefined while the loop is live.
62
73
  *
63
- * Set on an auth rejection or when a private retry window expires. Cleared when a new URL
64
- * or a disable/re-enable starts another sequence, not on a page hide/show.
74
+ * Set on an auth rejection, when a private retry window expires, or when {@link versions} names
75
+ * one this build cannot offer. Cleared when a new URL or version list, or a disable/re-enable,
76
+ * starts another key, not on a page hide/show.
65
77
  */
66
78
  error;
79
+ /**
80
+ * Why the connection is retrying: how its last attempt or session ended, cleared once a
81
+ * session serves again or a new URL starts. Mirrors Rust's `Monitor::failure()`.
82
+ */
83
+ failure;
67
84
  /**
68
85
  * The wire transport the current session runs over, or undefined while disconnected.
69
86
  *
@@ -71,17 +88,29 @@ export class Connection {
71
88
  * or reconfigure it, and everything else it offers is reachable through {@link origin}.
72
89
  */
73
90
  transport;
74
- /** The current connection's PROBE estimates, or undefined while disconnected. */
91
+ /** Receive estimates while observed, or undefined while disconnected; peek does not request them. */
75
92
  probe;
93
+ /** The latest transport counters, sampled while observed on a connection supporting getStats. */
94
+ sample;
95
+ /** The current session's liveness, or undefined on a transport that can't probe its peer (WebTransport, qmux-00) or while disconnected. */
96
+ liveness;
76
97
  /**
77
98
  * The send-side bandwidth allocator for the current URL, or undefined
78
99
  * while disabled or URL-less.
79
100
  *
80
- * Every handle on this URL shares the same instance, so publishers reserve
101
+ * Every handle on this URL shares the same identity, so publishers reserve
81
102
  * against one registry. Borrowed, not owned: the type has no close, since
82
103
  * closing it would starve every other handle.
83
104
  */
84
- bandwidth;
105
+ allocator;
106
+ /**
107
+ * The receive-side registry for the current URL, or undefined while disabled or URL-less.
108
+ *
109
+ * Every handle on this URL shares the same identity, so players watching over one
110
+ * connection split its receive estimate instead of each selecting against all of it,
111
+ * and their ceilings summed are the PROBE target. Borrowed, not owned: it has no close.
112
+ */
113
+ viewers;
85
114
  /**
86
115
  * The origin for the current URL, or undefined while disabled or URL-less.
87
116
  *
@@ -91,6 +120,16 @@ export class Connection {
91
120
  * every other handle.
92
121
  */
93
122
  origin;
123
+ /**
124
+ * The auth handle every session presents, or undefined while disabled or URL-less.
125
+ *
126
+ * Every session the connection makes presents the tokens it holds, so a route naming one
127
+ * keeps it across a reconnect, and its grant follows the live session. A private
128
+ * connection keeps one handle across URL changes, so its tokens go to the new URL, and
129
+ * starts another when `versions` changes. A shared connection's is the one every other
130
+ * handle on its URL uses, since they share the session.
131
+ */
132
+ auth;
94
133
  /**
95
134
  * Settles once this handle is released via {@link close}: `null` on a clean close, or
96
135
  * the abort {@link Error}. Peek it synchronously (`undefined` while open), observe it
@@ -100,15 +139,21 @@ export class Connection {
100
139
  return this.#closed;
101
140
  }
102
141
  #closed = new Once();
142
+ // Ended with this handle, so whoever answers its dials stops.
143
+ #dials;
103
144
  #status = new Signal("disconnected");
104
145
  #established = new Signal(undefined);
105
146
  #probe = new Signal(undefined);
106
147
  #origin = new Signal(undefined);
107
- #bandwidth = new Signal(undefined);
148
+ #allocator = new Signal(undefined);
149
+ #viewers = new Signal(undefined);
150
+ #auth = new Signal(undefined);
151
+ #loop = new Signal(undefined);
108
152
  #error = new Signal(undefined);
153
+ #failure = new Signal(undefined);
109
154
  #signals;
110
155
  /**
111
- * Take a handle on the connection for {@link ConnectionProps.url}.
156
+ * Take a handle on the connection for the `url` option.
112
157
  *
113
158
  * Dials immediately when a URL is given and `enabled` is not false; otherwise waits for
114
159
  * the signals to say go. The handle owns nothing but its own share: {@link close}
@@ -116,22 +161,42 @@ export class Connection {
116
161
  * (plus the linger window) wants them.
117
162
  */
118
163
  constructor(props) {
164
+ const given = props?.versions;
165
+ // A plain list is checked and copied now, so a bad name throws here and mutating the array
166
+ // later changes nothing. A live list is checked as it changes, failing on `error`.
167
+ const fixed = normalizeVersions({ ...props, versions: Array.isArray(given) ? given : undefined });
119
168
  refuse(props);
120
169
  this.#signals = new Effect();
170
+ if (props?.tokens instanceof DialsClass) {
171
+ // One connection answers them: another would sign for this one's dials.
172
+ if (props.tokens.claimed)
173
+ throw new TypeError("these dials already serve another connection");
174
+ this.#dials = props.tokens;
175
+ }
121
176
  this.url = Signal.from(props?.url);
177
+ this.versions = Signal.from(Array.isArray(given) ? fixed : given);
122
178
  this.enabled = Signal.from(props?.enabled ?? true);
123
179
  this.status = this.#status;
124
180
  this.error = this.#error;
125
- this.probe = this.#probe;
181
+ this.failure = this.#failure;
182
+ this.probe = new Follow(this.#probe);
183
+ this.sample = new Follow(new Derived([this.#loop], (loop) => loop?.sample));
126
184
  this.origin = this.#origin;
127
- this.bandwidth = this.#bandwidth;
185
+ this.allocator = this.#allocator;
186
+ this.viewers = this.#viewers;
187
+ this.auth = this.#auth;
128
188
  this.transport = this.#signals.computed((effect) => effect.get(this.#established)?.transport);
129
- const linger = props?.linger;
189
+ this.liveness = this.#signals.computed((effect) => {
190
+ const liveness = effect.get(this.#established)?.liveness;
191
+ return liveness && effect.get(liveness);
192
+ });
130
193
  // Key on the serialized URL: URL objects use identity equality, and an equivalent
131
194
  // instance must not release and redial.
132
195
  const href = this.#signals.computed((effect) => effect.get(this.url)?.href);
133
196
  if (props && (props.share === false || requiresPrivate(props))) {
134
197
  this.#runPrivate(props, href);
198
+ // Only once nothing above threw, so a rejected config leaves the dials free.
199
+ this.#dials?.claim();
135
200
  return;
136
201
  }
137
202
  this.#signals.run((effect) => {
@@ -140,15 +205,24 @@ export class Connection {
140
205
  const key = effect.get(href);
141
206
  if (!key)
142
207
  return;
143
- const lease = acquire(key, linger);
208
+ const versions = offered(effect.get(this.versions));
209
+ if (versions instanceof TypeError) {
210
+ effect.set(this.#error, versions, undefined);
211
+ return;
212
+ }
213
+ const lease = acquire(key, versions);
144
214
  effect.cleanup(lease.release);
145
215
  effect.set(this.#origin, lease.origin, undefined);
146
- effect.set(this.#bandwidth, lease.connection.bandwidth, undefined);
216
+ effect.set(this.#allocator, lease.connection.allocator, undefined);
217
+ effect.set(this.#viewers, lease.connection.viewers, undefined);
218
+ effect.set(this.#auth, lease.connection.auth, undefined);
219
+ effect.set(this.#loop, lease.connection, undefined);
147
220
  // Proxy the shared loop's outputs, so this handle reads like its own connection.
148
221
  effect.run((nested) => nested.set(this.#status, nested.get(lease.connection.status), "disconnected"));
149
222
  effect.run((nested) => nested.set(this.#established, nested.get(lease.connection.established), undefined));
150
- effect.run((nested) => nested.set(this.#probe, nested.get(lease.connection.probe), undefined));
223
+ effect.run((nested) => nested.set(this.#probe, lease.connection.probe, undefined));
151
224
  effect.run((nested) => nested.set(this.#error, nested.get(lease.connection.error), undefined));
225
+ effect.run((nested) => nested.set(this.#failure, nested.get(lease.connection.failure), undefined));
152
226
  });
153
227
  }
154
228
  #runPrivate(props, href) {
@@ -156,101 +230,177 @@ export class Connection {
156
230
  const origin = props.consume ?? new Origin.Producer();
157
231
  if (owned)
158
232
  this.#signals.cleanup(() => origin.close());
159
- const loop = new Reload({
160
- url: this.url,
161
- enabled: this.enabled,
162
- publish: props.publish ?? (owned ? origin.consume() : undefined),
163
- consume: origin,
164
- webtransport: props.webtransport,
165
- websocket: props.websocket,
166
- discovery: props.discovery,
167
- // A handle nobody watches wants unlimited retries; an auth rejection still
168
- // stops this URL, and a new one starts another sequence.
169
- delay: { timeout: Time.Milli(0), ...props.delay },
170
- goaway: props.goaway,
171
- });
172
- this.#signals.cleanup(() => loop.close());
173
- this.#signals.run((effect) => {
174
- if (!effect.get(this.enabled) || !effect.get(href))
233
+ const publish = props.publish ?? (owned ? origin.consume() : undefined);
234
+ // The origin spans version changes; only the loop dialing it is replaced. Each loop is built
235
+ // synchronously, not in an effect a microtask later, so its hold on `consume` is in place
236
+ // before a watcher created alongside could sync on an empty table.
237
+ let stop;
238
+ const start = (list) => {
239
+ stop?.();
240
+ const signals = new Effect();
241
+ stop = () => signals.close();
242
+ const versions = offered(list);
243
+ if (versions instanceof TypeError) {
244
+ signals.run((effect) => effect.set(this.#error, versions, undefined));
175
245
  return;
176
- effect.set(this.#origin, origin, undefined);
177
- effect.set(this.#bandwidth, loop.bandwidth, undefined);
178
- });
179
- this.#signals.run((effect) => effect.set(this.#status, effect.get(loop.status), "disconnected"));
180
- this.#signals.run((effect) => effect.set(this.#established, effect.get(loop.established), undefined));
181
- this.#signals.run((effect) => effect.set(this.#probe, effect.get(loop.probe), undefined));
182
- this.#signals.run((effect) => effect.set(this.#error, effect.get(loop.error), undefined));
246
+ }
247
+ const loop = new Reload({
248
+ url: this.url,
249
+ enabled: this.enabled,
250
+ publish,
251
+ consume: origin,
252
+ versions,
253
+ webtransport: props.webtransport,
254
+ websocket: props.websocket,
255
+ backoff: props.backoff,
256
+ timeout: props.timeout,
257
+ cost: props.cost,
258
+ goaway: props.goaway,
259
+ tokens: props.tokens,
260
+ urlAuth: props.urlAuth,
261
+ });
262
+ signals.cleanup(() => loop.close());
263
+ signals.run((effect) => {
264
+ if (!effect.get(this.enabled) || !effect.get(href))
265
+ return;
266
+ effect.set(this.#origin, origin, undefined);
267
+ effect.set(this.#allocator, loop.allocator, undefined);
268
+ effect.set(this.#viewers, loop.viewers, undefined);
269
+ effect.set(this.#auth, loop.auth, undefined);
270
+ effect.set(this.#loop, loop, undefined);
271
+ });
272
+ signals.run((effect) => effect.set(this.#status, effect.get(loop.status), "disconnected"));
273
+ signals.run((effect) => effect.set(this.#established, effect.get(loop.established), undefined));
274
+ signals.run((effect) => effect.set(this.#probe, loop.probe, undefined));
275
+ signals.run((effect) => effect.set(this.#error, effect.get(loop.error), undefined));
276
+ signals.run((effect) => effect.set(this.#failure, effect.get(loop.failure), undefined));
277
+ };
278
+ start(this.versions.peek());
279
+ this.#signals.cleanup(this.versions.subscribe(start));
280
+ this.#signals.cleanup(() => stop?.());
183
281
  }
184
282
  /**
185
- * Subscribe to broadcast announcements matching `scope`, spanning reconnects
283
+ * Subscribe to broadcast announcements at or beneath `prefix`, spanning reconnects
186
284
  * and URL switches: a switch retracts everything from
187
285
  * the old relay's origin, then the new one's arrivals stream in.
188
286
  */
189
- announced(scope = Path.Pattern.all(), options) {
190
- const producer = new Announce.Producer();
287
+ announced(prefix = Path.empty(), options) {
288
+ return list(this.routes(prefix, options));
289
+ }
290
+ /**
291
+ * Every route change at or beneath `prefix`, spanning reconnects like {@link announced}.
292
+ *
293
+ * @internal
294
+ */
295
+ routes(prefix = Path.empty(), options) {
296
+ // Throw here: inside the effect below, a refused prefix would leave the listing open and empty.
297
+ Path.Prefix.parse(prefix);
298
+ Path.encode(prefix);
299
+ const producer = new AnnounceProducer();
191
300
  const consumer = producer.consume();
192
- // Closing the consumer closes the shared state, so stop appending after that.
193
- let closed = false;
194
- void consumer.closed.then(() => {
195
- closed = true;
196
- });
197
301
  // A child of this handle's scope rather than a standalone Effect it merely cleans up
198
302
  // after: the disposer run() hands back also drops itself from the parent, so opening
199
303
  // and closing announcement streams repeatedly does not pile up dead pumps that live
200
304
  // until the whole handle closes.
201
305
  const stop = this.#signals.run((effect) => {
202
306
  const origin = effect.get(this.#origin);
203
- if (!origin)
307
+ if (!origin) {
308
+ // Like a reconnecting loop's origin: behind while enabled with nothing to deliver.
309
+ if (effect.get(this.enabled))
310
+ producer.behind();
311
+ else
312
+ producer.synced();
204
313
  return;
205
- const upstream = origin.announced(scope, options);
206
- effect.cleanup(() => upstream.close());
207
- // Track what this origin announced so a URL switch retracts it; the last
208
- // event rides along for the retraction.
209
- const active = new Map();
210
- effect.spawn(async () => {
211
- try {
212
- for (;;) {
213
- const entry = await effect.race(upstream.next());
214
- if (!entry)
215
- break;
216
- if (Announce.isActive(entry.kind))
217
- active.set(entry.prefix, entry);
218
- else
219
- active.delete(entry.prefix);
220
- producer.append(entry);
221
- }
222
- }
223
- finally {
224
- if (!closed) {
225
- for (const entry of active.values()) {
226
- producer.append({ ...entry, kind: "retracted" });
227
- }
228
- }
229
- }
230
- });
314
+ }
315
+ let routes;
316
+ try {
317
+ routes = origin.routes(prefix, options);
318
+ }
319
+ catch (err) {
320
+ // The origin's root can still push the prefix past the wire limits: end the listing with why.
321
+ producer.close(err instanceof Error ? err : new Error(String(err)));
322
+ return;
323
+ }
324
+ // A URL switch retracts what the old origin announced.
325
+ pumpAnnounced(effect, routes, producer);
231
326
  });
232
- void consumer.closed.then(stop);
327
+ closeUnwanted(producer);
328
+ void producer.closed.then(stop);
233
329
  return consumer;
234
330
  }
235
331
  /** Snapshot the live connection's transport counters, or undefined while disconnected. */
332
+ // fallow-ignore-next-line unused-class-member
236
333
  async stats() {
237
334
  return this.#established.peek()?.stats();
238
335
  }
239
336
  /**
240
- * Release this handle. The shared connection closes once its last handle is gone and
241
- * the linger window passes; other handles on the URL are unaffected. Idempotent.
337
+ * Resolve once the peer first answers the latest {@link ConnectionProps.tokens}, as Rust's
338
+ * `Tokens::poll_answered` does: each token the latest set newly presented, or the initial
339
+ * ones before any set, is granted in band, or is the connection credential a dial carried and
340
+ * the peer accepted. A token the set kept, the connection credential included, counts only
341
+ * once the peer refuses it, and nothing is re-checked after the answer. A set replaced before
342
+ * its answer moves the wait to the new one, and a connection with no tokens answers at once.
343
+ *
344
+ * An app that re-signs its credential for each dial can end the connection on a refusal by
345
+ * aborting its {@link auth} handle, which makes the loop give up with that error.
346
+ *
347
+ * Waits while no connection is held, such as before a URL is set.
348
+ *
349
+ * @throws The peer's refusal, an `Unsupported` error when the session cannot carry a token in
350
+ * band, the connection's end such as an abort of its auth handle, or the failure that stopped
351
+ * it retrying its URL while no session answered, such as a refused first dial.
352
+ */
353
+ async answered() {
354
+ for (;;) {
355
+ const closed = this.#closed.peek();
356
+ if (closed !== undefined)
357
+ throw closed ?? new Error("connection closed");
358
+ const loop = this.#loop.peek();
359
+ // A new loop, such as one a version change built, restarts the wait.
360
+ const { promise: moved, resolve } = Promise.withResolvers();
361
+ const stop = this.#loop.changed(() => resolve("moved"));
362
+ // Closing this handle ends the wait, even with no loop to notice.
363
+ const closing = this.#closed.changed(() => resolve("moved"));
364
+ try {
365
+ const answered = loop?.answered().then(() => "answered");
366
+ if ((await Promise.race(answered ? [answered, moved] : [moved])) === "answered")
367
+ return;
368
+ }
369
+ finally {
370
+ stop();
371
+ closing();
372
+ }
373
+ }
374
+ }
375
+ /**
376
+ * Release this handle. The shared connection drains and closes once its last handle is
377
+ * gone and the linger window passes; other handles on the URL are unaffected. Idempotent.
242
378
  */
243
379
  close(abort) {
244
380
  this.#signals.close();
381
+ this.#dials?.close();
245
382
  if (this.#closed.peek() === undefined)
246
383
  this.#closed.set(abort ?? null);
247
384
  }
248
385
  }
386
+ /** The checked copy of `versions` to dial with, or why it cannot be offered. */
387
+ function offered(versions) {
388
+ try {
389
+ return versions === undefined ? undefined : checkVersions(versions);
390
+ }
391
+ catch (err) {
392
+ if (err instanceof TypeError)
393
+ return err;
394
+ throw err;
395
+ }
396
+ }
249
397
  /** Throw if `props` cannot be honored, rather than silently dropping them. */
250
398
  function refuse(props) {
251
399
  if (!props)
252
400
  return;
253
401
  const extra = props;
402
+ if ("discovery" in props)
403
+ throw new TypeError(DISCOVERY_REMOVED);
254
404
  if (extra.transport) {
255
405
  throw new Error("a supplied transport cannot reconnect; call Connection.connect() instead");
256
406
  }
@@ -272,44 +422,58 @@ function refuse(props) {
272
422
  if (props.websocket !== undefined) {
273
423
  throw new Error("websocket options cannot be shared; pass share: false");
274
424
  }
275
- if (props.discovery !== undefined) {
276
- throw new Error("discovery cannot be shared; pass share: false");
425
+ if (props.backoff !== undefined) {
426
+ throw new Error("backoff cannot be shared; pass share: false");
427
+ }
428
+ if (props.tokens !== undefined) {
429
+ throw new Error("tokens cannot be shared; pass share: false");
277
430
  }
278
- if (props.delay !== undefined) {
279
- throw new Error("delay cannot be shared; pass share: false");
431
+ if (props.urlAuth) {
432
+ throw new Error("urlAuth cannot be shared; pass share: false");
433
+ }
434
+ if (props.timeout !== undefined) {
435
+ throw new Error("timeout cannot be shared; pass share: false");
280
436
  }
281
437
  if (props.goaway !== undefined) {
282
438
  throw new Error("goaway cannot be shared; pass share: false");
283
439
  }
440
+ if (props.cost !== undefined) {
441
+ throw new Error("cost cannot be shared; pass share: false");
442
+ }
284
443
  }
285
444
  /** Options tied to one handle cannot be represented by a URL-keyed shared entry. */
286
445
  function requiresPrivate(props) {
287
446
  return (props.webtransport !== undefined ||
288
447
  props.websocket !== undefined ||
289
- props.discovery !== undefined ||
290
- props.delay !== undefined ||
448
+ props.backoff !== undefined ||
449
+ props.tokens !== undefined ||
450
+ props.urlAuth === true ||
451
+ props.timeout !== undefined ||
291
452
  props.goaway !== undefined ||
453
+ props.cost !== undefined ||
292
454
  props.publish !== undefined ||
293
455
  props.consume !== undefined);
294
456
  }
295
457
  /** The process-wide pool backing {@link Connection}. */
296
458
  const pool = new Map();
297
- /** Take a reference on the shared entry for `key`, creating it on first use. */
298
- function acquire(key, linger) {
459
+ // Preserve the ordered versions when a redirect moves the URL.
460
+ function poolKey(url, versions) {
461
+ return JSON.stringify([url, versions]);
462
+ }
463
+ /** Take a reference on the shared entry, creating it on first use. */
464
+ function acquire(url, versions) {
465
+ const key = poolKey(url, versions);
299
466
  let entry = pool.get(key);
300
467
  if (!entry) {
301
468
  const origin = new Origin.Producer();
302
469
  const connection = new Reload({
303
- url: new URL(key),
470
+ url: new URL(url),
471
+ versions,
304
472
  enabled: true,
305
473
  publish: origin.consume(),
306
474
  consume: origin,
307
- // Nobody observes a shared loop's `closed`, so giving up would strand every handle
308
- // on this URL offline until the page reloads. Retry for as long as the entry lives
309
- // instead; an auth rejection still stops this URL, and evicts below.
310
- delay: { timeout: Time.Milli(0) },
311
475
  });
312
- const created = { key, origin, connection, refs: 0, linger: linger ?? LINGER_MS };
476
+ const created = { key, origin, connection, refs: 0 };
313
477
  // The loop only stops on a peer saying these credentials will never work, or on a
314
478
  // GOAWAY redirect it refused. Drop the entry so a later handle dials fresh rather
315
479
  // than joining a loop that has stopped; handles already on it keep it until they
@@ -318,16 +482,19 @@ function acquire(key, linger) {
318
482
  if (err !== undefined && pool.get(created.key) === created)
319
483
  pool.delete(created.key);
320
484
  });
321
- // An accepted redirect moves the entry to the URL it now dials, so a later handle
322
- // configured with that URL shares it, and one asking for the old URL dials fresh.
323
- // A live entry already at the target wins: this one leaves the pool and serves only
324
- // the handles it has until they release it.
485
+ // The entry follows the URL its loop dials: an accepted redirect moves it to the
486
+ // target, so a later handle configured with that URL shares it and one asking for
487
+ // the old URL dials fresh, and a dead target's dropped redirect moves it back to the
488
+ // configured URL. A live entry already at the new key wins: this one leaves the pool
489
+ // and serves only the handles it has until they release it.
490
+ const configured = key;
325
491
  connection.redirect.subscribe((redirect) => {
326
- if (!redirect || redirect.href === created.key)
492
+ const key = redirect ? poolKey(redirect.href, versions) : configured;
493
+ if (key === created.key)
327
494
  return;
328
495
  if (pool.get(created.key) === created)
329
496
  pool.delete(created.key);
330
- created.key = redirect.href;
497
+ created.key = key;
331
498
  if (!pool.has(created.key))
332
499
  pool.set(created.key, created);
333
500
  });
@@ -335,10 +502,9 @@ function acquire(key, linger) {
335
502
  pool.set(key, created);
336
503
  }
337
504
  const taken = entry;
338
- taken.linger = Time.Milli(Math.max(taken.linger, linger ?? LINGER_MS));
339
505
  taken.refs += 1;
340
506
  if (taken.timer !== undefined) {
341
- clearTimeout(taken.timer);
507
+ taken.timer();
342
508
  taken.timer = undefined;
343
509
  }
344
510
  let released = false;
@@ -351,14 +517,13 @@ function acquire(key, linger) {
351
517
  taken.refs -= 1;
352
518
  if (taken.refs > 0)
353
519
  return;
354
- taken.timer = setTimeout(() => {
520
+ // Don't hold a Node process open for a connection nobody is using.
521
+ taken.timer = after(LINGER, () => {
355
522
  if (pool.get(taken.key) === taken)
356
523
  pool.delete(taken.key);
357
524
  taken.connection.close();
358
525
  taken.origin.close();
359
- }, taken.linger);
360
- // Don't hold a Node process open for a connection nobody is using.
361
- taken.timer.unref?.();
526
+ }, { ref: false });
362
527
  },
363
528
  };
364
529
  }
@@ -373,8 +538,7 @@ export function resetShared() {
373
538
  const entries = [...pool.values()];
374
539
  pool.clear();
375
540
  for (const entry of entries) {
376
- if (entry.timer !== undefined)
377
- clearTimeout(entry.timer);
541
+ entry.timer?.();
378
542
  entry.connection.close();
379
543
  entry.origin.close();
380
544
  }