tuikit-atomicx-vue3 4.3.1 → 4.4.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.
Files changed (113) hide show
  1. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-D1G-LitO.js → MessageInput.vue_vue_type_script_setup_true_lang-D9jiYNFu.js} +31 -31
  2. package/dist/chat/index.d.ts +35 -35
  3. package/dist/chat/server.js +15 -15
  4. package/dist/components/ContactList/ContactInfo/BlacklistInfo/BlacklistInfo.js +6 -6
  5. package/dist/components/ContactList/ContactInfo/ContactInfo.js +1 -1
  6. package/dist/components/ContactList/ContactInfo/FriendApplicationInfo/FriendApplicationInfo.js +1 -1
  7. package/dist/components/ContactList/ContactInfo/FriendInfo/FriendInfo.js +9 -9
  8. package/dist/components/ContactList/ContactInfo/GroupApplicationInfo/GroupApplicationInfo.js +1 -1
  9. package/dist/components/ContactList/ContactInfo/GroupInfo/GroupInfo.js +4 -4
  10. package/dist/components/ContactList/ContactInfo/SearchGroupInfo/SearchGroupInfo.js +8 -8
  11. package/dist/components/ContactList/ContactInfo/SearchUserInfo/SearchUserInfo.js +7 -7
  12. package/dist/components/ContactList/ContactList.js +7 -7
  13. package/dist/components/ContactList/ContactListItem/BlacklistItem/BlacklistItem.js +8 -8
  14. package/dist/components/ContactList/ContactListItem/FriendApplicationItem/FriendApplicationItem.js +5 -5
  15. package/dist/components/ContactList/ContactListItem/FriendItem/FriendItem.js +5 -5
  16. package/dist/components/ContactList/ContactListItem/GroupApplicationItem/GroupApplicationItem.js +1 -1
  17. package/dist/components/ContactList/ContactListItem/GroupItem/GroupItem.js +1 -1
  18. package/dist/components/ContactList/ContactSearch/ContactSearch.js +6 -6
  19. package/dist/components/ConversationList/ConversationCreate/ConversationCreate.js +9 -9
  20. package/dist/components/ConversationList/ConversationList.js +4 -4
  21. package/dist/components/ConversationList/ConversationList.vue.d.ts +10 -10
  22. package/dist/components/ConversationList/ConversationPreview/ConversationPreview.vue.d.ts +10 -10
  23. package/dist/components/ConversationList/ConversationPreview/ConversationPreviewUI.js +20 -20
  24. package/dist/components/ConversationList/ConversationPreview/ConversationPreviewUI.vue.d.ts +2 -2
  25. package/dist/components/ConversationList/ConversationPreview/index.js +1 -1
  26. package/dist/components/ConversationList/index.d.ts +30 -30
  27. package/dist/components/MessageInput/EmojiPicker/EmojiPicker.js +88 -84
  28. package/dist/components/MessageInput/MessageInput.js +1 -1
  29. package/dist/components/MessageInput/MessageInput.vue.d.ts +2 -2
  30. package/dist/components/MessageInput/TextEditor/EditorCore.d.ts +2 -1
  31. package/dist/components/MessageInput/TextEditor/EditorCore.js +23 -21
  32. package/dist/components/MessageInput/TextEditor/TextEditor.vue.d.ts +2 -2
  33. package/dist/components/MessageInput/TextEditor/index.js +32 -31
  34. package/dist/components/MessageInput/index.d.ts +6 -6
  35. package/dist/components/MessageInput/index.js +1 -1
  36. package/dist/components/MessageList/Message/AudioMessage/WaveForm.js +24 -34
  37. package/dist/components/MessageList/Message/CustomMessage/CallMessage/CallMessage.js +29 -28
  38. package/dist/components/MessageList/Message/Message.vue.d.ts +1 -1
  39. package/dist/components/MessageList/MessageList.js +8 -6
  40. package/dist/components/MessageList/index.d.ts +2 -2
  41. package/dist/hooks/useAudioControl.d.ts +3 -3
  42. package/dist/hooks/useAudioControl.js +32 -30
  43. package/dist/rtc/server.js +45 -40
  44. package/dist/states/LoginState.d.ts +23 -0
  45. package/dist/states/LoginState.js +34 -39
  46. package/dist/states/MessageInputState/MessageInputState.d.ts +41 -7
  47. package/dist/states/MessageInputState/MessageInputState.js +60 -59
  48. package/dist/states/MessageInputState/utils.d.ts +8 -1
  49. package/dist/states/MessageInputState/utils.js +30 -10
  50. package/dist/styles/index.css +1 -1
  51. package/dist/utils/call.js +1 -1
  52. package/package.json +1 -1
  53. package/src/chat/server.ts +0 -1
  54. package/src/components/ContactList/ContactInfo/BlacklistInfo/BlacklistInfo.vue +1 -1
  55. package/src/components/ContactList/ContactInfo/ContactInfo.vue +1 -1
  56. package/src/components/ContactList/ContactInfo/FriendApplicationInfo/FriendApplicationInfo.vue +1 -1
  57. package/src/components/ContactList/ContactInfo/FriendInfo/FriendInfo.vue +1 -1
  58. package/src/components/ContactList/ContactInfo/GroupApplicationInfo/GroupApplicationInfo.vue +1 -1
  59. package/src/components/ContactList/ContactInfo/GroupInfo/GroupInfo.vue +1 -1
  60. package/src/components/ContactList/ContactInfo/SearchGroupInfo/SearchGroupInfo.vue +1 -1
  61. package/src/components/ContactList/ContactInfo/SearchUserInfo/SearchUserInfo.vue +1 -1
  62. package/src/components/ContactList/ContactList.vue +1 -1
  63. package/src/components/ContactList/ContactListItem/BlacklistItem/BlacklistItem.vue +1 -1
  64. package/src/components/ContactList/ContactListItem/FriendApplicationItem/FriendApplicationItem.vue +1 -1
  65. package/src/components/ContactList/ContactListItem/FriendItem/FriendItem.vue +1 -1
  66. package/src/components/ContactList/ContactListItem/GroupApplicationItem/GroupApplicationItem.vue +1 -1
  67. package/src/components/ContactList/ContactListItem/GroupItem/GroupItem.vue +1 -1
  68. package/src/components/ContactList/ContactSearch/ContactSearch.vue +1 -1
  69. package/src/components/ConversationList/ConversationActions/ConversationActions.vue +1 -1
  70. package/src/components/ConversationList/ConversationCreate/ConversationCreate.vue +2 -2
  71. package/src/components/ConversationList/ConversationCreate/ConversationCreateButton/ConversationCreateButton.vue +1 -1
  72. package/src/components/ConversationList/ConversationCreate/ConversationCreateGroupDetail/ConversationCreateGroupDetail.vue +1 -1
  73. package/src/components/ConversationList/ConversationCreate/ConversationCreateUserSelectList/ConversationCreateUserSelectList.vue +1 -1
  74. package/src/components/ConversationList/ConversationCreate/ConversationGroupTypeInfo/ConversationGroupTypeInfo.vue +1 -1
  75. package/src/components/ConversationList/ConversationList.vue +2 -2
  76. package/src/components/ConversationList/ConversationListContent/ConversationListContent.vue +1 -1
  77. package/src/components/ConversationList/ConversationListHeader/ConversationListHeader.vue +1 -1
  78. package/src/components/ConversationList/ConversationPlaceHolder/ConversationPlaceHolder.vue +1 -1
  79. package/src/components/ConversationList/ConversationPreview/ConversationPreview.vue +1 -1
  80. package/src/components/ConversationList/ConversationPreview/ConversationPreviewAbstract.vue +1 -1
  81. package/src/components/ConversationList/ConversationPreview/ConversationPreviewTimestamp.vue +1 -1
  82. package/src/components/ConversationList/ConversationPreview/ConversationPreviewTitle.vue +1 -1
  83. package/src/components/ConversationList/ConversationPreview/ConversationPreviewUI.vue +3 -3
  84. package/src/components/ConversationList/ConversationPreview/ConversationPreviewUnread.vue +1 -1
  85. package/src/components/ConversationList/ConversationSearch/ConversationSearch.vue +1 -1
  86. package/src/components/MessageInput/EmojiPicker/EmojiPicker.vue +7 -3
  87. package/src/components/MessageInput/MessageInput.module.scss +1 -0
  88. package/src/components/MessageInput/MessageInput.vue +1 -1
  89. package/src/components/MessageInput/TextEditor/EditorCore.ts +4 -2
  90. package/src/components/MessageInput/TextEditor/TextEditor.vue +3 -4
  91. package/src/components/MessageList/Message/AudioMessage/WaveForm.vue +20 -37
  92. package/src/components/MessageList/Message/CustomMessage/CallMessage/CallMessage.vue +1 -1
  93. package/src/components/MessageList/Message/Message.vue +1 -1
  94. package/src/components/MessageList/MessageList.vue +2 -0
  95. package/src/components/Search/Search.vue +1 -1
  96. package/src/components/Search/SearchAdvanced/DateRangePicker/DateRangePicker.vue +1 -1
  97. package/src/components/Search/SearchAdvanced/MessageAdvanced/MessageAdvanced.vue +1 -1
  98. package/src/components/Search/SearchAdvanced/SearchAdvanced.vue +1 -1
  99. package/src/components/Search/SearchAdvanced/SearchTab/SearchTab.vue +1 -1
  100. package/src/components/Search/SearchAdvanced/Slider/Slider.vue +1 -1
  101. package/src/components/Search/SearchAdvanced/UserAdvanced/UserAdvanced.vue +1 -1
  102. package/src/components/Search/SearchBar/SearchBar.vue +1 -1
  103. package/src/components/Search/SearchResults/EmptyResult/EmptyResult.vue +1 -1
  104. package/src/components/Search/SearchResults/Loading/Loading.vue +1 -1
  105. package/src/components/Search/SearchResults/SearchResults.vue +1 -1
  106. package/src/components/Search/SearchResults/SearchResultsItem/Conversation/Conversation.vue +1 -1
  107. package/src/components/Search/SearchResults/SearchResultsItem/Group/Group.vue +1 -1
  108. package/src/components/Search/SearchResults/SearchResultsItem/Message/Message.vue +1 -1
  109. package/src/components/Search/SearchResults/SearchResultsItem/SearchResultsItem.vue +1 -1
  110. package/src/components/Search/SearchResults/SearchResultsItem/User/User.vue +1 -1
  111. package/src/hooks/useAudioControl.ts +17 -4
  112. package/src/rtc/server.ts +4 -0
  113. package/src/utils/call.ts +2 -2
@@ -1,16 +1,19 @@
1
- var u = Object.defineProperty;
2
- var L = (o, i, t) => i in o ? u(o, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[i] = t;
3
- var s = (o, i, t) => L(o, typeof i != "symbol" ? i + "" : i, t);
4
- import { ref as f } from "vue";
5
- import U from "@tencentcloud/chat-uikit-engine";
6
- import S, { TUIConstants as g, TUILogin as T } from "@tencentcloud/tui-core";
7
- import c from "@tencentcloud/tuiroom-engine-js";
8
- import { useLoginState as m } from "../states/LoginState.js";
1
+ var h = Object.defineProperty;
2
+ var T = (n, t, i) => t in n ? h(n, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[t] = i;
3
+ var s = (n, t, i) => T(n, typeof t != "symbol" ? t + "" : t, i);
4
+ import { ref as U } from "vue";
5
+ import m from "@tencentcloud/chat-uikit-engine";
6
+ import S, { TUIConstants as g, TUILogin as _ } from "@tencentcloud/tui-core";
7
+ import l from "@tencentcloud/tuiroom-engine-js";
8
+ import { dataReport as p } from "../report/dataReport.js";
9
+ import { MetricsKey as c } from "../report/MetricsKey.js";
10
+ import { useLoginState as N } from "../states/LoginState.js";
11
+ import { isMobile as C } from "../utils/env.js";
9
12
  const e = class e {
10
13
  constructor() {
11
14
  s(this, "isReady", !1);
12
15
  s(this, "isEngineLoggingIn", !1);
13
- s(this, "isLogin", f(!1));
16
+ s(this, "isLogin", U(!1));
14
17
  s(this, "resolveList", []);
15
18
  s(this, "rejectList", []);
16
19
  this.init();
@@ -28,9 +31,9 @@ const e = class e {
28
31
  /**
29
32
  * @param { TUIInitParam } params
30
33
  */
31
- onNotifyEvent(i, t) {
32
- if (i === g.TUILogin.EVENT.LOGIN_STATE_CHANGED)
33
- switch (t) {
34
+ onNotifyEvent(t, i) {
35
+ if (t === g.TUILogin.EVENT.LOGIN_STATE_CHANGED)
36
+ switch (i) {
34
37
  case g.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS:
35
38
  this.login();
36
39
  break;
@@ -41,52 +44,54 @@ const e = class e {
41
44
  }
42
45
  async login() {
43
46
  const {
44
- chat: i,
45
- SDKAppID: t,
46
- userID: l,
47
- userSig: E
48
- } = T.getContext();
47
+ chat: t,
48
+ SDKAppID: i,
49
+ userID: E,
50
+ userSig: I
51
+ } = _.getContext();
49
52
  if (this.isEngineLoggingIn)
50
- return new Promise((n, r) => {
51
- this.resolveList.push(n), this.rejectList.push(r);
53
+ return new Promise((o, r) => {
54
+ this.resolveList.push(o), this.rejectList.push(r);
52
55
  });
53
56
  try {
54
- this.isEngineLoggingIn = !0, await U.login({
55
- chat: i,
56
- SDKAppID: t,
57
- userID: l,
58
- userSig: E
57
+ this.isEngineLoggingIn = !0;
58
+ const o = C ? c.T_METRICS_STATE_API_LOGIN_MOBILE_COUNT : c.T_METRICS_STATE_API_LOGIN_COUNT;
59
+ p.reportCount(o), await m.login({
60
+ chat: t,
61
+ SDKAppID: i,
62
+ userID: E,
63
+ userSig: I
59
64
  });
60
- const n = await c.login({
61
- sdkAppId: t,
62
- userId: l,
63
- userSig: E,
64
- tim: i
65
+ const r = await l.login({
66
+ sdkAppId: i,
67
+ userId: E,
68
+ userSig: I,
69
+ tim: t
65
70
  });
66
- this.isLogin.value = !0, this.resolveList.forEach((h) => {
67
- h();
71
+ this.isLogin.value = !0, this.resolveList.forEach((u) => {
72
+ u();
68
73
  }), this.rejectList = [], this.resolveList = [];
69
- const { loginUserInfo: r } = m(), a = (await i.getUserProfile({ userIDList: [l] })).data[0];
70
- return a.value || (r.value = {
74
+ const { loginUserInfo: f } = N(), a = (await t.getUserProfile({ userIDList: [E] })).data[0];
75
+ return a.value || (f.value = {
71
76
  userId: a.userID,
72
77
  userName: a.nick,
73
78
  avatarUrl: a.avatar,
74
79
  customInfo: a.profileCustomField
75
- }), n;
76
- } catch (n) {
80
+ }), r;
81
+ } catch (o) {
77
82
  throw this.rejectList.forEach((r) => {
78
- r(n);
79
- }), this.rejectList = [], this.resolveList = [], n;
83
+ r(o);
84
+ }), this.rejectList = [], this.resolveList = [], o;
80
85
  } finally {
81
86
  this.isEngineLoggingIn = !1;
82
87
  }
83
88
  }
84
89
  logout() {
85
- c.logout(), this.isLogin.value = !1, this.isEngineLoggingIn = !1;
90
+ l.logout(), this.isLogin.value = !1, this.isEngineLoggingIn = !1;
86
91
  }
87
92
  };
88
93
  s(e, "instance");
89
- let I = e;
94
+ let L = e;
90
95
  export {
91
- I as default
96
+ L as default
92
97
  };
@@ -3,6 +3,29 @@ import { LoginParams, LoginUserInfo, SetSelfInfoParams } from '../types/login';
3
3
  declare function login(options: LoginParams): Promise<void>;
4
4
  declare function setSelfInfo(options: SetSelfInfoParams): Promise<void>;
5
5
  declare function logout(): Promise<void>;
6
+ /**
7
+ * 用户登录状态管理 Hook
8
+ * @memberof module:LoginState
9
+ * @description 提供用户登录、登出、个人信息管理等功能
10
+ * @returns {Object} 返回登录状态管理对象
11
+ * @returns {Ref<LoginUserInfo | null>} returns.loginUserInfo - 当前登录用户信息
12
+ * @returns {Function} returns.login - 登录函数
13
+ * @returns {Function} returns.logout - 登出函数
14
+ * @returns {Function} returns.setSelfInfo - 设置个人信息函数
15
+ * @example
16
+ * ```typescript
17
+ * const { loginUserInfo, login, logout, setSelfInfo } = useLoginState();
18
+ *
19
+ * // 登录
20
+ * await login({ userId: 'user123', userSig: 'sig', sdkAppId: 123456 });
21
+ *
22
+ * // 设置个人信息
23
+ * await setSelfInfo({ nick: '新昵称' });
24
+ *
25
+ * // 登出
26
+ * await logout();
27
+ * ```
28
+ */
6
29
  export declare function useLoginState(): {
7
30
  loginUserInfo: import('vue').Ref<{
8
31
  userId: string;
@@ -1,69 +1,64 @@
1
1
  import { ref as c } from "vue";
2
- import { TUILogin as i } from "@tencentcloud/tui-core";
3
- import { dataReport as f } from "../report/dataReport.js";
4
- import { MetricsKey as u } from "../report/MetricsKey.js";
5
- import { useStatistical as g } from "../statistical/statistical.js";
6
- import { isMobile as m } from "../utils/env.js";
7
- const a = c(null), { getChatScene: I } = g();
8
- async function S(r) {
2
+ import { TUILogin as u } from "@tencentcloud/tui-core";
3
+ import { useStatistical as i } from "../statistical/statistical.js";
4
+ const s = c(null), { getChatScene: f } = i();
5
+ async function g(r) {
9
6
  if (!r.userId || !r.userSig || !r.sdkAppId)
10
7
  throw new Error("[loginState login] params error");
11
- const { userId: l, userSig: e, sdkAppId: n, ...o } = r, s = {
8
+ const { userId: l, userSig: t, sdkAppId: n, ...e } = r, a = {
12
9
  SDKAppID: n,
13
10
  userID: l,
14
- userSig: e,
11
+ userSig: t,
15
12
  useUploadPlugin: !0,
16
- scene: I(),
17
- ...o
13
+ scene: f(),
14
+ ...e
18
15
  };
19
16
  try {
20
- await i.login(s);
21
- const t = m ? u.T_METRICS_STATE_API_LOGIN_MOBILE_COUNT : u.T_METRICS_STATE_API_LOGIN_COUNT;
22
- f.reportCount(t);
23
- } catch (t) {
24
- throw console.error("[loginState login] error", t), t;
17
+ await u.login(a);
18
+ } catch (o) {
19
+ throw console.error("[loginState login] error", o), o;
25
20
  }
26
21
  }
27
- async function _(r) {
28
- const l = a.value || {}, { chat: e } = i.getContext();
29
- if (e) {
22
+ async function m(r) {
23
+ const l = s.value || {}, { chat: t } = u.getContext();
24
+ if (t) {
30
25
  const n = [];
31
- r.customInfo && Object.keys(r.customInfo).forEach((o) => {
32
- var t;
33
- let s = o;
34
- o.includes("Tag_Profile_Custom") || (s = `Tag_Profile_Custom_${o}`), n.push({
35
- key: s,
36
- value: (t = r.customInfo) == null ? void 0 : t[o]
26
+ r.customInfo && Object.keys(r.customInfo).forEach((e) => {
27
+ var o;
28
+ let a = e;
29
+ e.includes("Tag_Profile_Custom") || (a = `Tag_Profile_Custom_${e}`), n.push({
30
+ key: a,
31
+ value: (o = r.customInfo) == null ? void 0 : o[e]
37
32
  });
38
33
  });
39
34
  try {
40
- const o = await e.updateMyProfile({
35
+ const e = await t.updateMyProfile({
41
36
  nick: r.userName,
42
37
  avatar: r.avatarUrl,
43
38
  profileCustomField: n
44
39
  });
45
- return a.value = {
40
+ return s.value = {
46
41
  ...l,
47
42
  ...r
48
- }, o;
49
- } catch (o) {
50
- throw console.error("[loginState setSelfInfo] error", o), o;
43
+ }, e;
44
+ } catch (e) {
45
+ throw console.error("[loginState setSelfInfo] error", e), e;
51
46
  }
52
47
  } else
53
48
  throw Error("[loginState setSelfInfo] not login");
54
49
  }
55
- async function p() {
56
- a.value = null, i.logout();
50
+ async function I() {
51
+ s.value = null, u.logout();
57
52
  }
58
- function w() {
53
+ function p() {
59
54
  return {
60
- loginUserInfo: a,
61
- login: S,
62
- logout: p,
63
- setSelfInfo: _
55
+ loginUserInfo: s,
56
+ login: g,
57
+ logout: I,
58
+ setSelfInfo: m
64
59
  };
65
60
  }
66
61
  export {
67
- w as default,
68
- w as useLoginState
62
+ p as default,
63
+ p as useLoginState
69
64
  };
@@ -3,13 +3,13 @@ import { MessageContentType, InputContent } from './type';
3
3
  import { Editor } from '@tiptap/vue-3';
4
4
 
5
5
  /**
6
- * Message Input Store
7
- *
8
- * This store manages the state and operations related to the chat message input, including:
9
- * - Raw input value (text or structured content)
10
- * - Editor instance management
11
- * - Content manipulation (insertion, updating, etc.)
12
- * - Message sending functionality
6
+ * 消息输入状态管理
7
+ * @module MessageInputState
8
+ * @description 管理聊天消息输入相关的状态和操作,包括:
9
+ * - 原始输入值(文本或结构化内容)
10
+ * - 编辑器实例管理
11
+ * - 内容操作(插入、更新等)
12
+ * - 消息发送功能
13
13
  */
14
14
  interface MessageInputState {
15
15
  inputRawValue: Ref<string | InputContent[]>;
@@ -24,6 +24,40 @@ interface MessageInputAction {
24
24
  blurEditor: () => void;
25
25
  sendMessage: (msg?: string | InputContent[]) => void;
26
26
  }
27
+ /**
28
+ * 消息输入状态管理 Hook
29
+ * @memberof module:MessageInputState
30
+ * @description 提供消息输入相关的状态管理和操作功能,包括文本输入、编辑器控制、消息发送等
31
+ * @returns {MessageInputState & MessageInputAction} 返回消息输入状态管理对象
32
+ * @returns {Ref<string>} returns.inputRawValue - 输入框原始值
33
+ * @returns {Ref<boolean>} returns.isPeerTyping - 对方是否正在输入
34
+ * @returns {Function} returns.updateRawValue - 更新输入框原始值函数
35
+ * @returns {Function} returns.setEditorInstance - 设置编辑器实例函数
36
+ * @returns {Function} returns.setContent - 设置编辑器内容函数
37
+ * @returns {Function} returns.insertContent - 插入内容到编辑器函数
38
+ * @returns {Function} returns.focusEditor - 聚焦编辑器函数
39
+ * @returns {Function} returns.blurEditor - 失焦编辑器函数
40
+ * @returns {Function} returns.sendMessage - 发送消息函数
41
+ * @example
42
+ * ```typescript
43
+ * const {
44
+ * inputRawValue,
45
+ * isPeerTyping,
46
+ * setContent,
47
+ * sendMessage,
48
+ * focusEditor
49
+ * } = useMessageInputState();
50
+ *
51
+ * // 设置编辑器内容
52
+ * setContent('Hello World');
53
+ *
54
+ * // 发送消息
55
+ * await sendMessage();
56
+ *
57
+ * // 聚焦编辑器
58
+ * focusEditor();
59
+ * ```
60
+ */
27
61
  declare function useMessageInputState(): MessageInputState & MessageInputAction;
28
62
  export { useMessageInputState, MessageContentType };
29
63
  export type { InputContent };
@@ -1,111 +1,112 @@
1
- import { ref as d } from "vue";
2
- import { TUIStore as w, StoreName as M, TUIChatService as o } from "@tencentcloud/chat-uikit-engine";
3
- import { MessageContentType as s } from "./type.js";
4
- import { convertInputContentToEditorNode as p } from "./utils.js";
1
+ import { ref as l } from "vue";
2
+ import { TUIStore as w, StoreName as I, TUIChatService as r } from "@tencentcloud/chat-uikit-engine";
3
+ import { MessageContentType as a } from "./type.js";
4
+ import { trimInputContent as M, convertInputContentToEditorNode as p } from "./utils.js";
5
5
  import { useMessageListState as v } from "../MessageListState/MessageListState.js";
6
6
  import { transformTextWithEmojiNameToKey as f } from "../../utils/emoji.js";
7
- const n = d(null), m = d(""), y = d(!1), E = (e) => {
7
+ const n = l(null), m = l(""), y = l(!1), E = (e) => {
8
8
  if (typeof e != "string" && !Array.isArray(e)) {
9
9
  console.warn("Invalid input type for updateRawValue");
10
10
  return;
11
11
  }
12
- typeof e == "string" ? m.value = e.trim() : m.value = (e == null ? void 0 : e.length) > 0 ? e : "", o.enterTypingState(), setTimeout(() => {
13
- o.leaveTypingState();
12
+ typeof e == "string" ? m.value = e.trim() : m.value = (e == null ? void 0 : e.length) > 0 ? e : "", r.enterTypingState(), setTimeout(() => {
13
+ r.leaveTypingState();
14
14
  }, 3e3);
15
- }, I = (e) => {
16
- n.value && n.value.destroy(), n.value = e;
17
15
  }, C = (e) => {
16
+ n.value && n.value.destroy(), n.value = e;
17
+ }, S = (e) => {
18
18
  if (n.value) {
19
19
  if (typeof e == "string")
20
20
  n.value.commands.setContent(e, !0);
21
21
  else {
22
- const r = e.map(p);
23
- n.value.commands.setContent(r, !0);
22
+ const i = e.map(p);
23
+ n.value.commands.setContent(i, !0);
24
24
  }
25
25
  n.value.commands.focus();
26
26
  }
27
- }, S = (e, r = !0) => {
27
+ }, x = (e, i = !0) => {
28
28
  if (n.value) {
29
29
  if (typeof e == "string")
30
30
  n.value.commands.insertContent(e);
31
31
  else {
32
- const a = e.map(p);
33
- n.value.commands.insertContent(a);
32
+ const o = e.map(p);
33
+ n.value.commands.insertContent(o);
34
34
  }
35
- r && n.value.commands.focus();
35
+ i && n.value.commands.focus();
36
36
  }
37
- }, x = () => {
37
+ }, h = () => {
38
38
  var e;
39
39
  (e = n.value) == null || e.commands.focus();
40
- }, h = () => {
40
+ }, R = () => {
41
41
  var e;
42
42
  (e = n.value) == null || e.commands.blur();
43
- }, R = async (e) => {
44
- const { enableReadReceipt: r } = v(), a = {
45
- needReadReceipt: r.value || !1
46
- }, c = e ?? m.value;
47
- if (!c)
43
+ }, A = async (e) => {
44
+ const { enableReadReceipt: i } = v(), o = {
45
+ needReadReceipt: i.value || !1
46
+ };
47
+ let s = e ?? m.value;
48
+ if (typeof s == "string" ? s = s.trim() : s = M(s), !s)
48
49
  return;
49
- if (typeof c == "string") {
50
- o.sendTextMessage({
51
- payload: { text: f(c) },
52
- ...a
50
+ if (typeof s == "string") {
51
+ r.sendTextMessage({
52
+ payload: { text: f(s) },
53
+ ...o
53
54
  });
54
55
  return;
55
56
  }
56
- let u = "";
57
- const i = async () => {
58
- u && (await o.sendTextMessage({
59
- payload: { text: f(u) },
60
- ...a
61
- }), u = "");
62
- }, l = {
63
- [s.TEXT]: (t) => t,
64
- [s.IMAGE]: async (t) => (await i(), await o.sendImageMessage({
57
+ let c = "";
58
+ const u = async () => {
59
+ c && (await r.sendTextMessage({
60
+ payload: { text: f(c) },
61
+ ...o
62
+ }), c = "");
63
+ }, d = {
64
+ [a.TEXT]: (t) => t,
65
+ [a.IMAGE]: async (t) => (await u(), await r.sendImageMessage({
65
66
  payload: { file: t },
66
- ...a
67
+ ...o
67
68
  }), ""),
68
- [s.VIDEO]: async (t) => (await i(), await o.sendVideoMessage({
69
+ [a.VIDEO]: async (t) => (await u(), await r.sendVideoMessage({
69
70
  payload: { file: t },
70
- ...a
71
+ ...o
71
72
  }), ""),
72
- [s.FILE]: async (t) => (await i(), await o.sendFileMessage({
73
+ [a.FILE]: async (t) => (await u(), await r.sendFileMessage({
73
74
  payload: { file: t },
74
- ...a
75
+ ...o
75
76
  }), ""),
76
- [s.MENTION]: async () => (await i(), console.warn("Mention feature not implemented yet"), ""),
77
- [s.EMOJI]: (t) => t.key
77
+ [a.MENTION]: async () => (await u(), console.warn("Mention feature not implemented yet"), ""),
78
+ [a.EMOJI]: (t) => t.key
78
79
  };
79
- for (const t of c) {
80
- if (!t.type || !l[t.type])
80
+ for (const t of s) {
81
+ if (!t.type || !d[t.type])
81
82
  throw new Error(`Invalid message type: ${t.type}`);
82
- const g = l[t.type], T = await g(t.content);
83
- [s.TEXT, s.EMOJI].includes(t.type) && (u += T);
83
+ const g = d[t.type], T = await g(t.content);
84
+ [a.TEXT, a.EMOJI].includes(t.type) && (c += T);
84
85
  }
85
- await i();
86
+ await u();
86
87
  };
87
- function F() {
88
+ function J() {
88
89
  return {
89
90
  inputRawValue: m,
90
91
  isPeerTyping: y,
91
92
  updateRawValue: E,
92
- setEditorInstance: I,
93
- setContent: C,
94
- insertContent: S,
95
- focusEditor: x,
96
- blurEditor: h,
97
- sendMessage: R
93
+ setEditorInstance: C,
94
+ setContent: S,
95
+ insertContent: x,
96
+ focusEditor: h,
97
+ blurEditor: R,
98
+ sendMessage: A
98
99
  };
99
100
  }
100
- function A() {
101
- w.watch(M.CHAT, {
101
+ function N() {
102
+ w.watch(I.CHAT, {
102
103
  typingStatus: (e) => {
103
104
  y.value = e;
104
105
  }
105
106
  });
106
107
  }
107
- A();
108
+ N();
108
109
  export {
109
- s as MessageContentType,
110
- F as useMessageInputState
110
+ a as MessageContentType,
111
+ J as useMessageInputState
111
112
  };
@@ -27,4 +27,11 @@ declare function convertInputContentToEditorNode(item: InputContent): {
27
27
  };
28
28
  text?: undefined;
29
29
  };
30
- export { convertInputContentToEditorNode, };
30
+ /**
31
+ * Trims whitespace from the beginning and end of an InputContent array,
32
+ * while preserving internal whitespace and line breaks
33
+ * @param content - The input content array to trim
34
+ * @returns Trimmed input content array
35
+ */
36
+ declare function trimInputContent(content: InputContent[]): InputContent[];
37
+ export { trimInputContent, convertInputContentToEditorNode, };
@@ -1,27 +1,27 @@
1
- import { MessageContentType as n } from "./type.js";
2
- function c(e) {
1
+ import { MessageContentType as r } from "./type.js";
2
+ function l(e) {
3
3
  switch (e.type) {
4
- case n.TEXT:
4
+ case r.TEXT:
5
5
  return {
6
6
  type: "text",
7
7
  text: e.content
8
8
  };
9
- case n.IMAGE: {
10
- const t = e.content, r = URL.createObjectURL(t);
9
+ case r.IMAGE: {
10
+ const t = e.content, s = URL.createObjectURL(t);
11
11
  return {
12
- type: n.IMAGE,
12
+ type: r.IMAGE,
13
13
  attrs: {
14
- src: r,
14
+ src: s,
15
15
  alt: t == null ? void 0 : t.name,
16
16
  fileData: t,
17
17
  title: t == null ? void 0 : t.name
18
18
  }
19
19
  };
20
20
  }
21
- case n.EMOJI: {
21
+ case r.EMOJI: {
22
22
  const t = e.content;
23
23
  return {
24
- type: n.EMOJI,
24
+ type: r.EMOJI,
25
25
  attrs: {
26
26
  src: t.url,
27
27
  alt: t.key,
@@ -36,6 +36,26 @@ function c(e) {
36
36
  };
37
37
  }
38
38
  }
39
+ function f(e) {
40
+ if (e.length === 0)
41
+ return [];
42
+ let t = -1, s = -1;
43
+ for (let n = 0; n < e.length; n++) {
44
+ const o = e[n];
45
+ (o.type !== r.TEXT || o.content.trim().length > 0) && (t === -1 && (t = n), s = n);
46
+ }
47
+ return t === -1 ? [] : e.slice(t, s + 1).map((n, o, p) => {
48
+ if (n.type === r.TEXT) {
49
+ let c = n.content;
50
+ return o === 0 && (c = c.trimStart()), o === p.length - 1 && (c = c.trimEnd()), {
51
+ ...n,
52
+ content: c
53
+ };
54
+ }
55
+ return n;
56
+ }).filter((n) => n.type === r.TEXT ? n.content.length > 0 : !0);
57
+ }
39
58
  export {
40
- c as convertInputContentToEditorNode
59
+ l as convertInputContentToEditorNode,
60
+ f as trimInputContent
41
61
  };