@violetix/baileys 0.5.5 → 0.6.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.
Files changed (80) hide show
  1. package/README.md +1530 -2009
  2. package/WAProto/index.d.ts +14030 -14586
  3. package/WAProto/index.js +58426 -88874
  4. package/lib/Defaults/index.d.ts +2 -7
  5. package/lib/Defaults/index.js +5 -20
  6. package/lib/Signal/Group/sender-key-message.js +19 -1
  7. package/lib/Signal/libsignal.js +82 -29
  8. package/lib/Signal/xeddsa-fast.js +114 -0
  9. package/lib/Socket/Client/types.js +6 -8
  10. package/lib/Socket/Client/websocket.js +3 -38
  11. package/lib/Socket/business.d.ts +0 -3
  12. package/lib/Socket/chats.d.ts +0 -3
  13. package/lib/Socket/chats.js +18 -45
  14. package/lib/Socket/communities.d.ts +0 -3
  15. package/lib/Socket/graphql.js +3 -7
  16. package/lib/Socket/groups.d.ts +0 -3
  17. package/lib/Socket/groups.js +3 -8
  18. package/lib/Socket/index.d.ts +15 -17
  19. package/lib/Socket/messages-recv.d.ts +0 -3
  20. package/lib/Socket/messages-recv.js +43 -127
  21. package/lib/Socket/messages-send.d.ts +0 -4
  22. package/lib/Socket/messages-send.js +63 -191
  23. package/lib/Socket/newsletter.d.ts +0 -3
  24. package/lib/Socket/newsletter.js +1 -2
  25. package/lib/Socket/newsletter.js.map +1 -1
  26. package/lib/Socket/socket.d.ts +0 -9
  27. package/lib/Socket/socket.js +53 -341
  28. package/lib/Store/make-in-memory-store.js +30 -41
  29. package/lib/Types/Auth.d.ts +2 -60
  30. package/lib/Types/Bussines.d.ts +2 -9
  31. package/lib/Types/Call.d.ts +2 -22
  32. package/lib/Types/Chat.d.ts +1 -2
  33. package/lib/Types/Contact.d.ts +2 -11
  34. package/lib/Types/Events.d.ts +2 -41
  35. package/lib/Types/GroupMetadata.d.ts +2 -36
  36. package/lib/Types/Message.d.ts +1 -11
  37. package/lib/Types/Product.d.ts +2 -5
  38. package/lib/Types/Signal.d.ts +2 -10
  39. package/lib/Types/Socket.d.ts +2 -33
  40. package/lib/Types/USync.d.ts +2 -9
  41. package/lib/Types/index.d.ts +1 -3
  42. package/lib/Utils/auth-utils.d.ts +2 -3
  43. package/lib/Utils/auth-utils.js +53 -37
  44. package/lib/Utils/business.js +11 -25
  45. package/lib/Utils/chat-utils.js +4 -6
  46. package/lib/Utils/decode-wa-message.js +2 -2
  47. package/lib/Utils/event-buffer.js +12 -21
  48. package/lib/Utils/generics.d.ts +5 -5
  49. package/lib/Utils/generics.js +7 -25
  50. package/lib/Utils/history.d.ts +1 -2
  51. package/lib/Utils/history.js +83 -137
  52. package/lib/Utils/index.d.ts +0 -4
  53. package/lib/Utils/index.js +0 -4
  54. package/lib/Utils/listener-guard.js +0 -2
  55. package/lib/Utils/message-retry-manager.js +0 -20
  56. package/lib/Utils/messages-media.d.ts +8 -39
  57. package/lib/Utils/messages-media.js +89 -218
  58. package/lib/Utils/messages.d.ts +0 -1
  59. package/lib/Utils/messages.js +36 -122
  60. package/lib/Utils/process-message.d.ts +0 -18
  61. package/lib/Utils/process-message.js +47 -99
  62. package/lib/Utils/rich-message-utils.js +4 -3
  63. package/lib/Utils/use-multi-file-auth-state.d.ts +3 -5
  64. package/lib/Utils/use-multi-file-auth-state.js +6 -27
  65. package/lib/Utils/use-single-file-auth-state.d.ts +1 -1
  66. package/lib/Utils/use-single-file-auth-state.js +3 -12
  67. package/lib/WABinary/types.d.ts +2 -6
  68. package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +3 -6
  69. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -3
  70. package/lib/WAUSync/USyncQuery.d.ts +1 -1
  71. package/lib/WAUSync/USyncQuery.js +4 -7
  72. package/package.json +107 -123
  73. package/lib/Utils/a2ui.d.ts +0 -50
  74. package/lib/Utils/a2ui.js +0 -168
  75. package/lib/Utils/anchor-guard.d.ts +0 -71
  76. package/lib/Utils/anchor-guard.js +0 -404
  77. package/lib/Utils/connection-manager.d.ts +0 -44
  78. package/lib/Utils/connection-manager.js +0 -258
  79. package/lib/Utils/ignore-key.d.ts +0 -51
  80. package/lib/Utils/ignore-key.js +0 -176
@@ -51,11 +51,7 @@ const makeDebouncedSaver = (filePath, getData, logger, delayMs = 500) => {
51
51
  clearTimeout(timer);
52
52
  try {
53
53
  writeFileSync(filePath, JSON.stringify(getData(), BufferJSON.replacer));
54
- } catch (err) {
55
- // Last-chance save on the way out. Nothing left to retry with, but a silent
56
- // failure here loses the session and looks like a random logout next boot.
57
- logger?.error?.({ err, filePath }, 'Failed to save credentials on exit');
58
- }
54
+ } catch { }
59
55
  }
60
56
  };
61
57
 
@@ -86,7 +82,7 @@ const makeDebouncedSaver = (filePath, getData, logger, delayMs = 500) => {
86
82
  return { save, flush: flushNow, destroy };
87
83
  };
88
84
 
89
- export const useMultiFileAuthState = async (folder, logger) => {
85
+ export const useMultiFileAuthState = async (folder) => {
90
86
  const writeData = async (data, file) => {
91
87
  const filePath = join(folder, fixFileName(file));
92
88
  const mutex = getFileLock(filePath);
@@ -111,13 +107,7 @@ export const useMultiFileAuthState = async (folder, logger) => {
111
107
  release();
112
108
  }
113
109
  });
114
- } catch (err) {
115
- // A missing file is the normal "no such key yet" answer. Anything else — corrupt
116
- // JSON, bad permissions — also yields null, which silently starts a fresh pairing,
117
- // so it is logged rather than swallowed.
118
- if (err?.code !== 'ENOENT') {
119
- logger?.warn?.({ err, file }, 'Failed to read auth state file');
120
- }
110
+ } catch {
121
111
  return null;
122
112
  }
123
113
  };
@@ -129,12 +119,7 @@ export const useMultiFileAuthState = async (folder, logger) => {
129
119
  return mutex.acquire().then(async (release) => {
130
120
  try {
131
121
  await unlink(filePath);
132
- } catch (err) {
133
- // Deleting a key that was never written is normal.
134
- if (err?.code !== 'ENOENT') {
135
- logger?.warn?.({ err, file }, 'Failed to remove auth state file');
136
- }
137
- }
122
+ } catch { }
138
123
  finally {
139
124
  release();
140
125
  }
@@ -154,7 +139,7 @@ export const useMultiFileAuthState = async (folder, logger) => {
154
139
  const fixFileName = (file) => file?.replace(/\//g, '__')?.replace(/:/g, '-');
155
140
  const creds = (await readData('creds.json')) || initAuthCreds();
156
141
  const credsPath = join(folder, 'creds.json');
157
- const debouncer = makeDebouncedSaver(credsPath, () => creds, logger, 500);
142
+ const debouncer = makeDebouncedSaver(credsPath, () => creds, null, 500);
158
143
 
159
144
  return {
160
145
  state: {
@@ -185,12 +170,6 @@ export const useMultiFileAuthState = async (folder, logger) => {
185
170
  }
186
171
  },
187
172
  saveCreds: debouncer.save,
188
- _flushCreds: debouncer.flush,
189
- /**
190
- * Drops the process exit/SIGINT/SIGTERM listeners this auth state installed. A long-lived
191
- * host that opens and closes many sessions leaks one set per call without it, and Node
192
- * starts warning about listener counts after eleven.
193
- */
194
- _destroy: debouncer.destroy
173
+ _flushCreds: debouncer.flush
195
174
  };
196
175
  };
@@ -1,4 +1,4 @@
1
- export function useSingleFileAuthState(fileName: any, logger?: any): Promise<{
1
+ export function useSingleFileAuthState(fileName: any): Promise<{
2
2
  state: {
3
3
  creds: any;
4
4
  keys: {
@@ -8,7 +8,7 @@ import { Mutex } from 'async-mutex';
8
8
  // Lia@Changes 25-03-26 --- Add useSingleFileAuthState with integrated cache
9
9
  const FLUSH_TIMEOUT_MS = 3000;
10
10
  // Lia@Changes 22-04-26 --- Enhanced useSingleFileAuthState with LRUCache
11
- export const useSingleFileAuthState = async (fileName, logger) => {
11
+ export const useSingleFileAuthState = async (fileName) => {
12
12
  const cache = new LRUCache({
13
13
  max: 20000,
14
14
  ttl: 1000 * DEFAULT_CACHE_TTLS.SIGNAL_STORE,
@@ -32,12 +32,7 @@ export const useSingleFileAuthState = async (fileName, logger) => {
32
32
  cache.set(keyName, value);
33
33
  }
34
34
  }
35
- catch (err) {
36
- // A missing file is a fresh session. Corrupt JSON or bad permissions also land
37
- // here and silently discard a working session, so they are logged.
38
- if (err?.code !== 'ENOENT') {
39
- logger?.warn?.({ err, fileName }, 'Failed to load auth state file, starting empty');
40
- }
35
+ catch {
41
36
  fileData = {};
42
37
  }
43
38
  isLoaded = true;
@@ -54,11 +49,7 @@ export const useSingleFileAuthState = async (fileName, logger) => {
54
49
  await writeFile(tempFile, JSON.stringify(fileData, BufferJSON.replacer));
55
50
  await rename(tempFile, fileName);
56
51
  }
57
- catch (err) {
58
- // Swallowing this lost every key written since the last successful flush with
59
- // no trace, which surfaces later as a session that cannot decrypt.
60
- logger?.error?.({ err, fileName }, 'Failed to flush auth state file');
61
- }
52
+ catch { }
62
53
  });
63
54
  }, FLUSH_TIMEOUT_MS);
64
55
  };
@@ -1,6 +1,2 @@
1
- export type BinaryNodeAttributes = Record<string, string>;
2
- export type BinaryNode = {
3
- tag: string;
4
- attrs: BinaryNodeAttributes;
5
- content?: BinaryNode[] | Uint8Array | string;
6
- };
1
+ export {};
2
+ //# sourceMappingURL=types.d.ts.map
@@ -1,4 +1,4 @@
1
- import { getBinaryNodeChild, getBinaryNodeChildren } from '../../WABinary/index.js';
1
+ import { assertNodeErrorFree, getBinaryNodeChild, getBinaryNodeChildren } from '../../WABinary/index.js';
2
2
  export class USyncBusinessProtocol {
3
3
  constructor(profileVersion = '2') {
4
4
  this.name = 'business'
@@ -10,8 +10,7 @@ export class USyncBusinessProtocol {
10
10
  attrs: {},
11
11
  content: [
12
12
  { tag: 'verified_name', attrs: {} },
13
- // pass a falsy profileVersion to ask for the verified name only
14
- ...(this.profileVersion ? [{ tag: 'profile', attrs: { v: this.profileVersion } }] : [])
13
+ { tag: 'profile', attrs: { v: this.profileVersion } }
15
14
  ]
16
15
  }
17
16
  }
@@ -27,9 +26,7 @@ export class USyncBusinessProtocol {
27
26
  }
28
27
  parser(node) {
29
28
  if (node.tag !== 'business') return null
30
- // a non-business contact answers with an <error/> child; that is "no business profile",
31
- // not a query failure, so it must not abort the whole usync result
32
- if (getBinaryNodeChild(node, 'error')) return null
29
+ assertNodeErrorFree(node)
33
30
  const verifiedNameNode = getBinaryNodeChild(node, 'verified_name')
34
31
  const profileNode = getBinaryNodeChild(node, 'profile')
35
32
 
@@ -1,14 +1,13 @@
1
1
  import { assertNodeErrorFree } from '../../WABinary/index.js';
2
2
  import { USyncUser } from '../USyncUser.js';
3
3
  export class USyncContactProtocol {
4
- constructor(addressingMode) {
4
+ constructor() {
5
5
  this.name = 'contact';
6
- this.addressingMode = addressingMode;
7
6
  }
8
7
  getQueryElement() {
9
8
  return {
10
9
  tag: 'contact',
11
- attrs: this.addressingMode ? { addressing_mode: this.addressingMode } : {}
10
+ attrs: {}
12
11
  };
13
12
  }
14
13
  getUserElement(user) {
@@ -17,7 +17,7 @@ export class USyncQuery {
17
17
  sideList: any[];
18
18
  } | undefined;
19
19
  withDeviceProtocol(): this;
20
- withContactProtocol(addressingMode?: 'lid' | 'pn'): this;
20
+ withContactProtocol(): this;
21
21
  withStatusProtocol(): this;
22
22
  withDisappearingModeProtocol(): this;
23
23
  withBotProfileProtocol(): this;
@@ -61,10 +61,7 @@ export class USyncQuery {
61
61
  }
62
62
  const parseUserNodes = (nodes) => nodes.reduce((acc, node) => {
63
63
  const id = node?.attrs.jid;
64
- // a username lookup answered without a jid means the server wants the 4-digit
65
- // username key before it reveals the account; keep the row so callers can see that
66
- const keyRequired = !id && !!getBinaryNodeChild(node, 'contact')?.attrs?.username;
67
- if (id || keyRequired) {
64
+ if (id) {
68
65
  // a user-level error attr means the contact has blocked us; WA uses
69
66
  // 401/403/405 on the <user> node in that case
70
67
  const userErrorCode = node?.attrs?.error ? parseInt(node.attrs.error, 10) : 0;
@@ -118,7 +115,7 @@ export class USyncQuery {
118
115
  if (isBlockedByAttr) {
119
116
  data.isBlockedByContact = true;
120
117
  }
121
- acc.push({ ...data, id, ...(keyRequired ? { keyRequired: true } : {}) });
118
+ acc.push({ ...data, id });
122
119
  }
123
120
  return acc;
124
121
  }, []);
@@ -136,8 +133,8 @@ export class USyncQuery {
136
133
  this.protocols.push(new USyncDeviceProtocol());
137
134
  return this;
138
135
  }
139
- withContactProtocol(addressingMode) {
140
- this.protocols.push(new USyncContactProtocol(addressingMode));
136
+ withContactProtocol() {
137
+ this.protocols.push(new USyncContactProtocol());
141
138
  return this;
142
139
  }
143
140
  withStatusProtocol() {
package/package.json CHANGED
@@ -1,125 +1,109 @@
1
1
  {
2
- "name": "@violetix/baileys",
3
- "version": "0.5.5",
4
- "description": "Enhanced Baileys v7 with fixes for newsletter media uploads, plus support for interactive messages, albums, and additional message types.",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "type": "module",
8
- "scripts": {
9
- "preinstall": "node ./engine-requirements.js",
10
- "test": "node --experimental-vm-modules --test",
11
- "test:types": "tsc -p tests/types/tsconfig.json",
12
- "check": "node scripts/check.mjs && npm run test:types && npm test",
13
- "prepublishOnly": "npm run check",
14
- "proto": "node scripts/generate-waproto.mjs"
15
- },
16
- "engines": {
17
- "node": ">=20.0.0"
18
- },
19
- "repository": {
20
- "type": "git",
21
- "url": "git+https://github.com/cv3inx/bv2.git"
22
- },
23
- "files": [
24
- "lib/**/*",
25
- "WAProto/**/*",
26
- "engine-requirements.js"
27
- ],
28
- "keywords": [
29
- "automation",
30
- "baileys",
31
- "bot",
32
- "interactive-messages",
33
- "js-whatsapp",
34
- "multi-device",
35
- "whatsapp",
36
- "whatsapp-api",
37
- "whatsapp-bot",
38
- "whatsapp-web"
39
- ],
40
- "homepage": "https://github.com/cv3inx/bv2#readme",
41
- "author": "Violetics",
42
- "contributors": [
43
- "Lia Wynn",
44
- "Rajeh Taher / WhiskeySockets"
45
- ],
46
- "license": "MIT",
47
- "publishConfig": {
48
- "access": "public"
49
- },
50
- "dependencies": {
51
- "@adiwajshing/keyed-db": "^0.2.4",
52
- "@cacheable/node-cache": "^1.4.0",
53
- "@hapi/boom": "^9.1.3",
54
- "async-mutex": "^0.5.0",
55
- "fflate": "^0.8.2",
56
- "libsignal": "^6.0.0",
57
- "lru-cache": "^11.2.6",
58
- "music-metadata": "^11.12.3",
59
- "p-queue": "^9.1.0",
60
- "pino": "^9.6.0",
61
- "protobufjs": "^7.5.6",
62
- "whatsapp-rust-bridge": "0.5.5",
63
- "ws": "^8.19.0"
64
- },
65
- "peerDependencies": {
66
- "@napi-rs/image": "~1.12.0",
67
- "audio-decode": "^2.2.3",
68
- "better-sqlite3": "^11.0.0",
69
- "jimp": "^1.6.1",
70
- "link-preview-js": "^3.0.0",
71
- "sharp": ">=0.33.0"
72
- },
73
- "peerDependenciesMeta": {
74
- "@napi-rs/image": {
75
- "optional": true
76
- },
77
- "audio-decode": {
78
- "optional": true
79
- },
80
- "better-sqlite3": {
81
- "optional": true
82
- },
83
- "jimp": {
84
- "optional": true
85
- },
86
- "link-preview-js": {
87
- "optional": true
88
- }
89
- },
90
- "resolutions": {
91
- "ajv@npm:^6.12.4": "^6.14.0",
92
- "basic-ftp": "^5.2.4",
93
- "brace-expansion@npm:^1.1.7": "^1.1.13",
94
- "brace-expansion@npm:^2.0.1": "^2.0.3",
95
- "flatted": "^3.4.2",
96
- "glob@npm:^10.2.2": "^10.5.0",
97
- "glob@npm:^10.3.10": "^10.5.0",
98
- "glob@npm:^10.5.0": "^10.5.0",
99
- "handlebars": "^4.7.9",
100
- "ip-address": "^10.1.1",
101
- "js-yaml@npm:^3.13.1": "^3.14.2",
102
- "js-yaml@npm:^4.1.0": "^4.1.1",
103
- "markdown-it": "^14.1.1",
104
- "minimatch@npm:^3.0.4": "^3.1.5",
105
- "minimatch@npm:^3.1.2": "^3.1.5",
106
- "minimatch@npm:^5.0.1": "^5.1.8",
107
- "minimatch@npm:^9.0.4": "^9.0.9",
108
- "minimatch@npm:^9.0.5": "^9.0.9",
109
- "picomatch@npm:^2.0.4": "^2.3.2",
110
- "picomatch@npm:^2.3.1": "^2.3.2",
111
- "picomatch@npm:^4.0.0": "^4.0.4",
112
- "picomatch@npm:^4.0.2": "^4.0.4",
113
- "socks": "^2.8.8",
114
- "tar": "^7.5.11",
115
- "tmp": "^0.2.5",
116
- "underscore": "^1.13.8",
117
- "yaml@npm:^2.6.1": "^2.8.4"
118
- },
119
- "packageManager": "yarn@4.9.2",
120
- "devDependencies": {
121
- "@types/node": "^20.19.43",
122
- "protobufjs-cli": "^1.3.3",
123
- "typescript": "^7.0.2"
124
- }
2
+ "name": "@violetix/baileys",
3
+ "version": "0.6.0",
4
+ "description": "Enhanced Baileys v7 with fixes for newsletter media uploads, plus support for interactive messages, albums, and additional message types.",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "type": "module",
8
+ "scripts": {
9
+ "preinstall": "node ./engine-requirements.js"
10
+ },
11
+ "engines": {
12
+ "node": ">=20.0.0"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/itsliaaa/baileys.git"
17
+ },
18
+ "files": [
19
+ "lib/**/*",
20
+ "WAProto/**/*",
21
+ "engine-requirements.js"
22
+ ],
23
+ "keywords": [
24
+ "automation",
25
+ "baileys",
26
+ "bot",
27
+ "interactive-messages",
28
+ "js-whatsapp",
29
+ "multi-device",
30
+ "whatsapp",
31
+ "whatsapp-api",
32
+ "whatsapp-bot",
33
+ "whatsapp-web"
34
+ ],
35
+ "homepage": "https://github.com/itsliaaa/baileys#readme",
36
+ "author": "Lia Wynn",
37
+ "license": "MIT",
38
+ "dependencies": {
39
+ "@adiwajshing/keyed-db": "^0.2.4",
40
+ "@cacheable/node-cache": "^1.4.0",
41
+ "@hapi/boom": "^9.1.3",
42
+ "@noble/curves": "2.4.0",
43
+ "async-mutex": "^0.5.0",
44
+ "fflate": "^0.8.2",
45
+ "libsignal": "^6.0.0",
46
+ "lru-cache": "^11.2.6",
47
+ "music-metadata": "^11.12.3",
48
+ "p-queue": "^9.1.0",
49
+ "pino": "^9.6.0",
50
+ "protobufjs": "^7.5.6",
51
+ "whatsapp-rust-bridge": "0.5.5",
52
+ "ws": "^8.19.0"
53
+ },
54
+ "peerDependencies": {
55
+ "@napi-rs/image": "~1.12.0",
56
+ "audio-decode": "^2.2.3",
57
+ "better-sqlite3": "^11.0.0",
58
+ "jimp": "^1.6.1",
59
+ "link-preview-js": "^3.0.0",
60
+ "sharp": "*"
61
+ },
62
+ "peerDependenciesMeta": {
63
+ "@napi-rs/image": {
64
+ "optional": true
65
+ },
66
+ "audio-decode": {
67
+ "optional": true
68
+ },
69
+ "better-sqlite3": {
70
+ "optional": true
71
+ },
72
+ "jimp": {
73
+ "optional": true
74
+ },
75
+ "link-preview-js": {
76
+ "optional": true
77
+ }
78
+ },
79
+ "resolutions": {
80
+ "ajv@npm:^6.12.4": "^6.14.0",
81
+ "basic-ftp": "^5.2.4",
82
+ "brace-expansion@npm:^1.1.7": "^1.1.13",
83
+ "brace-expansion@npm:^2.0.1": "^2.0.3",
84
+ "flatted": "^3.4.2",
85
+ "glob@npm:^10.2.2": "^10.5.0",
86
+ "glob@npm:^10.3.10": "^10.5.0",
87
+ "glob@npm:^10.5.0": "^10.5.0",
88
+ "handlebars": "^4.7.9",
89
+ "ip-address": "^10.1.1",
90
+ "js-yaml@npm:^3.13.1": "^3.14.2",
91
+ "js-yaml@npm:^4.1.0": "^4.1.1",
92
+ "markdown-it": "^14.1.1",
93
+ "minimatch@npm:^3.0.4": "^3.1.5",
94
+ "minimatch@npm:^3.1.2": "^3.1.5",
95
+ "minimatch@npm:^5.0.1": "^5.1.8",
96
+ "minimatch@npm:^9.0.4": "^9.0.9",
97
+ "minimatch@npm:^9.0.5": "^9.0.9",
98
+ "picomatch@npm:^2.0.4": "^2.3.2",
99
+ "picomatch@npm:^2.3.1": "^2.3.2",
100
+ "picomatch@npm:^4.0.0": "^4.0.4",
101
+ "picomatch@npm:^4.0.2": "^4.0.4",
102
+ "socks": "^2.8.8",
103
+ "tar": "^7.5.11",
104
+ "tmp": "^0.2.5",
105
+ "underscore": "^1.13.8",
106
+ "yaml@npm:^2.6.1": "^2.8.4"
107
+ },
108
+ "packageManager": "yarn@4.9.2"
125
109
  }
@@ -1,50 +0,0 @@
1
- export type A2UIWidget = {
2
- uuid: string;
3
- data: string;
4
- type: string;
5
- fallback?: string;
6
- };
7
- export type A2UIBuildOptions = {
8
- uuid?: string;
9
- surfaceId?: string;
10
- type?: string;
11
- /** `false` emits a bare `{ components }` payload instead of the `createSurface` envelope. */
12
- wrapped?: boolean;
13
- };
14
- export type A2UIChoice = {
15
- label: string;
16
- value: unknown;
17
- };
18
- export type A2UIListCardItem = {
19
- title: string;
20
- price?: string;
21
- trailingLabel?: string;
22
- assetId?: string;
23
- assetType?: string;
24
- emphasis?: string;
25
- };
26
- /** Every method registers a component and returns its id; container methods take those ids. */
27
- export declare class A2UI {
28
- constructor(options?: { catalogId?: string; version?: string });
29
- text(text: string, options?: { id?: string; variant?: string }): string;
30
- image(url: string, options?: { id?: string; variant?: string; fit?: string }): string;
31
- video(url: string, options?: { id?: string }): string;
32
- checkbox(label: string, options?: { id?: string; value?: boolean }): string;
33
- textField(label: string, options?: { id?: string; variant?: string }): string;
34
- button(childId: string, options?: { id?: string; variant?: string; action?: any }): string;
35
- card(childId: string, options?: { id?: string }): string;
36
- column(children: string[], options?: { id?: string; justify?: string; align?: string }): string;
37
- row(children: string[], options?: { id?: string }): string;
38
- divider(options?: { id?: string }): string;
39
- choicePicker(label: string, options: A2UIChoice[], extra?: {
40
- id?: string;
41
- variant?: string;
42
- value?: unknown;
43
- displayStyle?: string;
44
- filterable?: boolean;
45
- }): string;
46
- root(children: string[]): this;
47
- listCard(input: { title: string; items: A2UIListCardItem[]; fallbackText?: string; uuid?: string }): this;
48
- build(options?: A2UIBuildOptions): A2UIWidget;
49
- }
50
- export declare const buildA2UIWidget: (a2ui: A2UI | A2UIWidget, options?: A2UIBuildOptions) => A2UIWidget;