@vanzxy/baileys 1.4.6 → 1.4.7

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.
@@ -61,7 +61,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
61
61
  var _a, _Button_client, _Button_validateAgainstSchema, _ButtonV2_client, _Carousel_client, _Poll_client, _AIRich_client;
62
62
  Object.defineProperty(exports, "__esModule", { value: true });
63
63
  exports.Toolkit = exports.VanzxyRich = exports.VanzxyAI = exports.LeafRich = exports.AIVanzxy = exports.AIRich = exports.Poll = exports.Carousel = exports.ButtonV2 = exports.Button = exports.MESSAGE_BUILDER_VERSION = void 0;
64
- const MESSAGE_BUILDER_VERSION = '4.8';
64
+ const MESSAGE_BUILDER_VERSION = '4.9';
65
65
  exports.MESSAGE_BUILDER_VERSION = MESSAGE_BUILDER_VERSION;
66
66
  const messages_js_1 = require("./messages.js");
67
67
  const rich_message_utils_js_1 = require("./rich-message-utils.js");
@@ -1378,7 +1378,7 @@ class AIRich extends BaseBuilder {
1378
1378
  }))));
1379
1379
  return this;
1380
1380
  }
1381
- addImage(imageUrl, { resolveUrl = false } = {}) {
1381
+ addImage(imageUrl, { resolveUrl = false, instant = false } = {}) {
1382
1382
  if (!(typeof imageUrl === 'string' || Buffer.isBuffer(imageUrl) || (Array.isArray(imageUrl) && imageUrl.every((v) => typeof v === 'string' || Buffer.isBuffer(v))))) {
1383
1383
  throw new TypeError('imageUrl must be string | buffer | array of string/buffer');
1384
1384
  }
@@ -1420,6 +1420,9 @@ class AIRich extends BaseBuilder {
1420
1420
  status: { status: 'READY' },
1421
1421
  __typename: 'GenAIImaginePrimitive',
1422
1422
  }));
1423
+ if (instant) {
1424
+ this._inlineImages.push({ url: imagePreviewUrl, caption: undefined });
1425
+ }
1423
1426
  });
1424
1427
  return this;
1425
1428
  }
@@ -44,7 +44,7 @@
44
44
 
45
45
  'use strict';
46
46
 
47
- const MESSAGE_BUILDER_VERSION = '4.8';
47
+ const MESSAGE_BUILDER_VERSION = '4.9';
48
48
 
49
49
  import { generateWAMessageFromContent, prepareWAMessageMedia } from './messages.js';
50
50
  import { botMetadataSignature, botMetadataCertificate } from './rich-message-utils.js';
@@ -1587,6 +1587,68 @@ class AIRich extends BaseBuilder {
1587
1587
  // mediaKey still doesn't render, so it's a trust-chain gate, not a domain/encoding issue).
1588
1588
  // Track every addInlineImage() call here so send() can fall back to a normal imageMessage.
1589
1589
  this._inlineImages = [];
1590
+
1591
+ // Vanz@Add (v4.9.1) --- { id, insertAt } support for every add*()/set*() call, without
1592
+ // touching each method's own body/signature. Every add*() call ends up pushing 0-N items
1593
+ // onto _submessages and 0-N onto _sections (some push to both, some to just one — e.g.
1594
+ // addSuggest only touches _submessages, addSection only touches _sections). A Proxy wraps
1595
+ // every add*/set* call: it snapshots array lengths before calling the real method, lets the
1596
+ // method push onto the tail as it always has, then — if the caller passed { insertAt } —
1597
+ // peels those freshly-pushed items back off the tail and re-splices them right after the
1598
+ // last item that belongs to the block named by insertAt. Blocks are tracked by *object
1599
+ // reference*, not saved numeric index, so earlier insertions shifting the array around never
1600
+ // invalidates a later insertAt lookup (indexOf on the reference always finds the live position).
1601
+ this._blocks = new Map(); // id -> { subItems: object[], secItems: object[] }
1602
+ return new Proxy(this, {
1603
+ get(target, prop, receiver) {
1604
+ const orig = Reflect.get(target, prop, receiver);
1605
+ if (typeof orig !== 'function' || !/^(add|set)/.test(String(prop))) return orig;
1606
+
1607
+ return (...args) => {
1608
+ const opts = args.find((a) => a && typeof a === 'object' && !Array.isArray(a) && !Buffer.isBuffer(a) && ('id' in a || 'insertAt' in a));
1609
+ const id = opts?.id;
1610
+ const insertAt = opts?.insertAt;
1611
+
1612
+ const subBefore = target._submessages.length;
1613
+ const secBefore = target._sections.length;
1614
+
1615
+ const result = orig.apply(receiver, args);
1616
+
1617
+ const subItems = target._submessages.splice(subBefore);
1618
+ const secItems = target._sections.splice(secBefore);
1619
+
1620
+ if (insertAt) {
1621
+ const anchor = target._blocks.get(insertAt);
1622
+ if (!anchor) throw new Error(`insertAt: no block registered with id "${insertAt}" (register it by passing { id: "${insertAt}" } on an earlier add*() call)`);
1623
+
1624
+ const lastSub = anchor.subItems[anchor.subItems.length - 1];
1625
+ const subIdx = lastSub ? target._submessages.indexOf(lastSub) + 1 : target._submessages.length;
1626
+ target._submessages.splice(subIdx, 0, ...subItems);
1627
+
1628
+ const lastSec = anchor.secItems[anchor.secItems.length - 1];
1629
+ const secIdx = lastSec ? target._sections.indexOf(lastSec) + 1 : target._sections.length;
1630
+ target._sections.splice(secIdx, 0, ...secItems);
1631
+ } else {
1632
+ target._submessages.push(...subItems);
1633
+ target._sections.push(...secItems);
1634
+ }
1635
+
1636
+ if (id) target._blocks.set(id, { subItems, secItems });
1637
+
1638
+ return result === target ? receiver : result;
1639
+ };
1640
+ },
1641
+ });
1642
+ }
1643
+
1644
+ /** Flatten every primitive pushed into `_sections` so far into one array — lets you build a
1645
+ * card set in one AIRich instance and re-embed it into another via addSection(AIRich.newLayout(...)). */
1646
+ get items() {
1647
+ return this._sections.flatMap((s) => {
1648
+ const vm = s?.view_model;
1649
+ if (!vm) return [];
1650
+ return vm.primitives ?? (vm.primitive !== undefined ? [vm.primitive] : []);
1651
+ });
1590
1652
  }
1591
1653
 
1592
1654
  /** Push a raw pre-built submessage block (escape hatch for shapes not covered by the add*() helpers). */
@@ -1703,7 +1765,7 @@ class AIRich extends BaseBuilder {
1703
1765
  }
1704
1766
 
1705
1767
  /** Add a "Sources" strip. @param {string[]|string[][]} sources Flat list of urls, or `[title, url]` pairs. */
1706
- addSource(sources = []) {
1768
+ addSource(sources = [], { resolveUrl = false } = {}) {
1707
1769
  if (!(Array.isArray(sources) && (sources.every((item) => typeof item === 'string') || sources.every((item) => Array.isArray(item) && item.every((v) => typeof v === 'string'))))) {
1708
1770
  throw new TypeError('Sources must be a string array or an array of string arrays');
1709
1771
  }
@@ -1718,7 +1780,7 @@ class AIRich extends BaseBuilder {
1718
1780
  source_subtitle: 'AI',
1719
1781
  source_url: url ?? '',
1720
1782
  favicon: {
1721
- url: Toolkit.resolveMedia(this.#client, icon ?? '', 'image'),
1783
+ url: Toolkit.resolveMedia(this.#client, icon ?? '', 'image', { resolveUrl }),
1722
1784
  mime_type: 'image/jpeg',
1723
1785
  width: 16,
1724
1786
  height: 16,
@@ -1736,7 +1798,7 @@ class AIRich extends BaseBuilder {
1736
1798
  }
1737
1799
 
1738
1800
  /** Add a horizontally-scrollable reel of image/video items. */
1739
- addReels(reelsItems = []) {
1801
+ addReels(reelsItems = [], { resolveUrl = false } = {}) {
1740
1802
  if (
1741
1803
  !(
1742
1804
  (reelsItems && typeof reelsItems === 'object' && !Array.isArray(reelsItems)) ||
@@ -1752,8 +1814,8 @@ class AIRich extends BaseBuilder {
1752
1814
 
1753
1815
  const reels = reelsItems.map((item) => ({
1754
1816
  ...item,
1755
- _avatar: Toolkit.resolveMedia(this.#client, item.profileIconUrl ?? item.profile_url ?? item.profile ?? '', 'image'),
1756
- _thumbnail: Toolkit.resolveMedia(this.#client, item.thumbnailUrl ?? item.thumbnail ?? '', 'image'),
1817
+ _avatar: Toolkit.resolveMedia(this.#client, item.profileIconUrl ?? item.profile_url ?? item.profile ?? '', 'image', { resolveUrl }),
1818
+ _thumbnail: Toolkit.resolveMedia(this.#client, item.thumbnailUrl ?? item.thumbnail ?? '', 'image', { resolveUrl }),
1757
1819
  }));
1758
1820
 
1759
1821
  this._submessages.push({
@@ -1806,10 +1868,24 @@ class AIRich extends BaseBuilder {
1806
1868
  }
1807
1869
 
1808
1870
  /** Add a full-width image (or grid of images if `imageUrl` is an array). */
1809
- addImage(imageUrl, { resolveUrl = false } = {}) {
1871
+ /**
1872
+ * @param {{ resolveUrl?: boolean, instant?: boolean|'only' }} [options]
1873
+ * `instant: true` — sends BOTH: the GRID_IMAGE card (still shows WA's "can't verify"
1874
+ * forwarded-download prompt, unavoidable per-design of botForwardedMessage) AND a plain
1875
+ * (non-forwarded) imageMessage via send()'s inline-image fallback queue (`_inlineImages`,
1876
+ * shared with addInlineImage()) that renders instantly with no prompt. Two images, by design.
1877
+ * `instant: 'only'` — Vanz@Add (v4.9.2): skips building the GRID_IMAGE card entirely (no
1878
+ * submessage, no GenAIImaginePrimitive section) and queues ONLY the plain imageMessage.
1879
+ * One image, no prompt, nothing to download — use this when you don't need the rich card,
1880
+ * just the picture to show up immediately.
1881
+ */
1882
+ addImage(imageUrl, { resolveUrl = false, instant = false } = {}) {
1810
1883
  if (!(typeof imageUrl === 'string' || Buffer.isBuffer(imageUrl) || (Array.isArray(imageUrl) && imageUrl.every((v) => typeof v === 'string' || Buffer.isBuffer(v))))) {
1811
1884
  throw new TypeError('imageUrl must be string | buffer | array of string/buffer');
1812
1885
  }
1886
+ if (instant !== false && instant !== true && instant !== 'only') {
1887
+ throw new TypeError(`instant must be false, true, or 'only' — got ${JSON.stringify(instant)}`);
1888
+ }
1813
1889
 
1814
1890
  const list = Array.isArray(imageUrl)
1815
1891
  ? imageUrl.map((v) => {
@@ -1831,28 +1907,38 @@ class AIRich extends BaseBuilder {
1831
1907
  ];
1832
1908
  })();
1833
1909
 
1834
- this._submessages.push({
1835
- messageType: 1,
1836
- gridImageMetadata: {
1837
- gridImageUrl: {
1838
- imagePreviewUrl: list[0]?.imagePreviewUrl,
1910
+ const buildCard = instant !== 'only';
1911
+
1912
+ if (buildCard) {
1913
+ this._submessages.push({
1914
+ messageType: 1,
1915
+ gridImageMetadata: {
1916
+ gridImageUrl: {
1917
+ imagePreviewUrl: list[0]?.imagePreviewUrl,
1918
+ },
1919
+ imageUrls: list,
1839
1920
  },
1840
- imageUrls: list,
1841
- },
1842
- });
1921
+ });
1922
+ }
1843
1923
 
1844
1924
  list.forEach(({ imagePreviewUrl }) => {
1845
- this._sections.push(
1846
- AIRich.newLayout('Single', {
1847
- media: {
1848
- url: imagePreviewUrl,
1849
- mime_type: 'image/png',
1850
- },
1851
- imagine_type: 'IMAGE',
1852
- status: { status: 'READY' },
1853
- __typename: 'GenAIImaginePrimitive',
1854
- })
1855
- );
1925
+ if (buildCard) {
1926
+ this._sections.push(
1927
+ AIRich.newLayout('Single', {
1928
+ media: {
1929
+ url: imagePreviewUrl,
1930
+ mime_type: 'image/png',
1931
+ },
1932
+ imagine_type: 'IMAGE',
1933
+ status: { status: 'READY' },
1934
+ __typename: 'GenAIImaginePrimitive',
1935
+ })
1936
+ );
1937
+ }
1938
+
1939
+ if (instant) {
1940
+ this._inlineImages.push({ url: imagePreviewUrl, caption: undefined });
1941
+ }
1856
1942
  });
1857
1943
 
1858
1944
  return this;
@@ -1923,8 +2009,12 @@ class AIRich extends BaseBuilder {
1923
2009
  // fetch-full-video + ffmpeg-frame-extraction + duration-parse round trip per video, which
1924
2010
  // was the main source of blurose's slower response time. Pass { autoFill: true } to opt
1925
2011
  // back into the complete/slow path (real thumbnail + duration + file_length).
2012
+ // Vanz@Fix 23-08-26 --- addVideo() had no resolveUrl option at all (unlike addImage()), so the
2013
+ // video url always stayed a raw external link, which stock WA clients show a "download" state
2014
+ // for before rendering. Mirrors addImage()'s { resolveUrl } — when true, the url is uploaded to
2015
+ // WA's own media server first via Toolkit.toUrl() so it renders instantly like WA-native media.
1926
2016
  /** Add a video block. */
1927
- addVideo(videoUrl, { autoFill = false } = {}) {
2017
+ addVideo(videoUrl, { autoFill = false, resolveUrl = false } = {}) {
1928
2018
  const isObjectVideo = (v) => v && typeof v === 'object' && v.url;
1929
2019
 
1930
2020
  const isValidPrimitive =
@@ -1947,7 +2037,9 @@ class AIRich extends BaseBuilder {
1947
2037
  items.forEach((item) => {
1948
2038
  const isObject = isObjectVideo(item);
1949
2039
 
1950
- const url = isObject ? Toolkit.resolveMedia(this.#client, item.url ?? '', 'video') : Toolkit.resolveMedia(this.#client, item, 'video');
2040
+ const url = isObject
2041
+ ? Toolkit.resolveMedia(this.#client, item.url ?? '', 'video', { resolveUrl })
2042
+ : Toolkit.resolveMedia(this.#client, item, 'video', { resolveUrl });
1951
2043
 
1952
2044
  const bufferPromise = autoFill ? Promise.resolve(url).then((u) => Toolkit.fetchBuffer(u)) : null;
1953
2045
 
@@ -2005,7 +2097,7 @@ class AIRich extends BaseBuilder {
2005
2097
  }
2006
2098
 
2007
2099
  /** Add an inline product card (or array of cards). Each item needs at least a `title`. */
2008
- addProduct(data = {}) {
2100
+ addProduct(data = {}, { resolveUrl = false } = {}) {
2009
2101
  if (!((data && typeof data === 'object' && !Array.isArray(data)) || (Array.isArray(data) && data.every((item) => item && typeof item === 'object' && !Array.isArray(item))))) {
2010
2102
  throw new TypeError('Product items must be an object or an array of objects');
2011
2103
  }
@@ -2030,11 +2122,11 @@ class AIRich extends BaseBuilder {
2030
2122
  sale_price: item.sale_price,
2031
2123
  product_url: item.product_url ?? item.url,
2032
2124
  image: {
2033
- url: Toolkit.resolveMedia(this.#client, item.image_url ?? item.image, 'image'),
2125
+ url: Toolkit.resolveMedia(this.#client, item.image_url ?? item.image, 'image', { resolveUrl }),
2034
2126
  },
2035
2127
  additional_images: [
2036
2128
  {
2037
- url: Toolkit.resolveMedia(this.#client, item.icon_url ?? item.icon, 'image'),
2129
+ url: Toolkit.resolveMedia(this.#client, item.icon_url ?? item.icon, 'image', { resolveUrl }),
2038
2130
  },
2039
2131
  ],
2040
2132
  __typename: 'GenAIProductItemCardPrimitive',
@@ -2046,7 +2138,7 @@ class AIRich extends BaseBuilder {
2046
2138
  }
2047
2139
 
2048
2140
  /** Add an inline social-post style card (or array of cards). */
2049
- addPost(data = {}) {
2141
+ addPost(data = {}, { resolveUrl = false } = {}) {
2050
2142
  if (!((data && typeof data === 'object' && !Array.isArray(data)) || (Array.isArray(data) && data.every((item) => item && typeof item === 'object' && !Array.isArray(item))))) {
2051
2143
  throw new TypeError('Post items must be an object or an array of objects');
2052
2144
  }
@@ -2062,9 +2154,9 @@ class AIRich extends BaseBuilder {
2062
2154
  title: p.title ?? '',
2063
2155
  subtitle: p.subtitle ?? '',
2064
2156
  username: p.username ?? '',
2065
- profile_picture_url: Toolkit.resolveMedia(this.#client, p.profile_picture_url ?? p.profile_url ?? p.profile ?? '', 'image'),
2157
+ profile_picture_url: Toolkit.resolveMedia(this.#client, p.profile_picture_url ?? p.profile_url ?? p.profile ?? '', 'image', { resolveUrl }),
2066
2158
  is_verified: !!(p.is_verified || p.verified),
2067
- thumbnail_url: Toolkit.resolveMedia(this.#client, p.thumbnail_url ?? p.thumbnail ?? '', 'image'),
2159
+ thumbnail_url: Toolkit.resolveMedia(this.#client, p.thumbnail_url ?? p.thumbnail ?? '', 'image', { resolveUrl }),
2068
2160
  post_caption: p.post_caption ?? p.caption ?? '',
2069
2161
  likes_count: p.likes_count ?? p.like ?? 0,
2070
2162
  comments_count: p.comments_count ?? p.comment ?? 0,
@@ -2073,7 +2165,7 @@ class AIRich extends BaseBuilder {
2073
2165
  post_deeplink: p.post_deeplink ?? p.deeplink ?? '',
2074
2166
  source_app: p.source_app || p.source || 'INSTAGRAM',
2075
2167
  footer_label: p.footer_label ?? p.footer ?? '',
2076
- footer_icon: Toolkit.resolveMedia(this.#client, p.footer_icon ?? p.icon ?? '', 'image'),
2168
+ footer_icon: Toolkit.resolveMedia(this.#client, p.footer_icon ?? p.icon ?? '', 'image', { resolveUrl }),
2077
2169
  is_carousel: posts.length > 1,
2078
2170
  orientation: p.orientation ?? 'LANDSCAPE',
2079
2171
  post_type: p.post_type ?? 'VIDEO',
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Type declarations for lib/Utils/MessageBuilder.js
3
+ * Hand-written (this file had no .d.ts before — not shipped by upstream
4
+ * either). Public chaining API only; internal/private members omitted.
5
+ */
6
+
7
+ export const MESSAGE_BUILDER_VERSION: string; // '4.7'
8
+
9
+ export abstract class BaseBuilder {
10
+ setTitle(title: string): this;
11
+ setSubtitle(subtitle: string): this;
12
+ setBody(body: string): this;
13
+ setFooter(footer: string): this;
14
+ setContextInfo(obj: Record<string, any>): this;
15
+ addPayload(obj: Record<string, any>): this;
16
+ }
17
+
18
+ export interface LimitedTimeOfferParams {
19
+ text?: string;
20
+ url?: string;
21
+ copy_code?: string;
22
+ expiration_time?: number;
23
+ }
24
+
25
+ export interface BottomSheetParams {
26
+ in_thread_buttons_limit?: number;
27
+ divider_indices?: number[];
28
+ list_title?: string;
29
+ button_title?: string;
30
+ }
31
+
32
+ export interface TapTargetConfigurationParams {
33
+ title?: string;
34
+ description?: string;
35
+ canonical_url?: string;
36
+ domain?: string;
37
+ buttonIndex?: number;
38
+ }
39
+
40
+ export class Button extends BaseBuilder {
41
+ constructor(client: any);
42
+ setVideo(path: string | Buffer, options?: Record<string, any>): this;
43
+ setImage(path: string | Buffer, options?: Record<string, any>): this;
44
+ setDocument(path: string | Buffer, options?: Record<string, any>): this;
45
+ setMedia(obj: Record<string, any>): this;
46
+ clearButtons(): this;
47
+ setParams(obj: Record<string, any>): this;
48
+ addButton(name: string, params: string | Record<string, any>): this;
49
+ makeRow(header?: string, title?: string, description?: string, id?: string): this;
50
+ makeSection(title?: string, highlight_label?: string): this;
51
+ addSelection(title: string, options?: Record<string, any>): this;
52
+ addReply(display_text: string, id: string, options?: Record<string, any>): this;
53
+ /** cta_call. Note (v4.7): keys on `phone_number`, not `id` — fixed from a prior version that silently mis-keyed this field. */
54
+ addCall(display_text: string, phone_number: string, options?: Record<string, any>): this;
55
+ addReminder(display_text: string, id: string, options?: Record<string, any>): this;
56
+ addCancelReminder(display_text: string, id: string, options?: Record<string, any>): this;
57
+ addAddress(display_text: string, id: string, options?: Record<string, any>): this;
58
+ addLocation(options?: Record<string, any>): this;
59
+ addUrl(display_text: string, url: string, webview_interaction?: boolean, options?: Record<string, any>): this;
60
+ addCopy(display_text: string, copy_code: string, options?: Record<string, any>): this;
61
+ /** open_webview — opens a titled in-app webview. */
62
+ addOpenWebview(title: string, url: string, options?: Record<string, any>): this;
63
+ /** cta_catalog — opens the sender's WhatsApp Business catalog. Business-account gated. */
64
+ addCatalog(display_text?: string, options?: Record<string, any>): this;
65
+ /** automated_greeting_message_view_catalog. Business-account gated. */
66
+ addViewCatalog(options?: Record<string, any>): this;
67
+ /** call_permission_request. */
68
+ addCallPermission(display_text?: string, options?: Record<string, any>): this;
69
+ /** payment_info — structured payment-settings payload (e.g. PIX). Payment-enabled accounts only. */
70
+ addPaymentInfo(payload?: Record<string, any>): this;
71
+ /** review_and_pay — order/payment summary flow. Server-validated by WhatsApp. */
72
+ addReviewAndPay(payload?: Record<string, any>): this;
73
+ /** wa_payment_transaction_details. */
74
+ addTransactionDetails(payload?: Record<string, any>): this;
75
+ /** mpm — multi-product message. Business-catalog accounts only. */
76
+ addMultiProduct(payload?: Record<string, any>): this;
77
+ setLimitedTimeOffer(params?: LimitedTimeOfferParams): this;
78
+ setBottomSheet(params?: BottomSheetParams): this;
79
+ setTapTargetConfiguration(params?: TapTargetConfigurationParams): this;
80
+ toCard(): Promise<Record<string, any>>;
81
+ build(jid: string, options?: Record<string, any>): Promise<Record<string, any>>;
82
+ send(jid: string, options?: Record<string, any>): Promise<any>;
83
+
84
+ /** Native-flow names WA renders with a dedicated node instead of the generic v=9 "mixed" node. */
85
+ static SPECIAL_FLOW: Record<string, { v: string; name: string }>;
86
+
87
+ // Presets attached at runtime via attachPresets() from MessageKit.js.
88
+ static confirm?: (client: any, text: string, options?: Record<string, any>) => Button;
89
+ static yesNo?: (client: any, text: string, options?: Record<string, any>) => Button;
90
+ static menu?: (client: any, options?: Record<string, any>) => Button;
91
+ }
92
+
93
+ export class ButtonV2 extends BaseBuilder {
94
+ constructor(client: any);
95
+ addButton(displayText: string, buttonId?: string): this;
96
+ addRawButton(obj: Record<string, any>): this;
97
+ setThumbnail(path: string | Buffer): this;
98
+ setMedia(obj: Record<string, any>): this;
99
+ /** @param options.viewOnce Default true — some clients require this for legacy buttonsMessage to render; pass false for a normal (non-disappearing) message. */
100
+ build(jid: string, options?: Record<string, any> & { viewOnce?: boolean }): Promise<Record<string, any>>;
101
+ send(jid: string, options?: Record<string, any> & { viewOnce?: boolean }): Promise<any>;
102
+ }
103
+
104
+ export class Carousel extends BaseBuilder {
105
+ constructor(client: any);
106
+ /** WhatsApp caps carousels at this many cards (10); addCard() throws past it. */
107
+ static MAX_CARDS: number;
108
+ addCard(card: Record<string, any> | Record<string, any>[]): this;
109
+ build(jid: string, options?: Record<string, any>): Record<string, any>;
110
+ send(jid: string, options?: Record<string, any>): Promise<any>;
111
+ }
112
+
113
+ export class Poll extends BaseBuilder {
114
+ constructor(client: any);
115
+ setName(name: string): this;
116
+ addOption(name: string): this;
117
+ addOptions(names: string[]): this;
118
+ setSelectable(count: number): this;
119
+ setMultiSelect(canSelectMultiple?: boolean): this;
120
+ setHideVoter(hide?: boolean): this;
121
+ setCanAddOption(allow?: boolean): this;
122
+ setAnnouncementGroup(isAnnouncement?: boolean): this;
123
+ setEndDate(date: Date | string | number): this;
124
+ /** Defers hash/version handling to the socket's own sendMessage({poll}) logic — see .js docblock. */
125
+ setQuiz(correctOptionName: string): this;
126
+ build(): { poll: Record<string, any> };
127
+ send(jid: string, options?: Record<string, any>): Promise<any>;
128
+ }
129
+
130
+ export interface AddTextOptions {
131
+ hyperlink?: boolean;
132
+ citation?: boolean;
133
+ latex?: boolean;
134
+ }
135
+
136
+ export interface AddInlineImageOptions {
137
+ text?: string;
138
+ alignment?: string;
139
+ tapLinkUrl?: string;
140
+ resolveUrl?: boolean;
141
+ }
142
+
143
+ export class AIRich extends BaseBuilder {
144
+ constructor(client: any);
145
+ addSubmessage(submessage: Record<string, any>): this;
146
+ addSection(section: Record<string, any>): this;
147
+ addText(text: string, options?: AddTextOptions): this;
148
+ addCode(language: string, code: string): this;
149
+ addTable(table: string[][], options?: AddTextOptions): this;
150
+ addSource(sources?: Record<string, any>[], options?: { resolveUrl?: boolean }): this;
151
+ addReels(reelsItems?: Record<string, any>[], options?: { resolveUrl?: boolean }): this;
152
+ addImage(imageUrl: string, options?: { resolveUrl?: boolean }): this;
153
+ addInlineImage(imageUrl: string, options?: AddInlineImageOptions): this;
154
+ addVideo(videoUrl: string, options?: { autoFill?: boolean; resolveUrl?: boolean }): this;
155
+ addProduct(data?: Record<string, any>, options?: { resolveUrl?: boolean }): this;
156
+ addPost(data?: Record<string, any>, options?: { resolveUrl?: boolean }): this;
157
+ addTip(text: string): this;
158
+ /** FOATextPrimitive — large heading text, distinct from addText()'s paragraph text. */
159
+ addHeading(text: string): this;
160
+ /** GenAIImagePrimitive — "ready" static image (preview + full-res), distinct from addImage()'s generation-style card. */
161
+ addImageCard(previewUrl: string | Buffer, fullUrl?: string | Buffer, options?: { resolveUrl?: boolean }): this;
162
+ /** GenAI3PExtWidgetPrimitive — experimental, reverse-engineered; see JSDoc in the .js file for caveats. */
163
+ addWidget(data: Record<string, any> | Record<string, any>[], options?: { layout?: 'Single' | 'HScroll' | 'ActionRow' | string }): this;
164
+ /** GenAIFooterActionPrimitive — footer action link chips (e.g. "Join our Group"). */
165
+ addFooterAction(actions: { text: string; url: string; type?: string } | { text: string; url: string; type?: string }[]): this;
166
+ /** GenAIDividerPrimitive — plain horizontal line, no content. */
167
+ addDivider(): this;
168
+ /** GenAISpacerPrimitive — blank vertical spacing. */
169
+ addSpacer(spacing?: number): this;
170
+ /** GenAILatexUXPrimitive — has a real AI_RICH_RESPONSE_LATEX submessage (unlike most primitives here). */
171
+ addLatex(expression: string): this;
172
+ /** GenAITaskPrimitive — task/checklist card. */
173
+ addTask(data: { task_id?: string; title: string; subtitle?: string; status?: string; textFallback?: boolean }): this;
174
+ /** GenAIBotProgressStatusPrimitive — one-shot "searching/working" status chip. */
175
+ addProgressStatus(title: string, options?: { icon?: string; is_in_progress?: boolean; target_secondary_screen_id?: string; target_secondary_screen_tab_id?: string }): this;
176
+ /** GenAIBotThinkingStatusPrimitive — one-shot "thinking" status chip. */
177
+ addThinkingStatus(title: string, options?: { icon?: string; is_in_progress?: boolean; target_secondary_screen_id?: string; target_secondary_screen_tab_id?: string; textFallback?: boolean }): this;
178
+ /** GenAIMetaSubsQuotaUpsellPrimitive — subscription-quota-limit upsell card. */
179
+ addQuotaUpsell(data: { title: string; body?: string; body_line1?: string; body_line2?: string; buttons?: { label: string; action?: string; deeplink?: string }[] }): this;
180
+ /** FOABloksPrimitive — raw Bloks payload; most experimental primitive, fields passed through as-is. */
181
+ addBloks(data: { type: string; data?: string; uuid?: string; initial_response?: any; versioning_id?: string; textFallback?: boolean }): this;
182
+ addSuggest(suggestion: Record<string, any>, options?: { scroll?: boolean; layout?: string }): this;
183
+ /** GenAIImaginePrimitive with status GENERATING — pending-generation placeholder, distinct from addImage()/addVideo()'s READY status. */
184
+ addGenerating(options?: { imagine_type?: 'IMAGE' | 'ANIMATE'; estimated_completion_time?: number; textFallback?: boolean }): this;
185
+ build(): Record<string, any>;
186
+ send(jid: string, options?: Record<string, any>): Promise<any>;
187
+
188
+ static tokenizer(code: string, lang?: string): Record<string, any>;
189
+ static toTableMetadata(arr: string[][], options?: AddTextOptions): Record<string, any>;
190
+ static newLayout(name: string, data: Record<string, any> | Record<string, any>[], extra?: Record<string, any>): Record<string, any>;
191
+ /** Send a support-ticket marker message (messageContextInfo.supportPayload). */
192
+ static sendSupportPayload(client: any, jid: string, text: string, options?: { ticketId?: string; isAiMessage?: boolean; shouldShowSystemMessage?: boolean; version?: number }): Promise<any>;
193
+ /** Send an image + video as one paired-media unit (messageAssociation). */
194
+ static sendPairedMedia(client: any, jid: string, media: { image: string | Buffer; video: string | Buffer }): Promise<any>;
195
+ }
196
+
197
+ // Same class as AIRich — exported under alternate names (see Vanz@Alias in
198
+ // MessageBuilder.js). All four are structurally identical to AIRich.
199
+ export { AIRich as AIVanzxy, AIRich as LeafRich, AIRich as VanzxyAI, AIRich as VanzxyRich };
200
+
201
+ export class Toolkit {
202
+ static extractIE(text: string, options?: AddTextOptions): Record<string, any>;
203
+ static getMp4Duration(buffer: Buffer, options?: { silent?: boolean }): Promise<number>;
204
+ static getMp4Preview(
205
+ videoBuffer: Buffer,
206
+ options?: { time?: number; result?: 'buffer' | string; resize?: boolean; width?: number; height?: number; silent?: boolean }
207
+ ): Promise<Buffer | Record<string, any>>;
208
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vanzxy/baileys",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
4
4
  "description": "Enhanced Baileys fork by Vanzxy — based on @itsliaaa/baileys + @whiskeysockets/baileys with fixes for audio group status and clean media without newsletter button.",
5
5
  "type": "module",
6
6
  "main": "./cjs/lib/index.js",