@onyx-p/imlib-web 1.5.0 → 1.5.2

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/index.esm.js CHANGED
@@ -18486,9 +18486,9 @@ const getRemoteMessages = params => {
18486
18486
  rows: params.count
18487
18487
  };
18488
18488
  if (params.newToOld) {
18489
- reqParams.offset = Long.fromNumber(params.offset);
18489
+ reqParams.offset = Long.fromString(params.offset);
18490
18490
  } else {
18491
- reqParams.oldOffset = Long.fromNumber(params.offset);
18491
+ reqParams.oldOffset = Long.fromString(params.offset);
18492
18492
  }
18493
18493
  return webSocketServer.send(CmdIds$1.GetRemoteMessages, reqParams, {
18494
18494
  encoder: GetHistoryMessageReq,
@@ -18817,12 +18817,13 @@ const MessageTypes = {
18817
18817
  FILE: 0x3000100A,
18818
18818
  AUDIO: 0x30001011,
18819
18819
  VIDEO: 0x30001006,
18820
- CUST_COMMAND: 0x1000101d,
18821
- CUST_STORAGE: 0x1000102d,
18822
- CUST_NORMAL: 0x1000103d,
18823
- CUST_STATUS: 0x1000104d,
18824
18820
  RECALL: 0x6001001d,
18825
- CMD: 0x1000105d
18821
+ LOCATION: 0x30001005,
18822
+ CHAT_RECORD: 0x30001019,
18823
+ CONTACT: 0x10001002,
18824
+ GROUP_INVITATION: 0x30001003,
18825
+ REDPACKET: 0x10001040,
18826
+ TRANSFER: 0x10001030
18826
18827
  };
18827
18828
 
18828
18829
  const STATUSMESSAGE_ALIVE_TIMEMS = 6000;
@@ -18996,6 +18997,14 @@ const ConversationKey2StorageKey = {
18996
18997
  mentionedUIds: {
18997
18998
  keyName: 'mu',
18998
18999
  defaultVal: null
19000
+ },
19001
+ dialogTitle: {
19002
+ keyName: 'dt',
19003
+ defaultVal: null
19004
+ },
19005
+ smallAvatarUrl: {
19006
+ keyName: 'sa',
19007
+ defaultVal: null
18999
19008
  }
19000
19009
  };
19001
19010
  class ConversationStore {
@@ -19313,7 +19322,9 @@ class ConversationManager {
19313
19322
  targetId,
19314
19323
  isTop,
19315
19324
  notificationStatus,
19316
- notificationLevel
19325
+ notificationLevel,
19326
+ dialogTitle,
19327
+ smallAvatarUrl
19317
19328
  } = conversation;
19318
19329
  this.localConversationSet.add(this.getConversationKey(conversation));
19319
19330
  this.addStatus({
@@ -19321,7 +19332,9 @@ class ConversationManager {
19321
19332
  targetId,
19322
19333
  isTop,
19323
19334
  notificationStatus,
19324
- notificationLevel
19335
+ notificationLevel,
19336
+ dialogTitle,
19337
+ smallAvatarUrl
19325
19338
  }, false);
19326
19339
  }
19327
19340
  addStatus(statusItem, shouldNotify = false) {
@@ -19330,7 +19343,9 @@ class ConversationManager {
19330
19343
  targetId,
19331
19344
  notificationStatus,
19332
19345
  notificationLevel,
19333
- isTop
19346
+ isTop,
19347
+ dialogTitle,
19348
+ smallAvatarUrl
19334
19349
  } = statusItem;
19335
19350
  const conOpt = {
19336
19351
  conversationType,
@@ -19357,10 +19372,24 @@ class ConversationManager {
19357
19372
  val: isTop
19358
19373
  };
19359
19374
  }
19375
+ if (isDef(dialogTitle) && storageConversation.dialogTitle !== dialogTitle) {
19376
+ updatedItems.dialogTitle = {
19377
+ time: updatedTime,
19378
+ val: dialogTitle
19379
+ };
19380
+ }
19381
+ if (isDef(smallAvatarUrl) && storageConversation.smallAvatarUrl !== smallAvatarUrl) {
19382
+ updatedItems.smallAvatarUrl = {
19383
+ time: updatedTime,
19384
+ val: smallAvatarUrl
19385
+ };
19386
+ }
19360
19387
  this.store.set(conOpt, {
19361
19388
  notificationStatus,
19362
19389
  isTop,
19363
- notificationLevel
19390
+ notificationLevel,
19391
+ dialogTitle,
19392
+ smallAvatarUrl
19364
19393
  });
19365
19394
  if (Object.keys(updatedItems).length && shouldNotify) {
19366
19395
  this.setUpdatedConversation({
@@ -19544,7 +19573,9 @@ class ConversationManager {
19544
19573
  unreadMentionedCount,
19545
19574
  notificationLevel,
19546
19575
  notificationStatus,
19547
- isTop
19576
+ isTop,
19577
+ dialogTitle,
19578
+ smallAvatarUrl
19548
19579
  }) => ({
19549
19580
  conversationType,
19550
19581
  targetId,
@@ -19552,7 +19583,9 @@ class ConversationManager {
19552
19583
  unreadMentionedCount: unreadMentionedCount ?? 0,
19553
19584
  notificationLevel,
19554
19585
  notificationStatus,
19555
- isTop
19586
+ isTop,
19587
+ dialogTitle,
19588
+ smallAvatarUrl
19556
19589
  }));
19557
19590
  }
19558
19591
  destroyed() {
@@ -19600,7 +19633,9 @@ const nullConversationManager = {
19600
19633
  return [];
19601
19634
  },
19602
19635
  addLocalConversation: function (conversation) {},
19603
- loadConvsationsIfNotExist: function (list) {},
19636
+ loadConvsationsIfNotExist: function (list) {
19637
+ return Promise.resolve();
19638
+ },
19604
19639
  destroyed() {},
19605
19640
  syncConversationStatus: function () {}
19606
19641
  };
@@ -19705,7 +19740,7 @@ class MessageLoader {
19705
19740
  targetId: dialogId
19706
19741
  };
19707
19742
  });
19708
- ConversationManager$1.get().loadConvsationsIfNotExist(cons);
19743
+ await ConversationManager$1.get().loadConvsationsIfNotExist(cons);
19709
19744
  ServerMessageParser.parse(msg, (done, outputMsgs) => {
19710
19745
  const messages = [];
19711
19746
  const conversations = [];
@@ -27148,7 +27183,9 @@ function beforeSend(conversation, message, options) {
27148
27183
  async function send(message, sentArgs) {
27149
27184
  const dialogId = getFullDialogId(sentArgs.conversation);
27150
27185
  const receivedMessage = transSentAttrs2IReceivedMessage(message, sentArgs);
27151
- message.isPersited && ConversationManager$1.get().loadConvsationsIfNotExist([sentArgs.conversation]);
27186
+ if (message.isPersited) {
27187
+ await ConversationManager$1.get().loadConvsationsIfNotExist([sentArgs.conversation]);
27188
+ }
27152
27189
  const secretKey = await DialogSecretKey$1.getDialogAesKey(dialogId.toString());
27153
27190
  if (!secretKey) {
27154
27191
  receivedMessage.sentStatus = SentStatus.FAILED;
@@ -27313,10 +27350,9 @@ class IMClient extends EventEmitter {
27313
27350
  recallMsg = sendRecallMessage;
27314
27351
  async getRemoteHistoryMessages(conversation, options) {
27315
27352
  const dialogId = getFullDialogId(conversation);
27316
- debugger;
27317
27353
  return getRemoteMessages({
27318
27354
  dialogId,
27319
- offset: options.timestamp ?? 0,
27355
+ offset: options.timestamp ?? "0",
27320
27356
  count: options.count ?? 20,
27321
27357
  newToOld: options.order === 0
27322
27358
  }).then(({
@@ -27331,7 +27367,6 @@ class IMClient extends EventEmitter {
27331
27367
  });
27332
27368
  return;
27333
27369
  }
27334
- debugger;
27335
27370
  ServerMessageParser.parse({
27336
27371
  [dialogId]: data.msg ?? {}
27337
27372
  }, (_, outputMsgs) => {
@@ -28697,7 +28732,7 @@ const recallMessage = async (conversation, options) => {
28697
28732
  return response;
28698
28733
  };
28699
28734
  const getHistoryMessages = async (conversation, options) => {
28700
- assert('options.timestamp', options.timestamp ?? 0, AssertRules.NUMBER);
28735
+ assert('options.timestamp', options.timestamp ?? '0', AssertRules.ONLY_STRING);
28701
28736
  assert('options.count', options.count ?? 0, AssertRules.NUMBER);
28702
28737
  assert('options.order', options.order ?? 0, value => {
28703
28738
  return value === 0 || value === 1;
package/index.umd.js CHANGED
@@ -18492,9 +18492,9 @@
18492
18492
  rows: params.count
18493
18493
  };
18494
18494
  if (params.newToOld) {
18495
- reqParams.offset = Long.fromNumber(params.offset);
18495
+ reqParams.offset = Long.fromString(params.offset);
18496
18496
  } else {
18497
- reqParams.oldOffset = Long.fromNumber(params.offset);
18497
+ reqParams.oldOffset = Long.fromString(params.offset);
18498
18498
  }
18499
18499
  return webSocketServer.send(CmdIds$1.GetRemoteMessages, reqParams, {
18500
18500
  encoder: GetHistoryMessageReq,
@@ -18823,12 +18823,13 @@
18823
18823
  FILE: 0x3000100A,
18824
18824
  AUDIO: 0x30001011,
18825
18825
  VIDEO: 0x30001006,
18826
- CUST_COMMAND: 0x1000101d,
18827
- CUST_STORAGE: 0x1000102d,
18828
- CUST_NORMAL: 0x1000103d,
18829
- CUST_STATUS: 0x1000104d,
18830
18826
  RECALL: 0x6001001d,
18831
- CMD: 0x1000105d
18827
+ LOCATION: 0x30001005,
18828
+ CHAT_RECORD: 0x30001019,
18829
+ CONTACT: 0x10001002,
18830
+ GROUP_INVITATION: 0x30001003,
18831
+ REDPACKET: 0x10001040,
18832
+ TRANSFER: 0x10001030
18832
18833
  };
18833
18834
 
18834
18835
  const STATUSMESSAGE_ALIVE_TIMEMS = 6000;
@@ -19002,6 +19003,14 @@
19002
19003
  mentionedUIds: {
19003
19004
  keyName: 'mu',
19004
19005
  defaultVal: null
19006
+ },
19007
+ dialogTitle: {
19008
+ keyName: 'dt',
19009
+ defaultVal: null
19010
+ },
19011
+ smallAvatarUrl: {
19012
+ keyName: 'sa',
19013
+ defaultVal: null
19005
19014
  }
19006
19015
  };
19007
19016
  class ConversationStore {
@@ -19319,7 +19328,9 @@
19319
19328
  targetId,
19320
19329
  isTop,
19321
19330
  notificationStatus,
19322
- notificationLevel
19331
+ notificationLevel,
19332
+ dialogTitle,
19333
+ smallAvatarUrl
19323
19334
  } = conversation;
19324
19335
  this.localConversationSet.add(this.getConversationKey(conversation));
19325
19336
  this.addStatus({
@@ -19327,7 +19338,9 @@
19327
19338
  targetId,
19328
19339
  isTop,
19329
19340
  notificationStatus,
19330
- notificationLevel
19341
+ notificationLevel,
19342
+ dialogTitle,
19343
+ smallAvatarUrl
19331
19344
  }, false);
19332
19345
  }
19333
19346
  addStatus(statusItem, shouldNotify = false) {
@@ -19336,7 +19349,9 @@
19336
19349
  targetId,
19337
19350
  notificationStatus,
19338
19351
  notificationLevel,
19339
- isTop
19352
+ isTop,
19353
+ dialogTitle,
19354
+ smallAvatarUrl
19340
19355
  } = statusItem;
19341
19356
  const conOpt = {
19342
19357
  conversationType,
@@ -19363,10 +19378,24 @@
19363
19378
  val: isTop
19364
19379
  };
19365
19380
  }
19381
+ if (isDef(dialogTitle) && storageConversation.dialogTitle !== dialogTitle) {
19382
+ updatedItems.dialogTitle = {
19383
+ time: updatedTime,
19384
+ val: dialogTitle
19385
+ };
19386
+ }
19387
+ if (isDef(smallAvatarUrl) && storageConversation.smallAvatarUrl !== smallAvatarUrl) {
19388
+ updatedItems.smallAvatarUrl = {
19389
+ time: updatedTime,
19390
+ val: smallAvatarUrl
19391
+ };
19392
+ }
19366
19393
  this.store.set(conOpt, {
19367
19394
  notificationStatus,
19368
19395
  isTop,
19369
- notificationLevel
19396
+ notificationLevel,
19397
+ dialogTitle,
19398
+ smallAvatarUrl
19370
19399
  });
19371
19400
  if (Object.keys(updatedItems).length && shouldNotify) {
19372
19401
  this.setUpdatedConversation({
@@ -19550,7 +19579,9 @@
19550
19579
  unreadMentionedCount,
19551
19580
  notificationLevel,
19552
19581
  notificationStatus,
19553
- isTop
19582
+ isTop,
19583
+ dialogTitle,
19584
+ smallAvatarUrl
19554
19585
  }) => ({
19555
19586
  conversationType,
19556
19587
  targetId,
@@ -19558,7 +19589,9 @@
19558
19589
  unreadMentionedCount: unreadMentionedCount ?? 0,
19559
19590
  notificationLevel,
19560
19591
  notificationStatus,
19561
- isTop
19592
+ isTop,
19593
+ dialogTitle,
19594
+ smallAvatarUrl
19562
19595
  }));
19563
19596
  }
19564
19597
  destroyed() {
@@ -19606,7 +19639,9 @@
19606
19639
  return [];
19607
19640
  },
19608
19641
  addLocalConversation: function (conversation) {},
19609
- loadConvsationsIfNotExist: function (list) {},
19642
+ loadConvsationsIfNotExist: function (list) {
19643
+ return Promise.resolve();
19644
+ },
19610
19645
  destroyed() {},
19611
19646
  syncConversationStatus: function () {}
19612
19647
  };
@@ -19711,7 +19746,7 @@
19711
19746
  targetId: dialogId
19712
19747
  };
19713
19748
  });
19714
- ConversationManager$1.get().loadConvsationsIfNotExist(cons);
19749
+ await ConversationManager$1.get().loadConvsationsIfNotExist(cons);
19715
19750
  ServerMessageParser.parse(msg, (done, outputMsgs) => {
19716
19751
  const messages = [];
19717
19752
  const conversations = [];
@@ -27154,7 +27189,9 @@
27154
27189
  async function send(message, sentArgs) {
27155
27190
  const dialogId = getFullDialogId(sentArgs.conversation);
27156
27191
  const receivedMessage = transSentAttrs2IReceivedMessage(message, sentArgs);
27157
- message.isPersited && ConversationManager$1.get().loadConvsationsIfNotExist([sentArgs.conversation]);
27192
+ if (message.isPersited) {
27193
+ await ConversationManager$1.get().loadConvsationsIfNotExist([sentArgs.conversation]);
27194
+ }
27158
27195
  const secretKey = await DialogSecretKey$1.getDialogAesKey(dialogId.toString());
27159
27196
  if (!secretKey) {
27160
27197
  receivedMessage.sentStatus = exports.SentStatus.FAILED;
@@ -27319,10 +27356,9 @@
27319
27356
  recallMsg = sendRecallMessage;
27320
27357
  async getRemoteHistoryMessages(conversation, options) {
27321
27358
  const dialogId = getFullDialogId(conversation);
27322
- debugger;
27323
27359
  return getRemoteMessages({
27324
27360
  dialogId,
27325
- offset: options.timestamp ?? 0,
27361
+ offset: options.timestamp ?? "0",
27326
27362
  count: options.count ?? 20,
27327
27363
  newToOld: options.order === 0
27328
27364
  }).then(({
@@ -27337,7 +27373,6 @@
27337
27373
  });
27338
27374
  return;
27339
27375
  }
27340
- debugger;
27341
27376
  ServerMessageParser.parse({
27342
27377
  [dialogId]: data.msg ?? {}
27343
27378
  }, (_, outputMsgs) => {
@@ -28703,7 +28738,7 @@
28703
28738
  return response;
28704
28739
  };
28705
28740
  const getHistoryMessages = async (conversation, options) => {
28706
- assert('options.timestamp', options.timestamp ?? 0, AssertRules.NUMBER);
28741
+ assert('options.timestamp', options.timestamp ?? '0', AssertRules.ONLY_STRING);
28707
28742
  assert('options.count', options.count ?? 0, AssertRules.NUMBER);
28708
28743
  assert('options.order', options.order ?? 0, value => {
28709
28744
  return value === 0 || value === 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onyx-p/imlib-web",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "main": "index.umd.js",
5
5
  "module": "index.esm.js",
6
6
  "types": "types/index.d.ts",
@@ -5,10 +5,11 @@ export declare const MessageTypes: {
5
5
  FILE: number;
6
6
  AUDIO: number;
7
7
  VIDEO: number;
8
- CUST_COMMAND: number;
9
- CUST_STORAGE: number;
10
- CUST_NORMAL: number;
11
- CUST_STATUS: number;
12
8
  RECALL: number;
13
- CMD: number;
9
+ LOCATION: number;
10
+ CHAT_RECORD: number;
11
+ CONTACT: number;
12
+ GROUP_INVITATION: number;
13
+ REDPACKET: number;
14
+ TRANSFER: number;
14
15
  };
package/types/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import IReceivedConversation from './model/iReceivedConversation';
7
7
  import { CommonReqResult, PBCodec } from './net/connection/webSocketServer';
8
8
  import { BaseResp } from './net/pbs/rpc.base';
9
9
  export { TextMessage, ImageMessage, HQVoiceMessage, GIFMessage, FileMessage, VideoMessage } from './model/messages';
10
- export type { ITextMessageBody, IImageMessageBody, IGIFMessageBody, IFileMessageBody, IHQVoiceMessageBody, IRecallCommandMessageBody, IVideoMessageBody } from './model/messages';
10
+ export type { ITextMessageBody, IImageMessageBody, IGIFMessageBody, IFileMessageBody, IHQVoiceMessageBody, IRecallCommandMessageBody, IVideoMessageBody, ILocationMessageBody, IChatRecordMessageBody, IContactMessageBody, IInvitationMessageBody, IRedEnvelopeMessageBody, ITransferMessageBody } from './model/messages';
11
11
  export { MessageTypes } from './constants/messageTypes';
12
12
  export type { IBaseMessageBody, IReceivedMessage, IReceivedConversation };
13
13
  export * from './types';
@@ -5,5 +5,6 @@ import HQVoiceMessage, { IHQVoiceMessageBody } from './voiceMessage';
5
5
  import FileMessage, { IFileMessageBody } from './fileMessage';
6
6
  import VideoMessage, { IVideoMessageBody } from './videoMessage';
7
7
  import RecallCommandMessage, { IRecallCommandMessageBody } from './recallCommandMessage';
8
+ import { ILocationMessageBody, IChatRecordMessageBody, IContactMessageBody, IInvitationMessageBody, IRedEnvelopeMessageBody, ITransferMessageBody } from './otherMediaMessages';
8
9
  export { TextMessage, ImageMessage, GIFMessage, HQVoiceMessage, FileMessage, RecallCommandMessage, VideoMessage };
9
- export type { ITextMessageBody, IImageMessageBody, IGIFMessageBody, IHQVoiceMessageBody, IFileMessageBody, IRecallCommandMessageBody, IVideoMessageBody };
10
+ export type { ITextMessageBody, IImageMessageBody, IGIFMessageBody, IHQVoiceMessageBody, IFileMessageBody, IRecallCommandMessageBody, IVideoMessageBody, ILocationMessageBody, IChatRecordMessageBody, IContactMessageBody, IInvitationMessageBody, IRedEnvelopeMessageBody, ITransferMessageBody };
@@ -0,0 +1,80 @@
1
+ export interface ILocationMessageBody {
2
+ thumbnailObjectKey: string;
3
+ title: string;
4
+ desc: string;
5
+ locationType: number;
6
+ encryptKey?: string;
7
+ lat: number;
8
+ lon: number;
9
+ }
10
+ export interface IChatRecordMessageBody {
11
+ chatTitle: string;
12
+ msgDataFileKey: string;
13
+ msgList: Array<{
14
+ srcId: string;
15
+ senderNickname: string;
16
+ mediaConstructor: number;
17
+ msgPostContent: string;
18
+ }>;
19
+ encryptKey?: string;
20
+ }
21
+ export interface IContactMessageBody {
22
+ uid: string;
23
+ nickname: string;
24
+ phoneNumber: string;
25
+ langcode: string;
26
+ smallAvatarUrl?: string;
27
+ gender: number;
28
+ }
29
+ export interface IInvitationMessageBody {
30
+ groupUin: string;
31
+ groupTitle: string;
32
+ inviteFromUin: string;
33
+ inviteFromNickName: string;
34
+ totalMemberCount: number;
35
+ createTime: number;
36
+ smallAvatarUrl?: string;
37
+ groupMemberSmallAvatarUrlArr?: string[];
38
+ }
39
+ export interface IRedEnvelopeMessageBody {
40
+ id: number;
41
+ createTime: string;
42
+ updateTime: string;
43
+ amount: string;
44
+ count: number;
45
+ uid: string;
46
+ nativeNumber: string;
47
+ nativeType: number;
48
+ sendSign: string;
49
+ title: string;
50
+ symbol: string;
51
+ receivedStatus: number;
52
+ status: number;
53
+ expireTime: number;
54
+ currency: string;
55
+ currencyLogo: string;
56
+ refundAmount: string;
57
+ receivedAmount?: string;
58
+ }
59
+ export interface ITransferMessageBody {
60
+ id: number;
61
+ createTime: string;
62
+ updateTime: string;
63
+ uid: string;
64
+ orderId: string;
65
+ src: string;
66
+ symbol: string;
67
+ type: number;
68
+ toUid: string;
69
+ nativeType: number;
70
+ money: number;
71
+ refName: string;
72
+ transNo: string;
73
+ status: number;
74
+ pushStatus: number;
75
+ currency: string;
76
+ currencyLogo: string;
77
+ network: string;
78
+ networkLogo: string;
79
+ refId: string;
80
+ }
package/types/types.d.ts CHANGED
@@ -65,12 +65,14 @@ export interface IConversationState extends IBaseConversationInfo {
65
65
  notificationLevel: NotificationLevel;
66
66
  notificationStatus: NotificationStatus;
67
67
  isTop: boolean;
68
+ dialogTitle: string | null | undefined;
69
+ smallAvatarUrl: string | null | undefined;
68
70
  }
69
71
  /**
70
72
  * 会话信息
71
73
  */
72
74
  export type IConversationOption = IBaseConversationInfo;
73
- export type IUpdatedConversationItemKeys = Extract<keyof IReceivedConversation, 'isTop' | 'notificationStatus' | 'notificationLevel' | 'unreadMessageCount' | 'hasMentioned' | 'unreadMentionedCount' | 'latestMessage'>;
75
+ export type IUpdatedConversationItemKeys = Extract<keyof IReceivedConversation, 'isTop' | 'notificationStatus' | 'notificationLevel' | 'unreadMessageCount' | 'hasMentioned' | 'unreadMentionedCount' | 'dialogTitle' | 'smallAvatarUrl' | 'latestMessage'>;
74
76
  export type IUpdatedConversationItem = Partial<Record<IUpdatedConversationItemKeys, {
75
77
  time: string;
76
78
  val: any;
@@ -214,7 +216,7 @@ export type GetHistoryMessageOption = {
214
216
  /**
215
217
  * 获取此时间之前的消息,0 为从当前时间拉取
216
218
  */
217
- timestamp?: number;
219
+ timestamp?: string;
218
220
  /**
219
221
  * 获取消息的数量,范围: 1-20
220
222
  */