@trtc/calls-uikit-react 4.2.2 → 4.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trtc/calls-uikit-react",
3
- "version": "4.2.2",
3
+ "version": "4.2.4",
4
4
  "main": "./tuicall-uikit-react.umd.js",
5
5
  "module": "./tuicall-uikit-react.es.js",
6
6
  "types": "./types/index.d.ts",
@@ -14,9 +14,9 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@tencentcloud/tui-core-lite": "1.0.0",
17
- "@trtc/call-engine-lite-js": "~3.4.0",
17
+ "@trtc/call-engine-lite-js": "~3.4.7",
18
18
  "@tencentcloud/lite-chat": "^1.5.0",
19
- "@trtc/call-engine-lite-wx": "~3.4.3"
19
+ "@trtc/call-engine-lite-wx": "~3.4.7"
20
20
  },
21
21
  "bugs": {
22
22
  "url": "https://github.com/tencentyun/TUICallKit/issues"
@@ -226,6 +226,7 @@ export default class EngineEventHandler {
226
226
  this._unNormalEventsManager(event, TUICallEvent.LINE_BUSY);
227
227
  }
228
228
  private _handleCallNotConnected(event: any): void {
229
+ this?._callService?._cleanupAvoidRepeatCallState?.();
229
230
  this._callService?.executeExternalAfterCalling();
230
231
  this._unNormalEventsManager(event, TUICallEvent.ON_CALL_NOT_CONNECTED);
231
232
  }
@@ -239,7 +240,6 @@ export default class EngineEventHandler {
239
240
  }
240
241
  private _handleCallingEnd(event: any): void {
241
242
  console.log(`${NAME.PREFIX}callEnd event data: ${JSON.stringify(event)}.`);
242
-
243
243
  this._callService?.executeExternalAfterCalling();
244
244
  this._callService?._resetCallStore();
245
245
  }
@@ -26,7 +26,7 @@ const TUIGlobal: ITUIGlobal = TuiGlobal.getInstance();
26
26
  const TUIStore: ITUIStore = TuiStore.getInstance();
27
27
  const uiDesign = UIDesign.getInstance();
28
28
  uiDesign.setTUIStore(TUIStore);
29
- const version = '4.2.2';
29
+ const version = '4.2.4';
30
30
  const frameWork = 'react';
31
31
  export { TUIGlobal, TUIStore, uiDesign };
32
32
 
@@ -44,9 +44,17 @@ export default class TUICallService {
44
44
  private _permissionCheckTimer: any = null;
45
45
  private _chatCombine: any = null;
46
46
  private _engineEventHandler: any = null;
47
+ // wasm ready
48
+ private _wasmReadyPromise;
49
+ private _wasmReadyResolve;
50
+ private _isInitialized = false;
47
51
 
48
52
  constructor() {
49
53
  console.log(`${NAME.PREFIX}version: ${version}`);
54
+ this._wasmReadyPromise = new Promise(resolve => {
55
+ this._wasmReadyResolve = resolve;
56
+ });
57
+ this._loadWasm();
50
58
  this._watchTUIStore();
51
59
  this._engineEventHandler = EngineEventHandler.getInstance({ callService: this });
52
60
 
@@ -59,8 +67,23 @@ export default class TUICallService {
59
67
  }
60
68
  return TUICallService.instance;
61
69
  }
70
+ private _loadWasm() {
71
+ TUICallEngine.once('ready', () => this._wasmReadyResolve());
72
+ }
62
73
  @avoidRepeatedCall()
63
74
  public async init(params: IInitParams) {
75
+ if (this._isInitialized) {
76
+ console.warn('TUICallKit has already been initialized.');
77
+ return;
78
+ }
79
+ await this._wasmReadyPromise;
80
+
81
+ if (!this._isInitialized) {
82
+ this._doInit(params);
83
+ this._isInitialized = true;
84
+ }
85
+ }
86
+ private async _doInit(params: IInitParams) {
64
87
  try {
65
88
  if (this._tuiCallEngine) return;
66
89
  // @ts-ignore
@@ -109,6 +132,7 @@ export default class TUICallService {
109
132
  // component destroy
110
133
  public async destroyed() {
111
134
  try {
135
+ this._isInitialized = false;
112
136
  const currentCallStatus = TUIStore.getData(StoreName.CALL, NAME.CALL_STATUS);
113
137
  if (currentCallStatus !== CallStatus.IDLE) {
114
138
  throw new Error(`please destroyed when status is idle, current status: ${currentCallStatus}`);
@@ -650,7 +674,23 @@ export default class TUICallService {
650
674
  this._timerId = -1;
651
675
  }
652
676
  }
677
+ // clear all use avoidRepeatCall decorator state
678
+ private _cleanupAllAvoidRepeatCallState() {
679
+ this._tuiCallEngine?.reportLog?.({ name: 'TUICallkit._cleanupAllAvoidRepeatCallState', data: { } });
680
+ const methodsToClean = [
681
+ (this as any).calls,
682
+ (this as any).accept,
683
+ (this as any).hangup,
684
+ (this as any).reject,
685
+ ];
686
+
687
+ methodsToClean.forEach(method => {
688
+ method?.clearCallState?.(this);
689
+ });
690
+ }
653
691
  private _resetCallStore() {
692
+ this._cleanupAllAvoidRepeatCallState();
693
+
654
694
  const oldStatusStr = generateStatusChangeText();
655
695
  this._stopTimer();
656
696
  // localUserInfo, language 在通话结束后不需要清除
@@ -34,6 +34,11 @@ export function avoidRepeatedCall() {
34
34
  throw error;
35
35
  }
36
36
  };
37
+
38
+ descriptor.value.clearCallState = function(instance: any) {
39
+ isCallingSet.delete(instance);
40
+ };
41
+
37
42
  return descriptor;
38
43
  };
39
44
  }
package/src/index.ts CHANGED
@@ -35,7 +35,7 @@ const TUICallType = {
35
35
  AUDIO_CALL: 1,
36
36
  VIDEO_CALL: 2,
37
37
  };
38
- const Version = '4.2.2'; // basic-demo 原来上报使用
38
+ const Version = '4.2.4'; // basic-demo 原来上报使用
39
39
 
40
40
  // 输出产物
41
41
  export {