tardis-machine 18.9.2 → 18.10.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 (432) hide show
  1. package/dist/helpers.d.ts +0 -1
  2. package/dist/helpers.d.ts.map +1 -1
  3. package/dist/helpers.js +0 -1
  4. package/dist/helpers.js.map +1 -1
  5. package/dist/http/healthCheck.d.ts.map +1 -1
  6. package/dist/http/index.js +3 -3
  7. package/dist/http/replay.d.ts.map +1 -1
  8. package/dist/http/replay.js +2 -2
  9. package/dist/http/replaynormalized.d.ts.map +1 -1
  10. package/dist/http/replaynormalized.js +2 -2
  11. package/dist/index.js +1 -1
  12. package/dist/tardismachine.d.ts.map +1 -1
  13. package/dist/tardismachine.js +4 -4
  14. package/dist/tardismachine.js.map +1 -1
  15. package/dist/ws/index.js +3 -3
  16. package/dist/ws/replay.d.ts.map +1 -1
  17. package/dist/ws/replay.js +8 -17
  18. package/dist/ws/replay.js.map +1 -1
  19. package/dist/ws/replaynormalized.d.ts.map +1 -1
  20. package/dist/ws/replaynormalized.js +5 -11
  21. package/dist/ws/replaynormalized.js.map +1 -1
  22. package/dist/ws/server.d.ts +2 -1
  23. package/dist/ws/server.d.ts.map +1 -1
  24. package/dist/ws/server.js +55 -11
  25. package/dist/ws/server.js.map +1 -1
  26. package/dist/ws/streamnormalized.d.ts.map +1 -1
  27. package/dist/ws/streamnormalized.js +14 -20
  28. package/dist/ws/streamnormalized.js.map +1 -1
  29. package/node_modules/tardis-dev/dist/apikeyaccessinfo.js +2 -2
  30. package/node_modules/tardis-dev/dist/binarysplit.d.ts.map +1 -1
  31. package/node_modules/tardis-dev/dist/boundedqueue.d.ts.map +1 -1
  32. package/node_modules/tardis-dev/dist/boundedqueue.js.map +1 -1
  33. package/node_modules/tardis-dev/dist/clearcache.js +3 -3
  34. package/node_modules/tardis-dev/dist/combine.js +1 -1
  35. package/node_modules/tardis-dev/dist/computable/booksnapshot.d.ts.map +1 -1
  36. package/node_modules/tardis-dev/dist/computable/booksnapshot.js +3 -3
  37. package/node_modules/tardis-dev/dist/computable/computable.js +2 -2
  38. package/node_modules/tardis-dev/dist/computable/computable.js.map +1 -1
  39. package/node_modules/tardis-dev/dist/computable/index.js +3 -3
  40. package/node_modules/tardis-dev/dist/computable/tradebar.d.ts.map +1 -1
  41. package/node_modules/tardis-dev/dist/consts.d.ts +1 -1
  42. package/node_modules/tardis-dev/dist/consts.d.ts.map +1 -1
  43. package/node_modules/tardis-dev/dist/downloaddatasets.js +4 -4
  44. package/node_modules/tardis-dev/dist/exchangedetails.js +2 -2
  45. package/node_modules/tardis-dev/dist/filter.d.ts.map +1 -1
  46. package/node_modules/tardis-dev/dist/filter.js +1 -1
  47. package/node_modules/tardis-dev/dist/filter.js.map +1 -1
  48. package/node_modules/tardis-dev/dist/handy.d.ts +4 -3
  49. package/node_modules/tardis-dev/dist/handy.d.ts.map +1 -1
  50. package/node_modules/tardis-dev/dist/handy.js +24 -17
  51. package/node_modules/tardis-dev/dist/handy.js.map +1 -1
  52. package/node_modules/tardis-dev/dist/index.js +16 -16
  53. package/node_modules/tardis-dev/dist/instrumentinfo.d.ts +1 -1
  54. package/node_modules/tardis-dev/dist/instrumentinfo.d.ts.map +1 -1
  55. package/node_modules/tardis-dev/dist/instrumentinfo.js +2 -2
  56. package/node_modules/tardis-dev/dist/instrumentinfo.js.map +1 -1
  57. package/node_modules/tardis-dev/dist/mappers/ascendex.d.ts +4 -4
  58. package/node_modules/tardis-dev/dist/mappers/ascendex.js +3 -3
  59. package/node_modules/tardis-dev/dist/mappers/ascendex.js.map +1 -1
  60. package/node_modules/tardis-dev/dist/mappers/aster.d.ts +8 -8
  61. package/node_modules/tardis-dev/dist/mappers/aster.js +4 -4
  62. package/node_modules/tardis-dev/dist/mappers/aster.js.map +1 -1
  63. package/node_modules/tardis-dev/dist/mappers/backpack.d.ts +11 -11
  64. package/node_modules/tardis-dev/dist/mappers/backpack.d.ts.map +1 -1
  65. package/node_modules/tardis-dev/dist/mappers/backpack.js +3 -3
  66. package/node_modules/tardis-dev/dist/mappers/backpack.js.map +1 -1
  67. package/node_modules/tardis-dev/dist/mappers/binance.d.ts +18 -18
  68. package/node_modules/tardis-dev/dist/mappers/binance.js +4 -4
  69. package/node_modules/tardis-dev/dist/mappers/binance.js.map +1 -1
  70. package/node_modules/tardis-dev/dist/mappers/binancedex.js +2 -2
  71. package/node_modules/tardis-dev/dist/mappers/binancedex.js.map +1 -1
  72. package/node_modules/tardis-dev/dist/mappers/binanceeuropeanoptions.d.ts +1 -1
  73. package/node_modules/tardis-dev/dist/mappers/binanceeuropeanoptions.js +2 -2
  74. package/node_modules/tardis-dev/dist/mappers/binanceeuropeanoptions.js.map +1 -1
  75. package/node_modules/tardis-dev/dist/mappers/bitfinex.d.ts +8 -8
  76. package/node_modules/tardis-dev/dist/mappers/bitfinex.js +3 -3
  77. package/node_modules/tardis-dev/dist/mappers/bitfinex.js.map +1 -1
  78. package/node_modules/tardis-dev/dist/mappers/bitflyer.d.ts +1 -1
  79. package/node_modules/tardis-dev/dist/mappers/bitflyer.js +2 -2
  80. package/node_modules/tardis-dev/dist/mappers/bitflyer.js.map +1 -1
  81. package/node_modules/tardis-dev/dist/mappers/bitget.d.ts +1 -1
  82. package/node_modules/tardis-dev/dist/mappers/bitget.d.ts.map +1 -1
  83. package/node_modules/tardis-dev/dist/mappers/bitget.js +3 -3
  84. package/node_modules/tardis-dev/dist/mappers/bitget.js.map +1 -1
  85. package/node_modules/tardis-dev/dist/mappers/bithumb.d.ts +2 -2
  86. package/node_modules/tardis-dev/dist/mappers/bithumb.js +2 -2
  87. package/node_modules/tardis-dev/dist/mappers/bithumb.js.map +1 -1
  88. package/node_modules/tardis-dev/dist/mappers/bitmex.d.ts +2 -2
  89. package/node_modules/tardis-dev/dist/mappers/bitmex.js +3 -3
  90. package/node_modules/tardis-dev/dist/mappers/bitmex.js.map +1 -1
  91. package/node_modules/tardis-dev/dist/mappers/bitnomial.d.ts +1 -1
  92. package/node_modules/tardis-dev/dist/mappers/bitnomial.js +2 -2
  93. package/node_modules/tardis-dev/dist/mappers/bitnomial.js.map +1 -1
  94. package/node_modules/tardis-dev/dist/mappers/bitstamp.d.ts +2 -2
  95. package/node_modules/tardis-dev/dist/mappers/bitstamp.js +3 -3
  96. package/node_modules/tardis-dev/dist/mappers/bitstamp.js.map +1 -1
  97. package/node_modules/tardis-dev/dist/mappers/bitvavo.d.ts +3 -3
  98. package/node_modules/tardis-dev/dist/mappers/bitvavo.js +2 -2
  99. package/node_modules/tardis-dev/dist/mappers/bitvavo.js.map +1 -1
  100. package/node_modules/tardis-dev/dist/mappers/blockchaincom.d.ts +2 -2
  101. package/node_modules/tardis-dev/dist/mappers/blockchaincom.js +2 -2
  102. package/node_modules/tardis-dev/dist/mappers/blockchaincom.js.map +1 -1
  103. package/node_modules/tardis-dev/dist/mappers/bullish.d.ts +5 -5
  104. package/node_modules/tardis-dev/dist/mappers/bullish.js +3 -3
  105. package/node_modules/tardis-dev/dist/mappers/bullish.js.map +1 -1
  106. package/node_modules/tardis-dev/dist/mappers/bybit.d.ts +14 -14
  107. package/node_modules/tardis-dev/dist/mappers/bybit.d.ts.map +1 -1
  108. package/node_modules/tardis-dev/dist/mappers/bybit.js +4 -4
  109. package/node_modules/tardis-dev/dist/mappers/bybit.js.map +1 -1
  110. package/node_modules/tardis-dev/dist/mappers/bybitspot.d.ts +5 -5
  111. package/node_modules/tardis-dev/dist/mappers/bybitspot.d.ts.map +1 -1
  112. package/node_modules/tardis-dev/dist/mappers/bybitspot.js +1 -1
  113. package/node_modules/tardis-dev/dist/mappers/bybitspot.js.map +1 -1
  114. package/node_modules/tardis-dev/dist/mappers/coinbase.d.ts +1 -1
  115. package/node_modules/tardis-dev/dist/mappers/coinbase.js +2 -2
  116. package/node_modules/tardis-dev/dist/mappers/coinbase.js.map +1 -1
  117. package/node_modules/tardis-dev/dist/mappers/coinbasederivatives.d.ts +4 -4
  118. package/node_modules/tardis-dev/dist/mappers/coinbasederivatives.js +3 -3
  119. package/node_modules/tardis-dev/dist/mappers/coinbasederivatives.js.map +1 -1
  120. package/node_modules/tardis-dev/dist/mappers/coinbaseinternational.d.ts +2 -2
  121. package/node_modules/tardis-dev/dist/mappers/coinbaseinternational.js +3 -3
  122. package/node_modules/tardis-dev/dist/mappers/coinbaseinternational.js.map +1 -1
  123. package/node_modules/tardis-dev/dist/mappers/coinflex.d.ts +1 -1
  124. package/node_modules/tardis-dev/dist/mappers/coinflex.js +3 -3
  125. package/node_modules/tardis-dev/dist/mappers/coinflex.js.map +1 -1
  126. package/node_modules/tardis-dev/dist/mappers/cryptocom.d.ts +7 -7
  127. package/node_modules/tardis-dev/dist/mappers/cryptocom.d.ts.map +1 -1
  128. package/node_modules/tardis-dev/dist/mappers/cryptocom.js +3 -3
  129. package/node_modules/tardis-dev/dist/mappers/cryptocom.js.map +1 -1
  130. package/node_modules/tardis-dev/dist/mappers/cryptofacilities.d.ts +2 -2
  131. package/node_modules/tardis-dev/dist/mappers/cryptofacilities.js +3 -3
  132. package/node_modules/tardis-dev/dist/mappers/cryptofacilities.js.map +1 -1
  133. package/node_modules/tardis-dev/dist/mappers/delta.d.ts +1 -1
  134. package/node_modules/tardis-dev/dist/mappers/delta.js +3 -3
  135. package/node_modules/tardis-dev/dist/mappers/delta.js.map +1 -1
  136. package/node_modules/tardis-dev/dist/mappers/delta_india.d.ts +5 -5
  137. package/node_modules/tardis-dev/dist/mappers/delta_india.js +3 -3
  138. package/node_modules/tardis-dev/dist/mappers/delta_india.js.map +1 -1
  139. package/node_modules/tardis-dev/dist/mappers/deribit.d.ts +3 -3
  140. package/node_modules/tardis-dev/dist/mappers/deribit.js +3 -3
  141. package/node_modules/tardis-dev/dist/mappers/deribit.js.map +1 -1
  142. package/node_modules/tardis-dev/dist/mappers/dydx.d.ts +3 -3
  143. package/node_modules/tardis-dev/dist/mappers/dydx.js +3 -3
  144. package/node_modules/tardis-dev/dist/mappers/dydx.js.map +1 -1
  145. package/node_modules/tardis-dev/dist/mappers/dydxv4.d.ts +4 -4
  146. package/node_modules/tardis-dev/dist/mappers/dydxv4.js +3 -3
  147. package/node_modules/tardis-dev/dist/mappers/dydxv4.js.map +1 -1
  148. package/node_modules/tardis-dev/dist/mappers/ftx.d.ts +8 -8
  149. package/node_modules/tardis-dev/dist/mappers/ftx.js +3 -3
  150. package/node_modules/tardis-dev/dist/mappers/ftx.js.map +1 -1
  151. package/node_modules/tardis-dev/dist/mappers/gateio.d.ts +1 -1
  152. package/node_modules/tardis-dev/dist/mappers/gateio.js +3 -3
  153. package/node_modules/tardis-dev/dist/mappers/gateio.js.map +1 -1
  154. package/node_modules/tardis-dev/dist/mappers/gateiofutures.d.ts +4 -4
  155. package/node_modules/tardis-dev/dist/mappers/gateiofutures.js +3 -3
  156. package/node_modules/tardis-dev/dist/mappers/gateiofutures.js.map +1 -1
  157. package/node_modules/tardis-dev/dist/mappers/gemini.d.ts +1 -1
  158. package/node_modules/tardis-dev/dist/mappers/gemini.js +2 -2
  159. package/node_modules/tardis-dev/dist/mappers/gemini.js.map +1 -1
  160. package/node_modules/tardis-dev/dist/mappers/hitbtc.js +2 -2
  161. package/node_modules/tardis-dev/dist/mappers/hitbtc.js.map +1 -1
  162. package/node_modules/tardis-dev/dist/mappers/huobi.d.ts +34 -34
  163. package/node_modules/tardis-dev/dist/mappers/huobi.d.ts.map +1 -1
  164. package/node_modules/tardis-dev/dist/mappers/huobi.js +3 -3
  165. package/node_modules/tardis-dev/dist/mappers/huobi.js.map +1 -1
  166. package/node_modules/tardis-dev/dist/mappers/hyperliquid.d.ts +3 -3
  167. package/node_modules/tardis-dev/dist/mappers/hyperliquid.js +2 -2
  168. package/node_modules/tardis-dev/dist/mappers/hyperliquid.js.map +1 -1
  169. package/node_modules/tardis-dev/dist/mappers/index.d.ts +225 -224
  170. package/node_modules/tardis-dev/dist/mappers/index.d.ts.map +1 -1
  171. package/node_modules/tardis-dev/dist/mappers/index.js +57 -51
  172. package/node_modules/tardis-dev/dist/mappers/index.js.map +1 -1
  173. package/node_modules/tardis-dev/dist/mappers/kraken.d.ts.map +1 -1
  174. package/node_modules/tardis-dev/dist/mappers/kraken.js +2 -2
  175. package/node_modules/tardis-dev/dist/mappers/kraken.js.map +1 -1
  176. package/node_modules/tardis-dev/dist/mappers/kucoin.d.ts +3 -3
  177. package/node_modules/tardis-dev/dist/mappers/kucoin.js +3 -3
  178. package/node_modules/tardis-dev/dist/mappers/kucoin.js.map +1 -1
  179. package/node_modules/tardis-dev/dist/mappers/kucoinfutures.d.ts +4 -4
  180. package/node_modules/tardis-dev/dist/mappers/kucoinfutures.js +4 -4
  181. package/node_modules/tardis-dev/dist/mappers/kucoinfutures.js.map +1 -1
  182. package/node_modules/tardis-dev/dist/mappers/lighter.d.ts +10 -10
  183. package/node_modules/tardis-dev/dist/mappers/lighter.js +3 -3
  184. package/node_modules/tardis-dev/dist/mappers/lighter.js.map +1 -1
  185. package/node_modules/tardis-dev/dist/mappers/mapper.d.ts +1 -0
  186. package/node_modules/tardis-dev/dist/mappers/mapper.d.ts.map +1 -1
  187. package/node_modules/tardis-dev/dist/mappers/mapper.js.map +1 -1
  188. package/node_modules/tardis-dev/dist/mappers/mexc.d.ts +3 -3
  189. package/node_modules/tardis-dev/dist/mappers/mexc.d.ts.map +1 -1
  190. package/node_modules/tardis-dev/dist/mappers/mexc.js +3 -3
  191. package/node_modules/tardis-dev/dist/mappers/mexc.js.map +1 -1
  192. package/node_modules/tardis-dev/dist/mappers/mexcfutures.d.ts +9 -9
  193. package/node_modules/tardis-dev/dist/mappers/mexcfutures.d.ts.map +1 -1
  194. package/node_modules/tardis-dev/dist/mappers/mexcfutures.js +23 -7
  195. package/node_modules/tardis-dev/dist/mappers/mexcfutures.js.map +1 -1
  196. package/node_modules/tardis-dev/dist/mappers/mexcfuturesprotobuf.d.ts +48 -0
  197. package/node_modules/tardis-dev/dist/mappers/mexcfuturesprotobuf.d.ts.map +1 -0
  198. package/node_modules/tardis-dev/dist/mappers/mexcfuturesprotobuf.js +113 -0
  199. package/node_modules/tardis-dev/dist/mappers/mexcfuturesprotobuf.js.map +1 -0
  200. package/node_modules/tardis-dev/dist/mappers/okex.d.ts +15 -15
  201. package/node_modules/tardis-dev/dist/mappers/okex.d.ts.map +1 -1
  202. package/node_modules/tardis-dev/dist/mappers/okex.js +5 -5
  203. package/node_modules/tardis-dev/dist/mappers/okex.js.map +1 -1
  204. package/node_modules/tardis-dev/dist/mappers/okexspreads.d.ts +2 -2
  205. package/node_modules/tardis-dev/dist/mappers/okexspreads.d.ts.map +1 -1
  206. package/node_modules/tardis-dev/dist/mappers/okexspreads.js +1 -1
  207. package/node_modules/tardis-dev/dist/mappers/okexspreads.js.map +1 -1
  208. package/node_modules/tardis-dev/dist/mappers/phemex.d.ts +1 -1
  209. package/node_modules/tardis-dev/dist/mappers/phemex.js +3 -3
  210. package/node_modules/tardis-dev/dist/mappers/phemex.js.map +1 -1
  211. package/node_modules/tardis-dev/dist/mappers/poloniex.d.ts.map +1 -1
  212. package/node_modules/tardis-dev/dist/mappers/poloniex.js +2 -2
  213. package/node_modules/tardis-dev/dist/mappers/poloniex.js.map +1 -1
  214. package/node_modules/tardis-dev/dist/mappers/polymarket.d.ts +3 -3
  215. package/node_modules/tardis-dev/dist/mappers/polymarket.js +2 -2
  216. package/node_modules/tardis-dev/dist/mappers/polymarket.js.map +1 -1
  217. package/node_modules/tardis-dev/dist/mappers/registry.d.ts +1 -0
  218. package/node_modules/tardis-dev/dist/mappers/registry.d.ts.map +1 -1
  219. package/node_modules/tardis-dev/dist/mappers/registry.js +5 -4
  220. package/node_modules/tardis-dev/dist/mappers/registry.js.map +1 -1
  221. package/node_modules/tardis-dev/dist/mappers/serum.d.ts +9 -9
  222. package/node_modules/tardis-dev/dist/mappers/serum.js +2 -2
  223. package/node_modules/tardis-dev/dist/mappers/serum.js.map +1 -1
  224. package/node_modules/tardis-dev/dist/mappers/upbit.d.ts +2 -2
  225. package/node_modules/tardis-dev/dist/mappers/upbit.js +2 -2
  226. package/node_modules/tardis-dev/dist/mappers/upbit.js.map +1 -1
  227. package/node_modules/tardis-dev/dist/mappers/whitebit.d.ts +4 -4
  228. package/node_modules/tardis-dev/dist/mappers/whitebit.js +3 -3
  229. package/node_modules/tardis-dev/dist/mappers/whitebit.js.map +1 -1
  230. package/node_modules/tardis-dev/dist/mappers/woox.d.ts.map +1 -1
  231. package/node_modules/tardis-dev/dist/mappers/woox.js +3 -3
  232. package/node_modules/tardis-dev/dist/mappers/woox.js.map +1 -1
  233. package/node_modules/tardis-dev/dist/options.js.map +1 -1
  234. package/node_modules/tardis-dev/dist/orderbook.d.ts.map +1 -1
  235. package/node_modules/tardis-dev/dist/orderbook.js +1 -1
  236. package/node_modules/tardis-dev/dist/orderbook.js.map +1 -1
  237. package/node_modules/tardis-dev/dist/priceleveltree.d.ts.map +1 -1
  238. package/node_modules/tardis-dev/dist/priceleveltree.js.map +1 -1
  239. package/node_modules/tardis-dev/dist/realtimefeeds/aster.d.ts +1 -1
  240. package/node_modules/tardis-dev/dist/realtimefeeds/aster.d.ts.map +1 -1
  241. package/node_modules/tardis-dev/dist/realtimefeeds/aster.js +3 -3
  242. package/node_modules/tardis-dev/dist/realtimefeeds/aster.js.map +1 -1
  243. package/node_modules/tardis-dev/dist/realtimefeeds/backpack.d.ts +2 -5
  244. package/node_modules/tardis-dev/dist/realtimefeeds/backpack.d.ts.map +1 -1
  245. package/node_modules/tardis-dev/dist/realtimefeeds/backpack.js +4 -24
  246. package/node_modules/tardis-dev/dist/realtimefeeds/backpack.js.map +1 -1
  247. package/node_modules/tardis-dev/dist/realtimefeeds/binance.d.ts +6 -3
  248. package/node_modules/tardis-dev/dist/realtimefeeds/binance.d.ts.map +1 -1
  249. package/node_modules/tardis-dev/dist/realtimefeeds/binance.js +16 -11
  250. package/node_modules/tardis-dev/dist/realtimefeeds/binance.js.map +1 -1
  251. package/node_modules/tardis-dev/dist/realtimefeeds/binancedex.d.ts.map +1 -1
  252. package/node_modules/tardis-dev/dist/realtimefeeds/binancedex.js +2 -2
  253. package/node_modules/tardis-dev/dist/realtimefeeds/binanceeuropeanoptions.d.ts.map +1 -1
  254. package/node_modules/tardis-dev/dist/realtimefeeds/binanceeuropeanoptions.js +2 -2
  255. package/node_modules/tardis-dev/dist/realtimefeeds/binanceeuropeanoptions.js.map +1 -1
  256. package/node_modules/tardis-dev/dist/realtimefeeds/bitfinex.d.ts +4 -4
  257. package/node_modules/tardis-dev/dist/realtimefeeds/bitfinex.d.ts.map +1 -1
  258. package/node_modules/tardis-dev/dist/realtimefeeds/bitfinex.js +1 -1
  259. package/node_modules/tardis-dev/dist/realtimefeeds/bitflyer.d.ts.map +1 -1
  260. package/node_modules/tardis-dev/dist/realtimefeeds/bitflyer.js +1 -1
  261. package/node_modules/tardis-dev/dist/realtimefeeds/bitget.d.ts +1 -1
  262. package/node_modules/tardis-dev/dist/realtimefeeds/bitget.d.ts.map +1 -1
  263. package/node_modules/tardis-dev/dist/realtimefeeds/bitget.js +2 -2
  264. package/node_modules/tardis-dev/dist/realtimefeeds/bithumb.d.ts.map +1 -1
  265. package/node_modules/tardis-dev/dist/realtimefeeds/bithumb.js +1 -1
  266. package/node_modules/tardis-dev/dist/realtimefeeds/bitstamp.d.ts +1 -1
  267. package/node_modules/tardis-dev/dist/realtimefeeds/bitstamp.d.ts.map +1 -1
  268. package/node_modules/tardis-dev/dist/realtimefeeds/bitstamp.js +2 -2
  269. package/node_modules/tardis-dev/dist/realtimefeeds/bitstamp.js.map +1 -1
  270. package/node_modules/tardis-dev/dist/realtimefeeds/bitvavo.d.ts.map +1 -1
  271. package/node_modules/tardis-dev/dist/realtimefeeds/bitvavo.js +1 -1
  272. package/node_modules/tardis-dev/dist/realtimefeeds/blockchaincom.d.ts.map +1 -1
  273. package/node_modules/tardis-dev/dist/realtimefeeds/blockchaincom.js +2 -2
  274. package/node_modules/tardis-dev/dist/realtimefeeds/bullish.d.ts.map +1 -1
  275. package/node_modules/tardis-dev/dist/realtimefeeds/bullish.js +1 -1
  276. package/node_modules/tardis-dev/dist/realtimefeeds/bullish.js.map +1 -1
  277. package/node_modules/tardis-dev/dist/realtimefeeds/bybit.d.ts +1 -1
  278. package/node_modules/tardis-dev/dist/realtimefeeds/bybit.d.ts.map +1 -1
  279. package/node_modules/tardis-dev/dist/realtimefeeds/bybit.js +2 -2
  280. package/node_modules/tardis-dev/dist/realtimefeeds/coinbase.d.ts.map +1 -1
  281. package/node_modules/tardis-dev/dist/realtimefeeds/coinbase.js +1 -1
  282. package/node_modules/tardis-dev/dist/realtimefeeds/coinbasederivatives.d.ts +2 -2
  283. package/node_modules/tardis-dev/dist/realtimefeeds/coinbasederivatives.d.ts.map +1 -1
  284. package/node_modules/tardis-dev/dist/realtimefeeds/coinbasederivatives.js +2 -2
  285. package/node_modules/tardis-dev/dist/realtimefeeds/coinbasederivatives.js.map +1 -1
  286. package/node_modules/tardis-dev/dist/realtimefeeds/coinflex.d.ts.map +1 -1
  287. package/node_modules/tardis-dev/dist/realtimefeeds/coinflex.js +1 -1
  288. package/node_modules/tardis-dev/dist/realtimefeeds/cryptocom.d.ts.map +1 -1
  289. package/node_modules/tardis-dev/dist/realtimefeeds/cryptocom.js +1 -1
  290. package/node_modules/tardis-dev/dist/realtimefeeds/cryptofacilities.d.ts.map +1 -1
  291. package/node_modules/tardis-dev/dist/realtimefeeds/cryptofacilities.js +1 -1
  292. package/node_modules/tardis-dev/dist/realtimefeeds/delta.d.ts.map +1 -1
  293. package/node_modules/tardis-dev/dist/realtimefeeds/delta.js +1 -1
  294. package/node_modules/tardis-dev/dist/realtimefeeds/delta_india.d.ts +1 -1
  295. package/node_modules/tardis-dev/dist/realtimefeeds/delta_india.d.ts.map +1 -1
  296. package/node_modules/tardis-dev/dist/realtimefeeds/delta_india.js +2 -2
  297. package/node_modules/tardis-dev/dist/realtimefeeds/deribit.d.ts +1 -1
  298. package/node_modules/tardis-dev/dist/realtimefeeds/deribit.d.ts.map +1 -1
  299. package/node_modules/tardis-dev/dist/realtimefeeds/deribit.js +2 -2
  300. package/node_modules/tardis-dev/dist/realtimefeeds/dydx.d.ts.map +1 -1
  301. package/node_modules/tardis-dev/dist/realtimefeeds/dydx.js +1 -1
  302. package/node_modules/tardis-dev/dist/realtimefeeds/dydx_v4.d.ts.map +1 -1
  303. package/node_modules/tardis-dev/dist/realtimefeeds/dydx_v4.js +1 -1
  304. package/node_modules/tardis-dev/dist/realtimefeeds/ftx.d.ts +1 -1
  305. package/node_modules/tardis-dev/dist/realtimefeeds/ftx.d.ts.map +1 -1
  306. package/node_modules/tardis-dev/dist/realtimefeeds/ftx.js +2 -2
  307. package/node_modules/tardis-dev/dist/realtimefeeds/ftx.js.map +1 -1
  308. package/node_modules/tardis-dev/dist/realtimefeeds/gateio.d.ts.map +1 -1
  309. package/node_modules/tardis-dev/dist/realtimefeeds/gateio.js +1 -1
  310. package/node_modules/tardis-dev/dist/realtimefeeds/gateiofutures.d.ts.map +1 -1
  311. package/node_modules/tardis-dev/dist/realtimefeeds/gateiofutures.js +1 -1
  312. package/node_modules/tardis-dev/dist/realtimefeeds/gateiofutures.js.map +1 -1
  313. package/node_modules/tardis-dev/dist/realtimefeeds/gemini.d.ts.map +1 -1
  314. package/node_modules/tardis-dev/dist/realtimefeeds/gemini.js +1 -1
  315. package/node_modules/tardis-dev/dist/realtimefeeds/hitbtc.d.ts.map +1 -1
  316. package/node_modules/tardis-dev/dist/realtimefeeds/hitbtc.js +1 -1
  317. package/node_modules/tardis-dev/dist/realtimefeeds/huobi.d.ts +1 -1
  318. package/node_modules/tardis-dev/dist/realtimefeeds/huobi.d.ts.map +1 -1
  319. package/node_modules/tardis-dev/dist/realtimefeeds/huobi.js +2 -2
  320. package/node_modules/tardis-dev/dist/realtimefeeds/huobi.js.map +1 -1
  321. package/node_modules/tardis-dev/dist/realtimefeeds/hyperliquid.d.ts.map +1 -1
  322. package/node_modules/tardis-dev/dist/realtimefeeds/hyperliquid.js +1 -1
  323. package/node_modules/tardis-dev/dist/realtimefeeds/index.d.ts.map +1 -1
  324. package/node_modules/tardis-dev/dist/realtimefeeds/index.js +49 -51
  325. package/node_modules/tardis-dev/dist/realtimefeeds/index.js.map +1 -1
  326. package/node_modules/tardis-dev/dist/realtimefeeds/kraken.d.ts.map +1 -1
  327. package/node_modules/tardis-dev/dist/realtimefeeds/kraken.js +1 -1
  328. package/node_modules/tardis-dev/dist/realtimefeeds/kucoin.d.ts.map +1 -1
  329. package/node_modules/tardis-dev/dist/realtimefeeds/kucoin.js +2 -2
  330. package/node_modules/tardis-dev/dist/realtimefeeds/kucoinfutures.d.ts +1 -1
  331. package/node_modules/tardis-dev/dist/realtimefeeds/kucoinfutures.d.ts.map +1 -1
  332. package/node_modules/tardis-dev/dist/realtimefeeds/kucoinfutures.js +2 -2
  333. package/node_modules/tardis-dev/dist/realtimefeeds/kucoinfutures.js.map +1 -1
  334. package/node_modules/tardis-dev/dist/realtimefeeds/lighter.d.ts.map +1 -1
  335. package/node_modules/tardis-dev/dist/realtimefeeds/lighter.js +1 -1
  336. package/node_modules/tardis-dev/dist/realtimefeeds/mango.js +1 -1
  337. package/node_modules/tardis-dev/dist/realtimefeeds/mexc.d.ts.map +1 -1
  338. package/node_modules/tardis-dev/dist/realtimefeeds/mexc.js +3 -3
  339. package/node_modules/tardis-dev/dist/realtimefeeds/mexc.js.map +1 -1
  340. package/node_modules/tardis-dev/dist/realtimefeeds/mexcfutures.d.ts +1 -0
  341. package/node_modules/tardis-dev/dist/realtimefeeds/mexcfutures.d.ts.map +1 -1
  342. package/node_modules/tardis-dev/dist/realtimefeeds/mexcfutures.js +21 -11
  343. package/node_modules/tardis-dev/dist/realtimefeeds/mexcfutures.js.map +1 -1
  344. package/node_modules/tardis-dev/dist/realtimefeeds/mexcfuturesprotobuf.d.ts +186 -0
  345. package/node_modules/tardis-dev/dist/realtimefeeds/mexcfuturesprotobuf.d.ts.map +1 -0
  346. package/node_modules/tardis-dev/dist/realtimefeeds/mexcfuturesprotobuf.js +846 -0
  347. package/node_modules/tardis-dev/dist/realtimefeeds/mexcfuturesprotobuf.js.map +1 -0
  348. package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.js +1 -129
  349. package/node_modules/tardis-dev/dist/realtimefeeds/mexcprotobuf.js.map +1 -1
  350. package/node_modules/tardis-dev/dist/realtimefeeds/okex.d.ts.map +1 -1
  351. package/node_modules/tardis-dev/dist/realtimefeeds/okex.js +3 -3
  352. package/node_modules/tardis-dev/dist/realtimefeeds/okex.js.map +1 -1
  353. package/node_modules/tardis-dev/dist/realtimefeeds/okexspreads.d.ts.map +1 -1
  354. package/node_modules/tardis-dev/dist/realtimefeeds/okexspreads.js +2 -2
  355. package/node_modules/tardis-dev/dist/realtimefeeds/phemex.d.ts.map +1 -1
  356. package/node_modules/tardis-dev/dist/realtimefeeds/phemex.js +1 -1
  357. package/node_modules/tardis-dev/dist/realtimefeeds/poloniex.d.ts.map +1 -1
  358. package/node_modules/tardis-dev/dist/realtimefeeds/poloniex.js +1 -1
  359. package/node_modules/tardis-dev/dist/realtimefeeds/polymarket.d.ts.map +1 -1
  360. package/node_modules/tardis-dev/dist/realtimefeeds/polymarket.js +1 -1
  361. package/node_modules/tardis-dev/dist/realtimefeeds/protobufreader.d.ts +22 -0
  362. package/node_modules/tardis-dev/dist/realtimefeeds/protobufreader.d.ts.map +1 -0
  363. package/node_modules/tardis-dev/dist/realtimefeeds/protobufreader.js +130 -0
  364. package/node_modules/tardis-dev/dist/realtimefeeds/protobufreader.js.map +1 -0
  365. package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.d.ts.map +1 -1
  366. package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.js +8 -29
  367. package/node_modules/tardis-dev/dist/realtimefeeds/realtimefeed.js.map +1 -1
  368. package/node_modules/tardis-dev/dist/realtimefeeds/requestweight.d.ts.map +1 -1
  369. package/node_modules/tardis-dev/dist/realtimefeeds/requestweight.js +1 -1
  370. package/node_modules/tardis-dev/dist/realtimefeeds/requestweight.js.map +1 -1
  371. package/node_modules/tardis-dev/dist/realtimefeeds/serum.d.ts.map +1 -1
  372. package/node_modules/tardis-dev/dist/realtimefeeds/serum.js +1 -1
  373. package/node_modules/tardis-dev/dist/realtimefeeds/staratlas.js +1 -1
  374. package/node_modules/tardis-dev/dist/realtimefeeds/upbit.d.ts.map +1 -1
  375. package/node_modules/tardis-dev/dist/realtimefeeds/upbit.js +1 -1
  376. package/node_modules/tardis-dev/dist/realtimefeeds/whitebit.d.ts +1 -4
  377. package/node_modules/tardis-dev/dist/realtimefeeds/whitebit.d.ts.map +1 -1
  378. package/node_modules/tardis-dev/dist/realtimefeeds/whitebit.js +4 -22
  379. package/node_modules/tardis-dev/dist/realtimefeeds/whitebit.js.map +1 -1
  380. package/node_modules/tardis-dev/dist/realtimefeeds/woox.d.ts.map +1 -1
  381. package/node_modules/tardis-dev/dist/realtimefeeds/woox.js +2 -2
  382. package/node_modules/tardis-dev/dist/realtimeiterator.js +1 -1
  383. package/node_modules/tardis-dev/dist/replay.d.ts.map +1 -1
  384. package/node_modules/tardis-dev/dist/replay.js +55 -78
  385. package/node_modules/tardis-dev/dist/replay.js.map +1 -1
  386. package/node_modules/tardis-dev/dist/stream.d.ts.map +1 -1
  387. package/node_modules/tardis-dev/dist/stream.js +15 -10
  388. package/node_modules/tardis-dev/dist/stream.js.map +1 -1
  389. package/node_modules/tardis-dev/dist/wait.d.ts +3 -0
  390. package/node_modules/tardis-dev/dist/wait.d.ts.map +1 -0
  391. package/node_modules/tardis-dev/dist/wait.js +17 -0
  392. package/node_modules/tardis-dev/dist/wait.js.map +1 -0
  393. package/node_modules/tardis-dev/dist/worker.d.ts.map +1 -1
  394. package/node_modules/tardis-dev/dist/worker.js +20 -14
  395. package/node_modules/tardis-dev/dist/worker.js.map +1 -1
  396. package/node_modules/tardis-dev/dist/zstd.d.ts +1 -1
  397. package/node_modules/tardis-dev/dist/zstd.d.ts.map +1 -1
  398. package/node_modules/tardis-dev/dist/zstd.js +2 -3
  399. package/node_modules/tardis-dev/dist/zstd.js.map +1 -1
  400. package/node_modules/tardis-dev/package.json +4 -4
  401. package/node_modules/tardis-dev/src/handy.ts +35 -14
  402. package/node_modules/tardis-dev/src/instrumentinfo.ts +2 -0
  403. package/node_modules/tardis-dev/src/mappers/index.ts +8 -0
  404. package/node_modules/tardis-dev/src/mappers/mapper.ts +1 -0
  405. package/node_modules/tardis-dev/src/mappers/mexcfutures.ts +27 -5
  406. package/node_modules/tardis-dev/src/mappers/mexcfuturesprotobuf.ts +144 -0
  407. package/node_modules/tardis-dev/src/mappers/registry.ts +4 -2
  408. package/node_modules/tardis-dev/src/realtimefeeds/backpack.ts +2 -31
  409. package/node_modules/tardis-dev/src/realtimefeeds/binance.ts +12 -2
  410. package/node_modules/tardis-dev/src/realtimefeeds/index.ts +0 -2
  411. package/node_modules/tardis-dev/src/realtimefeeds/mexcfutures.ts +20 -13
  412. package/node_modules/tardis-dev/src/realtimefeeds/mexcfuturesprotobuf.ts +997 -0
  413. package/node_modules/tardis-dev/src/realtimefeeds/mexcprotobuf.ts +1 -153
  414. package/node_modules/tardis-dev/src/realtimefeeds/protobufreader.ts +153 -0
  415. package/node_modules/tardis-dev/src/realtimefeeds/realtimefeed.ts +5 -29
  416. package/node_modules/tardis-dev/src/realtimefeeds/whitebit.ts +3 -36
  417. package/node_modules/tardis-dev/src/replay.ts +59 -81
  418. package/node_modules/tardis-dev/src/stream.ts +15 -8
  419. package/node_modules/tardis-dev/src/wait.ts +17 -0
  420. package/node_modules/tardis-dev/src/worker.ts +20 -12
  421. package/node_modules/tardis-dev/src/zstd.ts +2 -3
  422. package/package.json +3 -3
  423. package/src/helpers.ts +0 -2
  424. package/src/ws/replay.ts +6 -15
  425. package/src/ws/replaynormalized.ts +4 -10
  426. package/src/ws/server.ts +54 -11
  427. package/src/ws/streamnormalized.ts +13 -21
  428. package/node_modules/tardis-dev/dist/realtimefeeds/bitnomial.d.ts +0 -11
  429. package/node_modules/tardis-dev/dist/realtimefeeds/bitnomial.d.ts.map +0 -1
  430. package/node_modules/tardis-dev/dist/realtimefeeds/bitnomial.js +0 -52
  431. package/node_modules/tardis-dev/dist/realtimefeeds/bitnomial.js.map +0 -1
  432. package/node_modules/tardis-dev/src/realtimefeeds/bitnomial.ts +0 -60
@@ -1,4 +1,4 @@
1
- const textDecoder = new TextDecoder()
1
+ import { ProtobufReader } from './protobufreader.ts'
2
2
 
3
3
  // Decodes only the current MEXC real-time channels supported by MexcRealTimeFeed.
4
4
  // Field numbers mirror the official schemas at commit 7b8ac7a6681f28551612a5a7cefbb7e09b56bb85:
@@ -210,155 +210,3 @@ function decodeBookTicker(data: Uint8Array) {
210
210
 
211
211
  return message
212
212
  }
213
-
214
- class ProtobufReader {
215
- private offset = 0
216
-
217
- constructor(private readonly data: Uint8Array) {}
218
-
219
- get done() {
220
- return this.offset === this.data.length
221
- }
222
-
223
- readTag() {
224
- const tag = this.readVarint()
225
- if (typeof tag === 'bigint' || tag > 0xffffffff) {
226
- throw new Error('Invalid protobuf tag')
227
- }
228
-
229
- const fieldNumber = tag >>> 3
230
- const wireType = tag & 7
231
-
232
- if (fieldNumber === 0) {
233
- throw new Error('Invalid protobuf field number 0')
234
- }
235
-
236
- return { fieldNumber, wireType }
237
- }
238
-
239
- readString(wireType: number) {
240
- this.expectWireType(wireType, 2)
241
- const length = this.readLength()
242
- const start = this.offset
243
- const end = start + length
244
-
245
- if (end > this.data.length) {
246
- throw new Error('Invalid protobuf message length')
247
- }
248
-
249
- this.offset = end
250
- return Buffer.isBuffer(this.data) ? this.data.toString('utf8', start, end) : textDecoder.decode(this.data.subarray(start, end))
251
- }
252
-
253
- readBytes(wireType: number) {
254
- this.expectWireType(wireType, 2)
255
- const length = this.readLength()
256
- const end = this.offset + length
257
-
258
- if (end > this.data.length) {
259
- throw new Error('Invalid protobuf message length')
260
- }
261
-
262
- const value = this.data.subarray(this.offset, end)
263
- this.offset = end
264
- return value
265
- }
266
-
267
- readInt32(wireType: number) {
268
- this.expectWireType(wireType, 0)
269
- const value = this.readVarint()
270
- return typeof value === 'number' ? value | 0 : Number(BigInt.asIntN(32, value))
271
- }
272
-
273
- readInt64String(wireType: number) {
274
- this.expectWireType(wireType, 0)
275
- const value = this.readVarint()
276
- return typeof value === 'number' ? value.toString() : BigInt.asIntN(64, value).toString()
277
- }
278
-
279
- skipField(wireType: number): void {
280
- switch (wireType) {
281
- case 0:
282
- this.skipVarint()
283
- return
284
- case 1:
285
- this.skipBytes(8)
286
- return
287
- case 2:
288
- this.skipBytes(this.readLength())
289
- return
290
- case 5:
291
- this.skipBytes(4)
292
- return
293
- default:
294
- throw new Error(`Unsupported protobuf wire type ${wireType}`)
295
- }
296
- }
297
-
298
- private readVarint() {
299
- let value = 0
300
- let multiplier = 1
301
-
302
- // Seven base-128 digits use at most 49 bits, so they remain exact and fast as a number.
303
- for (let index = 0; index < 7; index++) {
304
- const byte = this.readByte()
305
- value += (byte & 0x7f) * multiplier
306
-
307
- if ((byte & 0x80) === 0) {
308
- return value
309
- }
310
- multiplier *= 0x80
311
- }
312
-
313
- // Larger int64 values need BigInt to preserve every bit before converting them to strings.
314
- let bigValue = BigInt(value)
315
- for (let index = 7; index < 10; index++) {
316
- const byte = this.readByte()
317
- bigValue |= BigInt(byte & 0x7f) << BigInt(index * 7)
318
-
319
- if ((byte & 0x80) === 0) {
320
- return bigValue
321
- }
322
- }
323
-
324
- throw new Error('Invalid protobuf varint')
325
- }
326
-
327
- private readLength() {
328
- const length = this.readVarint()
329
- if (typeof length === 'bigint' || Number.isSafeInteger(length) === false) {
330
- throw new Error('Invalid protobuf message length')
331
- }
332
- return length
333
- }
334
-
335
- private skipVarint() {
336
- for (let index = 0; index < 10; index++) {
337
- if ((this.readByte() & 0x80) === 0) {
338
- return
339
- }
340
- }
341
- throw new Error('Invalid protobuf varint')
342
- }
343
-
344
- private readByte() {
345
- if (this.offset >= this.data.length) {
346
- throw new Error('Unexpected end of protobuf message')
347
- }
348
- return this.data[this.offset++]!
349
- }
350
-
351
- private skipBytes(length: number) {
352
- const end = this.offset + length
353
- if (Number.isSafeInteger(length) === false || end > this.data.length) {
354
- throw new Error('Invalid protobuf message length')
355
- }
356
- this.offset = end
357
- }
358
-
359
- private expectWireType(actual: number, expected: number) {
360
- if (actual !== expected) {
361
- throw new Error(`Invalid protobuf wire type ${actual}, expected ${expected}`)
362
- }
363
- }
364
- }
@@ -0,0 +1,153 @@
1
+ const textDecoder = new TextDecoder()
2
+
3
+ export class ProtobufReader {
4
+ private offset = 0
5
+
6
+ constructor(private readonly data: Uint8Array) {}
7
+
8
+ get done() {
9
+ return this.offset === this.data.length
10
+ }
11
+
12
+ readTag() {
13
+ const tag = this.readVarint()
14
+ if (typeof tag === 'bigint' || tag > 0xffffffff) {
15
+ throw new Error('Invalid protobuf tag')
16
+ }
17
+
18
+ const fieldNumber = tag >>> 3
19
+ const wireType = tag & 7
20
+
21
+ if (fieldNumber === 0) {
22
+ throw new Error('Invalid protobuf field number 0')
23
+ }
24
+
25
+ return { fieldNumber, wireType }
26
+ }
27
+
28
+ readString(wireType: number) {
29
+ this.expectWireType(wireType, 2)
30
+ const length = this.readLength()
31
+ const start = this.offset
32
+ const end = start + length
33
+
34
+ if (end > this.data.length) {
35
+ throw new Error('Invalid protobuf message length')
36
+ }
37
+
38
+ this.offset = end
39
+ return Buffer.isBuffer(this.data) ? this.data.toString('utf8', start, end) : textDecoder.decode(this.data.subarray(start, end))
40
+ }
41
+
42
+ readBytes(wireType: number) {
43
+ this.expectWireType(wireType, 2)
44
+ const length = this.readLength()
45
+ const end = this.offset + length
46
+
47
+ if (end > this.data.length) {
48
+ throw new Error('Invalid protobuf message length')
49
+ }
50
+
51
+ const value = this.data.subarray(this.offset, end)
52
+ this.offset = end
53
+ return value
54
+ }
55
+
56
+ readInt32(wireType: number) {
57
+ this.expectWireType(wireType, 0)
58
+ const value = this.readVarint()
59
+ return typeof value === 'number' ? value | 0 : Number(BigInt.asIntN(32, value))
60
+ }
61
+
62
+ readInt64String(wireType: number) {
63
+ this.expectWireType(wireType, 0)
64
+ const value = this.readVarint()
65
+ return typeof value === 'number' ? value.toString() : BigInt.asIntN(64, value).toString()
66
+ }
67
+
68
+ skipField(wireType: number): void {
69
+ switch (wireType) {
70
+ case 0:
71
+ this.skipVarint()
72
+ return
73
+ case 1:
74
+ this.skipBytes(8)
75
+ return
76
+ case 2:
77
+ this.skipBytes(this.readLength())
78
+ return
79
+ case 5:
80
+ this.skipBytes(4)
81
+ return
82
+ default:
83
+ throw new Error(`Unsupported protobuf wire type ${wireType}`)
84
+ }
85
+ }
86
+
87
+ private readVarint() {
88
+ let value = 0
89
+ let multiplier = 1
90
+
91
+ // Seven base-128 digits use at most 49 bits, so they remain exact and fast as a number.
92
+ for (let index = 0; index < 7; index++) {
93
+ const byte = this.readByte()
94
+ value += (byte & 0x7f) * multiplier
95
+
96
+ if ((byte & 0x80) === 0) {
97
+ return value
98
+ }
99
+ multiplier *= 0x80
100
+ }
101
+
102
+ // Larger int64 values need BigInt to preserve every bit before converting them to strings.
103
+ let bigValue = BigInt(value)
104
+ for (let index = 7; index < 10; index++) {
105
+ const byte = this.readByte()
106
+ bigValue |= BigInt(byte & 0x7f) << BigInt(index * 7)
107
+
108
+ if ((byte & 0x80) === 0) {
109
+ return bigValue
110
+ }
111
+ }
112
+
113
+ throw new Error('Invalid protobuf varint')
114
+ }
115
+
116
+ private readLength() {
117
+ const length = this.readVarint()
118
+ if (typeof length === 'bigint' || Number.isSafeInteger(length) === false) {
119
+ throw new Error('Invalid protobuf message length')
120
+ }
121
+ return length
122
+ }
123
+
124
+ private skipVarint() {
125
+ for (let index = 0; index < 10; index++) {
126
+ if ((this.readByte() & 0x80) === 0) {
127
+ return
128
+ }
129
+ }
130
+ throw new Error('Invalid protobuf varint')
131
+ }
132
+
133
+ private readByte() {
134
+ if (this.offset >= this.data.length) {
135
+ throw new Error('Unexpected end of protobuf message')
136
+ }
137
+ return this.data[this.offset++]!
138
+ }
139
+
140
+ private skipBytes(length: number) {
141
+ const end = this.offset + length
142
+ if (Number.isSafeInteger(length) === false || end > this.data.length) {
143
+ throw new Error('Invalid protobuf message length')
144
+ }
145
+ this.offset = end
146
+ }
147
+
148
+ private expectWireType(actual: number, expected: number) {
149
+ if (actual !== expected) {
150
+ throw new Error(`Invalid protobuf wire type ${actual}, expected ${expected}`)
151
+ }
152
+ }
153
+ }
@@ -1,9 +1,8 @@
1
1
  import WebSocket, { createWebSocketStream } from 'ws'
2
2
  import type { ClientRequestArgs } from 'http'
3
3
  import { PassThrough, Writable } from 'stream'
4
- import { setTimeout as sleep } from 'node:timers/promises'
5
4
  import { createDebug, type DebugLogger } from '../debug.ts'
6
- import { getProxyAgent, HttpClientError, ONE_SEC_IN_MS, optimizeFilters } from '../handy.ts'
5
+ import { abortableWait, getProxyAgent, getRetryDelay, ONE_SEC_IN_MS, optimizeFilters } from '../handy.ts'
7
6
  import { getMessageParser } from '../parsemessage.ts'
8
7
  import { closeIterator, createManagedRealTimeIterator, mergeRealTime, type ManagedRealTimeIterator } from '../realtimeiterator.ts'
9
8
  import { Exchange, Filter } from '../types.ts'
@@ -273,7 +272,7 @@ export abstract class RealTimeFeedBase implements RealTimeFeedIterable {
273
272
  yield { __disconnect__: true, error: connectionError, delivered }
274
273
 
275
274
  if (retryDelay !== undefined) {
276
- await wait(retryDelay, this._closeController.signal)
275
+ await abortableWait(retryDelay, this._closeController.signal)
277
276
  }
278
277
  }
279
278
  }
@@ -378,7 +377,7 @@ export abstract class RealTimeFeedBase implements RealTimeFeedIterable {
378
377
 
379
378
  this._send(connection, message)
380
379
  if (this.throttleSubscribeMS > 0) {
381
- await wait(this.throttleSubscribeMS, connection.controller.signal)
380
+ await abortableWait(this.throttleSubscribeMS, connection.controller.signal)
382
381
  }
383
382
  }
384
383
 
@@ -387,7 +386,7 @@ export abstract class RealTimeFeedBase implements RealTimeFeedIterable {
387
386
  const messagesBeforeSnapshots = subscribeMessages.length === 0 ? 0 : subscribeMessages.length + 1
388
387
  // Wait for subscription acknowledgements and the first data message before fetching snapshots.
389
388
  while (shouldCancel() === false && connection.receivedMessagesCount < messagesBeforeSnapshots) {
390
- await wait(100, connection.controller.signal)
389
+ await abortableWait(100, connection.controller.signal)
391
390
  }
392
391
 
393
392
  if (shouldCancel()) {
@@ -448,29 +447,6 @@ export abstract class RealTimeFeedBase implements RealTimeFeedIterable {
448
447
  }
449
448
  }
450
449
 
451
- async function wait(delayMS: number, signal: AbortSignal) {
452
- try {
453
- await sleep(delayMS, undefined, { signal })
454
- } catch (error) {
455
- if (signal.aborted === false) {
456
- throw error
457
- }
458
- }
459
- }
460
-
461
- function getRetryDelay(error: Error, retries: number) {
462
- const MAX_DELAY = 32 * 1000
463
- const httpError = error instanceof HttpClientError ? error : undefined
464
- const isRateLimited = httpError?.status === 418 || httpError?.status === 429 || error.message.includes('429')
465
-
466
- if (isRateLimited) {
467
- const fallbackDelay = httpError?.status === 418 ? 2 * 60 * 1000 : (MAX_DELAY / 2) * retries
468
- return httpError?.retryAfterMS ?? fallbackDelay
469
- }
470
-
471
- return Math.min(Math.pow(2, retries - 1) * 1000, MAX_DELAY)
472
- }
473
-
474
450
  function resolveOrAbort<T>(promise: Promise<T>, signal: AbortSignal): Promise<T | typeof ABORTED> {
475
451
  if (signal.aborted) {
476
452
  return Promise.resolve(ABORTED)
@@ -550,7 +526,7 @@ export abstract class MultiConnectionRealTimeFeedBase implements RealTimeFeedIte
550
526
 
551
527
  if (disconnect.error !== undefined) {
552
528
  retries++
553
- await wait(getRetryDelay(disconnect.error, retries), this._closeController.signal)
529
+ await abortableWait(getRetryDelay(disconnect.error, retries), this._closeController.signal)
554
530
  }
555
531
  }
556
532
  }
@@ -1,6 +1,5 @@
1
1
  import { Writable } from 'stream'
2
- import { setTimeout as sleep } from 'node:timers/promises'
3
- import { batch, getJSON } from '../handy.ts'
2
+ import { getJSON } from '../handy.ts'
4
3
  import { Filter } from '../types.ts'
5
4
  import { MultiConnectionRealTimeFeedBase, PoolingClientBase, RealTimeFeedBase, Sequence } from './realtimefeed.ts'
6
5
 
@@ -29,24 +28,8 @@ export class WhiteBitRealTimeFeed extends MultiConnectionRealTimeFeedBase {
29
28
  throw new Error('WhiteBitRealTimeFeed requires explicitly specified symbols when subscribing to live feed')
30
29
  }
31
30
  }
32
- const webSocketSymbols = [...new Set(webSocketFilters.flatMap((filter) => filter.symbols!))]
33
- const spotSymbols = webSocketSymbols.filter((symbol) => !symbol.endsWith('_PERP'))
34
- const perpetualSymbols = webSocketSymbols.filter((symbol) => symbol.endsWith('_PERP'))
35
- let connectionIndex = 0
36
-
37
- for (const marketSymbols of [spotSymbols, perpetualSymbols]) {
38
- for (const group of batch(marketSymbols, 50)) {
39
- yield new WhiteBitWebSocketRealTimeFeed(
40
- exchange,
41
- webSocketFilters
42
- .map((filter) => ({ ...filter, symbols: filter.symbols!.filter((symbol) => group.includes(symbol)) }))
43
- .filter((filter) => filter.symbols.length > 0),
44
- timeoutIntervalMS,
45
- onError,
46
- validateSequence,
47
- connectionIndex++ * 50
48
- )
49
- }
31
+ if (webSocketFilters.length > 0) {
32
+ yield new WhiteBitWebSocketRealTimeFeed(exchange, webSocketFilters, timeoutIntervalMS, onError, validateSequence)
50
33
  }
51
34
 
52
35
  const futuresFilters = filters.filter((filter) => filter.channel === 'futures_update')
@@ -65,22 +48,6 @@ export class WhiteBitRealTimeFeed extends MultiConnectionRealTimeFeedBase {
65
48
  export class WhiteBitWebSocketRealTimeFeed extends RealTimeFeedBase {
66
49
  protected readonly wssURL = 'wss://wss.whitebit.com/ws'
67
50
 
68
- constructor(
69
- exchange: string,
70
- filters: Filter<string>[],
71
- timeoutIntervalMS: number | undefined,
72
- onError?: (error: Error) => void,
73
- validateSequence?: boolean,
74
- private readonly _startDelayMS = 0
75
- ) {
76
- super(exchange, filters, timeoutIntervalMS, onError, validateSequence)
77
- }
78
-
79
- protected async getWebSocketUrl() {
80
- await sleep(this._startDelayMS)
81
- return super.getWebSocketUrl()
82
- }
83
-
84
51
  protected mapToSubscribeMessages(filters: Filter<string>[]) {
85
52
  let id = 0
86
53
  return filters.flatMap(({ channel, symbols }) => {
@@ -1,19 +1,20 @@
1
1
  import { createReadStream } from 'node:fs'
2
2
  import { rm } from 'node:fs/promises'
3
- import { EventEmitter, once } from 'events'
3
+ import { pipeline } from 'node:stream'
4
+ import { once } from 'events'
4
5
  import { Worker } from 'worker_threads'
5
6
  import { constants, createGunzip } from 'zlib'
6
7
  import { BinarySplitBatchStream } from './binarysplit.ts'
7
8
  import { clearCacheSync } from './clearcache.ts'
8
9
  import { EXCHANGES, EXCHANGE_CHANNELS_INFO } from './consts.ts'
9
10
  import { debug } from './debug.ts'
10
- import { addDays, createNormalizedSymbolFilter, getFilters, parseAsUTCDate, wait } from './handy.ts'
11
+ import { addDays, createNormalizedSymbolFilter, getFilters, parseAsUTCDate } from './handy.ts'
11
12
  import { Mapper, MapperFactory, normalizeBookChanges } from './mappers/index.ts'
12
13
  import { getOptions } from './options.ts'
13
14
  import { getMessageParser } from './parsemessage.ts'
14
15
  import { Disconnect, Exchange, FilterForExchange } from './types.ts'
15
16
  import { WorkerJobPayload, WorkerMessage, WorkerSignal } from './worker.ts'
16
- import { createZstdDecompressionStream } from './zstd.ts'
17
+ import { createZstdDecompressor } from './zstd.ts'
17
18
 
18
19
  type MapperOutput<T> = T extends MapperFactory<any, infer U> ? U : never
19
20
  type ReplayNormalizedMessage<U extends readonly MapperFactory<any, any>[], Z extends boolean> = Z extends true
@@ -130,9 +131,17 @@ async function* replayLineBatches<T extends Exchange>({
130
131
  waitWhenDataNotYetAvailable
131
132
  }
132
133
 
133
- const worker = new ReliableWorker(payload)
134
+ const worker = new Worker(new URL('./worker.js', import.meta.url), {
135
+ workerData: payload
136
+ })
137
+
138
+ let workerExited = false
139
+
140
+ worker.on('message', (message: WorkerMessage | WorkerSignal.READY_TO_TERMINATE) => {
141
+ if (message === WorkerSignal.READY_TO_TERMINATE) {
142
+ return
143
+ }
134
144
 
135
- worker.on('message', (message: WorkerMessage) => {
136
145
  cachedSlicePaths.set(message.sliceKey, {
137
146
  slicePath: message.slicePath,
138
147
  sliceSize: message.sliceSize
@@ -145,6 +154,11 @@ async function* replayLineBatches<T extends Exchange>({
145
154
  replayError = err
146
155
  })
147
156
 
157
+ worker.on('exit', (code) => {
158
+ workerExited = true
159
+ debug('worker finished with code: %d', code)
160
+ })
161
+
148
162
  try {
149
163
  let currentSliceDate = new Date(fromDate)
150
164
  // iterate over every minute in <=from,to> date range
@@ -173,26 +187,29 @@ async function* replayLineBatches<T extends Exchange>({
173
187
  // response is a path to file on disk let' read it as stream
174
188
  const { slicePath: cachedSlicePath, sliceSize } = cachedSlice
175
189
  const isZstdSlice = cachedSlicePath.endsWith('.zst')
176
- const decompressedStream = isZstdSlice
177
- ? createZstdDecompressionStream(cachedSlicePath, CHUNK_SIZE)
178
- : createReadStream(cachedSlicePath, { highWaterMark: CHUNK_SIZE }).pipe(createGunzip(GZIP_OPTIONS))
179
- const linesStream = decompressedStream
180
- .on('error', function onDecompressionError(err) {
181
- debug('%s decompression error %o', isZstdSlice ? 'zstd' : 'gzip', err)
182
- linesStream.destroy(err)
183
- })
184
- // and split by new line
185
- .pipe(new BinarySplitBatchStream())
186
- .on('error', function onBinarySplitStreamError(err) {
187
- debug('binary split stream error %o', err)
188
- linesStream.destroy(err)
189
- })
190
+ const { promise: pipelineDone, resolve: onPipelineDone } = Promise.withResolvers<void>()
191
+ const linesStream = pipeline(
192
+ createReadStream(cachedSlicePath, { highWaterMark: CHUNK_SIZE }),
193
+ isZstdSlice ? createZstdDecompressor(CHUNK_SIZE) : createGunzip(GZIP_OPTIONS),
194
+ new BinarySplitBatchStream(),
195
+ (err) => {
196
+ if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
197
+ debug('%s slice pipeline error %o', isZstdSlice ? 'zstd' : 'gzip', err)
198
+ }
199
+ onPipelineDone()
200
+ }
201
+ )
190
202
 
191
203
  let linesCount = 0
192
204
 
193
- for await (const bufferLines of linesStream as AsyncIterable<Buffer[]>) {
194
- linesCount += bufferLines.length
195
- yield bufferLines
205
+ try {
206
+ for await (const bufferLines of linesStream.iterator({ destroyOnReturn: false }) as AsyncIterable<Buffer[]>) {
207
+ linesCount += bufferLines.length
208
+ yield bufferLines
209
+ }
210
+ } finally {
211
+ linesStream.destroy()
212
+ await pipelineDone
196
213
  }
197
214
 
198
215
  debug('processed slice: %s, exchange: %s, count: %d', sliceKey, exchange, linesCount)
@@ -239,9 +256,8 @@ async function* replayLineBatches<T extends Exchange>({
239
256
  )
240
257
  }
241
258
 
242
- const underlyingWorker = worker.getUnderlyingWorker()
243
- if (underlyingWorker !== undefined) {
244
- await terminateWorker(underlyingWorker, 500)
259
+ if (workerExited === false) {
260
+ await terminateWorker(worker, 500)
245
261
  }
246
262
  }
247
263
  }
@@ -283,18 +299,26 @@ function parseReplayThreeDigits(bufferLine: Buffer, start: number) {
283
299
 
284
300
  // gracefully terminate worker
285
301
  async function terminateWorker(worker: Worker, waitTimeout: number) {
286
- let cancelWait = () => {}
287
- const maxWaitGuard = new Promise((resolve) => {
288
- const timeoutId = setTimeout(resolve, waitTimeout)
289
- cancelWait = () => clearTimeout(timeoutId)
290
- })
302
+ await new Promise<void>((resolve) => {
303
+ const finish = () => {
304
+ clearTimeout(timeoutId)
305
+ worker.off('message', onMessage)
306
+ worker.off('exit', finish)
307
+ resolve()
308
+ }
309
+
310
+ const onMessage = (signal: unknown) => {
311
+ if (signal === WorkerSignal.READY_TO_TERMINATE) {
312
+ finish()
313
+ }
314
+ }
291
315
 
292
- const readyToTerminate = new Promise<void>((resolve) => {
293
- worker.once('message', (signal) => signal === WorkerSignal.READY_TO_TERMINATE && resolve())
294
- }).then(cancelWait)
316
+ const timeoutId = setTimeout(finish, waitTimeout)
317
+ worker.on('message', onMessage)
318
+ worker.once('exit', finish)
319
+ worker.postMessage(WorkerSignal.BEFORE_TERMINATE)
320
+ })
295
321
 
296
- worker.postMessage(WorkerSignal.BEFORE_TERMINATE)
297
- await Promise.race([readyToTerminate, maxWaitGuard])
298
322
  await worker.terminate()
299
323
  }
300
324
 
@@ -535,52 +559,6 @@ function validateReplayNormalizedOptions(fromDate: Date, normalizers: MapperFact
535
559
  }
536
560
  }
537
561
 
538
- class ReliableWorker extends EventEmitter {
539
- private _errorsCount = 0
540
- private _worker: Worker | undefined = undefined
541
-
542
- constructor(private readonly _payload: WorkerJobPayload) {
543
- super()
544
-
545
- this._initWorker()
546
- }
547
-
548
- private _initWorker() {
549
- this._worker = new Worker(new URL('./worker.js', import.meta.url), {
550
- workerData: this._payload
551
- })
552
-
553
- this._worker.on('message', (message: WorkerMessage) => {
554
- this.emit('message', message)
555
- })
556
-
557
- this._worker.on('error', this._handleError)
558
-
559
- this._worker.on('exit', (code) => {
560
- debug('worker finished with code: %d', code)
561
- })
562
- }
563
-
564
- private _handleError = async (err: Error) => {
565
- debug('underlying worker error %o', err)
566
-
567
- if (err.message.includes('HttpError') === false && this._errorsCount < 30) {
568
- this._errorsCount++
569
- const delayMS = Math.min(Math.pow(2, this._errorsCount) * 1000, 120 * 1000)
570
- debug('re-init worker after: %d ms', delayMS)
571
- await wait(delayMS)
572
- // it was most likely unhandled socket hang up error, let's retry first with new worker and don't emit error right away
573
- this._initWorker()
574
- } else {
575
- this.emit('error', err)
576
- }
577
- }
578
-
579
- public getUnderlyingWorker() {
580
- return this._worker
581
- }
582
- }
583
-
584
562
  export type ReplayOptions<T extends Exchange, U extends boolean = false, Z extends boolean = false> = {
585
563
  readonly exchange: T
586
564
  readonly from: string