easemob-websdk 4.21.1 → 4.22.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.
package/Easemob-chat.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export interface EasemobChatStatic {
2
2
  connection: typeof EasemobChat.Connection;
3
3
  message: typeof EasemobChat.Message;
4
+ image: EasemobChat.ImageModule;
4
5
  utils: EasemobChat.Utils;
5
6
  logger: EasemobChat.Logger;
6
7
  statusCode: EasemobChat.Code;
@@ -66,6 +67,78 @@ export declare namespace EasemobChat {
66
67
 
67
68
  type VoiceSourceFile = File | MiniProgramVoiceFile;
68
69
 
70
+ interface ImageInfo {
71
+ width: number;
72
+ height: number;
73
+ type?: string;
74
+ }
75
+
76
+ interface BigImageOptions {
77
+ maxShortEdge: number;
78
+ quality: number;
79
+ }
80
+
81
+ interface BigImageResult {
82
+ file?: File;
83
+ path?: string;
84
+ width: number;
85
+ height: number;
86
+ size: number;
87
+ type: string;
88
+ }
89
+
90
+ interface ImageProcessor {
91
+ getImageInfo(source: File | string): Promise<ImageInfo>;
92
+ generateBigImage(
93
+ source: File | string,
94
+ options: BigImageOptions
95
+ ): Promise<BigImageResult | null>;
96
+ computeMd5(source: File | string): Promise<string>;
97
+ }
98
+
99
+ interface MiniAppRuntime {
100
+ getImageInfo(options: {
101
+ src: string;
102
+ success: (res: { width: number; height: number; type?: string }) => void;
103
+ fail: (err: any) => void;
104
+ }): void;
105
+ compressImage?(options: {
106
+ src: string;
107
+ quality?: number;
108
+ compressedWidth?: number;
109
+ compressedHeight?: number;
110
+ success?: (res: { tempFilePath: string }) => void;
111
+ fail?: (err: any) => void;
112
+ }): void;
113
+ getFileSystemManager?(): {
114
+ getFileInfo(options: {
115
+ filePath: string;
116
+ success: (res: { size: number }) => void;
117
+ fail: (err: any) => void;
118
+ }): void;
119
+ readFile(options: {
120
+ filePath: string;
121
+ encoding?: string;
122
+ success: (res: { data: ArrayBuffer | string }) => void;
123
+ fail: (err: any) => void;
124
+ }): void;
125
+ };
126
+ }
127
+
128
+ interface ImageModule {
129
+ DEFAULT_BIG_IMAGE_SHORT_EDGE: number;
130
+ DEFAULT_BIG_IMAGE_QUALITY: number;
131
+ webImageProcessor: ImageProcessor;
132
+ resolveScaledSize: (
133
+ width: number,
134
+ height: number,
135
+ maxShortEdge: number
136
+ ) => { width: number; height: number };
137
+ createMiniAppImageProcessor: (
138
+ runtime: MiniAppRuntime
139
+ ) => ImageProcessor;
140
+ }
141
+
69
142
  type ExcludeAckMessageBody = Exclude<
70
143
  MessageBody,
71
144
  ReadMsgBody | DeliveryMsgBody | ChannelMsgBody
@@ -7704,6 +7777,45 @@ export declare namespace EasemobChat {
7704
7777
  isRead?: boolean;
7705
7778
  /** Has the message been delivered (only single chat messages have this field). */
7706
7779
  isDelivered?: boolean;
7780
+ /** Whether the message sends the original image. */
7781
+ isOriginalImage?: boolean;
7782
+ /** The original image URL. */
7783
+ originalImageUrl?: string;
7784
+ /** The big image URL. */
7785
+ bigImageUrl?: string;
7786
+ }
7787
+
7788
+ interface ImageFileSource {
7789
+ /** File object for web platforms. */
7790
+ data?: File;
7791
+ /** Local file path for mini program platforms. */
7792
+ path?: string;
7793
+ /** File name. */
7794
+ filename: string;
7795
+ /** MIME type. */
7796
+ filetype?: string;
7797
+ /** File size in bytes. */
7798
+ size?: number;
7799
+ }
7800
+
7801
+ interface CreateImageMessageParameters {
7802
+ chatType: ChatType;
7803
+ to: string;
7804
+ from?: string;
7805
+ file: ImageFileSource;
7806
+ width?: number;
7807
+ height?: number;
7808
+ /** Whether to send the original image. Default is false. */
7809
+ isOriginalImage?: boolean;
7810
+ ext?: { [key: string]: any };
7811
+ msgConfig?: { allowGroupAck: boolean };
7812
+ isChatThread?: boolean;
7813
+ priority?: MessagePriority;
7814
+ deliverOnlineOnly?: boolean;
7815
+ receiverList?: string[];
7816
+ onFileUploadError?: (err: ErrorEvent) => void;
7817
+ onFileUploadComplete?: (data: UploadFileResult) => void;
7818
+ onFileUploadProgress?: (data: ProgressEvent) => void;
7707
7819
  }
7708
7820
 
7709
7821
  interface CreateImgMsgParameters {
@@ -7761,6 +7873,8 @@ export declare namespace EasemobChat {
7761
7873
  thumbnailHeight?: number;
7762
7874
  /** Whether the image is a gif. */
7763
7875
  isGif?: boolean;
7876
+ /** Whether to send the original image. Default is false. */
7877
+ isOriginalImage?: boolean;
7764
7878
  }
7765
7879
 
7766
7880
  interface AudioParameters {
@@ -8196,6 +8310,8 @@ export declare namespace EasemobChat {
8196
8310
  static createOldMsg(options: NewMessageParamters): MessageBody;
8197
8311
  /** Create messages. */
8198
8312
  static create(options: CreateMsgType): MessageBody;
8313
+ /** Create an image message with SDK-internal upload support. */
8314
+ static createImageMessage(options: CreateImageMessageParameters): ImgMsgBody;
8199
8315
  /** When sending attachment messages, use this method to obtain the file path. */
8200
8316
  static getFileUrl: (fileInputId: string | HTMLInputElement) => FileObj;
8201
8317