node-nim 9.9.2 → 9.10.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.
- package/README.md +126 -126
- package/dist/nim_def/msglog_def.js.map +1 -1
- package/node-nim-tester.js +40 -40
- package/package.json +73 -73
- package/script/download-sdk.js +78 -78
- package/script/exec-node-nim-tester.js +17 -17
- package/script/publish-to-netease-npm.js +28 -28
- package/types/nim/msglog.d.ts +1 -1
- package/types/nim/sysmsg.d.ts +2 -2
- package/types/nim_def/msglog_def.d.ts +8 -7
- package/types/nim_def/session_def.d.ts +1 -1
- package/types/nim_def/sysmsg_def.d.ts +3 -3
- package/types/nim_def/talk_def.d.ts +2 -2
- package/types/nim_def/talkex_def.d.ts +5 -5
- package/types/qchat_def/channel_def.d.ts +57 -57
- package/types/qchat_def/message_def.d.ts +36 -36
- package/types/qchat_def/public_def.d.ts +24 -24
- package/types/qchat_def/role_def.d.ts +63 -63
- package/types/qchat_def/server_def.d.ts +45 -45
- package/types/qchat_def/system_notification_def.d.ts +7 -7
package/README.md
CHANGED
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
# NetEase IM Node.js addon wrapper
|
|
2
|
-
|
|
3
|
-
[](https://codecov.io/gh/netease-im/node-nim) [](https://github.com/netease-im/node-nim/releases)
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [NetEase IM Node.js addon wrapper](#netease-im-nodejs-addon-wrapper)
|
|
8
|
-
- [Table of Contents](#table-of-contents)
|
|
9
|
-
- [Introduction](#introduction)
|
|
10
|
-
- [Installation](#installation)
|
|
11
|
-
- [Build From Source](#build-from-source)
|
|
12
|
-
- [Unit Test](#unit-test)
|
|
13
|
-
- [Sample Code](#sample-code)
|
|
14
|
-
- [Quick Start](#quick-start)
|
|
15
|
-
|
|
16
|
-
## Introduction
|
|
17
|
-
|
|
18
|
-
node-nim is a wrapper of [NetEase IM](https://netease.im/).
|
|
19
|
-
For more detailed documentation, changelog and tech support. See https://dev.yunxin.163.com/.
|
|
20
|
-
|
|
21
|
-
## Installation
|
|
22
|
-
|
|
23
|
-
node-nim runs on Node.js and is available as a NPM package. You can specify architecture and platform by `--arch` and `--platform` flags.
|
|
24
|
-
|
|
25
|
-
node-nim will download the nim SDK which has the same version, you can override the version by add `--nimSdkVersion` or `--nimSdkUrl` flag.
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
npm install node-nim --save-dev --arch=x64 --platform=win32 --nimSdkVersion=9.1.0
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Build From Source
|
|
32
|
-
|
|
33
|
-
Technically, nim sdk is shipped with a prebuilt node-nim.node binary file, so you don't need to build it yourself.
|
|
34
|
-
But if you want to add some personal features or you just want to do so, feel free to build it!
|
|
35
|
-
Build Requirements:
|
|
36
|
-
|
|
37
|
-
- Node.js
|
|
38
|
-
- npm
|
|
39
|
-
- CMake
|
|
40
|
-
- CMake supported generator(Unix Makefiles, Ninja, Visual Studio, Xcode...)
|
|
41
|
-
|
|
42
|
-
Now you are all set to build, run following commands in the root directory of the project:
|
|
43
|
-
|
|
44
|
-
```cmake
|
|
45
|
-
cmake -S . -B build
|
|
46
|
-
cmake --build build --config Release
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
And voilà, you now have your own node-nim binary file in the `build` directory.
|
|
50
|
-
|
|
51
|
-
## Unit Test
|
|
52
|
-
|
|
53
|
-
Execute following script to run unit test, [check this](./test/test_all.js), and you can also get an coverage report under 'coverage'.
|
|
54
|
-
|
|
55
|
-
```
|
|
56
|
-
npm run coverage
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Sample Code
|
|
60
|
-
|
|
61
|
-
```js
|
|
62
|
-
// Chatroom
|
|
63
|
-
import * as node_nim from 'node-nim'
|
|
64
|
-
let ret = node_nim.chatroom.init('', '')
|
|
65
|
-
if (!ret) {
|
|
66
|
-
console.log('init failed')
|
|
67
|
-
process.exit(1)
|
|
68
|
-
}
|
|
69
|
-
node_nim.chatroom.initEventHandlers()
|
|
70
|
-
ret = node_nim.chatroom.enter('room_id', 'login_data', {}, '')
|
|
71
|
-
if (!ret) {
|
|
72
|
-
console.log('enter failed')
|
|
73
|
-
process.exit(1)
|
|
74
|
-
}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
```js
|
|
78
|
-
// NIM
|
|
79
|
-
import * as node_nim from 'node-nim'
|
|
80
|
-
const result = node_nim.nim.client.init('app_key', 'app_data_dir', 'app_install_dir', {
|
|
81
|
-
db_encrypt_key: 'abcdefghijklmnopqrstuvwxyz012345'
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
if (!result) {
|
|
85
|
-
console.log('init failed')
|
|
86
|
-
process.exit(1)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
node_nim.nim.initEventHandlers()
|
|
90
|
-
|
|
91
|
-
let resp = await node_nim.nim.client.login(
|
|
92
|
-
'app_key',
|
|
93
|
-
'username',
|
|
94
|
-
'password',
|
|
95
|
-
null, // pass your callback function if you dont use the return Promise
|
|
96
|
-
''
|
|
97
|
-
)
|
|
98
|
-
if (resp[0].res_code_ != node_nim.NIMResCode.kNIMResSuccess) {
|
|
99
|
-
console.log('login failed')
|
|
100
|
-
process.exit(1)
|
|
101
|
-
}
|
|
102
|
-
console.log('loginResult', res)
|
|
103
|
-
// login has 3 steps, step 3 succeeded
|
|
104
|
-
node_nim.nim.talk.on('receiveMsg', function (result) {
|
|
105
|
-
console.log('receiveMsg', result)
|
|
106
|
-
})
|
|
107
|
-
node_nim.nim.talk.on('sendMsg', (msg) => {
|
|
108
|
-
console.log('sendMsg', msg)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
node_nim.nim.talk.sendMsg(
|
|
112
|
-
{
|
|
113
|
-
session_type_: 0, // p2p
|
|
114
|
-
receiver_accid_: 'receiver_accid',
|
|
115
|
-
timetag_: new Date().getTime(),
|
|
116
|
-
type_: 0, // text message
|
|
117
|
-
content_: 'Send from NIM node quick start.',
|
|
118
|
-
client_msg_id_: new Date().getTime().toString() // use an uuid
|
|
119
|
-
},
|
|
120
|
-
''
|
|
121
|
-
)
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## Quick Start
|
|
125
|
-
|
|
126
|
-
Check out this [quick start project](https://github.com/netease-im/node-nim-quick-start) and try out NIM's outstanding features!
|
|
1
|
+
# NetEase IM Node.js addon wrapper
|
|
2
|
+
|
|
3
|
+
[](https://codecov.io/gh/netease-im/node-nim) [](https://github.com/netease-im/node-nim/releases)
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [NetEase IM Node.js addon wrapper](#netease-im-nodejs-addon-wrapper)
|
|
8
|
+
- [Table of Contents](#table-of-contents)
|
|
9
|
+
- [Introduction](#introduction)
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Build From Source](#build-from-source)
|
|
12
|
+
- [Unit Test](#unit-test)
|
|
13
|
+
- [Sample Code](#sample-code)
|
|
14
|
+
- [Quick Start](#quick-start)
|
|
15
|
+
|
|
16
|
+
## Introduction
|
|
17
|
+
|
|
18
|
+
node-nim is a wrapper of [NetEase IM](https://netease.im/).
|
|
19
|
+
For more detailed documentation, changelog and tech support. See https://dev.yunxin.163.com/.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
node-nim runs on Node.js and is available as a NPM package. You can specify architecture and platform by `--arch` and `--platform` flags.
|
|
24
|
+
|
|
25
|
+
node-nim will download the nim SDK which has the same version, you can override the version by add `--nimSdkVersion` or `--nimSdkUrl` flag.
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
npm install node-nim --save-dev --arch=x64 --platform=win32 --nimSdkVersion=9.1.0
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Build From Source
|
|
32
|
+
|
|
33
|
+
Technically, nim sdk is shipped with a prebuilt node-nim.node binary file, so you don't need to build it yourself.
|
|
34
|
+
But if you want to add some personal features or you just want to do so, feel free to build it!
|
|
35
|
+
Build Requirements:
|
|
36
|
+
|
|
37
|
+
- Node.js
|
|
38
|
+
- npm
|
|
39
|
+
- CMake
|
|
40
|
+
- CMake supported generator(Unix Makefiles, Ninja, Visual Studio, Xcode...)
|
|
41
|
+
|
|
42
|
+
Now you are all set to build, run following commands in the root directory of the project:
|
|
43
|
+
|
|
44
|
+
```cmake
|
|
45
|
+
cmake -S . -B build
|
|
46
|
+
cmake --build build --config Release
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
And voilà, you now have your own node-nim binary file in the `build` directory.
|
|
50
|
+
|
|
51
|
+
## Unit Test
|
|
52
|
+
|
|
53
|
+
Execute following script to run unit test, [check this](./test/test_all.js), and you can also get an coverage report under 'coverage'.
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
npm run coverage
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Sample Code
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
// Chatroom
|
|
63
|
+
import * as node_nim from 'node-nim'
|
|
64
|
+
let ret = node_nim.chatroom.init('', '')
|
|
65
|
+
if (!ret) {
|
|
66
|
+
console.log('init failed')
|
|
67
|
+
process.exit(1)
|
|
68
|
+
}
|
|
69
|
+
node_nim.chatroom.initEventHandlers()
|
|
70
|
+
ret = node_nim.chatroom.enter('room_id', 'login_data', {}, '')
|
|
71
|
+
if (!ret) {
|
|
72
|
+
console.log('enter failed')
|
|
73
|
+
process.exit(1)
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
// NIM
|
|
79
|
+
import * as node_nim from 'node-nim'
|
|
80
|
+
const result = node_nim.nim.client.init('app_key', 'app_data_dir', 'app_install_dir', {
|
|
81
|
+
db_encrypt_key: 'abcdefghijklmnopqrstuvwxyz012345'
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
if (!result) {
|
|
85
|
+
console.log('init failed')
|
|
86
|
+
process.exit(1)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
node_nim.nim.initEventHandlers()
|
|
90
|
+
|
|
91
|
+
let resp = await node_nim.nim.client.login(
|
|
92
|
+
'app_key',
|
|
93
|
+
'username',
|
|
94
|
+
'password',
|
|
95
|
+
null, // pass your callback function if you dont use the return Promise
|
|
96
|
+
''
|
|
97
|
+
)
|
|
98
|
+
if (resp[0].res_code_ != node_nim.NIMResCode.kNIMResSuccess) {
|
|
99
|
+
console.log('login failed')
|
|
100
|
+
process.exit(1)
|
|
101
|
+
}
|
|
102
|
+
console.log('loginResult', res)
|
|
103
|
+
// login has 3 steps, step 3 succeeded
|
|
104
|
+
node_nim.nim.talk.on('receiveMsg', function (result) {
|
|
105
|
+
console.log('receiveMsg', result)
|
|
106
|
+
})
|
|
107
|
+
node_nim.nim.talk.on('sendMsg', (msg) => {
|
|
108
|
+
console.log('sendMsg', msg)
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
node_nim.nim.talk.sendMsg(
|
|
112
|
+
{
|
|
113
|
+
session_type_: 0, // p2p
|
|
114
|
+
receiver_accid_: 'receiver_accid',
|
|
115
|
+
timetag_: new Date().getTime(),
|
|
116
|
+
type_: 0, // text message
|
|
117
|
+
content_: 'Send from NIM node quick start.',
|
|
118
|
+
client_msg_id_: new Date().getTime().toString() // use an uuid
|
|
119
|
+
},
|
|
120
|
+
''
|
|
121
|
+
)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Quick Start
|
|
125
|
+
|
|
126
|
+
Check out this [quick start project](https://github.com/netease-im/node-nim-quick-start) and try out NIM's outstanding features!
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msglog_def.js","sourceRoot":"","sources":["../../ts/nim_def/msglog_def.ts"],"names":[],"mappings":";;;AAEA,mCAAmC;AACnC,IAAY,iBA+DX;AA/DD,WAAY,iBAAiB;IACzB,yGAAgC,CAAA,CAAC;qEACgC;IACjE,qGAA8B,CAAA,CAAC;qEACkC;IACjE,uGAA+B,CAAA,CAA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c;IAC/C,6GAAiC,CAAA,CAAC,YAAY;IAC9C,uHAAsC,CAAA,CAAC,cAAc;IACrD,6GAAiC,CAAA,CAAC,6CAA6C;AACnF,CAAC,EAVW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAU9B;AAED,8CAA8C;AAC9C,IAAY,wBAGX;AAHD,WAAY,wBAAwB;IAChC,+EAAY,CAAA,CAAC,mBAAmB;IAChC,iFAAa,CAAA,CAAC,mBAAmB;AACrC,CAAC,EAHW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAGnC;AAED,0CAA0C;AAC1C,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC5B,2GAA8B,CAAA,CAAC,YAAY;IAC3C,6GAA+B,CAAA,CAAC,YAAY;AAChD,CAAC,EAHW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAG/B;AAED,IAAY,UAIX;AAJD,WAAY,UAAU;IAClB,0DAAgB,CAAA,CAAC,YAAY;IAC7B,mDAAY,CAAA,CAAC,aAAa;IAC1B,iDAAW,CAAA,CAAC,YAAY;AAC5B,CAAC,EAJW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAIrB;AAmHD,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC7B,iHAAgC,CAAA;IAChC,mHAAiC,CAAA;IACjC,6HAAsC,CAAA;AAC1C,CAAC,EAJW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAIhC"}
|
package/node-nim-tester.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { Command } = require('commander')
|
|
4
|
-
const WebAT = require('hawk-web')
|
|
5
|
-
const program = new Command()
|
|
6
|
-
const downloadSDK = require('./script/download-sdk.js').downloadSDK
|
|
7
|
-
program
|
|
8
|
-
.command('run')
|
|
9
|
-
.description('run node-nim tester')
|
|
10
|
-
.requiredOption('--deviceId <deviceId>', 'tester device id')
|
|
11
|
-
.option('--taskId <taskId>', 'hawk test suite task id')
|
|
12
|
-
.option('--url <url>', 'hawk websocket url')
|
|
13
|
-
.option('--version <version>', 'test sdk version')
|
|
14
|
-
.option('--nimSdkUrl <nimSdkUrl>', 'nim native sdk download url')
|
|
15
|
-
.allowUnknownOption(true)
|
|
16
|
-
.action(async (options) => {
|
|
17
|
-
console.log('run node-nim tester, options:', options)
|
|
18
|
-
if (options.nimSdkUrl) {
|
|
19
|
-
await downloadSDK(options.nimSdkUrl)
|
|
20
|
-
}
|
|
21
|
-
const NIM = require('./dist/node-nim')
|
|
22
|
-
new WebAT({
|
|
23
|
-
applicationName: 'nim',
|
|
24
|
-
platform: 'Windows&MacOS',
|
|
25
|
-
version: options.version,
|
|
26
|
-
url: options.url,
|
|
27
|
-
deviceId: options.deviceId,
|
|
28
|
-
taskId: options.taskId,
|
|
29
|
-
targets: {
|
|
30
|
-
NIM
|
|
31
|
-
},
|
|
32
|
-
oncompleted: () => {
|
|
33
|
-
// 执行完成后退出进程
|
|
34
|
-
process.exit(0)
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
// parse
|
|
40
|
-
program.parse()
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { Command } = require('commander')
|
|
4
|
+
const WebAT = require('hawk-web')
|
|
5
|
+
const program = new Command()
|
|
6
|
+
const downloadSDK = require('./script/download-sdk.js').downloadSDK
|
|
7
|
+
program
|
|
8
|
+
.command('run')
|
|
9
|
+
.description('run node-nim tester')
|
|
10
|
+
.requiredOption('--deviceId <deviceId>', 'tester device id')
|
|
11
|
+
.option('--taskId <taskId>', 'hawk test suite task id')
|
|
12
|
+
.option('--url <url>', 'hawk websocket url')
|
|
13
|
+
.option('--version <version>', 'test sdk version')
|
|
14
|
+
.option('--nimSdkUrl <nimSdkUrl>', 'nim native sdk download url')
|
|
15
|
+
.allowUnknownOption(true)
|
|
16
|
+
.action(async (options) => {
|
|
17
|
+
console.log('run node-nim tester, options:', options)
|
|
18
|
+
if (options.nimSdkUrl) {
|
|
19
|
+
await downloadSDK(options.nimSdkUrl)
|
|
20
|
+
}
|
|
21
|
+
const NIM = require('./dist/node-nim')
|
|
22
|
+
new WebAT({
|
|
23
|
+
applicationName: 'nim',
|
|
24
|
+
platform: 'Windows&MacOS',
|
|
25
|
+
version: options.version,
|
|
26
|
+
url: options.url,
|
|
27
|
+
deviceId: options.deviceId,
|
|
28
|
+
taskId: options.taskId,
|
|
29
|
+
targets: {
|
|
30
|
+
NIM
|
|
31
|
+
},
|
|
32
|
+
oncompleted: () => {
|
|
33
|
+
// 执行完成后退出进程
|
|
34
|
+
process.exit(0)
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
// parse
|
|
40
|
+
program.parse()
|
package/package.json
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "node-nim",
|
|
3
|
-
"version": "9.
|
|
4
|
-
"description": "NetEase IM nodejs wrapper based on NetEase IM C++ SDK",
|
|
5
|
-
"main": "dist/node-nim.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"node-nim-tester": "node-nim-tester.js"
|
|
8
|
-
},
|
|
9
|
-
"types": "types/node-nim.d.ts",
|
|
10
|
-
"author": "Netease",
|
|
11
|
-
"license": "ISC",
|
|
12
|
-
"homepage": "https://github.com/netease-im/node-nim",
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "git://github.com/netease-im/node-nim.git"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"coverage": "nyc mocha test/test_all.js -slow 200 -timeout 10000",
|
|
19
|
-
"build_ts": "rimraf ./dist && rimraf ./types && tsc",
|
|
20
|
-
"build_doc": "typedoc",
|
|
21
|
-
"prepublishOnly": "npm run build_ts",
|
|
22
|
-
"install": "npm run download_sdk",
|
|
23
|
-
"download_sdk": "node -e \"require('./script/download-sdk.js').downloadSDK()\"",
|
|
24
|
-
"publish_to_netease_npm": "node script/publish-to-netease-npm.js"
|
|
25
|
-
},
|
|
26
|
-
"nyc": {
|
|
27
|
-
"cache": false,
|
|
28
|
-
"reporter": [
|
|
29
|
-
"lcov"
|
|
30
|
-
]
|
|
31
|
-
},
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"compare-versions": "^4.1.3",
|
|
34
|
-
"download": "^8.0.0",
|
|
35
|
-
"eventemitter3": "^4.0.7",
|
|
36
|
-
"node-fetch": "^2.6.5"
|
|
37
|
-
},
|
|
38
|
-
"optionalDependencies": {
|
|
39
|
-
"commander": "^8.3.0",
|
|
40
|
-
"hawk-web": "^1.3.2"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
43
|
-
"@types/node": "^16.10.5",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
45
|
-
"@typescript-eslint/parser": "^5.17.0",
|
|
46
|
-
"bluebird": "^3.7.2",
|
|
47
|
-
"cmake-js": "^6.3.0",
|
|
48
|
-
"eslint": "^7.32.0",
|
|
49
|
-
"git-describe": "^4.1.0",
|
|
50
|
-
"mocha": "^9.1.1",
|
|
51
|
-
"node-addon-api": "^4.3.0",
|
|
52
|
-
"nyc": "^15.1.0",
|
|
53
|
-
"typedoc": "^0.23.6",
|
|
54
|
-
"typedoc-github-wiki-theme": "^1.0.1",
|
|
55
|
-
"typedoc-plugin-markdown": "^3.13.3",
|
|
56
|
-
"typescript": "^4.3.5"
|
|
57
|
-
},
|
|
58
|
-
"keywords": [
|
|
59
|
-
"netease",
|
|
60
|
-
"nim",
|
|
61
|
-
"im sdk",
|
|
62
|
-
"nim sdk",
|
|
63
|
-
"nim node",
|
|
64
|
-
"nim electron"
|
|
65
|
-
],
|
|
66
|
-
"files": [
|
|
67
|
-
"dist/",
|
|
68
|
-
"types/",
|
|
69
|
-
"package.json",
|
|
70
|
-
"script/",
|
|
71
|
-
"node-nim-tester.js"
|
|
72
|
-
]
|
|
73
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "node-nim",
|
|
3
|
+
"version": "9.10.0",
|
|
4
|
+
"description": "NetEase IM nodejs wrapper based on NetEase IM C++ SDK",
|
|
5
|
+
"main": "dist/node-nim.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"node-nim-tester": "node-nim-tester.js"
|
|
8
|
+
},
|
|
9
|
+
"types": "types/node-nim.d.ts",
|
|
10
|
+
"author": "Netease",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"homepage": "https://github.com/netease-im/node-nim",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git://github.com/netease-im/node-nim.git"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"coverage": "nyc mocha test/test_all.js -slow 200 -timeout 10000",
|
|
19
|
+
"build_ts": "rimraf ./dist && rimraf ./types && tsc",
|
|
20
|
+
"build_doc": "typedoc",
|
|
21
|
+
"prepublishOnly": "npm run build_ts",
|
|
22
|
+
"install": "npm run download_sdk",
|
|
23
|
+
"download_sdk": "node -e \"require('./script/download-sdk.js').downloadSDK()\"",
|
|
24
|
+
"publish_to_netease_npm": "node script/publish-to-netease-npm.js"
|
|
25
|
+
},
|
|
26
|
+
"nyc": {
|
|
27
|
+
"cache": false,
|
|
28
|
+
"reporter": [
|
|
29
|
+
"lcov"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"compare-versions": "^4.1.3",
|
|
34
|
+
"download": "^8.0.0",
|
|
35
|
+
"eventemitter3": "^4.0.7",
|
|
36
|
+
"node-fetch": "^2.6.5"
|
|
37
|
+
},
|
|
38
|
+
"optionalDependencies": {
|
|
39
|
+
"commander": "^8.3.0",
|
|
40
|
+
"hawk-web": "^1.3.2"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^16.10.5",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
45
|
+
"@typescript-eslint/parser": "^5.17.0",
|
|
46
|
+
"bluebird": "^3.7.2",
|
|
47
|
+
"cmake-js": "^6.3.0",
|
|
48
|
+
"eslint": "^7.32.0",
|
|
49
|
+
"git-describe": "^4.1.0",
|
|
50
|
+
"mocha": "^9.1.1",
|
|
51
|
+
"node-addon-api": "^4.3.0",
|
|
52
|
+
"nyc": "^15.1.0",
|
|
53
|
+
"typedoc": "^0.23.6",
|
|
54
|
+
"typedoc-github-wiki-theme": "^1.0.1",
|
|
55
|
+
"typedoc-plugin-markdown": "^3.13.3",
|
|
56
|
+
"typescript": "^4.3.5"
|
|
57
|
+
},
|
|
58
|
+
"keywords": [
|
|
59
|
+
"netease",
|
|
60
|
+
"nim",
|
|
61
|
+
"im sdk",
|
|
62
|
+
"nim sdk",
|
|
63
|
+
"nim node",
|
|
64
|
+
"nim electron"
|
|
65
|
+
],
|
|
66
|
+
"files": [
|
|
67
|
+
"dist/",
|
|
68
|
+
"types/",
|
|
69
|
+
"package.json",
|
|
70
|
+
"script/",
|
|
71
|
+
"node-nim-tester.js"
|
|
72
|
+
]
|
|
73
|
+
}
|
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
|