@observertc/observer-js 0.42.9 → 1.0.1-28c6425.0
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/.prettierrc +6 -6
- package/README.md +0 -104
- package/lib/ObservedCall.d.ts +66 -42
- package/lib/ObservedCall.d.ts.map +1 -1
- package/lib/ObservedCall.js +232 -108
- package/lib/ObservedCallSummary.d.ts +18 -0
- package/lib/ObservedCallSummary.d.ts.map +1 -0
- package/lib/ObservedCertificate.d.ts +19 -0
- package/lib/ObservedCertificate.d.ts.map +1 -0
- package/lib/ObservedCertificate.js +38 -0
- package/lib/ObservedClient.d.ts +71 -130
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +311 -750
- package/lib/ObservedClientSummary.d.ts +23 -0
- package/lib/ObservedClientSummary.d.ts.map +1 -0
- package/lib/ObservedClientSummary.js +2 -0
- package/lib/ObservedCodec.d.ts +22 -0
- package/lib/ObservedCodec.d.ts.map +1 -0
- package/lib/ObservedCodec.js +45 -0
- package/lib/ObservedDataChannel.d.ts +23 -69
- package/lib/ObservedDataChannel.d.ts.map +1 -1
- package/lib/ObservedDataChannel.js +67 -109
- package/lib/ObservedIceCandidate.d.ts +29 -0
- package/lib/ObservedIceCandidate.d.ts.map +1 -0
- package/lib/ObservedIceCandidate.js +59 -0
- package/lib/ObservedIceCandidatePair.d.ts +44 -0
- package/lib/ObservedIceCandidatePair.d.ts.map +1 -0
- package/lib/ObservedIceCandidatePair.js +111 -0
- package/lib/ObservedIceTransport.d.ts +36 -0
- package/lib/ObservedIceTransport.d.ts.map +1 -0
- package/lib/ObservedIceTransport.js +93 -0
- package/lib/ObservedInboundRtp.d.ts +92 -0
- package/lib/ObservedInboundRtp.d.ts.map +1 -0
- package/lib/ObservedInboundRtp.js +193 -0
- package/lib/ObservedInboundTrack.d.ts +29 -0
- package/lib/ObservedInboundTrack.d.ts.map +1 -0
- package/lib/ObservedInboundTrack.js +57 -0
- package/lib/ObservedMediaPlayout.d.ts +22 -0
- package/lib/ObservedMediaPlayout.d.ts.map +1 -0
- package/lib/ObservedMediaPlayout.js +42 -0
- package/lib/ObservedMediaSource.d.ts +28 -0
- package/lib/ObservedMediaSource.d.ts.map +1 -0
- package/lib/ObservedMediaSource.js +55 -0
- package/lib/ObservedOutboundRtp.d.ts +62 -0
- package/lib/ObservedOutboundRtp.d.ts.map +1 -0
- package/lib/ObservedOutboundRtp.js +144 -0
- package/lib/ObservedOutboundTrack.d.ts +29 -0
- package/lib/ObservedOutboundTrack.d.ts.map +1 -0
- package/lib/ObservedOutboundTrack.js +57 -0
- package/lib/ObservedPeerConnection.d.ts +132 -80
- package/lib/ObservedPeerConnection.d.ts.map +1 -1
- package/lib/ObservedPeerConnection.js +630 -357
- package/lib/ObservedPeerConnectionTransport.d.ts +17 -0
- package/lib/ObservedPeerConnectionTransport.d.ts.map +1 -0
- package/lib/ObservedPeerConnectionTransport.js +34 -0
- package/lib/ObservedRemoteInboundRtp.d.ts +30 -0
- package/lib/ObservedRemoteInboundRtp.d.ts.map +1 -0
- package/lib/ObservedRemoteInboundRtp.js +60 -0
- package/lib/ObservedRemoteOutboundRtp.d.ts +30 -0
- package/lib/ObservedRemoteOutboundRtp.d.ts.map +1 -0
- package/lib/ObservedRemoteOutboundRtp.js +60 -0
- package/lib/ObservedTURN.d.ts +31 -0
- package/lib/ObservedTURN.d.ts.map +1 -0
- package/lib/ObservedTURN.js +58 -0
- package/lib/ObservedTurnServer.d.ts +25 -0
- package/lib/ObservedTurnServer.d.ts.map +1 -0
- package/lib/ObservedTurnServer.js +59 -0
- package/lib/Observer.d.ts +45 -51
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +150 -226
- package/lib/ObserverSummary.d.ts +13 -0
- package/lib/ObserverSummary.d.ts.map +1 -0
- package/lib/ObserverSummary.js +2 -0
- package/lib/common/Middleware.d.ts +10 -1
- package/lib/common/Middleware.d.ts.map +1 -1
- package/lib/common/Middleware.js +55 -36
- package/lib/common/logger.d.ts +8 -4
- package/lib/common/logger.d.ts.map +1 -1
- package/lib/common/logger.js +44 -68
- package/lib/common/types.d.ts +0 -21
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.js +1 -0
- package/lib/common/utils.d.ts +2 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +17 -3
- package/lib/detectors/Detector.d.ts +5 -0
- package/lib/detectors/Detector.d.ts.map +1 -0
- package/lib/detectors/Detector.js +3 -0
- package/lib/detectors/Detectors.d.ts +11 -0
- package/lib/detectors/Detectors.d.ts.map +1 -0
- package/lib/detectors/Detectors.js +34 -0
- package/lib/index.d.ts +24 -25
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +41 -41
- package/lib/monitors/TurnUsageMonitor.d.ts +0 -52
- package/lib/monitors/TurnUsageMonitor.d.ts.map +1 -1
- package/lib/monitors/TurnUsageMonitor.js +145 -120
- package/lib/schema/ClientEventTypes.d.ts +100 -0
- package/lib/schema/ClientEventTypes.d.ts.map +1 -0
- package/lib/schema/ClientEventTypes.js +38 -0
- package/lib/schema/ClientMetaTypes.d.ts +34 -0
- package/lib/schema/ClientMetaTypes.d.ts.map +1 -0
- package/lib/schema/ClientMetaTypes.js +16 -0
- package/lib/schema/ClientSample.d.ts +1333 -0
- package/lib/schema/ClientSample.d.ts.map +1 -0
- package/lib/schema/ClientSample.js +4 -0
- package/lib/scores/CalculatedScore.d.ts +6 -0
- package/lib/scores/CalculatedScore.d.ts.map +1 -0
- package/lib/scores/CalculatedScore.js +2 -0
- package/lib/scores/DefaultCallScoreCalculator.d.ts +7 -0
- package/lib/scores/DefaultCallScoreCalculator.d.ts.map +1 -0
- package/lib/scores/DefaultCallScoreCalculator.js +21 -0
- package/lib/scores/ScoreCalculator.d.ts +4 -0
- package/lib/scores/ScoreCalculator.d.ts.map +1 -0
- package/lib/scores/ScoreCalculator.js +2 -0
- package/lib/updaters/CallUpdater.d.ts +5 -0
- package/lib/updaters/CallUpdater.d.ts.map +1 -0
- package/lib/updaters/CallUpdater.js +2 -0
- package/lib/updaters/ObserverUpdater.d.ts +5 -0
- package/lib/updaters/ObserverUpdater.d.ts.map +1 -0
- package/lib/updaters/ObserverUpdater.js +2 -0
- package/lib/updaters/OnAllCallObserverUpdater_.d.ts +13 -0
- package/lib/updaters/OnAllCallObserverUpdater_.d.ts.map +1 -0
- package/lib/updaters/OnAllCallObserverUpdater_.js +38 -0
- package/lib/updaters/OnAllClientCallUpdater.d.ts +13 -0
- package/lib/updaters/OnAllClientCallUpdater.d.ts.map +1 -0
- package/lib/updaters/OnAllClientCallUpdater.js +37 -0
- package/lib/updaters/OnAnyCallObserverUpdater_.d.ts +11 -0
- package/lib/updaters/OnAnyCallObserverUpdater_.d.ts.map +1 -0
- package/lib/updaters/OnAnyCallObserverUpdater_.js +27 -0
- package/lib/updaters/OnAnyClientCallUpdater.d.ts +11 -0
- package/lib/updaters/OnAnyClientCallUpdater.d.ts.map +1 -0
- package/lib/updaters/OnAnyClientCallUpdater.js +27 -0
- package/lib/updaters/OnIntervalUpdater.d.ts +10 -0
- package/lib/updaters/OnIntervalUpdater.d.ts.map +1 -0
- package/lib/updaters/OnIntervalUpdater.js +17 -0
- package/lib/updaters/Updater.d.ts +6 -0
- package/lib/updaters/Updater.d.ts.map +1 -0
- package/lib/updaters/Updater.js +2 -0
- package/lib/utils/RemoteTrackResolver.d.ts +7 -0
- package/lib/utils/RemoteTrackResolver.d.ts.map +1 -0
- package/lib/utils/RemoteTrackResolver.js +2 -0
- package/package.json +4 -4
- package/src/ObservedCall.ts +291 -164
- package/src/ObservedCallSummary.ts +22 -0
- package/src/ObservedCertificate.ts +43 -0
- package/src/ObservedClient.ts +342 -1064
- package/src/ObservedClientSummary.ts +24 -0
- package/src/ObservedCodec.ts +49 -0
- package/src/ObservedDataChannel.ts +68 -181
- package/src/ObservedIceCandidate.ts +64 -0
- package/src/ObservedIceCandidatePair.ts +118 -0
- package/src/ObservedIceTransport.ts +99 -0
- package/src/ObservedInboundRtp.ts +205 -0
- package/src/ObservedInboundTrack.ts +70 -0
- package/src/ObservedMediaPlayout.ts +49 -0
- package/src/ObservedMediaSource.ts +60 -0
- package/src/ObservedOutboundRtp.ts +156 -0
- package/src/ObservedOutboundTrack.ts +69 -0
- package/src/ObservedPeerConnection.ts +839 -408
- package/src/ObservedPeerConnectionTransport.ts +38 -0
- package/src/ObservedRemoteInboundRtp.ts +64 -0
- package/src/ObservedRemoteOutboundRtp.ts +65 -0
- package/src/ObservedTURN.ts +86 -0
- package/src/ObservedTurnServer.ts +72 -0
- package/src/Observer.ts +171 -294
- package/src/ObserverSummary.ts +15 -0
- package/src/common/Middleware.ts +70 -42
- package/src/common/logger.ts +60 -69
- package/src/common/types.ts +0 -42
- package/src/common/utils.ts +18 -2
- package/src/detectors/Detector.ts +6 -0
- package/src/detectors/Detectors.ts +38 -0
- package/src/index.ts +24 -90
- package/src/monitors/TurnUsageMonitor.ts +164 -164
- package/src/schema/ClientEventTypes.ts +112 -0
- package/src/schema/ClientMetaTypes.ts +41 -0
- package/src/schema/ClientSample.ts +1682 -0
- package/src/scores/CalculatedScore.ts +6 -0
- package/src/scores/DefaultCallScoreCalculator.ts +23 -0
- package/src/scores/ScoreCalculator.ts +3 -0
- package/src/updaters/CallUpdater.ts +5 -0
- package/src/updaters/ObserverUpdater.ts +5 -0
- package/src/updaters/OnAllCallObserverUpdater_.ts +46 -0
- package/src/updaters/OnAllClientCallUpdater.ts +46 -0
- package/src/updaters/OnAnyCallObserverUpdater_.ts +32 -0
- package/src/updaters/OnAnyClientCallUpdater.ts +32 -0
- package/src/updaters/OnIntervalUpdater.ts +19 -0
- package/src/updaters/Updater.ts +5 -0
- package/src/utils/RemoteTrackResolver.ts +12 -0
- package/tsconfig.json +3 -3
- package/lib/ObservedICE.d.ts +0 -64
- package/lib/ObservedICE.d.ts.map +0 -1
- package/lib/ObservedICE.js +0 -141
- package/lib/ObservedInboundAudioTrack.d.ts +0 -96
- package/lib/ObservedInboundAudioTrack.d.ts.map +0 -1
- package/lib/ObservedInboundAudioTrack.js +0 -217
- package/lib/ObservedInboundVideoTrack.d.ts +0 -101
- package/lib/ObservedInboundVideoTrack.d.ts.map +0 -1
- package/lib/ObservedInboundVideoTrack.js +0 -232
- package/lib/ObservedOutboundAudioTrack.d.ts +0 -87
- package/lib/ObservedOutboundAudioTrack.d.ts.map +0 -1
- package/lib/ObservedOutboundAudioTrack.js +0 -186
- package/lib/ObservedOutboundVideoTrack.d.ts +0 -91
- package/lib/ObservedOutboundVideoTrack.d.ts.map +0 -1
- package/lib/ObservedOutboundVideoTrack.js +0 -193
- package/lib/ObservedSfu.d.ts +0 -59
- package/lib/ObservedSfu.d.ts.map +0 -1
- package/lib/ObservedSfu.js +0 -157
- package/lib/ObservedSfuInboundRtpPad.d.ts +0 -42
- package/lib/ObservedSfuInboundRtpPad.d.ts.map +0 -1
- package/lib/ObservedSfuInboundRtpPad.js +0 -71
- package/lib/ObservedSfuOutboundRtpPad.d.ts +0 -42
- package/lib/ObservedSfuOutboundRtpPad.d.ts.map +0 -1
- package/lib/ObservedSfuOutboundRtpPad.js +0 -72
- package/lib/ObservedSfuSctpChannel.d.ts +0 -42
- package/lib/ObservedSfuSctpChannel.d.ts.map +0 -1
- package/lib/ObservedSfuSctpChannel.js +0 -57
- package/lib/ObservedSfuTransport.d.ts +0 -58
- package/lib/ObservedSfuTransport.d.ts.map +0 -1
- package/lib/ObservedSfuTransport.js +0 -120
- package/lib/RemoteTrackAssigner.d.ts +0 -14
- package/lib/RemoteTrackAssigner.d.ts.map +0 -1
- package/lib/RemoteTrackAssigner.js +0 -52
- package/lib/ReportsCollector.d.ts +0 -109
- package/lib/ReportsCollector.d.ts.map +0 -1
- package/lib/ReportsCollector.js +0 -207
- package/lib/common/CalculatedScore.d.ts +0 -80
- package/lib/common/CalculatedScore.d.ts.map +0 -1
- package/lib/common/CalculatedScore.js +0 -162
- package/lib/common/CallEventType.d.ts +0 -63
- package/lib/common/CallEventType.d.ts.map +0 -1
- package/lib/common/CallEventType.js +0 -39
- package/lib/common/CallMetaReports.d.ts +0 -42
- package/lib/common/CallMetaReports.d.ts.map +0 -1
- package/lib/common/CallMetaReports.js +0 -36
- package/lib/common/QualityScoreUtils.d.ts +0 -1
- package/lib/common/QualityScoreUtils.d.ts.map +0 -1
- package/lib/common/QualityScoreUtils.js +0 -1
- package/lib/common/TypedEventEmitter.d.ts +0 -22
- package/lib/common/TypedEventEmitter.d.ts.map +0 -1
- package/lib/common/TypedEventEmitter.js +0 -11
- package/lib/common/callEventReports.d.ts +0 -10
- package/lib/common/callEventReports.d.ts.map +0 -1
- package/lib/common/callEventReports.js +0 -112
- package/lib/monitors/CallSummary.d.ts +0 -37
- package/lib/monitors/CallSummary.d.ts.map +0 -1
- package/lib/monitors/CallSummaryMonitor.d.ts +0 -32
- package/lib/monitors/CallSummaryMonitor.d.ts.map +0 -1
- package/lib/monitors/CallSummaryMonitor.js +0 -152
- package/lib/monitors/ClientIssueMonitor.d.ts +0 -32
- package/lib/monitors/ClientIssueMonitor.d.ts.map +0 -1
- package/lib/monitors/ClientIssueMonitor.js +0 -49
- package/lib/monitors/SfuServerMonitor.d.ts +0 -79
- package/lib/monitors/SfuServerMonitor.d.ts.map +0 -1
- package/lib/monitors/SfuServerMonitor.js +0 -198
- package/src/ObservedICE.ts +0 -237
- package/src/ObservedInboundAudioTrack.ts +0 -344
- package/src/ObservedInboundVideoTrack.ts +0 -361
- package/src/ObservedOutboundAudioTrack.ts +0 -307
- package/src/ObservedOutboundVideoTrack.ts +0 -319
- package/src/ObservedSfu.ts +0 -231
- package/src/ObservedSfuInboundRtpPad.ts +0 -106
- package/src/ObservedSfuOutboundRtpPad.ts +0 -107
- package/src/ObservedSfuSctpChannel.ts +0 -103
- package/src/ObservedSfuTransport.ts +0 -185
- package/src/RemoteTrackAssigner.ts +0 -68
- package/src/ReportsCollector.ts +0 -336
- package/src/common/CalculatedScore.ts +0 -188
- package/src/common/CallEventType.ts +0 -69
- package/src/common/CallMetaReports.ts +0 -82
- package/src/common/QualityScoreUtils.ts +0 -0
- package/src/common/TypedEventEmitter.ts +0 -32
- package/src/common/callEventReports.ts +0 -178
- package/src/monitors/CallSummary.ts +0 -38
- package/src/monitors/CallSummaryMonitor.ts +0 -192
- package/src/monitors/ClientIssueMonitor.ts +0 -88
- package/src/monitors/SfuServerMonitor.ts +0 -285
- /package/lib/{monitors/CallSummary.js → ObservedCallSummary.js} +0 -0
package/lib/Observer.js
CHANGED
|
@@ -1,255 +1,179 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.Observer = void 0;
|
|
15
4
|
const logger_1 = require("./common/logger");
|
|
16
5
|
const ObservedCall_1 = require("./ObservedCall");
|
|
17
|
-
const ReportsCollector_1 = require("./ReportsCollector");
|
|
18
6
|
const events_1 = require("events");
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const SfuServerMonitor_1 = require("./monitors/SfuServerMonitor");
|
|
7
|
+
const ObservedTURN_1 = require("./ObservedTURN");
|
|
8
|
+
const Detectors_1 = require("./detectors/Detectors");
|
|
9
|
+
const OnIntervalUpdater_1 = require("./updaters/OnIntervalUpdater");
|
|
10
|
+
const OnAllCallObserverUpdater_1 = require("./updaters/OnAllCallObserverUpdater_");
|
|
11
|
+
const OnAnyCallObserverUpdater_1 = require("./updaters/OnAnyCallObserverUpdater_");
|
|
25
12
|
const logger = (0, logger_1.createLogger)('Observer');
|
|
26
13
|
class Observer extends events_1.EventEmitter {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
14
|
+
config;
|
|
15
|
+
detectors;
|
|
16
|
+
observedTURN = new ObservedTURN_1.ObservedTURN();
|
|
17
|
+
observedCalls = new Map();
|
|
18
|
+
updater;
|
|
19
|
+
closed = false;
|
|
20
|
+
totalAddedCall = 0;
|
|
21
|
+
totalRemovedCall = 0;
|
|
22
|
+
totalRttLt50Measurements = 0;
|
|
23
|
+
totalRttLt150Measurements = 0;
|
|
24
|
+
totalRttLt300Measurements = 0;
|
|
25
|
+
totalRttGtOrEq300Measurements = 0;
|
|
26
|
+
totalClientIssues = 0;
|
|
27
|
+
numberOfClientsUsedTurn = 0;
|
|
28
|
+
numberOfClients = 0;
|
|
29
|
+
numberOfInboundRtpStreams = 0;
|
|
30
|
+
numberOfOutboundRtpStreams = 0;
|
|
31
|
+
numberOfDataChannels = 0;
|
|
32
|
+
numberOfPeerConnections = 0;
|
|
33
|
+
get numberOfCalls() {
|
|
34
|
+
return this.observedCalls.size;
|
|
39
35
|
}
|
|
40
|
-
|
|
36
|
+
_timer;
|
|
37
|
+
constructor(config = {
|
|
38
|
+
updatePolicy: 'update-when-all-call-updated',
|
|
39
|
+
updateIntervalInMs: undefined,
|
|
40
|
+
}) {
|
|
41
41
|
super();
|
|
42
42
|
this.config = config;
|
|
43
|
-
this.reports = new ReportsCollector_1.ReportsCollector();
|
|
44
|
-
this._observedCalls = new Map();
|
|
45
|
-
this._observedSfus = new Map();
|
|
46
|
-
this._monitors = new Map();
|
|
47
|
-
this._closed = false;
|
|
48
43
|
this.setMaxListeners(Infinity);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return;
|
|
54
|
-
if (this.config.maxReports < collectedReports) {
|
|
55
|
-
this._emitReports();
|
|
44
|
+
this.update = this.update.bind(this);
|
|
45
|
+
if (this.config.updateIntervalInMs) {
|
|
46
|
+
if (this.config.updatePolicy && this.config.updatePolicy !== 'update-on-interval') {
|
|
47
|
+
throw new Error('update policy must be update-on-interval if updateIntervalInMs is set in config');
|
|
56
48
|
}
|
|
57
|
-
|
|
58
|
-
this._emitReports();
|
|
59
|
-
this.once('close', () => {
|
|
60
|
-
this.reports.off('newreport', onNewReport);
|
|
61
|
-
this.reports.off('reports', onReports);
|
|
62
|
-
});
|
|
63
|
-
this.reports.on('newreport', onNewReport);
|
|
64
|
-
this.reports.on('reports', onReports);
|
|
65
|
-
}
|
|
66
|
-
createObservedCall(config) {
|
|
67
|
-
if (this._closed) {
|
|
68
|
-
throw new Error('Attempted to create a call source on a closed observer');
|
|
49
|
+
this._timer = setInterval(this.update.bind(this), this.config.updateIntervalInMs);
|
|
69
50
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (this._observedCalls.has(call.callId))
|
|
75
|
-
throw new Error(`Observed Call with id ${call.callId} already exists`);
|
|
76
|
-
call.once('close', () => {
|
|
77
|
-
var _a;
|
|
78
|
-
this._observedCalls.delete(call.callId);
|
|
79
|
-
reportCallEnded && this.reports.addCallEventReport((0, callEventReports_1.createCallEndedEventReport)(call.serviceId, call.roomId, call.callId, (_a = call.observationEnded) !== null && _a !== void 0 ? _a : Date.now()));
|
|
80
|
-
});
|
|
81
|
-
this._observedCalls.set(call.callId, call);
|
|
82
|
-
reportCallStarted && this.reports.addCallEventReport((0, callEventReports_1.createCallStartedEventReport)(call.serviceId, call.roomId, call.callId, call.observationStarted));
|
|
83
|
-
this.emit('newcall', call);
|
|
84
|
-
return call;
|
|
85
|
-
}
|
|
86
|
-
createObservedSfu(model, appData) {
|
|
87
|
-
if (this._closed) {
|
|
88
|
-
throw new Error('Attempted to create an sfu source on a closed observer');
|
|
51
|
+
if (this.config.updateIntervalInMs) {
|
|
52
|
+
if (this.config.updatePolicy !== 'update-on-interval') {
|
|
53
|
+
throw new Error('updatePolicy must be update-on-interval if updateIntervalInMs is set in config');
|
|
54
|
+
}
|
|
89
55
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const existingMonitor = this._monitors.get(CallSummaryMonitor_1.CallSummaryMonitor.name);
|
|
106
|
-
if (existingMonitor)
|
|
107
|
-
return existingMonitor;
|
|
108
|
-
const monitor = new CallSummaryMonitor_1.CallSummaryMonitor(options);
|
|
109
|
-
const onNewCall = (call) => {
|
|
110
|
-
monitor.addCall(call);
|
|
111
|
-
call.once('close', () => {
|
|
112
|
-
var _a;
|
|
113
|
-
return setTimeout(() => {
|
|
114
|
-
const summary = monitor.takeSummary(call.callId);
|
|
115
|
-
summary && monitor.emit('summary', summary);
|
|
116
|
-
}, (_a = options === null || options === void 0 ? void 0 : options.timeoutAfterCallClose) !== null && _a !== void 0 ? _a : 1000);
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
monitor.once('close', () => {
|
|
120
|
-
this._monitors.delete(CallSummaryMonitor_1.CallSummaryMonitor.name);
|
|
121
|
-
this.off('newcall', onNewCall);
|
|
122
|
-
});
|
|
123
|
-
this._monitors.set(CallSummaryMonitor_1.CallSummaryMonitor.name, monitor);
|
|
124
|
-
this.on('newcall', onNewCall);
|
|
125
|
-
this.once('close', () => {
|
|
126
|
-
monitor.close();
|
|
127
|
-
});
|
|
128
|
-
return monitor;
|
|
56
|
+
switch (this.config.updatePolicy) {
|
|
57
|
+
case 'update-on-any-call-updated':
|
|
58
|
+
this.updater = new OnAllCallObserverUpdater_1.OnAllCallObserverUpdater(this);
|
|
59
|
+
break;
|
|
60
|
+
case 'update-when-all-call-updated':
|
|
61
|
+
this.updater = new OnAnyCallObserverUpdater_1.OnAnyCallObserverUpdater(this);
|
|
62
|
+
break;
|
|
63
|
+
case 'update-on-interval':
|
|
64
|
+
if (!this.config.updateIntervalInMs) {
|
|
65
|
+
throw new Error('updateIntervalInMs setting in config must be set if updatePolicy is update-on-interval');
|
|
66
|
+
}
|
|
67
|
+
this.updater = new OnIntervalUpdater_1.OnIntervalUpdater(this.config.updateIntervalInMs, this.update.bind(this));
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
this.detectors = new Detectors_1.Detectors();
|
|
129
71
|
}
|
|
130
|
-
|
|
131
|
-
if (this.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (existingMonitor)
|
|
135
|
-
return existingMonitor;
|
|
136
|
-
const monitor = new TurnUsageMonitor_1.TurnUsageMonitor();
|
|
137
|
-
const onNewCall = (call) => {
|
|
138
|
-
const onNewClient = (client) => {
|
|
139
|
-
const onNewPeerConnection = (pc) => {
|
|
140
|
-
const onUsingTurnChanged = (usingTurn) => {
|
|
141
|
-
if (usingTurn)
|
|
142
|
-
monitor.addPeerConnection(pc);
|
|
143
|
-
else
|
|
144
|
-
monitor.removePeerConnection(pc);
|
|
145
|
-
};
|
|
146
|
-
pc.once('close', () => {
|
|
147
|
-
pc.ICE.off('usingturnchanged', onUsingTurnChanged);
|
|
148
|
-
monitor.removePeerConnection(pc);
|
|
149
|
-
});
|
|
150
|
-
pc.ICE.on('usingturnchanged', onUsingTurnChanged);
|
|
151
|
-
};
|
|
152
|
-
client.once('close', () => client.off('newpeerconnection', onNewPeerConnection));
|
|
153
|
-
client.on('newpeerconnection', onNewPeerConnection);
|
|
154
|
-
};
|
|
155
|
-
call.once('close', () => call.off('newclient', onNewClient));
|
|
156
|
-
call.on('newclient', onNewClient);
|
|
157
|
-
};
|
|
158
|
-
monitor.once('close', () => {
|
|
159
|
-
this._monitors.delete(TurnUsageMonitor_1.TurnUsageMonitor.name);
|
|
160
|
-
this.off('newcall', onNewCall);
|
|
161
|
-
});
|
|
162
|
-
this._monitors.set(TurnUsageMonitor_1.TurnUsageMonitor.name, monitor);
|
|
163
|
-
this.on('newcall', onNewCall);
|
|
164
|
-
this.once('close', () => {
|
|
165
|
-
monitor.close();
|
|
166
|
-
});
|
|
167
|
-
return monitor;
|
|
72
|
+
getObservedCall(callId) {
|
|
73
|
+
if (this.closed || !this.observedCalls.has(callId))
|
|
74
|
+
return;
|
|
75
|
+
return this.observedCalls.get(callId);
|
|
168
76
|
}
|
|
169
|
-
|
|
170
|
-
if (this.
|
|
171
|
-
throw new Error('
|
|
172
|
-
|
|
173
|
-
if (
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const onNewPeerConnection = (pc) => {
|
|
186
|
-
monitor.addPeerConnection(pc);
|
|
187
|
-
};
|
|
188
|
-
client.once('close', () => client.off('newpeerconnection', onNewPeerConnection));
|
|
189
|
-
client.on('newpeerconnection', onNewPeerConnection);
|
|
190
|
-
};
|
|
191
|
-
call.once('close', () => call.off('newclient', onNewClient));
|
|
192
|
-
call.on('newclient', onNewClient);
|
|
193
|
-
};
|
|
194
|
-
monitor.once('close', () => {
|
|
195
|
-
this._monitors.delete(SfuServerMonitor_1.SfuServerMonitor.name);
|
|
196
|
-
this.off('newcall', onNewCall);
|
|
197
|
-
});
|
|
198
|
-
this._monitors.set(SfuServerMonitor_1.SfuServerMonitor.name, monitor);
|
|
199
|
-
this.on('newcall', onNewCall);
|
|
200
|
-
this.once('close', () => {
|
|
201
|
-
monitor.close();
|
|
202
|
-
});
|
|
203
|
-
return monitor;
|
|
204
|
-
}
|
|
205
|
-
createClientIssueMonitor() {
|
|
206
|
-
if (this._closed)
|
|
207
|
-
throw new Error('Cannot create a turn usage monitor on a closed observer');
|
|
208
|
-
const existingMonitor = this._monitors.get(ClientIssueMonitor_1.ClientIssueMonitor.name);
|
|
209
|
-
if (existingMonitor)
|
|
210
|
-
return existingMonitor;
|
|
211
|
-
const monitor = new ClientIssueMonitor_1.ClientIssueMonitor();
|
|
212
|
-
const onNewCall = (call) => monitor.addCall(call);
|
|
213
|
-
monitor.once('close', () => {
|
|
214
|
-
this._monitors.delete(ClientIssueMonitor_1.ClientIssueMonitor.name);
|
|
215
|
-
this.off('newcall', onNewCall);
|
|
216
|
-
});
|
|
217
|
-
this._monitors.set(ClientIssueMonitor_1.ClientIssueMonitor.name, monitor);
|
|
218
|
-
this.on('newcall', onNewCall);
|
|
219
|
-
this.once('close', () => {
|
|
220
|
-
monitor.close();
|
|
77
|
+
createObservedCall(settings) {
|
|
78
|
+
if (this.closed) {
|
|
79
|
+
throw new Error('Attempted to create a call source on a closed observer');
|
|
80
|
+
}
|
|
81
|
+
if (!settings.updatePolicy) {
|
|
82
|
+
settings.updatePolicy = this.config.defaultCallUpdatePolicy;
|
|
83
|
+
settings.updateIntervalInMs = this.config.defaultCallUpdateIntervalInMs;
|
|
84
|
+
}
|
|
85
|
+
const observedCall = new ObservedCall_1.ObservedCall(settings, this);
|
|
86
|
+
const onCallUpdated = () => this._onObservedCallUpdated(observedCall);
|
|
87
|
+
if (this.observedCalls.has(observedCall.callId))
|
|
88
|
+
throw new Error(`Observed Call with id ${observedCall.callId} already exists`);
|
|
89
|
+
observedCall.once('close', () => {
|
|
90
|
+
this.observedCalls.delete(observedCall.callId);
|
|
91
|
+
observedCall.off('update', onCallUpdated);
|
|
92
|
+
++this.totalRemovedCall;
|
|
221
93
|
});
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
get observedSfus() {
|
|
228
|
-
return this._observedSfus;
|
|
229
|
-
}
|
|
230
|
-
get closed() {
|
|
231
|
-
return this._closed;
|
|
94
|
+
this.observedCalls.set(observedCall.callId, observedCall);
|
|
95
|
+
observedCall.on('update', onCallUpdated);
|
|
96
|
+
++this.totalAddedCall;
|
|
97
|
+
this.emit('newcall', observedCall);
|
|
98
|
+
return observedCall;
|
|
232
99
|
}
|
|
233
100
|
close() {
|
|
234
|
-
if (this.
|
|
101
|
+
if (this.closed) {
|
|
235
102
|
return logger.debug('Attempted to close twice');
|
|
236
103
|
}
|
|
237
|
-
this.
|
|
238
|
-
this.
|
|
104
|
+
this.closed = true;
|
|
105
|
+
clearInterval(this._timer);
|
|
106
|
+
this._timer = undefined;
|
|
107
|
+
this.observedCalls.forEach((call) => call.close());
|
|
239
108
|
this.emit('close');
|
|
240
109
|
}
|
|
241
|
-
|
|
242
|
-
if (this.
|
|
243
|
-
|
|
244
|
-
|
|
110
|
+
accept(sample) {
|
|
111
|
+
if (this.closed)
|
|
112
|
+
return;
|
|
113
|
+
if (!sample.callId)
|
|
114
|
+
return logger.warn('Received sample without callId. %o', sample);
|
|
115
|
+
if (!sample.clientId)
|
|
116
|
+
return logger.warn('Received sample without clientId %o', sample);
|
|
117
|
+
const call = this.getObservedCall(sample.callId) ?? this.createObservedCall({
|
|
118
|
+
callId: sample.callId,
|
|
119
|
+
updateIntervalInMs: this.config.defaultCallUpdateIntervalInMs,
|
|
120
|
+
updatePolicy: this.config.defaultCallUpdatePolicy,
|
|
121
|
+
});
|
|
122
|
+
const client = call.getObservedClient(sample.clientId) ?? call.createObservedClient({
|
|
123
|
+
clientId: sample.clientId,
|
|
124
|
+
});
|
|
125
|
+
client.accept(sample);
|
|
126
|
+
}
|
|
127
|
+
update() {
|
|
128
|
+
if (this.closed) {
|
|
129
|
+
return;
|
|
245
130
|
}
|
|
246
|
-
this.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
131
|
+
this.numberOfInboundRtpStreams = 0;
|
|
132
|
+
this.numberOfOutboundRtpStreams = 0;
|
|
133
|
+
this.numberOfPeerConnections = 0;
|
|
134
|
+
this.numberOfDataChannels = 0;
|
|
135
|
+
this.numberOfClients = 0;
|
|
136
|
+
this.numberOfClientsUsedTurn = 0;
|
|
137
|
+
for (const call of this.observedCalls.values()) {
|
|
138
|
+
this.numberOfInboundRtpStreams += call.numberOfInboundRtpStreams;
|
|
139
|
+
this.numberOfOutboundRtpStreams += call.numberOfOutboundRtpStreams;
|
|
140
|
+
this.numberOfPeerConnections += call.numberOfPeerConnections;
|
|
141
|
+
this.numberOfDataChannels += call.numberOfDataChannels;
|
|
142
|
+
this.numberOfClients += call.numberOfClients;
|
|
143
|
+
this.numberOfClientsUsedTurn += call.clientsUsedTurn.size;
|
|
252
144
|
}
|
|
145
|
+
this.observedTURN.update();
|
|
146
|
+
this.emit('update');
|
|
147
|
+
}
|
|
148
|
+
_onObservedCallUpdated(call) {
|
|
149
|
+
this.totalRttLt50Measurements += call.deltaRttLt50Measurements;
|
|
150
|
+
this.totalRttLt150Measurements += call.deltaRttLt150Measurements;
|
|
151
|
+
this.totalRttLt300Measurements += call.deltaRttLt300Measurements;
|
|
152
|
+
this.totalRttGtOrEq300Measurements += call.deltaRttGtOrEq300Measurements;
|
|
153
|
+
this.totalClientIssues += call.deltaNumberOfIssues;
|
|
154
|
+
}
|
|
155
|
+
resetSummaryMetrics() {
|
|
156
|
+
this.totalAddedCall = 0;
|
|
157
|
+
this.totalRemovedCall = 0;
|
|
158
|
+
this.totalRttLt50Measurements = 0;
|
|
159
|
+
this.totalRttLt150Measurements = 0;
|
|
160
|
+
this.totalRttLt300Measurements = 0;
|
|
161
|
+
this.totalRttGtOrEq300Measurements = 0;
|
|
162
|
+
this.totalClientIssues = 0;
|
|
163
|
+
}
|
|
164
|
+
createSummary() {
|
|
165
|
+
return {
|
|
166
|
+
totalAddedCall: this.totalAddedCall,
|
|
167
|
+
totalRemovedCall: this.totalRemovedCall,
|
|
168
|
+
totalRttLt50Measurements: this.totalRttLt50Measurements,
|
|
169
|
+
totalRttLt150Measurements: this.totalRttLt150Measurements,
|
|
170
|
+
totalRttLt300Measurements: this.totalRttLt300Measurements,
|
|
171
|
+
totalRttGtOrEq300Measurements: this.totalRttGtOrEq300Measurements,
|
|
172
|
+
totalClientIssues: this.totalClientIssues,
|
|
173
|
+
currentActiveCalls: this.observedCalls.size,
|
|
174
|
+
currentNumberOfClients: this.numberOfClients,
|
|
175
|
+
currentNumberOfClientsUsingTURN: this.numberOfClientsUsedTurn,
|
|
176
|
+
};
|
|
253
177
|
}
|
|
254
178
|
}
|
|
255
179
|
exports.Observer = Observer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type ObserverSummary = {
|
|
2
|
+
currentActiveCalls: number;
|
|
3
|
+
currentNumberOfClientsUsingTURN: number;
|
|
4
|
+
currentNumberOfClients: number;
|
|
5
|
+
totalAddedCall: number;
|
|
6
|
+
totalRemovedCall: number;
|
|
7
|
+
totalRttLt50Measurements: number;
|
|
8
|
+
totalRttLt150Measurements: number;
|
|
9
|
+
totalRttLt300Measurements: number;
|
|
10
|
+
totalRttGtOrEq300Measurements: number;
|
|
11
|
+
totalClientIssues: number;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=ObserverSummary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObserverSummary.d.ts","sourceRoot":"","sources":["../src/ObserverSummary.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,+BAA+B,EAAE,MAAM,CAAC;IACxC,sBAAsB,EAAE,MAAM,CAAC;IAE/B,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IAEzB,wBAAwB,EAAE,MAAM,CAAC;IACjC,yBAAyB,EAAE,MAAM,CAAC;IAClC,yBAAyB,EAAE,MAAM,CAAC;IAClC,6BAA6B,EAAE,MAAM,CAAC;IAEtC,iBAAiB,EAAE,MAAM,CAAC;CAC1B,CAAA"}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
export type Middleware<T> = (input: T, next: (nextInput: T) => void) => void;
|
|
2
2
|
export interface Processor<T> {
|
|
3
|
+
finalCallback?: Callback<T>;
|
|
3
4
|
process(value: T): void;
|
|
4
5
|
addMiddleware(...middlewares: Middleware<T>[]): Processor<T>;
|
|
5
6
|
removeMiddleware(...middlewares: Middleware<T>[]): Processor<T>;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
type Callback<T> = (input: T) => void;
|
|
9
|
+
export declare class MiddlewareProcessor<T> implements Processor<T> {
|
|
10
|
+
private stack;
|
|
11
|
+
finalCallback?: Callback<T>;
|
|
12
|
+
addMiddleware(...middlewares: Middleware<T>[]): Processor<T>;
|
|
13
|
+
removeMiddleware(...middlewares: Middleware<T>[]): Processor<T>;
|
|
14
|
+
process(value: T): void;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
8
17
|
//# sourceMappingURL=Middleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Middleware.d.ts","sourceRoot":"","sources":["../../src/common/Middleware.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAC3B,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,IAAI,KACxB,IAAI,CAAC;AAEV,MAAM,WAAW,SAAS,CAAC,CAAC;IAC3B,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACxB,aAAa,CAAC,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7D,gBAAgB,CAAC,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;CAChE;AAED,
|
|
1
|
+
{"version":3,"file":"Middleware.d.ts","sourceRoot":"","sources":["../../src/common/Middleware.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAC3B,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,IAAI,KACxB,IAAI,CAAC;AAEV,MAAM,WAAW,SAAS,CAAC,CAAC;IAC3B,aAAa,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACxB,aAAa,CAAC,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7D,gBAAgB,CAAC,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;CAChE;AAED,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAoCtC,qBAAa,mBAAmB,CAAC,CAAC,CAAE,YAAW,SAAS,CAAC,CAAC,CAAC;IAC1D,OAAO,CAAC,KAAK,CAAuB;IAC7B,aAAa,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE5B,aAAa,CAAC,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;IAQ5D,gBAAgB,CAAC,GAAG,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;IAc/D,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;CAS9B"}
|
package/lib/common/Middleware.js
CHANGED
|
@@ -1,41 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
exports.MiddlewareProcessor = void 0;
|
|
4
|
+
class Executor {
|
|
5
|
+
stack;
|
|
6
|
+
finalCallback;
|
|
7
|
+
done = false;
|
|
8
|
+
index = 0;
|
|
9
|
+
prevIndex = -1;
|
|
10
|
+
constructor(stack, finalCallback) {
|
|
11
|
+
this.stack = stack;
|
|
12
|
+
this.finalCallback = finalCallback;
|
|
13
|
+
}
|
|
14
|
+
// Executes the middleware stack
|
|
15
|
+
execute(input) {
|
|
16
|
+
if (this.index <= this.prevIndex) {
|
|
17
|
+
throw new Error('Middleware must call next() only once!');
|
|
18
|
+
}
|
|
19
|
+
else if (this.done) {
|
|
20
|
+
throw new Error('Middleware stack has already been executed!');
|
|
21
|
+
}
|
|
22
|
+
this.prevIndex = this.index;
|
|
23
|
+
const middleware = this.stack[this.index];
|
|
24
|
+
this.index++;
|
|
25
|
+
if (middleware) {
|
|
26
|
+
return middleware(input, (nextInput) => this.execute(nextInput));
|
|
27
|
+
}
|
|
28
|
+
this.done = true;
|
|
29
|
+
this.finalCallback?.(input);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class MiddlewareProcessor {
|
|
33
|
+
stack = [];
|
|
34
|
+
finalCallback;
|
|
35
|
+
addMiddleware(...middlewares) {
|
|
36
|
+
if (middlewares && middlewares.length > 0) {
|
|
37
|
+
this.stack.push(...middlewares);
|
|
38
|
+
}
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
removeMiddleware(...middlewares) {
|
|
42
|
+
if (middlewares && middlewares.length > 0) {
|
|
43
|
+
for (const middleware of middlewares) {
|
|
44
|
+
const index = this.stack.indexOf(middleware);
|
|
45
|
+
if (index >= 0) {
|
|
46
|
+
this.stack.splice(index, 1);
|
|
19
47
|
}
|
|
20
48
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (!middleware)
|
|
32
|
-
return;
|
|
33
|
-
const next = (nextInput) => execute(index + 1, nextInput);
|
|
34
|
-
return middleware(input, next);
|
|
35
|
-
};
|
|
36
|
-
return execute(0, value);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
return result;
|
|
49
|
+
}
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
process(value) {
|
|
53
|
+
if (this.stack.length === 0) {
|
|
54
|
+
return this.finalCallback?.(value);
|
|
55
|
+
}
|
|
56
|
+
const executor = new Executor(this.stack, this.finalCallback);
|
|
57
|
+
executor.execute(value);
|
|
58
|
+
}
|
|
40
59
|
}
|
|
41
|
-
exports.
|
|
60
|
+
exports.MiddlewareProcessor = MiddlewareProcessor;
|
package/lib/common/logger.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
2
1
|
export interface Logger {
|
|
3
2
|
trace(...args: any[]): void;
|
|
4
3
|
debug(...args: any[]): void;
|
|
@@ -6,8 +5,13 @@ export interface Logger {
|
|
|
6
5
|
warn(...args: any[]): void;
|
|
7
6
|
error(...args: any[]): void;
|
|
8
7
|
}
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export interface ObserverLogger {
|
|
9
|
+
trace(module: string, ...args: any[]): void;
|
|
10
|
+
debug(module: string, ...args: any[]): void;
|
|
11
|
+
info(module: string, ...args: any[]): void;
|
|
12
|
+
warn(module: string, ...args: any[]): void;
|
|
13
|
+
error(module: string, ...args: any[]): void;
|
|
14
|
+
}
|
|
12
15
|
export declare function createLogger(moduleName: string): Logger;
|
|
16
|
+
export declare function setObserverLogger(logger: ObserverLogger): void;
|
|
13
17
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/common/logger.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/common/logger.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IAEtB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE5B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE5B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE3B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE3B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAE9B,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE5C,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE5C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE3C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE3C,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC5C;AA8BD,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAuBvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,QAEvD"}
|