@onyx-p/imlib-web 2.4.0 → 2.4.1

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
@@ -28648,16 +28648,24 @@ const DefaultThumbnailConfig = {
28648
28648
  scale: 2.4
28649
28649
  };
28650
28650
  class Img {
28651
- async create(file) {
28651
+ async create(file, sendOptions) {
28652
28652
  try {
28653
28653
  const blobUrl = getBlobUrl(file);
28654
28654
  const image = await getImageObj(blobUrl);
28655
28655
  revokeBlobUrl(blobUrl);
28656
- const {
28657
- imageFile: sentImageFile,
28658
- compressWidth,
28659
- compressHeight
28660
- } = compress(image, 0.85, file.type);
28656
+ let sentImageFile;
28657
+ let compressWidth;
28658
+ let compressHeight;
28659
+ if (sendOptions?.full) {
28660
+ sentImageFile = file;
28661
+ compressWidth = image.width;
28662
+ compressHeight = image.height;
28663
+ } else {
28664
+ const compressResult = compress(image, 0.85, file.type);
28665
+ sentImageFile = compressResult.imageFile;
28666
+ compressWidth = compressResult.compressWidth;
28667
+ compressHeight = compressResult.compressHeight;
28668
+ }
28661
28669
  const thumbnail = getThumbnail(image, DefaultThumbnailConfig);
28662
28670
  return {
28663
28671
  success: true,
@@ -28832,8 +28840,8 @@ class Sight {
28832
28840
  return {
28833
28841
  success: true,
28834
28842
  message: new VideoMessage({
28835
- videoObjectKey: "",
28836
- thumbnailObjectKey: "",
28843
+ videoObjectKey: '',
28844
+ thumbnailObjectKey: '',
28837
28845
  during: formatDurationSeconds(duration),
28838
28846
  width,
28839
28847
  height,
@@ -28934,7 +28942,7 @@ async function createSendFunction(fileType, conversation, msgBody, hooks, sendOp
28934
28942
  success,
28935
28943
  message: message1,
28936
28944
  files
28937
- } = await mediaMessageCreator.create(msgBody.file);
28945
+ } = await mediaMessageCreator.create(msgBody.file, sendOptions);
28938
28946
  if (!success || !message1 || !files) {
28939
28947
  return {
28940
28948
  code: ErrorCode.MEDIA_EXCEPTION
package/index.umd.js CHANGED
@@ -28654,16 +28654,24 @@
28654
28654
  scale: 2.4
28655
28655
  };
28656
28656
  class Img {
28657
- async create(file) {
28657
+ async create(file, sendOptions) {
28658
28658
  try {
28659
28659
  const blobUrl = getBlobUrl(file);
28660
28660
  const image = await getImageObj(blobUrl);
28661
28661
  revokeBlobUrl(blobUrl);
28662
- const {
28663
- imageFile: sentImageFile,
28664
- compressWidth,
28665
- compressHeight
28666
- } = compress(image, 0.85, file.type);
28662
+ let sentImageFile;
28663
+ let compressWidth;
28664
+ let compressHeight;
28665
+ if (sendOptions?.full) {
28666
+ sentImageFile = file;
28667
+ compressWidth = image.width;
28668
+ compressHeight = image.height;
28669
+ } else {
28670
+ const compressResult = compress(image, 0.85, file.type);
28671
+ sentImageFile = compressResult.imageFile;
28672
+ compressWidth = compressResult.compressWidth;
28673
+ compressHeight = compressResult.compressHeight;
28674
+ }
28667
28675
  const thumbnail = getThumbnail(image, DefaultThumbnailConfig);
28668
28676
  return {
28669
28677
  success: true,
@@ -28838,8 +28846,8 @@
28838
28846
  return {
28839
28847
  success: true,
28840
28848
  message: new VideoMessage({
28841
- videoObjectKey: "",
28842
- thumbnailObjectKey: "",
28849
+ videoObjectKey: '',
28850
+ thumbnailObjectKey: '',
28843
28851
  during: formatDurationSeconds(duration),
28844
28852
  width,
28845
28853
  height,
@@ -28940,7 +28948,7 @@
28940
28948
  success,
28941
28949
  message: message1,
28942
28950
  files
28943
- } = await mediaMessageCreator.create(msgBody.file);
28951
+ } = await mediaMessageCreator.create(msgBody.file, sendOptions);
28944
28952
  if (!success || !message1 || !files) {
28945
28953
  return {
28946
28954
  code: exports.ErrorCode.MEDIA_EXCEPTION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onyx-p/imlib-web",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "main": "index.umd.js",
5
5
  "module": "index.esm.js",
6
6
  "types": "types/index.d.ts",
package/types/types.d.ts CHANGED
@@ -200,6 +200,7 @@ export interface IUploadMessageOption extends ISendMessageOptions {
200
200
  */
201
201
  export interface IImageMessageOption extends IUploadMessageOption {
202
202
  thumbnailConfig?: IThumbnailConfig;
203
+ full?: boolean;
203
204
  }
204
205
  /**
205
206
  * 缩略图配置