@quantform/core 0.7.0-beta.49 → 0.7.0-beta.50

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 (273) hide show
  1. package/jest.config.ts +1 -1
  2. package/{dist → lib}/cli/index.js +9 -6
  3. package/lib/cli/live.d.ts +5 -0
  4. package/lib/cli/live.d.ts.map +1 -0
  5. package/{dist/cli/replay.js → lib/cli/live.js} +4 -3
  6. package/lib/cli/paper.d.ts +5 -0
  7. package/lib/cli/paper.d.ts.map +1 -0
  8. package/{dist/cli/dev.js → lib/cli/paper.js} +6 -1
  9. package/{dist → lib}/cli/pull.js +1 -1
  10. package/lib/cli/replay.d.ts +6 -0
  11. package/lib/cli/replay.d.ts.map +1 -0
  12. package/{dist/cli/run.js → lib/cli/replay.js} +10 -1
  13. package/{dist → lib}/core.js +3 -3
  14. package/{dist → lib}/index.d.ts +1 -0
  15. package/{dist → lib}/index.d.ts.map +1 -1
  16. package/{dist → lib}/index.js +1 -0
  17. package/{dist → lib}/replay/storage/use-replay-storage-buffer.d.ts.map +1 -1
  18. package/{dist → lib}/replay/storage/use-replay-storage-buffer.js +1 -0
  19. package/lib/session/use-session.d.ts +13 -0
  20. package/lib/session/use-session.d.ts.map +1 -0
  21. package/lib/session/use-session.js +14 -0
  22. package/{dist → lib}/simulator/use-simulator.spec.js +12 -18
  23. package/lib/storage/use-storage-factory.d.ts +10 -0
  24. package/lib/storage/use-storage-factory.d.ts.map +1 -0
  25. package/lib/storage/use-storage-factory.js +13 -0
  26. package/lib/use-execution-mode.d.ts +20 -0
  27. package/lib/use-execution-mode.d.ts.map +1 -0
  28. package/lib/use-execution-mode.js +33 -0
  29. package/{dist → lib}/use-logger.js +1 -1
  30. package/{dist → lib}/use-memo.d.ts +4 -7
  31. package/lib/use-memo.d.ts.map +1 -0
  32. package/{dist → lib}/use-memo.js +5 -11
  33. package/package.json +4 -4
  34. package/src/cli/index.ts +11 -8
  35. package/src/cli/live.ts +22 -0
  36. package/src/cli/paper.ts +22 -0
  37. package/src/cli/pull.ts +2 -2
  38. package/src/cli/replay.ts +12 -4
  39. package/src/core.ts +6 -6
  40. package/src/index.ts +1 -0
  41. package/src/replay/storage/use-replay-storage-buffer.ts +2 -0
  42. package/src/replay/use-replay.spec.ts +0 -1
  43. package/src/session/use-session.ts +16 -4
  44. package/src/simulator/use-simulator.spec.ts +10 -26
  45. package/src/storage/use-storage-factory.ts +7 -7
  46. package/src/use-execution-mode.ts +23 -31
  47. package/src/use-logger.ts +3 -3
  48. package/src/use-memo.ts +6 -11
  49. package/tsconfig.json +2 -2
  50. package/dist/cli/dev.d.ts +0 -2
  51. package/dist/cli/dev.d.ts.map +0 -1
  52. package/dist/cli/replay.d.ts +0 -2
  53. package/dist/cli/replay.d.ts.map +0 -1
  54. package/dist/cli/run.d.ts +0 -2
  55. package/dist/cli/run.d.ts.map +0 -1
  56. package/dist/session/use-session.d.ts +0 -4
  57. package/dist/session/use-session.d.ts.map +0 -1
  58. package/dist/session/use-session.js +0 -7
  59. package/dist/storage/use-storage-factory.d.ts +0 -10
  60. package/dist/storage/use-storage-factory.d.ts.map +0 -1
  61. package/dist/storage/use-storage-factory.js +0 -14
  62. package/dist/use-execution-mode.d.ts +0 -34
  63. package/dist/use-execution-mode.d.ts.map +0 -1
  64. package/dist/use-execution-mode.js +0 -45
  65. package/dist/use-memo.d.ts.map +0 -1
  66. package/src/cli/dev.ts +0 -15
  67. package/src/cli/run.ts +0 -15
  68. /package/{dist → lib}/asset/asset.d.ts +0 -0
  69. /package/{dist → lib}/asset/asset.d.ts.map +0 -0
  70. /package/{dist → lib}/asset/asset.js +0 -0
  71. /package/{dist → lib}/asset/asset.spec.d.ts +0 -0
  72. /package/{dist → lib}/asset/asset.spec.d.ts.map +0 -0
  73. /package/{dist → lib}/asset/asset.spec.js +0 -0
  74. /package/{dist → lib}/asset/index.d.ts +0 -0
  75. /package/{dist → lib}/asset/index.d.ts.map +0 -0
  76. /package/{dist → lib}/asset/index.js +0 -0
  77. /package/{dist → lib}/cli/build.d.ts +0 -0
  78. /package/{dist → lib}/cli/build.d.ts.map +0 -0
  79. /package/{dist → lib}/cli/build.js +0 -0
  80. /package/{dist → lib}/cli/index.d.ts +0 -0
  81. /package/{dist → lib}/cli/index.d.ts.map +0 -0
  82. /package/{dist → lib}/cli/internal/script.d.ts +0 -0
  83. /package/{dist → lib}/cli/internal/script.d.ts.map +0 -0
  84. /package/{dist → lib}/cli/internal/script.js +0 -0
  85. /package/{dist → lib}/cli/internal/workspace.d.ts +0 -0
  86. /package/{dist → lib}/cli/internal/workspace.d.ts.map +0 -0
  87. /package/{dist → lib}/cli/internal/workspace.js +0 -0
  88. /package/{dist → lib}/cli/pull.d.ts +0 -0
  89. /package/{dist → lib}/cli/pull.d.ts.map +0 -0
  90. /package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts +0 -0
  91. /package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts.map +0 -0
  92. /package/{dist → lib}/component/distinct-until-timesamp-changed.js +0 -0
  93. /package/{dist → lib}/component/error.d.ts +0 -0
  94. /package/{dist → lib}/component/error.d.ts.map +0 -0
  95. /package/{dist → lib}/component/error.js +0 -0
  96. /package/{dist → lib}/component/index.d.ts +0 -0
  97. /package/{dist → lib}/component/index.d.ts.map +0 -0
  98. /package/{dist → lib}/component/index.js +0 -0
  99. /package/{dist → lib}/component/ohlc-operator.d.ts +0 -0
  100. /package/{dist → lib}/component/ohlc-operator.d.ts.map +0 -0
  101. /package/{dist → lib}/component/ohlc-operator.js +0 -0
  102. /package/{dist → lib}/component/ohlc-operator.spec.d.ts +0 -0
  103. /package/{dist → lib}/component/ohlc-operator.spec.d.ts.map +0 -0
  104. /package/{dist → lib}/component/ohlc-operator.spec.js +0 -0
  105. /package/{dist → lib}/component/ohlc.d.ts +0 -0
  106. /package/{dist → lib}/component/ohlc.d.ts.map +0 -0
  107. /package/{dist → lib}/component/ohlc.js +0 -0
  108. /package/{dist → lib}/component/ohlc.spec.d.ts +0 -0
  109. /package/{dist → lib}/component/ohlc.spec.d.ts.map +0 -0
  110. /package/{dist → lib}/component/ohlc.spec.js +0 -0
  111. /package/{dist → lib}/component/timeframe.d.ts +0 -0
  112. /package/{dist → lib}/component/timeframe.d.ts.map +0 -0
  113. /package/{dist → lib}/component/timeframe.js +0 -0
  114. /package/{dist → lib}/core.d.ts +0 -0
  115. /package/{dist → lib}/core.d.ts.map +0 -0
  116. /package/{dist → lib}/instrument/commission/commission.d.ts +0 -0
  117. /package/{dist → lib}/instrument/commission/commission.d.ts.map +0 -0
  118. /package/{dist → lib}/instrument/commission/commission.js +0 -0
  119. /package/{dist → lib}/instrument/commission/commission.spec.d.ts +0 -0
  120. /package/{dist → lib}/instrument/commission/commission.spec.d.ts.map +0 -0
  121. /package/{dist → lib}/instrument/commission/commission.spec.js +0 -0
  122. /package/{dist → lib}/instrument/index.d.ts +0 -0
  123. /package/{dist → lib}/instrument/index.d.ts.map +0 -0
  124. /package/{dist → lib}/instrument/index.js +0 -0
  125. /package/{dist → lib}/instrument/instrument.d.ts +0 -0
  126. /package/{dist → lib}/instrument/instrument.d.ts.map +0 -0
  127. /package/{dist → lib}/instrument/instrument.js +0 -0
  128. /package/{dist → lib}/instrument/instrument.spec.d.ts +0 -0
  129. /package/{dist → lib}/instrument/instrument.spec.d.ts.map +0 -0
  130. /package/{dist → lib}/instrument/instrument.spec.js +0 -0
  131. /package/{dist → lib}/make-test-module.d.ts +0 -0
  132. /package/{dist → lib}/make-test-module.d.ts.map +0 -0
  133. /package/{dist → lib}/make-test-module.js +0 -0
  134. /package/{dist → lib}/module.d.ts +0 -0
  135. /package/{dist → lib}/module.d.ts.map +0 -0
  136. /package/{dist → lib}/module.js +0 -0
  137. /package/{dist → lib}/module.spec.d.ts +0 -0
  138. /package/{dist → lib}/module.spec.d.ts.map +0 -0
  139. /package/{dist → lib}/module.spec.js +0 -0
  140. /package/{dist → lib}/operators.d.ts +0 -0
  141. /package/{dist → lib}/operators.d.ts.map +0 -0
  142. /package/{dist → lib}/operators.js +0 -0
  143. /package/{dist → lib}/replay/index.d.ts +0 -0
  144. /package/{dist → lib}/replay/index.d.ts.map +0 -0
  145. /package/{dist → lib}/replay/index.js +0 -0
  146. /package/{dist → lib}/replay/replay-guard.d.ts +0 -0
  147. /package/{dist → lib}/replay/replay-guard.d.ts.map +0 -0
  148. /package/{dist → lib}/replay/replay-guard.js +0 -0
  149. /package/{dist → lib}/replay/replay.d.ts +0 -0
  150. /package/{dist → lib}/replay/replay.d.ts.map +0 -0
  151. /package/{dist → lib}/replay/replay.js +0 -0
  152. /package/{dist → lib}/replay/storage/use-replay-storage-buffer.d.ts +0 -0
  153. /package/{dist → lib}/replay/storage/use-replay-storage-cursor.d.ts +0 -0
  154. /package/{dist → lib}/replay/storage/use-replay-storage-cursor.d.ts.map +0 -0
  155. /package/{dist → lib}/replay/storage/use-replay-storage-cursor.js +0 -0
  156. /package/{dist → lib}/replay/storage/use-replay-storage.d.ts +0 -0
  157. /package/{dist → lib}/replay/storage/use-replay-storage.d.ts.map +0 -0
  158. /package/{dist → lib}/replay/storage/use-replay-storage.js +0 -0
  159. /package/{dist → lib}/replay/storage/use-replay-storage.spec.d.ts +0 -0
  160. /package/{dist → lib}/replay/storage/use-replay-storage.spec.d.ts.map +0 -0
  161. /package/{dist → lib}/replay/storage/use-replay-storage.spec.js +0 -0
  162. /package/{dist → lib}/replay/use-replay-breakpoint.d.ts +0 -0
  163. /package/{dist → lib}/replay/use-replay-breakpoint.d.ts.map +0 -0
  164. /package/{dist → lib}/replay/use-replay-breakpoint.js +0 -0
  165. /package/{dist → lib}/replay/use-replay-manager.d.ts +0 -0
  166. /package/{dist → lib}/replay/use-replay-manager.d.ts.map +0 -0
  167. /package/{dist → lib}/replay/use-replay-manager.js +0 -0
  168. /package/{dist → lib}/replay/use-replay-options.d.ts +0 -0
  169. /package/{dist → lib}/replay/use-replay-options.d.ts.map +0 -0
  170. /package/{dist → lib}/replay/use-replay-options.js +0 -0
  171. /package/{dist → lib}/replay/use-replay.d.ts +0 -0
  172. /package/{dist → lib}/replay/use-replay.d.ts.map +0 -0
  173. /package/{dist → lib}/replay/use-replay.js +0 -0
  174. /package/{dist → lib}/replay/use-replay.spec.d.ts +0 -0
  175. /package/{dist → lib}/replay/use-replay.spec.d.ts.map +0 -0
  176. /package/{dist → lib}/replay/use-replay.spec.js +0 -0
  177. /package/{dist → lib}/replay/when-replay-finished.d.ts +0 -0
  178. /package/{dist → lib}/replay/when-replay-finished.d.ts.map +0 -0
  179. /package/{dist → lib}/replay/when-replay-finished.js +0 -0
  180. /package/{dist → lib}/session/index.d.ts +0 -0
  181. /package/{dist → lib}/session/index.d.ts.map +0 -0
  182. /package/{dist → lib}/session/index.js +0 -0
  183. /package/{dist → lib}/session/use-session-object.d.ts +0 -0
  184. /package/{dist → lib}/session/use-session-object.d.ts.map +0 -0
  185. /package/{dist → lib}/session/use-session-object.js +0 -0
  186. /package/{dist → lib}/session/use-session-storage.d.ts +0 -0
  187. /package/{dist → lib}/session/use-session-storage.d.ts.map +0 -0
  188. /package/{dist → lib}/session/use-session-storage.js +0 -0
  189. /package/{dist → lib}/shared/datetime.d.ts +0 -0
  190. /package/{dist → lib}/shared/datetime.d.ts.map +0 -0
  191. /package/{dist → lib}/shared/datetime.js +0 -0
  192. /package/{dist → lib}/shared/decimals.d.ts +0 -0
  193. /package/{dist → lib}/shared/decimals.d.ts.map +0 -0
  194. /package/{dist → lib}/shared/decimals.js +0 -0
  195. /package/{dist → lib}/shared/decimals.spec.d.ts +0 -0
  196. /package/{dist → lib}/shared/decimals.spec.d.ts.map +0 -0
  197. /package/{dist → lib}/shared/decimals.spec.js +0 -0
  198. /package/{dist → lib}/shared/environment.d.ts +0 -0
  199. /package/{dist → lib}/shared/environment.d.ts.map +0 -0
  200. /package/{dist → lib}/shared/environment.js +0 -0
  201. /package/{dist → lib}/shared/index.d.ts +0 -0
  202. /package/{dist → lib}/shared/index.d.ts.map +0 -0
  203. /package/{dist → lib}/shared/index.js +0 -0
  204. /package/{dist → lib}/simulator/index.d.ts +0 -0
  205. /package/{dist → lib}/simulator/index.d.ts.map +0 -0
  206. /package/{dist → lib}/simulator/index.js +0 -0
  207. /package/{dist → lib}/simulator/use-simulator.d.ts +0 -0
  208. /package/{dist → lib}/simulator/use-simulator.d.ts.map +0 -0
  209. /package/{dist → lib}/simulator/use-simulator.js +0 -0
  210. /package/{dist → lib}/simulator/use-simulator.spec.d.ts +0 -0
  211. /package/{dist → lib}/simulator/use-simulator.spec.d.ts.map +0 -0
  212. /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts +0 -0
  213. /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts.map +0 -0
  214. /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts +0 -0
  215. /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts.map +0 -0
  216. /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.js +0 -0
  217. /package/{dist → lib}/storage/in-memory/in-memory-storage.js +0 -0
  218. /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts +0 -0
  219. /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts.map +0 -0
  220. /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.js +0 -0
  221. /package/{dist → lib}/storage/in-memory/index.d.ts +0 -0
  222. /package/{dist → lib}/storage/in-memory/index.d.ts.map +0 -0
  223. /package/{dist → lib}/storage/in-memory/index.js +0 -0
  224. /package/{dist → lib}/storage/index.d.ts +0 -0
  225. /package/{dist → lib}/storage/index.d.ts.map +0 -0
  226. /package/{dist → lib}/storage/index.js +0 -0
  227. /package/{dist → lib}/storage/storage.d.ts +0 -0
  228. /package/{dist → lib}/storage/storage.d.ts.map +0 -0
  229. /package/{dist → lib}/storage/storage.js +0 -0
  230. /package/{dist → lib}/storage/use-cache.d.ts +0 -0
  231. /package/{dist → lib}/storage/use-cache.d.ts.map +0 -0
  232. /package/{dist → lib}/storage/use-cache.js +0 -0
  233. /package/{dist → lib}/storage/use-cache.spec.d.ts +0 -0
  234. /package/{dist → lib}/storage/use-cache.spec.d.ts.map +0 -0
  235. /package/{dist → lib}/storage/use-cache.spec.js +0 -0
  236. /package/{dist → lib}/storage/use-storage.d.ts +0 -0
  237. /package/{dist → lib}/storage/use-storage.d.ts.map +0 -0
  238. /package/{dist → lib}/storage/use-storage.js +0 -0
  239. /package/{dist → lib}/strategy.d.ts +0 -0
  240. /package/{dist → lib}/strategy.d.ts.map +0 -0
  241. /package/{dist → lib}/strategy.js +0 -0
  242. /package/{dist → lib}/strategy.spec.d.ts +0 -0
  243. /package/{dist → lib}/strategy.spec.d.ts.map +0 -0
  244. /package/{dist → lib}/strategy.spec.js +0 -0
  245. /package/{dist → lib}/use-hash.d.ts +0 -0
  246. /package/{dist → lib}/use-hash.d.ts.map +0 -0
  247. /package/{dist → lib}/use-hash.js +0 -0
  248. /package/{dist → lib}/use-hash.spec.d.ts +0 -0
  249. /package/{dist → lib}/use-hash.spec.d.ts.map +0 -0
  250. /package/{dist → lib}/use-hash.spec.js +0 -0
  251. /package/{dist → lib}/use-logger.d.ts +0 -0
  252. /package/{dist → lib}/use-logger.d.ts.map +0 -0
  253. /package/{dist → lib}/use-memo.spec.d.ts +0 -0
  254. /package/{dist → lib}/use-memo.spec.d.ts.map +0 -0
  255. /package/{dist → lib}/use-memo.spec.js +0 -0
  256. /package/{dist → lib}/use-socket.d.ts +0 -0
  257. /package/{dist → lib}/use-socket.d.ts.map +0 -0
  258. /package/{dist → lib}/use-socket.js +0 -0
  259. /package/{dist → lib}/use-timestamp.d.ts +0 -0
  260. /package/{dist → lib}/use-timestamp.d.ts.map +0 -0
  261. /package/{dist → lib}/use-timestamp.js +0 -0
  262. /package/{dist → lib}/when-socket.d.ts +0 -0
  263. /package/{dist → lib}/when-socket.d.ts.map +0 -0
  264. /package/{dist → lib}/when-socket.js +0 -0
  265. /package/{dist → lib}/with-memo.d.ts +0 -0
  266. /package/{dist → lib}/with-memo.d.ts.map +0 -0
  267. /package/{dist → lib}/with-memo.js +0 -0
  268. /package/{dist → lib}/with-memo.spec.d.ts +0 -0
  269. /package/{dist → lib}/with-memo.spec.d.ts.map +0 -0
  270. /package/{dist → lib}/with-memo.spec.js +0 -0
  271. /package/{dist → lib}/with-request.d.ts +0 -0
  272. /package/{dist → lib}/with-request.d.ts.map +0 -0
  273. /package/{dist → lib}/with-request.js +0 -0
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
@@ -11,6 +11,7 @@ export * from '@lib/use-execution-mode';
11
11
  export * from '@lib/storage';
12
12
  export * from '@lib/use-logger';
13
13
  export * from '@lib/replay';
14
+ export * from '@lib/use-socket';
14
15
  export * from '@lib/when-socket';
15
16
  export * from '@lib/with-request';
16
17
  export * from '@lib/with-memo';
@@ -9,6 +9,8 @@ export const useReplayStorageBuffer = withMemo(<T>(dependencies: dependency[]) =
9
9
  const { query } = useReplayStorage<T>(dependencies);
10
10
  const { from, to } = useReplayOptions();
11
11
 
12
+ console.log(from, to);
13
+
12
14
  let page = new Array<{ timestamp: number; payload: T }>();
13
15
  let index = 0;
14
16
  let completed = false;
@@ -2,7 +2,6 @@ import exp from 'constants';
2
2
  import { from, lastValueFrom, tap } from 'rxjs';
3
3
 
4
4
  import { makeTestModule } from '@lib/make-test-module';
5
- import { replayExecutionMode } from '@lib/use-execution-mode';
6
5
  import { dependency } from '@lib/use-hash';
7
6
 
8
7
  import { between } from '..';
@@ -1,5 +1,17 @@
1
- import { withMemo } from '@lib/with-memo';
1
+ import { Dependency, useContext } from '@lib/module';
2
2
 
3
- export const useSession = withMemo(() => ({
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
+ });
@@ -1,13 +1,8 @@
1
- import { makeTestModule, mockedFunc } from '@lib/make-test-module';
1
+ import { makeTestModule } from '@lib/make-test-module';
2
2
  import { useExecutionMode } from '@lib/use-execution-mode';
3
3
 
4
4
  import { useSimulator } from './use-simulator';
5
5
 
6
- jest.mock('@lib/use-execution-mode', () => ({
7
- ...jest.requireActual('@lib/use-execution-mode'),
8
- useExecutionMode: jest.fn()
9
- }));
10
-
11
6
  describe(useSimulator.name, () => {
12
7
  let fixtures: Awaited<ReturnType<typeof getFixtures>>;
13
8
 
@@ -15,22 +10,16 @@ describe(useSimulator.name, () => {
15
10
  fixtures = await getFixtures();
16
11
  });
17
12
 
18
- afterEach(() => fixtures.clear());
19
-
20
- test('get real value when simulator mode disabled', () => {
21
- const { act } = fixtures;
22
-
23
- fixtures.givenSimulationEnabled(false);
13
+ test('get real value when simulator mode disabled', async () => {
14
+ const { act } = await fixtures.givenModule(false);
24
15
 
25
16
  const value = act(() => useSimulator('simulator', 'real'));
26
17
 
27
18
  expect(value).toBe('real');
28
19
  });
29
20
 
30
- test('get simulation value when simulator mode enabled', () => {
31
- const { act } = fixtures;
32
-
33
- fixtures.givenSimulationEnabled(true);
21
+ test('get simulation value when simulator mode enabled', async () => {
22
+ const { act } = await fixtures.givenModule(true);
34
23
 
35
24
  const value = act(() => useSimulator('simulator', 'real'));
36
25
 
@@ -39,16 +28,11 @@ describe(useSimulator.name, () => {
39
28
  });
40
29
 
41
30
  async function getFixtures() {
42
- const { act } = await makeTestModule([]);
43
-
44
31
  return {
45
- act,
46
- givenSimulationEnabled(isSimulation: boolean) {
47
- mockedFunc(useExecutionMode).mockReturnValue({
48
- isSimulation,
49
- recording: false
50
- } as any);
51
- },
52
- clear: jest.clearAllMocks
32
+ async givenModule(isSimulation: boolean) {
33
+ return isSimulation
34
+ ? await makeTestModule([useExecutionMode.paperOptions({ recording: false })])
35
+ : await makeTestModule([useExecutionMode.liveOptions({ recording: false })]);
36
+ }
53
37
  };
54
38
  }
@@ -1,4 +1,4 @@
1
- import { useContext } from '@lib/module';
1
+ import { Dependency, useContext } from '@lib/module';
2
2
  import { Storage } from '@lib/storage';
3
3
 
4
4
  const token = Symbol('storage-factory-token');
@@ -7,11 +7,11 @@ export interface StorageFactory {
7
7
  for(key: string): Storage;
8
8
  }
9
9
 
10
- export function storage(factory: StorageFactory) {
11
- return {
12
- provide: token,
13
- useValue: factory
14
- };
10
+ export function useStorageFactory() {
11
+ return useContext<StorageFactory>(token);
15
12
  }
16
13
 
17
- export const useStorageFactory = () => useContext<StorageFactory>(token);
14
+ useStorageFactory.options = (factory: StorageFactory): Dependency => ({
15
+ provide: token,
16
+ useValue: factory
17
+ });
@@ -1,4 +1,4 @@
1
- import { useContext } from '@lib/module';
1
+ import { Dependency, useContext } from '@lib/module';
2
2
 
3
3
  const injectionToken = Symbol('execution-mode');
4
4
 
@@ -7,35 +7,7 @@ type ExecutionMode = {
7
7
  recording: boolean;
8
8
  };
9
9
 
10
- export function replayExecutionMode() {
11
- return {
12
- provide: injectionToken,
13
- useValue: { mode: 'replay', recording: false } as ExecutionMode
14
- };
15
- }
16
-
17
- export function paperExecutionMode(options: { recording: boolean }) {
18
- return {
19
- provide: injectionToken,
20
- useValue: { mode: 'paper', ...options } as ExecutionMode
21
- };
22
- }
23
-
24
- export function liveExecutionMode(options: { recording: boolean }) {
25
- return {
26
- provide: injectionToken,
27
- useValue: { mode: 'live', ...options } as ExecutionMode
28
- };
29
- }
30
-
31
- export function idleExecutionMode() {
32
- return {
33
- provide: injectionToken,
34
- useValue: { mode: 'idle', recording: false } as ExecutionMode
35
- };
36
- }
37
-
38
- export const useExecutionMode = () => {
10
+ export function useExecutionMode() {
39
11
  const { mode, recording } = useContext<ExecutionMode>(injectionToken);
40
12
 
41
13
  return {
@@ -46,4 +18,24 @@ export const useExecutionMode = () => {
46
18
  isSimulation: mode !== 'live',
47
19
  recording
48
20
  };
49
- };
21
+ }
22
+
23
+ useExecutionMode.replayOptions = (): Dependency => ({
24
+ provide: injectionToken,
25
+ useValue: { mode: 'replay', recording: false } as ExecutionMode
26
+ });
27
+
28
+ useExecutionMode.paperOptions = (options: { recording: boolean }): Dependency => ({
29
+ provide: injectionToken,
30
+ useValue: { mode: 'paper', ...options } as ExecutionMode
31
+ });
32
+
33
+ useExecutionMode.liveOptions = (options: { recording: boolean }): Dependency => ({
34
+ provide: injectionToken,
35
+ useValue: { mode: 'live', ...options } as ExecutionMode
36
+ });
37
+
38
+ useExecutionMode.idleOptions = (): Dependency => ({
39
+ provide: injectionToken,
40
+ useValue: { mode: 'idle', recording: false } as ExecutionMode
41
+ });
package/src/use-logger.ts CHANGED
@@ -19,9 +19,9 @@ const colorize = (content: string) => {
19
19
  */
20
20
  export const useLogger = withMemo((context: string, tint?: string) => {
21
21
  const prefix = () =>
22
- `${chalk.gray(new Date(useTimestamp()).toISOString())} ${chalk.hex(
23
- tint ?? colorize(context)
24
- )(context)}`;
22
+ `${chalk.hex(tint ?? colorize(context))(
23
+ new Date(useTimestamp()).toISOString()
24
+ )} ${chalk.hex(tint ?? colorize(context))(context)}`;
25
25
 
26
26
  return {
27
27
  info: (message: any, ...params: unknown[]) =>
package/src/use-memo.ts CHANGED
@@ -1,18 +1,8 @@
1
- import { useContext } from '@lib/module';
1
+ import { Dependency, useContext } from '@lib/module';
2
2
  import { dependency, useHash } from '@lib/use-hash';
3
3
 
4
4
  export const token = Symbol('memo-token');
5
5
 
6
- /**
7
- *
8
- */
9
- export function memo() {
10
- return {
11
- provide: token,
12
- useValue: {}
13
- };
14
- }
15
-
16
6
  export function useMemo<T>(calculateValue: () => T, dependencies: dependency[]) {
17
7
  const memory = useContext<Record<string, any>>(token);
18
8
  const hash = useHash(dependencies);
@@ -23,3 +13,8 @@ export function useMemo<T>(calculateValue: () => T, dependencies: dependency[])
23
13
 
24
14
  return (memory[hash] = calculateValue()) as T;
25
15
  }
16
+
17
+ useMemo.options = (): Dependency => ({
18
+ provide: token,
19
+ useValue: {}
20
+ });
package/tsconfig.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "compilerOptions": {
4
4
  "rootDir": "src",
5
5
  "baseUrl": ".",
6
- "outDir": "dist",
6
+ "outDir": "lib",
7
7
  "paths": {
8
8
  "@lib/*": ["src/*"]
9
9
  }
@@ -13,6 +13,6 @@
13
13
  ],
14
14
  "exclude": [
15
15
  "jest.config.js",
16
- "dist/**/*"
16
+ "lib/**/*"
17
17
  ]
18
18
  }
package/dist/cli/dev.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export default function (name: string, options: any): Promise<void>;
2
- //# sourceMappingURL=dev.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"AAKA,yBAA+B,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,iBASxD"}
@@ -1,2 +0,0 @@
1
- export default function (name: string, options: any): Promise<void>;
2
- //# sourceMappingURL=replay.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../src/cli/replay.ts"],"names":[],"mappings":"AAMA,yBAA+B,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,iBAYxD"}
package/dist/cli/run.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export default function (name: string, options: any): Promise<void>;
2
- //# sourceMappingURL=run.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AAKA,yBAA+B,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,iBASxD"}
@@ -1,4 +0,0 @@
1
- export declare const useSession: () => {
2
- id: string;
3
- };
4
- //# sourceMappingURL=use-session.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-session.d.ts","sourceRoot":"","sources":["../../src/session/use-session.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;CAEpB,CAAC"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSession = void 0;
4
- const with_memo_1 = require("../with-memo");
5
- exports.useSession = (0, with_memo_1.withMemo)(() => ({
6
- id: 'ttt' //Date.now()
7
- }));
@@ -1,10 +0,0 @@
1
- import { Storage } from '../storage';
2
- export interface StorageFactory {
3
- for(key: string): Storage;
4
- }
5
- export declare function storage(factory: StorageFactory): {
6
- provide: symbol;
7
- useValue: StorageFactory;
8
- };
9
- export declare const useStorageFactory: () => StorageFactory;
10
- //# sourceMappingURL=use-storage-factory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-storage-factory.d.ts","sourceRoot":"","sources":["../../src/storage/use-storage-factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc;;;EAK9C;AAED,eAAO,MAAM,iBAAiB,sBAA0C,CAAC"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useStorageFactory = exports.storage = void 0;
4
- const module_1 = require("../module");
5
- const token = Symbol('storage-factory-token');
6
- function storage(factory) {
7
- return {
8
- provide: token,
9
- useValue: factory
10
- };
11
- }
12
- exports.storage = storage;
13
- const useStorageFactory = () => (0, module_1.useContext)(token);
14
- exports.useStorageFactory = useStorageFactory;
@@ -1,34 +0,0 @@
1
- type ExecutionMode = {
2
- mode: 'replay' | 'paper' | 'live' | 'idle';
3
- recording: boolean;
4
- };
5
- export declare function replayExecutionMode(): {
6
- provide: symbol;
7
- useValue: ExecutionMode;
8
- };
9
- export declare function paperExecutionMode(options: {
10
- recording: boolean;
11
- }): {
12
- provide: symbol;
13
- useValue: ExecutionMode;
14
- };
15
- export declare function liveExecutionMode(options: {
16
- recording: boolean;
17
- }): {
18
- provide: symbol;
19
- useValue: ExecutionMode;
20
- };
21
- export declare function idleExecutionMode(): {
22
- provide: symbol;
23
- useValue: ExecutionMode;
24
- };
25
- export declare const useExecutionMode: () => {
26
- isReplay: boolean;
27
- isPaper: boolean;
28
- isLive: boolean;
29
- isIdle: boolean;
30
- isSimulation: boolean;
31
- recording: boolean;
32
- };
33
- export {};
34
- //# sourceMappingURL=use-execution-mode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-execution-mode.d.ts","sourceRoot":"","sources":["../src/use-execution-mode.ts"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAC3C,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,mBAAmB;;;EAKlC;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE;;;EAKjE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE;;;EAKhE;AAED,wBAAgB,iBAAiB;;;EAKhC;AAED,eAAO,MAAM,gBAAgB;;;;;;;CAW5B,CAAC"}
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useExecutionMode = exports.idleExecutionMode = exports.liveExecutionMode = exports.paperExecutionMode = exports.replayExecutionMode = void 0;
4
- const module_1 = require("./module");
5
- const injectionToken = Symbol('execution-mode');
6
- function replayExecutionMode() {
7
- return {
8
- provide: injectionToken,
9
- useValue: { mode: 'replay', recording: false }
10
- };
11
- }
12
- exports.replayExecutionMode = replayExecutionMode;
13
- function paperExecutionMode(options) {
14
- return {
15
- provide: injectionToken,
16
- useValue: Object.assign({ mode: 'paper' }, options)
17
- };
18
- }
19
- exports.paperExecutionMode = paperExecutionMode;
20
- function liveExecutionMode(options) {
21
- return {
22
- provide: injectionToken,
23
- useValue: Object.assign({ mode: 'live' }, options)
24
- };
25
- }
26
- exports.liveExecutionMode = liveExecutionMode;
27
- function idleExecutionMode() {
28
- return {
29
- provide: injectionToken,
30
- useValue: { mode: 'idle', recording: false }
31
- };
32
- }
33
- exports.idleExecutionMode = idleExecutionMode;
34
- const useExecutionMode = () => {
35
- const { mode, recording } = (0, module_1.useContext)(injectionToken);
36
- return {
37
- isReplay: mode === 'replay',
38
- isPaper: mode === 'paper',
39
- isLive: mode === 'live',
40
- isIdle: mode === 'idle',
41
- isSimulation: mode !== 'live',
42
- recording
43
- };
44
- };
45
- exports.useExecutionMode = useExecutionMode;
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-memo.d.ts","sourceRoot":"","sources":["../src/use-memo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAW,MAAM,eAAe,CAAC;AAEpD,eAAO,MAAM,KAAK,eAAuB,CAAC;AAE1C;;GAEG;AACH,wBAAgB,IAAI;;;EAKnB;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,KAS7E"}
package/src/cli/dev.ts DELETED
@@ -1,15 +0,0 @@
1
- import build from '@lib/cli/build';
2
- import { paperExecutionMode } from '@lib/use-execution-mode';
3
-
4
- import { Script } from './internal/script';
5
-
6
- export default async function (name: string, options: any) {
7
- if (await build()) {
8
- return;
9
- }
10
-
11
- const script = new Script(name, [paperExecutionMode({ recording: false })]);
12
- const output = await script.run();
13
-
14
- console.log(output);
15
- }
package/src/cli/run.ts DELETED
@@ -1,15 +0,0 @@
1
- import build from '@lib/cli/build';
2
- import { liveExecutionMode } from '@lib/use-execution-mode';
3
-
4
- import { Script } from './internal/script';
5
-
6
- export default async function (name: string, options: any) {
7
- if (await build()) {
8
- return;
9
- }
10
-
11
- const script = new Script(name, [liveExecutionMode({ recording: true })]);
12
- const output = await script.run();
13
-
14
- console.log(output);
15
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes