@onyx-p/imlib-web 1.2.5 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/README.md +14 -0
- package/dist/index.esm.js +33421 -0
- package/dist/index.umd.js +33503 -0
- package/{types → dist/types}/index.d.ts +68 -9
- package/{types → dist/types}/model/baseMessage.d.ts +4 -7
- package/dist/types/model/iQuotedReplyMessage.d.ts +7 -0
- package/{types → dist/types}/model/iReceivedConversation.d.ts +22 -6
- package/{types → dist/types}/model/iReceivedMessage.d.ts +19 -10
- package/dist/types/model/mentionedInfo.d.ts +9 -0
- package/dist/types/model/messages/fileMessage.d.ts +24 -0
- package/dist/types/model/messages/gifMessage.d.ts +27 -0
- package/dist/types/model/messages/imageMessage.d.ts +32 -0
- package/dist/types/model/messages/index.d.ts +12 -0
- package/dist/types/model/messages/notificationMessages.d.ts +20 -0
- package/dist/types/model/messages/otherMediaMessages.d.ts +105 -0
- package/dist/types/model/messages/recallCommandMessage.d.ts +9 -0
- package/dist/types/model/messages/textMessage.d.ts +12 -0
- package/dist/types/model/messages/videoMessage.d.ts +30 -0
- package/dist/types/model/messages/voiceMessage.d.ts +18 -0
- package/{types → dist/types}/model/statusTypes.d.ts +9 -17
- package/{types → dist/types}/types.d.ts +74 -40
- package/package.json +65 -13
- package/index.esm.js +0 -21664
- package/index.umd.js +0 -21721
- package/types/model/mentionedInfo.d.ts +0 -9
- package/types/model/messages/commandMessage.d.ts +0 -20
- package/types/model/messages/custMessage.d.ts +0 -34
- package/types/model/messages/fileMessage.d.ts +0 -25
- package/types/model/messages/gifMessage.d.ts +0 -28
- package/types/model/messages/imageMessage.d.ts +0 -32
- package/types/model/messages/index.d.ts +0 -10
- package/types/model/messages/recallCommandMessage.d.ts +0 -18
- package/types/model/messages/textMessage.d.ts +0 -16
- package/types/model/messages/voiceMessage.d.ts +0 -21
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { BaseMessage, IExtraData, IUserInfo } from './model/baseMessage';
|
|
2
2
|
import IReceivedMessage from './model/iReceivedMessage';
|
|
3
|
-
import { ConnectionStatus, ConversationType, ErrorCode,
|
|
3
|
+
import { ConnectionStatus, ConversationType, ErrorCode, MessageDirection, NotificationLevel, NotificationStatus } from './model/statusTypes';
|
|
4
4
|
import IReceivedConversation from './model/iReceivedConversation';
|
|
5
|
-
import Long from 'long';
|
|
6
5
|
export declare enum LogLevel {
|
|
7
6
|
DEBUG = 0,
|
|
8
7
|
INFO = 1,
|
|
@@ -22,11 +21,14 @@ export type IInitOption = {
|
|
|
22
21
|
*/
|
|
23
22
|
logStdout?: (logLevel: LogLevel, content: string) => void;
|
|
24
23
|
serverInfo?: string;
|
|
24
|
+
uploader?: IUploader;
|
|
25
|
+
deviceCode: string;
|
|
26
|
+
deviceType: number;
|
|
25
27
|
};
|
|
26
28
|
export interface ProfileInfo {
|
|
27
|
-
deviceId:
|
|
28
|
-
sessionId:
|
|
29
|
-
uid:
|
|
29
|
+
deviceId: string;
|
|
30
|
+
sessionId: string;
|
|
31
|
+
uid: string;
|
|
30
32
|
}
|
|
31
33
|
export declare enum Events {
|
|
32
34
|
CONNECTING = "CONNECTING",
|
|
@@ -35,7 +37,25 @@ export declare enum Events {
|
|
|
35
37
|
SUSPEND = "SUSPEND",
|
|
36
38
|
MESSAGES = "MESSAGES",
|
|
37
39
|
PULL_OFFLINE_MESSAGE_FINISHED = "PULL_OFFLINE_MESSAGE_FINISHED",
|
|
38
|
-
CONVERSATION = "CONVERSATION"
|
|
40
|
+
CONVERSATION = "CONVERSATION",
|
|
41
|
+
PUSH = "PUSH",
|
|
42
|
+
RECALL = "RECALL",
|
|
43
|
+
ARRIVAL_RECEIPT_RECEIVED = "ARRIVAL_RECEIPT_RECEIVED",
|
|
44
|
+
READ_RECEIPT_RECEIVED = "READ_RECEIPT_RECEIVED"
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 收到已读/已发送回执数据结构
|
|
48
|
+
* @category Interface
|
|
49
|
+
*/
|
|
50
|
+
export interface IReceiptReceivedEvent {
|
|
51
|
+
/**
|
|
52
|
+
* 会话信息,包含会话属性
|
|
53
|
+
*/
|
|
54
|
+
conversation: IConversationOption;
|
|
55
|
+
/**
|
|
56
|
+
* 消息的id列表
|
|
57
|
+
*/
|
|
58
|
+
messageUIdList: string[];
|
|
39
59
|
}
|
|
40
60
|
export type EventListeners = {
|
|
41
61
|
[Events.CONNECTING]: () => void;
|
|
@@ -49,11 +69,17 @@ export type EventListeners = {
|
|
|
49
69
|
[Events.CONVERSATION]: (event: {
|
|
50
70
|
conversations: IUpdatedConversation[];
|
|
51
71
|
}) => void;
|
|
72
|
+
[Events.PUSH]: (event: {
|
|
73
|
+
cmdId: number;
|
|
74
|
+
body: Uint8Array;
|
|
75
|
+
}) => void;
|
|
76
|
+
[Events.RECALL]: (messageUId: string) => void;
|
|
77
|
+
[Events.ARRIVAL_RECEIPT_RECEIVED]: (event: IReceiptReceivedEvent) => void;
|
|
78
|
+
[Events.READ_RECEIPT_RECEIVED]: (event: IReceiptReceivedEvent) => void;
|
|
52
79
|
};
|
|
53
80
|
export interface IBaseConversationInfo {
|
|
54
81
|
conversationType: ConversationType;
|
|
55
82
|
targetId: string;
|
|
56
|
-
channelId?: string;
|
|
57
83
|
}
|
|
58
84
|
export interface IConversationState extends IBaseConversationInfo {
|
|
59
85
|
unreadCount: number;
|
|
@@ -61,12 +87,15 @@ export interface IConversationState extends IBaseConversationInfo {
|
|
|
61
87
|
notificationLevel: NotificationLevel;
|
|
62
88
|
notificationStatus: NotificationStatus;
|
|
63
89
|
isTop: boolean;
|
|
90
|
+
dialogTitle: string | null | undefined;
|
|
91
|
+
smallAvatarUrl: string | null | undefined;
|
|
92
|
+
updateTime: number | null | undefined;
|
|
64
93
|
}
|
|
65
94
|
/**
|
|
66
95
|
* 会话信息
|
|
67
96
|
*/
|
|
68
97
|
export type IConversationOption = IBaseConversationInfo;
|
|
69
|
-
export type IUpdatedConversationItemKeys = Extract<keyof IReceivedConversation, 'isTop' | 'notificationStatus' | 'notificationLevel' | 'unreadMessageCount' | 'hasMentioned' | 'unreadMentionedCount' | 'latestMessage'>;
|
|
98
|
+
export type IUpdatedConversationItemKeys = Extract<keyof IReceivedConversation, 'isTop' | 'notificationStatus' | 'notificationLevel' | 'unreadMessageCount' | 'hasMentioned' | 'unreadMentionedCount' | 'dialogTitle' | 'smallAvatarUrl' | 'latestMessage' | 'burnAfterReadingFlag' | 'burnAfterReadingTime'>;
|
|
70
99
|
export type IUpdatedConversationItem = Partial<Record<IUpdatedConversationItemKeys, {
|
|
71
100
|
time: number;
|
|
72
101
|
val: any;
|
|
@@ -105,20 +134,16 @@ export type IPushConfig = {
|
|
|
105
134
|
* 发送消息时的可选项信息
|
|
106
135
|
*/
|
|
107
136
|
export interface ISendMessageOptions {
|
|
108
|
-
/**
|
|
109
|
-
* 用于发送群定向消息,只当 conversationType 值为 `ConversationType.GROUP` 时有效
|
|
110
|
-
*/
|
|
111
|
-
directionalUserIdList?: string[];
|
|
112
137
|
/**
|
|
113
138
|
* 消息发送之前的回调
|
|
114
139
|
*/
|
|
115
|
-
onSendBefore?: (message: IReceivedMessage) => void;
|
|
140
|
+
onSendBefore?: (message: IReceivedMessage, uploadOptions?: IUploadMessageParams) => void;
|
|
116
141
|
/**
|
|
117
142
|
* 重发消息时用到,重发消息的 messageId。
|
|
118
143
|
* 当要重发消息时所有参数需与原始消息参数一致,messageId 必须存在。
|
|
119
144
|
* 正常发消息时无需传该参数。
|
|
120
145
|
*/
|
|
121
|
-
messageId?:
|
|
146
|
+
messageId?: string;
|
|
122
147
|
/**
|
|
123
148
|
* 推送配置,用于配置移动端远程推送的推送栏显示内容
|
|
124
149
|
*/
|
|
@@ -141,14 +166,35 @@ export interface IUploadHooks {
|
|
|
141
166
|
/**
|
|
142
167
|
* 文件上传完成回调,可通过修改返回值以修改待发布的消息内容,如实现自定义消息
|
|
143
168
|
*/
|
|
144
|
-
onComplete?: (
|
|
169
|
+
onComplete?: (result: IUploadCompletedResult) => void | BaseMessage;
|
|
170
|
+
}
|
|
171
|
+
export interface IUploadMessageParams {
|
|
172
|
+
items: {
|
|
145
173
|
url: string;
|
|
146
|
-
|
|
174
|
+
file: Blob;
|
|
175
|
+
}[];
|
|
176
|
+
encryptKey: string;
|
|
177
|
+
}
|
|
178
|
+
export type IUploadPrepareResult = IUploadMessageParams;
|
|
179
|
+
export type IUploadCompletedResult = {
|
|
180
|
+
urls: string[];
|
|
181
|
+
encryptedKey: string;
|
|
182
|
+
};
|
|
183
|
+
export type IUploadCallback = {
|
|
184
|
+
onProgress?: (progress: number) => void;
|
|
185
|
+
onCompleted?: (result: IUploadCompletedResult) => void;
|
|
186
|
+
onError?: (reason: string) => void;
|
|
187
|
+
};
|
|
188
|
+
export interface IUploader {
|
|
189
|
+
upload(params: IUploadMessageParams, callback: IUploadCallback): void;
|
|
190
|
+
cancel(): void;
|
|
191
|
+
prepare(files: Blob[]): Promise<IUploadPrepareResult>;
|
|
147
192
|
}
|
|
148
193
|
/**
|
|
149
194
|
* 文件消息配置
|
|
150
195
|
*/
|
|
151
196
|
export interface IUploadMessageOption extends ISendMessageOptions {
|
|
197
|
+
full?: boolean;
|
|
152
198
|
}
|
|
153
199
|
/**
|
|
154
200
|
* 图片消息配置
|
|
@@ -156,6 +202,12 @@ export interface IUploadMessageOption extends ISendMessageOptions {
|
|
|
156
202
|
export interface IImageMessageOption extends IUploadMessageOption {
|
|
157
203
|
thumbnailConfig?: IThumbnailConfig;
|
|
158
204
|
}
|
|
205
|
+
export interface IInsertOptions {
|
|
206
|
+
/**
|
|
207
|
+
* 插入消息是否计入未读数: true 计数 false 不计数, 默认不计数
|
|
208
|
+
*/
|
|
209
|
+
isUnread?: boolean;
|
|
210
|
+
}
|
|
159
211
|
/**
|
|
160
212
|
* 缩略图配置
|
|
161
213
|
*/
|
|
@@ -170,31 +222,9 @@ export interface IThumbnailConfig {
|
|
|
170
222
|
*/
|
|
171
223
|
export interface IRecallMessageOptions {
|
|
172
224
|
/**
|
|
173
|
-
* 消息的唯一id
|
|
225
|
+
* 消息的唯一id,服务端依赖此属性删除要撤回的消息
|
|
174
226
|
*/
|
|
175
227
|
messageUId: string;
|
|
176
|
-
/**
|
|
177
|
-
* 消息发送时间,服务端依赖此属性查找要撤回的消息
|
|
178
|
-
*/
|
|
179
|
-
sentTime: number;
|
|
180
|
-
/**
|
|
181
|
-
* 撤回消息携带用户信息
|
|
182
|
-
*/
|
|
183
|
-
user?: IUserProfile;
|
|
184
|
-
/**
|
|
185
|
-
* 是否发送静默消息
|
|
186
|
-
* @description
|
|
187
|
-
* 当值为 `true` 时,服务器将不会发送 Push 信息,移动端也不会弹出本地通知提醒
|
|
188
|
-
*/
|
|
189
|
-
disableNotification?: boolean;
|
|
190
|
-
/**
|
|
191
|
-
* 撤回消息携带扩展信息
|
|
192
|
-
*/
|
|
193
|
-
extra?: string;
|
|
194
|
-
/**
|
|
195
|
-
* 是否删除原始消息(在移动端会使用到),为 true 时移动端会不显示小灰条提示
|
|
196
|
-
*/
|
|
197
|
-
isDelete?: boolean;
|
|
198
228
|
}
|
|
199
229
|
/**
|
|
200
230
|
* 获取远程消息 option 参数
|
|
@@ -203,7 +233,7 @@ export type GetHistoryMessageOption = {
|
|
|
203
233
|
/**
|
|
204
234
|
* 获取此时间之前的消息,0 为从当前时间拉取
|
|
205
235
|
*/
|
|
206
|
-
timestamp?:
|
|
236
|
+
timestamp?: string;
|
|
207
237
|
/**
|
|
208
238
|
* 获取消息的数量,范围: 1-20
|
|
209
239
|
*/
|
|
@@ -281,3 +311,7 @@ export interface IAsyncRes<T = any> {
|
|
|
281
311
|
* 通过 `Promise.resolve` 来处理预期内的异常,进而通过 Uncatch Promise Error 暴露预期外的异常
|
|
282
312
|
*/
|
|
283
313
|
export type IPromiseResult<T> = Promise<IAsyncRes<T>>;
|
|
314
|
+
export interface ISenderEnrichedMessage extends IReceivedMessage {
|
|
315
|
+
senderNickname: string;
|
|
316
|
+
senderAvatar?: string | null | undefined;
|
|
317
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onyx-p/imlib-web",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"main": "index.umd.js",
|
|
5
|
-
"module": "index.esm.js",
|
|
6
|
-
"types": "types/index.d.ts",
|
|
3
|
+
"version": "1.2.7",
|
|
4
|
+
"main": "./dist/index.umd.js",
|
|
5
|
+
"module": "./dist/index.esm.js",
|
|
6
|
+
"types": "./dist/types/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"clean:dist": "rimraf dist",
|
|
9
|
+
"build:types": "npm run clean:dist && tsc -b ./tsconfig.types.json",
|
|
10
|
+
"build": "npm run build:types && rollup -c --bundleConfigAsCjs && node scripts/prepare-publish.js",
|
|
11
|
+
"dev": "npm run clean:dist && rollup -c --bundleConfigAsCjs",
|
|
12
|
+
"test": "node test/test.js"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@babel/core": "^7.26.0",
|
|
17
|
+
"@babel/plugin-transform-runtime": "^7.25.9",
|
|
18
|
+
"@babel/preset-env": "^7.26.0",
|
|
19
|
+
"@babel/runtime-corejs3": "^7.26.0",
|
|
20
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
21
|
+
"@rollup/plugin-commonjs": "^28.0.2",
|
|
22
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
23
|
+
"@types/crypto-js": "^4.2.2",
|
|
24
|
+
"@types/node": "^22.10.2",
|
|
25
|
+
"electron": "^30.0.0",
|
|
26
|
+
"eslint": "^9.17.0",
|
|
27
|
+
"eslint-config-prettier": "^9.1.0",
|
|
28
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
29
|
+
"prettier": "^3.4.2",
|
|
30
|
+
"rollup": "^3.28.0",
|
|
31
|
+
"rollup-plugin-bundle-size": "^1.0.3",
|
|
32
|
+
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
33
|
+
"rollup-plugin-re": "^1.0.7",
|
|
34
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
35
|
+
"rollup-plugin-visualizer": "^5.12.0",
|
|
36
|
+
"tslib": "^2.8.1",
|
|
37
|
+
"typescript": "^5.7.2"
|
|
38
|
+
},
|
|
7
39
|
"files": [
|
|
8
|
-
"index.umd.js",
|
|
9
|
-
"index.esm.js",
|
|
10
|
-
"types/index.d.ts",
|
|
11
|
-
"types/types.d.ts",
|
|
12
|
-
"types/model",
|
|
40
|
+
"dist/index.umd.js",
|
|
41
|
+
"dist/index.esm.js",
|
|
42
|
+
"dist/types/index.d.ts",
|
|
43
|
+
"dist/types/types.d.ts",
|
|
44
|
+
"dist/types/model",
|
|
13
45
|
"README.md"
|
|
14
46
|
],
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"crypto-js": "^4.2.0",
|
|
49
|
+
"electron-store": "^10.0.1",
|
|
50
|
+
"long": "^5.2.3",
|
|
51
|
+
"protobufjs": "^7.4.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"electron": ">=10.0.0"
|
|
55
|
+
},
|
|
56
|
+
"description": "",
|
|
57
|
+
"directories": {
|
|
58
|
+
"example": "examples",
|
|
59
|
+
"lib": "lib",
|
|
60
|
+
"test": "test"
|
|
61
|
+
},
|
|
62
|
+
"repository": {
|
|
63
|
+
"type": "git",
|
|
64
|
+
"url": ""
|
|
65
|
+
},
|
|
66
|
+
"keywords": [
|
|
67
|
+
"im"
|
|
68
|
+
],
|
|
69
|
+
"author": "zimu"
|
|
70
|
+
}
|