@quantform/core 0.7.0-beta.50 → 0.7.0-beta.52
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/lib/replay/index.d.ts +1 -1
- package/lib/replay/index.d.ts.map +1 -1
- package/lib/replay/index.js +1 -1
- package/lib/replay/replay-guard.js +2 -2
- 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-breakpoint.js → use-replay-lock.js} +5 -5
- package/lib/use-socket.d.ts +1 -0
- package/lib/use-socket.d.ts.map +1 -1
- package/lib/use-socket.js +17 -3
- package/package.json +1 -1
- package/src/replay/index.ts +1 -1
- package/src/replay/replay-guard.ts +2 -2
- package/src/replay/{use-replay-breakpoint.ts → use-replay-lock.ts} +3 -3
- package/src/use-socket.ts +23 -4
- package/lib/replay/use-replay-breakpoint.d.ts +0 -3
- package/lib/replay/use-replay-breakpoint.d.ts.map +0 -1
package/lib/replay/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/replay/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/replay/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qCAAqC,CAAC;AACpD,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
|
package/lib/replay/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./use-replay"), exports);
|
|
18
|
-
__exportStar(require("./use-replay-
|
|
18
|
+
__exportStar(require("./use-replay-lock"), exports);
|
|
19
19
|
__exportStar(require("./use-replay-options"), exports);
|
|
20
20
|
__exportStar(require("./storage/use-replay-storage"), exports);
|
|
21
21
|
__exportStar(require("./storage/use-replay-storage-buffer"), exports);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.replayGuard = void 0;
|
|
4
|
-
const
|
|
4
|
+
const use_replay_lock_1 = require("./use-replay-lock");
|
|
5
5
|
function replayGuard(fn) {
|
|
6
|
-
return (...args) => (0,
|
|
6
|
+
return (...args) => (0, use_replay_lock_1.useReplayLock)(fn(...args));
|
|
7
7
|
}
|
|
8
8
|
exports.replayGuard = replayGuard;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-replay-lock.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay-lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,UAAU,EAAE,MAAM,MAAM,CAAC;AAO5C,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAqBpE"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useReplayLock = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const use_execution_mode_1 = require("../use-execution-mode");
|
|
6
6
|
const use_logger_1 = require("../use-logger");
|
|
7
7
|
const use_replay_manager_1 = require("./use-replay-manager");
|
|
8
|
-
function
|
|
8
|
+
function useReplayLock(input) {
|
|
9
9
|
const { isReplay } = (0, use_execution_mode_1.useExecutionMode)();
|
|
10
10
|
if (!isReplay) {
|
|
11
11
|
return input;
|
|
12
12
|
}
|
|
13
13
|
const { info } = (0, use_logger_1.useLogger)('replay');
|
|
14
14
|
const { stop, tryContinue } = (0, use_replay_manager_1.useReplayManager)();
|
|
15
|
-
info('
|
|
15
|
+
info('lock acquired');
|
|
16
16
|
stop();
|
|
17
17
|
return input.pipe((0, rxjs_1.finalize)(() => {
|
|
18
|
-
info('
|
|
18
|
+
info('lock released');
|
|
19
19
|
tryContinue();
|
|
20
20
|
}));
|
|
21
21
|
}
|
|
22
|
-
exports.
|
|
22
|
+
exports.useReplayLock = useReplayLock;
|
package/lib/use-socket.d.ts
CHANGED
package/lib/use-socket.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-socket.d.ts","sourceRoot":"","sources":["../src/use-socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,UAAU,
|
|
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"}
|
package/lib/use-socket.js
CHANGED
|
@@ -8,6 +8,19 @@ const use_timestamp_1 = require("./use-timestamp");
|
|
|
8
8
|
function useSocket(url, options = { pingInterval: 5000 }) {
|
|
9
9
|
const { debug } = (0, use_logger_1.useLogger)('useSocket');
|
|
10
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
|
+
});
|
|
11
24
|
return {
|
|
12
25
|
/**
|
|
13
26
|
* Observes socket events and handles connection health monitoring via ping/pong
|
|
@@ -23,16 +36,13 @@ function useSocket(url, options = { pingInterval: 5000 }) {
|
|
|
23
36
|
});
|
|
24
37
|
socket.onerror = it => {
|
|
25
38
|
clearInterval(interval);
|
|
26
|
-
debug('errored', url);
|
|
27
39
|
stream.error(it);
|
|
28
40
|
};
|
|
29
41
|
socket.onclose = () => {
|
|
30
|
-
debug('closed', url);
|
|
31
42
|
clearInterval(interval);
|
|
32
43
|
stream.error();
|
|
33
44
|
};
|
|
34
45
|
socket.onopen = () => {
|
|
35
|
-
debug('opened', url);
|
|
36
46
|
isAlive = true;
|
|
37
47
|
interval = setInterval(() => {
|
|
38
48
|
if (isAlive) {
|
|
@@ -60,9 +70,13 @@ function useSocket(url, options = { pingInterval: 5000 }) {
|
|
|
60
70
|
},
|
|
61
71
|
send(message) {
|
|
62
72
|
return (0, rxjs_1.defer)(() => {
|
|
73
|
+
debug('sent', url, message.payload);
|
|
63
74
|
socket.send(JSON.stringify(message.payload));
|
|
64
75
|
return (0, rxjs_1.of)({ timestamp: (0, use_timestamp_1.useTimestamp)() });
|
|
65
76
|
});
|
|
77
|
+
},
|
|
78
|
+
monitor() {
|
|
79
|
+
return monitor.asObservable();
|
|
66
80
|
}
|
|
67
81
|
};
|
|
68
82
|
}
|
package/package.json
CHANGED
package/src/replay/index.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
|
|
3
3
|
import { dependency } from '@lib/use-hash';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { useReplayLock } from './use-replay-lock';
|
|
6
6
|
|
|
7
7
|
export function replayGuard<T extends Array<dependency>, K>(
|
|
8
8
|
fn: (...args: T) => Observable<{ timestamp: number; payload: K }>
|
|
9
9
|
): (...args: T) => Observable<{ timestamp: number; payload: K }> {
|
|
10
|
-
return (...args: T) =>
|
|
10
|
+
return (...args: T) => useReplayLock(fn(...args));
|
|
11
11
|
}
|
|
@@ -5,7 +5,7 @@ import { useLogger } from '@lib/use-logger';
|
|
|
5
5
|
|
|
6
6
|
import { useReplayManager } from './use-replay-manager';
|
|
7
7
|
|
|
8
|
-
export function
|
|
8
|
+
export function useReplayLock<T>(input: Observable<T>): Observable<T> {
|
|
9
9
|
const { isReplay } = useExecutionMode();
|
|
10
10
|
|
|
11
11
|
if (!isReplay) {
|
|
@@ -15,13 +15,13 @@ export function useReplayBreakpoint<T>(input: Observable<T>): Observable<T> {
|
|
|
15
15
|
const { info } = useLogger('replay');
|
|
16
16
|
const { stop, tryContinue } = useReplayManager();
|
|
17
17
|
|
|
18
|
-
info('
|
|
18
|
+
info('lock acquired');
|
|
19
19
|
|
|
20
20
|
stop();
|
|
21
21
|
|
|
22
22
|
return input.pipe(
|
|
23
23
|
finalize(() => {
|
|
24
|
-
info('
|
|
24
|
+
info('lock released');
|
|
25
25
|
|
|
26
26
|
tryContinue();
|
|
27
27
|
})
|
package/src/use-socket.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defer, Observable, of } from 'rxjs';
|
|
1
|
+
import { defer, Observable, of, ReplaySubject } from 'rxjs';
|
|
2
2
|
import { WebSocket } from 'ws';
|
|
3
3
|
|
|
4
4
|
import { useLogger } from './use-logger';
|
|
@@ -10,6 +10,22 @@ export function useSocket(
|
|
|
10
10
|
) {
|
|
11
11
|
const { debug } = useLogger('useSocket');
|
|
12
12
|
const socket = new WebSocket(url);
|
|
13
|
+
const monitor = new ReplaySubject<'opened' | 'closed' | 'errored'>();
|
|
14
|
+
|
|
15
|
+
socket.on('error', e => {
|
|
16
|
+
debug('errored', url, e);
|
|
17
|
+
monitor.next('errored');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
socket.on('close', () => {
|
|
21
|
+
debug('closed', url);
|
|
22
|
+
monitor.next('closed');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
socket.on('open', () => {
|
|
26
|
+
debug('opened', url);
|
|
27
|
+
monitor.next('opened');
|
|
28
|
+
});
|
|
13
29
|
|
|
14
30
|
return {
|
|
15
31
|
/**
|
|
@@ -28,16 +44,13 @@ export function useSocket(
|
|
|
28
44
|
});
|
|
29
45
|
socket.onerror = it => {
|
|
30
46
|
clearInterval(interval);
|
|
31
|
-
debug('errored', url);
|
|
32
47
|
stream.error(it);
|
|
33
48
|
};
|
|
34
49
|
socket.onclose = () => {
|
|
35
|
-
debug('closed', url);
|
|
36
50
|
clearInterval(interval);
|
|
37
51
|
stream.error();
|
|
38
52
|
};
|
|
39
53
|
socket.onopen = () => {
|
|
40
|
-
debug('opened', url);
|
|
41
54
|
isAlive = true;
|
|
42
55
|
interval = setInterval(() => {
|
|
43
56
|
if (isAlive) {
|
|
@@ -69,10 +82,16 @@ export function useSocket(
|
|
|
69
82
|
|
|
70
83
|
send(message: { payload: unknown }): Observable<{ timestamp: number }> {
|
|
71
84
|
return defer(() => {
|
|
85
|
+
debug('sent', url, message.payload);
|
|
86
|
+
|
|
72
87
|
socket.send(JSON.stringify(message.payload));
|
|
73
88
|
|
|
74
89
|
return of({ timestamp: useTimestamp() });
|
|
75
90
|
});
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
monitor() {
|
|
94
|
+
return monitor.asObservable();
|
|
76
95
|
}
|
|
77
96
|
};
|
|
78
97
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-replay-breakpoint.d.ts","sourceRoot":"","sources":["../../src/replay/use-replay-breakpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,UAAU,EAAE,MAAM,MAAM,CAAC;AAO5C,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAqB1E"}
|