nim-web-sdk-ng 0.2.0 → 0.3.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/CHANGELOG.md +9 -0
- package/dist/CHATROOM_BROWSER_SDK.d.ts +142 -7
- package/dist/CHATROOM_BROWSER_SDK.js +16 -7
- package/dist/CHATROOM_UNIAPP_SDK.d.ts +142 -7
- package/dist/CHATROOM_UNIAPP_SDK.js +15 -1
- package/dist/NIM_BROWSER_SDK.d.ts +131 -7
- package/dist/NIM_BROWSER_SDK.js +16 -7
- package/dist/NIM_UNIAPP_SDK.d.ts +131 -7
- package/dist/NIM_UNIAPP_SDK.js +15 -1
- package/dist/esm/index.d.ts +142 -7
- package/dist/esm/index.js +15 -1
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## 0.3.0
|
|
2
|
+
|
|
3
|
+
* feature: 追加 deleteSelfMsgs 单向删除接口。
|
|
4
|
+
* feature: 推送插件以及适配代码,推送功能的使用参见文章:
|
|
5
|
+
* chore: uniapp 平台适配优化,能够支持编译去支付宝小程序,微信小程序
|
|
6
|
+
* chore: 优化撤回消息逻辑,使撤回消息后 session 的 unread 数等参数能得到正确的更新。
|
|
7
|
+
* chore: 聊天室追加鉴权方式
|
|
8
|
+
* fix: 修复登出协议的一些问题
|
|
9
|
+
|
|
1
10
|
## 0.2.0
|
|
2
11
|
|
|
3
12
|
* feature: 追加 superTeam 超级群逻辑
|
|
@@ -126,6 +126,14 @@ interface MsgServiceInterface {
|
|
|
126
126
|
* 如果同时在多个端登录了同一个账号, 那么其它端也会收到这条系统通知.
|
|
127
127
|
*/
|
|
128
128
|
recallMsg(options: RecallMsgOptions): Promise<IMMessage>;
|
|
129
|
+
/**
|
|
130
|
+
* 单向删除消息
|
|
131
|
+
*
|
|
132
|
+
* 不同与直接删除消息,单向删除消息后,自己看不到删除的消息,但对方仍能看到,也就是仅删除自己这侧的消息
|
|
133
|
+
*
|
|
134
|
+
* 如果同时在多个端登录了同一个账号, 其他端会收到一个单向删除的事件.
|
|
135
|
+
*/
|
|
136
|
+
deleteSelfMsgs(options: deleteSelfMsgsOptions): Promise<DeleteSelfMsgsResult[]>;
|
|
129
137
|
sendMsgReceipt(options: SendMsgReceiptOptions): Promise<SendMsgReceiptResult | void>;
|
|
130
138
|
/**
|
|
131
139
|
* 查看这条消息对方是否已读过。
|
|
@@ -589,6 +597,46 @@ declare type RecallMsgOptions = {
|
|
|
589
597
|
*/
|
|
590
598
|
env?: string;
|
|
591
599
|
};
|
|
600
|
+
declare type deleteSelfMsgsOptions = {
|
|
601
|
+
/**
|
|
602
|
+
* 待删除的消息对象
|
|
603
|
+
*/
|
|
604
|
+
msgs: IMMessage[];
|
|
605
|
+
/**
|
|
606
|
+
* 扩展字段
|
|
607
|
+
*/
|
|
608
|
+
ext?: string;
|
|
609
|
+
};
|
|
610
|
+
declare type DeleteSelfMsgsResult = {
|
|
611
|
+
/**
|
|
612
|
+
* 删除时间
|
|
613
|
+
*/
|
|
614
|
+
deletedTime: number;
|
|
615
|
+
/**
|
|
616
|
+
* 此消息的发送者
|
|
617
|
+
*/
|
|
618
|
+
from: string;
|
|
619
|
+
/**
|
|
620
|
+
* 此消息的 idClient
|
|
621
|
+
*/
|
|
622
|
+
idClient: string;
|
|
623
|
+
/**
|
|
624
|
+
* 此消息的 idServer
|
|
625
|
+
*/
|
|
626
|
+
idServer: string;
|
|
627
|
+
/**
|
|
628
|
+
* 此消息的场景,只有 p2p, team ,超大群暂时不允许单向删除
|
|
629
|
+
*/
|
|
630
|
+
scene: 'p2p' | 'team';
|
|
631
|
+
/**
|
|
632
|
+
* 此消息的发送时间
|
|
633
|
+
*/
|
|
634
|
+
time: number;
|
|
635
|
+
/**
|
|
636
|
+
* 此消息的接收者
|
|
637
|
+
*/
|
|
638
|
+
to: string;
|
|
639
|
+
};
|
|
592
640
|
declare type SendMsgReceiptOptions = {
|
|
593
641
|
msg: IMMessage;
|
|
594
642
|
};
|
|
@@ -873,6 +921,7 @@ declare type TSystemInfo = {
|
|
|
873
921
|
* 尽量使用规范或接近规范的定义
|
|
874
922
|
*/
|
|
875
923
|
declare class Adapters {
|
|
924
|
+
static setLogger(logger: any): void;
|
|
876
925
|
static platform: string;
|
|
877
926
|
static WebSocket: typeof WebSocket;
|
|
878
927
|
static localStorage: Storage;
|
|
@@ -922,6 +971,10 @@ declare type RequestParams = {
|
|
|
922
971
|
[key: string]: string | number;
|
|
923
972
|
};
|
|
924
973
|
timeout?: number;
|
|
974
|
+
/**
|
|
975
|
+
* 支付宝需要传 dataType: text 才能让 socket io 嗅探请求不挂
|
|
976
|
+
*/
|
|
977
|
+
dataType: string;
|
|
925
978
|
};
|
|
926
979
|
declare function setAdapters(newAdapters: Adapters): void;
|
|
927
980
|
|
|
@@ -981,6 +1034,11 @@ declare type CoreOptions = {
|
|
|
981
1034
|
*/
|
|
982
1035
|
reconnectionAttempts?: number;
|
|
983
1036
|
};
|
|
1037
|
+
declare enum DisconnectType {
|
|
1038
|
+
ACTIVE = 1,
|
|
1039
|
+
KICKED = 2,
|
|
1040
|
+
OFFLINE = 3
|
|
1041
|
+
}
|
|
984
1042
|
declare type NIMStatus = 'unconnected' | 'connecting' | 'connected' | 'logined' | 'waitReconnect' | 'destroyed';
|
|
985
1043
|
declare class Core extends EventEmitter {
|
|
986
1044
|
status: NIMStatus;
|
|
@@ -1007,9 +1065,20 @@ declare class Core extends EventEmitter {
|
|
|
1007
1065
|
connect(options?: ConnectOptions): Promise<void>;
|
|
1008
1066
|
private doConnect;
|
|
1009
1067
|
resetConnectStatus(): void;
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1068
|
+
/**
|
|
1069
|
+
* 断开连接
|
|
1070
|
+
*
|
|
1071
|
+
* 1. 标记未完成的 cmd 无效
|
|
1072
|
+
* 2. 取消心跳定时
|
|
1073
|
+
* 3. 关闭长连接通道
|
|
1074
|
+
* 4. 区分断开类型(是否需要重连,是否需要通知)
|
|
1075
|
+
* 4a. 主动断开的(登陆失败也算主动断开了): 1. 不需要重连、2. 移除网络监听、3. 通知上层 disconnect 事件
|
|
1076
|
+
* 4b. 被踢下线的: 1. 不需要重连、2. 移除网络监听、3. 通知上层 kicked 事件和原因
|
|
1077
|
+
* 4c. 因网络变化,心跳超时,发包失败等被动断开的: 1. 需要尝试重连、2. 不移除网络监听、3. 通知 willReconnect 事件、4. 设置重连定时
|
|
1078
|
+
* 4d. 因网络变化,心跳超时,发包失败等被动断开的,但是用户不开启重连配置,或者重连尝试最大次数已经达到:处理逻辑同 5a.
|
|
1079
|
+
*/
|
|
1080
|
+
doDisconnect(type: DisconnectType, description: string | StrAnyObj$1): void;
|
|
1081
|
+
private attempToReconnect;
|
|
1013
1082
|
/**
|
|
1014
1083
|
* @ignore
|
|
1015
1084
|
*/
|
|
@@ -1022,6 +1091,7 @@ declare class Core extends EventEmitter {
|
|
|
1022
1091
|
*/
|
|
1023
1092
|
ping(): void;
|
|
1024
1093
|
private initOnlineListener;
|
|
1094
|
+
private destroyOnlineListener;
|
|
1025
1095
|
/**
|
|
1026
1096
|
* 退出登录,并断开websocket连接
|
|
1027
1097
|
*
|
|
@@ -1029,6 +1099,15 @@ declare class Core extends EventEmitter {
|
|
|
1029
1099
|
* 如需销毁实例,请用 destroy
|
|
1030
1100
|
*/
|
|
1031
1101
|
disconnect(): Promise<void>;
|
|
1102
|
+
/**
|
|
1103
|
+
* 销毁实例
|
|
1104
|
+
*
|
|
1105
|
+
* 实现法则:不能使正在运行中的promise/callback访问不到某实例的变量报错,因此只是掐断实例接收新消息的通道,并且移除所有的监听,移除所有能通知上层的事件。
|
|
1106
|
+
*
|
|
1107
|
+
* 在 disconnect 断开连接后:
|
|
1108
|
+
* 1. 标明 status 为 destroy
|
|
1109
|
+
* 2. 移除 connect 等方法使连接状态无法再此更改。
|
|
1110
|
+
*/
|
|
1032
1111
|
destroy(): Promise<void>;
|
|
1033
1112
|
}
|
|
1034
1113
|
|
|
@@ -1476,6 +1555,17 @@ declare type ChatroomInitializeOptions = {
|
|
|
1476
1555
|
* 登录登出等通知目标的标签,是一个标签表达式
|
|
1477
1556
|
*/
|
|
1478
1557
|
notifyTargetTags?: string;
|
|
1558
|
+
/**
|
|
1559
|
+
* 鉴权方式,默认0
|
|
1560
|
+
* 0 表示最初的loginToken的校验方式,
|
|
1561
|
+
* 1 表示基于appSecret计算的token鉴权方式,
|
|
1562
|
+
* 2表示基于第三方回调的token鉴权方式,
|
|
1563
|
+
*/
|
|
1564
|
+
authType: number;
|
|
1565
|
+
/**
|
|
1566
|
+
* 登录自定义字段,用于提交给用户的第三方回调服务进行登录检测
|
|
1567
|
+
*/
|
|
1568
|
+
loginExt: string;
|
|
1479
1569
|
};
|
|
1480
1570
|
|
|
1481
1571
|
interface ChatroomServiceInterface {
|
|
@@ -1875,9 +1965,13 @@ declare type Session = {
|
|
|
1875
1965
|
*/
|
|
1876
1966
|
unread: number;
|
|
1877
1967
|
/**
|
|
1878
|
-
*
|
|
1968
|
+
* 上一条消息.
|
|
1969
|
+
*
|
|
1970
|
+
* 若 lastMsg 为 undefined ,那么可能是从未设置过的,会话不完整。getSessions 将过滤掉此会话
|
|
1971
|
+
*
|
|
1972
|
+
* 若 lastMsg 为 null,lastMsg 为 null 则可能是撤回消息,也可能是清除了这个会话的历史消息
|
|
1879
1973
|
*/
|
|
1880
|
-
lastMsg
|
|
1974
|
+
lastMsg?: IMMessage | null;
|
|
1881
1975
|
/**
|
|
1882
1976
|
* 更新时间
|
|
1883
1977
|
*/
|
|
@@ -3232,6 +3326,38 @@ declare type Relations = {
|
|
|
3232
3326
|
blackList: MarkedUserInfo[];
|
|
3233
3327
|
muteList: MarkedUserInfo[];
|
|
3234
3328
|
};
|
|
3329
|
+
/**
|
|
3330
|
+
* 推送专用,更新并上报厂商推送(APNs、小米推送等)的devicetoken
|
|
3331
|
+
*/
|
|
3332
|
+
declare type UpdatePushTokenOptions = {
|
|
3333
|
+
/**
|
|
3334
|
+
* 证书名
|
|
3335
|
+
*/
|
|
3336
|
+
tokenName: string;
|
|
3337
|
+
/**
|
|
3338
|
+
* 推送 token
|
|
3339
|
+
*/
|
|
3340
|
+
token: string;
|
|
3341
|
+
/**
|
|
3342
|
+
* 推送通道。默认 0,表示 apns 通道
|
|
3343
|
+
*/
|
|
3344
|
+
pushkit: number;
|
|
3345
|
+
};
|
|
3346
|
+
/**
|
|
3347
|
+
* 推送专用
|
|
3348
|
+
*/
|
|
3349
|
+
declare type UpdateAppBackgroundOptions = {
|
|
3350
|
+
/**
|
|
3351
|
+
* app 是否正处在后台。
|
|
3352
|
+
* true 为 app 转入后台运行
|
|
3353
|
+
* false 为 app 切回前台运行
|
|
3354
|
+
*/
|
|
3355
|
+
isBackground: boolean;
|
|
3356
|
+
/**
|
|
3357
|
+
* 未读数(角标数字),只有ios需要传这个参数。
|
|
3358
|
+
*/
|
|
3359
|
+
badge: number;
|
|
3360
|
+
};
|
|
3235
3361
|
|
|
3236
3362
|
interface NIMInterface {
|
|
3237
3363
|
/**
|
|
@@ -3395,7 +3521,7 @@ declare type SyncOptions = {
|
|
|
3395
3521
|
/**
|
|
3396
3522
|
* 是否同步单向删除信息,默认 true
|
|
3397
3523
|
*/
|
|
3398
|
-
|
|
3524
|
+
deleteSelfMsgs?: boolean;
|
|
3399
3525
|
/**
|
|
3400
3526
|
* 是否同步置顶会话信息,默认 false
|
|
3401
3527
|
*/
|
|
@@ -3464,6 +3590,7 @@ declare class MsgService extends Service implements MsgServiceInterface {
|
|
|
3464
3590
|
sendVideoMsg(options: IBaseSendFileOptions$1): Promise<IMMessage>;
|
|
3465
3591
|
private doSendFile;
|
|
3466
3592
|
recallMsg(options: RecallMsgOptions): Promise<IMMessage>;
|
|
3593
|
+
deleteSelfMsgs(options: deleteSelfMsgsOptions): Promise<DeleteSelfMsgsResult[]>;
|
|
3467
3594
|
sendMsgReceipt(options: SendMsgReceiptOptions): Promise<SendMsgReceiptResult | void>;
|
|
3468
3595
|
sendTeamMsgReceipt(options: SendTeamMsgReceiptOptions): Promise<void>;
|
|
3469
3596
|
getTeamMsgReads(options: GetTeamMsgReadsOptions): Promise<GetTeamMsgReadsResult>;
|
|
@@ -3474,6 +3601,9 @@ declare class MsgService extends Service implements MsgServiceInterface {
|
|
|
3474
3601
|
private syncOfflineMsgsHandler;
|
|
3475
3602
|
private onMsgReceiptHandler;
|
|
3476
3603
|
private syncMsgReceiptsHandler;
|
|
3604
|
+
private syncDeleteSelfMsgsHandler;
|
|
3605
|
+
private onDeleteSelfMsgHandler;
|
|
3606
|
+
private onDeleteSelfMsgsHandler;
|
|
3477
3607
|
}
|
|
3478
3608
|
|
|
3479
3609
|
interface MiscServiceInterface {
|
|
@@ -3513,6 +3643,8 @@ declare class UserService extends Service implements UserServiceInterface {
|
|
|
3513
3643
|
getRelations(): Promise<Relations>;
|
|
3514
3644
|
getBlackList(): Promise<MarkedUserInfo[]>;
|
|
3515
3645
|
getMuteList(): Promise<MarkedUserInfo[]>;
|
|
3646
|
+
updatePushToken(options: UpdatePushTokenOptions): Promise<void>;
|
|
3647
|
+
updateAppBackground(options: UpdateAppBackgroundOptions): Promise<void>;
|
|
3516
3648
|
getUsersNameCardFromServer(options: getUsersOptions): Promise<UserNameCard[]>;
|
|
3517
3649
|
updateMyNameCard(options: updateMyInfoOptions): Promise<UserNameCard>;
|
|
3518
3650
|
private onUpdateBlackListHandler;
|
|
@@ -3555,6 +3687,7 @@ declare class SessionService extends Service implements SessionServiceInterface
|
|
|
3555
3687
|
/** 设置当前会话,同时清空其未读数,返回的Promise状态表示未读数是否清空成功 */
|
|
3556
3688
|
/** 收到消息,更新会话 */
|
|
3557
3689
|
private updateSessionWithMsg;
|
|
3690
|
+
/** 收到 msg receipt,更新会话已读计数 */
|
|
3558
3691
|
private updateSessionMsgReceiptTime;
|
|
3559
3692
|
/** 根据ack计算未读数,并存储结果 */
|
|
3560
3693
|
private storeUnreadByAck;
|
|
@@ -3567,6 +3700,8 @@ declare class SessionService extends Service implements SessionServiceInterface
|
|
|
3567
3700
|
onSyncDone(): void;
|
|
3568
3701
|
/** 初始化同步时,收到漫游/离线消息后,会话相关的处理 */
|
|
3569
3702
|
private onSyncMsgs;
|
|
3703
|
+
/** 多端同步/在线时,收到单向删除通知,需要更新会话 */
|
|
3704
|
+
private updateSessionForDeletedMsg;
|
|
3570
3705
|
}
|
|
3571
3706
|
|
|
3572
3707
|
declare class ModuleService$1 {
|
|
@@ -3646,7 +3781,7 @@ declare class SystemMessageService extends Service implements SystemMessageServi
|
|
|
3646
3781
|
private onSysMsgHandler;
|
|
3647
3782
|
private syncOfflineSysMsgsHandler;
|
|
3648
3783
|
private onRecallMsgHandler;
|
|
3649
|
-
private
|
|
3784
|
+
private syncRecallMsgOfflineAndRoamingHandler;
|
|
3650
3785
|
}
|
|
3651
3786
|
|
|
3652
3787
|
declare class FriendService extends Service implements FriendServiceInterface {
|