@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
@@ -0,0 +1,59 @@
1
+ import { type GetPromise, type Getter } from "@moq/signals";
2
+ import type * as announce from "../announced.ts";
3
+ import type { Grant } from "../auth.ts";
4
+ import type { Goaway } from "../connection/goaway.ts";
5
+ import type { BroadcastCache } from "../consume.ts";
6
+ import { Cost, WireRoute } from "../hop.ts";
7
+ import * as Path from "../path.ts";
8
+ import { type Slots } from "../util/limits.ts";
9
+ import { type AnnounceBroadcast } from "./announce.ts";
10
+ import type { Version } from "./version.ts";
11
+ /** What a `routes()` reader asked for. */
12
+ export interface Request {
13
+ /** The prefix the reader lists: claims at or beneath it. */
14
+ prefix: Path.Valid;
15
+ /** Also report claims with a `.`-prefixed segment below the prefix. */
16
+ hidden: boolean;
17
+ /** Also report claims above the prefix, whose subtree covers it. */
18
+ covering: boolean;
19
+ /** Report each identity's claim at a path rather than the best one. */
20
+ claims: boolean;
21
+ }
22
+ /** What the session's route layer is built on. */
23
+ export interface Session {
24
+ quic: WebTransport;
25
+ version: Version;
26
+ consumes: BroadcastCache;
27
+ /** The session's announce cap: one slot per live claim. */
28
+ slots: Slots;
29
+ /** Rank a route last once the peer sent GOAWAY. */
30
+ drained(route: WireRoute): WireRoute;
31
+ /** What crossing this link adds to a claim's cost, once known. */
32
+ cost(): Promise<Cost>;
33
+ /** This link's rank, which every claim through it carries at most. */
34
+ priority: number;
35
+ goaway?: GetPromise<Goaway>;
36
+ /** Our grant: the peer answers a prefix wider than what it lets us subscribe to region by region. */
37
+ grant?: Getter<Grant | undefined>;
38
+ /** Send one message on this session's Announce Stream. */
39
+ send(msg: AnnounceBroadcast): Promise<void>;
40
+ }
41
+ /** The claims a lite-07 session's peer sends, shared by every reader of the session. */
42
+ export declare class Routed {
43
+ #private;
44
+ constructor(session: Session);
45
+ /** Feed `announced` what the stream carries for `request`, until its last consumer leaves. */
46
+ attach(announced: announce.Producer, request: Request): void;
47
+ /** This side finished its stream: the prefixes asked of the peer stay as they are. */
48
+ silence(): void;
49
+ /** The peer finished its stream: it is leaving, its claims go, and it answers nothing more. */
50
+ finish(): void;
51
+ /** The session ended: every reader ends with `err`, and every claim goes. */
52
+ close(err?: Error): void;
53
+ /**
54
+ * Apply one message the peer sent on its Announce Stream as a publisher. Once the peer left,
55
+ * whatever it still sends about the claims that ended with it is moot.
56
+ */
57
+ receive(msg: AnnounceBroadcast): Promise<void>;
58
+ }
59
+ //# sourceMappingURL=routed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routed.d.ts","sourceRoot":"","sources":["../../src/lite/routed.ts"],"names":[],"mappings":"AAYA,OAAO,EAAgB,KAAK,UAAU,EAAE,KAAK,MAAM,EAAQ,MAAM,cAAc,CAAC;AAChF,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAe,SAAS,EAAE,MAAM,WAAW,CAAC;AAGzD,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,EAAW,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAEN,KAAK,iBAAiB,EAKtB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,0CAA0C;AAC1C,MAAM,WAAW,OAAO;IACvB,4DAA4D;IAC5D,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC;IACnB,uEAAuE;IACvE,MAAM,EAAE,OAAO,CAAC;IAChB,oEAAoE;IACpE,QAAQ,EAAE,OAAO,CAAC;IAClB,uEAAuE;IACvE,MAAM,EAAE,OAAO,CAAC;CAChB;AAED,kDAAkD;AAClD,MAAM,WAAW,OAAO;IACvB,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,cAAc,CAAC;IACzB,2DAA2D;IAC3D,KAAK,EAAE,KAAK,CAAC;IACb,mDAAmD;IACnD,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IACrC,kEAAkE;IAClE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC5B,qGAAqG;IACrG,KAAK,CAAC,EAAE,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IAClC,0DAA0D;IAC1D,IAAI,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAmDD,wFAAwF;AACxF,qBAAa,MAAM;;IAgClB,YAAY,OAAO,EAAE,OAAO,EAgB3B;IAyBD,8FAA8F;IAC9F,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAqB3D;IAsFD,sFAAsF;IACtF,OAAO,IAAI,IAAI,CAGd;IAED,+FAA+F;IAC/F,MAAM,IAAI,IAAI,CAIb;IAED,6EAA6E;IAC7E,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAavB;IAiND;;;OAGG;IACG,OAAO,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmEnD;CACD"}
package/lite/routed.js ADDED
@@ -0,0 +1,564 @@
1
+ // Lite-07: what the peer sends on its Announce Stream as a publisher, and the prefixes this
2
+ // session asks it for on its own.
3
+ //
4
+ // Every `routes()` reader of the session shares the one stream. The session asks the peer only
5
+ // for the covering set of what its readers want, no prefix at or below another, edited in place
6
+ // one ANNOUNCE_REQUEST at a time, and each reader is fed from the claims the stream carries,
7
+ // presented under the reader's own prefix as the peer would present them to a request for it.
8
+ //
9
+ // This node is an endpoint: it declares no Node ID, so the peer sends it claims and never routes.
10
+ // Each claim is one identity's at a path, with what the peer's own reader shows of it: its cost,
11
+ // how far above the path it was made, and whether a route still reaches it.
12
+ import { race } from "@moq/signals";
13
+ import { error, ProtocolViolation, peerEnded } from "../error.js";
14
+ import { Cost, routesEqual, WireRoute } from "../hop.js";
15
+ import { arrival, bestOfTier, coveringPrefixes, hiddenBelow } from "../internal.js";
16
+ import * as Path from "../path.js";
17
+ import { SlotMap } from "../util/limits.js";
18
+ import { AnnounceHistory, requestFits, requestParts, } from "./announce.js";
19
+ // The most a claim at `path` can be above it: a claim above the session's root covers the whole
20
+ // of what the peer shows. Mirrors rs/moq-net.
21
+ const checkAbove = (path, above) => {
22
+ if (above > BigInt(Path.parts(path).length))
23
+ throw new ProtocolViolation(`a claim at ${path} cannot be ${above} segments above it`);
24
+ };
25
+ /** The claims a lite-07 session's peer sends, shared by every reader of the session. */
26
+ export class Routed {
27
+ #session;
28
+ #readers = new Set();
29
+ /** The prefixes asked of the peer. */
30
+ #asked = new Map();
31
+ #nextPrefix = 0n;
32
+ /** The ANNOUNCE_REQUEST the peer has not answered yet. */
33
+ #editing;
34
+ /** The peer finished its stream: it answers nothing more. */
35
+ #finished = false;
36
+ /** This side finished its stream: it asks for nothing more. */
37
+ #silent = false;
38
+ /** The grant showed a reader more since the last edit: the next goes even when it changes
39
+ * nothing, since its ANNOUNCE_OK follows what the change shows under a wider prefix. */
40
+ #regranted = false;
41
+ /** What our grant lets us subscribe to, as last seen. */
42
+ #granted;
43
+ // Each live claim holds one of the session's announce slots.
44
+ #claims;
45
+ // The claims shown at each path, oldest first.
46
+ #byPath = new Map();
47
+ #history = new AnnounceHistory();
48
+ // What crossing this link costs, known before the first claim arrives.
49
+ #cost;
50
+ // Set once the session lets go of its claims, which then show nothing anew.
51
+ #closing = false;
52
+ #stopDrain;
53
+ #stopGrant;
54
+ constructor(session) {
55
+ this.#session = session;
56
+ this.#claims = new SlotMap(session.slots);
57
+ // A draining peer ranks its claims last from the GOAWAY itself.
58
+ this.#stopDrain = session.goaway?.changed(() => {
59
+ if (this.#closing)
60
+ return;
61
+ // As one change, so a path its claims cover never passes through another route.
62
+ session.consumes.batch(() => {
63
+ for (const [id, live] of this.#claims)
64
+ this.#serve(id, live, false, false);
65
+ });
66
+ });
67
+ this.#granted = session.grant?.peek()?.subscribe;
68
+ this.#stopGrant = session.grant?.subscribe(() => {
69
+ this.#ask();
70
+ this.#release();
71
+ });
72
+ }
73
+ // Note a grant change, read as it is set rather than when its listeners run, so a reader
74
+ // attached between the two waits too. What it newly shows within a prefix asked may already be
75
+ // in the peer's answer, unheard here: the next edit goes, since its answer follows the change,
76
+ // and the readers there and any reader arriving before that answer wait for it. Elsewhere, and
77
+ // on a narrowing, nothing new can arrive, and a reader stays synced. Mirrors rs/moq-net.
78
+ #regrant() {
79
+ const next = this.#session.grant?.peek()?.subscribe;
80
+ const granted = this.#granted;
81
+ if (next === granted || (next && granted?.equals(next)))
82
+ return;
83
+ this.#granted = next;
84
+ const regions = gained(granted, next);
85
+ const overlaps = (prefix) => regions.some((region) => Path.hasPrefix(region, prefix) || Path.hasPrefix(prefix, region));
86
+ if ([...this.#asked.values()].some((asked) => overlaps(asked.path)))
87
+ this.#regranted = true;
88
+ for (const reader of this.#readers) {
89
+ if (!overlaps(reader.prefix))
90
+ continue;
91
+ this.#regranted = true;
92
+ if (!reader.synced)
93
+ continue;
94
+ reader.synced = false;
95
+ reader.announced.behind();
96
+ }
97
+ }
98
+ /** Feed `announced` what the stream carries for `request`, until its last consumer leaves. */
99
+ attach(announced, request) {
100
+ if (this.#closing) {
101
+ announced.close();
102
+ return;
103
+ }
104
+ const reader = { ...request, announced, reported: new Map(), synced: false };
105
+ this.#readers.add(reader);
106
+ // What the stream already carries shows before the reader counts as synced.
107
+ const paths = new Set();
108
+ for (const path of this.#byPath.keys()) {
109
+ const at = presentedAt(reader, path);
110
+ if (at !== undefined)
111
+ paths.add(at);
112
+ }
113
+ for (const path of paths)
114
+ this.#refresh(reader, path, false);
115
+ this.#ask();
116
+ this.#release();
117
+ void race([announced.closed]).then(() => {
118
+ if (!this.#readers.delete(reader))
119
+ return;
120
+ this.#ask();
121
+ this.#release();
122
+ });
123
+ }
124
+ // The covering set of what the readers want: no prefix at or below another. A prefix asks for
125
+ // hidden claims when a reader beneath it does, or sits behind a hidden segment itself.
126
+ #wanted() {
127
+ const heads = new Set();
128
+ for (const reader of this.#readers)
129
+ heads.add(reader.prefix);
130
+ const covering = (head) => {
131
+ let top = head;
132
+ for (const above of coveringPrefixes(head))
133
+ if (heads.has(above))
134
+ top = above;
135
+ return top;
136
+ };
137
+ const wanted = new Map();
138
+ for (const reader of this.#readers) {
139
+ const top = covering(reader.prefix);
140
+ const hidden = reader.hidden || hiddenBelow(top, reader.prefix);
141
+ wanted.set(top, (wanted.get(top) ?? false) || hidden);
142
+ }
143
+ // The whole set has to fit one request: past that, everything is asked for at the root.
144
+ if (!requestFits(wanted.keys(), this.#session.version)) {
145
+ const hidden = [...this.#readers].some((reader) => reader.hidden || hiddenBelow(Path.empty(), reader.prefix));
146
+ return new Map([[Path.empty(), hidden]]);
147
+ }
148
+ return wanted;
149
+ }
150
+ // The edit that brings what is asked of the peer in line with what the readers want.
151
+ #edit() {
152
+ const wanted = this.#wanted();
153
+ const remove = [];
154
+ for (const [id, asked] of this.#asked) {
155
+ if (wanted.get(asked.path) === asked.hidden)
156
+ wanted.delete(asked.path);
157
+ else
158
+ remove.push(id);
159
+ }
160
+ return { remove, add: [...wanted].map(([prefix, hidden]) => ({ prefix, hidden })) };
161
+ }
162
+ // Ask the peer for what the readers now want, one edit at a time.
163
+ #ask() {
164
+ this.#regrant();
165
+ if (this.#editing || this.#finished || this.#silent || this.#closing)
166
+ return;
167
+ const { remove, add } = this.#edit();
168
+ if (remove.length === 0 && add.length === 0 && !this.#regranted)
169
+ return;
170
+ this.#regranted = false;
171
+ const added = [];
172
+ for (const { prefix, hidden } of add) {
173
+ const id = this.#nextPrefix++;
174
+ this.#asked.set(id, { path: prefix, hidden, live: false, synced: false });
175
+ added.push(id);
176
+ }
177
+ this.#editing = { remove, add: added };
178
+ console.debug(`announced: remove=${remove.join(",")} add=${add.map(({ prefix }) => prefix).join(",")}`);
179
+ // However large, the edit goes whole, in as many messages as it takes. A peer that stopped
180
+ // the stream is leaving, which the session's own handling of the stop ends these routes for.
181
+ for (const part of requestParts(remove, add, this.#session.version)) {
182
+ this.#session.send(part).catch((err) => {
183
+ if (!peerEnded(this.#session.quic, err))
184
+ this.close(error(err));
185
+ });
186
+ }
187
+ }
188
+ // Let each reader see its prefix synced once its answer is in: the peer answered every
189
+ // request, and sent the initial set of each prefix asked for it.
190
+ #release() {
191
+ const done = this.#finished || this.#silent;
192
+ if (!done) {
193
+ this.#ask();
194
+ if (this.#editing)
195
+ return;
196
+ const { remove, add } = this.#edit();
197
+ if (remove.length > 0 || add.length > 0)
198
+ return;
199
+ }
200
+ for (const reader of this.#readers) {
201
+ if (reader.synced)
202
+ continue;
203
+ const answered = [...this.#asked.values()].every((asked) => asked.synced ||
204
+ !(Path.hasPrefix(asked.path, reader.prefix) || Path.hasPrefix(reader.prefix, asked.path)));
205
+ if (!done && !answered)
206
+ continue;
207
+ reader.synced = true;
208
+ reader.announced.synced();
209
+ }
210
+ }
211
+ /** This side finished its stream: the prefixes asked of the peer stay as they are. */
212
+ silence() {
213
+ this.#silent = true;
214
+ this.#release();
215
+ }
216
+ /** The peer finished its stream: it is leaving, its claims go, and it answers nothing more. */
217
+ finish() {
218
+ this.#finished = true;
219
+ for (const id of [...this.#claims.keys()])
220
+ this.#end(id, true);
221
+ this.#release();
222
+ }
223
+ /** The session ended: every reader ends with `err`, and every claim goes. */
224
+ close(err) {
225
+ if (this.#closing)
226
+ return;
227
+ this.#closing = true;
228
+ this.#stopDrain?.();
229
+ this.#stopGrant?.();
230
+ for (const live of this.#claims.values()) {
231
+ if (live.path !== undefined && live.taken)
232
+ this.#session.consumes.withdraw(live.path, live.owner);
233
+ }
234
+ this.#claims.clear();
235
+ this.#byPath.clear();
236
+ const readers = [...this.#readers];
237
+ this.#readers.clear();
238
+ for (const reader of readers)
239
+ reader.announced.close(err);
240
+ }
241
+ #claim(id) {
242
+ const found = this.#claims.get(id);
243
+ if (!found)
244
+ throw new ProtocolViolation(`unknown announce id ${id}`);
245
+ return found;
246
+ }
247
+ // A claim through this session: its cost plus this link's; ranked below every available claim
248
+ // while the peer or a node on its way drains, then by the lowest priority on its way, this
249
+ // link's included; and unavailable while no route reaches it.
250
+ #candidate(live, claim) {
251
+ if (this.#cost === undefined)
252
+ throw new Error("a claim before the link was priced");
253
+ return this.#session.drained(WireRoute.normalize({
254
+ identity: live.identity,
255
+ epoch: claim.epoch,
256
+ cost: Cost.charged(claim.cost, this.#cost),
257
+ claimed: true,
258
+ priority: Math.min(this.#session.priority, claim.priority),
259
+ above: claim.above,
260
+ draining: claim.draining || undefined,
261
+ available: !claim.unavailable,
262
+ }));
263
+ }
264
+ // Whether `live` is shown: at a path this node can hold, on a run that was told available.
265
+ #shown(live) {
266
+ return live.path !== undefined && live.taken;
267
+ }
268
+ // Bring what the session shows of the claim `id` in line with `live`, which `was` shown or
269
+ // not before the change. `restart` marks another epoch, whose consumes subscribe fresh, and
270
+ // `lost` a claim let go rather than withdrawn.
271
+ #serve(id, live, restart, lost, was = this.#shown(live)) {
272
+ if (live.path === undefined)
273
+ return;
274
+ const consumes = this.#session.consumes;
275
+ let ids = this.#byPath.get(live.path);
276
+ if (this.#shown(live)) {
277
+ if (!ids) {
278
+ ids = new Set();
279
+ this.#byPath.set(live.path, ids);
280
+ }
281
+ // A claim shown anew or restarted iterates last, as the newest; a re-price keeps its
282
+ // place, as the consume cache does. See mostSpecific.
283
+ if (!was || restart) {
284
+ ids.delete(id);
285
+ live.ref = {};
286
+ arrival(live.ref);
287
+ }
288
+ ids.add(id);
289
+ consumes.announce(live.path, live.owner, this.#candidate(live, live.claim), restart);
290
+ }
291
+ else if (was) {
292
+ ids?.delete(id);
293
+ if (ids?.size === 0)
294
+ this.#byPath.delete(live.path);
295
+ consumes.withdraw(live.path, live.owner);
296
+ }
297
+ else {
298
+ return;
299
+ }
300
+ this.#touch(live.path, lost);
301
+ }
302
+ // The claim `id` is gone: its publisher withdrew it unless `lost`.
303
+ #end(id, lost) {
304
+ const live = this.#claim(id);
305
+ this.#history.end(id);
306
+ this.#claims.delete(id);
307
+ const was = this.#shown(live);
308
+ live.taken = false;
309
+ this.#serve(id, live, false, lost, was);
310
+ }
311
+ // The claims `reader` is shown at `path`, each with where it is filed and how it is shown:
312
+ // those at the path itself, and at the reader's own prefix each claim at or above it, as the
313
+ // peer presents a claim covering more than a requested prefix: that many segments more above
314
+ // the path, so a claim exactly there still outranks it. Oldest first at each filing.
315
+ #candidates(reader, path) {
316
+ const candidates = [];
317
+ for (const at of path === reader.prefix ? coveringPrefixes(path) : [path]) {
318
+ const by = BigInt(Path.parts(path).length - Path.parts(at).length);
319
+ for (const id of this.#byPath.get(at) ?? []) {
320
+ const live = this.#claim(id);
321
+ const filed = this.#candidate(live, live.claim);
322
+ const shown = by === 0n ? filed : this.#candidate(live, { ...live.claim, above: live.claim.above + by });
323
+ candidates.push({ prefix: at, ref: live.ref, filed, shown });
324
+ }
325
+ }
326
+ return candidates;
327
+ }
328
+ // Report to `reader` the best claim at `path`, or with `claims` each identity's, and each
329
+ // one's end. `lost` marks the claims leaving as let go rather than withdrawn, so they go
330
+ // offline rather than ending.
331
+ #refresh(reader, path, lost) {
332
+ const { announced } = reader;
333
+ if (announced.closed.peek() !== undefined)
334
+ return;
335
+ // Keyed by identity with `claims`, and otherwise the one key `undefined`.
336
+ const now = new Map();
337
+ if (visible(reader, path)) {
338
+ const candidates = this.#candidates(reader, path);
339
+ // At the reader's own prefix, the same pick a consume of `path` makes from the cache,
340
+ // ranked where each claim is filed, newest first at each filing. Beneath it, the best
341
+ // claim filed at `path`, as the origin's listing shows each row: each carries its Above,
342
+ // so the reader holds every filing. Ranked from the claims alone, never walking the
343
+ // prefixes they are not filed at, so a refresh stays linear in the claims shown.
344
+ const depths = new Map();
345
+ const pick = (among) => {
346
+ // Alone, it is the pick: nothing supersedes or outranks it.
347
+ if (among.length === 1)
348
+ return among[0];
349
+ const orders = new Map();
350
+ const filed = [];
351
+ // Newest first at each filing, as mostSpecific numbers them.
352
+ for (let i = among.length - 1; i >= 0; i--) {
353
+ const candidate = among[i];
354
+ const { prefix, ref } = candidate;
355
+ let depth = depths.get(prefix);
356
+ if (depth === undefined) {
357
+ depth = Path.parts(prefix).length;
358
+ depths.set(prefix, depth);
359
+ }
360
+ const order = orders.get(prefix) ?? 0;
361
+ orders.set(prefix, order + 1);
362
+ filed.push({ prefix, depth, order, arrival: arrival(ref), candidate, route: candidate.filed });
363
+ }
364
+ return bestOfTier(path, filed)?.candidate;
365
+ };
366
+ if (reader.claims) {
367
+ // Each identity's pick, as a consume pinned to it makes, from one pass over the claims.
368
+ const identities = new Map();
369
+ for (const candidate of candidates) {
370
+ const own = identities.get(candidate.filed.identity);
371
+ if (own)
372
+ own.push(candidate);
373
+ else
374
+ identities.set(candidate.filed.identity, [candidate]);
375
+ }
376
+ for (const [identity, own] of identities) {
377
+ const best = pick(own);
378
+ if (best)
379
+ now.set(identity, best.shown);
380
+ }
381
+ }
382
+ else {
383
+ const best = pick(candidates);
384
+ if (best)
385
+ now.set(undefined, best.shown);
386
+ }
387
+ }
388
+ const prev = reader.reported.get(path) ?? new Map();
389
+ // Arrivals first, so a reader sees a claim replaced rather than the path gone between.
390
+ for (const [key, next] of now) {
391
+ const was = prev.get(key);
392
+ if (was && routesEqual(was, next))
393
+ continue;
394
+ const restart = !!was && (was.identity !== next.identity || was.epoch !== next.epoch);
395
+ const kind = !was ? "start" : restart ? "restart" : "update";
396
+ console.debug(`announced: broadcast=${path} ${kind} identity=${next.identity}`);
397
+ announced.append({ prefix: path, kind, route: next });
398
+ }
399
+ for (const [key, was] of prev) {
400
+ if (now.has(key))
401
+ continue;
402
+ console.debug(`announced: broadcast=${path} active=false lost=${lost}`);
403
+ announced.append({ prefix: path, kind: lost ? "offline" : "end", route: was });
404
+ }
405
+ if (now.size > 0)
406
+ reader.reported.set(path, now);
407
+ else
408
+ reader.reported.delete(path);
409
+ }
410
+ // Report the claims at `path` to every reader it shows under: at the path itself for a reader
411
+ // above it, and at the reader's own prefix for one below.
412
+ #touch(path, lost) {
413
+ for (const reader of this.#readers) {
414
+ const at = presentedAt(reader, path);
415
+ if (at !== undefined)
416
+ this.#refresh(reader, at, lost);
417
+ }
418
+ }
419
+ // ANNOUNCE_OK: the last edit takes effect on the peer's stream. Both ends drop every claim
420
+ // within a prefix it removed, and the peer tells again what an added prefix covers.
421
+ #ok() {
422
+ const editing = this.#editing;
423
+ if (!editing)
424
+ throw new ProtocolViolation("ANNOUNCE_OK with no ANNOUNCE_REQUEST unanswered");
425
+ this.#editing = undefined;
426
+ const removed = [];
427
+ for (const id of editing.remove) {
428
+ const asked = this.#asked.get(id);
429
+ if (asked)
430
+ removed.push(asked.path);
431
+ this.#asked.delete(id);
432
+ }
433
+ // Whether a prefix in effect before the edit survives it: the peer's claims within one stay.
434
+ const survives = [...this.#asked.values()].some((asked) => asked.live);
435
+ for (const id of editing.add) {
436
+ const asked = this.#asked.get(id);
437
+ if (!asked)
438
+ throw new Error("an added prefix");
439
+ asked.live = true;
440
+ }
441
+ if (removed.length > 0) {
442
+ for (const [id, live] of [...this.#claims]) {
443
+ const { path } = live;
444
+ // A claim whose path could not be resolved lies in a prefix this side cannot name.
445
+ // The peer may still hold it, and ends it by its id, so it goes only when no earlier
446
+ // prefix is left for it to lie in.
447
+ const within = path === undefined ? !survives : removed.some((prefix) => Path.hasPrefix(prefix, path));
448
+ // The peer never ended it: it only stopped telling this session.
449
+ if (within)
450
+ this.#end(id, true);
451
+ }
452
+ }
453
+ // What the readers want may have moved while the peer answered.
454
+ this.#ask();
455
+ this.#release();
456
+ }
457
+ /**
458
+ * Apply one message the peer sent on its Announce Stream as a publisher. Once the peer left,
459
+ * whatever it still sends about the claims that ended with it is moot.
460
+ */
461
+ async receive(msg) {
462
+ if (this.#closing || this.#finished)
463
+ return;
464
+ switch (msg.status) {
465
+ case "ok":
466
+ this.#ok();
467
+ break;
468
+ case "synced": {
469
+ const asked = this.#asked.get(msg.prefix);
470
+ if (!asked?.live)
471
+ throw new ProtocolViolation(`SYNCED for unknown Prefix ID ${msg.prefix}`);
472
+ if (asked.synced)
473
+ throw new ProtocolViolation(`duplicate SYNCED for Prefix ID ${msg.prefix}`);
474
+ asked.synced = true;
475
+ this.#release();
476
+ break;
477
+ }
478
+ case "request":
479
+ // The peer's own request is answered by the publisher half.
480
+ break;
481
+ case "start": {
482
+ // Every claim, and every change to one, arrives after the first start.
483
+ this.#cost ??= await this.#session.cost();
484
+ if (this.#closing || this.#finished)
485
+ return;
486
+ // Every claim's path is relative to the session, whichever requested prefix it lies in.
487
+ const path = this.#history.start(msg);
488
+ const id = this.#history.next - 1n;
489
+ if (path === undefined)
490
+ console.warn(`refusing a claim: claim=${id} reason=path`);
491
+ else
492
+ checkAbove(path, msg.claim.above);
493
+ for (const other of path === undefined ? [] : (this.#byPath.get(path) ?? [])) {
494
+ if (this.#claim(other).identity === msg.identity)
495
+ throw new ProtocolViolation(`${path} claimed twice for one identity`);
496
+ }
497
+ const live = {
498
+ path,
499
+ identity: msg.identity,
500
+ claim: msg.claim,
501
+ taken: false,
502
+ owner: {},
503
+ ref: {},
504
+ };
505
+ this.#claims.set(id, live);
506
+ live.taken = !msg.claim.unavailable;
507
+ this.#serve(id, live, false, false, false);
508
+ break;
509
+ }
510
+ case "change": {
511
+ const live = this.#claim(msg.id);
512
+ if (live.path !== undefined)
513
+ checkAbove(live.path, msg.claim.above);
514
+ const was = this.#shown(live);
515
+ const run = live.claim.epoch !== msg.claim.epoch || live.claim.above !== msg.claim.above;
516
+ const restart = live.claim.epoch !== msg.claim.epoch;
517
+ live.claim = msg.claim;
518
+ // The bit counts only on a run this node already holds: another run is taken once
519
+ // it is told available, and the one held before it is lost.
520
+ live.taken = run ? !msg.claim.unavailable : live.taken || !msg.claim.unavailable;
521
+ this.#serve(msg.id, live, restart, true, was);
522
+ break;
523
+ }
524
+ case "endedId":
525
+ this.#end(msg.id, msg.lost ?? false);
526
+ break;
527
+ case "skipped":
528
+ case "active":
529
+ case "update":
530
+ case "ended":
531
+ // Lite-07 names every claim's identity, ends one by its Announce ID, and decoding
532
+ // refuses an unknown type, which only lite-06 skips.
533
+ throw new ProtocolViolation(`${msg.status} announcement on lite-07`);
534
+ }
535
+ }
536
+ }
537
+ // Whether `reader` reports a claim at `path`. A path holding a `*` is kept on record but never
538
+ // reported: no origin accepts one, and an older subscriber would read it as a wildcard.
539
+ function visible(reader, path) {
540
+ const matches = Path.hasPrefix(reader.prefix, path) || (reader.covering && Path.hasPrefix(path, reader.prefix));
541
+ return matches && !path.includes("*") && (reader.hidden || !hiddenBelow(reader.prefix, path));
542
+ }
543
+ // Where `reader` is shown a claim at `path`: there when it lies within the reader's prefix, at
544
+ // the prefix itself when it covers more, and nowhere otherwise.
545
+ function presentedAt(reader, path) {
546
+ if (Path.hasPrefix(reader.prefix, path))
547
+ return path;
548
+ return Path.hasPrefix(path, reader.prefix) ? reader.prefix : undefined;
549
+ }
550
+ // The prefixes holding what the grant `next` shows that `before` did not: each of its prefixes
551
+ // `before` does not cover, less any too long for a path, which covers nothing a peer could name.
552
+ // Empty for a narrowing. Mirrors rs/moq-net's `Permit::beyond`.
553
+ function gained(before, next) {
554
+ if (!before)
555
+ return [];
556
+ if (!next)
557
+ return [Path.empty()];
558
+ return next
559
+ .toArray()
560
+ .filter((prefix) => !before.matches(prefix.text))
561
+ .map((prefix) => prefix.text)
562
+ .filter((region) => Path.check(region) === undefined);
563
+ }
564
+ //# sourceMappingURL=routed.js.map