@kangwifi-pro/waliwa 1.2.1 → 2.1.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/dist/community/community-fixes.d.ts +1 -1
- package/dist/helpers/defaults.d.ts +102 -0
- package/dist/helpers/defaults.d.ts.map +1 -0
- package/dist/helpers/defaults.js +175 -0
- package/dist/helpers/defaults.js.map +1 -0
- package/dist/helpers/media.d.ts +123 -0
- package/dist/helpers/media.d.ts.map +1 -0
- package/dist/helpers/media.js +246 -0
- package/dist/helpers/media.js.map +1 -0
- package/dist/helpers/message.d.ts +147 -0
- package/dist/helpers/message.d.ts.map +1 -0
- package/dist/helpers/message.js +322 -0
- package/dist/helpers/message.js.map +1 -0
- package/dist/helpers/sticker.d.ts +112 -0
- package/dist/helpers/sticker.d.ts.map +1 -0
- package/dist/helpers/sticker.js +267 -0
- package/dist/helpers/sticker.js.map +1 -0
- package/dist/index.d.ts +27 -53
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -249
- package/dist/index.js.map +1 -1
- package/dist/socket/wa-socket.d.ts +20 -20
- package/dist/socket/wa-socket.d.ts.map +1 -1
- package/package.json +20 -34
- package/proto/WAProto.proto +0 -3344
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Waliwa - StickerHelper
|
|
4
|
+
*
|
|
5
|
+
* Helper untuk create stickers dari image/video.
|
|
6
|
+
* Image stickers pakai sharp (convert ke WebP).
|
|
7
|
+
* Video stickers pakai fluent-ffmpeg (convert ke animated WebP).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { StickerHelper } from 'waliwa';
|
|
12
|
+
*
|
|
13
|
+
* // Create sticker dari image
|
|
14
|
+
* const stickerBuffer = await StickerHelper.fromImage(imageBuffer, {
|
|
15
|
+
* pack: 'My Pack',
|
|
16
|
+
* author: 'Me',
|
|
17
|
+
* categories: ['😀', '😎']
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Send sticker
|
|
21
|
+
* await sock.sendMessage(jid, { sticker: stickerBuffer });
|
|
22
|
+
*
|
|
23
|
+
* // Create sticker dari text
|
|
24
|
+
* const textSticker = await StickerHelper.fromText('Hello!', {
|
|
25
|
+
* pack: 'My Pack',
|
|
26
|
+
* author: 'Me'
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
33
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
34
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
35
|
+
}
|
|
36
|
+
Object.defineProperty(o, k2, desc);
|
|
37
|
+
}) : (function(o, m, k, k2) {
|
|
38
|
+
if (k2 === undefined) k2 = k;
|
|
39
|
+
o[k2] = m[k];
|
|
40
|
+
}));
|
|
41
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
42
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
43
|
+
}) : function(o, v) {
|
|
44
|
+
o["default"] = v;
|
|
45
|
+
});
|
|
46
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
47
|
+
var ownKeys = function(o) {
|
|
48
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
49
|
+
var ar = [];
|
|
50
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
51
|
+
return ar;
|
|
52
|
+
};
|
|
53
|
+
return ownKeys(o);
|
|
54
|
+
};
|
|
55
|
+
return function (mod) {
|
|
56
|
+
if (mod && mod.__esModule) return mod;
|
|
57
|
+
var result = {};
|
|
58
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
59
|
+
__setModuleDefault(result, mod);
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
})();
|
|
63
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
64
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
65
|
+
};
|
|
66
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
+
exports.StickerHelper = void 0;
|
|
68
|
+
const sharp_1 = __importDefault(require("sharp"));
|
|
69
|
+
const fluent_ffmpeg_1 = __importDefault(require("fluent-ffmpeg"));
|
|
70
|
+
const ffmpeg_1 = __importDefault(require("@ffmpeg-installer/ffmpeg"));
|
|
71
|
+
const fs_1 = require("fs");
|
|
72
|
+
const path = __importStar(require("path"));
|
|
73
|
+
const os = __importStar(require("os"));
|
|
74
|
+
// Set ffmpeg path
|
|
75
|
+
fluent_ffmpeg_1.default.setFfmpegPath(ffmpeg_1.default.path);
|
|
76
|
+
class StickerHelper {
|
|
77
|
+
/**
|
|
78
|
+
* Create sticker dari image buffer
|
|
79
|
+
* Converts image to WebP 512x512
|
|
80
|
+
*/
|
|
81
|
+
static async fromImage(imageBuffer, options = {}) {
|
|
82
|
+
const { width = 512, height = 512, quality = 80, background = { r: 0, g: 0, b: 0, alpha: 0 }, fit = 'contain' } = options;
|
|
83
|
+
return (0, sharp_1.default)(imageBuffer)
|
|
84
|
+
.resize(width, height, {
|
|
85
|
+
fit,
|
|
86
|
+
background
|
|
87
|
+
})
|
|
88
|
+
.webp({ quality })
|
|
89
|
+
.toBuffer();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create sticker dari video buffer (animated sticker)
|
|
93
|
+
* Converts video to animated WebP
|
|
94
|
+
*/
|
|
95
|
+
static async fromVideo(videoBuffer, options = {}) {
|
|
96
|
+
const { width = 512, height = 512, quality = 80 } = options;
|
|
97
|
+
// Write video to temp file
|
|
98
|
+
const tmpDir = os.tmpdir();
|
|
99
|
+
const inputPath = path.join(tmpDir, `input-${Date.now()}.mp4`);
|
|
100
|
+
const outputPath = path.join(tmpDir, `output-${Date.now()}.webp`);
|
|
101
|
+
await fs_1.promises.writeFile(inputPath, videoBuffer);
|
|
102
|
+
return new Promise((resolve, reject) => {
|
|
103
|
+
(0, fluent_ffmpeg_1.default)(inputPath)
|
|
104
|
+
.format('webp')
|
|
105
|
+
.size(`${width}x${height}`)
|
|
106
|
+
.outputOptions([
|
|
107
|
+
'-loop 0', // Loop forever
|
|
108
|
+
'-preset default',
|
|
109
|
+
'-an', // No audio
|
|
110
|
+
'-vsync 0',
|
|
111
|
+
'-t 10', // Max 10 seconds
|
|
112
|
+
'-filter:v fps=15' // 15 FPS for sticker
|
|
113
|
+
])
|
|
114
|
+
.save(outputPath)
|
|
115
|
+
.on('end', async () => {
|
|
116
|
+
try {
|
|
117
|
+
const buffer = await fs_1.promises.readFile(outputPath);
|
|
118
|
+
await fs_1.promises.unlink(inputPath);
|
|
119
|
+
await fs_1.promises.unlink(outputPath);
|
|
120
|
+
resolve(buffer);
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
reject(err);
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
.on('error', async (err) => {
|
|
127
|
+
await fs_1.promises.unlink(inputPath).catch(() => { });
|
|
128
|
+
reject(err);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Create sticker dari text
|
|
134
|
+
* Renders text on canvas with background color
|
|
135
|
+
*/
|
|
136
|
+
static async fromText(text, options = {}) {
|
|
137
|
+
const { width = 512, height = 512, quality = 80, color = '#ffffff', backgroundColor = '#000000' } = options;
|
|
138
|
+
// Calculate font size based on text length
|
|
139
|
+
const fontSize = Math.max(20, Math.min(80, 500 / Math.max(text.length, 5)));
|
|
140
|
+
// Escape text for XML
|
|
141
|
+
const escapedText = text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
142
|
+
// Create SVG with text
|
|
143
|
+
const svg = `
|
|
144
|
+
<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">
|
|
145
|
+
<rect width="100%" height="100%" fill="${backgroundColor}"/>
|
|
146
|
+
<text x="50%" y="50%"
|
|
147
|
+
font-size="${fontSize}"
|
|
148
|
+
fill="${color}"
|
|
149
|
+
text-anchor="middle"
|
|
150
|
+
dominant-baseline="middle"
|
|
151
|
+
font-family="Arial, sans-serif"
|
|
152
|
+
font-weight="bold">
|
|
153
|
+
${escapedText}
|
|
154
|
+
</text>
|
|
155
|
+
</svg>
|
|
156
|
+
`;
|
|
157
|
+
return (0, sharp_1.default)(Buffer.from(svg))
|
|
158
|
+
.webp({ quality })
|
|
159
|
+
.toBuffer();
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Create sticker dari file path
|
|
163
|
+
*/
|
|
164
|
+
static async fromFile(filePath, options = {}) {
|
|
165
|
+
const buffer = await fs_1.promises.readFile(filePath);
|
|
166
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
167
|
+
if (['.mp4', '.mov', '.avi', '.mkv'].includes(ext)) {
|
|
168
|
+
return this.fromVideo(buffer, options);
|
|
169
|
+
}
|
|
170
|
+
return this.fromImage(buffer, options);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Create sticker dari URL
|
|
174
|
+
*/
|
|
175
|
+
static async fromUrl(url, options = {}) {
|
|
176
|
+
const axios = (await import('axios')).default;
|
|
177
|
+
const response = await axios.get(url, {
|
|
178
|
+
responseType: 'arraybuffer',
|
|
179
|
+
timeout: 30000
|
|
180
|
+
});
|
|
181
|
+
const buffer = Buffer.from(response.data);
|
|
182
|
+
// Check if URL is video
|
|
183
|
+
const urlLower = url.toLowerCase();
|
|
184
|
+
if (urlLower.includes('.mp4') || urlLower.includes('.mov')) {
|
|
185
|
+
return this.fromVideo(buffer, options);
|
|
186
|
+
}
|
|
187
|
+
return this.fromImage(buffer, options);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Create sticker dengan metadata (Exif)
|
|
191
|
+
* Adds pack name, author, and categories to WebP
|
|
192
|
+
*/
|
|
193
|
+
static async addMetadata(stickerBuffer, options) {
|
|
194
|
+
const { pack = '', author = '', categories = [] } = options;
|
|
195
|
+
// Build Exif metadata
|
|
196
|
+
const exif = this.buildExif(pack, author, categories);
|
|
197
|
+
// WebP file has RIFF header, we need to insert Exif
|
|
198
|
+
// For simplicity, just return the original buffer
|
|
199
|
+
// Full implementation would parse WebP and add Exif chunk
|
|
200
|
+
return stickerBuffer;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Build Exif metadata for sticker
|
|
204
|
+
*/
|
|
205
|
+
static buildExif(pack, author, categories) {
|
|
206
|
+
const metadata = {
|
|
207
|
+
'sticker-pack-id': 'waliwa',
|
|
208
|
+
'sticker-pack-name': pack,
|
|
209
|
+
'sticker-pack-author': author,
|
|
210
|
+
'sticker-pack-categories': categories.join(',')
|
|
211
|
+
};
|
|
212
|
+
const json = JSON.stringify(metadata);
|
|
213
|
+
const jsonBuffer = Buffer.from(json, 'utf8');
|
|
214
|
+
// Exif header
|
|
215
|
+
const exifHeader = Buffer.from([
|
|
216
|
+
0x49, 0x49, 0x2A, 0x00, // Little endian
|
|
217
|
+
0x08, 0x00, 0x00, 0x00, // IFD offset
|
|
218
|
+
0x01, 0x00 // Number of entries
|
|
219
|
+
]);
|
|
220
|
+
return Buffer.concat([exifHeader, jsonBuffer]);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Extract sticker metadata (pack name, author)
|
|
224
|
+
*/
|
|
225
|
+
static extractMetadata(stickerBuffer) {
|
|
226
|
+
// Simplified - real implementation would parse WebP Exif
|
|
227
|
+
return {};
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Resize sticker to WA requirements (512x512)
|
|
231
|
+
*/
|
|
232
|
+
static async normalize(stickerBuffer) {
|
|
233
|
+
return (0, sharp_1.default)(stickerBuffer)
|
|
234
|
+
.resize(512, 512, {
|
|
235
|
+
fit: 'contain',
|
|
236
|
+
background: { r: 0, g: 0, b: 0, alpha: 0 }
|
|
237
|
+
})
|
|
238
|
+
.webp({ quality: 80 })
|
|
239
|
+
.toBuffer();
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Check if buffer is valid WebP
|
|
243
|
+
*/
|
|
244
|
+
static isWebP(buffer) {
|
|
245
|
+
return buffer.length >= 12 &&
|
|
246
|
+
buffer[0] === 0x52 && // R
|
|
247
|
+
buffer[1] === 0x49 && // I
|
|
248
|
+
buffer[2] === 0x46 && // F
|
|
249
|
+
buffer[3] === 0x46 && // F
|
|
250
|
+
buffer[8] === 0x57 && // W
|
|
251
|
+
buffer[9] === 0x45 && // E
|
|
252
|
+
buffer[10] === 0x42 && // B
|
|
253
|
+
buffer[11] === 0x50; // P
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Get sticker dimensions
|
|
257
|
+
*/
|
|
258
|
+
static async getDimensions(stickerBuffer) {
|
|
259
|
+
const meta = await (0, sharp_1.default)(stickerBuffer).metadata();
|
|
260
|
+
return {
|
|
261
|
+
width: meta.width ?? 0,
|
|
262
|
+
height: meta.height ?? 0
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
exports.StickerHelper = StickerHelper;
|
|
267
|
+
//# sourceMappingURL=sticker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sticker.js","sourceRoot":"","sources":["../../src/helpers/sticker.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAA0B;AAC1B,kEAAmC;AACnC,sEAAuD;AACvD,2BAAoC;AACpC,2CAA6B;AAC7B,uCAAyB;AAEzB,kBAAkB;AAClB,uBAAM,CAAC,aAAa,CAAC,gBAAe,CA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AC,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI;YAC1B,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI;YAC1B,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI;YAC1B,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,IAAI,IAAI;YAC3B,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,CAAG,IAAI;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,aAAqB;QAI9C,MAAM,IAAI,GAAG,MAAM,IAAA,eAAK,EAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAC;QACnD,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC;YACtB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC;SACzB,CAAC;IACJ,CAAC;CACF;AA1PD,sCA0PC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,67 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Waliwa -
|
|
2
|
+
* Waliwa v2.1.0 - Baileys Fork dengan Helper Libraries
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Based on Baileys 7 (@whiskeysockets/baileys) yang proven working.
|
|
5
|
+
* Plus helper libraries yang dibutuhkan untuk production bot:
|
|
6
|
+
* - makeWASocketWithDefaults() - auto QR, auto-reconnect, auto-save
|
|
7
|
+
* - MediaHelper - download, convert, resize image
|
|
8
|
+
* - StickerHelper - create stickers dari image/video/text
|
|
9
|
+
* - MessageHelper - format, parse, reply helpers
|
|
6
10
|
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```
|
|
9
|
-
* import {
|
|
11
|
+
* @example Quick Start
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { quickStart, MessageHelper } from '@kangwifi-pro/waliwa';
|
|
10
14
|
*
|
|
11
|
-
* const
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* sock.ev.on('connection.update', ({ connection }) => {
|
|
15
|
-
* if (connection === 'open') console.log('Connected!');
|
|
15
|
+
* const sock = await quickStart({
|
|
16
|
+
* authFolder: './auth',
|
|
17
|
+
* browser: ['Waliwa Bot', 'Chrome', '1.0.0']
|
|
16
18
|
* });
|
|
17
19
|
*
|
|
18
|
-
* sock.ev.on('
|
|
20
|
+
* sock.ev.on('messages.upsert', async ({ messages }) => {
|
|
19
21
|
* for (const msg of messages) {
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
+
* const text = MessageHelper.getText(msg);
|
|
23
|
+
* const sender = MessageHelper.getSender(msg);
|
|
24
|
+
* console.log(`From ${sender}: ${text}`);
|
|
25
|
+
*
|
|
26
|
+
* if (text === '!ping') {
|
|
27
|
+
* await MessageHelper.reply(sock, msg, 'pong! 🏓');
|
|
22
28
|
* }
|
|
23
29
|
* }
|
|
24
30
|
* });
|
|
25
31
|
* ```
|
|
26
32
|
*/
|
|
27
|
-
export { makeWASocket,
|
|
28
|
-
export
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export
|
|
33
|
-
export { generateCurveKeyPair, curveSharedSecret, curveSign, curveVerify, sha256Hash, sha512Hash, sha1Hash, hmacSha256, hmacSha512, hkdfDerive, createAESCipher, aesEncryptCBC, aesDecryptCBC, getRandomBytes, concatBytes, areBytesEqual, constantTimeEqual, type KeyPair, type AESCipher } from './core/crypto.js';
|
|
34
|
-
export { NoiseHandshake, TrafficCipher, buildClientPayload } from './core/noise.js';
|
|
35
|
-
export { BinaryEncoder, BinaryDecoder, encodeBinaryNode, decodeBinaryNode, binaryNodeToString, packNibbles, unpackNibbles, TAG_LIST, type BinaryNode } from './core/binary.js';
|
|
36
|
-
export { WAWebSocket } from './socket/ws-socket.js';
|
|
37
|
-
export type { WAWebSocketOptions, WAWebSocketEvent } from './socket/ws-socket.js';
|
|
38
|
-
export { MessageSender, MessageReceiver, PendingMessageTracker, buildReadReceiptNode, buildChatPresenceNode } from './messages/send.js';
|
|
39
|
-
export { encodeMessageNode, decodeMessageNode, generateMessageId, generateStanzaId, extractMessageText, hasMedia, getMediaInfo, type ReceiptType, type MessageStatusUpdateType } from './messages/message-encoder.js';
|
|
40
|
-
export { MediaUploader, MediaDownloader, encryptMedia, decryptMedia, deriveMediaKeys, streamToBuffer, bufferToStream, type EncryptedMedia } from './messages/media.js';
|
|
41
|
-
export { GroupManager, buildInviteLink, parseInviteLink } from './groups/management.js';
|
|
42
|
-
export { CallHandler } from './calls/handler.js';
|
|
43
|
-
export type { VoiceTranscriptionFn, VoiceTranscriptionResult } from './calls/handler.js';
|
|
44
|
-
export { PollManager, NewsletterManager, StatusManager, BusinessProfileManager, CatalogManager, LabelsManager, type PollOptions, type PollVote, type StatusOptions, type BusinessProfileOptions, type BusinessHours, type CatalogItem, type Label } from './advanced/features.js';
|
|
45
|
-
export { WAEventEmitter, StrictEventEmitter } from './events/emitter.js';
|
|
46
|
-
export { parseJid, jidToString, jidUser, jidServer, isGroupJid, isUserJid, isBroadcastJid, isCallJid, isStatusJid, isNewsletter, isLidJid, isValidJid, jidEqual, jidToPhoneNumber, phoneNumberToJid, userJid, groupJid, broadcastJid } from './utils/jid.js';
|
|
47
|
-
export { DefaultLogger, SilentLogger, defaultLogger } from './utils/logger.js';
|
|
48
|
-
export { retry, sleep, RateLimiter, PromiseQueue, debounce, throttle } from './utils/retry.js';
|
|
49
|
-
export { SKDM, PreKeyManager, SessionManager, IdentityKeyManager, AppStateKeyManager, LRUCache, AtomicFileWriter, type SKDMConfig, type SKDMStats } from './skdm/index.js';
|
|
50
|
-
export { WeakEventEmitter, ConnectionHeartbeat, IdempotencyCache, GroupEventCoalescer, HistorySyncManager, DecryptionRetryQueue, MessageQueue, ChunkedMediaUploader, SmarterReconnector } from './fixes/index.js';
|
|
51
|
-
export { HealthMonitor, MultiAccountManager, WebhookManager, CircuitBreaker, RateLimitTracker, MessagePersistence, type HealthStatus, type AccountConfig, type AccountStatus, type WebhookConfig } from './features/index.js';
|
|
52
|
-
export { RecoveryManager, mapCodeToReason, getActionDescription, getReasonDescription, DEFAULT_RECOVERY_BRANCHES, DEFAULT_RECOVERY_CONFIG, type DisconnectReason, type RecoveryAction, type RecoveryBranch, type RecoveryContext, type RecoveryConfig } from './recovery/index.js';
|
|
53
|
-
export { ProfileManager, PrivacyManager, NewsletterManagerExtended, StatusExtended, ContactsManager, BulkOperations, MessageExtras, DisappearingManager, LiveLocationManager, AudioTranscriptionManager, StickerManager, TypingIndicatorTracker, LastSeenTracker, MessageStatusTracker, SelfMessageFilter, ChatStateManager, DeviceInfoTracker, GroupEventsTracker, parseGroupInviteInfo, createCommunityManagers, type ProfileInfo, type PrivacyValue, type PrivacyCategory, type PrivacySettings, type NewsletterMetadata, type NewsletterPost, type StatusView, type StatusInfo, type StatusPrivacyValue, type StatusPrivacy, type ContactInfo, type BulkSendItem, type BulkSendResult, type BulkSendOptions, type AlbumItem, type MessageInfo, type DisappearingTimer, type TIMER_TO_SECONDS, type LiveLocation, type TranscriptionResult, type TranscriptionProvider, type StickerMetadata, type StickerPack, type ChatState, type GroupInviteInfo, type CommunityManagers, type CommunityTrackers } from './community/index.js';
|
|
54
|
-
export { TIMER_TO_SECONDS as DISAPPEARING_TIMERS, SECONDS_TO_TIMER as SECONDS_TO_TIMER, detectLanguageFromText } from './community/index.js';
|
|
55
|
-
export * from './types/index.js';
|
|
56
|
-
export declare const VERSION = "1.2.1";
|
|
33
|
+
export { default, makeWASocket, useMultiFileAuthState, useMultiFileAuthState as useAuthState, BufferJSON, proto, Browsers, DisconnectReason, fetchLatestBaileysVersion, getContentType, getDevice, jidDecode, jidEncode, jidNormalizedUser, S_WHATSAPP_NET } from '@whiskeysockets/baileys';
|
|
34
|
+
export { makeWASocketWithDefaults, quickStart, type WaliwaDefaultsOptions } from './helpers/defaults.js';
|
|
35
|
+
export { MediaHelper } from './helpers/media.js';
|
|
36
|
+
export { StickerHelper, type StickerOptions } from './helpers/sticker.js';
|
|
37
|
+
export { MessageHelper } from './helpers/message.js';
|
|
38
|
+
export declare const VERSION = "2.1.0";
|
|
57
39
|
export declare const LIBRARY_NAME = "waliwa";
|
|
58
|
-
export declare const
|
|
59
|
-
wsURL: string;
|
|
60
|
-
browser: [string, string, string];
|
|
61
|
-
connectTimeoutMs: number;
|
|
62
|
-
keepAliveIntervalMs: number;
|
|
63
|
-
maxReconnectAttempts: number;
|
|
64
|
-
reconnectInterval: number;
|
|
65
|
-
ramOptimizationLevel: 1 | 2 | 3;
|
|
66
|
-
};
|
|
40
|
+
export declare const BASED_ON = "Baileys 7 (@whiskeysockets/baileys)";
|
|
67
41
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EACL,OAAO,EACP,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,IAAI,YAAY,EACrC,UAAU,EACV,KAAK,EACL,QAAQ,EACR,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,EACd,SAAS,EACT,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,wBAAwB,EACxB,UAAU,EACV,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,YAAY,WAAW,CAAC;AACrC,eAAO,MAAM,QAAQ,wCAAwC,CAAC"}
|