@koi-design/callkit 2.0.0-beta.8 → 2.0.0-beta.9

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 CHANGED
@@ -102,11 +102,7 @@ interface IConfig {
102
102
  version: string;
103
103
  host: string;
104
104
  log: LoggerLevel;
105
- trackLogs: {
106
- enabled: boolean;
107
- interval: number;
108
- maxSize: number;
109
- };
105
+ trackLogs: TrackLogsConfig;
110
106
  audioRef?: HTMLAudioElement | (() => HTMLAudioElement);
111
107
  constrains: WebrtcConstranis;
112
108
  socket: string;
@@ -142,7 +138,8 @@ declare class Config {
142
138
  validate: () => boolean;
143
139
  isLogin: () => boolean;
144
140
  check(): boolean;
145
- isLogsEnabled(): boolean;
141
+ getTrackLogsConfig(): TrackLogsConfig;
142
+ enableTrackLogs(enabled: boolean): void;
146
143
  }
147
144
 
148
145
  declare const CallStatus: {
@@ -308,7 +305,12 @@ type EncryptionMethodType = (typeof EncryptionMethod)[keyof typeof EncryptionMet
308
305
  declare const CallSourceType: {
309
306
  phoneNum: number;
310
307
  workOrderId: number;
311
- };
308
+ };
309
+ interface TrackLogsConfig {
310
+ enabled: boolean;
311
+ interval: number;
312
+ maxSize: number;
313
+ }
312
314
 
313
315
  interface CallParams {
314
316
  agentId: string;
@@ -3633,6 +3633,11 @@ var WebCall = (() => {
3633
3633
  phoneNum: 1,
3634
3634
  workOrderId: 2
3635
3635
  };
3636
+ var trackLogsDefaultConfig = {
3637
+ enabled: false,
3638
+ interval: 5e3,
3639
+ maxSize: 8192
3640
+ };
3636
3641
 
3637
3642
  // package/call.ts
3638
3643
  var Call = class {
@@ -3774,11 +3779,7 @@ var WebCall = (() => {
3774
3779
  version: "1.0.27",
3775
3780
  host: "",
3776
3781
  log: "info",
3777
- trackLogs: {
3778
- enabled: false,
3779
- interval: 5e3,
3780
- maxSize: 8192
3781
- },
3782
+ trackLogs: trackLogsDefaultConfig,
3782
3783
  audioRef: void 0,
3783
3784
  constrains: constrainsDefault,
3784
3785
  socket: "",
@@ -3863,9 +3864,11 @@ var WebCall = (() => {
3863
3864
  }
3864
3865
  return true;
3865
3866
  }
3866
- isLogsEnabled() {
3867
- const { trackLogs } = this.getConfig();
3868
- return trackLogs?.enabled ?? false;
3867
+ getTrackLogsConfig() {
3868
+ return this.getConfig().trackLogs ?? trackLogsDefaultConfig;
3869
+ }
3870
+ enableTrackLogs(enabled) {
3871
+ this.config.trackLogs.enabled = enabled;
3869
3872
  }
3870
3873
  };
3871
3874
 
@@ -3894,12 +3897,8 @@ var WebCall = (() => {
3894
3897
  this.startTrackLogsTimer();
3895
3898
  }
3896
3899
  startTrackLogsTimer() {
3897
- const { trackLogs } = this.callKit.config.getConfig();
3898
- if (!trackLogs.enabled) {
3899
- return;
3900
- }
3901
- const { interval } = trackLogs;
3902
- if (this.trackLogsTimer) {
3900
+ const { interval, enabled } = this.callKit.config.getConfig().trackLogs;
3901
+ if (!enabled || this.trackLogsTimer) {
3903
3902
  return;
3904
3903
  }
3905
3904
  this.trackLogsTimer = setInterval(() => {
@@ -3910,14 +3909,12 @@ var WebCall = (() => {
3910
3909
  if (this.pendingTrackLogs.length === 0) {
3911
3910
  return;
3912
3911
  }
3913
- const isLogsEnabled = this.callKit.config.isLogsEnabled();
3914
- if (isLogsEnabled) {
3912
+ const { enabled, maxSize } = this.callKit.config.getTrackLogsConfig();
3913
+ if (enabled) {
3915
3914
  try {
3916
3915
  const chunks = [];
3917
3916
  let currentChunk = [];
3918
3917
  let currentSize = 0;
3919
- const { trackLogs } = this.callKit.config.getConfig();
3920
- const { maxSize } = trackLogs;
3921
3918
  for (const log of this.pendingTrackLogs) {
3922
3919
  const logSize = getByteSize(log);
3923
3920
  const separator = currentChunk.length > 0 ? "\n" : "";
@@ -4001,8 +3998,8 @@ var WebCall = (() => {
4001
3998
  content: extra?.content ?? {}
4002
3999
  };
4003
4000
  const logString = transformLog(log);
4004
- const isLogsEnabled = this.callKit.config.isLogsEnabled();
4005
- if (isLogsEnabled) {
4001
+ const { enabled } = this.callKit.config.getTrackLogsConfig();
4002
+ if (enabled) {
4006
4003
  this.pendingTrackLogs.push(logString);
4007
4004
  }
4008
4005
  this.callKit.trigger(KitEvent.KIT_LOG, logString);