node-nim 7.8.3 → 9.1.0-rc.1
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 +83 -36
- package/download-sdk.mjs +59 -0
- package/js/api/client.js +147 -80
- package/js/api/client.js.map +1 -0
- package/js/api/data_sync.js +20 -20
- package/js/api/data_sync.js.map +1 -0
- package/js/api/friend.js +101 -38
- package/js/api/friend.js.map +1 -0
- package/js/api/global.js +90 -38
- package/js/api/global.js.map +1 -0
- package/js/api/msglog.js +455 -104
- package/js/api/msglog.js.map +1 -0
- package/js/api/nos.js +140 -50
- package/js/api/nos.js.map +1 -0
- package/js/api/online_session.js +58 -32
- package/js/api/online_session.js.map +1 -0
- package/js/api/pass_through_proxy.js +33 -20
- package/js/api/pass_through_proxy.js.map +1 -0
- package/js/api/plugin.js +52 -16
- package/js/api/plugin.js.map +1 -0
- package/js/api/session.js +250 -83
- package/js/api/session.js.map +1 -0
- package/js/api/subscribe_event.js +102 -38
- package/js/api/subscribe_event.js.map +1 -0
- package/js/api/super_team.js +387 -123
- package/js/api/super_team.js.map +1 -0
- package/js/api/sysmsg.js +127 -50
- package/js/api/sysmsg.js.map +1 -0
- package/js/api/talk.js +71 -50
- package/js/api/talk.js.map +1 -0
- package/js/api/talkex.js +115 -71
- package/js/api/talkex.js.map +1 -0
- package/js/api/team.js +514 -116
- package/js/api/team.js.map +1 -0
- package/js/api/tool.js +104 -41
- package/js/api/tool.js.map +1 -0
- package/js/api/user.js +134 -50
- package/js/api/user.js.map +1 -0
- package/js/{api/rescode_def.js → def/client_def.js} +157 -93
- package/js/def/client_def.js.map +1 -0
- package/js/{api → def}/data_sync_def.js +21 -22
- package/js/def/data_sync_def.js.map +1 -0
- package/js/{api → def}/doc_trans_def.js +17 -18
- package/js/def/doc_trans_def.js.map +1 -0
- package/js/{api → def}/friend_def.js +38 -38
- package/js/def/friend_def.js.map +1 -0
- package/js/{api → def}/global_def.js +49 -49
- package/js/def/global_def.js.map +1 -0
- package/js/{api → def}/msglog_def.js +131 -125
- package/js/def/msglog_def.js.map +1 -0
- package/js/{api → def}/nos_def.js +17 -16
- package/js/def/nos_def.js.map +1 -0
- package/js/{api → def}/online_session_def.js +3 -2
- package/js/def/online_session_def.js.map +1 -0
- package/js/{api → def}/pass_through_proxy_def.js +11 -11
- package/js/def/pass_through_proxy_def.js.map +1 -0
- package/js/{api → def}/plugin_def.js +3 -2
- package/js/def/plugin_def.js.map +1 -0
- package/js/{api/session.def.js → def/session_def.js} +27 -26
- package/js/def/session_def.js.map +1 -0
- package/js/{api → def}/subscribe_event_def.js +53 -52
- package/js/def/subscribe_event_def.js.map +1 -0
- package/js/{api → def}/super_team_def.js +65 -62
- package/js/def/super_team_def.js.map +1 -0
- package/js/{api → def}/sysmsg_def.js +37 -27
- package/js/def/sysmsg_def.js.map +1 -0
- package/js/{api → def}/talk_def.js +3 -2
- package/js/def/talk_def.js.map +1 -0
- package/js/{api → def}/talkex_def.js +3 -2
- package/js/def/talkex_def.js.map +1 -0
- package/js/{api → def}/team_def.js +70 -69
- package/js/def/team_def.js.map +1 -0
- package/js/{api → def}/tool_def.js +12 -12
- package/js/def/tool_def.js.map +1 -0
- package/js/{api → def}/user_def.js +23 -22
- package/js/def/user_def.js.map +1 -0
- package/js/loader.js +30 -0
- package/js/loader.js.map +1 -0
- package/js/nim.js +40 -46
- package/js/nim.js.map +1 -0
- package/package.json +61 -48
- package/types/api/client.d.ts +124 -0
- package/types/api/data_sync.d.ts +13 -0
- package/types/api/friend.d.ts +82 -0
- package/types/api/global.d.ts +69 -0
- package/types/api/msglog.d.ts +388 -0
- package/types/api/nos.d.ts +118 -0
- package/types/api/online_session.d.ts +44 -0
- package/types/api/pass_through_proxy.d.ts +24 -0
- package/types/api/plugin.d.ts +37 -0
- package/types/api/session.d.ts +212 -0
- package/types/api/subscribe_event.d.ts +87 -0
- package/types/api/super_team.d.ts +332 -0
- package/types/api/sysmsg.d.ts +104 -0
- package/types/api/talk.d.ts +69 -0
- package/types/api/talkex.d.ts +93 -0
- package/types/api/team.d.ts +442 -0
- package/types/api/tool.d.ts +75 -0
- package/types/api/user.d.ts +111 -0
- package/types/def/client_def.d.ts +276 -0
- package/types/def/data_sync_def.d.ts +19 -0
- package/types/def/doc_trans_def.d.ts +11 -0
- package/types/def/friend_def.d.ts +65 -0
- package/types/def/global_def.d.ts +69 -0
- package/types/def/msglog_def.d.ts +328 -0
- package/types/def/nos_def.d.ts +71 -0
- package/types/def/online_session_def.d.ts +34 -0
- package/types/def/pass_through_proxy_def.d.ts +12 -0
- package/types/def/plugin_def.d.ts +7 -0
- package/types/def/session_def.d.ts +113 -0
- package/types/def/subscribe_event_def.d.ts +82 -0
- package/types/def/super_team_def.d.ts +133 -0
- package/types/def/sysmsg_def.d.ts +84 -0
- package/types/def/talk_def.d.ts +48 -0
- package/types/def/talkex_def.d.ts +111 -0
- package/types/def/team_def.d.ts +153 -0
- package/types/def/tool_def.d.ts +27 -0
- package/types/def/user_def.d.ts +58 -0
- package/types/loader.d.ts +2 -0
- package/types/nim.d.ts +18 -0
- package/js/api/client_def.js +0 -58
- package/js/api/nim.js +0 -13
- package/js/api/rts.js +0 -68
- package/js/api/rts_def.js +0 -15
- package/js/api/signaling.js +0 -62
- package/js/api/signaling_def.js +0 -20
- package/just-task.js +0 -154
- package/scripts/build_addon.js +0 -56
- package/scripts/build_wrapper.js +0 -45
- package/scripts/fetch_wrapper.js +0 -45
- package/scripts/pack_addon.js +0 -41
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** @enum NIMUserSpecialRelationshipChangeType 用户特殊关系数据变更类型 */
|
|
2
|
+
export declare enum NIMUserSpecialRelationshipChangeType {
|
|
3
|
+
kNIMUserSpecialRelationshipChangeTypeMarkBlack = 1,
|
|
4
|
+
kNIMUserSpecialRelationshipChangeTypeMarkMute = 2,
|
|
5
|
+
kNIMUserSpecialRelationshipChangeTypeSyncMuteAndBlackList = 3
|
|
6
|
+
}
|
|
7
|
+
/** @enum NIMUserQueryType 查询用户信息条件选项 */
|
|
8
|
+
export declare enum NIMUserQueryType {
|
|
9
|
+
kNIMUserQueryDefault = 0,
|
|
10
|
+
kNIMUserQueryByAccId = 1,
|
|
11
|
+
kNIMUserQueryByNickname = 2 /** < 仅匹配用户昵称 */
|
|
12
|
+
}
|
|
13
|
+
export declare enum NINPushType {
|
|
14
|
+
kNIMPushTypeDefault = 0,
|
|
15
|
+
kNIMPushTypePushKit = 1
|
|
16
|
+
}
|
|
17
|
+
export interface BlackMuteListInfo {
|
|
18
|
+
accid_: string; /**< 用户ID */
|
|
19
|
+
set_black_: boolean; /**< 是否黑名单 */
|
|
20
|
+
set_mute_: boolean; /**< 是否被静音 */
|
|
21
|
+
create_timetag_: number; /**< 档案创建时间(毫秒) */
|
|
22
|
+
update_timetag_: number; /**< 档案更新时间(毫秒) */
|
|
23
|
+
}
|
|
24
|
+
export interface UserNameCard {
|
|
25
|
+
accid_: string; /**< 用户ID */
|
|
26
|
+
nickname_: string; /**< 用户昵称 */
|
|
27
|
+
icon_url_: string; /**< 用户头像下载地址 */
|
|
28
|
+
signature_: string; /**< 用户签名 */
|
|
29
|
+
gender_: number; /**< 用户性别 */
|
|
30
|
+
email_: string; /**< 用户邮箱 */
|
|
31
|
+
birth_: string; /**< 用户生日 */
|
|
32
|
+
mobile_: string; /**< 用户电话 */
|
|
33
|
+
expand_: string; /**< 用户扩展数据 */
|
|
34
|
+
create_timetag_: number; /**< 用户档案创建时间戳(毫秒) */
|
|
35
|
+
update_timetag_: number; /**< 用户档案更新时间戳(毫秒) */
|
|
36
|
+
}
|
|
37
|
+
export interface SpecialRelationshipChangeEvent {
|
|
38
|
+
type_: NIMUserSpecialRelationshipChangeType; /**< 黑名单/静音名单更新事件类型 */
|
|
39
|
+
content_: string; /**< 黑名单/静音名单更新事件内容,根据事件类型调用ParseXXXChange接口(nim_cpp_user.h)解析该内容 */
|
|
40
|
+
}
|
|
41
|
+
export declare type SpecialRelationshipChangedCallback = (result: SpecialRelationshipChangeEvent) => void;
|
|
42
|
+
export declare type UserNameCardChangedCallback = (result: Array<UserNameCard>) => void;
|
|
43
|
+
export declare type SetRelationCallback = (rescode: number, accid: string, setOpt: boolean) => void;
|
|
44
|
+
export declare type GetSpecialListCallback = (rescode: number, result: Array<BlackMuteListInfo>) => void;
|
|
45
|
+
export declare type GetUserNameCardCallback = (result: Array<UserNameCard>) => void;
|
|
46
|
+
export declare type UpdateMyUserNameCardCallback = (rescode: number) => void;
|
|
47
|
+
export interface NIMUserAPI {
|
|
48
|
+
InitEventHandlers(): void;
|
|
49
|
+
SetBlack(accid: string, setBlack: boolean, cb: SetRelationCallback, jsonExtension: string): boolean;
|
|
50
|
+
SetMute(accid: string, set_mute: boolean, cb: SetRelationCallback, jsonExtension: string): boolean;
|
|
51
|
+
GetMutelist(cb: GetSpecialListCallback, jsonExtension: string): void;
|
|
52
|
+
GetBlacklist(cb: GetSpecialListCallback, jsonExtension: string): void;
|
|
53
|
+
GetUserNameCard(accids: Array<string>, cb: GetUserNameCardCallback, jsonExtension: string): boolean;
|
|
54
|
+
GetUserNameCardOnline(accids: Array<string>, cb: GetUserNameCardCallback, jsonExtension: string): boolean;
|
|
55
|
+
UpdateMyUserNameCard(nameCard: UserNameCard, cb: UpdateMyUserNameCardCallback, jsonExtension: string): boolean;
|
|
56
|
+
QueryUserListByKeyword(keyword: string, cb: GetUserNameCardCallback, jsonExtension: string): boolean;
|
|
57
|
+
UpdatePushToken(cerName: string, token: string, type: NINPushType): void;
|
|
58
|
+
}
|
package/types/nim.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { NIMClient } from './api/client';
|
|
2
|
+
export { NIMDataSync } from './api/data_sync';
|
|
3
|
+
export { NIMFriend } from './api/friend';
|
|
4
|
+
export { NIMGlobal } from './api/global';
|
|
5
|
+
export { NIMMsgLog } from './api/msglog';
|
|
6
|
+
export { NIMNOS } from './api/nos';
|
|
7
|
+
export { NIMOnlineSession } from './api/online_session';
|
|
8
|
+
export { NIMPassThroughProxy } from './api/pass_through_proxy';
|
|
9
|
+
export { NIMSession } from './api/session';
|
|
10
|
+
export { NIMSubscribeEvent } from './api/subscribe_event';
|
|
11
|
+
export { NIMSuperTeam } from './api/super_team';
|
|
12
|
+
export { NIMSysMsg } from './api/sysmsg';
|
|
13
|
+
export { NIMTalk } from './api/talk';
|
|
14
|
+
export { NIMTeam } from './api/team';
|
|
15
|
+
export { NIMTool } from './api/tool';
|
|
16
|
+
export { NIMUser } from './api/user';
|
|
17
|
+
export { NIMPlugin } from './api/plugin';
|
|
18
|
+
export { NIMTalkEx } from './api/talkex';
|
package/js/api/client_def.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NIMMultiSpotNotifyType = exports.NIMKickReason = exports.NIMLoginStep = exports.NIMClientType = exports.NIMLoginState = exports.NIMLogoutType = exports.NIMSDKLogLevel = void 0;
|
|
4
|
-
var NIMSDKLogLevel;
|
|
5
|
-
(function (NIMSDKLogLevel) {
|
|
6
|
-
NIMSDKLogLevel[NIMSDKLogLevel["kNIMSDKLogLevelApp"] = 5] = "kNIMSDKLogLevelApp";
|
|
7
|
-
NIMSDKLogLevel[NIMSDKLogLevel["kNIMSDKLogLevelPro"] = 6] = "kNIMSDKLogLevelPro";
|
|
8
|
-
})(NIMSDKLogLevel = exports.NIMSDKLogLevel || (exports.NIMSDKLogLevel = {}));
|
|
9
|
-
/** @enum NIMLogoutType Logout类型 */
|
|
10
|
-
var NIMLogoutType;
|
|
11
|
-
(function (NIMLogoutType) {
|
|
12
|
-
NIMLogoutType[NIMLogoutType["kNIMLogoutChangeAccout"] = 1] = "kNIMLogoutChangeAccout";
|
|
13
|
-
NIMLogoutType[NIMLogoutType["kNIMLogoutKickout"] = 2] = "kNIMLogoutKickout";
|
|
14
|
-
NIMLogoutType[NIMLogoutType["kNIMLogoutAppExit"] = 3] = "kNIMLogoutAppExit";
|
|
15
|
-
NIMLogoutType[NIMLogoutType["kNIMLogoutRelogin"] = 4] = "kNIMLogoutRelogin";
|
|
16
|
-
})(NIMLogoutType = exports.NIMLogoutType || (exports.NIMLogoutType = {}));
|
|
17
|
-
/** @enum NIMLoginState 登录状态 */
|
|
18
|
-
var NIMLoginState;
|
|
19
|
-
(function (NIMLoginState) {
|
|
20
|
-
NIMLoginState[NIMLoginState["kNIMLoginStateLogin"] = 1] = "kNIMLoginStateLogin";
|
|
21
|
-
NIMLoginState[NIMLoginState["kNIMLoginStateUnLogin"] = 2] = "kNIMLoginStateUnLogin";
|
|
22
|
-
})(NIMLoginState = exports.NIMLoginState || (exports.NIMLoginState = {}));
|
|
23
|
-
;
|
|
24
|
-
/** @enum NIMClientType 客户端类型 */
|
|
25
|
-
var NIMClientType;
|
|
26
|
-
(function (NIMClientType) {
|
|
27
|
-
NIMClientType[NIMClientType["kNIMClientTypeDefault"] = 0] = "kNIMClientTypeDefault";
|
|
28
|
-
NIMClientType[NIMClientType["kNIMClientTypeAndroid"] = 1] = "kNIMClientTypeAndroid";
|
|
29
|
-
NIMClientType[NIMClientType["kNIMClientTypeiOS"] = 2] = "kNIMClientTypeiOS";
|
|
30
|
-
NIMClientType[NIMClientType["kNIMClientTypePCWindows"] = 4] = "kNIMClientTypePCWindows";
|
|
31
|
-
NIMClientType[NIMClientType["kNIMClientTypeWeb"] = 16] = "kNIMClientTypeWeb";
|
|
32
|
-
NIMClientType[NIMClientType["kNIMClientTypeRestAPI"] = 32] = "kNIMClientTypeRestAPI";
|
|
33
|
-
NIMClientType[NIMClientType["kNIMClientTypeMacOS"] = 64] = "kNIMClientTypeMacOS";
|
|
34
|
-
})(NIMClientType = exports.NIMClientType || (exports.NIMClientType = {}));
|
|
35
|
-
/** @enum NIMLoginStep 登录步骤 */
|
|
36
|
-
var NIMLoginStep;
|
|
37
|
-
(function (NIMLoginStep) {
|
|
38
|
-
NIMLoginStep[NIMLoginStep["kNIMLoginStepLinking"] = 0] = "kNIMLoginStepLinking";
|
|
39
|
-
NIMLoginStep[NIMLoginStep["kNIMLoginStepLink"] = 1] = "kNIMLoginStepLink";
|
|
40
|
-
NIMLoginStep[NIMLoginStep["kNIMLoginStepLogining"] = 2] = "kNIMLoginStepLogining";
|
|
41
|
-
NIMLoginStep[NIMLoginStep["kNIMLoginStepLogin"] = 3] = "kNIMLoginStepLogin";
|
|
42
|
-
})(NIMLoginStep = exports.NIMLoginStep || (exports.NIMLoginStep = {}));
|
|
43
|
-
;
|
|
44
|
-
/** @enum NIMKickReason 被踢原因 */
|
|
45
|
-
var NIMKickReason;
|
|
46
|
-
(function (NIMKickReason) {
|
|
47
|
-
NIMKickReason[NIMKickReason["kNIMKickReasonSameGeneric"] = 1] = "kNIMKickReasonSameGeneric";
|
|
48
|
-
NIMKickReason[NIMKickReason["kNIMKickReasonServerKick"] = 2] = "kNIMKickReasonServerKick";
|
|
49
|
-
NIMKickReason[NIMKickReason["kNIMKickReasonKickBySelfOtherClient"] = 3] = "kNIMKickReasonKickBySelfOtherClient";
|
|
50
|
-
})(NIMKickReason = exports.NIMKickReason || (exports.NIMKickReason = {}));
|
|
51
|
-
;
|
|
52
|
-
/** @enum NIMMultiSpotNotifyType 多点登录通知类型 */
|
|
53
|
-
var NIMMultiSpotNotifyType;
|
|
54
|
-
(function (NIMMultiSpotNotifyType) {
|
|
55
|
-
NIMMultiSpotNotifyType[NIMMultiSpotNotifyType["kNIMMultiSpotNotifyTypeImIn"] = 2] = "kNIMMultiSpotNotifyTypeImIn";
|
|
56
|
-
NIMMultiSpotNotifyType[NIMMultiSpotNotifyType["kNIMMultiSpotNotifyTypeImOut"] = 3] = "kNIMMultiSpotNotifyTypeImOut";
|
|
57
|
-
})(NIMMultiSpotNotifyType = exports.NIMMultiSpotNotifyType || (exports.NIMMultiSpotNotifyType = {}));
|
|
58
|
-
;
|
package/js/api/nim.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const nim = require('bindings')('nim');
|
|
4
|
-
if (process.platform === 'win32') {
|
|
5
|
-
// Add the compiled product path to the environment variable,
|
|
6
|
-
// so that the third party does not need to copy the
|
|
7
|
-
// dynamic library separately to the program directory when importing.
|
|
8
|
-
const path = require('path');
|
|
9
|
-
const asarPath = path.join(__dirname, '../../build/Release/');
|
|
10
|
-
const unpackedPath = asarPath.replace('app.asar', 'app.asar.unpacked');
|
|
11
|
-
process.env.PATH = `${unpackedPath};${process.env.PATH}`;
|
|
12
|
-
}
|
|
13
|
-
exports.default = nim;
|
package/js/api/rts.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const nim_1 = __importDefault(require("./nim"));
|
|
7
|
-
const events_1 = __importDefault(require("events"));
|
|
8
|
-
class NIMRts extends events_1.default.EventEmitter {
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
this.rts = new nim_1.default.Rts();
|
|
12
|
-
}
|
|
13
|
-
setProxy(type, host, port, user, password) {
|
|
14
|
-
this.rts.SetProxy(type, host, port, user, password);
|
|
15
|
-
}
|
|
16
|
-
startChannel(channel_type, uid, info, cb) {
|
|
17
|
-
this.rts.StartChannel(channel_type, uid, info, cb);
|
|
18
|
-
}
|
|
19
|
-
setStartNotifyCb(cb) {
|
|
20
|
-
this.rts.SetStartNotifyCb(cb);
|
|
21
|
-
}
|
|
22
|
-
createConf(name, custom_info, cb) {
|
|
23
|
-
this.rts.CreateConf(name, custom_info, cb);
|
|
24
|
-
}
|
|
25
|
-
joinConf(name, session_id, record, cb) {
|
|
26
|
-
this.rts.JoinConf(name, session_id, record, cb);
|
|
27
|
-
}
|
|
28
|
-
ack(session_id, channel_type, accept, data_record, audio_record, cb) {
|
|
29
|
-
this.rts.Ack(session_id, channel_type, accept, data_record, audio_record, cb);
|
|
30
|
-
}
|
|
31
|
-
setAckNotifyCb(cb) {
|
|
32
|
-
this.rts.SetAckNotifyCb(cb);
|
|
33
|
-
}
|
|
34
|
-
setSyncAckNotifyCb(cb) {
|
|
35
|
-
this.rts.SetSyncAckNotifyCb(cb);
|
|
36
|
-
}
|
|
37
|
-
setConnectNotifyCb(cb) {
|
|
38
|
-
this.rts.SetConnectNotifyCb(cb);
|
|
39
|
-
}
|
|
40
|
-
setMemberChangeCb(cb) {
|
|
41
|
-
this.rts.SetMemberChangeCb(cb);
|
|
42
|
-
}
|
|
43
|
-
control(session_id, info, cb) {
|
|
44
|
-
this.rts.Control(session_id, info, cb);
|
|
45
|
-
}
|
|
46
|
-
setControlNotifyCb(cb) {
|
|
47
|
-
this.rts.SetControlNotifyCb(cb);
|
|
48
|
-
}
|
|
49
|
-
setVChatMode(session_id, mode) {
|
|
50
|
-
this.rts.SetVChatMode(session_id, mode);
|
|
51
|
-
}
|
|
52
|
-
hangup(session_id, cb) {
|
|
53
|
-
this.rts.Hangup(session_id, cb);
|
|
54
|
-
}
|
|
55
|
-
setHangupNotifyCb(cb) {
|
|
56
|
-
this.rts.SetHangupNotifyCb(cb);
|
|
57
|
-
}
|
|
58
|
-
relogin(session_id, channel_type, cb) {
|
|
59
|
-
this.rts.Relogin(session_id, channel_type, cb);
|
|
60
|
-
}
|
|
61
|
-
sendData(session_id, channel_type, data, uid) {
|
|
62
|
-
this.rts.SendData(session_id, channel_type, data, uid);
|
|
63
|
-
}
|
|
64
|
-
setRecDataCb(cb) {
|
|
65
|
-
this.rts.SetRecDataCb(cb);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.default = NIMRts;
|
package/js/api/rts_def.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NIMProxyType = void 0;
|
|
4
|
-
/** @enum NIMProxyType 代理类型 */
|
|
5
|
-
var NIMProxyType;
|
|
6
|
-
(function (NIMProxyType) {
|
|
7
|
-
NIMProxyType[NIMProxyType["kNIMProxyNone"] = 0] = "kNIMProxyNone";
|
|
8
|
-
NIMProxyType[NIMProxyType["kNIMProxyHttp11"] = 1] = "kNIMProxyHttp11";
|
|
9
|
-
NIMProxyType[NIMProxyType["kNIMProxySocks4"] = 4] = "kNIMProxySocks4";
|
|
10
|
-
NIMProxyType[NIMProxyType["kNIMProxySocks4a"] = 5] = "kNIMProxySocks4a";
|
|
11
|
-
NIMProxyType[NIMProxyType["kNIMProxySocks5"] = 6] = "kNIMProxySocks5";
|
|
12
|
-
NIMProxyType[NIMProxyType["kNIMProxyNrtc"] = 10] = "kNIMProxyNrtc";
|
|
13
|
-
})(NIMProxyType = exports.NIMProxyType || (exports.NIMProxyType = {}));
|
|
14
|
-
;
|
|
15
|
-
;
|
package/js/api/signaling.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const nim_1 = __importDefault(require("./nim"));
|
|
7
|
-
const events_1 = __importDefault(require("events"));
|
|
8
|
-
class NIMSignaling extends events_1.default.EventEmitter {
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
this.signaling = new nim_1.default.Signaling();
|
|
12
|
-
}
|
|
13
|
-
regOnlineNotifyCb(cb) {
|
|
14
|
-
this.signaling.RegOnlineNotifyCb(cb);
|
|
15
|
-
}
|
|
16
|
-
regMutilClientSyncNotifyCb(cb) {
|
|
17
|
-
this.signaling.RegMutilClientSyncNotifyCb(cb);
|
|
18
|
-
}
|
|
19
|
-
regOfflineNotifyCb(cb) {
|
|
20
|
-
this.signaling.RegOfflineNotifyCb(cb);
|
|
21
|
-
}
|
|
22
|
-
regChannelsSyncCb(cb) {
|
|
23
|
-
this.signaling.RegChannelsSyncCb(cb);
|
|
24
|
-
}
|
|
25
|
-
regMembersSyncCb(cb) {
|
|
26
|
-
this.signaling.RegMembersSyncCb(cb);
|
|
27
|
-
}
|
|
28
|
-
signalingCreate(param, cb) {
|
|
29
|
-
this.signaling.SignalingCreate(param, cb);
|
|
30
|
-
}
|
|
31
|
-
signalingClose(param, cb) {
|
|
32
|
-
this.signaling.SignalingClose(param, cb);
|
|
33
|
-
}
|
|
34
|
-
join(param, cb) {
|
|
35
|
-
this.signaling.Join(param, cb);
|
|
36
|
-
}
|
|
37
|
-
leave(param, cb) {
|
|
38
|
-
this.signaling.Leave(param, cb);
|
|
39
|
-
}
|
|
40
|
-
queryChannelInfo(param, cb) {
|
|
41
|
-
this.signaling.QueryChannelInfo(param, cb);
|
|
42
|
-
}
|
|
43
|
-
call(param, cb) {
|
|
44
|
-
this.signaling.Call(param, cb);
|
|
45
|
-
}
|
|
46
|
-
invite(param, cb) {
|
|
47
|
-
this.signaling.Invite(param, cb);
|
|
48
|
-
}
|
|
49
|
-
cancelInvite(param, cb) {
|
|
50
|
-
this.signaling.CancelInvite(param, cb);
|
|
51
|
-
}
|
|
52
|
-
reject(param, cb) {
|
|
53
|
-
this.signaling.Reject(param, cb);
|
|
54
|
-
}
|
|
55
|
-
accept(param, cb) {
|
|
56
|
-
this.signaling.Accept(param, cb);
|
|
57
|
-
}
|
|
58
|
-
control(param, cb) {
|
|
59
|
-
this.signaling.Control(param, cb);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.default = NIMSignaling;
|
package/js/api/signaling_def.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NIMSignalingType = exports.NIMSignalingEventType = void 0;
|
|
4
|
-
var NIMSignalingEventType;
|
|
5
|
-
(function (NIMSignalingEventType) {
|
|
6
|
-
NIMSignalingEventType[NIMSignalingEventType["kNIMSignalingEventTypeClose"] = 1] = "kNIMSignalingEventTypeClose";
|
|
7
|
-
NIMSignalingEventType[NIMSignalingEventType["kNIMSignalingEventTypeJoin"] = 2] = "kNIMSignalingEventTypeJoin";
|
|
8
|
-
NIMSignalingEventType[NIMSignalingEventType["kNIMSignalingEventTypeInvite"] = 3] = "kNIMSignalingEventTypeInvite";
|
|
9
|
-
NIMSignalingEventType[NIMSignalingEventType["kNIMSignalingEventTypeCancelInvite"] = 4] = "kNIMSignalingEventTypeCancelInvite";
|
|
10
|
-
NIMSignalingEventType[NIMSignalingEventType["kNIMSignalingEventTypeReject"] = 5] = "kNIMSignalingEventTypeReject";
|
|
11
|
-
NIMSignalingEventType[NIMSignalingEventType["kNIMSignalingEventTypeAccept"] = 6] = "kNIMSignalingEventTypeAccept";
|
|
12
|
-
NIMSignalingEventType[NIMSignalingEventType["kNIMSignalingEventTypeLeave"] = 7] = "kNIMSignalingEventTypeLeave";
|
|
13
|
-
NIMSignalingEventType[NIMSignalingEventType["kNIMSignalingEventTypeCtrl"] = 8] = "kNIMSignalingEventTypeCtrl";
|
|
14
|
-
})(NIMSignalingEventType = exports.NIMSignalingEventType || (exports.NIMSignalingEventType = {}));
|
|
15
|
-
var NIMSignalingType;
|
|
16
|
-
(function (NIMSignalingType) {
|
|
17
|
-
NIMSignalingType[NIMSignalingType["kNIMSignalingTypeAudio"] = 1] = "kNIMSignalingTypeAudio";
|
|
18
|
-
NIMSignalingType[NIMSignalingType["kNIMSignalingTypeVideo"] = 2] = "kNIMSignalingTypeVideo";
|
|
19
|
-
NIMSignalingType[NIMSignalingType["kNIMSignalingTypeCustom"] = 3] = "kNIMSignalingTypeCustom";
|
|
20
|
-
})(NIMSignalingType = exports.NIMSignalingType || (exports.NIMSignalingType = {}));
|
package/just-task.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
const { task, option, logger, argv } = require('just-task')
|
|
2
|
-
const fs = require('fs')
|
|
3
|
-
const download = require('download')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
const fetchWrapper = require(path.join(__dirname, './scripts/fetch_wrapper'))
|
|
6
|
-
const buildWrapper = require(path.join(__dirname, './scripts/build_wrapper'))
|
|
7
|
-
const buildAddon = require(path.join(__dirname, './scripts/build_addon'))
|
|
8
|
-
const packAddon = require(path.join(__dirname, './scripts/pack_addon'))
|
|
9
|
-
const packageMeta = require(path.join(__dirname, 'package.json'))
|
|
10
|
-
|
|
11
|
-
option('target')
|
|
12
|
-
option('target_platform', { default: process.platform, choices: ['darwin', 'win32', 'linux'] })
|
|
13
|
-
option('target_arch', { default: process.arch, choices: ['ia32', 'x64'] })
|
|
14
|
-
option('runtime', { default: 'electron', choices: ['electron', 'node'] })
|
|
15
|
-
option('debug', { default: false, boolean: true })
|
|
16
|
-
option('silent', { default: false, boolean: true })
|
|
17
|
-
|
|
18
|
-
const nativeUrl = 'https://yx-web-nosdn.netease.im/package/1632832061/NIM_CrossPlatform_SDK_v7.8.3.zip?download=NIM_CrossPlatform_SDK_v7.8.3.zip'
|
|
19
|
-
|
|
20
|
-
task('fetch-wrapper', () => {
|
|
21
|
-
const platform = argv().target_platform
|
|
22
|
-
const arch = argv().target_arch
|
|
23
|
-
const cachePath = path.join(__dirname, 'nim_sdk')
|
|
24
|
-
const temporaryPath = path.join(__dirname, 'temporary')
|
|
25
|
-
return fetchWrapper({
|
|
26
|
-
fetchUrl: nativeUrl,
|
|
27
|
-
temporaryPath,
|
|
28
|
-
extractPath: cachePath,
|
|
29
|
-
platform,
|
|
30
|
-
arch
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
task('build-wrapper', () => {
|
|
35
|
-
const platform = argv().target_platform
|
|
36
|
-
const arch = argv().target_arch
|
|
37
|
-
const sourcePath = path.join(__dirname, 'nim_sdk')
|
|
38
|
-
return buildWrapper({
|
|
39
|
-
platform,
|
|
40
|
-
arch,
|
|
41
|
-
sourcePath
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
task('build', () => {
|
|
46
|
-
const target = argv().target
|
|
47
|
-
const platform = argv().target_platform || process.platform
|
|
48
|
-
const arch = argv().target_arch || process.arch
|
|
49
|
-
const runtime = argv().runtime
|
|
50
|
-
const version = packageMeta.version
|
|
51
|
-
const packageName = packageMeta.name
|
|
52
|
-
const sourcePath = path.join(__dirname, 'nim_sdk')
|
|
53
|
-
|
|
54
|
-
logger.info(JSON.stringify(argv()))
|
|
55
|
-
|
|
56
|
-
return new Promise((resolve, reject) => {
|
|
57
|
-
buildWrapper({
|
|
58
|
-
platform,
|
|
59
|
-
arch,
|
|
60
|
-
sourcePath
|
|
61
|
-
}).then(() => {
|
|
62
|
-
return buildAddon({
|
|
63
|
-
target,
|
|
64
|
-
runtime,
|
|
65
|
-
platform,
|
|
66
|
-
arch
|
|
67
|
-
})
|
|
68
|
-
}).then(() => {
|
|
69
|
-
return packAddon({
|
|
70
|
-
packageName,
|
|
71
|
-
version,
|
|
72
|
-
target,
|
|
73
|
-
platform,
|
|
74
|
-
arch,
|
|
75
|
-
runtime
|
|
76
|
-
})
|
|
77
|
-
}).then(() => resolve())
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
task('package', () => {
|
|
82
|
-
logger.info(JSON.stringify(argv()))
|
|
83
|
-
const target = argv().target
|
|
84
|
-
const platform = argv().target_platform
|
|
85
|
-
const arch = argv().target_arch
|
|
86
|
-
const runtime = argv().runtime
|
|
87
|
-
const version = packageMeta.version
|
|
88
|
-
const packageName = packageMeta.name
|
|
89
|
-
return packAddon({
|
|
90
|
-
packageName,
|
|
91
|
-
version,
|
|
92
|
-
target,
|
|
93
|
-
platform,
|
|
94
|
-
arch,
|
|
95
|
-
runtime
|
|
96
|
-
})
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
task('install', () => {
|
|
100
|
-
if ((process.env.npm_config_skip_install || false)) {
|
|
101
|
-
logger.info('[install] Skip downlaod prebuilt libraries.')
|
|
102
|
-
return
|
|
103
|
-
}
|
|
104
|
-
let target = '5.0.8'
|
|
105
|
-
let runtime = 'electron'
|
|
106
|
-
const targetPlatform = process.env.npm_config_target_platform || process.platform
|
|
107
|
-
const targetArch = process.env.npm_config_target_arch || process.arch
|
|
108
|
-
const downloadUrl = process.env.npm_config_download_url
|
|
109
|
-
const curPkgMeta = require(path.join(__dirname, 'package.json'))
|
|
110
|
-
const rootPkgMeta = require(path.join(process.env.INIT_CWD, 'package.json'))
|
|
111
|
-
logger.info('------------------ just install --------------------')
|
|
112
|
-
if (rootPkgMeta.devDependencies && rootPkgMeta.devDependencies.electron) {
|
|
113
|
-
// v13.1.2 => 13.1.2, remove prefix 'v'
|
|
114
|
-
target = rootPkgMeta.devDependencies.electron.replace(/^.*?(\d+.+\d).*/, '$1')
|
|
115
|
-
} else {
|
|
116
|
-
target = process.version.match(/^v(\d+\.\d+)/)[1]
|
|
117
|
-
runtime = 'node'
|
|
118
|
-
}
|
|
119
|
-
// 13.1.2 => 13.1, match major.minor only
|
|
120
|
-
const nodeAbi = `${runtime}-v${target.replace(/^(\d+.+?\d+).*/, '$1')}`
|
|
121
|
-
return new Promise((resolve, reject) => {
|
|
122
|
-
const host = 'https://yx-web-nosdn.netease.im'
|
|
123
|
-
const remotePath = 'package'
|
|
124
|
-
const packageName = `${curPkgMeta.name}-v${curPkgMeta.version}-${nodeAbi}-${targetPlatform}-${targetArch}.tar.gz`
|
|
125
|
-
const localPath = 'build/Release'
|
|
126
|
-
fs.rmdirSync(path.join(__dirname, localPath), { recursive: true })
|
|
127
|
-
download(`${host}/${remotePath}/${packageName}`, path.join(__dirname, localPath), {
|
|
128
|
-
strip: 1,
|
|
129
|
-
extract: true
|
|
130
|
-
}).then(() => {
|
|
131
|
-
logger.info(`[install] Download prebuilt binaries from ${host}/${remotePath}/${packageName}`)
|
|
132
|
-
resolve()
|
|
133
|
-
}).catch(err => {
|
|
134
|
-
logger.warn(`[install] Failed to download package from: ${host}/${remotePath}/${packageName}, error code: ${err.statusCode}`)
|
|
135
|
-
logger.info('[install] Start build from local source file.')
|
|
136
|
-
const cachePath = path.join(__dirname, 'nim_sdk')
|
|
137
|
-
const temporaryPath = path.join(__dirname, 'temporary')
|
|
138
|
-
fetchWrapper({
|
|
139
|
-
fetchUrl: nativeUrl,
|
|
140
|
-
temporaryPath,
|
|
141
|
-
extractPath: cachePath
|
|
142
|
-
}).then(() => {
|
|
143
|
-
return buildWrapper({
|
|
144
|
-
sourcePath: cachePath
|
|
145
|
-
})
|
|
146
|
-
}).then(() => {
|
|
147
|
-
return buildAddon({
|
|
148
|
-
target,
|
|
149
|
-
runtime
|
|
150
|
-
})
|
|
151
|
-
}).then(() => resolve())
|
|
152
|
-
})
|
|
153
|
-
})
|
|
154
|
-
})
|
package/scripts/build_addon.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const { logger } = require('just-task')
|
|
2
|
-
const shell = require('shelljs')
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const fs = require('fs')
|
|
5
|
-
|
|
6
|
-
module.exports = ({
|
|
7
|
-
target = '8.0.0',
|
|
8
|
-
runtime = 'electron',
|
|
9
|
-
platform = process.platform,
|
|
10
|
-
arch = process.arch,
|
|
11
|
-
debug = false,
|
|
12
|
-
silent = false,
|
|
13
|
-
msvcVersion = '2017',
|
|
14
|
-
distUrl = 'https://electronjs.org/headers',
|
|
15
|
-
forceClean = false
|
|
16
|
-
}) => {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
logger.info(`[build] start building [${runtime}-${target}]`)
|
|
19
|
-
const command = [`npx node-gyp configure`]
|
|
20
|
-
command.push(`--arch=${arch} --msvs_version=${msvcVersion}`)
|
|
21
|
-
if (runtime === 'electron') {
|
|
22
|
-
command.push(`--target=${target} --dist-url=${distUrl}`)
|
|
23
|
-
}
|
|
24
|
-
if (debug) {
|
|
25
|
-
command.push('--debug')
|
|
26
|
-
if (platform === 'darwin') {
|
|
27
|
-
command.push('-- -f xcode')
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
logger.info(command.join(' '))
|
|
31
|
-
logger.info('[build] platform:', platform)
|
|
32
|
-
logger.info('[build] arch:', arch)
|
|
33
|
-
logger.info('[build] target:', target)
|
|
34
|
-
logger.info('[build] runtime:', runtime)
|
|
35
|
-
if (forceClean) {
|
|
36
|
-
if (shell.exec(`npx node-gyp clean`, { silent }) !== 0) {
|
|
37
|
-
reject(new Error('failed to clean up build folder.'))
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
shell.exec(command.join(' '), { silent }, (code, stdout, stderr) => {
|
|
41
|
-
logger.info(`[build] configure done ${stdout}`)
|
|
42
|
-
if (code !== 0) {
|
|
43
|
-
reject(stderr)
|
|
44
|
-
}
|
|
45
|
-
shell.exec(`npx node-gyp build`, { silent }, (code, stdout, stderr) => {
|
|
46
|
-
if (code !== 0) {
|
|
47
|
-
logger.error('[build] failed to build C++ addon manually.')
|
|
48
|
-
logger.error(stderr)
|
|
49
|
-
reject(stderr)
|
|
50
|
-
}
|
|
51
|
-
logger.info(`[build] build complete ${stdout}`)
|
|
52
|
-
resolve()
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
}
|
package/scripts/build_wrapper.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const shell = require('shelljs')
|
|
3
|
-
const { logger } = require('just-task')
|
|
4
|
-
|
|
5
|
-
module.exports = ({
|
|
6
|
-
platform = process.platform,
|
|
7
|
-
arch = process.arch,
|
|
8
|
-
sourcePath
|
|
9
|
-
}) => {
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
const wrapperSource = path.join(sourcePath, 'wrapper')
|
|
12
|
-
|
|
13
|
-
// Generate Visual Studio solution
|
|
14
|
-
const temporaryPath = path.join(sourcePath, `build_${platform}_${arch}`)
|
|
15
|
-
const cmakeGenerate = [`cmake ${wrapperSource}`]
|
|
16
|
-
cmakeGenerate.push(`-B${temporaryPath}`)
|
|
17
|
-
cmakeGenerate.push('-T"v141_xp"')
|
|
18
|
-
cmakeGenerate.push(`-DCMAKE_INSTALL_PREFIX=${sourcePath}`)
|
|
19
|
-
if (platform === 'win32') {
|
|
20
|
-
cmakeGenerate.push('-DBUILD_SHARED_LIBS=ON')
|
|
21
|
-
cmakeGenerate.push(arch === 'ia32' ? '-G"Visual Studio 15 2017"' : '-G"Visual Studio 15 2017 Win64"')
|
|
22
|
-
} else if (platform === 'darwin') {
|
|
23
|
-
cmakeGenerate.push('-G"Xcode" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9')
|
|
24
|
-
} else {
|
|
25
|
-
reject(new Error('Unsupported platform.'))
|
|
26
|
-
}
|
|
27
|
-
logger.info(`[wrapper] ${cmakeGenerate.join(' ')}`)
|
|
28
|
-
if (shell.exec(cmakeGenerate.join(' ')).code !== 0) {
|
|
29
|
-
logger.error('[wrapper] Failed to generate NIM C++ wrapper solution.')
|
|
30
|
-
process.exit(1)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Build C++ wrapper
|
|
34
|
-
const cmakeBuild = [`cmake --build ${temporaryPath}`]
|
|
35
|
-
cmakeBuild.push('--config Release')
|
|
36
|
-
cmakeBuild.push('--target install')
|
|
37
|
-
logger.info(`[wrapper] ${cmakeBuild.join(' ')}`)
|
|
38
|
-
if (shell.exec(cmakeBuild.join(' ')).code !== 0) {
|
|
39
|
-
logger.error('[wrapper] Failed to build NIM C++ wrapper.')
|
|
40
|
-
process.exit(1)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
resolve()
|
|
44
|
-
})
|
|
45
|
-
}
|
package/scripts/fetch_wrapper.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const download = require('download')
|
|
3
|
-
const tar = require('tar')
|
|
4
|
-
const fs = require('fs')
|
|
5
|
-
const { logger } = require('just-task')
|
|
6
|
-
|
|
7
|
-
module.exports = ({
|
|
8
|
-
platform = process.platform,
|
|
9
|
-
arch = process.arch,
|
|
10
|
-
fetchUrl,
|
|
11
|
-
temporaryPath,
|
|
12
|
-
extractPath
|
|
13
|
-
}) => {
|
|
14
|
-
return new Promise((resolve, reject) => {
|
|
15
|
-
logger.info(fetchUrl)
|
|
16
|
-
download(fetchUrl, temporaryPath, {
|
|
17
|
-
strip: 1,
|
|
18
|
-
extract: true
|
|
19
|
-
}).then(() => {
|
|
20
|
-
logger.info(`[fetch] Download file from ${fetchUrl}`)
|
|
21
|
-
const files = fs.readdirSync(temporaryPath)
|
|
22
|
-
const matchPlatform = platform === 'win32' ? 'windows' : 'macosx'
|
|
23
|
-
const matchArch = arch === 'ia32' ? 'x86' : (platform === 'win32' ? 'x64' : 'x86_64')
|
|
24
|
-
for (let i = 0; i < files.length; i++) {
|
|
25
|
-
logger.info(`[fetch] found resource: ${files[i]}`)
|
|
26
|
-
if (files[i].indexOf(matchPlatform) !== -1 && files[i].indexOf(matchArch) !== -1) {
|
|
27
|
-
const sourceFile = path.join(temporaryPath, files[i])
|
|
28
|
-
if (!fs.existsSync(extractPath)) {
|
|
29
|
-
fs.mkdirSync(extractPath)
|
|
30
|
-
}
|
|
31
|
-
logger.info(`[wrapper] Extract file from ${sourceFile} to ${extractPath}`)
|
|
32
|
-
tar.extract({
|
|
33
|
-
file: sourceFile,
|
|
34
|
-
cwd: extractPath,
|
|
35
|
-
sync: true
|
|
36
|
-
})
|
|
37
|
-
resolve()
|
|
38
|
-
break
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}).catch(err => {
|
|
42
|
-
reject(err)
|
|
43
|
-
})
|
|
44
|
-
})
|
|
45
|
-
}
|
package/scripts/pack_addon.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const tar = require('tar')
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const { logger } = require('just-task')
|
|
5
|
-
|
|
6
|
-
module.exports = ({
|
|
7
|
-
packageName,
|
|
8
|
-
version,
|
|
9
|
-
target,
|
|
10
|
-
platform,
|
|
11
|
-
arch,
|
|
12
|
-
runtime,
|
|
13
|
-
artifactsDirectory = path.join(__dirname, '../build/Release'),
|
|
14
|
-
distDirectory = path.join(__dirname, '../packages')
|
|
15
|
-
}) => {
|
|
16
|
-
return new Promise((resolve, reject) => {
|
|
17
|
-
const strippedVersion = target.replace(/^.*?(\d+.+?\d).*/, '$1')
|
|
18
|
-
const artifacts = fs.readdirSync(artifactsDirectory)
|
|
19
|
-
const targetName = `${packageName}-v${version}-${runtime}-v${strippedVersion}-${platform}-${arch}.tar.gz`
|
|
20
|
-
const targetFile = path.join(distDirectory, targetName)
|
|
21
|
-
if (!fs.existsSync(distDirectory)) {
|
|
22
|
-
fs.mkdirSync(distDirectory)
|
|
23
|
-
}
|
|
24
|
-
logger.info(`[package] Tar artifacts as: ${targetName}`)
|
|
25
|
-
tar.create({
|
|
26
|
-
gzip: true,
|
|
27
|
-
file: targetFile,
|
|
28
|
-
cwd: artifactsDirectory,
|
|
29
|
-
filter: (path, stat) => {
|
|
30
|
-
if (path.match(/\.pdb|\.dll|\.node|\.framework|\.dylib/g) !== null) {
|
|
31
|
-
logger.info(`[package] ${path}`)
|
|
32
|
-
return true
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}, artifacts).then(() => {
|
|
36
|
-
resolve()
|
|
37
|
-
}).catch(err => {
|
|
38
|
-
reject(err)
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
}
|