@realvare/based 2.6.24 → 2.6.251

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.
@@ -479,21 +479,8 @@ async function generateThumbnail(file, mediaType, options) {
479
479
  };
480
480
  }
481
481
  const getHttpStream = async (url, options = {}) => {
482
- const { retryRequestDelayMs, maxMsgRetryCount } = options;
483
- let retries = 0;
484
- while (retries < maxMsgRetryCount) {
485
- try {
486
- const fetched = await axios_1.default.get(url.toString(), { ...options, responseType: 'stream' });
487
- return fetched.data;
488
- }
489
- catch (error) {
490
- retries++;
491
- if (retries >= maxMsgRetryCount) {
492
- throw error;
493
- }
494
- await (0, generics_1.delay)(retryRequestDelayMs || 1000);
495
- }
496
- }
482
+ const fetched = await axios_1.default.get(url.toString(), { ...options, responseType: 'stream' });
483
+ return fetched.data;
497
484
  };
498
485
  exports.getHttpStream = getHttpStream;
499
486
  const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequired, opts } = {}) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@realvare/based",
3
- "version": "2.6.24",
4
- "description": "WhatsApp Web API by Sam",
3
+ "version": "2.6.251",
4
+ "description": "whatsapp api by sam",
5
5
  "keywords": [
6
6
  "baileys",
7
7
  "whatsapp",
@@ -9,9 +9,7 @@
9
9
  "whatsapp-web",
10
10
  "whatsapp-bot",
11
11
  "automation",
12
- "multi-device",
13
- "lid",
14
- "based"
12
+ "multi-device"
15
13
  ],
16
14
  "homepage": "https://github.com/realvare/based.git",
17
15
  "repository": {
@@ -58,7 +56,6 @@
58
56
  "music-metadata": "^7.12.3",
59
57
  "pino": "^9.6",
60
58
  "protobufjs": "^7.2.5",
61
- "sharp": "^0.33.5",
62
59
  "uuid": "^10.0.0",
63
60
  "ws": "^8.18.0"
64
61
  },
@@ -97,10 +94,10 @@
97
94
  "jimp": {
98
95
  "optional": true
99
96
  },
100
- "sharp": {
97
+ "link-preview-js": {
101
98
  "optional": true
102
99
  },
103
- "link-preview-js": {
100
+ "sharp": {
104
101
  "optional": true
105
102
  }
106
103
  },
@@ -108,4 +105,4 @@
108
105
  "engines": {
109
106
  "node": ">=20.0.0"
110
107
  }
111
- }
108
+ }
@@ -1,35 +0,0 @@
1
- const sharp = require('sharp');
2
- const fs = require('fs/promises');
3
- const fetch = require('node-fetch');
4
-
5
- /**
6
- * Generates an optimized JPEG thumbnail buffer for externalAdReply.
7
- * @param {string | Buffer} imagePathOrBuffer - Path to image file, Buffer, or URL.
8
- * @param {number} [size=150] - Target square size (default 150 for balance between quality and load time).
9
- * @param {number} [quality=85] - JPEG quality (1-100, default 85).
10
- * @returns {Promise<Buffer>} - Optimized thumbnail buffer.
11
- */
12
- async function generateThumbnail(imagePathOrBuffer, size = 150, quality = 85) {
13
- let input;
14
-
15
- if (typeof imagePathOrBuffer === 'string') {
16
- if (imagePathOrBuffer.startsWith('http')) {
17
- // Fetch from URL
18
- const response = await fetch(imagePathOrBuffer);
19
- input = Buffer.from(await response.arrayBuffer());
20
- } else {
21
- // Local file
22
- input = await fs.readFile(imagePathOrBuffer);
23
- }
24
- } else {
25
- input = imagePathOrBuffer;
26
- }
27
-
28
- return sharp(input)
29
- .resize(size, size, { fit: 'cover', kernel: sharp.kernel.lanczos3 }) // Lanczos for sharp resizing
30
- .sharpen() // Optional: Adds slight sharpness to counter blurring
31
- .jpeg({ quality, mozjpeg: true }) // Use high-quality JPEG compression
32
- .toBuffer();
33
- }
34
-
35
- module.exports = { generateThumbnail };