@quantform/core 0.7.0-beta.5 → 0.7.0-beta.51
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}/asset/asset.d.ts +3 -0
- package/lib/asset/asset.d.ts.map +1 -0
- package/{dist → lib}/asset/asset.js +7 -1
- package/{dist → lib}/cli/index.js +9 -6
- package/lib/cli/internal/script.d.ts +8 -0
- package/lib/cli/internal/script.d.ts.map +1 -0
- package/lib/cli/internal/script.js +65 -0
- package/lib/cli/live.d.ts +5 -0
- package/lib/cli/live.d.ts.map +1 -0
- package/lib/cli/live.js +33 -0
- package/lib/cli/paper.d.ts +5 -0
- package/lib/cli/paper.d.ts.map +1 -0
- package/lib/cli/paper.js +33 -0
- package/lib/cli/pull.d.ts.map +1 -0
- package/lib/cli/pull.js +28 -0
- package/lib/cli/replay.d.ts +6 -0
- package/lib/cli/replay.d.ts.map +1 -0
- package/lib/cli/replay.js +37 -0
- package/{dist → lib}/core.js +3 -3
- package/lib/index.d.ts +21 -0
- package/lib/index.d.ts.map +1 -0
- package/{dist → lib}/index.js +6 -13
- package/{dist → lib}/instrument/instrument.d.ts +3 -0
- package/lib/instrument/instrument.d.ts.map +1 -0
- package/{dist → lib}/instrument/instrument.js +7 -1
- package/{dist → lib}/make-test-module.d.ts +3 -2
- package/lib/make-test-module.d.ts.map +1 -0
- package/{dist → lib}/make-test-module.js +11 -2
- package/lib/operators.d.ts +5 -0
- package/lib/operators.d.ts.map +1 -0
- package/lib/operators.js +16 -0
- package/lib/replay/index.d.ts +10 -0
- package/lib/replay/index.d.ts.map +1 -0
- package/{dist → lib}/replay/index.js +7 -4
- package/lib/replay/replay-guard.d.ts +10 -0
- package/lib/replay/replay-guard.d.ts.map +1 -0
- package/lib/replay/replay-guard.js +8 -0
- package/lib/replay/replay.d.ts +10 -0
- package/lib/replay/replay.d.ts.map +1 -0
- package/lib/replay/replay.js +9 -0
- package/lib/replay/storage/use-replay-storage-buffer.d.ts +15 -0
- package/lib/replay/storage/use-replay-storage-buffer.d.ts.map +1 -0
- package/lib/replay/storage/use-replay-storage-buffer.js +57 -0
- package/lib/replay/storage/use-replay-storage-cursor.d.ts +30 -0
- package/lib/replay/storage/use-replay-storage-cursor.d.ts.map +1 -0
- package/lib/replay/storage/use-replay-storage-cursor.js +49 -0
- package/lib/replay/storage/use-replay-storage.d.ts +13 -0
- package/lib/replay/storage/use-replay-storage.d.ts.map +1 -0
- package/lib/replay/storage/use-replay-storage.js +39 -0
- package/lib/replay/storage/use-replay-storage.spec.d.ts +2 -0
- package/lib/replay/storage/use-replay-storage.spec.d.ts.map +1 -0
- package/lib/replay/storage/use-replay-storage.spec.js +74 -0
- package/lib/replay/use-replay-lock.d.ts +3 -0
- package/lib/replay/use-replay-lock.d.ts.map +1 -0
- package/lib/replay/use-replay-lock.js +22 -0
- package/lib/replay/use-replay-manager.d.ts +28 -0
- package/lib/replay/use-replay-manager.d.ts.map +1 -0
- package/lib/replay/use-replay-manager.js +68 -0
- package/{dist → lib}/replay/use-replay.d.ts +2 -2
- package/lib/replay/use-replay.d.ts.map +1 -0
- package/lib/replay/use-replay.js +20 -0
- package/lib/replay/use-replay.spec.js +130 -0
- package/lib/replay/when-replay-finished.d.ts +2 -0
- package/lib/replay/when-replay-finished.d.ts.map +1 -0
- package/lib/replay/when-replay-finished.js +15 -0
- package/{dist → lib}/session/use-session-storage.js +2 -2
- 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/lib/shared/decimals.d.ts +14 -0
- package/lib/shared/decimals.d.ts.map +1 -0
- package/lib/shared/decimals.js +18 -0
- package/{dist → lib}/simulator/use-simulator.spec.js +12 -18
- package/{dist → lib}/storage/index.d.ts +1 -0
- package/{dist → lib}/storage/index.d.ts.map +1 -1
- package/{dist → lib}/storage/index.js +1 -0
- 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/storage/use-storage.d.ts.map +1 -0
- package/{dist → lib}/storage/use-storage.js +2 -2
- package/lib/strategy.d.ts +15 -0
- package/lib/strategy.d.ts.map +1 -0
- package/lib/strategy.js +26 -0
- package/lib/strategy.spec.d.ts +2 -0
- package/lib/strategy.spec.d.ts.map +1 -0
- package/lib/strategy.spec.js +34 -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 +5 -5
- package/lib/use-memo.d.ts +8 -0
- package/lib/use-memo.d.ts.map +1 -0
- package/lib/use-memo.js +19 -0
- package/lib/use-socket.d.ts +20 -0
- package/lib/use-socket.d.ts.map +1 -0
- package/lib/use-socket.js +83 -0
- package/{dist → lib}/use-timestamp.js +2 -2
- package/lib/when-socket.d.ts +8 -0
- package/lib/when-socket.d.ts.map +1 -0
- package/{dist/use-socket.js → lib/when-socket.js} +6 -5
- package/lib/with-memo.d.ts +5 -0
- package/lib/with-memo.d.ts.map +1 -0
- package/{dist/use.js → lib/with-memo.js} +5 -5
- package/lib/with-memo.spec.d.ts +2 -0
- package/lib/with-memo.spec.d.ts.map +1 -0
- package/{dist/use.spec.js → lib/with-memo.spec.js} +3 -3
- package/{dist/use-request.d.ts → lib/with-request.d.ts} +6 -6
- package/lib/with-request.d.ts.map +1 -0
- package/lib/with-request.js +68 -0
- package/package.json +5 -5
- package/src/asset/asset.ts +6 -0
- package/src/cli/index.ts +11 -8
- package/src/cli/internal/script.ts +70 -0
- package/src/cli/live.ts +22 -0
- package/src/cli/paper.ts +22 -0
- package/src/cli/pull.ts +6 -66
- package/src/cli/replay.ts +15 -19
- package/src/core.ts +6 -6
- package/src/index.ts +6 -13
- package/src/instrument/instrument.ts +6 -0
- package/src/make-test-module.ts +20 -4
- package/src/operators.ts +18 -0
- package/src/replay/index.ts +7 -4
- package/src/replay/replay-guard.ts +11 -0
- package/src/replay/replay.ts +13 -0
- package/src/replay/storage/use-replay-storage-buffer.ts +52 -0
- package/src/replay/storage/use-replay-storage-cursor.ts +44 -0
- package/src/replay/storage/use-replay-storage.spec.ts +84 -0
- package/src/replay/storage/use-replay-storage.ts +29 -0
- package/src/replay/use-replay-lock.ts +29 -0
- package/src/replay/use-replay-manager.ts +83 -0
- package/src/replay/use-replay.spec.ts +10 -4
- package/src/replay/use-replay.ts +11 -17
- package/src/replay/when-replay-finished.ts +20 -0
- package/src/session/use-session-storage.ts +2 -2
- package/src/session/use-session.ts +16 -4
- package/src/shared/decimals.ts +0 -45
- package/src/simulator/use-simulator.spec.ts +10 -26
- package/src/storage/index.ts +1 -0
- package/src/storage/use-storage-factory.ts +7 -7
- package/src/storage/use-storage.ts +2 -2
- package/src/strategy.spec.ts +42 -0
- package/src/strategy.ts +36 -0
- package/src/use-execution-mode.ts +27 -27
- package/src/use-logger.ts +7 -7
- package/src/use-memo.ts +6 -21
- package/src/use-socket.ts +82 -44
- package/src/use-timestamp.ts +2 -2
- package/src/when-socket.ts +61 -0
- package/src/{use.spec.ts → with-memo.spec.ts} +3 -3
- package/src/{use.ts → with-memo.ts} +4 -4
- package/src/with-request.ts +83 -0
- package/tsconfig.json +2 -2
- package/dist/as-readonly.d.ts +0 -3
- package/dist/as-readonly.d.ts.map +0 -1
- package/dist/as-readonly.js +0 -8
- package/dist/asset/asset.d.ts.map +0 -1
- package/dist/cli/dev.d.ts +0 -2
- package/dist/cli/dev.d.ts.map +0 -1
- package/dist/cli/dev.js +0 -61
- package/dist/cli/pull.d.ts.map +0 -1
- package/dist/cli/pull.js +0 -107
- package/dist/cli/replay.d.ts +0 -2
- package/dist/cli/replay.d.ts.map +0 -1
- package/dist/cli/replay.js +0 -64
- package/dist/cli/run.d.ts +0 -2
- package/dist/cli/run.d.ts.map +0 -1
- package/dist/cli/run.js +0 -62
- package/dist/defined.d.ts +0 -3
- package/dist/defined.d.ts.map +0 -1
- package/dist/defined.js +0 -8
- package/dist/exclude.d.ts +0 -3
- package/dist/exclude.d.ts.map +0 -1
- package/dist/exclude.js +0 -8
- package/dist/index.d.ts +0 -28
- package/dist/index.d.ts.map +0 -1
- package/dist/instrument/instrument.d.ts.map +0 -1
- package/dist/make-test-module.d.ts.map +0 -1
- package/dist/not-found.d.ts +0 -2
- package/dist/not-found.d.ts.map +0 -1
- package/dist/not-found.js +0 -4
- package/dist/replay/index.d.ts +0 -7
- package/dist/replay/index.d.ts.map +0 -1
- package/dist/replay/use-replay-coordinator.d.ts +0 -10
- package/dist/replay/use-replay-coordinator.d.ts.map +0 -1
- package/dist/replay/use-replay-coordinator.js +0 -119
- package/dist/replay/use-replay-reader.d.ts +0 -7
- package/dist/replay/use-replay-reader.d.ts.map +0 -1
- package/dist/replay/use-replay-reader.js +0 -32
- package/dist/replay/use-replay-reader.spec.d.ts +0 -2
- package/dist/replay/use-replay-reader.spec.d.ts.map +0 -1
- package/dist/replay/use-replay-reader.spec.js +0 -58
- package/dist/replay/use-replay-storage.d.ts +0 -10
- package/dist/replay/use-replay-storage.d.ts.map +0 -1
- package/dist/replay/use-replay-storage.js +0 -10
- package/dist/replay/use-replay-writer.d.ts +0 -6
- package/dist/replay/use-replay-writer.d.ts.map +0 -1
- package/dist/replay/use-replay-writer.js +0 -14
- package/dist/replay/use-replay-writer.spec.d.ts +0 -2
- package/dist/replay/use-replay-writer.spec.d.ts.map +0 -1
- package/dist/replay/use-replay-writer.spec.js +0 -53
- package/dist/replay/use-replay.d.ts.map +0 -1
- package/dist/replay/use-replay.js +0 -32
- package/dist/replay/use-replay.spec.js +0 -106
- package/dist/replay/with-replay.d.ts +0 -4
- package/dist/replay/with-replay.d.ts.map +0 -1
- package/dist/replay/with-replay.js +0 -8
- 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/shared/decimals.d.ts +0 -30
- package/dist/shared/decimals.d.ts.map +0 -1
- package/dist/shared/decimals.js +0 -61
- 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/storage/use-storage.d.ts.map +0 -1
- package/dist/strat.d.ts +0 -7
- package/dist/strat.d.ts.map +0 -1
- package/dist/strat.js +0 -7
- package/dist/use-execution-mode.d.ts +0 -29
- package/dist/use-execution-mode.d.ts.map +0 -1
- package/dist/use-execution-mode.js +0 -37
- package/dist/use-lock.d.ts +0 -9
- package/dist/use-lock.d.ts.map +0 -1
- package/dist/use-lock.js +0 -40
- package/dist/use-memo.d.ts +0 -21
- package/dist/use-memo.d.ts.map +0 -1
- package/dist/use-memo.js +0 -35
- package/dist/use-request.d.ts.map +0 -1
- package/dist/use-request.js +0 -27
- package/dist/use-socket.d.ts +0 -6
- package/dist/use-socket.d.ts.map +0 -1
- package/dist/use-state.d.ts +0 -4
- package/dist/use-state.d.ts.map +0 -1
- package/dist/use-state.js +0 -24
- package/dist/use-state.spec.d.ts +0 -2
- package/dist/use-state.spec.d.ts.map +0 -1
- package/dist/use-state.spec.js +0 -36
- package/dist/use.d.ts +0 -5
- package/dist/use.d.ts.map +0 -1
- package/dist/use.spec.d.ts +0 -2
- package/dist/use.spec.d.ts.map +0 -1
- package/src/as-readonly.ts +0 -5
- package/src/cli/dev.ts +0 -31
- package/src/cli/run.ts +0 -29
- package/src/defined.ts +0 -6
- package/src/exclude.ts +0 -9
- package/src/not-found.ts +0 -1
- package/src/replay/use-replay-coordinator.ts +0 -142
- package/src/replay/use-replay-reader.spec.ts +0 -64
- package/src/replay/use-replay-reader.ts +0 -23
- package/src/replay/use-replay-storage.ts +0 -8
- package/src/replay/use-replay-writer.spec.ts +0 -56
- package/src/replay/use-replay-writer.ts +0 -17
- package/src/replay/with-replay.ts +0 -10
- package/src/strat.ts +0 -7
- package/src/use-lock.ts +0 -52
- package/src/use-request.ts +0 -47
- package/src/use-state.spec.ts +0 -31
- package/src/use-state.ts +0 -30
- /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/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}/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.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}/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}/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.spec.d.ts +0 -0
- /package/{dist → lib}/replay/use-replay.spec.d.ts.map +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}/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.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/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}/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-timestamp.d.ts +0 -0
- /package/{dist → lib}/use-timestamp.d.ts.map +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Decimal } from 'decimal.js';
|
|
2
|
+
declare module 'decimal.js' {
|
|
3
|
+
interface Decimal {
|
|
4
|
+
toFloor(decimalPlaces: number): Decimal;
|
|
5
|
+
toCeil(decimalPlaces: number): Decimal;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare class decimal extends Decimal {
|
|
9
|
+
}
|
|
10
|
+
export declare function d(value: Decimal.Value): decimal;
|
|
11
|
+
export declare namespace d {
|
|
12
|
+
var Zero: decimal;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=decimals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimals.d.ts","sourceRoot":"","sources":["../../src/shared/decimals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,QAAQ,YAAY,CAAC;IAC1B,UAAU,OAAO;QACf,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;QACxC,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;KACxC;CACF;AAUD,qBAAa,OAAQ,SAAQ,OAAO;CAAG;AAEvC,wBAAgB,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,WAErC;yBAFe,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.d = exports.decimal = void 0;
|
|
4
|
+
const decimal_js_1 = require("decimal.js");
|
|
5
|
+
decimal_js_1.Decimal.prototype.toFloor = function (decimalPlaces) {
|
|
6
|
+
return this.toDecimalPlaces(decimalPlaces, decimal_js_1.Decimal.ROUND_FLOOR);
|
|
7
|
+
};
|
|
8
|
+
decimal_js_1.Decimal.prototype.toCeil = function (decimalPlaces) {
|
|
9
|
+
return this.toDecimalPlaces(decimalPlaces, decimal_js_1.Decimal.ROUND_CEIL);
|
|
10
|
+
};
|
|
11
|
+
class decimal extends decimal_js_1.Decimal {
|
|
12
|
+
}
|
|
13
|
+
exports.decimal = decimal;
|
|
14
|
+
function d(value) {
|
|
15
|
+
return new decimal(value);
|
|
16
|
+
}
|
|
17
|
+
exports.d = d;
|
|
18
|
+
d.Zero = new decimal(0);
|
|
@@ -12,38 +12,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const make_test_module_1 = require("../make-test-module");
|
|
13
13
|
const use_execution_mode_1 = require("../use-execution-mode");
|
|
14
14
|
const use_simulator_1 = require("./use-simulator");
|
|
15
|
-
jest.mock('@lib/use-execution-mode', () => (Object.assign(Object.assign({}, jest.requireActual('@lib/use-execution-mode')), { useExecutionMode: jest.fn() })));
|
|
16
15
|
describe(use_simulator_1.useSimulator.name, () => {
|
|
17
16
|
let fixtures;
|
|
18
17
|
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
18
|
fixtures = yield getFixtures();
|
|
20
19
|
}));
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const { act } = fixtures;
|
|
24
|
-
fixtures.givenSimulationEnabled(false);
|
|
20
|
+
test('get real value when simulator mode disabled', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const { act } = yield fixtures.givenModule(false);
|
|
25
22
|
const value = act(() => (0, use_simulator_1.useSimulator)('simulator', 'real'));
|
|
26
23
|
expect(value).toBe('real');
|
|
27
|
-
});
|
|
28
|
-
test('get simulation value when simulator mode enabled', () => {
|
|
29
|
-
const { act } = fixtures;
|
|
30
|
-
fixtures.givenSimulationEnabled(true);
|
|
24
|
+
}));
|
|
25
|
+
test('get simulation value when simulator mode enabled', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
const { act } = yield fixtures.givenModule(true);
|
|
31
27
|
const value = act(() => (0, use_simulator_1.useSimulator)('simulator', 'real'));
|
|
32
28
|
expect(value).toBe('simulator');
|
|
33
|
-
});
|
|
29
|
+
}));
|
|
34
30
|
});
|
|
35
31
|
function getFixtures() {
|
|
36
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
const { act } = yield (0, make_test_module_1.makeTestModule)([]);
|
|
38
33
|
return {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
givenModule(isSimulation) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
return isSimulation
|
|
37
|
+
? yield (0, make_test_module_1.makeTestModule)([use_execution_mode_1.useExecutionMode.paperOptions({ recording: false })])
|
|
38
|
+
: yield (0, make_test_module_1.makeTestModule)([use_execution_mode_1.useExecutionMode.liveOptions({ recording: false })]);
|
|
44
39
|
});
|
|
45
|
-
}
|
|
46
|
-
clear: jest.clearAllMocks
|
|
40
|
+
}
|
|
47
41
|
};
|
|
48
42
|
});
|
|
49
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./storage"), exports);
|
|
18
|
+
__exportStar(require("./use-cache"), exports);
|
|
18
19
|
__exportStar(require("./use-storage"), exports);
|
|
19
20
|
__exportStar(require("./use-storage-factory"), exports);
|
|
20
21
|
__exportStar(require("./in-memory"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Dependency } from '../module';
|
|
2
|
+
import { Storage } from '../storage';
|
|
3
|
+
export interface StorageFactory {
|
|
4
|
+
for(key: string): Storage;
|
|
5
|
+
}
|
|
6
|
+
export declare function useStorageFactory(): StorageFactory;
|
|
7
|
+
export declare namespace useStorageFactory {
|
|
8
|
+
var options: (factory: StorageFactory) => Dependency;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=use-storage-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-storage-factory.d.ts","sourceRoot":"","sources":["../../src/storage/use-storage-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,mBAEhC;yBAFe,iBAAiB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStorageFactory = void 0;
|
|
4
|
+
const module_1 = require("../module");
|
|
5
|
+
const token = Symbol('storage-factory-token');
|
|
6
|
+
function useStorageFactory() {
|
|
7
|
+
return (0, module_1.useContext)(token);
|
|
8
|
+
}
|
|
9
|
+
exports.useStorageFactory = useStorageFactory;
|
|
10
|
+
useStorageFactory.options = (factory) => ({
|
|
11
|
+
provide: token,
|
|
12
|
+
useValue: factory
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-storage.d.ts","sourceRoot":"","sources":["../../src/storage/use-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAW,MAAM,eAAe,CAAC;AAKpD,eAAO,MAAM,UAAU,6DAKrB,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useStorage = void 0;
|
|
4
|
-
const use_1 = require("../use");
|
|
5
4
|
const use_hash_1 = require("../use-hash");
|
|
5
|
+
const with_memo_1 = require("../with-memo");
|
|
6
6
|
const use_storage_factory_1 = require("./use-storage-factory");
|
|
7
|
-
exports.useStorage = (0,
|
|
7
|
+
exports.useStorage = (0, with_memo_1.withMemo)((dependencies) => {
|
|
8
8
|
const key = (0, use_hash_1.useHash)(dependencies);
|
|
9
9
|
const factory = (0, use_storage_factory_1.useStorageFactory)();
|
|
10
10
|
return factory.for(key);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { Dependency } from './module';
|
|
3
|
+
export type Descriptor = () => Observable<unknown>;
|
|
4
|
+
export declare let before: (descriptor: Descriptor) => void;
|
|
5
|
+
export declare let behavior: (descriptor: Descriptor) => void;
|
|
6
|
+
export declare let after: (descriptor: Descriptor) => void;
|
|
7
|
+
export declare function strategy(descriptor: () => Dependency[]): {
|
|
8
|
+
dependencies: Dependency[];
|
|
9
|
+
description: {
|
|
10
|
+
before: Descriptor[];
|
|
11
|
+
behavior: Descriptor[];
|
|
12
|
+
after: Descriptor[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../src/strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAM,MAAM,MAAM,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;AAEnD,eAAO,IAAI,MAAM,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;AACpD,eAAO,IAAI,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;AACtD,eAAO,IAAI,KAAK,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;AAEnD,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,UAAU,EAAE;;;;;;;EAyBtD"}
|
package/lib/strategy.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.strategy = exports.after = exports.behavior = exports.before = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
function strategy(descriptor) {
|
|
6
|
+
const description = {
|
|
7
|
+
before: Array.of(),
|
|
8
|
+
behavior: Array.of(),
|
|
9
|
+
after: Array.of()
|
|
10
|
+
};
|
|
11
|
+
exports.before = descriptor => description.before.push(descriptor);
|
|
12
|
+
exports.behavior = descriptor => description.behavior.push(descriptor);
|
|
13
|
+
exports.after = descriptor => description.after.push(descriptor);
|
|
14
|
+
const dependencies = descriptor();
|
|
15
|
+
if (!description.before.length) {
|
|
16
|
+
description.before.push(() => (0, rxjs_1.of)(true));
|
|
17
|
+
}
|
|
18
|
+
if (!description.after.length) {
|
|
19
|
+
description.after.push(() => (0, rxjs_1.of)(true));
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
dependencies,
|
|
23
|
+
description
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.strategy = strategy;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy.spec.d.ts","sourceRoot":"","sources":["../src/strategy.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const rxjs_1 = require("rxjs");
|
|
4
|
+
const strategy_1 = require("./strategy");
|
|
5
|
+
describe(strategy_1.strategy.name, () => {
|
|
6
|
+
let fixtures;
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
fixtures = getFixtures();
|
|
9
|
+
});
|
|
10
|
+
test('happy path', () => {
|
|
11
|
+
const sut = (0, strategy_1.strategy)(() => {
|
|
12
|
+
(0, strategy_1.before)(() => (0, rxjs_1.of)('before'));
|
|
13
|
+
(0, strategy_1.behavior)(() => (0, rxjs_1.of)('behavior 1'));
|
|
14
|
+
(0, strategy_1.behavior)(() => (0, rxjs_1.of)('behavior 2'));
|
|
15
|
+
(0, strategy_1.after)(() => (0, rxjs_1.of)('after'));
|
|
16
|
+
return fixtures.given.dependencies();
|
|
17
|
+
});
|
|
18
|
+
expect(sut.dependencies).toEqual(expect.arrayContaining(fixtures.given.dependencies()));
|
|
19
|
+
expect(sut.description).toEqual({
|
|
20
|
+
before: [expect.any(Function)],
|
|
21
|
+
behavior: [expect.any(Function), expect.any(Function)],
|
|
22
|
+
after: [expect.any(Function)]
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
function getFixtures() {
|
|
27
|
+
return {
|
|
28
|
+
given: {
|
|
29
|
+
dependencies() {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Dependency } from './module';
|
|
2
|
+
export declare function useExecutionMode(): {
|
|
3
|
+
isReplay: boolean;
|
|
4
|
+
isPaper: boolean;
|
|
5
|
+
isLive: boolean;
|
|
6
|
+
isIdle: boolean;
|
|
7
|
+
isSimulation: boolean;
|
|
8
|
+
recording: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare namespace useExecutionMode {
|
|
11
|
+
var replayOptions: () => Dependency;
|
|
12
|
+
var paperOptions: (options: {
|
|
13
|
+
recording: boolean;
|
|
14
|
+
}) => Dependency;
|
|
15
|
+
var liveOptions: (options: {
|
|
16
|
+
recording: boolean;
|
|
17
|
+
}) => Dependency;
|
|
18
|
+
var idleOptions: () => Dependency;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=use-execution-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-execution-mode.d.ts","sourceRoot":"","sources":["../src/use-execution-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AASrD,wBAAgB,gBAAgB;;;;;;;EAW/B;yBAXe,gBAAgB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useExecutionMode = void 0;
|
|
4
|
+
const module_1 = require("./module");
|
|
5
|
+
const injectionToken = Symbol('execution-mode');
|
|
6
|
+
function useExecutionMode() {
|
|
7
|
+
const { mode, recording } = (0, module_1.useContext)(injectionToken);
|
|
8
|
+
return {
|
|
9
|
+
isReplay: mode === 'replay',
|
|
10
|
+
isPaper: mode === 'paper',
|
|
11
|
+
isLive: mode === 'live',
|
|
12
|
+
isIdle: mode === 'idle',
|
|
13
|
+
isSimulation: mode !== 'live',
|
|
14
|
+
recording
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.useExecutionMode = useExecutionMode;
|
|
18
|
+
useExecutionMode.replayOptions = () => ({
|
|
19
|
+
provide: injectionToken,
|
|
20
|
+
useValue: { mode: 'replay', recording: false }
|
|
21
|
+
});
|
|
22
|
+
useExecutionMode.paperOptions = (options) => ({
|
|
23
|
+
provide: injectionToken,
|
|
24
|
+
useValue: Object.assign({ mode: 'paper' }, options)
|
|
25
|
+
});
|
|
26
|
+
useExecutionMode.liveOptions = (options) => ({
|
|
27
|
+
provide: injectionToken,
|
|
28
|
+
useValue: Object.assign({ mode: 'live' }, options)
|
|
29
|
+
});
|
|
30
|
+
useExecutionMode.idleOptions = () => ({
|
|
31
|
+
provide: injectionToken,
|
|
32
|
+
useValue: { mode: 'idle', recording: false }
|
|
33
|
+
});
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useLogger = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const use_1 = require("./use");
|
|
9
8
|
const use_timestamp_1 = require("./use-timestamp");
|
|
9
|
+
const with_memo_1 = require("./with-memo");
|
|
10
10
|
const colorize = (content) => {
|
|
11
11
|
let hash = 0x811c9dc5;
|
|
12
12
|
for (let i = 0; i < content.length; i++) {
|
|
@@ -18,8 +18,8 @@ const colorize = (content) => {
|
|
|
18
18
|
/**
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
exports.useLogger = (0,
|
|
22
|
-
const prefix = () => `${chalk_1.default.
|
|
21
|
+
exports.useLogger = (0, with_memo_1.withMemo)((context, tint) => {
|
|
22
|
+
const prefix = () => `${chalk_1.default.hex(tint !== null && tint !== void 0 ? tint : colorize(context))(new Date((0, use_timestamp_1.useTimestamp)()).toISOString())} ${chalk_1.default.hex(tint !== null && tint !== void 0 ? tint : colorize(context))(context)}`;
|
|
23
23
|
return {
|
|
24
24
|
info: (message, ...params) => (params === null || params === void 0 ? void 0 : params.length)
|
|
25
25
|
? console.info(`${prefix()}: ${message}`, params)
|
|
@@ -31,7 +31,7 @@ exports.useLogger = (0, use_1.use)((context, tint) => {
|
|
|
31
31
|
? console.warn(`${prefix()}: ${message}`, params)
|
|
32
32
|
: console.warn(`${prefix()}: ${message}`),
|
|
33
33
|
error: (message, ...params) => (params === null || params === void 0 ? void 0 : params.length)
|
|
34
|
-
? console.error(`${prefix()}: ${message}`, params)
|
|
35
|
-
: console.error(`${prefix()}: ${message}`)
|
|
34
|
+
? console.error(`${prefix()}: ${chalk_1.default.red(message)}`, params)
|
|
35
|
+
: console.error(`${prefix()}: ${chalk_1.default.red(message)}`)
|
|
36
36
|
};
|
|
37
37
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Dependency } from './module';
|
|
2
|
+
import { dependency } from './use-hash';
|
|
3
|
+
export declare const token: unique symbol;
|
|
4
|
+
export declare function useMemo<T>(calculateValue: () => T, dependencies: dependency[]): T;
|
|
5
|
+
export declare namespace useMemo {
|
|
6
|
+
var options: () => Dependency;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=use-memo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-memo.d.ts","sourceRoot":"","sources":["../src/use-memo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAW,MAAM,eAAe,CAAC;AAEpD,eAAO,MAAM,KAAK,eAAuB,CAAC;AAE1C,wBAAgB,OAAO,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,KAS7E;yBATe,OAAO"}
|
package/lib/use-memo.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMemo = exports.token = void 0;
|
|
4
|
+
const module_1 = require("./module");
|
|
5
|
+
const use_hash_1 = require("./use-hash");
|
|
6
|
+
exports.token = Symbol('memo-token');
|
|
7
|
+
function useMemo(calculateValue, dependencies) {
|
|
8
|
+
const memory = (0, module_1.useContext)(exports.token);
|
|
9
|
+
const hash = (0, use_hash_1.useHash)(dependencies);
|
|
10
|
+
if (memory[hash]) {
|
|
11
|
+
return memory[hash];
|
|
12
|
+
}
|
|
13
|
+
return (memory[hash] = calculateValue());
|
|
14
|
+
}
|
|
15
|
+
exports.useMemo = useMemo;
|
|
16
|
+
useMemo.options = () => ({
|
|
17
|
+
provide: exports.token,
|
|
18
|
+
useValue: {}
|
|
19
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
export declare function useSocket(url: string, options?: {
|
|
3
|
+
pingInterval?: number;
|
|
4
|
+
}): {
|
|
5
|
+
/**
|
|
6
|
+
* Observes socket events and handles connection health monitoring via ping/pong
|
|
7
|
+
* @returns observable emitting message events with timestamps and parsed payloads
|
|
8
|
+
*/
|
|
9
|
+
watch(): Observable<{
|
|
10
|
+
timestamp: number;
|
|
11
|
+
payload: unknown;
|
|
12
|
+
}>;
|
|
13
|
+
send(message: {
|
|
14
|
+
payload: unknown;
|
|
15
|
+
}): Observable<{
|
|
16
|
+
timestamp: number;
|
|
17
|
+
}>;
|
|
18
|
+
monitor(): Observable<"opened" | "closed" | "errored">;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=use-socket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-socket.d.ts","sourceRoot":"","sources":["../src/use-socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,UAAU,EAAqB,MAAM,MAAM,CAAC;AAM5D,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAA2B;IAsBzD;;;OAGG;aACM,WAAW;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;kBAgD9C;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,WAAW;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;;EAczE"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSocket = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const ws_1 = require("ws");
|
|
6
|
+
const use_logger_1 = require("./use-logger");
|
|
7
|
+
const use_timestamp_1 = require("./use-timestamp");
|
|
8
|
+
function useSocket(url, options = { pingInterval: 5000 }) {
|
|
9
|
+
const { debug } = (0, use_logger_1.useLogger)('useSocket');
|
|
10
|
+
const socket = new ws_1.WebSocket(url);
|
|
11
|
+
const monitor = new rxjs_1.ReplaySubject();
|
|
12
|
+
socket.on('error', e => {
|
|
13
|
+
debug('errored', url, e);
|
|
14
|
+
monitor.next('errored');
|
|
15
|
+
});
|
|
16
|
+
socket.on('close', () => {
|
|
17
|
+
debug('closed', url);
|
|
18
|
+
monitor.next('closed');
|
|
19
|
+
});
|
|
20
|
+
socket.on('open', () => {
|
|
21
|
+
debug('opened', url);
|
|
22
|
+
monitor.next('opened');
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
/**
|
|
26
|
+
* Observes socket events and handles connection health monitoring via ping/pong
|
|
27
|
+
* @returns observable emitting message events with timestamps and parsed payloads
|
|
28
|
+
*/
|
|
29
|
+
watch() {
|
|
30
|
+
let isAlive = false;
|
|
31
|
+
let interval;
|
|
32
|
+
return new rxjs_1.Observable(stream => {
|
|
33
|
+
socket.onmessage = it => stream.next({
|
|
34
|
+
timestamp: (0, use_timestamp_1.useTimestamp)(),
|
|
35
|
+
payload: JSON.parse(it.data)
|
|
36
|
+
});
|
|
37
|
+
socket.onerror = it => {
|
|
38
|
+
clearInterval(interval);
|
|
39
|
+
stream.error(it);
|
|
40
|
+
};
|
|
41
|
+
socket.onclose = () => {
|
|
42
|
+
clearInterval(interval);
|
|
43
|
+
stream.error();
|
|
44
|
+
};
|
|
45
|
+
socket.onopen = () => {
|
|
46
|
+
isAlive = true;
|
|
47
|
+
interval = setInterval(() => {
|
|
48
|
+
if (isAlive) {
|
|
49
|
+
isAlive = false;
|
|
50
|
+
socket.ping();
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
socket.terminate();
|
|
54
|
+
clearInterval(interval);
|
|
55
|
+
}
|
|
56
|
+
}, options.pingInterval);
|
|
57
|
+
socket.on('pong', () => {
|
|
58
|
+
isAlive = true;
|
|
59
|
+
});
|
|
60
|
+
socket.on('ping', () => {
|
|
61
|
+
isAlive = true;
|
|
62
|
+
socket.pong();
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
return () => {
|
|
66
|
+
clearInterval(interval);
|
|
67
|
+
socket.terminate();
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
send(message) {
|
|
72
|
+
return (0, rxjs_1.defer)(() => {
|
|
73
|
+
debug('sent', url, message.payload);
|
|
74
|
+
socket.send(JSON.stringify(message.payload));
|
|
75
|
+
return (0, rxjs_1.of)({ timestamp: (0, use_timestamp_1.useTimestamp)() });
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
monitor() {
|
|
79
|
+
return monitor.asObservable();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
exports.useSocket = useSocket;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useTimestamp = void 0;
|
|
4
|
-
const
|
|
4
|
+
const replay_1 = require("./replay");
|
|
5
5
|
const use_execution_mode_1 = require("./use-execution-mode");
|
|
6
6
|
function useTimestamp() {
|
|
7
7
|
const { isReplay } = (0, use_execution_mode_1.useExecutionMode)();
|
|
8
8
|
if (isReplay) {
|
|
9
|
-
return (0,
|
|
9
|
+
return (0, replay_1.useReplayManager)().timestamp();
|
|
10
10
|
}
|
|
11
11
|
return Date.now();
|
|
12
12
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when-socket.d.ts","sourceRoot":"","sources":["../src/when-socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAMlC,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAA2B,GAC1D,CAAC,UAAU,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,CAmDnF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.whenSocket = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const ws_1 = require("ws");
|
|
6
6
|
const use_logger_1 = require("./use-logger");
|
|
7
7
|
const use_timestamp_1 = require("./use-timestamp");
|
|
8
|
-
function
|
|
9
|
-
const { debug } = (0, use_logger_1.useLogger)('
|
|
8
|
+
function whenSocket(url, options = { pingInterval: 5000 }) {
|
|
9
|
+
const { debug } = (0, use_logger_1.useLogger)('whenSocket');
|
|
10
10
|
const message = new rxjs_1.Observable(stream => {
|
|
11
11
|
const socket = new ws_1.WebSocket(url);
|
|
12
12
|
let isAlive = false;
|
|
@@ -14,6 +14,7 @@ function useSocket(url) {
|
|
|
14
14
|
socket.onmessage = it => stream.next({ timestamp: (0, use_timestamp_1.useTimestamp)(), payload: JSON.parse(it.data) });
|
|
15
15
|
socket.onerror = it => {
|
|
16
16
|
clearInterval(interval);
|
|
17
|
+
debug('errored', url);
|
|
17
18
|
stream.error(it);
|
|
18
19
|
};
|
|
19
20
|
socket.onclose = () => {
|
|
@@ -33,7 +34,7 @@ function useSocket(url) {
|
|
|
33
34
|
socket.terminate();
|
|
34
35
|
clearInterval(interval);
|
|
35
36
|
}
|
|
36
|
-
},
|
|
37
|
+
}, options.pingInterval);
|
|
37
38
|
socket.on('pong', () => {
|
|
38
39
|
isAlive = true;
|
|
39
40
|
});
|
|
@@ -49,4 +50,4 @@ function useSocket(url) {
|
|
|
49
50
|
});
|
|
50
51
|
return [message, (message) => JSON.stringify(message)];
|
|
51
52
|
}
|
|
52
|
-
exports.
|
|
53
|
+
exports.whenSocket = whenSocket;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { dependency } from './use-hash';
|
|
3
|
+
export declare function withMemo<T extends Array<dependency>, U>(fn: (...args: T) => U): (...args: T) => U;
|
|
4
|
+
export declare function withMemo<T extends Array<dependency>, U>(fn: (...args: T) => Observable<U>): (...args: T) => Observable<U>;
|
|
5
|
+
//# sourceMappingURL=with-memo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-memo.d.ts","sourceRoot":"","sources":["../src/with-memo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAe,MAAM,MAAM,CAAC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxC,wBAAgB,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,EACrD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GACpB,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AACrB,wBAAgB,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,EACrD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,GAChC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.withMemo = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const uuid_1 = require("uuid");
|
|
6
|
-
const as_readonly_1 = require("./as-readonly");
|
|
7
6
|
const module_1 = require("./module");
|
|
7
|
+
const operators_1 = require("./operators");
|
|
8
8
|
const use_memo_1 = require("./use-memo");
|
|
9
|
-
function
|
|
9
|
+
function withMemo(fn) {
|
|
10
10
|
(0, module_1.throwWithContext)();
|
|
11
11
|
const uniqueId = (0, uuid_1.v4)();
|
|
12
12
|
return (...args) => (0, use_memo_1.useMemo)(() => {
|
|
13
13
|
const value = fn(...args);
|
|
14
14
|
if ((0, rxjs_1.isObservable)(value)) {
|
|
15
|
-
return value.pipe((0,
|
|
15
|
+
return value.pipe((0, operators_1.asReadonly)(), (0, rxjs_1.shareReplay)(1));
|
|
16
16
|
}
|
|
17
17
|
return value;
|
|
18
18
|
}, [uniqueId, ...args]);
|
|
19
19
|
}
|
|
20
|
-
exports.
|
|
20
|
+
exports.withMemo = withMemo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-memo.spec.d.ts","sourceRoot":"","sources":["../src/with-memo.spec.ts"],"names":[],"mappings":""}
|
|
@@ -11,8 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const make_test_module_1 = require("./make-test-module");
|
|
13
13
|
const instrument_1 = require("./instrument");
|
|
14
|
-
const
|
|
15
|
-
describe(
|
|
14
|
+
const with_memo_1 = require("./with-memo");
|
|
15
|
+
describe(with_memo_1.withMemo.name, () => {
|
|
16
16
|
let fixtures;
|
|
17
17
|
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
fixtures = yield getFixtures();
|
|
@@ -38,7 +38,7 @@ describe(use_1.use.name, () => {
|
|
|
38
38
|
function getFixtures() {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
const { act } = yield (0, make_test_module_1.makeTestModule)([]);
|
|
41
|
-
const getValue = (0,
|
|
41
|
+
const getValue = (0, with_memo_1.withMemo)((instrument) => instrument.id);
|
|
42
42
|
return {
|
|
43
43
|
act,
|
|
44
44
|
getValue: act(() => (instrument) => getValue(instrument))
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
1
2
|
export type RequestMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
|
|
2
3
|
export declare class RequestNetworkError extends Error {
|
|
3
4
|
readonly statusCode: number;
|
|
4
|
-
|
|
5
|
-
constructor(statusCode: number, json: () => Promise<string>);
|
|
5
|
+
constructor(statusCode: number);
|
|
6
6
|
}
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function withRequest({ method, url, headers, body }: {
|
|
8
8
|
method: RequestMethod;
|
|
9
9
|
url: string;
|
|
10
10
|
headers?: Record<string, any>;
|
|
11
11
|
body?: string;
|
|
12
|
-
}):
|
|
12
|
+
}): Observable<{
|
|
13
13
|
timestamp: number;
|
|
14
|
-
payload:
|
|
14
|
+
payload: unknown;
|
|
15
15
|
}>;
|
|
16
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=with-request.d.ts.map
|