@moq/net 0.4.8 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (662) hide show
  1. package/README.md +7 -1
  2. package/announce.d.ts +1 -1
  3. package/announce.d.ts.map +1 -1
  4. package/announce.js +1 -1
  5. package/announce.js.map +1 -1
  6. package/announced.d.ts +51 -47
  7. package/announced.d.ts.map +1 -1
  8. package/announced.js +183 -31
  9. package/announced.js.map +1 -1
  10. package/announced.test-util.d.ts +2 -0
  11. package/announced.test-util.d.ts.map +1 -0
  12. package/announced.test-util.js +27 -0
  13. package/announced.test-util.js.map +1 -0
  14. package/auth.d.ts +64 -0
  15. package/auth.d.ts.map +1 -0
  16. package/auth.js +20 -0
  17. package/auth.js.map +1 -0
  18. package/auth_gate.d.ts +2 -0
  19. package/auth_gate.d.ts.map +1 -0
  20. package/auth_gate.js +24 -0
  21. package/auth_gate.js.map +1 -0
  22. package/auth_session.d.ts +49 -0
  23. package/auth_session.d.ts.map +1 -0
  24. package/auth_session.js +1097 -0
  25. package/auth_session.js.map +1 -0
  26. package/bandwidth.d.ts +129 -25
  27. package/bandwidth.d.ts.map +1 -1
  28. package/bandwidth.js +410 -138
  29. package/bandwidth.js.map +1 -1
  30. package/bandwidth_api.d.ts +1 -1
  31. package/bandwidth_api.d.ts.map +1 -1
  32. package/bandwidth_api.js +1 -1
  33. package/bandwidth_api.js.map +1 -1
  34. package/broadcast.d.ts +62 -36
  35. package/broadcast.d.ts.map +1 -1
  36. package/broadcast.js +556 -172
  37. package/broadcast.js.map +1 -1
  38. package/cache.d.ts +103 -0
  39. package/cache.d.ts.map +1 -0
  40. package/cache.js +254 -0
  41. package/cache.js.map +1 -0
  42. package/claim.test-util.d.ts +5 -0
  43. package/claim.test-util.d.ts.map +1 -0
  44. package/claim.test-util.js +13 -0
  45. package/claim.test-util.js.map +1 -0
  46. package/connection/accept.d.ts +20 -12
  47. package/connection/accept.d.ts.map +1 -1
  48. package/connection/accept.js +97 -129
  49. package/connection/accept.js.map +1 -1
  50. package/connection/browser.d.ts.map +1 -1
  51. package/connection/browser.js +28 -19
  52. package/connection/browser.js.map +1 -1
  53. package/connection/connect.d.ts +119 -23
  54. package/connection/connect.d.ts.map +1 -1
  55. package/connection/connect.js +535 -216
  56. package/connection/connect.js.map +1 -1
  57. package/connection/dials.d.ts +45 -0
  58. package/connection/dials.d.ts.map +1 -0
  59. package/connection/dials.js +109 -0
  60. package/connection/dials.js.map +1 -0
  61. package/connection/endpoint.d.ts +60 -0
  62. package/connection/endpoint.d.ts.map +1 -0
  63. package/connection/endpoint.js +114 -0
  64. package/connection/endpoint.js.map +1 -0
  65. package/connection/forward.d.ts +7 -1
  66. package/connection/forward.d.ts.map +1 -1
  67. package/connection/forward.js +265 -80
  68. package/connection/forward.js.map +1 -1
  69. package/connection/goaway.d.ts +16 -9
  70. package/connection/goaway.d.ts.map +1 -1
  71. package/connection/goaway.js +22 -108
  72. package/connection/goaway.js.map +1 -1
  73. package/connection/handshake.d.ts +32 -6
  74. package/connection/handshake.d.ts.map +1 -1
  75. package/connection/handshake.js +97 -20
  76. package/connection/handshake.js.map +1 -1
  77. package/connection/index.d.ts +3 -6
  78. package/connection/index.d.ts.map +1 -1
  79. package/connection/index.js +1 -2
  80. package/connection/index.js.map +1 -1
  81. package/connection/liveness.d.ts +14 -0
  82. package/connection/liveness.d.ts.map +1 -0
  83. package/connection/liveness.js +30 -0
  84. package/connection/liveness.js.map +1 -0
  85. package/connection/pool.d.ts +137 -58
  86. package/connection/pool.d.ts.map +1 -1
  87. package/connection/pool.js +281 -117
  88. package/connection/pool.js.map +1 -1
  89. package/connection/reload.d.ts +60 -12
  90. package/connection/reload.d.ts.map +1 -1
  91. package/connection/reload.js +859 -233
  92. package/connection/reload.js.map +1 -1
  93. package/connection/session.d.ts +91 -0
  94. package/connection/session.d.ts.map +1 -0
  95. package/connection/session.js +2 -0
  96. package/connection/session.js.map +1 -0
  97. package/connection/stats.d.ts +20 -11
  98. package/connection/stats.d.ts.map +1 -1
  99. package/connection/stats.js +64 -8
  100. package/connection/stats.js.map +1 -1
  101. package/connection/ticker.d.ts +4 -0
  102. package/connection/ticker.d.ts.map +1 -0
  103. package/connection/ticker.js +66 -0
  104. package/connection/ticker.js.map +1 -0
  105. package/connection/tokens.d.ts +2 -0
  106. package/connection/tokens.d.ts.map +1 -0
  107. package/connection/tokens.js +404 -0
  108. package/connection/tokens.js.map +1 -0
  109. package/connection/transport.d.ts.map +1 -1
  110. package/connection/transport.js +4 -4
  111. package/connection/transport.js.map +1 -1
  112. package/connection/withdrawal.d.ts +2 -0
  113. package/connection/withdrawal.d.ts.map +1 -0
  114. package/connection/withdrawal.js +23 -0
  115. package/connection/withdrawal.js.map +1 -0
  116. package/consume.js +213 -46
  117. package/consume.js.map +1 -1
  118. package/cover.d.ts +59 -0
  119. package/cover.d.ts.map +1 -0
  120. package/cover.js +375 -0
  121. package/cover.js.map +1 -0
  122. package/datagram.d.ts +70 -11
  123. package/datagram.d.ts.map +1 -1
  124. package/datagram.js +317 -1
  125. package/datagram.js.map +1 -1
  126. package/datagram_stream.d.ts +18 -0
  127. package/datagram_stream.d.ts.map +1 -0
  128. package/datagram_stream.js +67 -0
  129. package/datagram_stream.js.map +1 -0
  130. package/defined.test-util.d.ts +2 -0
  131. package/defined.test-util.d.ts.map +1 -0
  132. package/defined.test-util.js +7 -0
  133. package/defined.test-util.js.map +1 -0
  134. package/delivered.d.ts +75 -0
  135. package/delivered.d.ts.map +1 -0
  136. package/delivered.js +228 -0
  137. package/delivered.js.map +1 -0
  138. package/demand.d.ts +173 -0
  139. package/demand.d.ts.map +1 -0
  140. package/demand.js +582 -0
  141. package/demand.js.map +1 -0
  142. package/drops.d.ts +93 -0
  143. package/drops.d.ts.map +1 -0
  144. package/drops.js +283 -0
  145. package/drops.js.map +1 -0
  146. package/error.d.ts +120 -21
  147. package/error.d.ts.map +1 -1
  148. package/error.js +230 -37
  149. package/error.js.map +1 -1
  150. package/errors.d.ts +2 -2
  151. package/errors.d.ts.map +1 -1
  152. package/errors.js +2 -2
  153. package/errors.js.map +1 -1
  154. package/fill.d.ts +174 -0
  155. package/fill.d.ts.map +1 -0
  156. package/fill.js +760 -0
  157. package/fill.js.map +1 -0
  158. package/flate/decoder.d.ts +2 -0
  159. package/flate/decoder.d.ts.map +1 -0
  160. package/flate/decoder.js +63 -0
  161. package/flate/decoder.js.map +1 -0
  162. package/flate/encoder.d.ts +2 -0
  163. package/flate/encoder.d.ts.map +1 -0
  164. package/flate/encoder.js +64 -0
  165. package/flate/encoder.js.map +1 -0
  166. package/flate/group.d.ts +34 -0
  167. package/flate/group.d.ts.map +1 -0
  168. package/flate/group.js +140 -0
  169. package/flate/group.js.map +1 -0
  170. package/frame.d.ts +80 -0
  171. package/frame.d.ts.map +1 -0
  172. package/frame.js +296 -0
  173. package/frame.js.map +1 -0
  174. package/frame.test-util.d.ts +5 -0
  175. package/frame.test-util.d.ts.map +1 -0
  176. package/frame.test-util.js +9 -0
  177. package/frame.test-util.js.map +1 -0
  178. package/group.d.ts +108 -45
  179. package/group.d.ts.map +1 -1
  180. package/group.js +1616 -307
  181. package/group.js.map +1 -1
  182. package/group_api.d.ts +7 -0
  183. package/group_api.d.ts.map +1 -0
  184. package/group_api.js +7 -0
  185. package/group_api.js.map +1 -0
  186. package/hop.d.ts +62 -76
  187. package/hop.d.ts.map +1 -1
  188. package/hop.js +92 -64
  189. package/hop.js.map +1 -1
  190. package/identity.d.ts +39 -0
  191. package/identity.d.ts.map +1 -0
  192. package/identity.js +47 -0
  193. package/identity.js.map +1 -0
  194. package/ietf/active_count.d.ts +2 -0
  195. package/ietf/active_count.d.ts.map +1 -0
  196. package/ietf/active_count.js +30 -0
  197. package/ietf/active_count.js.map +1 -0
  198. package/ietf/aliases.js +69 -35
  199. package/ietf/aliases.js.map +1 -1
  200. package/ietf/cluster.d.ts +3 -3
  201. package/ietf/cluster.js +14 -62
  202. package/ietf/cluster.js.map +1 -1
  203. package/ietf/connection.d.ts +1 -31
  204. package/ietf/connection.d.ts.map +1 -1
  205. package/ietf/connection.js +305 -143
  206. package/ietf/connection.js.map +1 -1
  207. package/ietf/datagram.d.ts +60 -0
  208. package/ietf/datagram.d.ts.map +1 -0
  209. package/ietf/datagram.js +152 -0
  210. package/ietf/datagram.js.map +1 -0
  211. package/ietf/error.d.ts +3 -3
  212. package/ietf/error.js +82 -100
  213. package/ietf/error.js.map +1 -1
  214. package/ietf/fetch.d.ts +91 -35
  215. package/ietf/fetch.d.ts.map +1 -1
  216. package/ietf/fetch.js +172 -93
  217. package/ietf/fetch.js.map +1 -1
  218. package/ietf/filter.d.ts +20 -30
  219. package/ietf/filter.d.ts.map +1 -1
  220. package/ietf/filter.js +140 -171
  221. package/ietf/filter.js.map +1 -1
  222. package/ietf/goaway.d.ts +11 -9
  223. package/ietf/goaway.d.ts.map +1 -1
  224. package/ietf/goaway.js +22 -35
  225. package/ietf/goaway.js.map +1 -1
  226. package/ietf/hidden.js +1 -1
  227. package/ietf/hidden.js.map +1 -1
  228. package/ietf/index.d.ts +2 -14
  229. package/ietf/index.d.ts.map +1 -1
  230. package/ietf/index.js +4 -14
  231. package/ietf/index.js.map +1 -1
  232. package/ietf/join.d.ts +7 -0
  233. package/ietf/join.d.ts.map +1 -0
  234. package/ietf/join.js +234 -0
  235. package/ietf/join.js.map +1 -0
  236. package/ietf/message.d.ts +18 -2
  237. package/ietf/message.d.ts.map +1 -1
  238. package/ietf/message.js +60 -40
  239. package/ietf/message.js.map +1 -1
  240. package/ietf/message.test-util.d.ts +6 -0
  241. package/ietf/message.test-util.d.ts.map +1 -0
  242. package/ietf/message.test-util.js +13 -0
  243. package/ietf/message.test-util.js.map +1 -0
  244. package/ietf/namespace.d.ts +17 -3
  245. package/ietf/namespace.d.ts.map +1 -1
  246. package/ietf/namespace.js +78 -26
  247. package/ietf/namespace.js.map +1 -1
  248. package/ietf/object.d.ts +194 -32
  249. package/ietf/object.d.ts.map +1 -1
  250. package/ietf/object.js +405 -178
  251. package/ietf/object.js.map +1 -1
  252. package/ietf/parameters.d.ts +22 -42
  253. package/ietf/parameters.d.ts.map +1 -1
  254. package/ietf/parameters.js +260 -472
  255. package/ietf/parameters.js.map +1 -1
  256. package/ietf/priority.d.ts +17 -2
  257. package/ietf/priority.d.ts.map +1 -1
  258. package/ietf/priority.js +19 -4
  259. package/ietf/priority.js.map +1 -1
  260. package/ietf/properties.d.ts +5 -4
  261. package/ietf/properties.d.ts.map +1 -1
  262. package/ietf/properties.js +78 -48
  263. package/ietf/properties.js.map +1 -1
  264. package/ietf/publish.d.ts +22 -30
  265. package/ietf/publish.d.ts.map +1 -1
  266. package/ietf/publish.js +45 -139
  267. package/ietf/publish.js.map +1 -1
  268. package/ietf/publish_namespace.d.ts +46 -69
  269. package/ietf/publish_namespace.d.ts.map +1 -1
  270. package/ietf/publish_namespace.js +66 -184
  271. package/ietf/publish_namespace.js.map +1 -1
  272. package/ietf/publisher.js +1800 -600
  273. package/ietf/publisher.js.map +1 -1
  274. package/ietf/range.d.ts +2 -0
  275. package/ietf/range.d.ts.map +1 -0
  276. package/ietf/range.js +222 -0
  277. package/ietf/range.js.map +1 -0
  278. package/ietf/request.d.ts +3 -27
  279. package/ietf/request.d.ts.map +1 -1
  280. package/ietf/request.js +41 -78
  281. package/ietf/request.js.map +1 -1
  282. package/ietf/request_stream.d.ts +1 -6
  283. package/ietf/request_stream.d.ts.map +1 -1
  284. package/ietf/request_stream.js +306 -16
  285. package/ietf/request_stream.js.map +1 -1
  286. package/ietf/session.d.ts +41 -0
  287. package/ietf/session.d.ts.map +1 -0
  288. package/ietf/session.js +65 -0
  289. package/ietf/session.js.map +1 -0
  290. package/ietf/setup.d.ts +4 -29
  291. package/ietf/setup.d.ts.map +1 -1
  292. package/ietf/setup.js +6 -117
  293. package/ietf/setup.js.map +1 -1
  294. package/ietf/setup_options.d.ts +31 -0
  295. package/ietf/setup_options.d.ts.map +1 -0
  296. package/ietf/setup_options.js +138 -0
  297. package/ietf/setup_options.js.map +1 -0
  298. package/ietf/solicit.js +4 -14
  299. package/ietf/solicit.js.map +1 -1
  300. package/ietf/subscribe.d.ts +48 -41
  301. package/ietf/subscribe.d.ts.map +1 -1
  302. package/ietf/subscribe.js +118 -239
  303. package/ietf/subscribe.js.map +1 -1
  304. package/ietf/subscribe_namespace.d.ts +13 -76
  305. package/ietf/subscribe_namespace.d.ts.map +1 -1
  306. package/ietf/subscribe_namespace.js +30 -201
  307. package/ietf/subscribe_namespace.js.map +1 -1
  308. package/ietf/subscriber.js +1839 -536
  309. package/ietf/subscriber.js.map +1 -1
  310. package/ietf/token.js +105 -27
  311. package/ietf/token.js.map +1 -1
  312. package/ietf/track.d.ts +25 -22
  313. package/ietf/track.d.ts.map +1 -1
  314. package/ietf/track.js +48 -61
  315. package/ietf/track.js.map +1 -1
  316. package/ietf/version.d.ts +13 -42
  317. package/ietf/version.d.ts.map +1 -1
  318. package/ietf/version.js +22 -48
  319. package/ietf/version.js.map +1 -1
  320. package/implementation.d.ts +2 -0
  321. package/implementation.d.ts.map +1 -0
  322. package/implementation.js +5 -0
  323. package/implementation.js.map +1 -0
  324. package/index.d.ts +25 -10
  325. package/index.d.ts.map +1 -1
  326. package/index.js +19 -6
  327. package/index.js.map +1 -1
  328. package/internal.d.ts +1512 -64
  329. package/internal.d.ts.map +1 -1
  330. package/internal.js +557 -79
  331. package/internal.js.map +1 -1
  332. package/ledger.d.ts +23 -0
  333. package/ledger.d.ts.map +1 -0
  334. package/ledger.js +247 -0
  335. package/ledger.js.map +1 -0
  336. package/listing.d.ts +132 -0
  337. package/listing.d.ts.map +1 -0
  338. package/listing.js +486 -0
  339. package/listing.js.map +1 -0
  340. package/lite/announce.d.ts +124 -63
  341. package/lite/announce.d.ts.map +1 -1
  342. package/lite/announce.js +384 -158
  343. package/lite/announce.js.map +1 -1
  344. package/lite/announce_stream.d.ts +2 -0
  345. package/lite/announce_stream.d.ts.map +1 -0
  346. package/lite/announce_stream.js +92 -0
  347. package/lite/announce_stream.js.map +1 -0
  348. package/lite/answer.d.ts +22 -0
  349. package/lite/answer.d.ts.map +1 -0
  350. package/lite/answer.js +301 -0
  351. package/lite/answer.js.map +1 -0
  352. package/lite/auth.d.ts +45 -0
  353. package/lite/auth.d.ts.map +1 -0
  354. package/lite/auth.js +204 -0
  355. package/lite/auth.js.map +1 -0
  356. package/lite/compat.d.ts +31 -0
  357. package/lite/compat.d.ts.map +1 -0
  358. package/lite/compat.js +86 -0
  359. package/lite/compat.js.map +1 -0
  360. package/lite/connection.d.ts +1 -45
  361. package/lite/connection.d.ts.map +1 -1
  362. package/lite/connection.js +360 -77
  363. package/lite/connection.js.map +1 -1
  364. package/lite/datagram-end.d.ts +26 -0
  365. package/lite/datagram-end.d.ts.map +1 -0
  366. package/lite/datagram-end.js +30 -0
  367. package/lite/datagram-end.js.map +1 -0
  368. package/lite/datagram.d.ts +73 -8
  369. package/lite/datagram.d.ts.map +1 -1
  370. package/lite/datagram.js +144 -9
  371. package/lite/datagram.js.map +1 -1
  372. package/lite/duration.d.ts +6 -0
  373. package/lite/duration.d.ts.map +1 -0
  374. package/lite/duration.js +14 -0
  375. package/lite/duration.js.map +1 -0
  376. package/lite/error.d.ts +9 -0
  377. package/lite/error.d.ts.map +1 -0
  378. package/lite/error.js +24 -0
  379. package/lite/error.js.map +1 -0
  380. package/lite/fills.d.ts +162 -0
  381. package/lite/fills.d.ts.map +1 -0
  382. package/lite/fills.js +486 -0
  383. package/lite/fills.js.map +1 -0
  384. package/lite/fit.d.ts +49 -0
  385. package/lite/fit.d.ts.map +1 -0
  386. package/lite/fit.js +305 -0
  387. package/lite/fit.js.map +1 -0
  388. package/lite/goaway.d.ts +1 -1
  389. package/lite/goaway.d.ts.map +1 -1
  390. package/lite/goaway.js +5 -13
  391. package/lite/goaway.js.map +1 -1
  392. package/lite/group.d.ts +64 -13
  393. package/lite/group.d.ts.map +1 -1
  394. package/lite/group.js +108 -30
  395. package/lite/group.js.map +1 -1
  396. package/lite/identity.d.ts +25 -0
  397. package/lite/identity.d.ts.map +1 -0
  398. package/lite/identity.js +79 -0
  399. package/lite/identity.js.map +1 -0
  400. package/lite/index.d.ts +2 -1
  401. package/lite/index.d.ts.map +1 -1
  402. package/lite/index.js +2 -1
  403. package/lite/index.js.map +1 -1
  404. package/lite/message.d.ts +9 -1
  405. package/lite/message.d.ts.map +1 -1
  406. package/lite/message.js +28 -44
  407. package/lite/message.js.map +1 -1
  408. package/lite/priority.d.ts +9 -2
  409. package/lite/priority.d.ts.map +1 -1
  410. package/lite/priority.js +11 -105
  411. package/lite/priority.js.map +1 -1
  412. package/lite/probe.d.ts.map +1 -1
  413. package/lite/probe.js +9 -0
  414. package/lite/probe.js.map +1 -1
  415. package/lite/publisher.d.ts +10 -1
  416. package/lite/publisher.d.ts.map +1 -1
  417. package/lite/publisher.js +2548 -437
  418. package/lite/publisher.js.map +1 -1
  419. package/lite/routed.d.ts +59 -0
  420. package/lite/routed.d.ts.map +1 -0
  421. package/lite/routed.js +564 -0
  422. package/lite/routed.js.map +1 -0
  423. package/lite/session.d.ts +1 -27
  424. package/lite/session.d.ts.map +1 -1
  425. package/lite/session.js +0 -99
  426. package/lite/session.js.map +1 -1
  427. package/lite/setup.d.ts +29 -2
  428. package/lite/setup.d.ts.map +1 -1
  429. package/lite/setup.js +95 -21
  430. package/lite/setup.js.map +1 -1
  431. package/lite/stream.d.ts +5 -11
  432. package/lite/stream.d.ts.map +1 -1
  433. package/lite/stream.js +5 -1
  434. package/lite/stream.js.map +1 -1
  435. package/lite/subscribe.d.ts +475 -75
  436. package/lite/subscribe.d.ts.map +1 -1
  437. package/lite/subscribe.js +1373 -142
  438. package/lite/subscribe.js.map +1 -1
  439. package/lite/subscriber.d.ts +7 -44
  440. package/lite/subscriber.d.ts.map +1 -1
  441. package/lite/subscriber.js +3290 -515
  442. package/lite/subscriber.js.map +1 -1
  443. package/lite/track.d.ts +24 -9
  444. package/lite/track.d.ts.map +1 -1
  445. package/lite/track.js +116 -37
  446. package/lite/track.js.map +1 -1
  447. package/lite/tracks.d.ts +55 -0
  448. package/lite/tracks.d.ts.map +1 -0
  449. package/lite/tracks.js +114 -0
  450. package/lite/tracks.js.map +1 -0
  451. package/lite/version.d.ts +132 -24
  452. package/lite/version.d.ts.map +1 -1
  453. package/lite/version.js +378 -33
  454. package/lite/version.js.map +1 -1
  455. package/meta.d.ts +77 -0
  456. package/meta.d.ts.map +1 -0
  457. package/meta.js +130 -0
  458. package/meta.js.map +1 -0
  459. package/meta_api.d.ts +7 -0
  460. package/meta_api.d.ts.map +1 -0
  461. package/meta_api.js +7 -0
  462. package/meta_api.js.map +1 -0
  463. package/mint.d.ts +28 -0
  464. package/mint.d.ts.map +1 -0
  465. package/mint.js +66 -0
  466. package/mint.js.map +1 -0
  467. package/open.d.ts +63 -0
  468. package/open.d.ts.map +1 -0
  469. package/open.js +250 -0
  470. package/open.js.map +1 -0
  471. package/origin.d.ts +392 -140
  472. package/origin.d.ts.map +1 -1
  473. package/origin.js +2533 -686
  474. package/origin.js.map +1 -1
  475. package/package.json +8 -13
  476. package/path.d.ts +51 -51
  477. package/path.d.ts.map +1 -1
  478. package/path.js +210 -57
  479. package/path.js.map +1 -1
  480. package/payload.d.ts +33 -0
  481. package/payload.d.ts.map +1 -0
  482. package/payload.js +65 -0
  483. package/payload.js.map +1 -0
  484. package/prefix.d.ts +152 -0
  485. package/prefix.d.ts.map +1 -0
  486. package/prefix.js +349 -0
  487. package/prefix.js.map +1 -0
  488. package/priority.d.ts +8 -0
  489. package/priority.d.ts.map +1 -0
  490. package/priority.js +185 -0
  491. package/priority.js.map +1 -0
  492. package/queue.d.ts +2 -0
  493. package/queue.d.ts.map +1 -0
  494. package/queue.js +46 -0
  495. package/queue.js.map +1 -0
  496. package/ranges.d.ts +36 -0
  497. package/ranges.d.ts.map +1 -0
  498. package/ranges.js +312 -0
  499. package/ranges.js.map +1 -0
  500. package/rescale.d.ts +24 -0
  501. package/rescale.d.ts.map +1 -0
  502. package/rescale.js +39 -0
  503. package/rescale.js.map +1 -0
  504. package/resume.d.ts +55 -0
  505. package/resume.d.ts.map +1 -0
  506. package/resume.js +4173 -0
  507. package/resume.js.map +1 -0
  508. package/resume.test-util.d.ts +2 -0
  509. package/resume.test-util.d.ts.map +1 -0
  510. package/resume.test-util.js +25 -0
  511. package/resume.test-util.js.map +1 -0
  512. package/skips.d.ts +48 -0
  513. package/skips.d.ts.map +1 -0
  514. package/skips.js +182 -0
  515. package/skips.js.map +1 -0
  516. package/stream.d.ts +75 -37
  517. package/stream.d.ts.map +1 -1
  518. package/stream.js +236 -92
  519. package/stream.js.map +1 -1
  520. package/subscription.test-util.d.ts +2 -0
  521. package/subscription.test-util.d.ts.map +1 -0
  522. package/subscription.test-util.js +49 -0
  523. package/subscription.test-util.js.map +1 -0
  524. package/tail.d.ts +23 -14
  525. package/tail.d.ts.map +1 -1
  526. package/tail.js +224 -97
  527. package/tail.js.map +1 -1
  528. package/time.d.ts +41 -102
  529. package/time.d.ts.map +1 -1
  530. package/time.js +129 -91
  531. package/time.js.map +1 -1
  532. package/timed.d.ts +21 -0
  533. package/timed.d.ts.map +1 -0
  534. package/timed.js +2 -0
  535. package/timed.js.map +1 -0
  536. package/track.d.ts +577 -245
  537. package/track.d.ts.map +1 -1
  538. package/track.js +7306 -771
  539. package/track.js.map +1 -1
  540. package/track_api.d.ts +7 -0
  541. package/track_api.d.ts.map +1 -0
  542. package/track_api.js +7 -0
  543. package/track_api.js.map +1 -0
  544. package/util/abort.d.ts +1 -0
  545. package/util/abort.d.ts.map +1 -1
  546. package/util/abort.js +23 -1
  547. package/util/abort.js.map +1 -1
  548. package/util/announce.d.ts +4 -0
  549. package/util/announce.d.ts.map +1 -0
  550. package/util/announce.js +11 -0
  551. package/util/announce.js.map +1 -0
  552. package/util/bigint.d.ts +3 -0
  553. package/util/bigint.d.ts.map +1 -0
  554. package/util/bigint.js +8 -0
  555. package/util/bigint.js.map +1 -0
  556. package/util/change.d.ts +12 -0
  557. package/util/change.d.ts.map +1 -0
  558. package/util/change.js +18 -0
  559. package/util/change.js.map +1 -0
  560. package/util/deadline.d.ts +2 -0
  561. package/util/deadline.d.ts.map +1 -0
  562. package/util/deadline.js +108 -0
  563. package/util/deadline.js.map +1 -0
  564. package/util/decode_error.d.ts +3 -0
  565. package/util/decode_error.d.ts.map +1 -0
  566. package/util/decode_error.js +11 -0
  567. package/util/decode_error.js.map +1 -0
  568. package/util/demand.d.ts +8 -0
  569. package/util/demand.d.ts.map +1 -0
  570. package/util/demand.js +24 -0
  571. package/util/demand.js.map +1 -0
  572. package/util/given_up.d.ts +2 -0
  573. package/util/given_up.d.ts.map +1 -0
  574. package/util/given_up.js +101 -0
  575. package/util/given_up.js.map +1 -0
  576. package/util/hex.d.ts +6 -0
  577. package/util/hex.d.ts.map +1 -1
  578. package/util/hex.js +19 -4
  579. package/util/hex.js.map +1 -1
  580. package/util/key.d.ts +15 -0
  581. package/util/key.d.ts.map +1 -0
  582. package/util/key.js +38 -0
  583. package/util/key.js.map +1 -0
  584. package/util/limits.d.ts +2 -0
  585. package/util/limits.d.ts.map +1 -0
  586. package/util/limits.js +76 -0
  587. package/util/limits.js.map +1 -0
  588. package/util/observed.d.ts +23 -0
  589. package/util/observed.d.ts.map +1 -0
  590. package/util/observed.js +122 -0
  591. package/util/observed.js.map +1 -0
  592. package/util/sorted.d.ts +2 -0
  593. package/util/sorted.d.ts.map +1 -0
  594. package/util/sorted.js +149 -0
  595. package/util/sorted.js.map +1 -0
  596. package/util/timeout.d.ts +2 -1
  597. package/util/timeout.d.ts.map +1 -1
  598. package/util/timeout.js +13 -9
  599. package/util/timeout.js.map +1 -1
  600. package/util/timer.d.ts +2 -0
  601. package/util/timer.d.ts.map +1 -0
  602. package/util/timer.js +19 -0
  603. package/util/timer.js.map +1 -0
  604. package/util/utf8.d.ts +2 -0
  605. package/util/utf8.d.ts.map +1 -1
  606. package/util/utf8.js +7 -1
  607. package/util/utf8.js.map +1 -1
  608. package/util/varint.d.ts.map +1 -1
  609. package/util/varint.js +8 -1
  610. package/util/varint.js.map +1 -1
  611. package/util/watch.d.ts +8 -0
  612. package/util/watch.d.ts.map +1 -0
  613. package/util/watch.js +38 -0
  614. package/util/watch.js.map +1 -0
  615. package/util/yield.d.ts +2 -0
  616. package/util/yield.d.ts.map +1 -0
  617. package/util/yield.js +31 -0
  618. package/util/yield.js.map +1 -0
  619. package/varint.d.ts +0 -29
  620. package/varint.d.ts.map +1 -1
  621. package/varint.js +7 -28
  622. package/varint.js.map +1 -1
  623. package/varint_api.d.ts +7 -0
  624. package/varint_api.d.ts.map +1 -0
  625. package/varint_api.js +7 -0
  626. package/varint_api.js.map +1 -0
  627. package/version.d.ts +2 -0
  628. package/version.d.ts.map +1 -0
  629. package/version.js +4 -0
  630. package/version.js.map +1 -0
  631. package/window.d.ts +570 -0
  632. package/window.d.ts.map +1 -0
  633. package/window.js +1677 -0
  634. package/window.js.map +1 -0
  635. package/wire.d.ts +145 -30
  636. package/wire.d.ts.map +1 -1
  637. package/wire.js +27 -0
  638. package/wire.js.map +1 -1
  639. package/connection/established.d.ts +0 -53
  640. package/connection/established.d.ts.map +0 -1
  641. package/connection/established.js +0 -2
  642. package/connection/established.js.map +0 -1
  643. package/ietf/adapter.d.ts +0 -75
  644. package/ietf/adapter.d.ts.map +0 -1
  645. package/ietf/adapter.js +0 -699
  646. package/ietf/adapter.js.map +0 -1
  647. package/lite/datagram_stream.d.ts +0 -8
  648. package/lite/datagram_stream.d.ts.map +0 -1
  649. package/lite/datagram_stream.js +0 -43
  650. package/lite/datagram_stream.js.map +0 -1
  651. package/lite/fetch.d.ts +0 -28
  652. package/lite/fetch.d.ts.map +0 -1
  653. package/lite/fetch.js +0 -78
  654. package/lite/fetch.js.map +0 -1
  655. package/util/log.d.ts +0 -5
  656. package/util/log.d.ts.map +0 -1
  657. package/util/log.js +0 -16
  658. package/util/log.js.map +0 -1
  659. package/zod.d.ts +0 -13
  660. package/zod.d.ts.map +0 -1
  661. package/zod.js +0 -18
  662. package/zod.js.map +0 -1
package/delivered.js ADDED
@@ -0,0 +1,228 @@
1
+ /**
2
+ * The group keys a reader handed out, so it never hands one out twice. Mirrors
3
+ * `model::delivered` in `rs/moq-net`.
4
+ *
5
+ * @module
6
+ */
7
+ import { max, min } from "./util/key.js";
8
+ /**
9
+ * The group keys a reader handed out, as runs of consecutive keys.
10
+ *
11
+ * A reader stops expecting a group once it is past its budget, and counts everything below it
12
+ * as handed out (see {@link forgetBelow}). The run starting at 0 is that floor, so only the
13
+ * gaps above it cost memory.
14
+ */
15
+ export class Delivered {
16
+ // First and last key of each run, inclusive, sorted and never adjacent to each other.
17
+ #runs = [];
18
+ // The keys a fold counted as handed out that no range held then, so no budget judged them: a
19
+ // range added later owes each it holds (see {@link reopen}). Always within `#runs`, and never
20
+ // more runs than {@link foldBelow} leaves. Mirrors the Rust `Delivered::unjudged`.
21
+ #unjudged;
22
+ // How many times {@link remove} took keys back.
23
+ #removals = 0;
24
+ // The index of the run containing or preceding `key`, or -1 when none starts at or below it.
25
+ #below(key) {
26
+ let lo = 0;
27
+ let hi = this.#runs.length;
28
+ while (lo < hi) {
29
+ const mid = (lo + hi) >>> 1;
30
+ if (this.#runs[mid][0] <= key)
31
+ lo = mid + 1;
32
+ else
33
+ hi = mid;
34
+ }
35
+ return lo - 1;
36
+ }
37
+ /** Whether `key` was handed out, or is below the floor. */
38
+ has(key) {
39
+ const index = this.#below(key);
40
+ return index >= 0 && key <= this.#runs[index][1];
41
+ }
42
+ /** Whether every key in `[start, end)` was handed out, or is below the floor. */
43
+ covers(start, end) {
44
+ if (start >= end)
45
+ return true;
46
+ const index = this.#below(start);
47
+ return index >= 0 && end - 1n <= this.#runs[index][1];
48
+ }
49
+ /** Record `key` as handed out; `false` when it already was. */
50
+ add(key) {
51
+ if (this.has(key))
52
+ return false;
53
+ this.addRun(key, key + 1n);
54
+ return true;
55
+ }
56
+ /** Record every key in `[start, end)` as handed out. */
57
+ addRun(start, end) {
58
+ if (start >= end)
59
+ return;
60
+ this.#unjudged?.remove(start, end);
61
+ // The runs it overlaps or touches, `first` through `last`, merge into one.
62
+ let first = this.#below(start - 1n);
63
+ if (first < 0 || this.#runs[first][1] < start - 1n)
64
+ first++;
65
+ const last = this.#below(end);
66
+ if (last < first) {
67
+ this.#runs.splice(first, 0, [start, end - 1n]);
68
+ return;
69
+ }
70
+ const merged = [min(start, this.#runs[first][0]), max(end - 1n, this.#runs[last][1])];
71
+ this.#runs.splice(first, last - first + 1, merged);
72
+ }
73
+ /** Forget that any key in `[start, end)` was handed out, splitting the runs it cuts. */
74
+ remove(start, end) {
75
+ if (start >= end)
76
+ return;
77
+ this.#removals++;
78
+ this.#unjudged?.remove(start, end);
79
+ // The runs reaching into it, `first` through `last`, keep only what lies outside it.
80
+ let first = this.#below(start);
81
+ if (first < 0 || this.#runs[first][1] < start)
82
+ first++;
83
+ const last = this.#below(end - 1n);
84
+ if (last < first)
85
+ return;
86
+ const kept = [];
87
+ if (this.#runs[first][0] < start)
88
+ kept.push([this.#runs[first][0], start - 1n]);
89
+ if (this.#runs[last][1] >= end)
90
+ kept.push([end, this.#runs[last][1]]);
91
+ this.#runs.splice(first, last - first + 1, ...kept);
92
+ }
93
+ /** A record of what either this or `other` handed out. */
94
+ union(other) {
95
+ const union = new Delivered();
96
+ union.#runs = this.#runs.map(([first, last]) => [first, last]);
97
+ for (const [first, last] of other.#runs)
98
+ union.addRun(first, last + 1n);
99
+ return union;
100
+ }
101
+ /** The parts of `[start, end)` not handed out, in order. */
102
+ *gaps(start, end) {
103
+ let next = start;
104
+ for (let index = Math.max(this.#below(start), 0); index < this.#runs.length && next < end; index++) {
105
+ const [first, last] = this.#runs[index];
106
+ if (first > next)
107
+ yield { start: next, end: min(first, end) };
108
+ next = max(next, last + 1n);
109
+ }
110
+ if (next < end)
111
+ yield { start: next, end };
112
+ }
113
+ /**
114
+ * Count every key below `floor` as handed out, as a fold past the reader's budget does: each gap
115
+ * it closes that `judged` doesn't hold, or every one while the ranges are still being placed, a
116
+ * range added later that holds it owes again. Mirrors the Rust `Delivered::fold_below`.
117
+ *
118
+ * So that ranges moving to disjoint groups leave no more runs than they hold, what lies between
119
+ * two runs it remembers that `judged` doesn't hold joins them: what ranges added over it later
120
+ * hand out may then include a group handed out before, which the same identity makes harmless,
121
+ * rather than miss one never handed out.
122
+ */
123
+ foldBelow(floor, judged) {
124
+ const gaps = [...this.gaps(this.runEnd(0n) ?? 0n, floor)];
125
+ for (const gap of gaps) {
126
+ let from = gap.start;
127
+ for (const held of judged?.placed(gap.start, gap.end) ?? []) {
128
+ if (held.start > from)
129
+ this.#unjudge(from, held.start);
130
+ from = max(from, held.end);
131
+ }
132
+ if (from < gap.end)
133
+ this.#unjudge(from, gap.end);
134
+ }
135
+ this.forgetBelow(floor);
136
+ // Placed ranges say what joins; a fold while they're placed is followed by one that is.
137
+ const unjudged = this.#unjudged;
138
+ if (!judged || gaps.length === 0 || !unjudged || unjudged.#runs.length < 2)
139
+ return;
140
+ const [start, end] = [unjudged.#runs[0][0], unjudged.#runs[unjudged.#runs.length - 1][1] + 1n];
141
+ let from = start;
142
+ for (const held of [...judged.placed(start, end), { start: end, end }]) {
143
+ if (held.start > from) {
144
+ unjudged.addRun(from, held.start);
145
+ // Not what a reopen gave back since, which is owed rather than counted handed out.
146
+ for (const gap of [...this.gaps(from, held.start)])
147
+ unjudged.remove(gap.start, gap.end);
148
+ }
149
+ from = max(from, held.end);
150
+ }
151
+ }
152
+ // Remember `[start, end)` as folded unjudged.
153
+ #unjudge(start, end) {
154
+ this.#unjudged ??= new Delivered();
155
+ this.#unjudged.addRun(start, end);
156
+ }
157
+ /** Whether a fold counted `key` as handed out while no range held it. */
158
+ unjudged(key) {
159
+ return this.#unjudged?.has(key) ?? false;
160
+ }
161
+ /**
162
+ * Take back each key a fold counted as handed out unjudged that `judged` now holds, so it is
163
+ * owed again.
164
+ *
165
+ * The keys it gave back before that `judged` no longer holds, and any other gap it doesn't, it
166
+ * counts as handed out unjudged again first, so the gaps never outlive the ranges that owed
167
+ * them, as the Rust `Record::retire` bounds them. A live join still waiting gets back what it
168
+ * holds once it places, as any range added later does.
169
+ */
170
+ reopen(judged) {
171
+ const unjudged = this.#unjudged;
172
+ if (!unjudged)
173
+ return;
174
+ const held = unjudged.#runs.flatMap(([first, last]) => judged.placed(first, last + 1n));
175
+ if (held.length === 0)
176
+ return;
177
+ const last = this.#runs.at(-1);
178
+ if (last) {
179
+ for (const gap of [...this.gaps(0n, last[1])]) {
180
+ let from = gap.start;
181
+ for (const run of [...judged.placed(gap.start, gap.end), { start: gap.end, end: gap.end }]) {
182
+ if (run.start > from) {
183
+ this.addRun(from, run.start);
184
+ this.#unjudge(from, run.start);
185
+ }
186
+ from = max(from, run.end);
187
+ }
188
+ }
189
+ }
190
+ for (const run of held)
191
+ this.remove(run.start, run.end);
192
+ }
193
+ /** Count every key below `floor` as handed out. */
194
+ forgetBelow(floor) {
195
+ if (floor <= 0n)
196
+ return;
197
+ // Every run starting at or below the floor joins it, including one starting right at it.
198
+ const index = this.#below(floor);
199
+ const last = max(floor - 1n, index >= 0 ? this.#runs[index][1] : 0n);
200
+ this.#runs.splice(0, index + 1, [0n, last]);
201
+ }
202
+ /** The lowest key handed out above a gap. */
203
+ aboveGap() {
204
+ const first = this.#runs[0];
205
+ if (!first)
206
+ return undefined;
207
+ return first[0] === 0n ? this.#runs[1]?.[0] : first[0];
208
+ }
209
+ /** One past the highest key handed out. */
210
+ end() {
211
+ const last = this.#runs.at(-1);
212
+ return last && last[1] + 1n;
213
+ }
214
+ /** One past the last key of the run holding `key`, if it was handed out. */
215
+ runEnd(key) {
216
+ const index = this.#below(key);
217
+ return index >= 0 && key <= this.#runs[index][1] ? this.#runs[index][1] + 1n : undefined;
218
+ }
219
+ /** How many times a key was taken back, so a memo of what it covers knows to start over. */
220
+ get removals() {
221
+ return this.#removals;
222
+ }
223
+ /** How many runs it holds: one per gap, plus the floor, plus one per run folded unjudged. */
224
+ get runs() {
225
+ return this.#runs.length + (this.#unjudged?.runs ?? 0);
226
+ }
227
+ }
228
+ //# sourceMappingURL=delivered.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivered.js","sourceRoot":"","sources":["../src/delivered.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AASzC;;;;;;GAMG;AACH,MAAM,OAAO,SAAS;IACrB,sFAAsF;IACtF,KAAK,GAAuB,EAAE,CAAC;IAC/B,6FAA6F;IAC7F,8FAA8F;IAC9F,mFAAmF;IACnF,SAAS,CAAwB;IACjC,gDAAgD;IAChD,SAAS,GAAG,CAAC,CAAC;IAEd,6FAA6F;IAC7F,MAAM,CAAC,GAAW;QACjB,IAAI,EAAE,GAAG,CAAC,CAAC;QACX,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QAC3B,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC;YAChB,MAAM,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;YAC5B,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG;gBAAE,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;;gBACvC,EAAE,GAAG,GAAG,CAAC;QACf,CAAC;QACD,OAAO,EAAE,GAAG,CAAC,CAAC;IACf,CAAC;IAED,2DAA2D;IAC3D,GAAG,CAAC,GAAW;QACd,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/B,OAAO,KAAK,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,iFAAiF;IACjF,MAAM,CAAC,KAAa,EAAE,GAAW;QAChC,IAAI,KAAK,IAAI,GAAG;YAAE,OAAO,IAAI,CAAC;QAC9B,MAAM,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,IAAI,IAAI;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC;IACxD,CAAC;CACD","sourcesContent":["/**\n * The group keys a reader handed out, so it never hands one out twice. Mirrors\n * `model::delivered` in `rs/moq-net`.\n *\n * @module\n */\n\nimport { max, min } from \"./util/key.ts\";\nimport type { Run } from \"./window.ts\";\n\n/** The groups a reader's ranges hold, as a fold judges a gap by. */\nexport interface Judged {\n\t/** The runs the placed ranges name from `from` up to the exclusive `end`, lowest first. */\n\tplaced(from: bigint, end: bigint): Run[];\n}\n\n/**\n * The group keys a reader handed out, as runs of consecutive keys.\n *\n * A reader stops expecting a group once it is past its budget, and counts everything below it\n * as handed out (see {@link forgetBelow}). The run starting at 0 is that floor, so only the\n * gaps above it cost memory.\n */\nexport class Delivered {\n\t// First and last key of each run, inclusive, sorted and never adjacent to each other.\n\t#runs: [bigint, bigint][] = [];\n\t// The keys a fold counted as handed out that no range held then, so no budget judged them: a\n\t// range added later owes each it holds (see {@link reopen}). Always within `#runs`, and never\n\t// more runs than {@link foldBelow} leaves. Mirrors the Rust `Delivered::unjudged`.\n\t#unjudged: Delivered | undefined;\n\t// How many times {@link remove} took keys back.\n\t#removals = 0;\n\n\t// The index of the run containing or preceding `key`, or -1 when none starts at or below it.\n\t#below(key: bigint): number {\n\t\tlet lo = 0;\n\t\tlet hi = this.#runs.length;\n\t\twhile (lo < hi) {\n\t\t\tconst mid = (lo + hi) >>> 1;\n\t\t\tif (this.#runs[mid][0] <= key) lo = mid + 1;\n\t\t\telse hi = mid;\n\t\t}\n\t\treturn lo - 1;\n\t}\n\n\t/** Whether `key` was handed out, or is below the floor. */\n\thas(key: bigint): boolean {\n\t\tconst index = this.#below(key);\n\t\treturn index >= 0 && key <= this.#runs[index][1];\n\t}\n\n\t/** Whether every key in `[start, end)` was handed out, or is below the floor. */\n\tcovers(start: bigint, end: bigint): boolean {\n\t\tif (start >= end) return true;\n\t\tconst index = this.#below(start);\n\t\treturn index >= 0 && end - 1n <= this.#runs[index][1];\n\t}\n\n\t/** Record `key` as handed out; `false` when it already was. */\n\tadd(key: bigint): boolean {\n\t\tif (this.has(key)) return false;\n\t\tthis.addRun(key, key + 1n);\n\t\treturn true;\n\t}\n\n\t/** Record every key in `[start, end)` as handed out. */\n\taddRun(start: bigint, end: bigint): void {\n\t\tif (start >= end) return;\n\t\tthis.#unjudged?.remove(start, end);\n\t\t// The runs it overlaps or touches, `first` through `last`, merge into one.\n\t\tlet first = this.#below(start - 1n);\n\t\tif (first < 0 || this.#runs[first][1] < start - 1n) first++;\n\t\tconst last = this.#below(end);\n\t\tif (last < first) {\n\t\t\tthis.#runs.splice(first, 0, [start, end - 1n]);\n\t\t\treturn;\n\t\t}\n\t\tconst merged: [bigint, bigint] = [min(start, this.#runs[first][0]), max(end - 1n, this.#runs[last][1])];\n\t\tthis.#runs.splice(first, last - first + 1, merged);\n\t}\n\n\t/** Forget that any key in `[start, end)` was handed out, splitting the runs it cuts. */\n\tremove(start: bigint, end: bigint): void {\n\t\tif (start >= end) return;\n\t\tthis.#removals++;\n\t\tthis.#unjudged?.remove(start, end);\n\t\t// The runs reaching into it, `first` through `last`, keep only what lies outside it.\n\t\tlet first = this.#below(start);\n\t\tif (first < 0 || this.#runs[first][1] < start) first++;\n\t\tconst last = this.#below(end - 1n);\n\t\tif (last < first) return;\n\t\tconst kept: [bigint, bigint][] = [];\n\t\tif (this.#runs[first][0] < start) kept.push([this.#runs[first][0], start - 1n]);\n\t\tif (this.#runs[last][1] >= end) kept.push([end, this.#runs[last][1]]);\n\t\tthis.#runs.splice(first, last - first + 1, ...kept);\n\t}\n\n\t/** A record of what either this or `other` handed out. */\n\tunion(other: Delivered): Delivered {\n\t\tconst union = new Delivered();\n\t\tunion.#runs = this.#runs.map(([first, last]) => [first, last]);\n\t\tfor (const [first, last] of other.#runs) union.addRun(first, last + 1n);\n\t\treturn union;\n\t}\n\n\t/** The parts of `[start, end)` not handed out, in order. */\n\t*gaps(start: bigint, end: bigint): Generator<{ start: bigint; end: bigint }> {\n\t\tlet next = start;\n\t\tfor (let index = Math.max(this.#below(start), 0); index < this.#runs.length && next < end; index++) {\n\t\t\tconst [first, last] = this.#runs[index];\n\t\t\tif (first > next) yield { start: next, end: min(first, end) };\n\t\t\tnext = max(next, last + 1n);\n\t\t}\n\t\tif (next < end) yield { start: next, end };\n\t}\n\n\t/**\n\t * Count every key below `floor` as handed out, as a fold past the reader's budget does: each gap\n\t * it closes that `judged` doesn't hold, or every one while the ranges are still being placed, a\n\t * range added later that holds it owes again. Mirrors the Rust `Delivered::fold_below`.\n\t *\n\t * So that ranges moving to disjoint groups leave no more runs than they hold, what lies between\n\t * two runs it remembers that `judged` doesn't hold joins them: what ranges added over it later\n\t * hand out may then include a group handed out before, which the same identity makes harmless,\n\t * rather than miss one never handed out.\n\t */\n\tfoldBelow(floor: bigint, judged: Judged | undefined): void {\n\t\tconst gaps = [...this.gaps(this.runEnd(0n) ?? 0n, floor)];\n\t\tfor (const gap of gaps) {\n\t\t\tlet from = gap.start;\n\t\t\tfor (const held of judged?.placed(gap.start, gap.end) ?? []) {\n\t\t\t\tif (held.start > from) this.#unjudge(from, held.start);\n\t\t\t\tfrom = max(from, held.end);\n\t\t\t}\n\t\t\tif (from < gap.end) this.#unjudge(from, gap.end);\n\t\t}\n\t\tthis.forgetBelow(floor);\n\t\t// Placed ranges say what joins; a fold while they're placed is followed by one that is.\n\t\tconst unjudged = this.#unjudged;\n\t\tif (!judged || gaps.length === 0 || !unjudged || unjudged.#runs.length < 2) return;\n\t\tconst [start, end] = [unjudged.#runs[0][0], unjudged.#runs[unjudged.#runs.length - 1][1] + 1n];\n\t\tlet from = start;\n\t\tfor (const held of [...judged.placed(start, end), { start: end, end }]) {\n\t\t\tif (held.start > from) {\n\t\t\t\tunjudged.addRun(from, held.start);\n\t\t\t\t// Not what a reopen gave back since, which is owed rather than counted handed out.\n\t\t\t\tfor (const gap of [...this.gaps(from, held.start)]) unjudged.remove(gap.start, gap.end);\n\t\t\t}\n\t\t\tfrom = max(from, held.end);\n\t\t}\n\t}\n\n\t// Remember `[start, end)` as folded unjudged.\n\t#unjudge(start: bigint, end: bigint): void {\n\t\tthis.#unjudged ??= new Delivered();\n\t\tthis.#unjudged.addRun(start, end);\n\t}\n\n\t/** Whether a fold counted `key` as handed out while no range held it. */\n\tunjudged(key: bigint): boolean {\n\t\treturn this.#unjudged?.has(key) ?? false;\n\t}\n\n\t/**\n\t * Take back each key a fold counted as handed out unjudged that `judged` now holds, so it is\n\t * owed again.\n\t *\n\t * The keys it gave back before that `judged` no longer holds, and any other gap it doesn't, it\n\t * counts as handed out unjudged again first, so the gaps never outlive the ranges that owed\n\t * them, as the Rust `Record::retire` bounds them. A live join still waiting gets back what it\n\t * holds once it places, as any range added later does.\n\t */\n\treopen(judged: Judged): void {\n\t\tconst unjudged = this.#unjudged;\n\t\tif (!unjudged) return;\n\t\tconst held = unjudged.#runs.flatMap(([first, last]) => judged.placed(first, last + 1n));\n\t\tif (held.length === 0) return;\n\t\tconst last = this.#runs.at(-1);\n\t\tif (last) {\n\t\t\tfor (const gap of [...this.gaps(0n, last[1])]) {\n\t\t\t\tlet from = gap.start;\n\t\t\t\tfor (const run of [...judged.placed(gap.start, gap.end), { start: gap.end, end: gap.end }]) {\n\t\t\t\t\tif (run.start > from) {\n\t\t\t\t\t\tthis.addRun(from, run.start);\n\t\t\t\t\t\tthis.#unjudge(from, run.start);\n\t\t\t\t\t}\n\t\t\t\t\tfrom = max(from, run.end);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const run of held) this.remove(run.start, run.end);\n\t}\n\n\t/** Count every key below `floor` as handed out. */\n\tforgetBelow(floor: bigint): void {\n\t\tif (floor <= 0n) return;\n\t\t// Every run starting at or below the floor joins it, including one starting right at it.\n\t\tconst index = this.#below(floor);\n\t\tconst last = max(floor - 1n, index >= 0 ? this.#runs[index][1] : 0n);\n\t\tthis.#runs.splice(0, index + 1, [0n, last]);\n\t}\n\n\t/** The lowest key handed out above a gap. */\n\taboveGap(): bigint | undefined {\n\t\tconst first = this.#runs[0];\n\t\tif (!first) return undefined;\n\t\treturn first[0] === 0n ? this.#runs[1]?.[0] : first[0];\n\t}\n\n\t/** One past the highest key handed out. */\n\tend(): bigint | undefined {\n\t\tconst last = this.#runs.at(-1);\n\t\treturn last && last[1] + 1n;\n\t}\n\n\t/** One past the last key of the run holding `key`, if it was handed out. */\n\trunEnd(key: bigint): bigint | undefined {\n\t\tconst index = this.#below(key);\n\t\treturn index >= 0 && key <= this.#runs[index][1] ? this.#runs[index][1] + 1n : undefined;\n\t}\n\n\t/** How many times a key was taken back, so a memo of what it covers knows to start over. */\n\tget removals(): number {\n\t\treturn this.#removals;\n\t}\n\n\t/** How many runs it holds: one per gap, plus the floor, plus one per run folded unjudged. */\n\tget runs(): number {\n\t\treturn this.#runs.length + (this.#unjudged?.runs ?? 0);\n\t}\n}\n"]}
package/demand.d.ts ADDED
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Incremental demand: each subscriber's preferences keyed so an edit costs what it names, and the
3
+ * aggregate across subscribers counted so a change costs what it moved. Mirrors the Rust
4
+ * `track::demand`.
5
+ *
6
+ * @module
7
+ */
8
+ import { type Dispose, type Getter, Signal } from "@moq/signals";
9
+ import type { Range, Subscription } from "./track.ts";
10
+ import { type Joining, type Policy } from "./window.ts";
11
+ /**
12
+ * A change to a subscriber's preferences that edits its ranges by key: the ranges keyed `retire`
13
+ * go, then each of `add` joins under its key, and the rest stay as they resolved. A key added
14
+ * again replaces its range in place; any other key added is past every key held. Costs the ranges
15
+ * it names, however many the subscriber holds. Mirrors the Rust `Edit`.
16
+ */
17
+ export interface Edit {
18
+ retire: readonly bigint[];
19
+ add: readonly (readonly [bigint, Range])[];
20
+ /** The group each live join among `add` was already placed at, by its key: see {@link Subscription.placed}. */
21
+ placed?: ReadonlyMap<bigint, bigint>;
22
+ }
23
+ /** A range as a subscriber holds it, with the group it was {@link Subscription.placed | placed} at. Mirrors the Rust `Held`. */
24
+ export interface Held {
25
+ range: Range;
26
+ placed?: bigint;
27
+ }
28
+ /** Whether two placements by index agree, none being the same as an empty one. */
29
+ export declare function samePlaced(a: ReadonlyMap<number, bigint> | undefined, b: ReadonlyMap<number, bigint> | undefined): boolean;
30
+ /**
31
+ * A live join a received copy's readers wait on, by its lag in milliseconds (null for no lag limit) and its end, with the
32
+ * widest max in milliseconds one waits with, as a budget, and the newest answer tick any of them saw
33
+ * before it began waiting: only an answer recorded after that is fresh for every one of them.
34
+ * Mirrors the Rust `JoinAsk`.
35
+ */
36
+ export interface JoinAsk {
37
+ min: number | null;
38
+ end: bigint | undefined;
39
+ budget: number;
40
+ since: number;
41
+ }
42
+ /** A change to one subscriber's preferences, as an aggregate counts it. */
43
+ export interface Change {
44
+ /** Whether the subscriber was counted before the change. */
45
+ before?: boolean;
46
+ /** Whether the subscriber is counted after it. */
47
+ after?: boolean;
48
+ /** The ranges `before` held and `after` doesn't, counted. */
49
+ gone: readonly Held[];
50
+ /** The ranges `after` holds and `before` doesn't, counted. */
51
+ came: readonly Held[];
52
+ }
53
+ /** How many join answers were recorded: see {@link answered}. Mirrors the Rust `join_tick`. */
54
+ export declare function joinTick(): number;
55
+ /**
56
+ * Note an answer to a live join recorded, returning its tick: greater than that of every range
57
+ * added before. Mirrors the Rust `answered`.
58
+ */
59
+ export declare function answered(): number;
60
+ /**
61
+ * A subscriber's preferences, the ranges keyed so an {@link Edit} costs only what it names. Reads
62
+ * as the {@link Subscription} last given, its ranges in key order, materialized only when read.
63
+ * Mirrors the Rust `Prefs`.
64
+ */
65
+ export declare class Prefs implements Getter<Subscription | undefined> {
66
+ #private;
67
+ /** Bumped on every change, so a reader wakes without reading the ranges. */
68
+ readonly revision: Signal<number>;
69
+ /** Told each change, so the aggregates this subscriber joins move by what changed. */
70
+ onChange?: (change: Change) => void;
71
+ /**
72
+ * Whether the ranges last changed by a retune alone, each kept under its key with another policy
73
+ * or live join max, rather than replaced or restated.
74
+ */
75
+ retuned: boolean;
76
+ /** Start with `subscription`, already checked and defaulted, or none. */
77
+ constructor(subscription?: Subscription);
78
+ /** The preferences as a {@link Subscription}, costing every range once per change. */
79
+ peek(): Subscription | undefined;
80
+ changed(): Promise<Subscription | undefined>;
81
+ changed(fn: (value: Subscription | undefined) => void): Dispose;
82
+ subscribe(fn: (value: Subscription | undefined) => void): Dispose;
83
+ watch(fn: (value: Subscription | undefined) => void): Dispose;
84
+ /** Whether any preferences were given yet, without reading the ranges. */
85
+ given(): boolean;
86
+ /**
87
+ * The priority and order these ranges ask as a whole, without reading the ranges: the highest
88
+ * priority, newest first if any range at it is. Mirrors the Rust `Prefs::policy`.
89
+ */
90
+ policy(): Policy;
91
+ /** Every range with its key, in key order. */
92
+ entries(): IterableIterator<[bigint, Range]>;
93
+ /** Every range in key order, with the group each was placed at. Mirrors the Rust `Prefs::held`. */
94
+ held(): Held[];
95
+ /**
96
+ * How a received copy places the live join range keyed `key`: where it was already placed, or
97
+ * from an answer recorded since it was added. Mirrors the Rust `Prefs::joining`.
98
+ */
99
+ joining(key: bigint): Joining;
100
+ /**
101
+ * The join tick the live join range keyed `key` was added at, 0 for another: a received copy
102
+ * places it only from an answer recorded since, the live edge having moved since any earlier one.
103
+ * Mirrors the Rust `Prefs::since`.
104
+ */
105
+ since(key: bigint): number;
106
+ /**
107
+ * Note each live join range keyed in `since` as added at its tick instead, such as the one a
108
+ * front's reader added it at, which the copy it reads asked for: an answer recorded since then
109
+ * places it. Other ranges are left as they are. Returns the keys whose tick moved. Mirrors the
110
+ * Rust `Preferences::stamp`.
111
+ */
112
+ stamp(since: Iterable<readonly [bigint, number]>): bigint[];
113
+ /** Wake every reader, as a change would, without changing anything. */
114
+ touch(): void;
115
+ /**
116
+ * Replace every preference, already checked and defaulted, rekeying the ranges by position when
117
+ * they change. Ranges that change only their policy or a live join's max keep their keys, so each
118
+ * stays where it resolved, and come back as the keyed ranges they now read. Without `retune`, as a
119
+ * subscription restated whole, only a change of policy alone keeps them: a restated live join
120
+ * whose max changed is placed afresh. Returns whether the ranges changed, and how; nothing
121
+ * happens unless something did. Mirrors the Rust `Prefs::replace`.
122
+ */
123
+ set(next: Subscription, retune?: boolean): false | "replaced" | (readonly [bigint, Range])[];
124
+ /** Apply `edit`, costing the ranges it names. Returns whether the ranges changed. */
125
+ edit(edit: Edit): boolean;
126
+ }
127
+ /**
128
+ * The aggregate of every subscriber's preferences, counted so a change costs what it moved:
129
+ * the widest staleness budget, and the union of the ranges, each kept at its own priority and
130
+ * order. Read as a {@link Subscription}, materialized only when read. Mirrors the Rust
131
+ * `Subscriptions`.
132
+ */
133
+ export declare class Subscriptions implements Getter<Subscription | undefined> {
134
+ #private;
135
+ /**
136
+ * Move one subscriber from `before` to `after`, either undefined for none, its ranges by
137
+ * `gone` and `came`. Returns whether the aggregate changed.
138
+ */
139
+ replace({ before, after, gone, came }: Change): boolean;
140
+ /**
141
+ * Register or withdraw a reader waiting on `time`. The first or last reader changes {@link asks}
142
+ * and wakes the aggregate's watchers. Mirrors the Rust `Subscriptions::ask`.
143
+ */
144
+ ask(time: bigint, refuse: (time: bigint, error: Error) => void, waits: boolean): void;
145
+ /** Refuse a probe only for the readers already waiting at `time`. A later reader asks anew. */
146
+ refuseTime(time: bigint, error: Error): void;
147
+ /**
148
+ * The time starts a received copy's readers wait on, lowest first: its session asks its
149
+ * upstream to place each with a range of its own. Mirrors the Rust `Subscription::asks`.
150
+ */
151
+ asks(): bigint[];
152
+ /**
153
+ * Count a reader waiting on `join` once more when `waits`, else once less. Returns whether
154
+ * {@link joins} changed, which wakes every watcher as any change to the aggregate does. Mirrors
155
+ * the Rust `Subscriptions::join`.
156
+ */
157
+ join(join: JoinAsk, waits: boolean): boolean;
158
+ /**
159
+ * The live joins a received copy's readers wait on, each with the widest max one waits with and
160
+ * the newest answer tick one saw before it began: its session asks its upstream to place each
161
+ * with a range of its own. Mirrors the Rust `Subscription::joins`.
162
+ */
163
+ joins(): JoinAsk[];
164
+ /** The widest staleness budget in milliseconds any range asks under, without reading the ranges. */
165
+ maxDelay(): number;
166
+ /** The aggregate, costing the union's length once per change. */
167
+ peek(): Subscription | undefined;
168
+ changed(): Promise<Subscription | undefined>;
169
+ changed(fn: (value: Subscription | undefined) => void): Dispose;
170
+ subscribe(fn: (value: Subscription | undefined) => void): Dispose;
171
+ watch(fn: (value: Subscription | undefined) => void): Dispose;
172
+ }
173
+ //# sourceMappingURL=demand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demand.d.ts","sourceRoot":"","sources":["../src/demand.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGjE,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAGN,KAAK,OAAO,EAGZ,KAAK,MAAM,EAUX,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,WAAW,IAAI;IACpB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,GAAG,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;IAC3C,+GAA+G;IAC/G,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED,gIAAgI;AAChI,MAAM,WAAW,IAAI;IACpB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAeD,kFAAkF;AAClF,wBAAgB,UAAU,CACzB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC1C,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GACxC,OAAO,CAIT;AAED;;;;;GAKG;AACH,MAAM,WAAW,OAAO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