easemob-websdk 5.1.3 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/bundle/im-sdk-web.iife.js +1 -1
  2. package/cache/cache-types.d.ts +2 -2
  3. package/chat-client.d.ts +17 -2
  4. package/chunks/chat-manager-BB7wYWYG.js +2 -0
  5. package/chunks/chat-manager-auF_3s3R.cjs +1 -0
  6. package/chunks/common-Cg-lTASK.cjs +1 -0
  7. package/chunks/common-gbNWJrBc.js +1 -0
  8. package/chunks/{group-user-info-resolver-B-dyr__b.cjs → group-user-info-resolver-BNwtC7dY.cjs} +1 -1
  9. package/chunks/{group-user-info-resolver-D6AQAHEE.js → group-user-info-resolver-rs5Fnr0l.js} +1 -1
  10. package/chunks/index-BUNbI8gf.cjs +1 -0
  11. package/chunks/index-BxMCMoWN.js +1 -0
  12. package/chunks/index-C7fO2X0x.cjs +1 -0
  13. package/chunks/index-C_EMU0-3.js +1 -0
  14. package/chunks/index-CsqE2tfH.js +1 -0
  15. package/chunks/index-DeJuR3uW.cjs +1 -0
  16. package/chunks/index-Dknccp9Q.js +1 -0
  17. package/chunks/index-P1vnLSK2.cjs +1 -0
  18. package/chunks/multibody-content-BHb-Au8Q.js +1 -0
  19. package/chunks/multibody-content-BmdQukoX.cjs +1 -0
  20. package/chunks/{push-manager-CSIKhoPe.js → push-manager-BO3xq-7O.js} +1 -1
  21. package/chunks/{push-manager-D7RDsKuv.cjs → push-manager-DMI0G9v9.cjs} +1 -1
  22. package/chunks/reflection-proto-codec-B1apL0ws.js +1 -0
  23. package/chunks/reflection-proto-codec-CYglS_mx.cjs +1 -0
  24. package/chunks/session-list-query-DMe2GZ4v.cjs +1 -0
  25. package/chunks/session-list-query-Inseic9m.js +1 -0
  26. package/chunks/{user-info-DH3aE1gm.cjs → user-info-B5St7axd.cjs} +1 -1
  27. package/chunks/{user-info-7QzMa7bR.js → user-info-BkqJHgja.js} +1 -1
  28. package/core/index.d.ts +1 -1
  29. package/core/message/attachment-downloader.d.ts +4 -1
  30. package/core/message/message-sender.d.ts +19 -4
  31. package/core/message/prepare-text-translation.d.ts +7 -0
  32. package/index.cjs +1 -1
  33. package/index.d.ts +3 -2
  34. package/index.js +2 -2
  35. package/managers/chat/index.cjs +1 -1
  36. package/managers/chat/index.js +1 -1
  37. package/managers/chat-manager.d.ts +128 -7
  38. package/managers/chat-thread/index.cjs +1 -1
  39. package/managers/chat-thread/index.js +1 -1
  40. package/managers/chatroom/index.cjs +1 -1
  41. package/managers/chatroom/index.js +1 -1
  42. package/managers/contact/index.cjs +1 -1
  43. package/managers/contact/index.js +1 -1
  44. package/managers/group/index.cjs +1 -1
  45. package/managers/group/index.js +1 -1
  46. package/managers/presence/index.cjs +1 -1
  47. package/managers/presence/index.js +1 -1
  48. package/managers/push/index.cjs +1 -1
  49. package/managers/push/index.js +1 -1
  50. package/managers/user-info/index.cjs +1 -1
  51. package/managers/user-info/index.js +1 -1
  52. package/message/combine-payload-codec.d.ts +2 -2
  53. package/message/combine-payload-file.d.ts +11 -0
  54. package/message/create-message.d.ts +16 -4
  55. package/message/create-multibody-message.d.ts +31 -0
  56. package/message/message-snapshot.d.ts +2 -1
  57. package/message/multibody-content.d.ts +35 -0
  58. package/message/translations.d.ts +7 -0
  59. package/package.json +1 -1
  60. package/platform/image/miniapp-image-processor.d.ts +10 -6
  61. package/protocol/msync/codec.d.ts +3 -0
  62. package/protocol/msync/message-payload-decoder.d.ts +5 -1
  63. package/protocol/session-list/payload-decoder.d.ts +2 -2
  64. package/types/chat-manager.d.ts +2 -2
  65. package/types/conversation.d.ts +2 -2
  66. package/types/index.d.ts +33 -9
  67. package/types/message-create.d.ts +130 -2
  68. package/upload/attachment-uploader.d.ts +8 -0
  69. package/validators/message-create.d.ts +25 -2
  70. package/chunks/chat-manager-BI-6bEor.cjs +0 -1
  71. package/chunks/chat-manager-nXOTpJ01.js +0 -2
  72. package/chunks/common-DHQukb7J.js +0 -1
  73. package/chunks/common-tHGz9VBk.cjs +0 -1
  74. package/chunks/index-CneY58NJ.js +0 -1
  75. package/chunks/index-DJPAjXAp.cjs +0 -1
  76. package/chunks/index-DtWkVcfb.cjs +0 -1
  77. package/chunks/index-DxjmfFL7.js +0 -1
  78. package/chunks/reflection-proto-codec-7r8Sei3y.js +0 -1
  79. package/chunks/reflection-proto-codec-CwrIKT1L.cjs +0 -1
  80. package/chunks/session-list-query-C3iQvQxK.cjs +0 -1
  81. package/chunks/session-list-query-Cdpiw_IZ.js +0 -1
@@ -29,24 +29,39 @@ export declare class MessageSender {
29
29
  constructor(msyncCodec: MsyncCodec, websocket: SocketLike | null, eventHub: EventHub, attachmentUploader?: AttachmentUploader);
30
30
  updateAuthToken(token: string): void;
31
31
  /**
32
- * 发送消息
32
+ * 发送一条消息。调用方看到的是这一个方法,实际分成准备和等待回执两段。
33
+ *
34
+ * 1. 流式消息,或 WebSocket 未连接:直接失败,不上传。
35
+ * 2. 合并消息先打成一个文件。其他类型跳过。
36
+ * 3. `prepareMessage` 上传本地附件,并把远端地址写回消息体。复合消息在这里按段串行上传。
37
+ * 4. 调用 `onSending`。这时消息还没写到网上。
38
+ * 5. `doSendMessage` 编码并写出,然后停在 Promise 上,直到下面三者之一:
39
+ * - `handleAck`:服务端接受,补上 `msgServerId`,清本地文件,再 `onSuccess`。
40
+ * - `handleSendError`:服务端拒绝或连接中断。
41
+ * - 超时:一直没有回执。
42
+ * 6. 第 3 步之后的失败也进下面的 catch。`onFailed` 拿到的是上传后的消息,
43
+ * 已成功的附件带远端地址,再次发送时会跳过。
33
44
  */
34
45
  sendMessage(message: Message, options?: SendMessageOptions): Promise<Message>;
35
46
  sendAction(action: MessageActionRequest, createAckError?: (statusCode: number, reason?: string) => Error): Promise<ActionAckResult>;
36
47
  sendChatRoomOperation(request: ChatRoomOperationRequest, createAckError?: (statusCode: number, reason?: string) => Error): Promise<ActionAckResult>;
37
48
  /**
38
- * 实际发送消息
49
+ * 把准备好的消息写到 WebSocket,并等待服务端回执。
50
+ * 这里先登记待确认消息,再发送。回执到达时用 protocolId 找回这条登记,
51
+ * 由 `handleAck` 或 `handleSendError` 结束这个 Promise。
39
52
  */
40
53
  private doSendMessage;
41
54
  private sendProtocolPayload;
42
55
  private prepareCombineMessage;
43
56
  /**
44
- * 处理 ACK
57
+ * 服务端接受了这条消息。用 protocolId 找到 `doSendMessage` 登记的待确认消息,
58
+ * 写入服务端 id,清掉本地附件,再 resolve,发送 Promise 才返回。
45
59
  */
46
60
  handleAck(protocolId: string, msgServerId?: string, replacedMessage?: Message, chatRoomInfo?: JoinChatRoomInfo): void;
47
61
  private resolveReplacedMessage;
48
62
  /**
49
- * 处理发送失败
63
+ * 消息已经写出,但服务端拒绝或连接中断。
64
+ * reject 之后回到 `sendMessage` 的 catch,由那里回调 `onFailed`。
50
65
  */
51
66
  handleSendError(protocolId: string, error: Error): void;
52
67
  handleAckFailure(protocolId: string, statusCode: number, reason: string | undefined, error: Error): void;
@@ -0,0 +1,7 @@
1
+ import type { Message } from '../../types';
2
+ import type { MessageTranslationResult } from '../../types/chat-manager';
3
+ /** 仅为本次发送准备消息快照,不回填调用方持有的消息对象。 */
4
+ export declare const prepareTextTranslation: (message: Message, translate: (params: {
5
+ readonly text: string;
6
+ readonly targetLanguages: ReadonlyArray<string>;
7
+ }) => Promise<MessageTranslationResult>) => Promise<Message>;