node-nim 9.12.1 → 9.14.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/dist/nim/talk.js +118 -2
- package/dist/nim/talk.js.map +1 -1
- package/dist/node-nim.js +57 -82
- package/dist/node-nim.js.map +1 -1
- package/dist/v2/v2_nim_instance.js +44 -0
- package/dist/v2/v2_nim_instance.js.map +1 -0
- package/dist/v2/v2_nim_login_service.js +124 -0
- package/dist/v2/v2_nim_login_service.js.map +1 -0
- package/dist/v2_def/v2_nim_callback_def.js +3 -0
- package/dist/v2_def/v2_nim_callback_def.js.map +1 -0
- package/dist/v2_def/v2_nim_enum_def.js +326 -0
- package/dist/v2_def/v2_nim_enum_def.js.map +1 -0
- package/dist/v2_def/v2_nim_struct_def.js +3 -0
- package/dist/v2_def/v2_nim_struct_def.js.map +1 -0
- package/package.json +74 -74
- package/script/download-sdk.js +78 -78
- package/script/exec-node-nim-tester.js +17 -17
- package/types/nim/talk.d.ts +20 -3
- package/types/nim_def/friend_def.d.ts +10 -11
- package/types/nim_def/talk_def.d.ts +47 -2
- package/types/nim_def/user_def.d.ts +11 -11
- package/types/node-nim.d.ts +3 -27
- package/types/v2/v2_nim_instance.d.ts +25 -0
- package/types/v2/v2_nim_login_service.d.ts +96 -0
- package/types/v2_def/v2_nim_callback_def.d.ts +20 -0
- package/types/v2_def/v2_nim_enum_def.d.ts +300 -0
- package/types/v2_def/v2_nim_struct_def.d.ts +338 -0
package/script/download-sdk.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
const fetch = require('node-fetch')
|
|
2
|
-
const fs = require('fs')
|
|
3
|
-
const compareVersions = require('compare-versions')
|
|
4
|
-
const download = require('download')
|
|
5
|
-
const arch = process.env.npm_config_arch || process.arch
|
|
6
|
-
const platform = process.env.npm_config_platform || process.platform
|
|
7
|
-
const sdk_group = 'message'
|
|
8
|
-
const sdk_name = 'nim'
|
|
9
|
-
const sdk_path = `${__dirname}/../sdk`
|
|
10
|
-
if (process.env.npm_config_ignoredownloadsdk) {
|
|
11
|
-
console.log('ignore download sdk')
|
|
12
|
-
process.exit(0)
|
|
13
|
-
}
|
|
14
|
-
let sdk_version
|
|
15
|
-
let sdk_url = process.env.npm_config_nimsdkurl
|
|
16
|
-
if (process.env.npm_package_version) {
|
|
17
|
-
sdk_version = process.env.npm_package_version.split('-')[0]
|
|
18
|
-
}
|
|
19
|
-
if (process.env.npm_config_nimsdkversion) {
|
|
20
|
-
sdk_version = process.env.npm_config_nimsdkversion
|
|
21
|
-
}
|
|
22
|
-
async function downloadSDK(custom_sdk_url) {
|
|
23
|
-
if (custom_sdk_url) {
|
|
24
|
-
sdk_url = custom_sdk_url
|
|
25
|
-
}
|
|
26
|
-
// fetch publish list
|
|
27
|
-
const res = await fetch('https://admin.netease.im/public-service/free/publish/list')
|
|
28
|
-
const publish_json = await res.json()
|
|
29
|
-
// get sdk list
|
|
30
|
-
if (!sdk_url) {
|
|
31
|
-
let latest_version = '0.0.0'
|
|
32
|
-
let latest_sdk_url = ''
|
|
33
|
-
Object.keys(publish_json.data[sdk_group]).forEach((temp) => {
|
|
34
|
-
if (compareVersions.compare(latest_version, temp, '<')) {
|
|
35
|
-
publish_json.data[sdk_group][temp].forEach((member) => {
|
|
36
|
-
if (member.filename.includes(sdk_name) && member.filename.includes(platform) && member.filename.includes(arch)) {
|
|
37
|
-
latest_version = temp
|
|
38
|
-
latest_sdk_url = member.cdnlink
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
if (sdk_version === temp) {
|
|
43
|
-
publish_json.data[sdk_group][temp].forEach((member) => {
|
|
44
|
-
if (member.filename.includes(sdk_name) && member.filename.includes(platform) && member.filename.includes(arch)) {
|
|
45
|
-
sdk_url = member.cdnlink
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
if (!sdk_url || sdk_url.length === 0) {
|
|
51
|
-
console.log(`${sdk_name} sdk version ${sdk_version} not found, use latest version ${latest_version}`)
|
|
52
|
-
sdk_url = latest_sdk_url
|
|
53
|
-
}
|
|
54
|
-
console.log(`[node-nim] downloadSDK sdk_name:${sdk_name}, platform:${platform}, arch:${arch}`)
|
|
55
|
-
}
|
|
56
|
-
if (!sdk_url) {
|
|
57
|
-
console.error(`[node-nim] downloadSDK sdk_name:${sdk_name}, platform:${platform}, arch:${arch} not found`)
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
console.info(`[node-nim] Downloading prebuilt sdk from ${sdk_url} to ${sdk_path}`)
|
|
61
|
-
// remove sdk_path
|
|
62
|
-
if (fs.existsSync(sdk_path)) {
|
|
63
|
-
fs.rmSync(sdk_path, { recursive: true, force: true })
|
|
64
|
-
}
|
|
65
|
-
// download sdk
|
|
66
|
-
try {
|
|
67
|
-
await download(sdk_url, sdk_path, {
|
|
68
|
-
extract: true,
|
|
69
|
-
filter: (file) => {
|
|
70
|
-
return !file.path.includes('._')
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
console.info(`[node-nim] Downloading prebuilt sdk complete`)
|
|
74
|
-
} catch (err) {
|
|
75
|
-
console.error(`[node-nim] downloadSDK error:${err}`)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.downloadSDK = downloadSDK
|
|
1
|
+
const fetch = require('node-fetch')
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const compareVersions = require('compare-versions')
|
|
4
|
+
const download = require('download')
|
|
5
|
+
const arch = process.env.npm_config_arch || process.arch
|
|
6
|
+
const platform = process.env.npm_config_platform || process.platform
|
|
7
|
+
const sdk_group = 'message'
|
|
8
|
+
const sdk_name = 'nim'
|
|
9
|
+
const sdk_path = `${__dirname}/../sdk`
|
|
10
|
+
if (process.env.npm_config_ignoredownloadsdk) {
|
|
11
|
+
console.log('ignore download sdk')
|
|
12
|
+
process.exit(0)
|
|
13
|
+
}
|
|
14
|
+
let sdk_version
|
|
15
|
+
let sdk_url = process.env.npm_config_nimsdkurl
|
|
16
|
+
if (process.env.npm_package_version) {
|
|
17
|
+
sdk_version = process.env.npm_package_version.split('-')[0]
|
|
18
|
+
}
|
|
19
|
+
if (process.env.npm_config_nimsdkversion) {
|
|
20
|
+
sdk_version = process.env.npm_config_nimsdkversion
|
|
21
|
+
}
|
|
22
|
+
async function downloadSDK(custom_sdk_url) {
|
|
23
|
+
if (custom_sdk_url) {
|
|
24
|
+
sdk_url = custom_sdk_url
|
|
25
|
+
}
|
|
26
|
+
// fetch publish list
|
|
27
|
+
const res = await fetch('https://admin.netease.im/public-service/free/publish/list')
|
|
28
|
+
const publish_json = await res.json()
|
|
29
|
+
// get sdk list
|
|
30
|
+
if (!sdk_url) {
|
|
31
|
+
let latest_version = '0.0.0'
|
|
32
|
+
let latest_sdk_url = ''
|
|
33
|
+
Object.keys(publish_json.data[sdk_group]).forEach((temp) => {
|
|
34
|
+
if (compareVersions.compare(latest_version, temp, '<')) {
|
|
35
|
+
publish_json.data[sdk_group][temp].forEach((member) => {
|
|
36
|
+
if (member.filename.includes(sdk_name) && member.filename.includes(platform) && member.filename.includes(arch)) {
|
|
37
|
+
latest_version = temp
|
|
38
|
+
latest_sdk_url = member.cdnlink
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
if (sdk_version === temp) {
|
|
43
|
+
publish_json.data[sdk_group][temp].forEach((member) => {
|
|
44
|
+
if (member.filename.includes(sdk_name) && member.filename.includes(platform) && member.filename.includes(arch)) {
|
|
45
|
+
sdk_url = member.cdnlink
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
if (!sdk_url || sdk_url.length === 0) {
|
|
51
|
+
console.log(`${sdk_name} sdk version ${sdk_version} not found, use latest version ${latest_version}`)
|
|
52
|
+
sdk_url = latest_sdk_url
|
|
53
|
+
}
|
|
54
|
+
console.log(`[node-nim] downloadSDK sdk_name:${sdk_name}, platform:${platform}, arch:${arch}`)
|
|
55
|
+
}
|
|
56
|
+
if (!sdk_url) {
|
|
57
|
+
console.error(`[node-nim] downloadSDK sdk_name:${sdk_name}, platform:${platform}, arch:${arch} not found`)
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
console.info(`[node-nim] Downloading prebuilt sdk from ${sdk_url} to ${sdk_path}`)
|
|
61
|
+
// remove sdk_path
|
|
62
|
+
if (fs.existsSync(sdk_path)) {
|
|
63
|
+
fs.rmSync(sdk_path, { recursive: true, force: true })
|
|
64
|
+
}
|
|
65
|
+
// download sdk
|
|
66
|
+
try {
|
|
67
|
+
await download(sdk_url, sdk_path, {
|
|
68
|
+
extract: true,
|
|
69
|
+
filter: (file) => {
|
|
70
|
+
return !file.path.includes('._')
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
console.info(`[node-nim] Downloading prebuilt sdk complete`)
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.error(`[node-nim] downloadSDK error:${err}`)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.downloadSDK = downloadSDK
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const child_process = require('child_process')
|
|
2
|
-
const fs = require('fs')
|
|
3
|
-
const testDir = 'node-nim-tester'
|
|
4
|
-
if (!fs.existsSync(testDir)) {
|
|
5
|
-
fs.mkdirSync(testDir)
|
|
6
|
-
}
|
|
7
|
-
process.chdir(testDir)
|
|
8
|
-
child_process.execSync(`npm init --force`, { stdio: 'inherit' })
|
|
9
|
-
child_process.execSync(`npm install node-nim@latest --registry=http://npm.netease.im/`, { stdio: 'inherit' })
|
|
10
|
-
const args = process.argv.slice(2).join(' ')
|
|
11
|
-
if (process.platform === 'win32') {
|
|
12
|
-
child_process.execSync(`.\\node_modules\\.bin\\node-nim-tester.cmd run ${args}`, { stdio: 'inherit' })
|
|
13
|
-
} else {
|
|
14
|
-
child_process.execSync(`./node_modules/.bin/node-nim-tester run ${args}`, { stdio: 'inherit' })
|
|
15
|
-
}
|
|
16
|
-
process.chdir('..')
|
|
17
|
-
fs.rmSync(testDir, { recursive: true, force: true })
|
|
1
|
+
const child_process = require('child_process')
|
|
2
|
+
const fs = require('fs')
|
|
3
|
+
const testDir = 'node-nim-tester'
|
|
4
|
+
if (!fs.existsSync(testDir)) {
|
|
5
|
+
fs.mkdirSync(testDir)
|
|
6
|
+
}
|
|
7
|
+
process.chdir(testDir)
|
|
8
|
+
child_process.execSync(`npm init --force`, { stdio: 'inherit' })
|
|
9
|
+
child_process.execSync(`npm install node-nim@latest --registry=http://npm.netease.im/`, { stdio: 'inherit' })
|
|
10
|
+
const args = process.argv.slice(2).join(' ')
|
|
11
|
+
if (process.platform === 'win32') {
|
|
12
|
+
child_process.execSync(`.\\node_modules\\.bin\\node-nim-tester.cmd run ${args}`, { stdio: 'inherit' })
|
|
13
|
+
} else {
|
|
14
|
+
child_process.execSync(`./node_modules/.bin/node-nim-tester run ${args}`, { stdio: 'inherit' })
|
|
15
|
+
}
|
|
16
|
+
process.chdir('..')
|
|
17
|
+
fs.rmSync(testDir, { recursive: true, force: true })
|
package/types/nim/talk.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
|
-
import { IMMessage, NIMMessageType } from '../nim_def/msglog_def';
|
|
3
|
-
import { BroadcastMessage, MessageFilterCallback, NIMTalkAPI, RecallMsgNotify, RecallMsgsCallback, SendMessageArc, TeamNotificationFilterCallback } from '../nim_def/talk_def';
|
|
2
|
+
import { IMMessage, MessageSetting, NIMMessageType } from '../nim_def/msglog_def';
|
|
3
|
+
import { BroadcastMessage, FileUpPrgCallback, IMAudio, IMFile, IMImage, IMLocation, IMVideo, MessageFilterCallback, NIMTalkAPI, RecallMsgNotify, RecallMsgsCallback, SendMessageArc, TeamNotificationFilterCallback } from '../nim_def/talk_def';
|
|
4
4
|
import { NIMResCode } from '../nim_def/client_def';
|
|
5
|
+
import { NIMSessionType } from 'ts/node-nim';
|
|
5
6
|
export declare interface NIMTalkEvents {
|
|
6
7
|
/** 发送消息回调 */
|
|
7
8
|
sendMsg: [SendMessageArc];
|
|
@@ -27,7 +28,7 @@ export declare class NIMTalk extends EventEmitter<NIMTalkEvents> {
|
|
|
27
28
|
* @param pcb 上传进度的回调函数, 如果发送的消息里包含了文件资源,则通过此回调函数通知上传进度
|
|
28
29
|
* @return void 无返回值
|
|
29
30
|
*/
|
|
30
|
-
sendMsg(msg: IMMessage, jsonExtension: string): void;
|
|
31
|
+
sendMsg(msg: IMMessage, jsonExtension: string, progressCb: FileUpPrgCallback): void;
|
|
31
32
|
/** 停止正在发送中的消息(目前只支持发送文件消息时的终止)
|
|
32
33
|
* @param client_msg_id 停止发送的消息客户端id
|
|
33
34
|
* @param type 停止发送的消息类型
|
|
@@ -50,6 +51,22 @@ export declare class NIMTalk extends EventEmitter<NIMTalkEvents> {
|
|
|
50
51
|
* </pre>
|
|
51
52
|
*/
|
|
52
53
|
recallMsg(msg: IMMessage, notify_msg: string, cb: RecallMsgsCallback | null, apnstext: string, pushpayloadconst: string, jsonExtension: string): Promise<[NIMResCode, Array<RecallMsgNotify>]>;
|
|
54
|
+
/** 创建文本消息 */
|
|
55
|
+
createTextMessage(receiver_id: string, session_type: NIMSessionType, client_msg_id: string, content: string, msg_setting: MessageSetting, timetag: number, sub_type: number): IMMessage;
|
|
56
|
+
/** 创建文件消息 */
|
|
57
|
+
createFileMessage(receiver_id: string, session_type: NIMSessionType, client_msg_id: string, file: IMFile, file_path: string, msg_setting: MessageSetting, timetag: number, sub_type: number): IMMessage;
|
|
58
|
+
/** 创建图片消息 */
|
|
59
|
+
createImageMessage(receiver_id: string, session_type: NIMSessionType, client_msg_id: string, image: IMImage, file_path: string, msg_setting: MessageSetting, timetag: number, sub_type: number): IMMessage;
|
|
60
|
+
/** 创建语音消息 */
|
|
61
|
+
createAudioMessage(receiver_id: string, session_type: NIMSessionType, client_msg_id: string, audio: IMAudio, file_path: string, msg_setting: MessageSetting, timetag: number, sub_type: number): IMMessage;
|
|
62
|
+
/** 创建视频消息 */
|
|
63
|
+
createVideoMessage(receiver_id: string, session_type: NIMSessionType, client_msg_id: string, video: IMVideo, file_path: string, msg_setting: MessageSetting, timetag: number, sub_type: number): IMMessage;
|
|
64
|
+
/** 创建位置消息 */
|
|
65
|
+
createLocationMessage(receiver_id: string, session_type: NIMSessionType, client_msg_id: string, location: IMLocation, msg_setting: MessageSetting, timetag: number, sub_type: number): IMMessage;
|
|
66
|
+
/** 创建提醒消息 */
|
|
67
|
+
createTipMessage(receiver_id: string, session_type: NIMSessionType, client_msg_id: string, tip: string, msg_setting: MessageSetting, timetag: number, sub_type: number): IMMessage;
|
|
68
|
+
/** 创建转发消息 */
|
|
69
|
+
createRetweetMessage(sourceMessage: IMMessage, client_msg_id: string, session_type: NIMSessionType, receiver_id: string, msg_setting: MessageSetting, timetag: number): IMMessage;
|
|
53
70
|
/** 从消息体中获取附件(图片、语音、视频等)的本地路径
|
|
54
71
|
* @param msg 消息
|
|
55
72
|
* @return string 消息如果有附件,不管是否已下载,返回附件的本地路径;消息如果没有附件,返回空字符串。
|
|
@@ -34,17 +34,16 @@ export interface DeleteFriendOption {
|
|
|
34
34
|
}
|
|
35
35
|
/** @brief 云信好友 */
|
|
36
36
|
export interface FriendProfile {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
update_timetag_?: number; /** < 好友更新时间戳(毫秒) */
|
|
37
|
+
accid?: string; /** < 用户账号 */
|
|
38
|
+
flag?: NIMFriendFlag; /** < 主动的好友关系 */
|
|
39
|
+
beflag?: NIMFriendFlag; /** < 被动的好友关系 */
|
|
40
|
+
source?: NIMFriendSource; /** < 好友来源 */
|
|
41
|
+
alias?: string; /** < 好友别名 */
|
|
42
|
+
bits?: number; /** < 扩展数据 */
|
|
43
|
+
ex?: string; /** < 扩展数据 */
|
|
44
|
+
server_ex?: string; /** < 扩展数据 */
|
|
45
|
+
create_timetag?: number; /** < 好友创建时间戳(毫秒) */
|
|
46
|
+
update_timetag?: number; /** < 好友更新时间戳(毫秒) */
|
|
48
47
|
}
|
|
49
48
|
/** @brief 云信好友变更事件 */
|
|
50
49
|
export interface FriendChangeEvent {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NIMResCode } from './client_def';
|
|
2
|
-
import { IMMessage, NIMMessageFeature, NIMMessageType } from './msglog_def';
|
|
2
|
+
import { IMMessage, NIMMessageFeature, NIMMessageType, MessageSetting } from './msglog_def';
|
|
3
3
|
import { NIMSessionType } from './session_def';
|
|
4
4
|
export interface SendMessageArc {
|
|
5
5
|
talk_id_?: string; /**< 会话ID */
|
|
@@ -31,6 +31,50 @@ export interface RecallMsgNotify {
|
|
|
31
31
|
attach_?: string; /**< v8.2.0 透传的附件信息 */
|
|
32
32
|
callback_ext_?: string; /**< v8.2.0 第三方回调返回的字定义字段 */
|
|
33
33
|
}
|
|
34
|
+
export interface IMFile {
|
|
35
|
+
md5_?: string;
|
|
36
|
+
size_?: number;
|
|
37
|
+
url_?: string;
|
|
38
|
+
display_name_?: string;
|
|
39
|
+
file_extension_?: string;
|
|
40
|
+
msg_attachment_tag_?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface IMImage {
|
|
43
|
+
md5?: string;
|
|
44
|
+
size?: number;
|
|
45
|
+
url_?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
ext?: string;
|
|
48
|
+
upload_tag?: string;
|
|
49
|
+
w?: number;
|
|
50
|
+
h?: number;
|
|
51
|
+
}
|
|
52
|
+
export interface IMAudio {
|
|
53
|
+
md5?: string;
|
|
54
|
+
size?: number;
|
|
55
|
+
url_?: string;
|
|
56
|
+
name?: string;
|
|
57
|
+
ext?: string;
|
|
58
|
+
upload_tag?: string;
|
|
59
|
+
dur?: number;
|
|
60
|
+
}
|
|
61
|
+
export interface IMVideo {
|
|
62
|
+
md5?: string;
|
|
63
|
+
size?: number;
|
|
64
|
+
url_?: string;
|
|
65
|
+
name?: string;
|
|
66
|
+
ext?: string;
|
|
67
|
+
upload_tag?: string;
|
|
68
|
+
w?: number;
|
|
69
|
+
h?: number;
|
|
70
|
+
dur?: number;
|
|
71
|
+
}
|
|
72
|
+
export interface IMLocation {
|
|
73
|
+
title?: string;
|
|
74
|
+
lat?: number;
|
|
75
|
+
lng?: number;
|
|
76
|
+
}
|
|
77
|
+
export type FileUpPrgCallback = (uplaodedSize: number, totalSize: number) => void;
|
|
34
78
|
export type SendMsgAckCallback = (result: SendMessageArc) => void;
|
|
35
79
|
export type ReceiveMsgCallback = (result: IMMessage) => void;
|
|
36
80
|
export type ReceiveMsgsCallback = (result: Array<IMMessage>) => void;
|
|
@@ -41,11 +85,12 @@ export type TeamNotificationFilterCallback = (result: IMMessage) => boolean;
|
|
|
41
85
|
export type MessageFilterCallback = (result: IMMessage) => boolean;
|
|
42
86
|
export interface NIMTalkAPI {
|
|
43
87
|
InitEventHandlers(): void;
|
|
44
|
-
SendMsg(msg: IMMessage, jsonExtension: string): void;
|
|
88
|
+
SendMsg(msg: IMMessage, jsonExtension: string, progressCb: FileUpPrgCallback): void;
|
|
45
89
|
StopSendMsg(clientMsgId: string, type: NIMMessageType, jsonExtension: string): void;
|
|
46
90
|
RecallMsg(msg: IMMessage, notify_msg: string, cb: RecallMsgsCallback | null, apnstext: string, pushpayloadconst: string, jsonExtension: string): void;
|
|
47
91
|
GetAttachmentPathFromMsg(msg: IMMessage): string;
|
|
48
92
|
ReplyMessage(msg: IMMessage, json_reply_msg: string): void;
|
|
49
93
|
RegMessageFilter(cb: MessageFilterCallback | null, jsonExtension: string): void;
|
|
50
94
|
RegTeamNotificationFilter(cb: TeamNotificationFilterCallback | null, jsonExtension: string): void;
|
|
95
|
+
CreateTextMessage(receiver_id: string, session_type: NIMSessionType, client_msg_id: string, content: string, msg_setting: MessageSetting, timetag: number, sub_type: number): string;
|
|
51
96
|
}
|
|
@@ -23,17 +23,17 @@ export interface BlackMuteListInfo {
|
|
|
23
23
|
update_timetag_?: number; /**< 档案更新时间(毫秒) */
|
|
24
24
|
}
|
|
25
25
|
export interface UserNameCard {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
accid?: string; /**< 用户ID */
|
|
27
|
+
name?: string; /**< 用户昵称 */
|
|
28
|
+
icon?: string; /**< 用户头像下载地址 */
|
|
29
|
+
sign?: string; /**< 用户签名 */
|
|
30
|
+
gender?: number; /**< 用户性别 */
|
|
31
|
+
email?: string; /**< 用户邮箱 */
|
|
32
|
+
birth?: string; /**< 用户生日 */
|
|
33
|
+
mobile?: string; /**< 用户电话 */
|
|
34
|
+
ex?: string; /**< 用户扩展数据 */
|
|
35
|
+
create_timetag?: number; /**< 用户档案创建时间戳(毫秒) */
|
|
36
|
+
update_timetag?: number; /**< 用户档案更新时间戳(毫秒) */
|
|
37
37
|
}
|
|
38
38
|
export interface SpecialRelationshipChangeEvent {
|
|
39
39
|
type_?: NIMUserSpecialRelationshipChangeType; /**< 黑名单/静音名单更新事件类型 */
|
package/types/node-nim.d.ts
CHANGED
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
export { NIMClient } from './nim/client';
|
|
2
|
-
export { NIMDataSync } from './nim/data_sync';
|
|
3
|
-
export { NIMFriend } from './nim/friend';
|
|
4
|
-
export { NIMGlobal } from './nim/global';
|
|
5
|
-
export { NIMMsgLog } from './nim/msglog';
|
|
6
|
-
export { NIMNOS } from './nim/nos';
|
|
7
|
-
export { NIMOnlineSession } from './nim/online_session';
|
|
8
|
-
export { NIMPassThroughProxy } from './nim/pass_through_proxy';
|
|
9
|
-
export { NIMSession } from './nim/session';
|
|
10
|
-
export { NIMSubscribeEvent } from './nim/subscribe_event';
|
|
11
|
-
export { NIMSuperTeam } from './nim/super_team';
|
|
12
|
-
export { NIMSysMsg } from './nim/sysmsg';
|
|
13
|
-
export { NIMTalk } from './nim/talk';
|
|
14
|
-
export { NIMTeam } from './nim/team';
|
|
15
|
-
export { NIMTool } from './nim/tool';
|
|
16
|
-
export { NIMUser } from './nim/user';
|
|
17
|
-
export { NIMPlugin } from './nim/plugin';
|
|
18
|
-
export { NIMTalkEx } from './nim/talkex';
|
|
19
|
-
export { ChatRoomModule } from './chatroom/chatroom';
|
|
20
|
-
export { QChatInstanceModule } from './qchat/instance';
|
|
21
|
-
export { QChatServerModule } from './qchat/server';
|
|
22
|
-
export { QChatChannelModule } from './qchat/channel';
|
|
23
|
-
export { QChatChannelCategoryModule } from './qchat/channel_category';
|
|
24
|
-
export { QChatMessageModule } from './qchat/message';
|
|
25
|
-
export { QChatSystemNotificationModule } from './qchat/system_notification';
|
|
26
|
-
export { QChatAttachmentModule } from './qchat/attachment';
|
|
27
|
-
export { QChatRoleModule } from './qchat/role';
|
|
28
1
|
import { NIMClient } from './nim/client';
|
|
29
2
|
import { NIMDataSync } from './nim/data_sync';
|
|
30
3
|
import { NIMFriend } from './nim/friend';
|
|
@@ -52,6 +25,8 @@ import { QChatMessageModule } from './qchat/message';
|
|
|
52
25
|
import { QChatSystemNotificationModule } from './qchat/system_notification';
|
|
53
26
|
import { QChatAttachmentModule } from './qchat/attachment';
|
|
54
27
|
import { QChatRoleModule } from './qchat/role';
|
|
28
|
+
import { V2NIMInstance } from './v2/v2_nim_instance';
|
|
29
|
+
export { NIMClient, NIMDataSync, NIMFriend, NIMGlobal, NIMMsgLog, NIMNOS, NIMOnlineSession, NIMPassThroughProxy, NIMSession, NIMSubscribeEvent, NIMSuperTeam, NIMSysMsg, NIMTalk, NIMTeam, NIMTool, NIMUser, NIMPlugin, NIMTalkEx, ChatRoomModule, QChatInstanceModule, QChatServerModule, QChatChannelModule, QChatChannelCategoryModule, QChatMessageModule, QChatSystemNotificationModule, QChatAttachmentModule, QChatRoleModule };
|
|
55
30
|
export * from './nim_def/client_def';
|
|
56
31
|
export * from './nim_def/data_sync_def';
|
|
57
32
|
export * from './nim_def/friend_def';
|
|
@@ -115,3 +90,4 @@ export declare class QChat {
|
|
|
115
90
|
export declare const nim: NIM;
|
|
116
91
|
export declare const chatroom: ChatRoom;
|
|
117
92
|
export declare const qchat: QChat;
|
|
93
|
+
export declare const v2: V2NIMInstance;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { V2NIMInitOption, V2NIMError } from 'ts/v2_def/v2_nim_struct_def';
|
|
2
|
+
import { EventEmitter } from 'eventemitter3';
|
|
3
|
+
import { V2NIMLoginService } from './v2_nim_login_service';
|
|
4
|
+
export declare interface V2NIMInstanceEvents {
|
|
5
|
+
}
|
|
6
|
+
export declare class V2NIMInstance extends EventEmitter<V2NIMInstanceEvents> {
|
|
7
|
+
instance: any;
|
|
8
|
+
loginService: V2NIMLoginService | null;
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* 初始化
|
|
12
|
+
* @param option - 初始化选项
|
|
13
|
+
* @returns V2NIMError | null
|
|
14
|
+
* @example
|
|
15
|
+
*/
|
|
16
|
+
init(option: V2NIMInitOption): V2NIMError | null;
|
|
17
|
+
/** @brief 反初始化
|
|
18
|
+
* @return V2NIMError | null
|
|
19
|
+
*/
|
|
20
|
+
uninit(): V2NIMError | null;
|
|
21
|
+
/** @brief 获取登录服务
|
|
22
|
+
* @return V2NIMLoginService
|
|
23
|
+
*/
|
|
24
|
+
getLoginService(): V2NIMLoginService | null;
|
|
25
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { V2NIMDataSyncDetail, V2NIMError, V2NIMKickedOfflineDetail, V2NIMLoginClient, V2NIMLoginOption } from 'ts/v2_def/v2_nim_struct_def';
|
|
2
|
+
import { EventEmitter } from 'eventemitter3';
|
|
3
|
+
import { V2NIMReconnectDelayProvider } from 'ts/v2_def/v2_nim_callback_def';
|
|
4
|
+
export declare interface V2NIMLoginServiceEvents {
|
|
5
|
+
/** 登录状态变更回调 */
|
|
6
|
+
onLoginStatus: [V2NIMLoginStatus];
|
|
7
|
+
/** 登录失败回调 */
|
|
8
|
+
onLoginFailed: [V2NIMError];
|
|
9
|
+
/** 被踢下线回调 */
|
|
10
|
+
onKickedOffline: [V2NIMKickedOfflineDetail];
|
|
11
|
+
/** 登录客户端变更回调 */
|
|
12
|
+
onLoginClientChanged: [V2NIMLoginClientChange, V2NIMLoginClient[]];
|
|
13
|
+
}
|
|
14
|
+
export declare class V2NIMLoginService extends EventEmitter<V2NIMLoginServiceEvents> {
|
|
15
|
+
instance: any;
|
|
16
|
+
loginDetail: V2NIMLoginDetail;
|
|
17
|
+
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* 登录接口
|
|
20
|
+
* @param account 账号
|
|
21
|
+
* @param token 密码
|
|
22
|
+
* @param option 登录选项
|
|
23
|
+
* @returns Promise<void>
|
|
24
|
+
*/
|
|
25
|
+
login(account: string, token: string, option: V2NIMLoginOption): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* 登出接口
|
|
28
|
+
* @returns Promise<void>
|
|
29
|
+
*/
|
|
30
|
+
logout(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* 获取当前登录用户
|
|
33
|
+
* @returns string 当前登录用户
|
|
34
|
+
*/
|
|
35
|
+
getLoginUser(): string;
|
|
36
|
+
/**
|
|
37
|
+
* 获取登录状态
|
|
38
|
+
* @returns V2NIMLoginStatus 登录状态
|
|
39
|
+
*/
|
|
40
|
+
getLoginStatus(): V2NIMLoginStatus;
|
|
41
|
+
/**
|
|
42
|
+
* 获取登录客户端列表
|
|
43
|
+
* @returns V2NIMLoginClient[] 登录客户端列表
|
|
44
|
+
*/
|
|
45
|
+
getLoginClients(): V2NIMLoginClient[];
|
|
46
|
+
/**
|
|
47
|
+
* 踢掉登录客户端下线
|
|
48
|
+
* @param client 登录客户端
|
|
49
|
+
* @returns Promise<void>
|
|
50
|
+
*/
|
|
51
|
+
kickOffline(client: V2NIMLoginClient): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* 获取被踢下线原因
|
|
54
|
+
* @returns V2NIMKickedOfflineDetail 被踢下线原因
|
|
55
|
+
*/
|
|
56
|
+
getKickedOfflineDetail(): V2NIMKickedOfflineDetail;
|
|
57
|
+
/**
|
|
58
|
+
* 获取登录详情信息
|
|
59
|
+
* @returns V2NIMLoginDetail 登录详情信息
|
|
60
|
+
*/
|
|
61
|
+
getLoginDetail(): V2NIMLoginDetail;
|
|
62
|
+
}
|
|
63
|
+
export declare interface V2NIMLoginDetailEvents {
|
|
64
|
+
/** 连接状态变更回调 */
|
|
65
|
+
onConnectStatus: [V2NIMConnectStatus];
|
|
66
|
+
/** 连接断开回调 */
|
|
67
|
+
onDisconnected: [V2NIMError | null];
|
|
68
|
+
/** 连接成功回调 */
|
|
69
|
+
onConnectSuccess: [];
|
|
70
|
+
/** 连接失败回调 */
|
|
71
|
+
onConnectFailed: [V2NIMError];
|
|
72
|
+
/** 连接中回调 */
|
|
73
|
+
onConnecting: [];
|
|
74
|
+
/** 数据同步回调 */
|
|
75
|
+
onDataSync: [V2NIMDataSyncType, V2NIMDataSyncState, V2NIMError | null];
|
|
76
|
+
}
|
|
77
|
+
export declare class V2NIMLoginDetail extends EventEmitter<V2NIMLoginDetailEvents> {
|
|
78
|
+
instance: any;
|
|
79
|
+
constructor();
|
|
80
|
+
/**
|
|
81
|
+
* 获取连接状态
|
|
82
|
+
* @returns V2NIMConnectStatus 连接状态
|
|
83
|
+
*/
|
|
84
|
+
getConnectStatus(): V2NIMConnectStatus;
|
|
85
|
+
/**
|
|
86
|
+
* 获取数据同步状态
|
|
87
|
+
* @returns V2NIMDataSyncDetail[] 数据同步状态列表
|
|
88
|
+
*/
|
|
89
|
+
getDataSync(): V2NIMDataSyncDetail[];
|
|
90
|
+
/**
|
|
91
|
+
* 设置获取重连延时回调
|
|
92
|
+
* @param provider 获取重连延时回调
|
|
93
|
+
* @returns void
|
|
94
|
+
*/
|
|
95
|
+
setReconnectDelayProvider(provider: V2NIMReconnectDelayProvider): void;
|
|
96
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { V2NIMError, V2NIMMessage, V2NIMSendMessageResult } from './v2_nim_struct_def';
|
|
2
|
+
/** @brief 通用成功回调 */
|
|
3
|
+
export type V2NIMSuccessCallback = () => void;
|
|
4
|
+
/** @brief 通用失败回调 */
|
|
5
|
+
/** @param error 错误信息 */
|
|
6
|
+
export type V2NIMFailureCallback = (error: V2NIMError) => void;
|
|
7
|
+
/** @brief 通用进度回调 */
|
|
8
|
+
/** @param progress 进度, 0-100 */
|
|
9
|
+
export type V2NIMProgressCallback = (progress: number) => void;
|
|
10
|
+
/** @brief 消息发送成功回调 */
|
|
11
|
+
/** @param message 消息 */
|
|
12
|
+
/** @param result 消息发送结果 */
|
|
13
|
+
export type V2NIMSendMessageSuccessCallback = (message: V2NIMMessage, result: V2NIMSendMessageResult) => void;
|
|
14
|
+
/** @brief 消息数组成功回调 */
|
|
15
|
+
/** @param messages 消息数组 */
|
|
16
|
+
export type V2NIMMessageListSuccessCallback = (messages: Array<V2NIMMessage>) => void;
|
|
17
|
+
/** @brief 获取重连延时回调 */
|
|
18
|
+
/** @param defaultDelay 默认延时, 单位毫秒 */
|
|
19
|
+
/** @return number 延时, 单位毫秒 */
|
|
20
|
+
export type V2NIMReconnectDelayProvider = (defaultDelay: number) => number;
|