Compare commits

1 Commits

Author SHA1 Message Date
blooming
2ef3ee9ef9 feat: add new input state api (#11) 2024-10-17 15:13:14 +08:00
14 changed files with 77 additions and 18 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

16
package-lock.json generated
View File

@@ -1,21 +1,21 @@
{
"name": "@openim/electron-client-sdk",
"version": "1.1.0",
"version": "1.1.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@openim/electron-client-sdk",
"version": "1.1.0",
"version": "1.1.1",
"license": "MIT",
"dependencies": {
"koffi": "^2.8.0",
"koffi": "2.8.0",
"uuid": "^9.0.0"
},
"devDependencies": {
"@commitlint/cli": "^16.2.4",
"@commitlint/config-conventional": "^16.2.4",
"@openim/wasm-client-sdk": "^3.8.2-beta.4",
"@openim/wasm-client-sdk": "^3.8.2-1",
"@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.2-beta.3",
"@openim/wasm-client-sdk": "^3.8.2-1",
"electron": ">=12.0.0"
}
},
@@ -1882,9 +1882,9 @@
}
},
"node_modules/@openim/wasm-client-sdk": {
"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==",
"version": "3.8.2-1",
"resolved": "https://registry.npmjs.org/@openim/wasm-client-sdk/-/wasm-client-sdk-3.8.2-1.tgz",
"integrity": "sha512-ntpmRJrZVzaAM7MbA1BsY1jgeGEJUlyWGH6Yqz5+yjd1qNBL4f7SysiDXYHoizOWNNWCSGzeC8iZPDMRIS0hEw==",
"dev": true,
"engines": {
"node": ">=12.0"

View File

@@ -1,6 +1,6 @@
{
"name": "@openim/electron-client-sdk",
"version": "1.1.1",
"version": "1.1.2",
"description": "open im sdk for node",
"source": "src/index.ts",
"main": "lib/index.js",
@@ -43,7 +43,7 @@
"devDependencies": {
"@commitlint/cli": "^16.2.4",
"@commitlint/config-conventional": "^16.2.4",
"@openim/wasm-client-sdk": "^3.8.2",
"@openim/wasm-client-sdk": "^3.8.2-1",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-terser": "^0.4.4",
"@types/ffi-napi": "^4.0.10",
@@ -76,11 +76,11 @@
"*.ts": "eslint --cache --cache-location .eslintcache --fix"
},
"dependencies": {
"koffi": "^2.8.0",
"koffi": "2.8.0",
"uuid": "^9.0.0"
},
"peerDependencies": {
"@openim/wasm-client-sdk": "^3.8.2",
"@openim/wasm-client-sdk": "^3.8.2-1",
"electron": ">=12.0.0"
}
}

View File

@@ -130,12 +130,13 @@ export const eventMapping: Record<NativeEvent, CbEvents> = {
[NativeEvent.RECV_MESSAGE_EXTENSIONS_CHANGED]: CbEvents.UnUsedEvent,
[NativeEvent.RECV_MESSAGE_EXTENSIONS_DELETED]: CbEvents.UnUsedEvent,
[NativeEvent.RECV_MESSAGE_EXTENSIONS_ADDED]: CbEvents.UnUsedEvent,
[NativeEvent.RECV_OFFLINE_NEW_MESSAGE]: CbEvents.UnUsedEvent,
[NativeEvent.RECV_OFFLINE_NEW_MESSAGE]: CbEvents.OnRecvOfflineNewMessage,
[NativeEvent.MSG_DELETED]: CbEvents.UnUsedEvent,
[NativeEvent.RECV_OFFLINE_NEW_MESSAGES]: CbEvents.UnUsedEvent,
[NativeEvent.RECV_OFFLINE_NEW_MESSAGES]: CbEvents.OnRecvOfflineNewMessages,
[NativeEvent.MESSAGE_KV_INFO_CHANGED]: CbEvents.UnUsedEvent,
[NativeEvent.CONVERSATION_USER_INPUT_STATUS_CHANGED]: CbEvents.UnUsedEvent,
[NativeEvent.RECV_ONLINE_ONLY_MESSAGE]: CbEvents.UnUsedEvent,
[NativeEvent.CONVERSATION_USER_INPUT_STATUS_CHANGED]:
CbEvents.OnConversationUserInputStatusChanged,
[NativeEvent.RECV_ONLINE_ONLY_MESSAGE]: CbEvents.OnRecvOnlineOnlyMessage,
[NativeEvent.RECV_NEW_INVITATION]: CbEvents.OnReceiveNewInvitation,
[NativeEvent.INVITEE_ACCEPTED]: CbEvents.OnInviteeAccepted,
[NativeEvent.INVITEE_ACCEPTED_BY_OTHER_DEVICE]:

View File

@@ -462,6 +462,18 @@ class OpenIMSDK
'void',
['baseCallback *', 'str', 'str', 'str']
);
this.libOpenIMSDK.change_input_states = this.lib.func(
'__stdcall',
'change_input_states',
'void',
['baseCallback *', 'str', 'str', 'int']
);
this.libOpenIMSDK.get_input_states = this.lib.func(
'__stdcall',
'get_input_states',
'void',
['baseCallback *', 'str', 'str', 'str']
);
this.libOpenIMSDK.hide_all_conversations = this.lib.func(
'__stdcall',
'hide_all_conversations',
@@ -1127,7 +1139,7 @@ class OpenIMSDK
unInitSDK = (opid = uuidV4()) =>
this.asyncRetunWrap(
opid,
`unInitSDK-${opid}`,
this.libOpenIMSDK.un_init_sdk(`unInitSDK-${opid}`)
);
@@ -1345,6 +1357,8 @@ class OpenIMSDK
deleteConversationAndDeleteAllMsg!: ConversationModuleApi['deleteConversationAndDeleteAllMsg'];
setConversationMsgDestructTime!: ConversationModuleApi['setConversationMsgDestructTime'];
setConversationIsMsgDestruct!: ConversationModuleApi['setConversationIsMsgDestruct'];
changeInputStates!: ConversationModuleApi['changeInputStates'];
getInputStates!: ConversationModuleApi['getInputStates'];
// implements message api
createTextMessage!: MessageModuleApi['createTextMessage'];

View File

@@ -13,9 +13,11 @@ import {
SetConversationMsgDestructTimeParams,
SetConversationMsgDestructParams,
SetConversationParams,
ChangeInputStatesParams,
GetInputstatesParams,
} 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';
import { GroupAtType, Platform } from '@openim/wasm-client-sdk';
export function setupConversationModule(openIMSDK: OpenIMSDK) {
return {
@@ -241,6 +243,24 @@ export function setupConversationModule(openIMSDK: OpenIMSDK) {
JSON.stringify({ isMsgDestruct: params.isMsgDestruct })
);
}),
changeInputStates: (params: ChangeInputStatesParams, opid = uuidV4()) =>
new Promise<BaseResponse<void>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.change_input_states(
openIMSDK.baseCallbackWrap<void>(resolve, reject),
opid,
params.conversationID,
params.focus ? 1 : 0
);
}),
getInputStates: (params: GetInputstatesParams, opid = uuidV4()) =>
new Promise<BaseResponse<Platform[]>>((resolve, reject) => {
openIMSDK.libOpenIMSDK.get_input_states(
openIMSDK.baseCallbackWrap<Platform[]>(resolve, reject),
opid,
params.conversationID,
params.userID
);
}),
};
}
@@ -322,4 +342,12 @@ export interface ConversationModuleApi {
params: SetConversationMsgDestructParams,
opid?: string
) => Promise<BaseResponse<void>>;
changeInputStates: (
params: ChangeInputStatesParams,
opid?: string
) => Promise<BaseResponse<void>>;
getInputStates: (
params: GetInputstatesParams,
opid?: string
) => Promise<BaseResponse<Platform[]>>;
}

View File

@@ -33,6 +33,10 @@ type IMSDKInterface = Omit<WasmInterface, 'login'> & {
* @access only for electron
*/
initSDK: (param: InitConfig, opid?: string) => Promise<boolean>;
/**
* @access only for electron
*/
unInitSDK: (opid?: string) => Promise<void>;
/**
* @access only for electron
*/

View File

@@ -263,6 +263,18 @@ declare module 'libOpenIMSDK' {
clientMsgID: string
): void;
hide_all_conversations(cCallback: CB_S_I_S_S, operationID: string): void;
change_input_states(
cCallback: CB_S_I_S_S,
operationID: string,
conversationID: string,
focus: number
): void;
get_input_states(
cCallback: CB_S_I_S_S,
operationID: string,
conversationID: string,
userID: string
): void;
delete_all_msg_from_local_and_svr(
cCallback: CB_S_I_S_S,
operationID: string