node-nim 7.8.3 → 9.1.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +70 -23
  2. package/download-sdk.mjs +59 -0
  3. package/js/api/client.js +103 -36
  4. package/js/api/client.js.map +1 -0
  5. package/js/api/data_sync.js +8 -8
  6. package/js/api/data_sync.js.map +1 -0
  7. package/js/api/friend.js +75 -12
  8. package/js/api/friend.js.map +1 -0
  9. package/js/api/global.js +66 -14
  10. package/js/api/global.js.map +1 -0
  11. package/js/api/msglog.js +398 -47
  12. package/js/api/msglog.js.map +1 -0
  13. package/js/api/nos.js +114 -24
  14. package/js/api/nos.js.map +1 -0
  15. package/js/api/online_session.js +39 -13
  16. package/js/api/online_session.js.map +1 -0
  17. package/js/api/pass_through_proxy.js +18 -5
  18. package/js/api/pass_through_proxy.js.map +1 -0
  19. package/js/api/plugin.js +40 -4
  20. package/js/api/plugin.js.map +1 -0
  21. package/js/api/session.js +192 -25
  22. package/js/api/session.js.map +1 -0
  23. package/js/api/subscribe_event.js +75 -11
  24. package/js/api/subscribe_event.js.map +1 -0
  25. package/js/api/super_team.js +332 -68
  26. package/js/api/super_team.js.map +1 -0
  27. package/js/api/sysmsg.js +94 -17
  28. package/js/api/sysmsg.js.map +1 -0
  29. package/js/api/talk.js +50 -29
  30. package/js/api/talk.js.map +1 -0
  31. package/js/api/talkex.js +72 -28
  32. package/js/api/talkex.js.map +1 -0
  33. package/js/api/team.js +423 -25
  34. package/js/api/team.js.map +1 -0
  35. package/js/api/tool.js +72 -9
  36. package/js/api/tool.js.map +1 -0
  37. package/js/api/user.js +97 -13
  38. package/js/api/user.js.map +1 -0
  39. package/js/{api/rescode_def.js → def/client_def.js} +74 -10
  40. package/js/def/client_def.js.map +1 -0
  41. package/js/{api → def}/data_sync_def.js +1 -2
  42. package/js/def/data_sync_def.js.map +1 -0
  43. package/js/{api → def}/doc_trans_def.js +1 -2
  44. package/js/def/doc_trans_def.js.map +1 -0
  45. package/js/{api → def}/friend_def.js +2 -2
  46. package/js/def/friend_def.js.map +1 -0
  47. package/js/{api → def}/global_def.js +1 -1
  48. package/js/def/global_def.js.map +1 -0
  49. package/js/{api → def}/msglog_def.js +14 -8
  50. package/js/def/msglog_def.js.map +1 -0
  51. package/js/{api → def}/nos_def.js +1 -0
  52. package/js/def/nos_def.js.map +1 -0
  53. package/js/{api → def}/online_session_def.js +1 -0
  54. package/js/def/online_session_def.js.map +1 -0
  55. package/js/{api → def}/pass_through_proxy_def.js +1 -1
  56. package/js/def/pass_through_proxy_def.js.map +1 -0
  57. package/js/{api → def}/plugin_def.js +1 -0
  58. package/js/def/plugin_def.js.map +1 -0
  59. package/js/{api/session.def.js → def/session_def.js} +1 -0
  60. package/js/def/session_def.js.map +1 -0
  61. package/js/{api → def}/subscribe_event_def.js +2 -1
  62. package/js/def/subscribe_event_def.js.map +1 -0
  63. package/js/{api → def}/super_team_def.js +9 -6
  64. package/js/def/super_team_def.js.map +1 -0
  65. package/js/{api → def}/sysmsg_def.js +11 -1
  66. package/js/def/sysmsg_def.js.map +1 -0
  67. package/js/{api → def}/talk_def.js +1 -0
  68. package/js/def/talk_def.js.map +1 -0
  69. package/js/{api → def}/talkex_def.js +1 -0
  70. package/js/def/talkex_def.js.map +1 -0
  71. package/js/{api → def}/team_def.js +3 -2
  72. package/js/def/team_def.js.map +1 -0
  73. package/js/{api → def}/tool_def.js +1 -1
  74. package/js/def/tool_def.js.map +1 -0
  75. package/js/{api → def}/user_def.js +2 -1
  76. package/js/def/user_def.js.map +1 -0
  77. package/js/loader.js +30 -0
  78. package/js/loader.js.map +1 -0
  79. package/js/nim.js +38 -44
  80. package/js/nim.js.map +1 -0
  81. package/package.json +37 -24
  82. package/types/api/client.d.ts +124 -0
  83. package/types/api/data_sync.d.ts +13 -0
  84. package/types/api/friend.d.ts +82 -0
  85. package/types/api/global.d.ts +69 -0
  86. package/types/api/msglog.d.ts +388 -0
  87. package/types/api/nos.d.ts +118 -0
  88. package/types/api/online_session.d.ts +44 -0
  89. package/types/api/pass_through_proxy.d.ts +24 -0
  90. package/types/api/plugin.d.ts +37 -0
  91. package/types/api/session.d.ts +212 -0
  92. package/types/api/subscribe_event.d.ts +87 -0
  93. package/types/api/super_team.d.ts +332 -0
  94. package/types/api/sysmsg.d.ts +104 -0
  95. package/types/api/talk.d.ts +69 -0
  96. package/types/api/talkex.d.ts +93 -0
  97. package/types/api/team.d.ts +442 -0
  98. package/types/api/tool.d.ts +75 -0
  99. package/types/api/user.d.ts +111 -0
  100. package/types/def/client_def.d.ts +276 -0
  101. package/types/def/data_sync_def.d.ts +19 -0
  102. package/types/def/doc_trans_def.d.ts +11 -0
  103. package/types/def/friend_def.d.ts +65 -0
  104. package/types/def/global_def.d.ts +69 -0
  105. package/types/def/msglog_def.d.ts +328 -0
  106. package/types/def/nos_def.d.ts +71 -0
  107. package/types/def/online_session_def.d.ts +34 -0
  108. package/types/def/pass_through_proxy_def.d.ts +12 -0
  109. package/types/def/plugin_def.d.ts +7 -0
  110. package/types/def/session_def.d.ts +113 -0
  111. package/types/def/subscribe_event_def.d.ts +82 -0
  112. package/types/def/super_team_def.d.ts +133 -0
  113. package/types/def/sysmsg_def.d.ts +84 -0
  114. package/types/def/talk_def.d.ts +48 -0
  115. package/types/def/talkex_def.d.ts +111 -0
  116. package/types/def/team_def.d.ts +153 -0
  117. package/types/def/tool_def.d.ts +27 -0
  118. package/types/def/user_def.d.ts +58 -0
  119. package/types/loader.d.ts +2 -0
  120. package/types/nim.d.ts +18 -0
  121. package/js/api/client_def.js +0 -58
  122. package/js/api/nim.js +0 -13
  123. package/js/api/rts.js +0 -68
  124. package/js/api/rts_def.js +0 -15
  125. package/js/api/signaling.js +0 -62
  126. package/js/api/signaling_def.js +0 -20
  127. package/just-task.js +0 -154
  128. package/scripts/build_addon.js +0 -56
  129. package/scripts/build_wrapper.js +0 -45
  130. package/scripts/fetch_wrapper.js +0 -45
  131. package/scripts/pack_addon.js +0 -41
package/README.md CHANGED
@@ -1,36 +1,83 @@
1
1
  # NetEase IM Node.js addon wrapper
2
+ [![codecov](https://codecov.io/gh/netease-im/node-nim/branch/master/graph/badge.svg?token=YUP8T7ZG6U)](https://codecov.io/gh/netease-im/node-nim) [![GitHub all releases](https://img.shields.io/github/downloads/netease-im/node-nim/total)](https://github.com/netease-im/node-nim/releases)
2
3
 
3
- ## Build environment
4
+ ## Table of Contents
5
+ - [Introduction](#introduction)
6
+ - [Installation](#installation)
7
+ - [Build From Source](#build-from-source)
8
+ - [Unit Test](#unit-test)
9
+ - [Sample Code](#sample-code)
10
+ - [Quick Start](#quick-start)
4
11
 
5
- - CMake 3.10 or higher
6
- - Visual Studio 2017 or MSBuild 2017
12
+ ## Introduction
13
+ node-nim is a wrapper of [NetEase IM](https://netease.im/).
14
+ node-nim will download the nim SDK which has the same version, you can override the version by add `NIM_SDK_VERSION="${version}"` or `NIM_SDK_URL="${url}"` to environment variables.
15
+ For more detailed documentation, changelog and tech support. See https://dev.yunxin.163.com/.
7
16
 
8
- ## Command line
9
-
10
- |Options|Descroption|
11
- |---|---|
12
- |fetch-wrapper|Download NIM C++ SDK source files and C binary files|
13
- |build-wrapper|Build NIM C++ SDK|
14
- |package|Package the compiled artifacts|
15
- |build|Build with specified parameters (build-wrapper+package)|
17
+ ## Installation
18
+ node-nim runs on Node.js and is available as a NPM package.
19
+ ```
20
+ npm install node-nim --save-dev
21
+ ```
16
22
 
17
- Examples:
23
+ ## Build From Source
24
+ Technically, nim sdk is shipped with a prebuilt node-nim.node binary file, so you don't need to build it yourself.
25
+ But if you want to add some personal features or you just want to do so, feel free to build it!
26
+ Build Requirements:
27
+ - Node.js
28
+ - npm
29
+ - CMake
30
+ - CMake supported generator(Unix Makefiles, Ninja, Visual Studio, Xcode...)
18
31
 
19
- Fetch C++ wrapper source files and build C++ addon for node.js.
32
+ Now you are all set to build, run following command in the root directory of the project:
33
+ ```cmake
34
+ cmake -S . -B build
35
+ cmake --build build --config Release
36
+ ```
37
+ And voilà, you now have your own node-nim binary file in the `build` directory.
20
38
 
21
- ```bash
22
- npx just fetch-wrapper --target_platform=win32 --target_arch=ia32
23
- npx just build --runtime=electron --target=13.1.2 --target_platform=win32 --target_arch=ia32
39
+ ## Unit Test
40
+ Execute following script to run unit test, [check this](./test/test_all.js), and you can also get an coverage report under 'coverage'.
41
+ ```
42
+ npm run coverage
24
43
  ```
25
44
 
26
- Just build NIM C++ wrapper, needs `npx just fetch-wrapper` before.
45
+ ## Sample Code
46
+ ```js
47
+ const NIM = require('node-nim')
48
+ const assert = require('assert')
49
+ const client = new NIM.NIMClient()
50
+ const talk = new NIM.NIMTalk()
51
+ const result = client.init('app_key', 'app_data_dir', 'app_install_dir', {
52
+ db_encrypt_key: 'abcdefghijklmnopqrstuvwxyz012345'
53
+ })
27
54
 
28
- ```bash
29
- npx just build-wrapper --target_platform=win32 --target_arch=ia32
30
- ```
55
+ client.login('app_key', 'username', 'password_in_md5', (result) => {
56
+ assert.strictEqual(result.err_code, 200)
57
+ if (loginResult.login_step === 3) { // login has 3 steps, step 3 succeeded
58
+ talk.initEventHandlers() // init callbacks
59
+
60
+ talk.on('receiveMsg', function (result) {
61
+ console.log(result)
62
+ })
31
63
 
32
- Packing a compiled artifact as `.tar.gz` in `packages` folder.
64
+ talk.sendMsg({
65
+ to_type: 0, // p2p
66
+ to_accid: 'receiver_accid',
67
+ time: new Date().getTime(),
68
+ msg_type: 0, // text message
69
+ msg_body: 'Send from NIM node quick start.',
70
+ client_msg_id: new Date().getTime().toString(), // use an uuid
71
+ }, '', function () { })
33
72
 
34
- ```bash
35
- npx just package --runtime=electron --target=13.1.2 --target_platform=win32 --target_arch=ia32
73
+ client.logout(1, (err_code) => {
74
+ assert.strictEqual(err_code, 200)
75
+ }, '')
76
+
77
+ client.cleanUp('')
78
+ }
79
+ }, '')
36
80
  ```
81
+
82
+ ## Quick Start
83
+ Check out this [quick start project](https://github.com/netease-im/node-nim-quick-start) and try out NIM's outstanding features!
@@ -0,0 +1,59 @@
1
+ import fetch from 'node-fetch';
2
+ import compareVersions from 'compare-versions';
3
+ import download from 'download';
4
+
5
+ const arch = process.arch;
6
+ const platform = process.platform;
7
+ const sdk_group = "message";
8
+ const sdk_name = "nim";
9
+ const sdk_path = "sdk";
10
+ let sdk_url = process.env.NIM_SDK_URL;
11
+ let sdk_version = process.env.npm_package_version.split('-')[0];
12
+ if (process.env.NIM_SDK_VERSION) {
13
+ sdk_version = process.env.NIM_SDK_VERSION;
14
+ }
15
+ // fetch publish list
16
+ fetch('http://publish.netease.im/api/list').then((res) => res.json()).then((publish_json) => {
17
+ // get sdk list
18
+ if (!sdk_url) {
19
+ let sdk_list = [];
20
+ let latest_version = "0.0.0";
21
+ let latest_sdk_list = [];
22
+ Object.keys(publish_json[sdk_group]).forEach((temp) => {
23
+ if (compareVersions.compare(latest_version, temp, '<')) {
24
+ latest_version = temp;
25
+ latest_sdk_list = publish_json[sdk_group][temp];
26
+ }
27
+ if (sdk_version === temp) {
28
+ sdk_list = publish_json[sdk_group][temp];
29
+ }
30
+ });
31
+ if (sdk_list.length === 0) {
32
+ console.log(`${sdk_name} sdk version ${sdk_version} not found, use latest version ${latest_version}`);
33
+ sdk_list = latest_sdk_list;
34
+ }
35
+ console.log(`[node_pre_build] downloadSDK sdk_name:${sdk_name}, platform:${platform}, arch:${arch}`)
36
+ // use platform and arch to find the sdk
37
+ sdk_list.forEach((member) => {
38
+ if (member.filename.includes(sdk_name) && member.filename.includes(platform) && member.filename.includes(arch)) {
39
+ sdk_url = member.cdnlink;
40
+ }
41
+ });
42
+ }
43
+ if (!sdk_url) {
44
+ console.error(`[node_pre_build] downloadSDK sdk_name:${sdk_name}, platform:${platform}, arch:${arch} not found`);
45
+ return;
46
+ }
47
+ console.info(`[node_pre_build] Downloading prebuilt sdk from ${sdk_url} to ${sdk_path}`);
48
+ // download sdk
49
+ download(sdk_url, sdk_path, {
50
+ extract: true,
51
+ filter: (file) => {
52
+ return !file.path.includes('._');
53
+ },
54
+ }).then(() => {
55
+ console.info(`[node_pre_build] Downloading prebuilt sdk complete`);
56
+ }).catch((err) => {
57
+ console.error(`[node_pre_build] downloadSDK error:${err}`)
58
+ });
59
+ });
package/js/api/client.js CHANGED
@@ -3,78 +3,145 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const nim_1 = __importDefault(require("./nim"));
6
+ exports.NIMClient = void 0;
7
+ const loader_1 = __importDefault(require("../loader"));
7
8
  const events_1 = __importDefault(require("events"));
8
9
  class NIMClient extends events_1.default.EventEmitter {
9
10
  constructor() {
10
11
  super();
11
- this.client = new nim_1.default.Client();
12
- }
12
+ this.client = new loader_1.default.NIMClient({ "emit": this.emit.bind(this) });
13
+ }
14
+ /** NIM SDK初始化
15
+ * @param appKey 应用注册的APP KEY
16
+ * @param appDataDir 推荐用户目录放置在系统目录{AppData\Local},默认只需要传入目录名,SDK会默认在系统目录下创建该级用户目录。如果要使用其他自定义路径,需传入绝对路径路径,并确保该目录有正确的读写权限。
17
+ * @param appInstallDir SDK动态库所在的目录全路径(如果传入为空,则按照默认规则搜索该动态库)
18
+ * @param config 初始化参数
19
+ * @return bool 返回值true: 成功, false: 失败
20
+ */
13
21
  init(appKey, appDataDir, appInstallDir, config) {
14
22
  return this.client.Init(appKey, appDataDir, appInstallDir, config);
15
23
  }
24
+ /** 注册全局回调 */
25
+ initEventHandlers() {
26
+ return this.client.InitEventHandlers();
27
+ }
28
+ /** NIM客户端登录
29
+ * @param appKey
30
+ * @param account 帐号
31
+ * @param password 密码
32
+ * @param cb 登录流程的回调函数
33
+ * @param jsonExtension json扩展参数(v5.7.0 项目增加自定义参数字段)
34
+ * @return bool 检查参数如果不符合要求则返回失败
35
+ * @note
36
+ * <pre>
37
+ * 200:成功
38
+ * 302:账号或密码错误
39
+ * 403:禁止操作
40
+ * 408:请求超时
41
+ * 414:参数错误
42
+ * 415:网络连接出现错误
43
+ * 416:频率超限
44
+ * 422:账号被禁用
45
+ * </pre>
46
+ */
16
47
  login(appKey, account, password, cb, jsonExtension) {
17
48
  return this.client.Login(appKey, account, password, cb, jsonExtension);
18
49
  }
50
+ /** NIM客户端注销/退出
51
+ * @param logoutType Logout操作类型,其定义见nim_client_def.h
52
+ * @param cb 注销/退出的回调函数
53
+ * @param jsonExtension json扩展参数(备用,目前不需要)
54
+ * @return void 无返回值
55
+ * @note
56
+ * <pre>
57
+ * 200:成功
58
+ * 500:未知错误
59
+ * </pre>
60
+ */
19
61
  logout(logoutType, cb, jsonExtension) {
20
62
  return this.client.Logout(logoutType, cb, jsonExtension);
21
63
  }
22
- cleanUp(jsonExtension) {
23
- return this.client.CleanUp(jsonExtension);
64
+ /** NIM SDK清理
65
+ * @param jsonExtension json扩展参数(备用,目前不需要)
66
+ * @return void 无返回值
67
+ */
68
+ cleanup(jsonExtension) {
69
+ return this.client.Cleanup(jsonExtension);
24
70
  }
71
+ /** 获取SDK配置
72
+ * @return SDKConfig 返回值SDKConfig的引用 const类型,不可试图修改
73
+ */
25
74
  getSDKConfig() {
26
75
  return this.client.GetSDKConfig();
27
76
  }
28
- cleanUp2(jsonExtension) {
29
- return this.client.CleanUp2(jsonExtension);
30
- }
31
- loginCustomDataToJson(customData) {
32
- return this.client.LoginCustomDataToJson(customData);
33
- }
77
+ /** 获取客户端登录状态
78
+ * @param jsonExtension json扩展参数(备用,目前不需要)
79
+ * @return NIMLoginState 登录状态
80
+ */
34
81
  getLoginState(jsonExtension) {
35
82
  return this.client.GetLoginState(jsonExtension);
36
83
  }
84
+ /** NIM客户端手动重连(注意 APP需要统一处理自动重连/手动重连的回调,因为如果处于某次自动重连的过程中调用手动重连接口,不起作用!)
85
+ * @param jsonExtension json扩展参数(备用,目前不需要)
86
+ * @return void 无返回值
87
+ */
37
88
  relogin(jsonExtension) {
38
89
  return this.client.Relogin(jsonExtension);
39
90
  }
91
+ /** 将本帐号的其他端踢下线
92
+ * @param clients 设备标识
93
+ * @return bool 检查参数如果不符合要求则返回失败, 接口调用成功后的结果通过注册RegKickOtherClientCb回调得到
94
+ */
40
95
  kickOtherClient(clients) {
41
96
  return this.client.KickOtherClient(clients);
42
97
  }
43
- regReloginCb(cb, jsonExtension) {
44
- return this.client.RegReloginCb(cb, jsonExtension);
45
- }
46
- regKickoutCb(cb, jsonExtension) {
47
- return this.client.RegKickoutCb(cb, jsonExtension);
48
- }
49
- regDisconnectCb(cb, jsonExtension) {
50
- return this.client.RegDisconnectCb(cb, jsonExtension);
51
- }
52
- regMultispotLoginCb(cb, jsonExtension) {
53
- return this.client.RegMultispotLoginCb(cb, jsonExtension);
54
- }
55
- regKickOtherClientCb(cb, jsonExtension) {
56
- return this.client.RegKickOtherClientCb(cb, jsonExtension);
57
- }
58
- regSyncMultiportPushConfigCb(cb, jsonExtension) {
59
- return this.client.RegSyncMultiportPushConfigCb(cb, jsonExtension);
60
- }
61
- setMultiportPushConfigAsync(switchOn, cb, jsonExtension) {
62
- return this.client.SetMultiportPushConfigAsync(switchOn, cb, jsonExtension);
63
- }
98
+ /** (全局回调)设置多端推送
99
+ * @param switch_on 开关
100
+ * @param cb 回调函数
101
+ * @param jsonExtension json扩展参数(备用,目前不需要)
102
+ * @return void
103
+ * @note
104
+ * <pre>
105
+ * 200:成功
106
+ * </pre>
107
+ */
108
+ setMultiportPushConfigAsync(switch_on, cb, jsonExtension) {
109
+ return this.client.SetMultiportPushConfigAsync(switch_on, cb, jsonExtension);
110
+ }
111
+ /** 获得多端推送设置
112
+ * @param cb 回调函数
113
+ * @param jsonExtension json扩展参数(备用,目前不需要)
114
+ * @return void
115
+ */
64
116
  getMultiportPushConfigAsync(cb, jsonExtension) {
65
117
  return this.client.GetMultiportPushConfigAsync(cb, jsonExtension);
66
118
  }
119
+ /** 获取SDK版本号
120
+ * @return string 版本号
121
+ */
67
122
  getSDKVersion() {
68
123
  return this.client.GetSDKVersion();
69
124
  }
125
+ /** 获取当前服务器时间
126
+ * @param cb 操作结果的回调函数
127
+ * @param calc_local 是否在本地计算,false:直接到服务端查询 ,true:根据上次查询到的服务端时间与本地系统启动时间来计算,不会到服务端查询
128
+ * @return void
129
+ * @note
130
+ * <pre>
131
+ * 由于网络上/下行的原因,返回的时间会存在一定误差,
132
+ * 当 calc_local == false 时,如果跟上次调用该方法的时间间隔小于1000ms,SDK会采用 calc_local == true
133
+ * 时的方案以减少服务端的压力,并会在回调中指明返回的时间是由本地计算的。 如果返回 code != 200,同样会返回一个本地计算结果
134
+ * </pre>
135
+ */
70
136
  getServerCurrentTime(cb, calcLocal) {
71
137
  return this.client.GetServerCurrentTime(cb, calcLocal);
72
138
  }
73
- unregClientCb() {
74
- return this.client.UnregClientCb();
75
- }
139
+ /** 获取当前登录的用户账号(accid)
140
+ * @return string 当前登录的用户账号(accid)
141
+ * @note 没有登录时将返回空字符串 */
76
142
  getCurrentUserAccount() {
77
143
  return this.client.GetCurrentUserAccount();
78
144
  }
79
145
  }
80
- exports.default = NIMClient;
146
+ exports.NIMClient = NIMClient;
147
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../ts/api/client.ts"],"names":[],"mappings":";;;;;;AAIA,uDAA4B;AAC5B,oDAAwB;AAuBxB,MAAa,SAAU,SAAQ,gBAAE,CAAC,YAAY;IAE1C;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAG,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;QAMI;IACJ,IAAI,CAAC,MAAc,EACf,UAAkB,EAClB,aAAqB,EACrB,MAAiB;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,CAAC,C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AAC,CAAC;IACjF,CAAC;IAED;;;;SAIK;IACL,2BAA2B,CAAC,EAA+B,EAAE,aAAqB;QAC9E,OAAO,IAAI,CAAC,MAAM,CAAC,2BAA2B,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;IACtE,CAAC;IAED;;SAEK;IACL,aAAa;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;IACvC,CAAC;IAED;;;;;;;;;;SAUK;IACL,oBAAoB,CAAC,EAAgC,EAAE,SAAkB;QACrE,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;IAC3D,CAAC;IAED;;8BAE0B;IAC1B,qBAAqB;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC;IAC/C,CAAC;CACJ;AAlKD,8BAkKC"}
@@ -3,18 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const nim_1 = __importDefault(require("./nim"));
6
+ exports.NIMDataSync = void 0;
7
+ const loader_1 = __importDefault(require("../loader"));
7
8
  const events_1 = __importDefault(require("events"));
8
9
  class NIMDataSync extends events_1.default.EventEmitter {
9
10
  constructor() {
10
11
  super();
11
- this.dataSync = new nim_1.default.DataSync();
12
+ this.dataSync = new loader_1.default.NIMDataSync({ "emit": this.emit.bind(this) });
12
13
  }
13
- regCompleteCb(cb) {
14
- return this.dataSync.RegCompleteCb(cb);
15
- }
16
- unregDataSyncCb() {
17
- return this.dataSync.UnregDataSyncCb();
14
+ /** 注册全局回调 */
15
+ initEventHandlers() {
16
+ return this.dataSync.InitEventHandlers();
18
17
  }
19
18
  }
20
- exports.default = NIMDataSync;
19
+ exports.NIMDataSync = NIMDataSync;
20
+ //# sourceMappingURL=data_sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data_sync.js","sourceRoot":"","sources":["../../ts/api/data_sync.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA4B;AAC5B,oDAAwB;AASxB,MAAa,WAAY,SAAQ,gBAAE,CAAC,YAAY;IAE5C;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAG,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,aAAa;IACb,iBAAiB;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;IAC7C,CAAC;CACJ;AAXD,kCAWC"}
package/js/api/friend.js CHANGED
@@ -3,36 +3,99 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const nim_1 = __importDefault(require("./nim"));
6
+ exports.NIMFriend = void 0;
7
+ const loader_1 = __importDefault(require("../loader"));
7
8
  const events_1 = __importDefault(require("events"));
8
9
  class NIMFriend extends events_1.default.EventEmitter {
9
10
  constructor() {
10
11
  super();
11
- this.friend = new nim_1.default.Friend();
12
+ this.friend = new loader_1.default.NIMFriend({ "emit": this.emit.bind(this) });
12
13
  }
13
- regChangeCb(cb, jsonExtension) {
14
- return this.friend.RegChangeCb(cb, jsonExtension);
14
+ /** 注册全局回调 */
15
+ initEventHandlers() {
16
+ return this.friend.InitEventHandlers();
15
17
  }
16
- request(accid, verifyType, msg, cb, jsonExtension) {
17
- return this.friend.Request(accid, verifyType, msg, cb, jsonExtension);
18
+ /** 添加、验证好友
19
+ * @param accid 对方帐号
20
+ * @param verify_type 好友验证类型
21
+ * @param msg 接口扩展字段
22
+ * @param cb 好友请求回调函数
23
+ * @param jsonExtension json扩展参数(备用,目前不需要)
24
+ * @return bool 检查参数如果不符合要求则返回失败
25
+ * @note
26
+ * <pre>
27
+ * 200:成功
28
+ * 404:用户不存在
29
+ * 500:未知错误
30
+ * </pre>
31
+ */
32
+ request(accid, verify_type, msg, cb, jsonExtension) {
33
+ return this.friend.Request(accid, verify_type, msg, cb, jsonExtension);
18
34
  }
19
- deleteEx(accid, option, cb) {
20
- return this.friend.DeleteEx(accid, option, cb);
35
+ /** 删除好友
36
+ * @param accid 对方帐号
37
+ * @param option 删除好友选项,目前仅有是否删除备注信息选项
38
+ * @param cb 删除好友回调函数
39
+ * @return bool 检查参数如果不符合要求则返回失败
40
+ * @note
41
+ * <pre>
42
+ * 200:成功
43
+ * 404:用户不存在
44
+ * 500:未知错误
45
+ * </pre>
46
+ */
47
+ delete(accid, option, cb) {
48
+ return this.friend.Delete(accid, option, cb);
21
49
  }
50
+ /** 更新好友资料
51
+ * @param profile 好友资料
52
+ * @param cb 更新好友资料回调函数
53
+ * @param jsonExtension json扩展参数(备用,目前不需要)
54
+ * @return bool 检查参数如果不符合要求则返回失败
55
+ * @note
56
+ * <pre>
57
+ * 200:成功
58
+ * 404:用户不存在
59
+ * 500:未知错误
60
+ * </pre>
61
+ */
22
62
  update(profile, cb, jsonExtension) {
23
63
  return this.friend.Update(profile, cb, jsonExtension);
24
64
  }
65
+ /** 增量获取好友列表
66
+ * @param cb 获取好友列表回调函数
67
+ * @param jsonExtension json扩展参数(备用,目前不需要)
68
+ * @return void 无返回值
69
+ * @note
70
+ * <pre>
71
+ * 200:成功
72
+ * </pre>
73
+ */
25
74
  getList(cb, jsonExtension) {
26
75
  return this.friend.GetList(cb, jsonExtension);
27
76
  }
77
+ /** 获取好友信息
78
+ * @param accid 对方帐号
79
+ * @param cb 获取好友信息回调函数
80
+ * @param jsonExtension json扩展参数(备用,目前不需要)
81
+ * @return void 无返回值
82
+ */
28
83
  getFriendProfile(accid, cb, jsonExtension) {
29
84
  return this.friend.GetFriendProfile(accid, cb, jsonExtension);
30
85
  }
86
+ /** 增量获取好友列表
87
+ * @param keyword 要查询的关键字
88
+ * @param cb 获取好友列表回调函数
89
+ * @param jsonExtension json扩展参数(备用,目前不需要)
90
+ * @return bool 返回 true 表示发送查询请求成功,返回 false 表示关键字为空
91
+ * @note
92
+ * <pre>
93
+ * 200:成功
94
+ * </pre>
95
+ */
31
96
  queryFriendListByKeyword(keyword, cb, jsonExtension) {
32
97
  return this.friend.QueryFriendListByKeyword(keyword, cb, jsonExtension);
33
98
  }
34
- unregFriendCb() {
35
- return this.friend.UnregFriendCb();
36
- }
37
99
  }
38
- exports.default = NIMFriend;
100
+ exports.NIMFriend = NIMFriend;
101
+ //# sourceMappingURL=friend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"friend.js","sourceRoot":"","sources":["../../ts/api/friend.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA4B;AAC5B,oDAAwB;AAYxB,MAAa,SAAU,SAAQ,gBAAE,CAAC,YAAY;IAE1C;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAG,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,aAAa;IACb,iBAAiB;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;;;;SAaK;IACL,OAAO,CAAC,KAAa,EAAE,WAA0B,EAAE,GAAW,EAAE,EAAqB,EAAE,aAAqB;QACxG,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE,EAAE,aAAa,CAAC,CAAC;IAC3E,CAAC;IAED;;;;;;;;;;;SAWK;IACL,MAAM,CAAC,KAAa,EAAE,MAA0B,EAAE,EAAqB;QACnE,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;;;;;SAWK;IACL,MAAM,CAAC,OAAsB,EAAE,EAAqB,EAAE,aAAqB;QACvE,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,aAAa,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;;;SAQK;IACL,OAAO,CAAC,EAA0B,EAAE,aAAqB;QACrD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;IAClD,CAAC;IAED;;;;;SAKK;IACL,gBAAgB,CAAC,KAAa,EAAE,EAA4B,EAAE,aAAqB;QAC/E,OAAO,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,EAAE,EAAE,aAAa,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;;;SASK;IACL,wBAAwB,CAAC,OAAe,EAAE,EAA0B,EAAE,aAAqB;QACvF,OAAO,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,OAAO,EAAE,EAAE,EAAE,aAAa,CAAC,CAAC;IAC5E,CAAC;CACJ;AAlGD,8BAkGC"}
package/js/api/global.js CHANGED
@@ -3,36 +3,88 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const nim_1 = __importDefault(require("./nim"));
6
+ exports.NIMGlobal = void 0;
7
+ const loader_1 = __importDefault(require("../loader"));
7
8
  const events_1 = __importDefault(require("events"));
8
9
  class NIMGlobal extends events_1.default.EventEmitter {
9
10
  constructor() {
10
11
  super();
11
- this.global = new nim_1.default.Global();
12
+ this.global = new loader_1.default.NIMGlobal({ "emit": this.emit.bind(this) });
12
13
  }
13
- setExceptionReportCallback(cb, jsonExtension) {
14
- return this.global.SetExceptionReportCallback(cb, jsonExtension);
14
+ /** 注册全局回调 */
15
+ initEventHandlers() {
16
+ return this.global.InitEventHandlers();
15
17
  }
18
+ /** 注册输出系统环境异常的回调
19
+ * @param jsonExtension json扩展参数(备用,目前不需要)
20
+ * @param cb
21
+ * @return void 无返回值
22
+ */
23
+ setExceptionReportCallback(jsonExtension, cb) {
24
+ return this.global.SetExceptionReportCallback(jsonExtension, cb);
25
+ }
26
+ /** 设置SDK统一的网络代理。不需要代理时,type设置为kNIMProxyNone,其余参数都传空字符串(端口设为0)。有些代理不需要用户名和密码,相应参数也传空字符串。
27
+ * @param type 代理类型,见NIMProxyType定义
28
+ * @param host 代理地址
29
+ * @param port 代理端口
30
+ * @param user 代理用户名
31
+ * @param password 代理密码
32
+ * @return void 无返回值
33
+ */
16
34
  setProxy(type, host, port, user, password) {
17
35
  return this.global.SetProxy(type, host, port, user, password);
18
36
  }
37
+ /** 测试代理
38
+ * @param type 代理类型,见NIMProxyType定义
39
+ * @param host 代理地址
40
+ * @param port 代理端口
41
+ * @param user 代理用户名
42
+ * @param password 代理密码
43
+ * @param cb 回调函数
44
+ * @return void 无返回值
45
+ */
19
46
  detectProxy(type, host, port, user, password, cb) {
20
47
  return this.global.DetectProxy(type, host, port, user, password, cb);
21
48
  }
22
- getSDKCachedFileInfoAsync(loginId, fileType, endTimestamp, cb, jsonExtension) {
23
- return this.global.GetSDKCachedFileInfoAsync(loginId, fileType, endTimestamp, cb, jsonExtension);
24
- }
25
- deleteSDKCachedFileAsync(loginId, fileType, endTimestamp, cb, jsonExtension) {
26
- return this.global.DeleteSDKCachedFileAsync(loginId, fileType, endTimestamp, cb, jsonExtension);
49
+ /** 获取sdk缓存文件信息
50
+ * @param loginId 查询的账号ID
51
+ * @param fileType 文件类型,常量定义见NIMCachedFileType
52
+ * @param endTimestamp 查询时间截止点(查询全部填0)
53
+ * @param jsonExtension json扩展参数(备用,目前不需要)
54
+ * @param cb
55
+ * @return void 无返回值
56
+ */
57
+ getSDKCachedFileInfoAsync(loginId, fileType, endTimestamp, jsonExtension, cb) {
58
+ return this.global.GetSDKCachedFileInfoAsync(loginId, fileType, endTimestamp, jsonExtension, cb);
27
59
  }
28
- sdkFeedbackAsync(url, cb, jsonExtension) {
29
- return this.global.SDKFeedbackAsync(url, cb, jsonExtension);
60
+ /** 删除sdk缓存文件
61
+ * @param loginId 查询的账号ID
62
+ * @param fileType 文件类型,常量定义见NIMCachedFileType
63
+ * @param endTimestamp 删除时间截止点(查询全部填0)
64
+ * @param jsonExtension json扩展参数(备用,目前不需要)
65
+ * @param cb
66
+ * @return void 无返回值
67
+ */
68
+ deleteSDKCachedFileAsync(loginId, fileType, endTimestamp, jsonExtension, cb) {
69
+ return this.global.DeleteSDKCachedFileAsync(loginId, fileType, endTimestamp, jsonExtension, cb);
30
70
  }
31
- regSDKDBError(cb) {
32
- return this.global.RegSDKDBError(cb);
71
+ /** SDK 反馈
72
+ * @param url 开发者需将所需要反馈的文件(dump,应用日志等)上传至nos。
73
+ * @param jsonExtension json扩展参数(备用,目前不需要)
74
+ * @param cb
75
+ * @return void 无返回值
76
+ */
77
+ sdkFeedbackAsync(url, jsonExtension, cb) {
78
+ return this.global.SDKFeedbackAsync(url, jsonExtension, cb);
33
79
  }
80
+ /** 上传SDK日志到服务器
81
+ * @param feedbackStr 反馈信息
82
+ * @param cb 操作结果的回调函数
83
+ * @return void
84
+ */
34
85
  uploadSDKLog(feedbackStr, cb) {
35
86
  return this.global.UploadSDKLog(feedbackStr, cb);
36
87
  }
37
88
  }
38
- exports.default = NIMGlobal;
89
+ exports.NIMGlobal = NIMGlobal;
90
+ //# sourceMappingURL=global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.js","sourceRoot":"","sources":["../../ts/api/global.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA4B;AAC5B,oDAAwB;AASxB,MAAa,SAAU,SAAQ,gBAAE,CAAC,YAAY;IAE1C;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAG,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,E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