@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.
- package/jest.config.ts +1 -1
- package/{dist → lib}/cli/index.js +9 -6
- package/lib/cli/live.d.ts +5 -0
- package/lib/cli/live.d.ts.map +1 -0
- package/{dist/cli/replay.js → lib/cli/live.js} +4 -3
- package/lib/cli/paper.d.ts +5 -0
- package/lib/cli/paper.d.ts.map +1 -0
- package/{dist/cli/dev.js → lib/cli/paper.js} +6 -1
- package/{dist → lib}/cli/pull.js +1 -1
- package/lib/cli/replay.d.ts +6 -0
- package/lib/cli/replay.d.ts.map +1 -0
- package/{dist/cli/run.js → lib/cli/replay.js} +10 -1
- package/{dist → lib}/core.js +3 -3
- package/{dist → lib}/index.d.ts +1 -0
- package/{dist → lib}/index.d.ts.map +1 -1
- package/{dist → lib}/index.js +1 -0
- package/{dist → lib}/replay/storage/use-replay-storage-buffer.d.ts.map +1 -1
- package/{dist → lib}/replay/storage/use-replay-storage-buffer.js +1 -0
- package/lib/session/use-session.d.ts +13 -0
- package/lib/session/use-session.d.ts.map +1 -0
- package/lib/session/use-session.js +14 -0
- package/{dist → lib}/simulator/use-simulator.spec.js +12 -18
- package/lib/storage/use-storage-factory.d.ts +10 -0
- package/lib/storage/use-storage-factory.d.ts.map +1 -0
- package/lib/storage/use-storage-factory.js +13 -0
- package/lib/use-execution-mode.d.ts +20 -0
- package/lib/use-execution-mode.d.ts.map +1 -0
- package/lib/use-execution-mode.js +33 -0
- package/{dist → lib}/use-logger.js +1 -1
- package/{dist → lib}/use-memo.d.ts +4 -7
- package/lib/use-memo.d.ts.map +1 -0
- package/{dist → lib}/use-memo.js +5 -11
- package/package.json +4 -4
- package/src/cli/index.ts +11 -8
- package/src/cli/live.ts +22 -0
- package/src/cli/paper.ts +22 -0
- package/src/cli/pull.ts +2 -2
- package/src/cli/replay.ts +12 -4
- package/src/core.ts +6 -6
- package/src/index.ts +1 -0
- package/src/replay/storage/use-replay-storage-buffer.ts +2 -0
- package/src/replay/use-replay.spec.ts +0 -1
- package/src/session/use-session.ts +16 -4
- package/src/simulator/use-simulator.spec.ts +10 -26
- package/src/storage/use-storage-factory.ts +7 -7
- package/src/use-execution-mode.ts +23 -31
- package/src/use-logger.ts +3 -3
- package/src/use-memo.ts +6 -11
- package/tsconfig.json +2 -2
- package/dist/cli/dev.d.ts +0 -2
- package/dist/cli/dev.d.ts.map +0 -1
- package/dist/cli/replay.d.ts +0 -2
- package/dist/cli/replay.d.ts.map +0 -1
- package/dist/cli/run.d.ts +0 -2
- package/dist/cli/run.d.ts.map +0 -1
- package/dist/session/use-session.d.ts +0 -4
- package/dist/session/use-session.d.ts.map +0 -1
- package/dist/session/use-session.js +0 -7
- package/dist/storage/use-storage-factory.d.ts +0 -10
- package/dist/storage/use-storage-factory.d.ts.map +0 -1
- package/dist/storage/use-storage-factory.js +0 -14
- package/dist/use-execution-mode.d.ts +0 -34
- package/dist/use-execution-mode.d.ts.map +0 -1
- package/dist/use-execution-mode.js +0 -45
- package/dist/use-memo.d.ts.map +0 -1
- package/src/cli/dev.ts +0 -15
- package/src/cli/run.ts +0 -15
- /package/{dist → lib}/asset/asset.d.ts +0 -0
- /package/{dist → lib}/asset/asset.d.ts.map +0 -0
- /package/{dist → lib}/asset/asset.js +0 -0
- /package/{dist → lib}/asset/asset.spec.d.ts +0 -0
- /package/{dist → lib}/asset/asset.spec.d.ts.map +0 -0
- /package/{dist → lib}/asset/asset.spec.js +0 -0
- /package/{dist → lib}/asset/index.d.ts +0 -0
- /package/{dist → lib}/asset/index.d.ts.map +0 -0
- /package/{dist → lib}/asset/index.js +0 -0
- /package/{dist → lib}/cli/build.d.ts +0 -0
- /package/{dist → lib}/cli/build.d.ts.map +0 -0
- /package/{dist → lib}/cli/build.js +0 -0
- /package/{dist → lib}/cli/index.d.ts +0 -0
- /package/{dist → lib}/cli/index.d.ts.map +0 -0
- /package/{dist → lib}/cli/internal/script.d.ts +0 -0
- /package/{dist → lib}/cli/internal/script.d.ts.map +0 -0
- /package/{dist → lib}/cli/internal/script.js +0 -0
- /package/{dist → lib}/cli/internal/workspace.d.ts +0 -0
- /package/{dist → lib}/cli/internal/workspace.d.ts.map +0 -0
- /package/{dist → lib}/cli/internal/workspace.js +0 -0
- /package/{dist → lib}/cli/pull.d.ts +0 -0
- /package/{dist → lib}/cli/pull.d.ts.map +0 -0
- /package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts +0 -0
- /package/{dist → lib}/component/distinct-until-timesamp-changed.d.ts.map +0 -0
- /package/{dist → lib}/component/distinct-until-timesamp-changed.js +0 -0
- /package/{dist → lib}/component/error.d.ts +0 -0
- /package/{dist → lib}/component/error.d.ts.map +0 -0
- /package/{dist → lib}/component/error.js +0 -0
- /package/{dist → lib}/component/index.d.ts +0 -0
- /package/{dist → lib}/component/index.d.ts.map +0 -0
- /package/{dist → lib}/component/index.js +0 -0
- /package/{dist → lib}/component/ohlc-operator.d.ts +0 -0
- /package/{dist → lib}/component/ohlc-operator.d.ts.map +0 -0
- /package/{dist → lib}/component/ohlc-operator.js +0 -0
- /package/{dist → lib}/component/ohlc-operator.spec.d.ts +0 -0
- /package/{dist → lib}/component/ohlc-operator.spec.d.ts.map +0 -0
- /package/{dist → lib}/component/ohlc-operator.spec.js +0 -0
- /package/{dist → lib}/component/ohlc.d.ts +0 -0
- /package/{dist → lib}/component/ohlc.d.ts.map +0 -0
- /package/{dist → lib}/component/ohlc.js +0 -0
- /package/{dist → lib}/component/ohlc.spec.d.ts +0 -0
- /package/{dist → lib}/component/ohlc.spec.d.ts.map +0 -0
- /package/{dist → lib}/component/ohlc.spec.js +0 -0
- /package/{dist → lib}/component/timeframe.d.ts +0 -0
- /package/{dist → lib}/component/timeframe.d.ts.map +0 -0
- /package/{dist → lib}/component/timeframe.js +0 -0
- /package/{dist → lib}/core.d.ts +0 -0
- /package/{dist → lib}/core.d.ts.map +0 -0
- /package/{dist → lib}/instrument/commission/commission.d.ts +0 -0
- /package/{dist → lib}/instrument/commission/commission.d.ts.map +0 -0
- /package/{dist → lib}/instrument/commission/commission.js +0 -0
- /package/{dist → lib}/instrument/commission/commission.spec.d.ts +0 -0
- /package/{dist → lib}/instrument/commission/commission.spec.d.ts.map +0 -0
- /package/{dist → lib}/instrument/commission/commission.spec.js +0 -0
- /package/{dist → lib}/instrument/index.d.ts +0 -0
- /package/{dist → lib}/instrument/index.d.ts.map +0 -0
- /package/{dist → lib}/instrument/index.js +0 -0
- /package/{dist → lib}/instrument/instrument.d.ts +0 -0
- /package/{dist → lib}/instrument/instrument.d.ts.map +0 -0
- /package/{dist → lib}/instrument/instrument.js +0 -0
- /package/{dist → lib}/instrument/instrument.spec.d.ts +0 -0
- /package/{dist → lib}/instrument/instrument.spec.d.ts.map +0 -0
- /package/{dist → lib}/instrument/instrument.spec.js +0 -0
- /package/{dist → lib}/make-test-module.d.ts +0 -0
- /package/{dist → lib}/make-test-module.d.ts.map +0 -0
- /package/{dist → lib}/make-test-module.js +0 -0
- /package/{dist → lib}/module.d.ts +0 -0
- /package/{dist → lib}/module.d.ts.map +0 -0
- /package/{dist → lib}/module.js +0 -0
- /package/{dist → lib}/module.spec.d.ts +0 -0
- /package/{dist → lib}/module.spec.d.ts.map +0 -0
- /package/{dist → lib}/module.spec.js +0 -0
- /package/{dist → lib}/operators.d.ts +0 -0
- /package/{dist → lib}/operators.d.ts.map +0 -0
- /package/{dist → lib}/operators.js +0 -0
- /package/{dist → lib}/replay/index.d.ts +0 -0
- /package/{dist → lib}/replay/index.d.ts.map +0 -0
- /package/{dist → lib}/replay/index.js +0 -0
- /package/{dist → lib}/replay/replay-guard.d.ts +0 -0
- /package/{dist → lib}/replay/replay-guard.d.ts.map +0 -0
- /package/{dist → lib}/replay/replay-guard.js +0 -0
- /package/{dist → lib}/replay/replay.d.ts +0 -0
- /package/{dist → lib}/replay/replay.d.ts.map +0 -0
- /package/{dist → lib}/replay/replay.js +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage-buffer.d.ts +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage-cursor.d.ts +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage-cursor.d.ts.map +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage-cursor.js +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage.d.ts +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage.d.ts.map +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage.js +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage.spec.d.ts +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage.spec.d.ts.map +0 -0
- /package/{dist → lib}/replay/storage/use-replay-storage.spec.js +0 -0
- /package/{dist → lib}/replay/use-replay-breakpoint.d.ts +0 -0
- /package/{dist → lib}/replay/use-replay-breakpoint.d.ts.map +0 -0
- /package/{dist → lib}/replay/use-replay-breakpoint.js +0 -0
- /package/{dist → lib}/replay/use-replay-manager.d.ts +0 -0
- /package/{dist → lib}/replay/use-replay-manager.d.ts.map +0 -0
- /package/{dist → lib}/replay/use-replay-manager.js +0 -0
- /package/{dist → lib}/replay/use-replay-options.d.ts +0 -0
- /package/{dist → lib}/replay/use-replay-options.d.ts.map +0 -0
- /package/{dist → lib}/replay/use-replay-options.js +0 -0
- /package/{dist → lib}/replay/use-replay.d.ts +0 -0
- /package/{dist → lib}/replay/use-replay.d.ts.map +0 -0
- /package/{dist → lib}/replay/use-replay.js +0 -0
- /package/{dist → lib}/replay/use-replay.spec.d.ts +0 -0
- /package/{dist → lib}/replay/use-replay.spec.d.ts.map +0 -0
- /package/{dist → lib}/replay/use-replay.spec.js +0 -0
- /package/{dist → lib}/replay/when-replay-finished.d.ts +0 -0
- /package/{dist → lib}/replay/when-replay-finished.d.ts.map +0 -0
- /package/{dist → lib}/replay/when-replay-finished.js +0 -0
- /package/{dist → lib}/session/index.d.ts +0 -0
- /package/{dist → lib}/session/index.d.ts.map +0 -0
- /package/{dist → lib}/session/index.js +0 -0
- /package/{dist → lib}/session/use-session-object.d.ts +0 -0
- /package/{dist → lib}/session/use-session-object.d.ts.map +0 -0
- /package/{dist → lib}/session/use-session-object.js +0 -0
- /package/{dist → lib}/session/use-session-storage.d.ts +0 -0
- /package/{dist → lib}/session/use-session-storage.d.ts.map +0 -0
- /package/{dist → lib}/session/use-session-storage.js +0 -0
- /package/{dist → lib}/shared/datetime.d.ts +0 -0
- /package/{dist → lib}/shared/datetime.d.ts.map +0 -0
- /package/{dist → lib}/shared/datetime.js +0 -0
- /package/{dist → lib}/shared/decimals.d.ts +0 -0
- /package/{dist → lib}/shared/decimals.d.ts.map +0 -0
- /package/{dist → lib}/shared/decimals.js +0 -0
- /package/{dist → lib}/shared/decimals.spec.d.ts +0 -0
- /package/{dist → lib}/shared/decimals.spec.d.ts.map +0 -0
- /package/{dist → lib}/shared/decimals.spec.js +0 -0
- /package/{dist → lib}/shared/environment.d.ts +0 -0
- /package/{dist → lib}/shared/environment.d.ts.map +0 -0
- /package/{dist → lib}/shared/environment.js +0 -0
- /package/{dist → lib}/shared/index.d.ts +0 -0
- /package/{dist → lib}/shared/index.d.ts.map +0 -0
- /package/{dist → lib}/shared/index.js +0 -0
- /package/{dist → lib}/simulator/index.d.ts +0 -0
- /package/{dist → lib}/simulator/index.d.ts.map +0 -0
- /package/{dist → lib}/simulator/index.js +0 -0
- /package/{dist → lib}/simulator/use-simulator.d.ts +0 -0
- /package/{dist → lib}/simulator/use-simulator.d.ts.map +0 -0
- /package/{dist → lib}/simulator/use-simulator.js +0 -0
- /package/{dist → lib}/simulator/use-simulator.spec.d.ts +0 -0
- /package/{dist → lib}/simulator/use-simulator.spec.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.factory.js +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.js +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/in-memory-storage.spec.js +0 -0
- /package/{dist → lib}/storage/in-memory/index.d.ts +0 -0
- /package/{dist → lib}/storage/in-memory/index.d.ts.map +0 -0
- /package/{dist → lib}/storage/in-memory/index.js +0 -0
- /package/{dist → lib}/storage/index.d.ts +0 -0
- /package/{dist → lib}/storage/index.d.ts.map +0 -0
- /package/{dist → lib}/storage/index.js +0 -0
- /package/{dist → lib}/storage/storage.d.ts +0 -0
- /package/{dist → lib}/storage/storage.d.ts.map +0 -0
- /package/{dist → lib}/storage/storage.js +0 -0
- /package/{dist → lib}/storage/use-cache.d.ts +0 -0
- /package/{dist → lib}/storage/use-cache.d.ts.map +0 -0
- /package/{dist → lib}/storage/use-cache.js +0 -0
- /package/{dist → lib}/storage/use-cache.spec.d.ts +0 -0
- /package/{dist → lib}/storage/use-cache.spec.d.ts.map +0 -0
- /package/{dist → lib}/storage/use-cache.spec.js +0 -0
- /package/{dist → lib}/storage/use-storage.d.ts +0 -0
- /package/{dist → lib}/storage/use-storage.d.ts.map +0 -0
- /package/{dist → lib}/storage/use-storage.js +0 -0
- /package/{dist → lib}/strategy.d.ts +0 -0
- /package/{dist → lib}/strategy.d.ts.map +0 -0
- /package/{dist → lib}/strategy.js +0 -0
- /package/{dist → lib}/strategy.spec.d.ts +0 -0
- /package/{dist → lib}/strategy.spec.d.ts.map +0 -0
- /package/{dist → lib}/strategy.spec.js +0 -0
- /package/{dist → lib}/use-hash.d.ts +0 -0
- /package/{dist → lib}/use-hash.d.ts.map +0 -0
- /package/{dist → lib}/use-hash.js +0 -0
- /package/{dist → lib}/use-hash.spec.d.ts +0 -0
- /package/{dist → lib}/use-hash.spec.d.ts.map +0 -0
- /package/{dist → lib}/use-hash.spec.js +0 -0
- /package/{dist → lib}/use-logger.d.ts +0 -0
- /package/{dist → lib}/use-logger.d.ts.map +0 -0
- /package/{dist → lib}/use-memo.spec.d.ts +0 -0
- /package/{dist → lib}/use-memo.spec.d.ts.map +0 -0
- /package/{dist → lib}/use-memo.spec.js +0 -0
- /package/{dist → lib}/use-socket.d.ts +0 -0
- /package/{dist → lib}/use-socket.d.ts.map +0 -0
- /package/{dist → lib}/use-socket.js +0 -0
- /package/{dist → lib}/use-timestamp.d.ts +0 -0
- /package/{dist → lib}/use-timestamp.d.ts.map +0 -0
- /package/{dist → lib}/use-timestamp.js +0 -0
- /package/{dist → lib}/when-socket.d.ts +0 -0
- /package/{dist → lib}/when-socket.d.ts.map +0 -0
- /package/{dist → lib}/when-socket.js +0 -0
- /package/{dist → lib}/with-memo.d.ts +0 -0
- /package/{dist → lib}/with-memo.d.ts.map +0 -0
- /package/{dist → lib}/with-memo.js +0 -0
- /package/{dist → lib}/with-memo.spec.d.ts +0 -0
- /package/{dist → lib}/with-memo.spec.d.ts.map +0 -0
- /package/{dist → lib}/with-memo.spec.js +0 -0
- /package/{dist → lib}/with-request.d.ts +0 -0
- /package/{dist → lib}/with-request.d.ts.map +0 -0
- /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 {
|
|
2
|
+
import { useMemo } from '@lib/use-memo';
|
|
3
3
|
|
|
4
4
|
import { InMemoryStorageFactory } from './storage';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 {
|
|
1
|
+
import { Dependency, useContext } from '@lib/module';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
11
|
-
return
|
|
12
|
-
provide: token,
|
|
13
|
-
useValue: factory
|
|
14
|
-
};
|
|
10
|
+
export function useStorageFactory() {
|
|
11
|
+
return useContext<StorageFactory>(token);
|
|
15
12
|
}
|
|
16
13
|
|
|
17
|
-
|
|
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
|
|
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.
|
|
23
|
-
|
|
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
package/dist/cli/dev.d.ts
DELETED
package/dist/cli/dev.d.ts.map
DELETED
|
@@ -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"}
|
package/dist/cli/replay.d.ts
DELETED
package/dist/cli/replay.d.ts.map
DELETED
|
@@ -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
package/dist/cli/run.d.ts.map
DELETED
|
@@ -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 +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,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;
|
package/dist/use-memo.d.ts.map
DELETED
|
@@ -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
|
/package/{dist → lib}/core.d.ts
RENAMED
|
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
|