diff --git a/assets/linux_arm64/.gitkeep b/assets/linux_arm64/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/assets/linux_arm64/libopenimsdk.so b/assets/linux_arm64/libopenimsdk.so index b4a5d69..a84ca2d 100644 Binary files a/assets/linux_arm64/libopenimsdk.so and b/assets/linux_arm64/libopenimsdk.so differ diff --git a/assets/linux_x64/.gitkeep b/assets/linux_x64/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/assets/linux_x64/libopenimsdk.so b/assets/linux_x64/libopenimsdk.so index b4a5d69..b0a99b4 100644 Binary files a/assets/linux_x64/libopenimsdk.so and b/assets/linux_x64/libopenimsdk.so differ diff --git a/assets/mac_arm64/.gitkeep b/assets/mac_arm64/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/assets/mac_arm64/libopenimsdk.dylib b/assets/mac_arm64/libopenimsdk.dylib index 30d48d9..1cdc9ca 100644 Binary files a/assets/mac_arm64/libopenimsdk.dylib and b/assets/mac_arm64/libopenimsdk.dylib differ diff --git a/assets/mac_x64/.gitkeep b/assets/mac_x64/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/assets/mac_x64/libopenimsdk.dylib b/assets/mac_x64/libopenimsdk.dylib index 30d48d9..2a06212 100644 Binary files a/assets/mac_x64/libopenimsdk.dylib and b/assets/mac_x64/libopenimsdk.dylib differ diff --git a/assets/win_ia32/libopenimsdk.dll b/assets/win_ia32/libopenimsdk.dll deleted file mode 100644 index 366789d..0000000 Binary files a/assets/win_ia32/libopenimsdk.dll and /dev/null differ diff --git a/assets/win_x64/.gitkeep b/assets/win_x64/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/assets/win_x64/libopenimsdk.dll b/assets/win_x64/libopenimsdk.dll index 366789d..a56bdee 100644 Binary files a/assets/win_x64/libopenimsdk.dll and b/assets/win_x64/libopenimsdk.dll differ diff --git a/package-lock.json b/package-lock.json index d87e50f..7b53f59 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@openim/electron-client-sdk", - "version": "1.0.9", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@openim/electron-client-sdk", - "version": "1.0.9", + "version": "1.1.0", "license": "MIT", "dependencies": { "koffi": "^2.8.0", @@ -15,7 +15,7 @@ "devDependencies": { "@commitlint/cli": "^16.2.4", "@commitlint/config-conventional": "^16.2.4", - "@openim/wasm-client-sdk": "^3.8.0", + "@openim/wasm-client-sdk": "^3.8.2-beta.4", "@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-terser": "^0.4.4", "@types/ffi-napi": "^4.0.10", @@ -43,7 +43,7 @@ "node": ">=12.0" }, "peerDependencies": { - "@openim/wasm-client-sdk": "^3.8.0", + "@openim/wasm-client-sdk": "^3.8.2-beta.3", "electron": ">=12.0.0" } }, @@ -1882,9 +1882,9 @@ } }, "node_modules/@openim/wasm-client-sdk": { - "version": "3.8.1", - "resolved": "https://registry.npmjs.org/@openim/wasm-client-sdk/-/wasm-client-sdk-3.8.1.tgz", - "integrity": "sha512-1z90Z5A24MCeIuQtvP68GhQ2bEaS+XjpqtSnpLA9qcahaQqErzanzwJ4kDbo+1+Z0MFNqnDzjlnUjyf2FRv41Q==", + "version": "3.8.2-beta.4", + "resolved": "https://registry.npmjs.org/@openim/wasm-client-sdk/-/wasm-client-sdk-3.8.2-beta.4.tgz", + "integrity": "sha512-AH1FgOiQFM9bL1R18/z2oZkZwXKVZTy6EpMaBfSV6giM/++fwV4zLS0W/vJ7u8CrZgkcIPaY7h+JR3ICxn/3vg==", "dev": true, "engines": { "node": ">=12.0" diff --git a/package.json b/package.json index d4fa5e6..98166c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openim/electron-client-sdk", - "version": "1.0.9", + "version": "1.1.0", "description": "open im sdk for node", "source": "src/index.ts", "main": "lib/index.js", @@ -43,9 +43,9 @@ "devDependencies": { "@commitlint/cli": "^16.2.4", "@commitlint/config-conventional": "^16.2.4", + "@openim/wasm-client-sdk": "^3.8.2-beta.4", "@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-terser": "^0.4.4", - "@openim/wasm-client-sdk": "^3.8.0", "@types/ffi-napi": "^4.0.10", "@types/node": "^12.20.55", "@types/uuid": "^8.3.4", @@ -80,7 +80,7 @@ "uuid": "^9.0.0" }, "peerDependencies": { - "@openim/wasm-client-sdk": "^3.8.0", + "@openim/wasm-client-sdk": "^3.8.2-beta.3", "electron": ">=12.0.0" } } diff --git a/src/core/index.ts b/src/core/index.ts index 0ddfe38..d992449 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -24,6 +24,7 @@ import { CbEvents, LoginStatus, LogLevel } from '@openim/wasm-client-sdk'; import { SelfUserInfo } from '@openim/wasm-client-sdk/lib/types/entity'; import { SetConversationExParams, + SetConversationParams, SetFriendExParams, UploadFileParams, } from '@openim/wasm-client-sdk/lib/types/params'; @@ -364,47 +365,17 @@ class OpenIMSDK 'void', ['baseCallback *', 'str', 'str'] ); - this.libOpenIMSDK.get_conversation_recv_message_opt = this.lib.func( - '__stdcall', - 'get_conversation_recv_message_opt', - 'void', - ['baseCallback *', 'str', 'str'] - ); this.libOpenIMSDK.set_conversation_draft = this.lib.func( '__stdcall', 'set_conversation_draft', 'void', ['baseCallback *', 'str', 'str', 'str'] ); - this.libOpenIMSDK.reset_conversation_group_at_type = this.lib.func( + this.libOpenIMSDK.set_conversation = this.lib.func( '__stdcall', - 'reset_conversation_group_at_type', + 'set_conversation', 'void', - ['baseCallback *', 'str', 'str'] - ); - this.libOpenIMSDK.pin_conversation = this.lib.func( - '__stdcall', - 'pin_conversation', - 'void', - ['baseCallback *', 'str', 'str', 'int'] - ); - this.libOpenIMSDK.set_conversation_private_chat = this.lib.func( - '__stdcall', - 'set_conversation_private_chat', - 'void', - ['baseCallback *', 'str', 'str', 'int'] - ); - this.libOpenIMSDK.set_conversation_burn_duration = this.lib.func( - '__stdcall', - 'set_conversation_burn_duration', - 'void', - ['baseCallback *', 'str', 'str', 'int'] - ); - this.libOpenIMSDK.set_conversation_recv_message_opt = this.lib.func( - '__stdcall', - 'set_conversation_recv_message_opt', - 'void', - ['baseCallback *', 'str', 'str', 'int'] + ['baseCallback *', 'str', 'str', 'str'] ); this.libOpenIMSDK.get_total_unread_msg_count = this.lib.func( '__stdcall', @@ -544,11 +515,11 @@ class OpenIMSDK 'void', ['baseCallback *', 'str', 'str'] ); - this.libOpenIMSDK.get_users_info_with_cache = this.lib.func( + this.libOpenIMSDK.get_users_info = this.lib.func( '__stdcall', - 'get_users_info_with_cache', + 'get_users_info', 'void', - ['baseCallback *', 'str', 'str', 'str'] + ['baseCallback *', 'str', 'str'] ); this.libOpenIMSDK.set_self_info = this.lib.func( '__stdcall', @@ -556,12 +527,6 @@ class OpenIMSDK 'void', ['baseCallback *', 'str', 'str'] ); - this.libOpenIMSDK.set_global_recv_message_opt = this.lib.func( - '__stdcall', - 'set_global_recv_message_opt', - 'void', - ['baseCallback *', 'str', 'int'] - ); this.libOpenIMSDK.get_self_user_info = this.lib.func( '__stdcall', 'get_self_user_info', @@ -593,23 +558,29 @@ class OpenIMSDK ['baseCallback *', 'str', 'str'] ); // Friend functions - this.libOpenIMSDK.get_specified_friends_info = this.lib.func( + this.libOpenIMSDK.update_friends = this.lib.func( '__stdcall', 'get_specified_friends_info', 'void', ['baseCallback *', 'str', 'str'] ); + this.libOpenIMSDK.get_specified_friends_info = this.lib.func( + '__stdcall', + 'get_specified_friends_info', + 'void', + ['baseCallback *', 'str', 'str', 'int'] + ); this.libOpenIMSDK.get_friend_list = this.lib.func( '__stdcall', 'get_friend_list', 'void', - ['baseCallback *', 'str'] + ['baseCallback *', 'str', 'int'] ); this.libOpenIMSDK.get_friend_list_page = this.lib.func( '__stdcall', 'get_friend_list_page', 'void', - ['baseCallback *', 'str', 'int', 'int'] + ['baseCallback *', 'str', 'int', 'int', 'int'] ); this.libOpenIMSDK.search_friends = this.lib.func( '__stdcall', @@ -629,12 +600,6 @@ class OpenIMSDK 'void', ['baseCallback *', 'str', 'str'] ); - this.libOpenIMSDK.set_friend_remark = this.lib.func( - '__stdcall', - 'set_friend_remark', - 'void', - ['baseCallback *', 'str', 'str'] - ); this.libOpenIMSDK.delete_friend = this.lib.func( '__stdcall', 'delete_friend', @@ -720,12 +685,6 @@ class OpenIMSDK 'void', ['baseCallback *', 'str', 'str', 'str', 'int'] ); - this.libOpenIMSDK.set_group_member_role_level = this.lib.func( - '__stdcall', - 'set_group_member_role_level', - 'void', - ['baseCallback *', 'str', 'str', 'str', 'int'] - ); this.libOpenIMSDK.set_group_member_info = this.lib.func( '__stdcall', 'set_group_member_info', @@ -880,18 +839,6 @@ class OpenIMSDK // advance if (this.enterprise) { - this.libOpenIMSDK.set_conversation_msg_destruct_time = this.lib.func( - '__stdcall', - 'set_conversation_msg_destruct_time', - 'void', - ['baseCallback *', 'str', 'str', 'long long'] - ); - this.libOpenIMSDK.set_conversation_is_msg_destruct = this.lib.func( - '__stdcall', - 'set_conversation_is_msg_destruct', - 'void', - ['baseCallback *', 'str', 'str', 'int'] - ); this.libOpenIMSDK.send_group_message_read_receipt = this.lib.func( '__stdcall', 'send_group_message_read_receipt', @@ -973,48 +920,6 @@ class OpenIMSDK ['baseCallback *', 'str'] ); - this.libOpenIMSDK.signaling_create_meeting = this.lib.func( - '__stdcall', - 'signaling_create_meeting', - 'void', - ['baseCallback *', 'str', 'str'] - ); - - this.libOpenIMSDK.signaling_join_meeting = this.lib.func( - '__stdcall', - 'signaling_join_meeting', - 'void', - ['baseCallback *', 'str', 'str'] - ); - - this.libOpenIMSDK.signaling_update_meeting_info = this.lib.func( - '__stdcall', - 'signaling_update_meeting_info', - 'void', - ['baseCallback *', 'str', 'str'] - ); - - this.libOpenIMSDK.signaling_close_room = this.lib.func( - '__stdcall', - 'signaling_close_room', - 'void', - ['baseCallback *', 'str', 'str'] - ); - - this.libOpenIMSDK.signaling_get_meetings = this.lib.func( - '__stdcall', - 'signaling_get_meetings', - 'void', - ['baseCallback *', 'str'] - ); - - this.libOpenIMSDK.signaling_operate_stream = this.lib.func( - '__stdcall', - 'signaling_operate_stream', - 'void', - ['baseCallback *', 'str', 'str', 'str', 'str', 'int', 'int'] - ); - this.libOpenIMSDK.signaling_send_custom_signal = this.lib.func( '__stdcall', 'signaling_send_custom_signal', @@ -1350,7 +1255,7 @@ class OpenIMSDK // implements user api getSelfUserInfo!: UserModuleApi['getSelfUserInfo']; setSelfInfo!: UserModuleApi['setSelfInfo']; - getUsersInfoWithCache!: UserModuleApi['getUsersInfoWithCache']; + getUsersInfo!: UserModuleApi['getUsersInfo']; subscribeUsersStatus!: UserModuleApi['subscribeUsersStatus']; unsubscribeUsersStatus!: UserModuleApi['unsubscribeUsersStatus']; getSubscribeUsersStatus!: UserModuleApi['getSubscribeUsersStatus']; @@ -1376,6 +1281,7 @@ class OpenIMSDK removeBlack!: FriendModuleApi['removeBlack']; searchFriends!: FriendModuleApi['searchFriends']; setFriendRemark!: FriendModuleApi['setFriendRemark']; + updateFriends!: FriendModuleApi['updateFriends']; // implements group api createGroup!: GroupModuleApi['createGroup']; @@ -1409,6 +1315,7 @@ class OpenIMSDK getAllConversationList!: ConversationModuleApi['getAllConversationList']; getConversationListSplit!: ConversationModuleApi['getConversationListSplit']; getOneConversation!: ConversationModuleApi['getOneConversation']; + setConversation!: ConversationModuleApi['setConversation']; setConversationEx!: ( params: SetConversationExParams, opid?: string | undefined @@ -1480,12 +1387,7 @@ class OpenIMSDK signalingGetRoomByGroupID!: SignalingModuleApi['signalingGetRoomByGroupID']; signalingGetTokenByRoomID!: SignalingModuleApi['signalingGetTokenByRoomID']; signalingSendCustomSignal!: SignalingModuleApi['signalingSendCustomSignal']; - signalingCreateMeeting!: SignalingModuleApi['signalingCreateMeeting']; - signalingJoinMeeting!: SignalingModuleApi['signalingJoinMeeting']; - signalingUpdateMeetingInfo!: SignalingModuleApi['signalingUpdateMeetingInfo']; - signalingCloseRoom!: SignalingModuleApi['signalingCloseRoom']; - signalingGetMeetings!: SignalingModuleApi['signalingGetMeetings']; - signalingOperateStream!: SignalingModuleApi['signalingOperateStream']; + getSignalingInvitationInfoStartApp!: SignalingModuleApi['getSignalingInvitationInfoStartApp']; } export default OpenIMSDK; diff --git a/src/core/modules/conversation.ts b/src/core/modules/conversation.ts index 9581f27..7972151 100644 --- a/src/core/modules/conversation.ts +++ b/src/core/modules/conversation.ts @@ -12,8 +12,10 @@ import { SetConversationExParams, SetConversationMsgDestructTimeParams, SetConversationMsgDestructParams, + SetConversationParams, } from '@openim/wasm-client-sdk/lib/types/params'; import { ConversationItem } from '@openim/wasm-client-sdk/lib/types/entity'; +import { GroupAtType } from '@openim/wasm-client-sdk'; export function setupConversationModule(openIMSDK: OpenIMSDK) { return { @@ -47,11 +49,13 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) { }), setConversationEx: (params: SetConversationExParams, opid = uuidV4()) => new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.set_conversation_ex( + openIMSDK.libOpenIMSDK.set_conversation( openIMSDK.baseCallbackWrap(resolve, reject), opid, params.conversationID, - params.ex + JSON.stringify({ + ex: params.ex, + }) ); }), getMultipleConversation: (conversationIDList: string, opid = uuidV4()) => @@ -101,13 +105,24 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) { params.draftText ); }), - pinConversation: (params: SetConversationPinParams, opid = uuidV4()) => + setConversation: (params: SetConversationParams, opid = uuidV4()) => new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.pin_conversation( + openIMSDK.libOpenIMSDK.set_conversation( openIMSDK.baseCallbackWrap(resolve, reject), opid, params.conversationID, - params.isPinned ? 1 : 0 + JSON.stringify(params) + ); + }), + pinConversation: (params: SetConversationPinParams, opid = uuidV4()) => + new Promise>((resolve, reject) => { + openIMSDK.libOpenIMSDK.set_conversation( + openIMSDK.baseCallbackWrap(resolve, reject), + opid, + params.conversationID, + JSON.stringify({ + isPinned: params.isPinned, + }) ); }), setConversationRecvMessageOpt: ( @@ -115,11 +130,13 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) { opid = uuidV4() ) => new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.set_conversation_recv_message_opt( + openIMSDK.libOpenIMSDK.set_conversation( openIMSDK.baseCallbackWrap(resolve, reject), opid, params.conversationID, - params.opt + JSON.stringify({ + recvMsgOpt: params.opt, + }) ); }), setConversationPrivateChat: ( @@ -127,11 +144,13 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) { opid = uuidV4() ) => new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.set_conversation_private_chat( + openIMSDK.libOpenIMSDK.set_conversation( openIMSDK.baseCallbackWrap(resolve, reject), opid, params.conversationID, - params.isPrivate ? 1 : 0 + JSON.stringify({ + isPrivateChat: params.isPrivate, + }) ); }), setConversationBurnDuration: ( @@ -139,19 +158,24 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) { opid = uuidV4() ) => new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.set_conversation_burn_duration( + openIMSDK.libOpenIMSDK.set_conversation( openIMSDK.baseCallbackWrap(resolve, reject), opid, params.conversationID, - params.burnDuration + JSON.stringify({ + burnDuration: params.burnDuration, + }) ); }), - resetConversationGroupAtType: (groupID: string, opid = uuidV4()) => + resetConversationGroupAtType: (conversationID: string, opid = uuidV4()) => new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.reset_conversation_group_at_type( + openIMSDK.libOpenIMSDK.set_conversation( openIMSDK.baseCallbackWrap(resolve, reject), opid, - groupID + conversationID, + JSON.stringify({ + groupAtType: GroupAtType.AtNormal, + }) ); }), hideConversation: (conversationID: string, opid = uuidV4()) => @@ -196,11 +220,13 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) { opid = uuidV4() ) => new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.set_conversation_msg_destruct_time( + openIMSDK.libOpenIMSDK.set_conversation( openIMSDK.baseCallbackWrap(resolve, reject), opid, params.conversationID, - params.msgDestructTime + JSON.stringify({ + msgDestructTime: params.msgDestructTime, + }) ); }), setConversationIsMsgDestruct: ( @@ -208,11 +234,11 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) { opid = uuidV4() ) => new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.set_conversation_is_msg_destruct( + openIMSDK.libOpenIMSDK.set_conversation( openIMSDK.baseCallbackWrap(resolve, reject), opid, params.conversationID, - params.isMsgDestruct ? 1 : 0 + JSON.stringify({ isMsgDestruct: params.isMsgDestruct }) ); }), }; @@ -255,6 +281,10 @@ export interface ConversationModuleApi { params: SplitConversationParams, opid?: string ) => Promise>; + setConversation: ( + params: SetConversationParams, + opid?: string + ) => Promise>; setConversationRecvMessageOpt: ( params: SetConversationRecvOptParams, opid?: string @@ -268,7 +298,7 @@ export interface ConversationModuleApi { opid?: string ) => Promise>; resetConversationGroupAtType: ( - groupID: string, + conversationID: string, opid?: string ) => Promise>; hideConversation: ( diff --git a/src/core/modules/friend.ts b/src/core/modules/friend.ts index 5189422..c3be574 100644 --- a/src/core/modules/friend.ts +++ b/src/core/modules/friend.ts @@ -6,17 +6,20 @@ import { AccessFriendApplicationParams, AddBlackParams, AddFriendParams, + GetSpecifiedFriendsParams, OffsetParams, + PinFriendParams, RemarkFriendParams, SearchFriendParams, SetFriendExParams, + UpdateFriendsParams, } from '@openim/wasm-client-sdk/lib/types/params'; import { FriendshipInfo, BlackUserItem, FriendApplicationItem, - FullUserItem, SearchedFriendsInfo, + FriendUserItem, } from '@openim/wasm-client-sdk/lib/types/entity'; export function setupFriendModule(openIMSDK: OpenIMSDK) { @@ -72,11 +75,13 @@ export function setupFriendModule(openIMSDK: OpenIMSDK) { setFriendsEx: (params: SetFriendExParams, opid = uuidV4()) => new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.set_friends_ex( + openIMSDK.libOpenIMSDK.update_friends( openIMSDK.baseCallbackWrap(resolve, reject), opid, - JSON.stringify(params), - params.ex ?? '' + JSON.stringify({ + friendUserIDs: params.toUserIDs, + ex: params.ex, + }) ); }), @@ -104,29 +109,47 @@ export function setupFriendModule(openIMSDK: OpenIMSDK) { ); }), - getFriendList: (opid = uuidV4()) => - new Promise>((resolve, reject) => { + getFriendList: (filterBlack?: boolean, opid = uuidV4()) => + new Promise>((resolve, reject) => { openIMSDK.libOpenIMSDK.get_friend_list( - openIMSDK.baseCallbackWrap(resolve, reject), - opid + openIMSDK.baseCallbackWrap(resolve, reject), + opid, + filterBlack ? 1 : 0 ); }), - getFriendListPage: (params: OffsetParams, opid = uuidV4()) => - new Promise>((resolve, reject) => { + getFriendListPage: ( + params: OffsetParams & { filterBlack?: boolean }, + opid = uuidV4() + ) => + new Promise>((resolve, reject) => { openIMSDK.libOpenIMSDK.get_friend_list_page( - openIMSDK.baseCallbackWrap(resolve, reject), + openIMSDK.baseCallbackWrap(resolve, reject), opid, params.offset, - params.count + params.count, + params.filterBlack ? 1 : 0 ); }), - getSpecifiedFriendsInfo: (userIDList: string[], opid = uuidV4()) => - new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.get_specified_friends_info( - openIMSDK.baseCallbackWrap(resolve, reject), + updateFriends: (params: UpdateFriendsParams, opid = uuidV4()) => + new Promise>((resolve, reject) => { + openIMSDK.libOpenIMSDK.update_friends( + openIMSDK.baseCallbackWrap(resolve, reject), opid, - JSON.stringify(userIDList) + JSON.stringify(params) + ); + }), + + getSpecifiedFriendsInfo: ( + params: GetSpecifiedFriendsParams, + opid = uuidV4() + ) => + new Promise>((resolve, reject) => { + openIMSDK.libOpenIMSDK.get_specified_friends_info( + openIMSDK.baseCallbackWrap(resolve, reject), + opid, + JSON.stringify(params.friendUserIDList), + params.filterBlack ? 1 : 0 ); }), @@ -162,10 +185,25 @@ export function setupFriendModule(openIMSDK: OpenIMSDK) { setFriendRemark: (params: RemarkFriendParams, opid = uuidV4()) => new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.set_friend_remark( + openIMSDK.libOpenIMSDK.update_friends( openIMSDK.baseCallbackWrap(resolve, reject), opid, - JSON.stringify(params) + JSON.stringify({ + friendUserIDs: [params.toUserID], + remark: params.remark, + }) + ); + }), + + pinFriends: (params: PinFriendParams, opid = uuidV4()) => + new Promise>((resolve, reject) => { + openIMSDK.libOpenIMSDK.update_friends( + openIMSDK.baseCallbackWrap(resolve, reject), + opid, + JSON.stringify({ + friendUserIDs: params.toUserIDs, + isPinned: params.isPinned, + }) ); }), }; @@ -194,15 +232,22 @@ export interface FriendModuleApi { getFriendApplicationListAsRecipient: ( opid?: string ) => Promise>; - getFriendList: (opid?: string) => Promise>; + getFriendList: ( + filterBlack?: boolean, + opid?: string + ) => Promise>; getFriendListPage: ( - params: OffsetParams, + params: OffsetParams & { filterBlack?: boolean }, opid?: string - ) => Promise>; + ) => Promise>; + updateFriends: ( + params: UpdateFriendsParams, + opid?: string + ) => Promise>; getSpecifiedFriendsInfo: ( - userIDList: string[], + params: GetSpecifiedFriendsParams, opid?: string - ) => Promise>; + ) => Promise>; refuseFriendApplication: ( params: AccessFriendApplicationParams, opid?: string diff --git a/src/core/modules/signaling.ts b/src/core/modules/signaling.ts index 18ba6fd..604cad5 100644 --- a/src/core/modules/signaling.ts +++ b/src/core/modules/signaling.ts @@ -2,17 +2,13 @@ import { v4 as uuidV4 } from 'uuid'; import OpenIMSDK from '..'; import { BaseResponse } from '@/types/entity'; import { - CreateMeetingParams, CustomSignalParams, - MeetingOperateStreamParams, RtcActionParams, SignalingInviteParams, - UpdateMeetingParams, } from '@openim/wasm-client-sdk/lib/types/params'; import { RtcInviteResults, CallingRoomData, - MeetingRecord, } from '@openim/wasm-client-sdk/lib/types/entity'; export function setupSignalingModule(openIMSDK: OpenIMSDK) { @@ -81,6 +77,13 @@ export function setupSignalingModule(openIMSDK: OpenIMSDK) { roomID ); }), + getSignalingInvitationInfoStartApp: (opid = uuidV4()) => + new Promise>((resolve, reject) => { + openIMSDK.libOpenIMSDK.get_signaling_invitation_info_start_app( + openIMSDK.baseCallbackWrap(resolve, reject), + opid + ); + }), signalingSendCustomSignal: (params: CustomSignalParams, opid = uuidV4()) => new Promise>((resolve, reject) => { openIMSDK.libOpenIMSDK.signaling_send_custom_signal( @@ -90,70 +93,6 @@ export function setupSignalingModule(openIMSDK: OpenIMSDK) { params.roomID ); }), - signalingCreateMeeting: (params: CreateMeetingParams, opid = uuidV4()) => - new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.signaling_create_meeting( - openIMSDK.baseCallbackWrap(resolve, reject), - opid, - JSON.stringify(params) - ); - }), - signalingJoinMeeting: (roomID: string, opid = uuidV4()) => - new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.signaling_join_meeting( - openIMSDK.baseCallbackWrap(resolve, reject), - opid, - JSON.stringify({ - roomID, - }) - ); - }), - signalingUpdateMeetingInfo: ( - params: Partial & { roomID: string }, - opid = uuidV4() - ) => - new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.signaling_update_meeting_info( - openIMSDK.baseCallbackWrap(resolve, reject), - opid, - JSON.stringify(params) - ); - }), - signalingCloseRoom: (roomID: string, opid = uuidV4()) => - new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.signaling_close_room( - openIMSDK.baseCallbackWrap(resolve, reject), - opid, - roomID - ); - }), - signalingGetMeetings: (opid = uuidV4()) => - new Promise>( - (resolve, reject) => { - openIMSDK.libOpenIMSDK.signaling_get_meetings( - openIMSDK.baseCallbackWrap<{ meetingInfoList: MeetingRecord[] }>( - resolve, - reject - ), - opid - ); - } - ), - signalingOperateStream: ( - params: MeetingOperateStreamParams, - opid = uuidV4() - ) => - new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.signaling_operate_stream( - openIMSDK.baseCallbackWrap(resolve, reject), - opid, - params.streamType, - params.roomID, - params.userID ?? '', - params.mute ? 1 : 0, - params.muteAll ? 1 : 0 - ); - }), }; } @@ -190,31 +129,11 @@ export interface SignalingModuleApi { roomID: string, opid?: string ) => Promise>; + getSignalingInvitationInfoStartApp: ( + opid?: string + ) => Promise>; signalingSendCustomSignal: ( params: CustomSignalParams, opid?: string ) => Promise>; - signalingCreateMeeting: ( - params: CreateMeetingParams, - opid?: string - ) => Promise>; - signalingJoinMeeting: ( - meetingID: string, - opid?: string - ) => Promise>; - signalingUpdateMeetingInfo: ( - params: Partial & { roomID: string }, - opid?: string - ) => Promise>; - signalingCloseRoom: ( - roomID: string, - opid?: string - ) => Promise>; - signalingGetMeetings: ( - opid?: string - ) => Promise>; - signalingOperateStream: ( - params: MeetingOperateStreamParams, - opid?: string - ) => Promise>; } diff --git a/src/core/modules/user.ts b/src/core/modules/user.ts index e9bbbc7..15cfc2a 100644 --- a/src/core/modules/user.ts +++ b/src/core/modules/user.ts @@ -4,13 +4,10 @@ import OpenIMSDK from '..'; import { MessageReceiveOptType } from '@openim/wasm-client-sdk'; import { SelfUserInfo, - FullUserItemWithCache, UserOnlineState, + PublicUserItem, } from '@openim/wasm-client-sdk/lib/types/entity'; -import { - GetUserInfoWithCacheParams, - PartialUserItem, -} from '@openim/wasm-client-sdk/lib/types/params'; +import { PartialUserItem } from '@openim/wasm-client-sdk/lib/types/params'; export function setupUserModule(openIMSDK: OpenIMSDK) { return { @@ -31,16 +28,12 @@ export function setupUserModule(openIMSDK: OpenIMSDK) { ); }), - getUsersInfoWithCache: ( - params: GetUserInfoWithCacheParams, - opid = uuidV4() - ) => - new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.get_users_info_with_cache( - openIMSDK.baseCallbackWrap(resolve, reject), + getUsersInfo: (params: string[], opid = uuidV4()) => + new Promise>((resolve, reject) => { + openIMSDK.libOpenIMSDK.get_users_info( + openIMSDK.baseCallbackWrap(resolve, reject), opid, - JSON.stringify(params.userIDList), - params.groupID ?? '' + JSON.stringify(params) ); }), @@ -75,10 +68,12 @@ export function setupUserModule(openIMSDK: OpenIMSDK) { opid = uuidV4() ) => new Promise>((resolve, reject) => { - openIMSDK.libOpenIMSDK.set_global_recv_message_opt( + openIMSDK.libOpenIMSDK.set_self_info( openIMSDK.baseCallbackWrap(resolve, reject), opid, - msgReceiveOptType + JSON.stringify({ + globalRecvMsgOpt: msgReceiveOptType, + }) ); }), }; @@ -90,10 +85,10 @@ export interface UserModuleApi { params: PartialUserItem, opid?: string ) => Promise>; - getUsersInfoWithCache: ( - params: GetUserInfoWithCacheParams, + getUsersInfo: ( + params: string[], opid?: string - ) => Promise>; + ) => Promise>; subscribeUsersStatus: ( userIDList: string[], opid?: string diff --git a/src/main.ts b/src/main.ts index 16ae098..f5e4599 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import { ipcMain, WebContents } from 'electron'; +import { ipcMain, powerMonitor, WebContents } from 'electron'; import { CbEvents } from '@openim/wasm-client-sdk'; import OpenIMSDK from './core'; @@ -10,9 +10,19 @@ class OpenIMSDKMain { if (webContent) { this.webContents = [webContent]; } + this.systemStateHandler(); this.initMethodsHandler(); } + private systemStateHandler = () => { + powerMonitor.on('suspend', () => { + this.sdk.setAppBackgroundStatus(true); + }); + powerMonitor.on('resume', () => { + this.sdk.setAppBackgroundStatus(false); + }); + }; + private initMethodsHandler = () => { ipcMain.handle('openim-sdk-ipc-methods', async (_, method, ...args) => { try { diff --git a/src/preload.ts b/src/preload.ts index f11c6e3..b5f4ba8 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -1,5 +1,11 @@ import { contextBridge, ipcRenderer } from 'electron'; +const updateOnlineStatus = () => + ipcRenderer.invoke('openim-sdk-ipc-methods', 'networkStatusChanged'); + +window.addEventListener('online', updateOnlineStatus); +window.addEventListener('offline', updateOnlineStatus); + contextBridge.exposeInMainWorld('openIMRenderApi', { subscribe: (channel: string, callback: (...args: any[]) => void) => { const subscription = (_: unknown, ...args: any[]) => callback(...args); diff --git a/src/types/libOpenIMSDK.d.ts b/src/types/libOpenIMSDK.d.ts index 7dd52f7..53087b4 100644 --- a/src/types/libOpenIMSDK.d.ts +++ b/src/types/libOpenIMSDK.d.ts @@ -158,18 +158,6 @@ declare module 'libOpenIMSDK' { operationID: string, conversationIDList: string ): void; - set_conversation_msg_destruct_time( - cCallback: CB_S_I_S_S, - operationID: string, - conversationID: string, - msgDestructTime: number - ): void; - set_conversation_is_msg_destruct( - cCallback: CB_S_I_S_S, - operationID: string, - conversationID: string, - isMsgDestruct: number - ): void; send_group_message_read_receipt( cCallback: CB_S_I_S_S, operationID: string, @@ -190,57 +178,23 @@ declare module 'libOpenIMSDK' { operationID: string, conversationID: string ): void; - get_conversation_recv_message_opt( - cCallback: CB_S_I_S_S, - operationID: string, - conversationIDList: string - ): void; set_conversation_draft( cCallback: CB_S_I_S_S, operationID: string, conversationID: string, draftText: string ): void; - reset_conversation_group_at_type( - cCallback: CB_S_I_S_S, - operationID: string, - conversationID: string - ): void; - pin_conversation( + set_conversation( cCallback: CB_S_I_S_S, operationID: string, conversationID: string, - isPinned: number - ): void; - set_conversation_private_chat( - cCallback: CB_S_I_S_S, - operationID: string, - conversationID: string, - isPrivate: number - ): void; - set_conversation_burn_duration( - cCallback: CB_S_I_S_S, - operationID: string, - conversationID: string, - duration: number - ): void; - set_conversation_recv_message_opt( - cCallback: CB_S_I_S_S, - operationID: string, - conversationID: string, - opt: number + conversationFields: string ): void; get_total_unread_msg_count( cCallback: CB_S_I_S_S, operationID: string ): void; get_at_all_tag(operationID: string): string; - set_conversation_ex( - cCallback: CB_S_I_S_S, - operationID: string, - conversationID: string, - ex: string - ): void; get_conversation_id_by_session_type( operationID: string, sourceID: string, @@ -355,13 +309,7 @@ declare module 'libOpenIMSDK' { operationID: string, userIDs: string ): void; - get_users_info_with_cache( - cCallback: CB_S_I_S_S, - operationID: string, - userIDs: string, - groupID: string - ): void; - get_users_info_from_srv( + get_users_info( cCallback: CB_S_I_S_S, operationID: string, userIDs: string @@ -371,11 +319,6 @@ declare module 'libOpenIMSDK' { operationID: string, userInfo: string ): void; - set_global_recv_message_opt( - cCallback: CB_S_I_S_S, - operationID: string, - opt: number - ): void; get_self_user_info(cCallback: CB_S_I_S_S, operationID: string): void; update_msg_sender_info( cCallback: CB_S_I_S_S, @@ -406,26 +349,26 @@ declare module 'libOpenIMSDK' { get_specified_friends_info( cCallback: CB_S_I_S_S, operationID: string, - userIDList: string + userIDList: string, + filterBlack?: number + ): void; + get_friend_list( + cCallback: CB_S_I_S_S, + operationID: string, + filterBlack?: number ): void; - get_friend_list(cCallback: CB_S_I_S_S, operationID: string): void; get_friend_list_page( cCallback: CB_S_I_S_S, operationID: string, offset: number, - count: number + count: number, + filterBlack?: number ): void; search_friends( cCallback: CB_S_I_S_S, operationID: string, searchParam: string ): void; - set_friends_ex( - cCallback: CB_S_I_S_S, - operationID: string, - toUserIDs: string, - ex: string - ): void; check_friend( cCallback: CB_S_I_S_S, operationID: string, @@ -436,10 +379,10 @@ declare module 'libOpenIMSDK' { operationID: string, userIDReqMsg: string ): void; - set_friend_remark( + update_friends( cCallback: CB_S_I_S_S, operationID: string, - userIDRemark: string + friendInfos: string ): void; delete_friend( cCallback: CB_S_I_S_S, @@ -513,13 +456,6 @@ declare module 'libOpenIMSDK' { cUserID: string, cMutedSeconds: number ): void; - set_group_member_role_level( - cCallback: CB_S_I_S_S, - operationID: string, - cGroupID: string, - cUserID: string, - cRoleLevel: number - ): void; set_group_member_info( cCallback: CB_S_I_S_S, operationID: string, @@ -703,36 +639,6 @@ declare module 'libOpenIMSDK' { cCallback: CB_S_I_S_S, operationID: string ): void; - signaling_create_meeting( - cCallback: CB_S_I_S_S, - operationID: string, - cSignalingCreateMeetingReq: string - ): void; - signaling_join_meeting( - cCallback: CB_S_I_S_S, - operationID: string, - cSignalingJoinMeetingReq: string - ): void; - signaling_update_meeting_info( - cCallback: CB_S_I_S_S, - operationID: string, - cSignalingUpdateMeetingInfoReq: string - ): void; - signaling_close_room( - cCallback: CB_S_I_S_S, - operationID: string, - cRoomID: string - ): void; - signaling_get_meetings(cCallback: CB_S_I_S_S, operationID: string): void; - signaling_operate_stream( - cCallback: CB_S_I_S_S, - operationID: string, - cStreamType: string, - cRoomID: string, - cUserID: string, - mute: number, - muteAll: number - ): void; signaling_send_custom_signal( cCallback: CB_S_I_S_S, operationID: string,