@quantform/core 0.7.0-beta.9 → 0.7.9

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 (396) hide show
  1. package/jest.config.ts +1 -1
  2. package/{dist → lib}/asset/asset.d.ts +3 -0
  3. package/lib/asset/asset.d.ts.map +1 -0
  4. package/{dist → lib}/asset/asset.js +8 -2
  5. package/{dist → lib}/cli/index.js +9 -6
  6. package/lib/cli/internal/script.d.ts +8 -0
  7. package/lib/cli/internal/script.d.ts.map +1 -0
  8. package/lib/cli/internal/script.js +75 -0
  9. package/{dist → lib}/cli/internal/workspace.js +1 -2
  10. package/lib/cli/live.d.ts +5 -0
  11. package/lib/cli/live.d.ts.map +1 -0
  12. package/lib/cli/live.js +33 -0
  13. package/lib/cli/paper.d.ts +5 -0
  14. package/lib/cli/paper.d.ts.map +1 -0
  15. package/lib/cli/paper.js +33 -0
  16. package/lib/cli/pull.d.ts.map +1 -0
  17. package/lib/cli/pull.js +28 -0
  18. package/lib/cli/replay.d.ts +6 -0
  19. package/lib/cli/replay.d.ts.map +1 -0
  20. package/lib/cli/replay.js +37 -0
  21. package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts.map +1 -1
  22. package/{dist → lib}/component/distinct-until-timesamp-changed.js +1 -2
  23. package/lib/component/ohlc-operator.d.ts.map +1 -0
  24. package/{dist → lib}/component/ohlc-operator.js +3 -4
  25. package/{dist → lib}/component/ohlc.d.ts.map +1 -1
  26. package/{dist → lib}/component/timeframe.js +3 -3
  27. package/{dist → lib}/core.js +4 -5
  28. package/lib/index.d.ts +21 -0
  29. package/lib/index.d.ts.map +1 -0
  30. package/{dist → lib}/index.js +6 -13
  31. package/{dist → lib}/instrument/commission/commission.js +3 -3
  32. package/{dist → lib}/instrument/instrument.d.ts +3 -0
  33. package/lib/instrument/instrument.d.ts.map +1 -0
  34. package/{dist → lib}/instrument/instrument.js +8 -2
  35. package/lib/make-test-module.d.ts +13 -0
  36. package/lib/make-test-module.d.ts.map +1 -0
  37. package/{dist → lib}/make-test-module.js +13 -4
  38. package/lib/module.d.ts.map +1 -0
  39. package/lib/operators.d.ts +5 -0
  40. package/lib/operators.d.ts.map +1 -0
  41. package/lib/operators.js +15 -0
  42. package/lib/replay/index.d.ts +10 -0
  43. package/lib/replay/index.d.ts.map +1 -0
  44. package/{dist → lib}/replay/index.js +7 -4
  45. package/lib/replay/replay-guard.d.ts +10 -0
  46. package/lib/replay/replay-guard.d.ts.map +1 -0
  47. package/lib/replay/replay-guard.js +7 -0
  48. package/lib/replay/replay.d.ts +10 -0
  49. package/lib/replay/replay.d.ts.map +1 -0
  50. package/lib/replay/replay.js +8 -0
  51. package/lib/replay/storage/use-replay-storage-buffer.d.ts +15 -0
  52. package/lib/replay/storage/use-replay-storage-buffer.d.ts.map +1 -0
  53. package/lib/replay/storage/use-replay-storage-buffer.js +57 -0
  54. package/lib/replay/storage/use-replay-storage-cursor.d.ts +30 -0
  55. package/lib/replay/storage/use-replay-storage-cursor.d.ts.map +1 -0
  56. package/lib/replay/storage/use-replay-storage-cursor.js +49 -0
  57. package/lib/replay/storage/use-replay-storage.d.ts +13 -0
  58. package/lib/replay/storage/use-replay-storage.d.ts.map +1 -0
  59. package/lib/replay/storage/use-replay-storage.js +38 -0
  60. package/lib/replay/storage/use-replay-storage.spec.d.ts +2 -0
  61. package/lib/replay/storage/use-replay-storage.spec.d.ts.map +1 -0
  62. package/lib/replay/storage/use-replay-storage.spec.js +74 -0
  63. package/lib/replay/use-replay-lock.d.ts +3 -0
  64. package/lib/replay/use-replay-lock.d.ts.map +1 -0
  65. package/lib/replay/use-replay-lock.js +21 -0
  66. package/lib/replay/use-replay-manager.d.ts +28 -0
  67. package/lib/replay/use-replay-manager.d.ts.map +1 -0
  68. package/lib/replay/use-replay-manager.js +68 -0
  69. package/{dist → lib}/replay/use-replay-options.js +2 -2
  70. package/{dist → lib}/replay/use-replay.d.ts +2 -2
  71. package/lib/replay/use-replay.d.ts.map +1 -0
  72. package/lib/replay/use-replay.js +19 -0
  73. package/lib/replay/use-replay.spec.js +130 -0
  74. package/lib/replay/when-replay-finished.d.ts +2 -0
  75. package/lib/replay/when-replay-finished.d.ts.map +1 -0
  76. package/lib/replay/when-replay-finished.js +14 -0
  77. package/lib/session/use-session-object.d.ts +9 -0
  78. package/lib/session/use-session-object.d.ts.map +1 -0
  79. package/{dist → lib}/session/use-session-storage.js +2 -2
  80. package/lib/session/use-session.d.ts +13 -0
  81. package/lib/session/use-session.d.ts.map +1 -0
  82. package/lib/session/use-session.js +14 -0
  83. package/{dist → lib}/shared/datetime.js +1 -2
  84. package/lib/shared/decimals.d.ts +14 -0
  85. package/lib/shared/decimals.d.ts.map +1 -0
  86. package/lib/shared/decimals.js +18 -0
  87. package/{dist → lib}/shared/environment.js +2 -3
  88. package/{dist → lib}/simulator/use-simulator.js +1 -2
  89. package/{dist → lib}/simulator/use-simulator.spec.js +12 -18
  90. package/{dist → lib}/storage/in-memory/in-memory-storage.factory.js +2 -2
  91. package/{dist → lib}/storage/index.d.ts +1 -0
  92. package/{dist → lib}/storage/index.d.ts.map +1 -1
  93. package/{dist → lib}/storage/index.js +1 -0
  94. package/lib/storage/storage.d.ts.map +1 -0
  95. package/{dist → lib}/storage/use-cache.d.ts.map +1 -1
  96. package/lib/storage/use-storage-factory.d.ts +10 -0
  97. package/lib/storage/use-storage-factory.d.ts.map +1 -0
  98. package/lib/storage/use-storage-factory.js +12 -0
  99. package/lib/storage/use-storage.d.ts.map +1 -0
  100. package/{dist → lib}/storage/use-storage.js +2 -2
  101. package/lib/strategy.d.ts +15 -0
  102. package/lib/strategy.d.ts.map +1 -0
  103. package/lib/strategy.js +26 -0
  104. package/lib/strategy.spec.d.ts +2 -0
  105. package/lib/strategy.spec.d.ts.map +1 -0
  106. package/lib/strategy.spec.js +34 -0
  107. package/lib/use-execution-mode.d.ts +20 -0
  108. package/lib/use-execution-mode.d.ts.map +1 -0
  109. package/lib/use-execution-mode.js +32 -0
  110. package/{dist → lib}/use-hash.js +1 -2
  111. package/{dist → lib}/use-logger.js +5 -5
  112. package/lib/use-memo.d.ts +8 -0
  113. package/lib/use-memo.d.ts.map +1 -0
  114. package/lib/use-memo.js +19 -0
  115. package/lib/use-socket.d.ts +20 -0
  116. package/lib/use-socket.d.ts.map +1 -0
  117. package/lib/use-socket.js +82 -0
  118. package/{dist → lib}/use-timestamp.js +3 -4
  119. package/lib/when-socket.d.ts +8 -0
  120. package/lib/when-socket.d.ts.map +1 -0
  121. package/{dist/use-socket.js → lib/when-socket.js} +5 -6
  122. package/lib/with-memo.d.ts +5 -0
  123. package/lib/with-memo.d.ts.map +1 -0
  124. package/{dist/use.js → lib/with-memo.js} +4 -5
  125. package/lib/with-memo.spec.d.ts +2 -0
  126. package/lib/with-memo.spec.d.ts.map +1 -0
  127. package/{dist/use.spec.js → lib/with-memo.spec.js} +3 -3
  128. package/{dist/use-request.d.ts → lib/with-request.d.ts} +6 -6
  129. package/lib/with-request.d.ts.map +1 -0
  130. package/lib/with-request.js +68 -0
  131. package/package.json +5 -5
  132. package/src/asset/asset.ts +6 -0
  133. package/src/cli/index.ts +11 -8
  134. package/src/cli/internal/script.ts +70 -0
  135. package/src/cli/live.ts +22 -0
  136. package/src/cli/paper.ts +22 -0
  137. package/src/cli/pull.ts +6 -66
  138. package/src/cli/replay.ts +15 -19
  139. package/src/core.ts +6 -6
  140. package/src/index.ts +6 -13
  141. package/src/instrument/instrument.ts +6 -0
  142. package/src/make-test-module.ts +20 -4
  143. package/src/operators.ts +18 -0
  144. package/src/replay/index.ts +7 -4
  145. package/src/replay/replay-guard.ts +11 -0
  146. package/src/replay/replay.ts +13 -0
  147. package/src/replay/storage/use-replay-storage-buffer.ts +52 -0
  148. package/src/replay/storage/use-replay-storage-cursor.ts +44 -0
  149. package/src/replay/storage/use-replay-storage.spec.ts +84 -0
  150. package/src/replay/storage/use-replay-storage.ts +29 -0
  151. package/src/replay/use-replay-lock.ts +29 -0
  152. package/src/replay/use-replay-manager.ts +83 -0
  153. package/src/replay/use-replay.spec.ts +10 -4
  154. package/src/replay/use-replay.ts +11 -17
  155. package/src/replay/when-replay-finished.ts +20 -0
  156. package/src/session/use-session-storage.ts +2 -2
  157. package/src/session/use-session.ts +16 -4
  158. package/src/shared/decimals.ts +0 -45
  159. package/src/simulator/use-simulator.spec.ts +10 -26
  160. package/src/storage/index.ts +1 -0
  161. package/src/storage/use-storage-factory.ts +7 -7
  162. package/src/storage/use-storage.ts +2 -2
  163. package/src/strategy.spec.ts +42 -0
  164. package/src/strategy.ts +36 -0
  165. package/src/use-execution-mode.ts +27 -27
  166. package/src/use-logger.ts +7 -7
  167. package/src/use-memo.ts +6 -21
  168. package/src/use-socket.ts +82 -45
  169. package/src/use-timestamp.ts +2 -2
  170. package/src/when-socket.ts +61 -0
  171. package/src/{use.spec.ts → with-memo.spec.ts} +3 -3
  172. package/src/{use.ts → with-memo.ts} +4 -4
  173. package/src/with-request.ts +83 -0
  174. package/tsconfig.json +2 -2
  175. package/dist/as-readonly.d.ts +0 -3
  176. package/dist/as-readonly.d.ts.map +0 -1
  177. package/dist/as-readonly.js +0 -8
  178. package/dist/asset/asset.d.ts.map +0 -1
  179. package/dist/cli/dev.d.ts +0 -2
  180. package/dist/cli/dev.d.ts.map +0 -1
  181. package/dist/cli/dev.js +0 -61
  182. package/dist/cli/pull.d.ts.map +0 -1
  183. package/dist/cli/pull.js +0 -107
  184. package/dist/cli/replay.d.ts +0 -2
  185. package/dist/cli/replay.d.ts.map +0 -1
  186. package/dist/cli/replay.js +0 -64
  187. package/dist/cli/run.d.ts +0 -2
  188. package/dist/cli/run.d.ts.map +0 -1
  189. package/dist/cli/run.js +0 -62
  190. package/dist/component/ohlc-operator.d.ts.map +0 -1
  191. package/dist/defined.d.ts +0 -3
  192. package/dist/defined.d.ts.map +0 -1
  193. package/dist/defined.js +0 -8
  194. package/dist/errored.d.ts +0 -2
  195. package/dist/errored.d.ts.map +0 -1
  196. package/dist/errored.js +0 -4
  197. package/dist/exclude.d.ts +0 -3
  198. package/dist/exclude.d.ts.map +0 -1
  199. package/dist/exclude.js +0 -8
  200. package/dist/index.d.ts +0 -28
  201. package/dist/index.d.ts.map +0 -1
  202. package/dist/instrument/instrument.d.ts.map +0 -1
  203. package/dist/make-test-module.d.ts +0 -13
  204. package/dist/make-test-module.d.ts.map +0 -1
  205. package/dist/module.d.ts.map +0 -1
  206. package/dist/replay/index.d.ts +0 -7
  207. package/dist/replay/index.d.ts.map +0 -1
  208. package/dist/replay/use-replay-coordinator.d.ts +0 -10
  209. package/dist/replay/use-replay-coordinator.d.ts.map +0 -1
  210. package/dist/replay/use-replay-coordinator.js +0 -119
  211. package/dist/replay/use-replay-reader.d.ts +0 -7
  212. package/dist/replay/use-replay-reader.d.ts.map +0 -1
  213. package/dist/replay/use-replay-reader.js +0 -32
  214. package/dist/replay/use-replay-reader.spec.d.ts +0 -2
  215. package/dist/replay/use-replay-reader.spec.d.ts.map +0 -1
  216. package/dist/replay/use-replay-reader.spec.js +0 -58
  217. package/dist/replay/use-replay-storage.d.ts +0 -10
  218. package/dist/replay/use-replay-storage.d.ts.map +0 -1
  219. package/dist/replay/use-replay-storage.js +0 -10
  220. package/dist/replay/use-replay-writer.d.ts +0 -6
  221. package/dist/replay/use-replay-writer.d.ts.map +0 -1
  222. package/dist/replay/use-replay-writer.js +0 -14
  223. package/dist/replay/use-replay-writer.spec.d.ts +0 -2
  224. package/dist/replay/use-replay-writer.spec.d.ts.map +0 -1
  225. package/dist/replay/use-replay-writer.spec.js +0 -53
  226. package/dist/replay/use-replay.d.ts.map +0 -1
  227. package/dist/replay/use-replay.js +0 -32
  228. package/dist/replay/use-replay.spec.js +0 -106
  229. package/dist/replay/with-replay.d.ts +0 -4
  230. package/dist/replay/with-replay.d.ts.map +0 -1
  231. package/dist/replay/with-replay.js +0 -8
  232. package/dist/session/use-session-object.d.ts +0 -18
  233. package/dist/session/use-session-object.d.ts.map +0 -1
  234. package/dist/session/use-session.d.ts +0 -4
  235. package/dist/session/use-session.d.ts.map +0 -1
  236. package/dist/session/use-session.js +0 -7
  237. package/dist/shared/decimals.d.ts +0 -30
  238. package/dist/shared/decimals.d.ts.map +0 -1
  239. package/dist/shared/decimals.js +0 -61
  240. package/dist/storage/storage.d.ts.map +0 -1
  241. package/dist/storage/use-storage-factory.d.ts +0 -10
  242. package/dist/storage/use-storage-factory.d.ts.map +0 -1
  243. package/dist/storage/use-storage-factory.js +0 -14
  244. package/dist/storage/use-storage.d.ts.map +0 -1
  245. package/dist/strat.d.ts +0 -7
  246. package/dist/strat.d.ts.map +0 -1
  247. package/dist/strat.js +0 -7
  248. package/dist/use-execution-mode.d.ts +0 -29
  249. package/dist/use-execution-mode.d.ts.map +0 -1
  250. package/dist/use-execution-mode.js +0 -37
  251. package/dist/use-lock.d.ts +0 -9
  252. package/dist/use-lock.d.ts.map +0 -1
  253. package/dist/use-lock.js +0 -40
  254. package/dist/use-memo.d.ts +0 -21
  255. package/dist/use-memo.d.ts.map +0 -1
  256. package/dist/use-memo.js +0 -35
  257. package/dist/use-request.d.ts.map +0 -1
  258. package/dist/use-request.js +0 -27
  259. package/dist/use-socket.d.ts +0 -6
  260. package/dist/use-socket.d.ts.map +0 -1
  261. package/dist/use-state.d.ts +0 -4
  262. package/dist/use-state.d.ts.map +0 -1
  263. package/dist/use-state.js +0 -24
  264. package/dist/use-state.spec.d.ts +0 -2
  265. package/dist/use-state.spec.d.ts.map +0 -1
  266. package/dist/use-state.spec.js +0 -36
  267. package/dist/use.d.ts +0 -5
  268. package/dist/use.d.ts.map +0 -1
  269. package/dist/use.spec.d.ts +0 -2
  270. package/dist/use.spec.d.ts.map +0 -1
  271. package/src/as-readonly.ts +0 -5
  272. package/src/cli/dev.ts +0 -31
  273. package/src/cli/run.ts +0 -29
  274. package/src/defined.ts +0 -6
  275. package/src/errored.ts +0 -1
  276. package/src/exclude.ts +0 -9
  277. package/src/replay/use-replay-coordinator.ts +0 -142
  278. package/src/replay/use-replay-reader.spec.ts +0 -64
  279. package/src/replay/use-replay-reader.ts +0 -23
  280. package/src/replay/use-replay-storage.ts +0 -8
  281. package/src/replay/use-replay-writer.spec.ts +0 -56
  282. package/src/replay/use-replay-writer.ts +0 -17
  283. package/src/replay/with-replay.ts +0 -10
  284. package/src/strat.ts +0 -7
  285. package/src/use-lock.ts +0 -52
  286. package/src/use-request.ts +0 -47
  287. package/src/use-state.spec.ts +0 -31
  288. package/src/use-state.ts +0 -30
  289. package/{dist → lib}/asset/asset.spec.d.ts +0 -0
  290. package/{dist → lib}/asset/asset.spec.d.ts.map +0 -0
  291. package/{dist → lib}/asset/asset.spec.js +0 -0
  292. package/{dist → lib}/asset/index.d.ts +0 -0
  293. package/{dist → lib}/asset/index.d.ts.map +0 -0
  294. package/{dist → lib}/asset/index.js +0 -0
  295. package/{dist → lib}/cli/build.d.ts +0 -0
  296. package/{dist → lib}/cli/build.d.ts.map +0 -0
  297. package/{dist → lib}/cli/build.js +1 -1
  298. /package/{dist → lib}/cli/index.d.ts +0 -0
  299. /package/{dist → lib}/cli/index.d.ts.map +0 -0
  300. /package/{dist → lib}/cli/internal/workspace.d.ts +0 -0
  301. /package/{dist → lib}/cli/internal/workspace.d.ts.map +0 -0
  302. /package/{dist → lib}/cli/pull.d.ts +0 -0
  303. /package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts +0 -0
  304. /package/{dist → lib}/component/error.d.ts +0 -0
  305. /package/{dist → lib}/component/error.d.ts.map +0 -0
  306. /package/{dist → lib}/component/error.js +0 -0
  307. /package/{dist → lib}/component/index.d.ts +0 -0
  308. /package/{dist → lib}/component/index.d.ts.map +0 -0
  309. /package/{dist → lib}/component/index.js +0 -0
  310. /package/{dist → lib}/component/ohlc-operator.d.ts +0 -0
  311. /package/{dist → lib}/component/ohlc-operator.spec.d.ts +0 -0
  312. /package/{dist → lib}/component/ohlc-operator.spec.d.ts.map +0 -0
  313. /package/{dist → lib}/component/ohlc-operator.spec.js +0 -0
  314. /package/{dist → lib}/component/ohlc.d.ts +0 -0
  315. /package/{dist → lib}/component/ohlc.js +0 -0
  316. /package/{dist → lib}/component/ohlc.spec.d.ts +0 -0
  317. /package/{dist → lib}/component/ohlc.spec.d.ts.map +0 -0
  318. /package/{dist → lib}/component/ohlc.spec.js +0 -0
  319. /package/{dist → lib}/component/timeframe.d.ts +0 -0
  320. /package/{dist → lib}/component/timeframe.d.ts.map +0 -0
  321. /package/{dist → lib}/core.d.ts +0 -0
  322. /package/{dist → lib}/core.d.ts.map +0 -0
  323. /package/{dist → lib}/instrument/commission/commission.d.ts +0 -0
  324. /package/{dist → lib}/instrument/commission/commission.d.ts.map +0 -0
  325. /package/{dist → lib}/instrument/commission/commission.spec.d.ts +0 -0
  326. /package/{dist → lib}/instrument/commission/commission.spec.d.ts.map +0 -0
  327. /package/{dist → lib}/instrument/commission/commission.spec.js +0 -0
  328. /package/{dist → lib}/instrument/index.d.ts +0 -0
  329. /package/{dist → lib}/instrument/index.d.ts.map +0 -0
  330. /package/{dist → lib}/instrument/index.js +0 -0
  331. /package/{dist → lib}/instrument/instrument.spec.d.ts +0 -0
  332. /package/{dist → lib}/instrument/instrument.spec.d.ts.map +0 -0
  333. /package/{dist → lib}/instrument/instrument.spec.js +0 -0
  334. /package/{dist → lib}/module.d.ts +0 -0
  335. /package/{dist → lib}/module.js +0 -0
  336. /package/{dist → lib}/module.spec.d.ts +0 -0
  337. /package/{dist → lib}/module.spec.d.ts.map +0 -0
  338. /package/{dist → lib}/module.spec.js +0 -0
  339. /package/{dist → lib}/replay/use-replay-options.d.ts +0 -0
  340. /package/{dist → lib}/replay/use-replay-options.d.ts.map +0 -0
  341. /package/{dist → lib}/replay/use-replay.spec.d.ts +0 -0
  342. /package/{dist → lib}/replay/use-replay.spec.d.ts.map +0 -0
  343. /package/{dist → lib}/session/index.d.ts +0 -0
  344. /package/{dist → lib}/session/index.d.ts.map +0 -0
  345. /package/{dist → lib}/session/index.js +0 -0
  346. /package/{dist → lib}/session/use-session-object.js +0 -0
  347. /package/{dist → lib}/session/use-session-storage.d.ts +0 -0
  348. /package/{dist → lib}/session/use-session-storage.d.ts.map +0 -0
  349. /package/{dist → lib}/shared/datetime.d.ts +0 -0
  350. /package/{dist → lib}/shared/datetime.d.ts.map +0 -0
  351. /package/{dist → lib}/shared/decimals.spec.d.ts +0 -0
  352. /package/{dist → lib}/shared/decimals.spec.d.ts.map +0 -0
  353. /package/{dist → lib}/shared/decimals.spec.js +0 -0
  354. /package/{dist → lib}/shared/environment.d.ts +0 -0
  355. /package/{dist → lib}/shared/environment.d.ts.map +0 -0
  356. /package/{dist → lib}/shared/index.d.ts +0 -0
  357. /package/{dist → lib}/shared/index.d.ts.map +0 -0
  358. /package/{dist → lib}/shared/index.js +0 -0
  359. /package/{dist → lib}/simulator/index.d.ts +0 -0
  360. /package/{dist → lib}/simulator/index.d.ts.map +0 -0
  361. /package/{dist → lib}/simulator/index.js +0 -0
  362. /package/{dist → lib}/simulator/use-simulator.d.ts +0 -0
  363. /package/{dist → lib}/simulator/use-simulator.d.ts.map +0 -0
  364. /package/{dist → lib}/simulator/use-simulator.spec.d.ts +0 -0
  365. /package/{dist → lib}/simulator/use-simulator.spec.d.ts.map +0 -0
  366. /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts +0 -0
  367. /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts.map +0 -0
  368. /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts +0 -0
  369. /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts.map +0 -0
  370. /package/{dist → lib}/storage/in-memory/in-memory-storage.js +0 -0
  371. /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts +0 -0
  372. /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts.map +0 -0
  373. /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.js +0 -0
  374. /package/{dist → lib}/storage/in-memory/index.d.ts +0 -0
  375. /package/{dist → lib}/storage/in-memory/index.d.ts.map +0 -0
  376. /package/{dist → lib}/storage/in-memory/index.js +0 -0
  377. /package/{dist → lib}/storage/storage.d.ts +0 -0
  378. /package/{dist → lib}/storage/storage.js +0 -0
  379. /package/{dist → lib}/storage/use-cache.d.ts +0 -0
  380. /package/{dist → lib}/storage/use-cache.js +0 -0
  381. /package/{dist → lib}/storage/use-cache.spec.d.ts +0 -0
  382. /package/{dist → lib}/storage/use-cache.spec.d.ts.map +0 -0
  383. /package/{dist → lib}/storage/use-cache.spec.js +0 -0
  384. /package/{dist → lib}/storage/use-storage.d.ts +0 -0
  385. /package/{dist → lib}/use-hash.d.ts +0 -0
  386. /package/{dist → lib}/use-hash.d.ts.map +0 -0
  387. /package/{dist → lib}/use-hash.spec.d.ts +0 -0
  388. /package/{dist → lib}/use-hash.spec.d.ts.map +0 -0
  389. /package/{dist → lib}/use-hash.spec.js +0 -0
  390. /package/{dist → lib}/use-logger.d.ts +0 -0
  391. /package/{dist → lib}/use-logger.d.ts.map +0 -0
  392. /package/{dist → lib}/use-memo.spec.d.ts +0 -0
  393. /package/{dist → lib}/use-memo.spec.d.ts.map +0 -0
  394. /package/{dist → lib}/use-memo.spec.js +0 -0
  395. /package/{dist → lib}/use-timestamp.d.ts +0 -0
  396. /package/{dist → lib}/use-timestamp.d.ts.map +0 -0
package/src/cli/replay.ts CHANGED
@@ -1,31 +1,27 @@
1
- import { join } from 'path';
2
- import { lastValueFrom } from 'rxjs';
3
-
4
1
  import build from '@lib/cli/build';
5
- import { buildDirectory } from '@lib/cli/internal/workspace';
6
- import { core } from '@lib/core';
7
- import { Dependency, Module } from '@lib/module';
8
2
  import { replayOptions } from '@lib/replay';
9
- import { replayExecutionMode } from '@lib/use-execution-mode';
3
+ import { useSession } from '@lib/session';
4
+ import { useExecutionMode } from '@lib/use-execution-mode';
5
+
6
+ import { Script } from './internal/script';
10
7
 
11
- export default async function (name: string, options: any) {
8
+ export default async function (
9
+ name: string,
10
+ options: { id?: string; from?: string; to?: string }
11
+ ) {
12
12
  if (await build()) {
13
13
  return;
14
14
  }
15
15
 
16
- const script = await import(join(buildDirectory(), name));
17
- const dependencies = script.module2 as Dependency[];
16
+ const from = options.from ? new Date(options.from).getTime() : 0;
17
+ const to = options.to ? new Date(options.to).getTime() : Number.MAX_VALUE;
18
18
 
19
- const module = new Module([
20
- ...core(),
21
- ...dependencies,
22
- replayOptions({ from: 0, to: Number.MAX_VALUE }),
23
- replayExecutionMode()
19
+ const script = new Script(name, [
20
+ useSession.options({ id: options.id ?? Date.now().toString() }),
21
+ replayOptions({ from, to }),
22
+ useExecutionMode.replayOptions()
24
23
  ]);
25
-
26
- const { act } = await module.awake();
27
-
28
- const output = await act(() => lastValueFrom(script.default(options)));
24
+ const output = await script.run();
29
25
 
30
26
  console.log(output);
31
27
  }
package/src/core.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { Dependency } from '@lib/module';
2
- import { memo } from '@lib/use-memo';
2
+ import { useMemo } from '@lib/use-memo';
3
3
 
4
4
  import { InMemoryStorageFactory } from './storage';
5
- import { storage } from './storage/use-storage-factory';
6
- import { paperExecutionMode } from './use-execution-mode';
5
+ import { useStorageFactory } from './storage/use-storage-factory';
6
+ import { useExecutionMode } from './use-execution-mode';
7
7
 
8
8
  export function core(): Dependency[] {
9
9
  return [
10
- memo(),
11
- paperExecutionMode({ recording: false }),
12
- storage(new InMemoryStorageFactory())
10
+ useMemo.options(),
11
+ useExecutionMode.paperOptions({ recording: false }),
12
+ useStorageFactory.options(new InMemoryStorageFactory())
13
13
  ];
14
14
  }
package/src/index.ts CHANGED
@@ -7,21 +7,14 @@ export * from '@lib/use-timestamp';
7
7
  export * from '@lib/simulator';
8
8
  export * from '@lib/make-test-module';
9
9
  export * from '@lib/core';
10
- export * from '@lib/use-state';
11
- export * from '@lib/replay/use-replay-coordinator';
12
10
  export * from '@lib/use-execution-mode';
13
- export * from '@lib/storage/use-storage';
14
- export * from '@lib/storage/use-cache';
11
+ export * from '@lib/storage';
15
12
  export * from '@lib/use-logger';
16
13
  export * from '@lib/replay';
17
- export * from '@lib/replay/use-replay-coordinator';
18
14
  export * from '@lib/use-socket';
19
- export * from '@lib/use-request';
20
- export * from '@lib/defined';
21
- export * from '@lib/as-readonly';
22
- export * from '@lib/use';
15
+ export * from '@lib/when-socket';
16
+ export * from '@lib/with-request';
17
+ export * from '@lib/with-memo';
23
18
  export * from '@lib/session';
24
- export * from '@lib/exclude';
25
- export * from '@lib/use-lock';
26
- export * from '@lib/strat';
27
- export * from '@lib/errored';
19
+ export * from '@lib/strategy';
20
+ export * from '@lib/operators';
@@ -5,6 +5,12 @@ import { Commission } from './commission/commission';
5
5
 
6
6
  export const InstrumentSelectorSeparator = '-';
7
7
 
8
+ export class MissingInstrumentError extends Error {
9
+ constructor(instrument: InstrumentSelector) {
10
+ super(`Missing instrument: ${instrument}`);
11
+ }
12
+ }
13
+
8
14
  export class InstrumentSelector {
9
15
  readonly id: string;
10
16
  readonly base: AssetSelector;
@@ -1,4 +1,4 @@
1
- import { Observable, tap } from 'rxjs';
1
+ import { Observable, Subject } from 'rxjs';
2
2
 
3
3
  import { core } from '@lib/core';
4
4
  import { Dependency, Module } from '@lib/module';
@@ -20,9 +20,9 @@ export const mockedFunc = <Func extends MockableFunction>(mockedFunc: Func) =>
20
20
  mockedFunc as jest.MockedFunction<typeof mockedFunc>;
21
21
 
22
22
  export function toArray<T>(observable: Observable<T>) {
23
- const array = Array.of<T>();
23
+ const array = Array.of<T | Error>();
24
24
 
25
- const clone = (it: T): T => {
25
+ const clone = (it: T | Error): T | Error => {
26
26
  if (typeof it === 'symbol') {
27
27
  return it;
28
28
  }
@@ -38,9 +38,25 @@ export function toArray<T>(observable: Observable<T>) {
38
38
  return it;
39
39
  };
40
40
 
41
- observable.pipe(tap(it => array.push(clone(it)))).subscribe();
41
+ observable.subscribe({
42
+ next: it => array.push(clone(it)),
43
+ error: it => array.push(it)
44
+ });
42
45
 
43
46
  return array;
44
47
  }
45
48
 
46
49
  export type InferObservableType<T> = T extends Observable<infer U> ? U : never;
50
+
51
+ export function mockSubject<
52
+ T extends jest.FunctionProperties<Required<T>>,
53
+ M extends keyof jest.FunctionProperties<Required<T>>
54
+ >(object: T, method: M) {
55
+ const subject = new Subject<
56
+ InferObservableType<ReturnType<jest.FunctionProperties<Required<T>>[M]>>
57
+ >();
58
+
59
+ jest.spyOn<T, M>(object, method).mockReturnValue(subject.asObservable() as any);
60
+
61
+ return subject;
62
+ }
@@ -0,0 +1,18 @@
1
+ import { filter, map, Observable } from 'rxjs';
2
+
3
+ export function asReadonly<T>() {
4
+ return (input: Observable<T>) => input.pipe(map(it => it as Readonly<T>));
5
+ }
6
+
7
+ export function defined<T>() {
8
+ return (observable: Observable<T | undefined | null>) =>
9
+ observable.pipe(filter(it => it !== undefined && it !== null));
10
+ }
11
+
12
+ export function exclude<T, S extends symbol>(s: S) {
13
+ return (observable: Observable<T | S>) =>
14
+ observable.pipe(
15
+ filter(it => it !== s),
16
+ map(it => it as Exclude<T, typeof s>)
17
+ );
18
+ }
@@ -1,6 +1,9 @@
1
1
  export * from './use-replay';
2
- export * from './use-replay-coordinator';
2
+ export * from './use-replay-lock';
3
3
  export * from './use-replay-options';
4
- export * from './use-replay-reader';
5
- export * from './use-replay-writer';
6
- export * from './with-replay';
4
+ export * from './storage/use-replay-storage';
5
+ export * from './storage/use-replay-storage-buffer';
6
+ export * from './use-replay-manager';
7
+ export * from './when-replay-finished';
8
+ export * from './replay';
9
+ export * from './replay-guard';
@@ -0,0 +1,11 @@
1
+ import { Observable } from 'rxjs';
2
+
3
+ import { dependency } from '@lib/use-hash';
4
+
5
+ import { useReplayLock } from './use-replay-lock';
6
+
7
+ export function replayGuard<T extends Array<dependency>, K>(
8
+ fn: (...args: T) => Observable<{ timestamp: number; payload: K }>
9
+ ): (...args: T) => Observable<{ timestamp: number; payload: K }> {
10
+ return (...args: T) => useReplayLock(fn(...args));
11
+ }
@@ -0,0 +1,13 @@
1
+ import { Observable } from 'rxjs';
2
+
3
+ import { dependency } from '@lib/use-hash';
4
+ import { withMemo } from '@lib/with-memo';
5
+
6
+ import { useReplay } from './use-replay';
7
+
8
+ export function replay<T extends Array<dependency>, K>(
9
+ fn: (...args: T) => Observable<{ timestamp: number; payload: K }>,
10
+ dependencies: dependency[]
11
+ ): (...args: T) => Observable<{ timestamp: number; payload: K }> {
12
+ return withMemo((...args: T) => useReplay(fn(...args), [...dependencies, ...args]));
13
+ }
@@ -0,0 +1,52 @@
1
+ import { useReplayOptions } from '@lib/replay/use-replay-options';
2
+ import { between } from '@lib/storage';
3
+ import { dependency } from '@lib/use-hash';
4
+ import { withMemo } from '@lib/with-memo';
5
+
6
+ import { useReplayStorage } from './use-replay-storage';
7
+
8
+ export const useReplayStorageBuffer = withMemo(<T>(dependencies: dependency[]) => {
9
+ const { query } = useReplayStorage<T>(dependencies);
10
+ const { from, to } = useReplayOptions();
11
+
12
+ console.log(from, to);
13
+
14
+ let page = new Array<{ timestamp: number; payload: T }>();
15
+ let index = 0;
16
+ let completed = false;
17
+ let count = 0;
18
+
19
+ return {
20
+ size() {
21
+ return page.length - index;
22
+ },
23
+ peek() {
24
+ return page[index];
25
+ },
26
+ dequeue() {
27
+ return page[index++];
28
+ },
29
+ completed() {
30
+ return completed;
31
+ },
32
+ async fetchNextPage() {
33
+ if (completed) {
34
+ return;
35
+ }
36
+
37
+ index = 0;
38
+
39
+ page = await query({
40
+ where: {
41
+ timestamp: between(from, to)
42
+ },
43
+ limit: 10000,
44
+ offset: count,
45
+ orderBy: 'ASC'
46
+ });
47
+
48
+ count += page.length;
49
+ completed = page.length == 0;
50
+ }
51
+ };
52
+ });
@@ -0,0 +1,44 @@
1
+ import { dependency, useHash } from '@lib/use-hash';
2
+ import { useLogger } from '@lib/use-logger';
3
+ import { withMemo } from '@lib/with-memo';
4
+
5
+ import { useReplayStorageBuffer } from './use-replay-storage-buffer';
6
+
7
+ export const useReplayStorageCursor = withMemo(() => {
8
+ const { info } = useLogger('useReplayStorageCursor');
9
+ const storages = Array.of<ReturnType<typeof useReplayStorageBuffer<any>>>();
10
+
11
+ return {
12
+ get<T>(dependencies: dependency[]) {
13
+ const storage = useReplayStorageBuffer<T>(dependencies);
14
+
15
+ if (!storages.includes(storage)) {
16
+ info('opening a new replay buffer', useHash(dependencies));
17
+ storages.push(storage);
18
+ }
19
+
20
+ return storage;
21
+ },
22
+ async cursor() {
23
+ let current: ReturnType<typeof useReplayStorageBuffer<any>> | undefined;
24
+
25
+ for (const storage of storages) {
26
+ if (storage.completed()) {
27
+ continue;
28
+ }
29
+
30
+ if (storage.size() == 0) {
31
+ await storage.fetchNextPage();
32
+ }
33
+
34
+ if (storage.peek()) {
35
+ if (!current || current.peek().timestamp > storage.peek().timestamp) {
36
+ current = storage;
37
+ }
38
+ }
39
+ }
40
+
41
+ return current;
42
+ }
43
+ };
44
+ });
@@ -0,0 +1,84 @@
1
+ import { makeTestModule, mockedFunc } from '@lib/make-test-module';
2
+ import { Query, QueryObject, Storage } from '@lib/storage';
3
+ import { useStorage } from '@lib/storage';
4
+
5
+ import { useReplayStorage } from './use-replay-storage';
6
+
7
+ jest.mock('@lib/storage', () => ({
8
+ ...jest.requireActual('@lib/storage'),
9
+ useStorage: jest.fn()
10
+ }));
11
+
12
+ describe(useReplayStorage.name, () => {
13
+ let fixtures: Awaited<ReturnType<typeof getFixtures>>;
14
+
15
+ beforeEach(async () => {
16
+ fixtures = await getFixtures();
17
+ });
18
+
19
+ describe('query', () => {
20
+ test('happy path', async () => {
21
+ await fixtures.given.stored(fixtures.sample);
22
+ const sample = await fixtures.when.queried({});
23
+
24
+ expect(sample).toEqual(fixtures.sample);
25
+ });
26
+ });
27
+
28
+ describe('save', () => {
29
+ test('happy path', async () => {
30
+ await fixtures.when.saved(fixtures.sample);
31
+ await fixtures.then.stored(fixtures.sample);
32
+ });
33
+ });
34
+ });
35
+
36
+ async function getFixtures() {
37
+ const { act } = await makeTestModule([]);
38
+
39
+ const dependencies = ['binance:btc-usdt', 'candle', 'h1'];
40
+ const save: Storage['save'] = jest.fn();
41
+ const query: jest.MockedFunction<Storage['query']> = jest.fn();
42
+
43
+ mockedFunc(useStorage).mockReturnValue({ save, query } as any);
44
+
45
+ return {
46
+ sample: [
47
+ { timestamp: 1, payload: { o: 1.1, h: 1.1, l: 1.1, c: 1.1 } },
48
+ { timestamp: 2, payload: { o: 1.1, h: 2.2, l: 1.1, c: 2.2 } },
49
+ { timestamp: 3, payload: { o: 1.1, h: 3.3, l: 1.1, c: 3.3 } }
50
+ ],
51
+
52
+ given: {
53
+ stored<T>(sample: { timestamp: number; payload: T }[]) {
54
+ return query.mockReturnValue(
55
+ Promise.resolve(
56
+ sample.map(it => ({
57
+ timestamp: it.timestamp,
58
+ payload: JSON.stringify(it.payload)
59
+ }))
60
+ )
61
+ );
62
+ }
63
+ },
64
+ when: {
65
+ saved<T>(sample: { timestamp: number; payload: T }[]) {
66
+ return act(() => useReplayStorage(dependencies).save(sample));
67
+ },
68
+ queried<T>(query: Query<QueryObject>) {
69
+ return act(() => useReplayStorage<T>(dependencies).query(query));
70
+ }
71
+ },
72
+ then: {
73
+ stored<T>(sample: { timestamp: number; payload: T }[]) {
74
+ expect(save).toHaveBeenCalledWith(
75
+ expect.anything(),
76
+ sample.map(it => ({
77
+ timestamp: it.timestamp,
78
+ payload: JSON.stringify(it.payload)
79
+ }))
80
+ );
81
+ }
82
+ }
83
+ };
84
+ }
@@ -0,0 +1,29 @@
1
+ import { Query, QueryObject, Storage, useStorage } from '@lib/storage';
2
+ import { dependency, useHash } from '@lib/use-hash';
3
+
4
+ export function useReplayStorage<T>(dependencies: dependency[]) {
5
+ const storage = useStorage(['replay']);
6
+ const storageObjectKey = useHash(dependencies);
7
+ const storageObject = Storage.createObject(storageObjectKey, {
8
+ timestamp: 'number',
9
+ payload: 'string'
10
+ });
11
+
12
+ return {
13
+ async query(query: Query<QueryObject>) {
14
+ return (await storage.query(storageObject, query)).map(it => ({
15
+ timestamp: it.timestamp,
16
+ payload: JSON.parse(it.payload) as T
17
+ }));
18
+ },
19
+ save(objects: { timestamp: number; payload: T }[]) {
20
+ return storage.save(
21
+ storageObject,
22
+ objects.map(it => ({
23
+ timestamp: it.timestamp,
24
+ payload: JSON.stringify(it.payload)
25
+ }))
26
+ );
27
+ }
28
+ };
29
+ }
@@ -0,0 +1,29 @@
1
+ import { finalize, Observable } from 'rxjs';
2
+
3
+ import { useExecutionMode } from '@lib/use-execution-mode';
4
+ import { useLogger } from '@lib/use-logger';
5
+
6
+ import { useReplayManager } from './use-replay-manager';
7
+
8
+ export function useReplayLock<T>(input: Observable<T>): Observable<T> {
9
+ const { isReplay } = useExecutionMode();
10
+
11
+ if (!isReplay) {
12
+ return input;
13
+ }
14
+
15
+ const { info } = useLogger('replay');
16
+ const { stop, tryContinue } = useReplayManager();
17
+
18
+ info('lock acquired');
19
+
20
+ stop();
21
+
22
+ return input.pipe(
23
+ finalize(() => {
24
+ info('lock released');
25
+
26
+ tryContinue();
27
+ })
28
+ );
29
+ }
@@ -0,0 +1,83 @@
1
+ import { defer, filter, map, Observable, Subject } from 'rxjs';
2
+
3
+ import { dependency } from '@lib/use-hash';
4
+ import { withMemo } from '@lib/with-memo';
5
+
6
+ import { useReplayStorageBuffer } from './storage/use-replay-storage-buffer';
7
+ import { useReplayStorageCursor } from './storage/use-replay-storage-cursor';
8
+ import { useReplayOptions } from './use-replay-options';
9
+
10
+ export const useReplayManager = withMemo(() => {
11
+ const { from } = useReplayOptions();
12
+ const { get, cursor } = useReplayStorageCursor();
13
+
14
+ let timestamp = from;
15
+ let stopAcquire = 1;
16
+
17
+ const stream$ = new Subject<
18
+ [ReturnType<typeof useReplayStorageBuffer<any>>, { timestamp: number; payload: any }]
19
+ >();
20
+
21
+ const processNext = async () => {
22
+ const storage = await cursor();
23
+
24
+ if (!storage || !storage.peek()) {
25
+ stream$.complete();
26
+
27
+ return false;
28
+ }
29
+
30
+ const sample = storage.dequeue();
31
+
32
+ timestamp = sample.timestamp;
33
+
34
+ stream$.next([storage, sample]);
35
+
36
+ return true;
37
+ };
38
+
39
+ const next = async () => {
40
+ if (await processNext()) {
41
+ if (stopAcquire === 0) {
42
+ setImmediate(next);
43
+ }
44
+ }
45
+ };
46
+
47
+ const tryContinue = () => {
48
+ if (stopAcquire == 0) {
49
+ return;
50
+ }
51
+
52
+ stopAcquire = Math.max(0, stopAcquire - 1);
53
+
54
+ if (stopAcquire != 0) {
55
+ return;
56
+ }
57
+
58
+ next();
59
+ };
60
+
61
+ return {
62
+ stream: stream$.asObservable(),
63
+ timestamp() {
64
+ return timestamp;
65
+ },
66
+ stop() {
67
+ stopAcquire++;
68
+ },
69
+ tryContinue,
70
+ watch<T>(dependencies: dependency[]): Observable<{ timestamp: number; payload: T }> {
71
+ const storage = get<T>(dependencies);
72
+
73
+ return defer(() => {
74
+ tryContinue();
75
+
76
+ return stream$.pipe(
77
+ filter(([cur]) => cur === storage),
78
+ map(([, it]) => ({ timestamp: it.timestamp, payload: it.payload as T }))
79
+ );
80
+ });
81
+ }
82
+ };
83
+ });
@@ -1,15 +1,20 @@
1
+ import exp from 'constants';
1
2
  import { from, lastValueFrom, tap } from 'rxjs';
2
3
 
3
4
  import { makeTestModule } from '@lib/make-test-module';
4
- import { useReplayCoordinator } from '@lib/replay/use-replay-coordinator';
5
- import { replayExecutionMode } from '@lib/use-execution-mode';
6
5
  import { dependency } from '@lib/use-hash';
7
6
 
8
7
  import { between } from '..';
9
8
  import { useReplay } from './use-replay';
10
9
  import { replayOptions } from './use-replay-options';
11
- import { useReplayReader } from './use-replay-reader';
12
- import { useReplayWriter } from './use-replay-writer';
10
+
11
+ describe(useReplay.name, () => {
12
+ test('happy path', () => {
13
+ expect(true).toBe(true);
14
+ });
15
+ });
16
+
17
+ /*
13
18
 
14
19
  describe.skip(useReplayCoordinator.name, () => {
15
20
  let fixtures: Awaited<ReturnType<typeof getFixtures>>;
@@ -130,3 +135,4 @@ async function getFixtures() {
130
135
  }
131
136
  };
132
137
  }
138
+ */
@@ -1,34 +1,28 @@
1
- import { concatMap, map, Observable } from 'rxjs';
1
+ import { Observable, tap } from 'rxjs';
2
2
 
3
- import { useReplayCoordinator } from '@lib/replay/use-replay-coordinator';
4
3
  import { useExecutionMode } from '@lib/use-execution-mode';
5
4
  import { dependency } from '@lib/use-hash';
6
5
 
7
- import { useReplayWriter } from './use-replay-writer';
6
+ import { useReplayStorage } from './storage/use-replay-storage';
7
+ import { useReplayManager } from './use-replay-manager';
8
8
 
9
- export const useReplay = <T>(
9
+ export function useReplay<T>(
10
10
  input: Observable<{ timestamp: number; payload: T }>,
11
11
  dependencies: dependency[]
12
- ) => {
12
+ ) {
13
13
  const { isReplay, recording } = useExecutionMode();
14
14
 
15
15
  if (isReplay) {
16
- const { subscribe } = useReplayCoordinator();
16
+ const { watch } = useReplayManager();
17
17
 
18
- return subscribe(dependencies).pipe(
19
- map(it => it as unknown as { timestamp: number; payload: T })
20
- );
18
+ return watch<T>(dependencies);
21
19
  }
22
20
 
23
21
  if (recording) {
24
- const writer = useReplayWriter(dependencies);
25
- return input.pipe(
26
- concatMap(async it => {
27
- await writer([it]);
28
- return it;
29
- })
30
- );
22
+ const { save } = useReplayStorage<T>(dependencies);
23
+
24
+ return input.pipe(tap(it => save([it])));
31
25
  }
32
26
 
33
27
  return input;
34
- };
28
+ }
@@ -0,0 +1,20 @@
1
+ import { from, last, map, Subject } from 'rxjs';
2
+
3
+ import { useExecutionMode } from '@lib/use-execution-mode';
4
+
5
+ import { useReplayManager } from './use-replay-manager';
6
+
7
+ export function whenReplayFinished() {
8
+ const { isReplay } = useExecutionMode();
9
+
10
+ if (!isReplay) {
11
+ return new Subject<boolean>().asObservable();
12
+ }
13
+
14
+ const { stream } = useReplayManager();
15
+
16
+ return from(stream).pipe(
17
+ last(),
18
+ map(() => true)
19
+ );
20
+ }
@@ -1,8 +1,8 @@
1
1
  import { useSession } from '@lib/session';
2
2
  import { useStorage } from '@lib/storage';
3
- import { use } from '@lib/use';
3
+ import { withMemo } from '@lib/with-memo';
4
4
 
5
- export const useSessionStorage = use(() => {
5
+ export const useSessionStorage = withMemo(() => {
6
6
  const { id } = useSession();
7
7
 
8
8
  return useStorage(['session', id]);
@@ -1,5 +1,17 @@
1
- import { use } from '@lib/use';
1
+ import { Dependency, useContext } from '@lib/module';
2
2
 
3
- export const useSession = use(() => ({
4
- id: 'ttt' //Date.now()
5
- }));
3
+ const token = Symbol('session-options');
4
+
5
+ type SessionOptions = {
6
+ id: string;
7
+ };
8
+
9
+ /**
10
+ * Will return current replay execution options.
11
+ */
12
+ export const useSession = () => useContext<SessionOptions>(token);
13
+
14
+ useSession.options = (options: SessionOptions): Dependency => ({
15
+ provide: token,
16
+ useValue: options
17
+ });