@onyx-p/imlib-web 1.4.6 → 1.4.8

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
@@ -9470,7 +9470,7 @@ var CmdIds;
9470
9470
  CmdIds[CmdIds["GetNewMessage"] = 1610682407] = "GetNewMessage";
9471
9471
  CmdIds[CmdIds["RecallPrivateMessage"] = 1610682402] = "RecallPrivateMessage";
9472
9472
  CmdIds[CmdIds["RecallGroupMessage"] = 1610747947] = "RecallGroupMessage";
9473
- CmdIds[CmdIds["GetRemoteMessages"] = 1610682416] = "GetRemoteMessages";
9473
+ CmdIds[CmdIds["GetRemoteMessages"] = 1610682419] = "GetRemoteMessages";
9474
9474
  CmdIds[CmdIds["GetSuperGroupRemoteMessages"] = 1610776956] = "GetSuperGroupRemoteMessages";
9475
9475
  CmdIds[CmdIds["DeleteChatMessages"] = 1610682381] = "DeleteChatMessages";
9476
9476
  CmdIds[CmdIds["ClearChatHistoryMessage"] = 1610777164] = "ClearChatHistoryMessage";
@@ -16526,7 +16526,7 @@ const GetHistoryMessageReq = $root$1.GetHistoryMessageReq = (() => {
16526
16526
  * Properties of a GetHistoryMessageReq.
16527
16527
  * @exports IGetHistoryMessageReq
16528
16528
  * @interface IGetHistoryMessageReq
16529
- * @property {Long|null} [dialogKeys] GetHistoryMessageReq dialogKeys
16529
+ * @property {string|null} [dialogKeys] GetHistoryMessageReq dialogKeys
16530
16530
  * @property {Long|null} [offset] GetHistoryMessageReq offset
16531
16531
  * @property {Long|null} [oldOffset] GetHistoryMessageReq oldOffset
16532
16532
  * @property {number|null} [rows] GetHistoryMessageReq rows
@@ -16547,11 +16547,11 @@ const GetHistoryMessageReq = $root$1.GetHistoryMessageReq = (() => {
16547
16547
 
16548
16548
  /**
16549
16549
  * GetHistoryMessageReq dialogKeys.
16550
- * @member {Long} dialogKeys
16550
+ * @member {string} dialogKeys
16551
16551
  * @memberof GetHistoryMessageReq
16552
16552
  * @instance
16553
16553
  */
16554
- GetHistoryMessageReq.prototype.dialogKeys = $util$1.Long ? $util$1.Long.fromBits(0, 0, false) : 0;
16554
+ GetHistoryMessageReq.prototype.dialogKeys = "";
16555
16555
 
16556
16556
  /**
16557
16557
  * GetHistoryMessageReq offset.
@@ -16596,7 +16596,7 @@ const GetHistoryMessageReq = $root$1.GetHistoryMessageReq = (() => {
16596
16596
  */
16597
16597
  GetHistoryMessageReq.encode = function encode(message, writer) {
16598
16598
  if (!writer) writer = $Writer$1.create();
16599
- if (message.dialogKeys != null && Object.hasOwnProperty.call(message, "dialogKeys")) writer.uint32(/* id 1, wireType 0 =*/8).int64(message.dialogKeys);
16599
+ if (message.dialogKeys != null && Object.hasOwnProperty.call(message, "dialogKeys")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.dialogKeys);
16600
16600
  if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) writer.uint32(/* id 2, wireType 0 =*/16).int64(message.offset);
16601
16601
  if (message.oldOffset != null && Object.hasOwnProperty.call(message, "oldOffset")) writer.uint32(/* id 3, wireType 0 =*/24).int64(message.oldOffset);
16602
16602
  if (message.rows != null && Object.hasOwnProperty.call(message, "rows")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.rows);
@@ -16624,7 +16624,7 @@ const GetHistoryMessageReq = $root$1.GetHistoryMessageReq = (() => {
16624
16624
  switch (tag >>> 3) {
16625
16625
  case 1:
16626
16626
  {
16627
- message.dialogKeys = reader.int64();
16627
+ message.dialogKeys = reader.string();
16628
16628
  break;
16629
16629
  }
16630
16630
  case 2:
@@ -18481,7 +18481,7 @@ const recallChatMessage = (dialogId, messageUId) => {
18481
18481
  };
18482
18482
  const getRemoteMessages = params => {
18483
18483
  const reqParams = {
18484
- dialogKeys: Long.fromString(params.dialogId),
18484
+ dialogKeys: params.dialogId,
18485
18485
  newToOld: params.newToOld,
18486
18486
  rows: params.count
18487
18487
  };
@@ -26758,6 +26758,24 @@ function calcPosition(width, height, thumbnailConfig) {
26758
26758
  return scale > thumbnailConfig.scale ? gtScale() : ltScale();
26759
26759
  }
26760
26760
 
26761
+ function formatDurationSeconds(timeSeconds) {
26762
+ const seconds = Math.max(0, timeSeconds);
26763
+ const secondsPart = seconds % 60;
26764
+ const minutesPart = Math.floor(seconds / 60 % 60);
26765
+ const hoursPart = Math.floor(seconds / 3600);
26766
+ if (hoursPart > 0) {
26767
+ return `${hoursPart}:${minutesPart.toString().padStart(2, '0')}:${secondsPart.toString().padStart(2, '0')}`;
26768
+ } else {
26769
+ return `${minutesPart}:${secondsPart.toString().padStart(2, '0')}`;
26770
+ }
26771
+ }
26772
+
26773
+ const DefaultThumbnailConfig = {
26774
+ maxHeight: 500,
26775
+ maxWidth: 500,
26776
+ quality: 0.6,
26777
+ scale: 2.4
26778
+ };
26761
26779
  class Img {
26762
26780
  async create(file) {
26763
26781
  try {
@@ -26769,13 +26787,7 @@ class Img {
26769
26787
  compressWidth,
26770
26788
  compressHeight
26771
26789
  } = compress(image, 0.85, file.type);
26772
- const config = {
26773
- maxHeight: 160,
26774
- maxWidth: 160,
26775
- quality: 0.6,
26776
- scale: 2.4
26777
- };
26778
- const thumbnail = getThumbnail(image, config);
26790
+ const thumbnail = getThumbnail(image, DefaultThumbnailConfig);
26779
26791
  return {
26780
26792
  success: true,
26781
26793
  message: new ImageMessage({
@@ -26912,6 +26924,66 @@ class File {
26912
26924
  return content;
26913
26925
  }
26914
26926
  }
26927
+ class Sight {
26928
+ async create(file) {
26929
+ try {
26930
+ if (file.size > 100 * 1024 * 1024) {
26931
+ return {
26932
+ success: false
26933
+ };
26934
+ }
26935
+ const videoUrl = getBlobUrl(file);
26936
+ const video = document.createElement('video');
26937
+ video.src = videoUrl;
26938
+ await new Promise((resolve, reject) => {
26939
+ video.onloadedmetadata = resolve;
26940
+ video.onerror = reject;
26941
+ });
26942
+ const duration = video.duration;
26943
+ const width = video.videoWidth;
26944
+ const height = video.videoHeight;
26945
+ const scale = Math.min(DefaultThumbnailConfig.maxWidth / width, DefaultThumbnailConfig.maxHeight / height, DefaultThumbnailConfig.scale);
26946
+ const thumbnailWidth = Math.floor(width * scale);
26947
+ const thumbnailHeight = Math.floor(height * scale);
26948
+ const canvas = document.createElement('canvas');
26949
+ canvas.width = thumbnailWidth;
26950
+ canvas.height = thumbnailHeight;
26951
+ const ctx = canvas.getContext('2d');
26952
+ ctx?.drawImage(video, 0, 0, thumbnailWidth, thumbnailHeight);
26953
+ const thumbnailBlob = await new Promise(resolve => {
26954
+ canvas.toBlob(blob => resolve(blob), 'image/jpeg', DefaultThumbnailConfig.quality);
26955
+ });
26956
+ revokeBlobUrl(videoUrl);
26957
+ return {
26958
+ success: true,
26959
+ message: new VideoMessage({
26960
+ videoObjectKey: "",
26961
+ thumbnailObjectKey: "",
26962
+ during: formatDurationSeconds(duration),
26963
+ width,
26964
+ height,
26965
+ extension: getBlobExtension(file)
26966
+ }),
26967
+ files: [file, thumbnailBlob]
26968
+ };
26969
+ } catch (error) {
26970
+ return {
26971
+ success: false
26972
+ };
26973
+ }
26974
+ }
26975
+ updateMessageRemoteUrlProperty(messageContent, uploadedResult) {
26976
+ let content = deepClone(messageContent);
26977
+ const {
26978
+ urls: [videoObjectKey, thumbnailObjectKey],
26979
+ encryptedKey
26980
+ } = uploadedResult;
26981
+ content.videoObjectKey = videoObjectKey;
26982
+ content.thumbnailObjectKey = thumbnailObjectKey;
26983
+ content.encryptKey = encryptedKey;
26984
+ return content;
26985
+ }
26986
+ }
26915
26987
  var FileType;
26916
26988
  (function (FileType) {
26917
26989
  FileType[FileType["IMAGE"] = 1] = "IMAGE";
@@ -26936,6 +27008,9 @@ const getMediaMessageCreator = fileType => {
26936
27008
  case FileType.FILE:
26937
27009
  creator = new File();
26938
27010
  break;
27011
+ case FileType.SIGHT:
27012
+ creator = new Sight();
27013
+ break;
26939
27014
  }
26940
27015
  return creator;
26941
27016
  };
@@ -26947,6 +27022,7 @@ async function sendMessage$1(conversation, message, options) {
26947
27022
  const sendImageMessage$1 = createSendFunction.bind(null, FileType.IMAGE);
26948
27023
  const sendGIFMessage$1 = createSendFunction.bind(null, FileType.GIF);
26949
27024
  const sendHQVoiceMessage$1 = createSendFunction.bind(null, FileType.AUDIO);
27025
+ const sendSightMessage$1 = createSendFunction.bind(null, FileType.VIDEO);
26950
27026
  const sendFileMessage$1 = createSendFunction.bind(null, FileType.FILE);
26951
27027
  const sendRecallMessage = async (conversation, options) => {
26952
27028
  const dialogId = getFullDialogId(conversation);
@@ -27093,7 +27169,7 @@ async function send(message, sentArgs) {
27093
27169
  SentMessageStore.addMessage(sentArgs.messageId);
27094
27170
  const baseParams = {
27095
27171
  localId: Long.fromString(sentArgs.messageId),
27096
- mediaFlag: false,
27172
+ mediaFlag: message.messageType !== MessageTypes.TEXT,
27097
27173
  mediaConstructor: message.messageType,
27098
27174
  msgPreContent: '',
27099
27175
  msgPostContent: postEncryptedString,
@@ -27230,9 +27306,11 @@ class IMClient extends EventEmitter {
27230
27306
  sendGIFMessage = sendGIFMessage$1;
27231
27307
  sendHQVoiceMessage = sendHQVoiceMessage$1;
27232
27308
  sendFileMessage = sendFileMessage$1;
27309
+ sendSightMessage = sendSightMessage$1;
27233
27310
  recallMsg = sendRecallMessage;
27234
27311
  async getRemoteHistoryMessages(conversation, options) {
27235
27312
  const dialogId = getFullDialogId(conversation);
27313
+ debugger;
27236
27314
  return getRemoteMessages({
27237
27315
  dialogId,
27238
27316
  offset: options.timestamp ?? 0,
@@ -27250,10 +27328,11 @@ class IMClient extends EventEmitter {
27250
27328
  });
27251
27329
  return;
27252
27330
  }
27331
+ debugger;
27253
27332
  ServerMessageParser.parse({
27254
- [dialogId.toString()]: data.msg ?? {}
27333
+ [dialogId]: data.msg ?? {}
27255
27334
  }, (_, outputMsgs) => {
27256
- const messageList = outputMsgs.get(dialogId.toString()) ?? [];
27335
+ const messageList = outputMsgs.get(dialogId) ?? [];
27257
27336
  messageList.sort((e1, e2) => Long.fromString(e1.sentTime).lessThan(Long.fromString(e2.sentTime)) ? -1 : 1);
27258
27337
  resolve({
27259
27338
  code: ErrorCode.SUCCESS,
@@ -28593,6 +28672,15 @@ const sendFileMessage = async (conversation, msgBody, hooks, sendOptions) => {
28593
28672
  _logSendError(conversation, response.code);
28594
28673
  return response;
28595
28674
  };
28675
+ const sendSightMessage = async (conversation, msgBody, hooks, sendOptions) => {
28676
+ assert('conversation', conversation, AssertRules.CONVERSATION, true);
28677
+ assert('uploader', imConfig.getUploader(), AssertRules.OBJECT, true);
28678
+ assert('msgBody.file', msgBody.file, file => file instanceof Blob && file.type === 'video/mp4', true);
28679
+ _logSendBefore(conversation);
28680
+ const response = await imClient.sendSightMessage(conversation, msgBody, hooks, sendOptions);
28681
+ _logSendError(conversation, response.code);
28682
+ return response;
28683
+ };
28596
28684
  const recallMessage = async (conversation, options) => {
28597
28685
  assert('options.messageUId', options.messageUId, AssertRules.STRING, true);
28598
28686
  assert('options.sentTime', options.sentTime, AssertRules.NUMBER, true);
@@ -28692,4 +28780,4 @@ const _logSendError = (conversation, errorCode) => {
28692
28780
  }
28693
28781
  };
28694
28782
 
28695
- export { ConnectionStatus, ConversationType, ErrorCode, ErrorDesc, Events, FileMessage, GIFMessage, VoiceMessage as HQVoiceMessage, ImageMessage, LogLevel, MentionedType, MessageDirection, MessageTypes, NotificationLevel, NotificationStatus, ReceivedStatus, SentStatus, TextMessage, VideoMessage, addEventListener, clearAllMessagesUnreadStatus, clearHistoryMessages, clearMessagesUnreadStatus, clearTextMessageDraft, connect, deleteMessages, disconnect, getAllConversationState, getAllUnreadMentionedCount, getBlockedConversationList, getConnectionStatus, getConversation, getConversationList, getConversationNotificationLevel, getConversationNotificationStatus, getHistoryMessages, getRemoteHistoryMessages, getServerTime, getTextMessageDraft, getTopConversationList, getTotalUnreadCount, getUnreadCount, getUnreadMentionedCount, init, logOut, mockLogin, onceEventListener, recallMessage, registerMessageType, removeConversation, removeEventListener, request, saveTextMessageDraft, sendFileMessage, sendGIFMessage, sendHQVoiceMessage, sendImageMessage, sendMessage, sendTextMessage, setConversationNotificationStatus, setConversationToTop, setUserLogged };
28783
+ export { ConnectionStatus, ConversationType, ErrorCode, ErrorDesc, Events, FileMessage, GIFMessage, VoiceMessage as HQVoiceMessage, ImageMessage, LogLevel, MentionedType, MessageDirection, MessageTypes, NotificationLevel, NotificationStatus, ReceivedStatus, SentStatus, TextMessage, VideoMessage, addEventListener, clearAllMessagesUnreadStatus, clearHistoryMessages, clearMessagesUnreadStatus, clearTextMessageDraft, connect, deleteMessages, disconnect, getAllConversationState, getAllUnreadMentionedCount, getBlockedConversationList, getConnectionStatus, getConversation, getConversationList, getConversationNotificationLevel, getConversationNotificationStatus, getHistoryMessages, getRemoteHistoryMessages, getServerTime, getTextMessageDraft, getTopConversationList, getTotalUnreadCount, getUnreadCount, getUnreadMentionedCount, init, logOut, mockLogin, onceEventListener, recallMessage, registerMessageType, removeConversation, removeEventListener, request, saveTextMessageDraft, sendFileMessage, sendGIFMessage, sendHQVoiceMessage, sendImageMessage, sendMessage, sendSightMessage, sendTextMessage, setConversationNotificationStatus, setConversationToTop, setUserLogged };
package/index.umd.js CHANGED
@@ -9476,7 +9476,7 @@
9476
9476
  CmdIds[CmdIds["GetNewMessage"] = 1610682407] = "GetNewMessage";
9477
9477
  CmdIds[CmdIds["RecallPrivateMessage"] = 1610682402] = "RecallPrivateMessage";
9478
9478
  CmdIds[CmdIds["RecallGroupMessage"] = 1610747947] = "RecallGroupMessage";
9479
- CmdIds[CmdIds["GetRemoteMessages"] = 1610682416] = "GetRemoteMessages";
9479
+ CmdIds[CmdIds["GetRemoteMessages"] = 1610682419] = "GetRemoteMessages";
9480
9480
  CmdIds[CmdIds["GetSuperGroupRemoteMessages"] = 1610776956] = "GetSuperGroupRemoteMessages";
9481
9481
  CmdIds[CmdIds["DeleteChatMessages"] = 1610682381] = "DeleteChatMessages";
9482
9482
  CmdIds[CmdIds["ClearChatHistoryMessage"] = 1610777164] = "ClearChatHistoryMessage";
@@ -16532,7 +16532,7 @@
16532
16532
  * Properties of a GetHistoryMessageReq.
16533
16533
  * @exports IGetHistoryMessageReq
16534
16534
  * @interface IGetHistoryMessageReq
16535
- * @property {Long|null} [dialogKeys] GetHistoryMessageReq dialogKeys
16535
+ * @property {string|null} [dialogKeys] GetHistoryMessageReq dialogKeys
16536
16536
  * @property {Long|null} [offset] GetHistoryMessageReq offset
16537
16537
  * @property {Long|null} [oldOffset] GetHistoryMessageReq oldOffset
16538
16538
  * @property {number|null} [rows] GetHistoryMessageReq rows
@@ -16553,11 +16553,11 @@
16553
16553
 
16554
16554
  /**
16555
16555
  * GetHistoryMessageReq dialogKeys.
16556
- * @member {Long} dialogKeys
16556
+ * @member {string} dialogKeys
16557
16557
  * @memberof GetHistoryMessageReq
16558
16558
  * @instance
16559
16559
  */
16560
- GetHistoryMessageReq.prototype.dialogKeys = $util$1.Long ? $util$1.Long.fromBits(0, 0, false) : 0;
16560
+ GetHistoryMessageReq.prototype.dialogKeys = "";
16561
16561
 
16562
16562
  /**
16563
16563
  * GetHistoryMessageReq offset.
@@ -16602,7 +16602,7 @@
16602
16602
  */
16603
16603
  GetHistoryMessageReq.encode = function encode(message, writer) {
16604
16604
  if (!writer) writer = $Writer$1.create();
16605
- if (message.dialogKeys != null && Object.hasOwnProperty.call(message, "dialogKeys")) writer.uint32(/* id 1, wireType 0 =*/8).int64(message.dialogKeys);
16605
+ if (message.dialogKeys != null && Object.hasOwnProperty.call(message, "dialogKeys")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.dialogKeys);
16606
16606
  if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) writer.uint32(/* id 2, wireType 0 =*/16).int64(message.offset);
16607
16607
  if (message.oldOffset != null && Object.hasOwnProperty.call(message, "oldOffset")) writer.uint32(/* id 3, wireType 0 =*/24).int64(message.oldOffset);
16608
16608
  if (message.rows != null && Object.hasOwnProperty.call(message, "rows")) writer.uint32(/* id 4, wireType 0 =*/32).int32(message.rows);
@@ -16630,7 +16630,7 @@
16630
16630
  switch (tag >>> 3) {
16631
16631
  case 1:
16632
16632
  {
16633
- message.dialogKeys = reader.int64();
16633
+ message.dialogKeys = reader.string();
16634
16634
  break;
16635
16635
  }
16636
16636
  case 2:
@@ -18487,7 +18487,7 @@
18487
18487
  };
18488
18488
  const getRemoteMessages = params => {
18489
18489
  const reqParams = {
18490
- dialogKeys: Long.fromString(params.dialogId),
18490
+ dialogKeys: params.dialogId,
18491
18491
  newToOld: params.newToOld,
18492
18492
  rows: params.count
18493
18493
  };
@@ -26764,6 +26764,24 @@
26764
26764
  return scale > thumbnailConfig.scale ? gtScale() : ltScale();
26765
26765
  }
26766
26766
 
26767
+ function formatDurationSeconds(timeSeconds) {
26768
+ const seconds = Math.max(0, timeSeconds);
26769
+ const secondsPart = seconds % 60;
26770
+ const minutesPart = Math.floor(seconds / 60 % 60);
26771
+ const hoursPart = Math.floor(seconds / 3600);
26772
+ if (hoursPart > 0) {
26773
+ return `${hoursPart}:${minutesPart.toString().padStart(2, '0')}:${secondsPart.toString().padStart(2, '0')}`;
26774
+ } else {
26775
+ return `${minutesPart}:${secondsPart.toString().padStart(2, '0')}`;
26776
+ }
26777
+ }
26778
+
26779
+ const DefaultThumbnailConfig = {
26780
+ maxHeight: 500,
26781
+ maxWidth: 500,
26782
+ quality: 0.6,
26783
+ scale: 2.4
26784
+ };
26767
26785
  class Img {
26768
26786
  async create(file) {
26769
26787
  try {
@@ -26775,13 +26793,7 @@
26775
26793
  compressWidth,
26776
26794
  compressHeight
26777
26795
  } = compress(image, 0.85, file.type);
26778
- const config = {
26779
- maxHeight: 160,
26780
- maxWidth: 160,
26781
- quality: 0.6,
26782
- scale: 2.4
26783
- };
26784
- const thumbnail = getThumbnail(image, config);
26796
+ const thumbnail = getThumbnail(image, DefaultThumbnailConfig);
26785
26797
  return {
26786
26798
  success: true,
26787
26799
  message: new ImageMessage({
@@ -26918,6 +26930,66 @@
26918
26930
  return content;
26919
26931
  }
26920
26932
  }
26933
+ class Sight {
26934
+ async create(file) {
26935
+ try {
26936
+ if (file.size > 100 * 1024 * 1024) {
26937
+ return {
26938
+ success: false
26939
+ };
26940
+ }
26941
+ const videoUrl = getBlobUrl(file);
26942
+ const video = document.createElement('video');
26943
+ video.src = videoUrl;
26944
+ await new Promise((resolve, reject) => {
26945
+ video.onloadedmetadata = resolve;
26946
+ video.onerror = reject;
26947
+ });
26948
+ const duration = video.duration;
26949
+ const width = video.videoWidth;
26950
+ const height = video.videoHeight;
26951
+ const scale = Math.min(DefaultThumbnailConfig.maxWidth / width, DefaultThumbnailConfig.maxHeight / height, DefaultThumbnailConfig.scale);
26952
+ const thumbnailWidth = Math.floor(width * scale);
26953
+ const thumbnailHeight = Math.floor(height * scale);
26954
+ const canvas = document.createElement('canvas');
26955
+ canvas.width = thumbnailWidth;
26956
+ canvas.height = thumbnailHeight;
26957
+ const ctx = canvas.getContext('2d');
26958
+ ctx?.drawImage(video, 0, 0, thumbnailWidth, thumbnailHeight);
26959
+ const thumbnailBlob = await new Promise(resolve => {
26960
+ canvas.toBlob(blob => resolve(blob), 'image/jpeg', DefaultThumbnailConfig.quality);
26961
+ });
26962
+ revokeBlobUrl(videoUrl);
26963
+ return {
26964
+ success: true,
26965
+ message: new VideoMessage({
26966
+ videoObjectKey: "",
26967
+ thumbnailObjectKey: "",
26968
+ during: formatDurationSeconds(duration),
26969
+ width,
26970
+ height,
26971
+ extension: getBlobExtension(file)
26972
+ }),
26973
+ files: [file, thumbnailBlob]
26974
+ };
26975
+ } catch (error) {
26976
+ return {
26977
+ success: false
26978
+ };
26979
+ }
26980
+ }
26981
+ updateMessageRemoteUrlProperty(messageContent, uploadedResult) {
26982
+ let content = deepClone(messageContent);
26983
+ const {
26984
+ urls: [videoObjectKey, thumbnailObjectKey],
26985
+ encryptedKey
26986
+ } = uploadedResult;
26987
+ content.videoObjectKey = videoObjectKey;
26988
+ content.thumbnailObjectKey = thumbnailObjectKey;
26989
+ content.encryptKey = encryptedKey;
26990
+ return content;
26991
+ }
26992
+ }
26921
26993
  var FileType;
26922
26994
  (function (FileType) {
26923
26995
  FileType[FileType["IMAGE"] = 1] = "IMAGE";
@@ -26942,6 +27014,9 @@
26942
27014
  case FileType.FILE:
26943
27015
  creator = new File();
26944
27016
  break;
27017
+ case FileType.SIGHT:
27018
+ creator = new Sight();
27019
+ break;
26945
27020
  }
26946
27021
  return creator;
26947
27022
  };
@@ -26953,6 +27028,7 @@
26953
27028
  const sendImageMessage$1 = createSendFunction.bind(null, FileType.IMAGE);
26954
27029
  const sendGIFMessage$1 = createSendFunction.bind(null, FileType.GIF);
26955
27030
  const sendHQVoiceMessage$1 = createSendFunction.bind(null, FileType.AUDIO);
27031
+ const sendSightMessage$1 = createSendFunction.bind(null, FileType.VIDEO);
26956
27032
  const sendFileMessage$1 = createSendFunction.bind(null, FileType.FILE);
26957
27033
  const sendRecallMessage = async (conversation, options) => {
26958
27034
  const dialogId = getFullDialogId(conversation);
@@ -27099,7 +27175,7 @@
27099
27175
  SentMessageStore.addMessage(sentArgs.messageId);
27100
27176
  const baseParams = {
27101
27177
  localId: Long.fromString(sentArgs.messageId),
27102
- mediaFlag: false,
27178
+ mediaFlag: message.messageType !== MessageTypes.TEXT,
27103
27179
  mediaConstructor: message.messageType,
27104
27180
  msgPreContent: '',
27105
27181
  msgPostContent: postEncryptedString,
@@ -27236,9 +27312,11 @@
27236
27312
  sendGIFMessage = sendGIFMessage$1;
27237
27313
  sendHQVoiceMessage = sendHQVoiceMessage$1;
27238
27314
  sendFileMessage = sendFileMessage$1;
27315
+ sendSightMessage = sendSightMessage$1;
27239
27316
  recallMsg = sendRecallMessage;
27240
27317
  async getRemoteHistoryMessages(conversation, options) {
27241
27318
  const dialogId = getFullDialogId(conversation);
27319
+ debugger;
27242
27320
  return getRemoteMessages({
27243
27321
  dialogId,
27244
27322
  offset: options.timestamp ?? 0,
@@ -27256,10 +27334,11 @@
27256
27334
  });
27257
27335
  return;
27258
27336
  }
27337
+ debugger;
27259
27338
  ServerMessageParser.parse({
27260
- [dialogId.toString()]: data.msg ?? {}
27339
+ [dialogId]: data.msg ?? {}
27261
27340
  }, (_, outputMsgs) => {
27262
- const messageList = outputMsgs.get(dialogId.toString()) ?? [];
27341
+ const messageList = outputMsgs.get(dialogId) ?? [];
27263
27342
  messageList.sort((e1, e2) => Long.fromString(e1.sentTime).lessThan(Long.fromString(e2.sentTime)) ? -1 : 1);
27264
27343
  resolve({
27265
27344
  code: exports.ErrorCode.SUCCESS,
@@ -28599,6 +28678,15 @@
28599
28678
  _logSendError(conversation, response.code);
28600
28679
  return response;
28601
28680
  };
28681
+ const sendSightMessage = async (conversation, msgBody, hooks, sendOptions) => {
28682
+ assert('conversation', conversation, AssertRules.CONVERSATION, true);
28683
+ assert('uploader', imConfig.getUploader(), AssertRules.OBJECT, true);
28684
+ assert('msgBody.file', msgBody.file, file => file instanceof Blob && file.type === 'video/mp4', true);
28685
+ _logSendBefore(conversation);
28686
+ const response = await imClient.sendSightMessage(conversation, msgBody, hooks, sendOptions);
28687
+ _logSendError(conversation, response.code);
28688
+ return response;
28689
+ };
28602
28690
  const recallMessage = async (conversation, options) => {
28603
28691
  assert('options.messageUId', options.messageUId, AssertRules.STRING, true);
28604
28692
  assert('options.sentTime', options.sentTime, AssertRules.NUMBER, true);
@@ -28745,6 +28833,7 @@
28745
28833
  exports.sendHQVoiceMessage = sendHQVoiceMessage;
28746
28834
  exports.sendImageMessage = sendImageMessage;
28747
28835
  exports.sendMessage = sendMessage;
28836
+ exports.sendSightMessage = sendSightMessage;
28748
28837
  exports.sendTextMessage = sendTextMessage;
28749
28838
  exports.setConversationNotificationStatus = setConversationNotificationStatus;
28750
28839
  exports.setConversationToTop = setConversationToTop;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onyx-p/imlib-web",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
4
4
  "main": "index.umd.js",
5
5
  "module": "index.esm.js",
6
6
  "types": "types/index.d.ts",
package/types/index.d.ts CHANGED
@@ -195,6 +195,10 @@ export declare const sendHQVoiceMessage: (conversation: IConversationOption, msg
195
195
  * 发送文件消息
196
196
  */
197
197
  export declare const sendFileMessage: (conversation: IConversationOption, msgBody: ISendBody, hooks?: IUploadHooks, sendOptions?: IUploadMessageOption) => IPromiseResult<IReceivedMessage>;
198
+ /**
199
+ * 发送短视频消息
200
+ */
201
+ export declare const sendSightMessage: (conversation: IConversationOption, msgBody: ISendBody, hooks?: IUploadHooks, sendOptions?: IUploadMessageOption) => IPromiseResult<IReceivedMessage>;
198
202
  /**
199
203
  * 撤回消息
200
204
  * @param options