@koi-design/callkit 2.0.0-beta.7 → 2.0.0-beta.8
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/dist/index.d.ts +6 -1
- package/dist/index.global.js +22 -9
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +22 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -102,7 +102,11 @@ interface IConfig {
|
|
|
102
102
|
version: string;
|
|
103
103
|
host: string;
|
|
104
104
|
log: LoggerLevel;
|
|
105
|
-
trackLogs:
|
|
105
|
+
trackLogs: {
|
|
106
|
+
enabled: boolean;
|
|
107
|
+
interval: number;
|
|
108
|
+
maxSize: number;
|
|
109
|
+
};
|
|
106
110
|
audioRef?: HTMLAudioElement | (() => HTMLAudioElement);
|
|
107
111
|
constrains: WebrtcConstranis;
|
|
108
112
|
socket: string;
|
|
@@ -138,6 +142,7 @@ declare class Config {
|
|
|
138
142
|
validate: () => boolean;
|
|
139
143
|
isLogin: () => boolean;
|
|
140
144
|
check(): boolean;
|
|
145
|
+
isLogsEnabled(): boolean;
|
|
141
146
|
}
|
|
142
147
|
|
|
143
148
|
declare const CallStatus: {
|
package/dist/index.global.js
CHANGED
|
@@ -3774,7 +3774,11 @@ var WebCall = (() => {
|
|
|
3774
3774
|
version: "1.0.27",
|
|
3775
3775
|
host: "",
|
|
3776
3776
|
log: "info",
|
|
3777
|
-
trackLogs:
|
|
3777
|
+
trackLogs: {
|
|
3778
|
+
enabled: false,
|
|
3779
|
+
interval: 5e3,
|
|
3780
|
+
maxSize: 8192
|
|
3781
|
+
},
|
|
3778
3782
|
audioRef: void 0,
|
|
3779
3783
|
constrains: constrainsDefault,
|
|
3780
3784
|
socket: "",
|
|
@@ -3859,6 +3863,10 @@ var WebCall = (() => {
|
|
|
3859
3863
|
}
|
|
3860
3864
|
return true;
|
|
3861
3865
|
}
|
|
3866
|
+
isLogsEnabled() {
|
|
3867
|
+
const { trackLogs } = this.getConfig();
|
|
3868
|
+
return trackLogs?.enabled ?? false;
|
|
3869
|
+
}
|
|
3862
3870
|
};
|
|
3863
3871
|
|
|
3864
3872
|
// package/logger.ts
|
|
@@ -3871,8 +3879,6 @@ var WebCall = (() => {
|
|
|
3871
3879
|
const logLevel = String(level).toUpperCase();
|
|
3872
3880
|
return `${timestamp} [${logLevel}] [${type}] [${caller ?? "unknown"}] [${message}] ${(0, import_json_stringify_safe.default)(content)}`.trim();
|
|
3873
3881
|
}
|
|
3874
|
-
var MAX_SIZE = 8192;
|
|
3875
|
-
var FLUSH_INTERVAL = 5e3;
|
|
3876
3882
|
function getByteSize(str) {
|
|
3877
3883
|
return new Blob([str]).size;
|
|
3878
3884
|
}
|
|
@@ -3888,28 +3894,35 @@ var WebCall = (() => {
|
|
|
3888
3894
|
this.startTrackLogsTimer();
|
|
3889
3895
|
}
|
|
3890
3896
|
startTrackLogsTimer() {
|
|
3897
|
+
const { trackLogs } = this.callKit.config.getConfig();
|
|
3898
|
+
if (!trackLogs.enabled) {
|
|
3899
|
+
return;
|
|
3900
|
+
}
|
|
3901
|
+
const { interval } = trackLogs;
|
|
3891
3902
|
if (this.trackLogsTimer) {
|
|
3892
3903
|
return;
|
|
3893
3904
|
}
|
|
3894
3905
|
this.trackLogsTimer = setInterval(() => {
|
|
3895
3906
|
this.flushTrackLogs();
|
|
3896
|
-
},
|
|
3907
|
+
}, interval);
|
|
3897
3908
|
}
|
|
3898
3909
|
flushTrackLogs() {
|
|
3899
3910
|
if (this.pendingTrackLogs.length === 0) {
|
|
3900
3911
|
return;
|
|
3901
3912
|
}
|
|
3902
|
-
const
|
|
3903
|
-
if (
|
|
3913
|
+
const isLogsEnabled = this.callKit.config.isLogsEnabled();
|
|
3914
|
+
if (isLogsEnabled) {
|
|
3904
3915
|
try {
|
|
3905
3916
|
const chunks = [];
|
|
3906
3917
|
let currentChunk = [];
|
|
3907
3918
|
let currentSize = 0;
|
|
3919
|
+
const { trackLogs } = this.callKit.config.getConfig();
|
|
3920
|
+
const { maxSize } = trackLogs;
|
|
3908
3921
|
for (const log of this.pendingTrackLogs) {
|
|
3909
3922
|
const logSize = getByteSize(log);
|
|
3910
3923
|
const separator = currentChunk.length > 0 ? "\n" : "";
|
|
3911
3924
|
const separatorSize = getByteSize(separator);
|
|
3912
|
-
if (currentSize + logSize + separatorSize >
|
|
3925
|
+
if (currentSize + logSize + separatorSize > maxSize && currentChunk.length > 0) {
|
|
3913
3926
|
chunks.push(currentChunk.join("\n"));
|
|
3914
3927
|
currentChunk = [log];
|
|
3915
3928
|
currentSize = logSize;
|
|
@@ -3988,8 +4001,8 @@ var WebCall = (() => {
|
|
|
3988
4001
|
content: extra?.content ?? {}
|
|
3989
4002
|
};
|
|
3990
4003
|
const logString = transformLog(log);
|
|
3991
|
-
const
|
|
3992
|
-
if (
|
|
4004
|
+
const isLogsEnabled = this.callKit.config.isLogsEnabled();
|
|
4005
|
+
if (isLogsEnabled) {
|
|
3993
4006
|
this.pendingTrackLogs.push(logString);
|
|
3994
4007
|
}
|
|
3995
4008
|
this.callKit.trigger(KitEvent.KIT_LOG, logString);
|