@trtc/calls-uikit-react 4.5.1 → 4.5.2

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.5.1",
3
+ "version": "4.5.2",
4
4
  "main": "./tuicall-uikit-react.umd.js",
5
5
  "module": "./tuicall-uikit-react.es.js",
6
6
  "types": "./types/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@tencentcloud/tui-core-lite": "~1.0.1",
17
- "@trtc/call-engine-lite-js": "~4.0.1",
17
+ "@trtc/call-engine-lite-js": "~4.0.3",
18
18
  "@tencentcloud/lite-chat": "^1.6.3",
19
19
  "@trtc/call-engine-lite-wx": "~4.0.0"
20
20
  },
@@ -46,7 +46,8 @@ export function Message(props: IMessageProps) {
46
46
  plaintext = false,
47
47
  onClose = () => null,
48
48
  } = props;
49
- const timer = useRef<any>();
49
+ // React 19's useRef removed the no-argument overload; pass undefined explicitly.
50
+ const timer = useRef<any>(undefined);
50
51
  const classnames = classNames([
51
52
  className,
52
53
  `${classPrefix}-message-container`,
@@ -1,4 +1,4 @@
1
- import { render, unmountComponentAtNode } from 'react-dom';
1
+ import { createRoot, type Root } from 'react-dom/client';
2
2
  import React, { CSSProperties, useEffect } from 'react';
3
3
  import { IMessageProps, Message } from './Message';
4
4
  import { noop } from '../../../../TUICallService/utils/common-utils';
@@ -46,7 +46,9 @@ function createContainer(): Promise<Element> {
46
46
  const container = Array.from(mountedDom.querySelectorAll(`#${containerId}`));
47
47
  if (container.length < 1) {
48
48
  const div = document.createElement('div');
49
- render(
49
+ // Use React 18+ createRoot API; legacy ReactDOM.render was removed in React 19.
50
+ const root = createRoot(div);
51
+ root.render(
50
52
  <MessageContainer
51
53
  id={containerId}
52
54
  zIndex={1}
@@ -56,7 +58,6 @@ function createContainer(): Promise<Element> {
56
58
  resolve(containers[0]);
57
59
  }}
58
60
  />,
59
- div,
60
61
  );
61
62
  } else {
62
63
  resolve(container[0]);
@@ -73,9 +74,18 @@ async function createMessage(theme, config): Promise<any> {
73
74
 
74
75
  keyIndex += 1;
75
76
 
77
+ // Persist the React root so it can be unmounted explicitly in close().
78
+ let root: Root | null = null;
76
79
  const message = {
77
80
  close: () => {
78
- unmountComponentAtNode(div);
81
+ if (root) {
82
+ // Defer unmount to the next tick to avoid React's "synchronously unmount
83
+ // a root while React is already rendering" warning when the close is
84
+ // triggered from inside a render-phase callback.
85
+ const targetRoot = root;
86
+ root = null;
87
+ Promise.resolve().then(() => targetRoot.unmount());
88
+ }
79
89
  div.remove();
80
90
  message.closed = true;
81
91
  },
@@ -95,10 +105,9 @@ async function createMessage(theme, config): Promise<any> {
95
105
  }
96
106
 
97
107
  return new Promise((resolve) => {
98
- // TODO
99
- // ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot
100
- // Renders the component.
101
- render(
108
+ // Use React 18+ createRoot API; legacy ReactDOM.render was removed in React 19.
109
+ root = createRoot(div);
110
+ root.render(
102
111
  <Message
103
112
  key={keyIndex}
104
113
  {...config}
@@ -111,7 +120,6 @@ async function createMessage(theme, config): Promise<any> {
111
120
  >
112
121
  {content}
113
122
  </Message>,
114
- div,
115
123
  );
116
124
 
117
125
  // Mounts the current rendered message to the specified container.
@@ -29,7 +29,8 @@ const Popup = forwardRef((props: IPopupProps, ref: any) => {
29
29
  const [popperElement, setPopperElement] = useState(null);
30
30
  const [arrowElement, setArrowElement] = useState(null);
31
31
  const contentRef = useRef(null); // The content section.
32
- const updateTimeRef = useRef<any>();
32
+ // React 19's useRef removed the no-argument overload; pass undefined explicitly.
33
+ const updateTimeRef = useRef<any>(undefined);
33
34
  const popupRef = useRef(null);
34
35
  const { styles } = usePopper(referenceElement, popperElement, {
35
36
  modifiers: [{ name: 'arrow', options: { element: arrowElement } }],
@@ -14,7 +14,8 @@ interface IFloatingWindowProps {
14
14
 
15
15
  export default function FloatingWindow(props: IFloatingWindowProps) {
16
16
  const { isGroupCall } = useContext(CallInfoContext);
17
- const nodeRef = useRef<any>();
17
+ // React 19's useRef removed the no-argument overload; pass undefined explicitly.
18
+ const nodeRef = useRef<any>(undefined);
18
19
  const [clickable, setClickable] = useState(true);
19
20
  const visibility: any = props.show ? '' : 'hidden';
20
21
 
@@ -50,7 +50,9 @@ function processAnchorTags(content: string): string {
50
50
  return doc.body.innerHTML;
51
51
  }
52
52
 
53
- const TypeIcons: Record<string, () => JSX.Element> = {
53
+ // React 19 narrows component return types; use ReactNode instead of JSX.Element
54
+ // so each entry can be rendered as <TypeIcon />.
55
+ const TypeIcons: Record<string, () => ReactNode> = {
54
56
  success: () => <span style={{ color: 'green', marginRight: '6px' }}>✓</span>,
55
57
  info: () => <span style={{ color: '#1890ff', marginRight: '6px' }}>ℹ</span>,
56
58
  error: () => <span style={{ color: 'red', marginRight: '6px' }}>✕</span>,
@@ -27,7 +27,7 @@ const TUIGlobal: ITUIGlobal = TuiGlobal.getInstance();
27
27
  const TUIStore: ITUIStore = TuiStore.getInstance();
28
28
  const uiDesign = UIDesign.getInstance();
29
29
  uiDesign.setTUIStore(TUIStore);
30
- const version = '4.5.1';
30
+ const version = '4.5.2';
31
31
  import AIAssistant from './AIAssistant'; // 仅 web 支持 AI 实时字幕
32
32
  const frameWork = 'react';
33
33
  export { TUIGlobal, TUIStore, uiDesign };
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.5.1'; // basic-demo 原来上报使用
38
+ const Version = '4.5.2'; // basic-demo 原来上报使用
39
39
 
40
40
  // 输出产物
41
41
  export {