@onyx-p/imlib-web 3.0.4 → 3.0.6
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 +2 -1
- package/database/main.cjs +38 -0
- package/database/preload.cjs +2 -0
- package/database/worker.cjs +385 -39
- package/index.esm.js +4 -4
- package/index.umd.js +4 -4
- package/package.json +1 -1
- package/types/constants/messageTypes.d.ts +6 -0
- package/types/database/contracts.d.ts +5 -2
- package/types/database/legacyMediaReferences.d.ts +21 -0
- package/types/database/main/ipc.d.ts +1 -0
- package/types/database/main/keyStore.d.ts +1 -0
- package/types/database/main/messageStore.d.ts +21 -1
- package/types/database/main/service.d.ts +1 -0
- package/types/database/renderer/legacyIndexedDbMigration.d.ts +15 -2
- package/types/database/renderer/messageRepository.d.ts +22 -2
- package/types/index.d.ts +47 -7
- package/types/model/iReceivedMessage.d.ts +13 -0
- package/types/model/messages/index.d.ts +2 -2
- package/types/model/messages/notificationMessages.d.ts +16 -1
- package/types/model/messages/otherMediaMessages.d.ts +2 -1
- package/types/model/messages/textMessage.d.ts +2 -0
- package/types/types.d.ts +48 -1
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ export declare const MessageTypes: {
|
|
|
6
6
|
AUDIO: number;
|
|
7
7
|
VIDEO: number;
|
|
8
8
|
RECALL: number;
|
|
9
|
+
STORED_RECALL: number;
|
|
9
10
|
LOCATION: number;
|
|
10
11
|
CHAT_RECORD: number;
|
|
11
12
|
CONTACT: number;
|
|
@@ -14,6 +15,8 @@ export declare const MessageTypes: {
|
|
|
14
15
|
TRANSFER: number;
|
|
15
16
|
LINK: number;
|
|
16
17
|
};
|
|
18
|
+
export declare const WIRE_PRIVATE_RECALL = 1610678290;
|
|
19
|
+
export declare const WIRE_GROUP_RECALL = 1610743841;
|
|
17
20
|
export declare const NotiMessageTypes: {
|
|
18
21
|
GROUP_ARRIVAL_RECEIPT: number;
|
|
19
22
|
GROUP_READ_RECEIPT: number;
|
|
@@ -28,4 +31,7 @@ export declare const NotiMessageTypes: {
|
|
|
28
31
|
CHANGE_GROUP_AVATAR: number;
|
|
29
32
|
PRIVATE_MESSAGE_PINNED: number;
|
|
30
33
|
GROUP_MESSAGE_PINNED: number;
|
|
34
|
+
CHAT_COMMENT: number;
|
|
31
35
|
};
|
|
36
|
+
export declare function isRecallMessageType(messageType: number): boolean;
|
|
37
|
+
export declare function remapIncomingRecallConstructor(mediaConstructor: number): number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const DATABASE_GLOBAL: "acimDatabase";
|
|
2
2
|
export declare const DATABASE_CHANNEL: "acim-database:request";
|
|
3
|
-
export declare const READ_METHOD_NAMES: readonly ["getMessages", "getLatestMessage", "getLatestMessages", "getDialogLoadedState", "getMessageById", "getMessageByUId", "getMessageIdRange", "getMessagesByType", "getPinnedMessages", "searchMessages", "searchTextMessages", "getLegacyMigrationState"];
|
|
4
|
-
export declare const WRITE_METHOD_NAMES: readonly ["addMessages", "clearConversationCache", "clearAllCache", "removeMessagesByUId", "updateMessageReceiptStatus", "setMessagePinned", "unpinAllMessages", "clearBurnAfterReadingExpiredMessages", "upsertMessage", "convertToRecallMessages", "importLegacyBatch", "completeLegacyMigration"];
|
|
3
|
+
export declare const READ_METHOD_NAMES: readonly ["getMessages", "getLatestMessage", "getLatestMessages", "getDialogLoadedState", "getMessageById", "getMessageByUId", "getMessageIdRange", "getMessagesByType", "getPinnedMessages", "searchMessages", "searchTextMessages", "getLegacyMediaReferences", "getLegacyMigrationState"];
|
|
4
|
+
export declare const WRITE_METHOD_NAMES: readonly ["addMessages", "clearConversationCache", "clearAllCache", "removeMessagesByUId", "updateMessageReceiptStatus", "setMessagePinned", "setMessageReactions", "unpinAllMessages", "clearBurnAfterReadingExpiredMessages", "upsertMessage", "convertToRecallMessages", "importLegacyBatch", "completeLegacyMigration"];
|
|
5
5
|
export type DatabaseReadMethod = (typeof READ_METHOD_NAMES)[number];
|
|
6
6
|
export type DatabaseWriteMethod = (typeof WRITE_METHOD_NAMES)[number];
|
|
7
7
|
export type DatabaseMethod = DatabaseReadMethod | DatabaseWriteMethod;
|
|
@@ -17,6 +17,9 @@ export type DatabaseRequest = Readonly<{
|
|
|
17
17
|
options: DatabaseOpenOptions;
|
|
18
18
|
}> | Readonly<{
|
|
19
19
|
type: 'close';
|
|
20
|
+
}> | Readonly<{
|
|
21
|
+
type: 'delete';
|
|
22
|
+
options: DatabaseOpenOptions;
|
|
20
23
|
}> | Readonly<{
|
|
21
24
|
type: 'read';
|
|
22
25
|
method: DatabaseReadMethod;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type LegacyMediaKind = 'image' | 'image-thumbnail' | 'gif' | 'video' | 'video-thumbnail' | 'file' | 'audio';
|
|
2
|
+
export type LegacyMediaReference = Readonly<{
|
|
3
|
+
messageId: number;
|
|
4
|
+
conversationType: number;
|
|
5
|
+
targetId: string;
|
|
6
|
+
objectKey: string;
|
|
7
|
+
kind: LegacyMediaKind;
|
|
8
|
+
}>;
|
|
9
|
+
export type LegacyMediaReferencePage = Readonly<{
|
|
10
|
+
items: ReadonlyArray<LegacyMediaReference>;
|
|
11
|
+
nextCursor?: number;
|
|
12
|
+
}>;
|
|
13
|
+
type LegacyMessageLike = Readonly<{
|
|
14
|
+
messageId: number;
|
|
15
|
+
conversationType?: number;
|
|
16
|
+
targetId?: string;
|
|
17
|
+
messageType?: number;
|
|
18
|
+
content?: Record<string, unknown> | null;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function extractLegacyMediaReferences(message: LegacyMessageLike): ReadonlyArray<LegacyMediaReference>;
|
|
21
|
+
export {};
|
|
@@ -6,6 +6,7 @@ export interface DatabaseIpcMain {
|
|
|
6
6
|
export interface DatabaseServiceLike {
|
|
7
7
|
open(options: DatabaseOpenOptions): Promise<void>;
|
|
8
8
|
close(): Promise<void>;
|
|
9
|
+
deleteAccount(options: DatabaseOpenOptions): Promise<void>;
|
|
9
10
|
read(method: DatabaseReadMethod, args: ReadonlyArray<unknown>): Promise<unknown>;
|
|
10
11
|
write(method: DatabaseWriteMethod, args: ReadonlyArray<unknown>): Promise<unknown>;
|
|
11
12
|
}
|
|
@@ -8,6 +8,7 @@ export declare class DatabaseKeyStore {
|
|
|
8
8
|
private readonly filePath;
|
|
9
9
|
constructor(directory: string, safeStorage: SafeStorageAdapter);
|
|
10
10
|
getOrCreate(accountId: string): string;
|
|
11
|
+
remove(accountId: string): void;
|
|
11
12
|
private readKeys;
|
|
12
13
|
private writeKeys;
|
|
13
14
|
private validateKey;
|
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import type { LegacyMigrationState } from '../contracts';
|
|
2
|
+
import { type LegacyMediaReferencePage } from '../legacyMediaReferences';
|
|
2
3
|
import type { SqlDatabase } from './sqlTypes';
|
|
3
4
|
export type StoredMessage = {
|
|
4
5
|
messageId: number;
|
|
5
6
|
messageUId?: string;
|
|
7
|
+
conversationType?: number;
|
|
8
|
+
targetId?: string;
|
|
6
9
|
sentTime: string;
|
|
7
10
|
content?: any;
|
|
8
11
|
quotedReply?: any;
|
|
9
12
|
receivedStatus?: number;
|
|
10
13
|
burnAfterReadingFlag?: boolean;
|
|
11
14
|
burnAfterReadingTime?: number;
|
|
15
|
+
burnAfterReadingStartedAt?: number;
|
|
12
16
|
messageType?: number;
|
|
13
17
|
isPersited?: boolean;
|
|
18
|
+
pinned?: boolean;
|
|
19
|
+
reactions?: ReadonlyArray<{
|
|
20
|
+
uid: string;
|
|
21
|
+
msgId: string;
|
|
22
|
+
content: string;
|
|
23
|
+
nickname: string;
|
|
24
|
+
time: number;
|
|
25
|
+
}>;
|
|
14
26
|
[key: string]: any;
|
|
15
27
|
};
|
|
16
28
|
export type DialogState = Readonly<{
|
|
@@ -50,13 +62,21 @@ export declare class MessageStore {
|
|
|
50
62
|
clearConversationCache(dialogId: string): void;
|
|
51
63
|
clearAllCache(): void;
|
|
52
64
|
removeMessagesByUId(messageUIds: ReadonlyArray<string>): void;
|
|
53
|
-
updateMessageReceiptStatus(messageUIds: ReadonlyArray<string>, receivedStatus: number): void;
|
|
65
|
+
updateMessageReceiptStatus(messageUIds: ReadonlyArray<string>, receivedStatus: number, burnAfterReadingStartedAt?: number): void;
|
|
54
66
|
setMessagePinned(dialogId: string, messageUId: string, pinned: boolean): void;
|
|
67
|
+
setMessageReactions(dialogId: string, messageUId: string, reactions: ReadonlyArray<{
|
|
68
|
+
uid: string;
|
|
69
|
+
msgId: string;
|
|
70
|
+
content: string;
|
|
71
|
+
nickname: string;
|
|
72
|
+
time: number;
|
|
73
|
+
}>): boolean;
|
|
55
74
|
unpinAllMessages(dialogId: string): void;
|
|
56
75
|
clearBurnAfterReadingExpiredMessages(dialogId: string, now?: number): string[];
|
|
57
76
|
convertToRecallMessages(messageUIds: ReadonlyArray<string>, recallMessageType: number): void;
|
|
58
77
|
searchTextMessages(dialogId: string, keyword: string): StoredMessage[];
|
|
59
78
|
searchMessages(keyword: string, dialogId?: string, limit?: number): StoredMessage[];
|
|
79
|
+
getLegacyMediaReferences(afterMessageId?: number, limit?: number): LegacyMediaReferencePage;
|
|
60
80
|
getLegacyMigrationState(): LegacyMigrationState;
|
|
61
81
|
importLegacyBatch(batch: LegacyImportBatch): void;
|
|
62
82
|
completeLegacyMigration(): void;
|
|
@@ -23,6 +23,7 @@ export declare class MainDatabaseService {
|
|
|
23
23
|
read(method: DatabaseReadMethod, args: ReadonlyArray<unknown>): Promise<unknown>;
|
|
24
24
|
write(method: DatabaseWriteMethod, args: ReadonlyArray<unknown>): Promise<unknown>;
|
|
25
25
|
close(): Promise<void>;
|
|
26
|
+
deleteAccount(options: DatabaseOpenOptions): Promise<void>;
|
|
26
27
|
private assertOpen;
|
|
27
28
|
}
|
|
28
29
|
export declare class ThreadWorkerClient implements DatabaseWorkerClient {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import CryptoJS from 'crypto-js';
|
|
2
|
-
import type { DatabaseBridge } from '../contracts';
|
|
2
|
+
import type { DatabaseBridge, LegacyMigrationState } from '../contracts';
|
|
3
3
|
type LegacySecret = {
|
|
4
4
|
key: string;
|
|
5
5
|
iv: string;
|
|
@@ -13,7 +13,13 @@ export type LegacyMigrationResult = Readonly<{
|
|
|
13
13
|
messages: number;
|
|
14
14
|
dialogStates: number;
|
|
15
15
|
}>;
|
|
16
|
-
type
|
|
16
|
+
export type LegacyMigrationInfo = Readonly<{
|
|
17
|
+
state: LegacyMigrationState;
|
|
18
|
+
exists: boolean;
|
|
19
|
+
totalMessages: number;
|
|
20
|
+
totalDialogStates: number;
|
|
21
|
+
}>;
|
|
22
|
+
export type MigrationOptions = Readonly<{
|
|
17
23
|
appKey: string;
|
|
18
24
|
userId: string;
|
|
19
25
|
bridge: DatabaseBridge;
|
|
@@ -22,7 +28,14 @@ type MigrationOptions = Readonly<{
|
|
|
22
28
|
batchSize?: number;
|
|
23
29
|
onProgress?: (progress: LegacyMigrationProgress) => void;
|
|
24
30
|
}>;
|
|
31
|
+
export type DeleteLegacyOptions = Readonly<{
|
|
32
|
+
appKey: string;
|
|
33
|
+
userId: string;
|
|
34
|
+
indexedDBFactory?: IDBFactory;
|
|
35
|
+
}>;
|
|
25
36
|
export declare function deriveLegacyEncryptionKey(appKey: string, userId: string): LegacySecret;
|
|
26
37
|
export declare function decryptLegacyMessage<T extends Record<string, any>>(source: T, secret: LegacySecret, crypto?: typeof CryptoJS): T;
|
|
38
|
+
export declare function inspectLegacyIndexedDb({ appKey, userId, bridge, indexedDBFactory }: Pick<MigrationOptions, 'appKey' | 'userId' | 'bridge' | 'indexedDBFactory'>): Promise<LegacyMigrationInfo>;
|
|
39
|
+
export declare function deleteLegacyIndexedDb({ appKey, userId, indexedDBFactory }: DeleteLegacyOptions): Promise<void>;
|
|
27
40
|
export declare function migrateLegacyIndexedDb({ appKey, userId, bridge, indexedDBFactory, keyRange, batchSize, onProgress }: MigrationOptions): Promise<LegacyMigrationResult>;
|
|
28
41
|
export {};
|
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
import type IReceivedMessage from '../../model/iReceivedMessage';
|
|
2
2
|
import type { IConversationOption, IReceiptReceivedEvent } from '../../types';
|
|
3
3
|
import type { DatabaseBridge } from '../contracts';
|
|
4
|
-
import { type LegacyMigrationProgress, type LegacyMigrationResult } from './legacyIndexedDbMigration';
|
|
4
|
+
import { type LegacyMigrationInfo, type LegacyMigrationProgress, type LegacyMigrationResult } from './legacyIndexedDbMigration';
|
|
5
|
+
import type { LegacyMediaReferencePage } from '../legacyMediaReferences';
|
|
6
|
+
export type SqlMessageRepositoryOptions = Readonly<{
|
|
7
|
+
legacyMigrationMode?: 'automatic' | 'manual';
|
|
8
|
+
indexedDBFactory?: IDBFactory;
|
|
9
|
+
keyRange?: typeof IDBKeyRange;
|
|
10
|
+
}>;
|
|
5
11
|
export declare class SqlMessageRepository {
|
|
6
12
|
private readonly appKey;
|
|
7
13
|
private readonly userId;
|
|
8
14
|
private readonly bridge;
|
|
15
|
+
private readonly options;
|
|
9
16
|
private initialization;
|
|
10
|
-
constructor(appKey: string, userId: string, bridge?: DatabaseBridge);
|
|
17
|
+
constructor(appKey: string, userId: string, bridge?: DatabaseBridge, options?: SqlMessageRepositoryOptions);
|
|
11
18
|
initDB(): Promise<void>;
|
|
12
19
|
migrateLegacyDatabase(onProgress?: (progress: LegacyMigrationProgress) => void): Promise<LegacyMigrationResult>;
|
|
20
|
+
getLegacyMigrationInfo(): Promise<LegacyMigrationInfo>;
|
|
21
|
+
getLegacyMediaReferences(afterMessageId?: number, limit?: number): Promise<LegacyMediaReferencePage>;
|
|
22
|
+
deleteLegacyDatabase(): Promise<void>;
|
|
13
23
|
close(): Promise<void>;
|
|
24
|
+
deleteDatabase(): Promise<void>;
|
|
14
25
|
addMessages(messages: IReceivedMessage[], conversation: IConversationOption, isEnd?: boolean): Promise<void>;
|
|
15
26
|
getMessages(conversation: IConversationOption, timestamp?: string, count?: number, isForward?: boolean): Promise<{
|
|
16
27
|
messages: IReceivedMessage[];
|
|
@@ -38,13 +49,22 @@ export declare class SqlMessageRepository {
|
|
|
38
49
|
clearAllCache(): Promise<void>;
|
|
39
50
|
removeMessagesByUId(messageUIds: string[]): Promise<void>;
|
|
40
51
|
updateMessageReceiptStatus(event: IReceiptReceivedEvent, type: 0 | 1): Promise<void>;
|
|
52
|
+
markMessagesRead(messageUIds: ReadonlyArray<string>, readAt: number): Promise<void>;
|
|
41
53
|
setMessagePinned(conversation: IConversationOption, messageUId: string, pinned: boolean): Promise<void>;
|
|
54
|
+
setMessageReactions(conversation: IConversationOption, messageUId: string, reactions: ReadonlyArray<{
|
|
55
|
+
uid: string;
|
|
56
|
+
msgId: string;
|
|
57
|
+
content: string;
|
|
58
|
+
nickname: string;
|
|
59
|
+
time: number;
|
|
60
|
+
}>): Promise<boolean>;
|
|
42
61
|
unpinAllMessages(conversation: IConversationOption): Promise<void>;
|
|
43
62
|
clearBurnAfterReadingExpiredMessages(conversation: IConversationOption): Promise<string[]>;
|
|
44
63
|
upsertMessage(message: IReceivedMessage): Promise<void>;
|
|
45
64
|
convertToRecallMessages(messageUIds: string[]): Promise<void>;
|
|
46
65
|
searchTextMessages(conversation: IConversationOption, keyword: string): Promise<IReceivedMessage[]>;
|
|
47
66
|
searchMessages(keyword: string, limit?: number): Promise<IReceivedMessage[]>;
|
|
67
|
+
private migrationOptions;
|
|
48
68
|
private read;
|
|
49
69
|
private write;
|
|
50
70
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { ConnectionStatus, ConversationType, NotificationLevel, NotificationStatus } from './model/statusTypes';
|
|
2
|
-
import { EventListeners, Events, GetHistoryMessageOption, GetHistoryMessageResult, IAsyncRes, IBaseConversationInfo, IConversationOption, IConversationState, IDeleteMessageOptions, IGetConversationListOptions, IImageMessageOption, IInitOption, IPromiseResult, IRecallMessageOptions, ISendBody, ISenderEnrichedMessage, ISendMessageOptions, IUploadHooks, IUploadMessageOption, ProfileInfo, IInsertOptions } from './types';
|
|
2
|
+
import { EventListeners, Events, GetHistoryMessageOption, GetHistoryMessageResult, IAsyncRes, IBaseConversationInfo, IConversationOption, IConversationState, IDeleteMessageOptions, IGetConversationListOptions, IImageMessageOption, IInitOption, IPromiseResult, IRecallMessageOptions, ICommentMessageOptions, ISendBody, ISenderEnrichedMessage, ISendMessageOptions, IUploadHooks, IUploadMessageOption, ProfileInfo, IInsertOptions, MessagePinnedScope } from './types';
|
|
3
3
|
import { BaseMessage, IBaseMessageBody } from './model/baseMessage';
|
|
4
4
|
import { ITextMessageBody } from './model/messages/textMessage';
|
|
5
5
|
import IReceivedMessage from './model/iReceivedMessage';
|
|
6
|
+
import type { IMessageReaction } from './core/messageReactions';
|
|
6
7
|
import IReceivedConversation from './model/iReceivedConversation';
|
|
7
8
|
import { CommonReqResult, PBCodec } from './net/connection/webSocketServer';
|
|
8
9
|
import { BaseResp } from './net/pbs/rpc.base';
|
|
9
10
|
import { IChatRecordMsgDetail } from './model/messages/otherMediaMessages';
|
|
10
|
-
import type { LegacyMigrationProgress, LegacyMigrationResult } from './database/renderer/legacyIndexedDbMigration';
|
|
11
|
+
import type { LegacyMigrationInfo, LegacyMigrationProgress, LegacyMigrationResult } from './database/renderer/legacyIndexedDbMigration';
|
|
12
|
+
import type { LegacyMediaReferencePage } from './database/legacyMediaReferences';
|
|
13
|
+
import type { DialogFilterConfig } from './net/pbs/dialogFilter';
|
|
11
14
|
export { TextMessage, ImageMessage, HQVoiceMessage, GIFMessage, FileMessage, VideoMessage, RecallCommandMessage, LocationMessage, ChatRecordMessage, ContactMessage, InvitationMessage, RedEnvelopeMessage, TransferMessage, LinkMessage, PrivateOpenBurnAfterReadingMessage, PrivateCloseBurnAfterReadingMessage, GroupOpenBurnAfterReadingMessage, GroupCloseBurnAfterReadingMessage, PrivateMessagePinnedNotification, GroupMessagePinnedNotification } from './model/messages';
|
|
12
|
-
export type { ITextMessageBody, ITextMessageEntity, ITextMessageLinkPreview, ITextMessageStyleAttribute, TextMessageEntityType, IImageMessageBody, IGIFMessageBody, IFileMessageBody, IHQVoiceMessageBody, IRecallCommandMessageBody, IVideoMessageBody, ILocationMessageBody, IChatRecordMessageBody, IContactMessageBody, IInvitationMessageBody, IRedEnvelopeMessageBody, ITransferMessageBody, IBurnAfterReadingMessageBody, IMessagePinnedNotificationBody, ILinkMessageBody } from './model/messages';
|
|
13
|
-
export { MessageTypes, NotiMessageTypes } from './constants/messageTypes';
|
|
15
|
+
export type { ITextMessageBody, ITextMessageEntity, ITextMessageLinkPreview, ITextMessageStyleAttribute, TextMessageEntityType, IImageMessageBody, IGIFMessageBody, IFileMessageBody, IHQVoiceMessageBody, IRecallCommandMessageBody, IVideoMessageBody, ILocationMessageBody, IChatRecordMessageBody, IChatRecordMsgDetail, IContactMessageBody, IInvitationMessageBody, IRedEnvelopeMessageBody, ITransferMessageBody, IBurnAfterReadingMessageBody, IMessagePinnedNotificationBody, ILinkMessageBody } from './model/messages';
|
|
16
|
+
export { isRecallMessageType, MessageTypes, NotiMessageTypes, remapIncomingRecallConstructor } from './constants/messageTypes';
|
|
14
17
|
export type { IBaseMessageBody, IReceivedMessage, IReceivedConversation };
|
|
15
18
|
export * from './types';
|
|
16
19
|
export * from './model/statusTypes';
|
|
20
|
+
export type { DialogFilter, DialogFilterConfig } from './net/pbs/dialogFilter';
|
|
21
|
+
export type { LegacyMigrationInfo, LegacyMigrationProgress, LegacyMigrationResult } from './database/renderer/legacyIndexedDbMigration';
|
|
22
|
+
export type { LegacyMediaKind, LegacyMediaReference, LegacyMediaReferencePage } from './database/legacyMediaReferences';
|
|
17
23
|
/**
|
|
18
24
|
* 初始化
|
|
19
25
|
* @param initOption
|
|
@@ -24,6 +30,9 @@ export declare const init: (initOption: IInitOption) => void;
|
|
|
24
30
|
* Migration also runs automatically when the current user's database opens.
|
|
25
31
|
*/
|
|
26
32
|
export declare const migrateLegacyDatabase: (onProgress?: (progress: LegacyMigrationProgress) => void) => Promise<LegacyMigrationResult>;
|
|
33
|
+
export declare const getLegacyMigrationInfo: () => Promise<LegacyMigrationInfo>;
|
|
34
|
+
export declare const getLegacyMediaReferences: (afterMessageId?: number, limit?: number) => Promise<LegacyMediaReferencePage>;
|
|
35
|
+
export declare const deleteLegacyDatabase: () => Promise<void>;
|
|
27
36
|
/**
|
|
28
37
|
* 建立 IM 连接
|
|
29
38
|
* @param token
|
|
@@ -36,6 +45,7 @@ export declare const connect: () => IPromiseResult<void>;
|
|
|
36
45
|
export declare const disconnect: () => Promise<void>;
|
|
37
46
|
export declare const setUserLogged: (info: ProfileInfo) => Promise<void>;
|
|
38
47
|
export declare const logOut: () => Promise<void>;
|
|
48
|
+
export declare const deleteLocalDatabase: (userId: string) => Promise<void>;
|
|
39
49
|
/**
|
|
40
50
|
* 获取 IM 连接状态
|
|
41
51
|
*/
|
|
@@ -65,6 +75,7 @@ export declare function onceEventListener<T extends Events>(eventType: T, listen
|
|
|
65
75
|
* 移除事件
|
|
66
76
|
*/
|
|
67
77
|
export declare const removeEventListener: <T extends Events>(eventType: T, listener: EventListeners[T], target?: any) => void;
|
|
78
|
+
export declare const getCachedDialogFilterConfig: () => DialogFilterConfig;
|
|
68
79
|
/**
|
|
69
80
|
* 获取会话列表
|
|
70
81
|
* @param options
|
|
@@ -168,6 +179,13 @@ export declare const getBlockedConversationList: () => IPromiseResult<IBaseConve
|
|
|
168
179
|
* 设置会话是否置顶
|
|
169
180
|
*/
|
|
170
181
|
export declare const setConversationToTop: (options: IConversationOption, isTop?: boolean) => IPromiseResult<void>;
|
|
182
|
+
/**
|
|
183
|
+
* 设置会话阅后即焚。
|
|
184
|
+
* @param conversation 会话
|
|
185
|
+
* @param enabled 是否开启
|
|
186
|
+
* @param burnAfterReadingTime 消息已读后的保留时长(毫秒);开启时 0 表示即刻焚烧
|
|
187
|
+
*/
|
|
188
|
+
export declare const setConversationBurnAfterReading: (conversation: IConversationOption, enabled: boolean, burnAfterReadingTime?: number) => IPromiseResult<void>;
|
|
171
189
|
/**
|
|
172
190
|
* 获取置顶会话
|
|
173
191
|
*/
|
|
@@ -187,6 +205,12 @@ export declare const insertMessage: (conversation: IConversationOption, content:
|
|
|
187
205
|
* @param options
|
|
188
206
|
*/
|
|
189
207
|
export declare const sendMessage: (conversation: IConversationOption, message: BaseMessage, options?: ISendMessageOptions) => IPromiseResult<IReceivedMessage>;
|
|
208
|
+
/**
|
|
209
|
+
* 转发一条已接收消息。IMLib 负责克隆消息内容和发送生命周期,
|
|
210
|
+
* 资源复制由业务配置的 uploader copy hook 完成。
|
|
211
|
+
*/
|
|
212
|
+
export declare const forwardMessage: (conversation: IConversationOption, originalMessage: IReceivedMessage, options?: ISendMessageOptions) => IPromiseResult<IReceivedMessage>;
|
|
213
|
+
export declare const mergeForwardMessages: (conversation: IConversationOption, originalMessages: ReadonlyArray<ISenderEnrichedMessage>, chatTitle: string, options?: ISendMessageOptions) => IPromiseResult<IReceivedMessage>;
|
|
190
214
|
/**
|
|
191
215
|
* 发送文本消息
|
|
192
216
|
*/
|
|
@@ -217,7 +241,15 @@ export declare const sendSightMessage: (conversation: IConversationOption, msgBo
|
|
|
217
241
|
*/
|
|
218
242
|
export declare const recallMessage: (conversation: IConversationOption, options: IRecallMessageOptions) => IPromiseResult<IReceivedMessage>;
|
|
219
243
|
/**
|
|
220
|
-
*
|
|
244
|
+
* 对消息发表或取消表情评论。空 content 表示删除当前用户的评论。
|
|
245
|
+
*/
|
|
246
|
+
export declare const commentMessage: (conversation: IConversationOption, options: ICommentMessageOptions) => IPromiseResult<{
|
|
247
|
+
reactions: IMessageReaction[];
|
|
248
|
+
}>;
|
|
249
|
+
/**
|
|
250
|
+
* 获取历史消息。
|
|
251
|
+
* order 0:先读本地再按需向服务端补更旧消息。
|
|
252
|
+
* order 1:只读本地数据库中更新方向的消息。
|
|
221
253
|
*/
|
|
222
254
|
export declare const getRemoteHistoryMessages: (conversation: IConversationOption, options: GetHistoryMessageOption) => IPromiseResult<GetHistoryMessageResult>;
|
|
223
255
|
/**
|
|
@@ -227,7 +259,7 @@ export declare const getHistoryMessages: (conversation: IConversationOption, opt
|
|
|
227
259
|
/**
|
|
228
260
|
* 设置或取消置顶一条消息。状态将在服务端置顶通知到达后更新。
|
|
229
261
|
*/
|
|
230
|
-
export declare const setMessagePinned: (conversation: IConversationOption, messageUId: string, pinned: boolean) => IPromiseResult<void>;
|
|
262
|
+
export declare const setMessagePinned: (conversation: IConversationOption, messageUId: string, pinned: boolean, scope?: MessagePinnedScope) => IPromiseResult<void>;
|
|
231
263
|
/**
|
|
232
264
|
* 取消当前会话的全部置顶消息。
|
|
233
265
|
*/
|
|
@@ -240,6 +272,10 @@ export declare const getPinnedMessages: (conversation: IConversationOption, coun
|
|
|
240
272
|
* 按消息 id 删除消息
|
|
241
273
|
*/
|
|
242
274
|
export declare const deleteMessages: (conversation: IConversationOption, messages: IDeleteMessageOptions[]) => IPromiseResult<void>;
|
|
275
|
+
/**
|
|
276
|
+
* 仅删除本地缓存中的消息,不请求服务端。
|
|
277
|
+
*/
|
|
278
|
+
export declare const deleteLocalMessages: (conversation: IConversationOption, messageUIds: string[]) => IPromiseResult<void>;
|
|
243
279
|
/**
|
|
244
280
|
* 按时间戳删除消息
|
|
245
281
|
* @param conversation 会话
|
|
@@ -264,7 +300,7 @@ export declare const encodeReceivedMessage2ChatRecordMsgDetail: (message: ISende
|
|
|
264
300
|
* @param messages 消息列表
|
|
265
301
|
* @returns
|
|
266
302
|
*/
|
|
267
|
-
export declare const sendReadReceipts: (messages: IReceivedMessage[]) => IPromiseResult<void>;
|
|
303
|
+
export declare const sendReadReceipts: (messages: IReceivedMessage[], readAt?: number) => IPromiseResult<void>;
|
|
268
304
|
export declare const mockLogin: (config: {
|
|
269
305
|
langCode: string;
|
|
270
306
|
phone: string;
|
|
@@ -303,6 +339,10 @@ export declare const getMessageById: (messageId: number) => IPromiseResult<IRece
|
|
|
303
339
|
* 获取消息
|
|
304
340
|
*/
|
|
305
341
|
export declare const getMessageByUId: (messageUId: string) => IPromiseResult<IReceivedMessage | null | undefined>;
|
|
342
|
+
/**
|
|
343
|
+
* 更新本地消息缓存中的既有消息,不向服务端发送请求。
|
|
344
|
+
*/
|
|
345
|
+
export declare const updateMessage: (message: IReceivedMessage) => IPromiseResult<IReceivedMessage>;
|
|
306
346
|
/**
|
|
307
347
|
* 按消息类型查询当前会话的本地缓存消息。
|
|
308
348
|
* 只读 IMLib 本地库,不向服务端补历史。
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ConversationType, MessageDirection, ReceivedStatus, SentStatus } from './statusTypes';
|
|
2
2
|
import IQuotedReplyMessage from './iQuotedReplyMessage';
|
|
3
|
+
import type { IMessageReaction } from '../core/messageReactions';
|
|
3
4
|
/**
|
|
4
5
|
* 消息数据
|
|
5
6
|
*/
|
|
@@ -81,6 +82,10 @@ export default interface IReceivedMessage {
|
|
|
81
82
|
* 消息发送状态
|
|
82
83
|
*/
|
|
83
84
|
sentStatus: SentStatus;
|
|
85
|
+
/**
|
|
86
|
+
* 本地消息发送失败时的错误码。发送成功或尚未失败时不存在。
|
|
87
|
+
*/
|
|
88
|
+
sendErrorCode?: number;
|
|
84
89
|
/**
|
|
85
90
|
* 是否为阅后即焚消息
|
|
86
91
|
*/
|
|
@@ -90,10 +95,18 @@ export default interface IReceivedMessage {
|
|
|
90
95
|
* @default false
|
|
91
96
|
*/
|
|
92
97
|
pinned: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* 挂在目标消息上的表情评论
|
|
100
|
+
*/
|
|
101
|
+
reactions?: IMessageReaction[];
|
|
93
102
|
/**
|
|
94
103
|
* 阅后即焚消息的时长
|
|
95
104
|
*/
|
|
96
105
|
burnAfterReadingTime?: number;
|
|
106
|
+
/**
|
|
107
|
+
* 入站阅后即焚消息首次在本设备标记已读的时间
|
|
108
|
+
*/
|
|
109
|
+
burnAfterReadingStartedAt?: number;
|
|
97
110
|
/**
|
|
98
111
|
* 引用消息
|
|
99
112
|
*/
|
|
@@ -4,9 +4,9 @@ import GIFMessage, { IGIFMessageBody } from './gifMessage';
|
|
|
4
4
|
import HQVoiceMessage, { IHQVoiceMessageBody } from './voiceMessage';
|
|
5
5
|
import FileMessage, { IFileMessageBody } from './fileMessage';
|
|
6
6
|
import VideoMessage, { IVideoMessageBody } from './videoMessage';
|
|
7
|
-
import { ILocationMessageBody, LocationMessage, IChatRecordMessageBody, ChatRecordMessage, IContactMessageBody, ContactMessage, IInvitationMessageBody, InvitationMessage, IRedEnvelopeMessageBody, RedEnvelopeMessage, ITransferMessageBody, TransferMessage, ILinkMessageBody, LinkMessage } from './otherMediaMessages';
|
|
7
|
+
import { ILocationMessageBody, LocationMessage, IChatRecordMessageBody, IChatRecordMsgDetail, ChatRecordMessage, IContactMessageBody, ContactMessage, IInvitationMessageBody, InvitationMessage, IRedEnvelopeMessageBody, RedEnvelopeMessage, ITransferMessageBody, TransferMessage, ILinkMessageBody, LinkMessage } from './otherMediaMessages';
|
|
8
8
|
import { IBurnAfterReadingMessageBody, IMessagePinnedNotificationBody } from './notificationMessages';
|
|
9
9
|
import { PrivateOpenBurnAfterReadingMessage, PrivateCloseBurnAfterReadingMessage, GroupOpenBurnAfterReadingMessage, GroupCloseBurnAfterReadingMessage, PrivateMessagePinnedNotification, GroupMessagePinnedNotification } from './notificationMessages';
|
|
10
10
|
import RecallCommandMessage, { IRecallCommandMessageBody } from './recallCommandMessage';
|
|
11
11
|
export { TextMessage, ImageMessage, GIFMessage, HQVoiceMessage, FileMessage, RecallCommandMessage, VideoMessage, LocationMessage, ChatRecordMessage, ContactMessage, InvitationMessage, RedEnvelopeMessage, TransferMessage, PrivateOpenBurnAfterReadingMessage, PrivateCloseBurnAfterReadingMessage, GroupOpenBurnAfterReadingMessage, GroupCloseBurnAfterReadingMessage, PrivateMessagePinnedNotification, GroupMessagePinnedNotification, LinkMessage };
|
|
12
|
-
export type { ITextMessageBody, ITextMessageEntity, ITextMessageLinkPreview, ITextMessageStyleAttribute, TextMessageEntityType, IImageMessageBody, IGIFMessageBody, IHQVoiceMessageBody, IFileMessageBody, IRecallCommandMessageBody, IVideoMessageBody, ILocationMessageBody, IChatRecordMessageBody, IContactMessageBody, IInvitationMessageBody, IRedEnvelopeMessageBody, ITransferMessageBody, IBurnAfterReadingMessageBody, IMessagePinnedNotificationBody, ILinkMessageBody };
|
|
12
|
+
export type { ITextMessageBody, ITextMessageEntity, ITextMessageLinkPreview, ITextMessageStyleAttribute, TextMessageEntityType, IImageMessageBody, IGIFMessageBody, IHQVoiceMessageBody, IFileMessageBody, IRecallCommandMessageBody, IVideoMessageBody, ILocationMessageBody, IChatRecordMessageBody, IChatRecordMsgDetail, IContactMessageBody, IInvitationMessageBody, IRedEnvelopeMessageBody, ITransferMessageBody, IBurnAfterReadingMessageBody, IMessagePinnedNotificationBody, ILinkMessageBody };
|
|
@@ -16,10 +16,16 @@ export interface IMessageReadMessageBody extends IBaseMessageBody {
|
|
|
16
16
|
export interface IChangeGroupTitleMessageBody extends IBaseMessageBody {
|
|
17
17
|
newTitle: string;
|
|
18
18
|
groupUin: string;
|
|
19
|
+
templateId?: number;
|
|
20
|
+
params?: string[];
|
|
19
21
|
}
|
|
20
22
|
export interface IChangeGroupAvatarMessageBody extends IBaseMessageBody {
|
|
21
23
|
smallAvatarUrl: string;
|
|
22
24
|
groupId: string;
|
|
25
|
+
originalAvatarUrl?: string;
|
|
26
|
+
operatorUserId?: string;
|
|
27
|
+
templateId?: number;
|
|
28
|
+
params?: string[];
|
|
23
29
|
}
|
|
24
30
|
export interface IMessagePinnedNotificationBody extends IBaseMessageBody {
|
|
25
31
|
operatorUserId?: string;
|
|
@@ -29,6 +35,14 @@ export interface IMessagePinnedNotificationBody extends IBaseMessageBody {
|
|
|
29
35
|
msgId: string;
|
|
30
36
|
pinned: 0 | 1 | 2;
|
|
31
37
|
}
|
|
38
|
+
export interface IChatCommentNotificationBody extends IBaseMessageBody {
|
|
39
|
+
uid?: string | number;
|
|
40
|
+
msgId?: string | number;
|
|
41
|
+
content?: string;
|
|
42
|
+
nickName?: string;
|
|
43
|
+
nickname?: string;
|
|
44
|
+
time?: number | string;
|
|
45
|
+
}
|
|
32
46
|
declare const GroupArrivalReceiptMessage: new (content: IReceiptMessageBody) => import("../baseMessage").BaseMessage<IReceiptMessageBody>;
|
|
33
47
|
declare const GroupReadReceiptMessage: new (content: IReceiptMessageBody) => import("../baseMessage").BaseMessage<IReceiptMessageBody>;
|
|
34
48
|
declare const PrivateArrivalReceiptMessage: new (content: IReceiptMessageBody) => import("../baseMessage").BaseMessage<IReceiptMessageBody>;
|
|
@@ -42,4 +56,5 @@ declare const ChangeGroupTitleMessage: new (content: IChangeGroupTitleMessageBod
|
|
|
42
56
|
declare const ChangeGroupAvatarMessage: new (content: IChangeGroupAvatarMessageBody) => import("../baseMessage").BaseMessage<IChangeGroupAvatarMessageBody>;
|
|
43
57
|
declare const PrivateMessagePinnedNotification: new (content: IMessagePinnedNotificationBody) => import("../baseMessage").BaseMessage<IMessagePinnedNotificationBody>;
|
|
44
58
|
declare const GroupMessagePinnedNotification: new (content: IMessagePinnedNotificationBody) => import("../baseMessage").BaseMessage<IMessagePinnedNotificationBody>;
|
|
45
|
-
|
|
59
|
+
declare const ChatCommentNotification: new (content: IChatCommentNotificationBody) => import("../baseMessage").BaseMessage<IChatCommentNotificationBody>;
|
|
60
|
+
export { GroupArrivalReceiptMessage, GroupReadReceiptMessage, PrivateArrivalReceiptMessage, PrivateReadReceiptMessage, PrivateOpenBurnAfterReadingMessage, PrivateCloseBurnAfterReadingMessage, GroupOpenBurnAfterReadingMessage, GroupCloseBurnAfterReadingMessage, MessageReadMessage, ChangeGroupTitleMessage, ChangeGroupAvatarMessage, PrivateMessagePinnedNotification, GroupMessagePinnedNotification, ChatCommentNotification };
|
package/types/types.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { BaseMessage, IExtraData, IUserInfo } from './model/baseMessage';
|
|
2
2
|
import IReceivedMessage from './model/iReceivedMessage';
|
|
3
|
+
import type { IMessageReaction } from './core/messageReactions';
|
|
3
4
|
import { ConnectionStatus, ConversationType, ErrorCode, MessageDirection, NotificationLevel, NotificationStatus } from './model/statusTypes';
|
|
4
5
|
import IReceivedConversation from './model/iReceivedConversation';
|
|
6
|
+
export type { DialogFilterConfig } from './net/pbs/dialogFilter';
|
|
7
|
+
import type { DialogFilterConfig } from './net/pbs/dialogFilter';
|
|
8
|
+
export type { IMessageReaction };
|
|
5
9
|
export declare enum LogLevel {
|
|
6
10
|
DEBUG = 0,
|
|
7
11
|
INFO = 1,
|
|
@@ -10,6 +14,7 @@ export declare enum LogLevel {
|
|
|
10
14
|
FATAL = 4,
|
|
11
15
|
NONE = 1000
|
|
12
16
|
}
|
|
17
|
+
export type LegacyMigrationMode = 'automatic' | 'manual';
|
|
13
18
|
export type IInitOption = {
|
|
14
19
|
appkey: string;
|
|
15
20
|
/**
|
|
@@ -24,6 +29,7 @@ export type IInitOption = {
|
|
|
24
29
|
uploader?: IUploader;
|
|
25
30
|
deviceCode: string;
|
|
26
31
|
deviceType: number;
|
|
32
|
+
legacyMigrationMode?: LegacyMigrationMode;
|
|
27
33
|
};
|
|
28
34
|
export interface ProfileInfo {
|
|
29
35
|
deviceId: string;
|
|
@@ -42,13 +48,16 @@ export declare enum Events {
|
|
|
42
48
|
RECALL = "RECALL",
|
|
43
49
|
ARRIVAL_RECEIPT_RECEIVED = "ARRIVAL_RECEIPT_RECEIVED",
|
|
44
50
|
READ_RECEIPT_RECEIVED = "READ_RECEIPT_RECEIVED",
|
|
45
|
-
MESSAGE_PINNED_CHANGED = "MESSAGE_PINNED_CHANGED"
|
|
51
|
+
MESSAGE_PINNED_CHANGED = "MESSAGE_PINNED_CHANGED",
|
|
52
|
+
MESSAGE_REACTIONS_CHANGED = "MESSAGE_REACTIONS_CHANGED",
|
|
53
|
+
DIALOG_FILTER_CONFIG = "DIALOG_FILTER_CONFIG"
|
|
46
54
|
}
|
|
47
55
|
export declare enum MessagePinnedOperation {
|
|
48
56
|
PIN = 0,
|
|
49
57
|
UNPIN = 1,
|
|
50
58
|
UNPIN_ALL = 2
|
|
51
59
|
}
|
|
60
|
+
export type MessagePinnedScope = 'everyone' | 'me';
|
|
52
61
|
export interface IMessagePinnedChangedEvent {
|
|
53
62
|
conversation: IConversationOption;
|
|
54
63
|
messageUId?: string;
|
|
@@ -88,6 +97,8 @@ export type EventListeners = {
|
|
|
88
97
|
[Events.ARRIVAL_RECEIPT_RECEIVED]: (event: IReceiptReceivedEvent) => void;
|
|
89
98
|
[Events.READ_RECEIPT_RECEIVED]: (event: IReceiptReceivedEvent) => void;
|
|
90
99
|
[Events.MESSAGE_PINNED_CHANGED]: (event: IMessagePinnedChangedEvent) => void;
|
|
100
|
+
[Events.MESSAGE_REACTIONS_CHANGED]: (event: IMessageReactionsChangedEvent) => void;
|
|
101
|
+
[Events.DIALOG_FILTER_CONFIG]: (config: DialogFilterConfig) => void;
|
|
91
102
|
};
|
|
92
103
|
export interface IBaseConversationInfo {
|
|
93
104
|
conversationType: ConversationType;
|
|
@@ -118,6 +129,7 @@ export type IUpdatedConversationItem = Partial<Record<IUpdatedConversationItemKe
|
|
|
118
129
|
export type IUpdatedConversation = {
|
|
119
130
|
conversation: IReceivedConversation;
|
|
120
131
|
updatedItems: IUpdatedConversationItem;
|
|
132
|
+
removed?: boolean;
|
|
121
133
|
};
|
|
122
134
|
/**
|
|
123
135
|
* 消息的推送配置
|
|
@@ -197,10 +209,34 @@ export type IUploadCallback = {
|
|
|
197
209
|
onCompleted?: (result: IUploadCompletedResult) => void;
|
|
198
210
|
onError?: (reason: string) => void;
|
|
199
211
|
};
|
|
212
|
+
export type IForwardResourceSource = {
|
|
213
|
+
sourceUrl: string;
|
|
214
|
+
encryptKey?: string;
|
|
215
|
+
};
|
|
216
|
+
export type IForwardResourceItem = IForwardResourceSource & {
|
|
217
|
+
url: string;
|
|
218
|
+
};
|
|
219
|
+
export type IForwardResourcePrepareParams = {
|
|
220
|
+
sourceConversation: IConversationOption;
|
|
221
|
+
targetConversation: IConversationOption;
|
|
222
|
+
items: ReadonlyArray<IForwardResourceSource>;
|
|
223
|
+
};
|
|
224
|
+
export type IForwardResourceCopyParams = {
|
|
225
|
+
sourceConversation: IConversationOption;
|
|
226
|
+
targetConversation: IConversationOption;
|
|
227
|
+
items: ReadonlyArray<IForwardResourceItem>;
|
|
228
|
+
};
|
|
229
|
+
export type IForwardResourceCallback = {
|
|
230
|
+
onProgress?: (progress: number) => void;
|
|
231
|
+
onCompleted?: () => void;
|
|
232
|
+
onError?: (reason: string) => void;
|
|
233
|
+
};
|
|
200
234
|
export interface IUploader {
|
|
201
235
|
upload(params: IUploadMessageParams, callback: IUploadCallback): void;
|
|
202
236
|
cancel(): void;
|
|
203
237
|
prepare(files: Blob[]): Promise<IUploadPrepareResult>;
|
|
238
|
+
prepareCopy?(params: IForwardResourcePrepareParams): Promise<IForwardResourceCopyParams>;
|
|
239
|
+
copy?(params: IForwardResourceCopyParams, callback: IForwardResourceCallback): void;
|
|
204
240
|
}
|
|
205
241
|
/**
|
|
206
242
|
* 文件消息配置
|
|
@@ -238,6 +274,17 @@ export interface IRecallMessageOptions {
|
|
|
238
274
|
*/
|
|
239
275
|
messageUId: string;
|
|
240
276
|
}
|
|
277
|
+
export interface ICommentMessageOptions {
|
|
278
|
+
messageUId: string;
|
|
279
|
+
content: string;
|
|
280
|
+
nickname?: string;
|
|
281
|
+
}
|
|
282
|
+
export interface IMessageReactionsChangedEvent {
|
|
283
|
+
conversation: IConversationOption;
|
|
284
|
+
messageUId: string;
|
|
285
|
+
reactions: IMessageReaction[];
|
|
286
|
+
change: IMessageReaction;
|
|
287
|
+
}
|
|
241
288
|
/**
|
|
242
289
|
* 获取远程消息 option 参数
|
|
243
290
|
*/
|