├── .gitignore ├── CHANGELOG.md ├── CHANGELOG_V4_BETA.md ├── LICENSE.md ├── README.md ├── aiAgent.d.ts ├── aiAgent.js ├── catalog-info.yaml ├── cjs ├── aiAgent.cjs ├── aiAgent.d.cts ├── feedChannel.cjs ├── feedChannel.d.cts ├── groupChannel.cjs ├── groupChannel.d.cts ├── index.cjs ├── index.d.cts ├── lib │ ├── __bundle-093a1164.cjs │ ├── __bundle-1df85995.cjs │ ├── __bundle-2ce6b383.cjs │ ├── __bundle-38c66c0d.cjs │ ├── __bundle-431295de.cjs │ ├── __bundle-6f2ea5a8.cjs │ ├── __bundle-81e2a005.cjs │ ├── __bundle-a6c826ee.cjs │ ├── __bundle-a7cea5ad.cjs │ ├── __bundle-a7decc5d.cjs │ ├── __bundle-a9ae393e.cjs │ ├── __bundle-b4546809.cjs │ ├── __bundle-d9242ab0.cjs │ ├── __bundle-dae7bdf2.cjs │ ├── __bundle-e762fd36.cjs │ ├── __bundle-f86328d4.cjs │ └── __definition.d.cts ├── message.cjs ├── message.d.cts ├── node.cjs ├── node.d.cts ├── openChannel.cjs ├── openChannel.d.cts ├── poll.cjs └── poll.d.cts ├── feedChannel.d.ts ├── feedChannel.js ├── groupChannel.d.ts ├── groupChannel.js ├── index.d.ts ├── index.js ├── lib ├── __bundle-0a529541.js ├── __bundle-14c04e55.js ├── __bundle-1e2e2638.js ├── __bundle-46d64517.js ├── __bundle-5dbfca78.js ├── __bundle-8b4f432b.js ├── __bundle-99351df8.js ├── __bundle-a656e856.js ├── __bundle-acd77193.js ├── __bundle-bb2f29e5.js ├── __bundle-becd93d5.js ├── __bundle-bf8c7310.js ├── __bundle-e41600ba.js ├── __bundle-ea869841.js └── __definition.d.ts ├── message.d.ts ├── message.js ├── node.d.ts ├── node.js ├── openChannel.d.ts ├── openChannel.js ├── package.json ├── poll.d.ts ├── poll.js └── sendbird.min.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /CHANGELOG_V4_BETA.md: -------------------------------------------------------------------------------- 1 | ### v4.0.0 (June 14, 2022) 2 | - Added `MyMemberStateFilter` 3 | - `GroupChannelListQueryParams.memberStateFilter` -> `GroupChannelListQueryParams.myMemberStateFilter` 4 | - `GroupChannelCountParams.memberStateFilter` -> `GroupChannelCountParams.myMemberStateFilter` 5 | - `GroupChannelFilter.memberStateFilter` -> `GroupChannelFilter.myMemberStateFilter` 6 | - Moved `getXXXCount()` `GroupChannelModule` 7 | - `SendbirdChat.getUnreadItemCount()` -> `SendbirdChat.groupChannel.getUnreadItemCount()` 8 | - `SendbirdChat.getTotalUnreadChannelCount()` -> `SendbirdChat.groupChannel.getTotalUnreadChannelCount()` 9 | - `SendbirdChat.getTotalUnreadMessageCount()` -> `SendbirdChat.groupChannel.getTotalUnreadMessageCount()` 10 | - `SendbirdChat.getTotalScheduledMessageCount()` -> `SendbirdChat.groupChannel.getTotalScheduledMessageCount()` 11 | - `SendbirdChat.getSubscribedTotalUnreadMessageCount()` -> `SendbirdChat.groupChannel.getSubscribedTotalUnreadMessageCount()` 12 | - `SendbirdChat.getSubscribedCustomTypeTotalUnreadMessageCount()` -> `SendbirdChat.groupChannel.getSubscribedCustomTypeTotalUnreadMessageCount()` 13 | - `SendbirdChat.getSubscribedCustomTypeUnreadMessageCount()` -> `SendbirdChat.groupChannel.getSubscribedCustomTypeUnreadMessageCount()` 14 | - Bug fixed Scheduled messsage interface 15 | - Set default empty object `createChannel()` 16 | 17 | ### v4.0.0-beta.12 (June 09, 2022) 18 | - Type of `SendbirdChatParams.useAsyncStorageStore` has changed to AsyncStorage of `@react-native-async-storage/async-storage` 19 | - Added `clearCachedMessages()` in `SendbirdChat` 20 | - Rename `SendbirdChat.clearCache()` to `SendbirdChat.clearCachedData()` 21 | - Bug fixed the logic for filtering public group channel in `GroupChannelCollection` 22 | - Rename `SendbirdChat.Options.useMemberAsMessageSender` to `SendbirdChat.Options.useMemberInfoInMessage` 23 | - `useMemberInfoInMessage` now applies to both `message.sender` and `message.mentionedUsers` 24 | - Bug fixed cached channel not updated when disconnect and then connect 25 | - Bug fixed broken file data of auto-resent file message 26 | - Added `BaseMessage.parentMessage` 27 | - Added `BaseMessage.applyParentMessage()` 28 | - Parent message update event now updates `parentMessage` value of all its child messages 29 | - Bug fixed `message.metaArrays` value not being updated after calling `createMessageMetaArrayKeys()`, `deleteMessageMetaArrayKeys()`, `addMessageMetaArrayValues()`, and `removeMessageMetaArrayValues()` of `BaseChannel` 30 | - `MessageCollectionInitPolicy.API_ONLY` has been removed 31 | - All classes whose namespace ends with params (ex. `UserMessageCreateParams`, `GroupChannelCreateParams`, etc.) is now changed to interfaces 32 | - Improved stability 33 | 34 | ### v4.0.0-beta.11 (May 24, 2022) 35 | - `SendbirdChat.connect()` now returns `User` instance from the cache if local cache is enabled 36 | - Improved stability 37 | 38 | ### v4.0.0-beta.10 (May 17, 2022) 39 | - `BaseMessage`'s `requestedMentionUserIds` has been replaced with `mentionedUserIds` 40 | - Getter and setter for `mentionedUsers` have been added to `userMessageCreateParams`, `userMessageUpdateParams`, `fileMessageUpdateParams`, and `fileMessageUpdateParams` 41 | - Getters for `BaseMessage`, `isUserMessage`, `isFileMessage`, and `isAdminMessage` have been replaced with `isUserMessage()`, `isFileMessage()`, and `isAdminMessage()` 42 | - Getters for `BaseChannel`, `isGroupChannel`, and `isOpenChannel`, have been replaced with `isGroupChannel()`, and `isOpenChannel()` 43 | - `reqId` in `BaseMessageCreateParamsProperties` has been removed 44 | - Added `translationTargetLanguages` in `UserMessage` 45 | - Added `translationTargetLanguages` in `UserMessageUpdateParamsProperties` 46 | - Scheduled message support: 47 | - Deleted `ScheduledUserMessageParams` 48 | - Deleted `ScheduledUserMessage` 49 | - Deleted `registerScheduledUserMessage()` in `GroupChannel` 50 | - Added `scheduledInfo` in `BaseMessage` 51 | - Added `ScheduledStatus` 52 | - Added `SCHEDULED` in `SendingStatus` 53 | - Added `ScheduledMessageRetrievalParams` 54 | - Added `ScheduledFileMessageCreateParams` 55 | - Added `ScheduledFileMessageUpdateParams` 56 | - Added `ScheduledUserMessageCreateParams` 57 | - Added `ScheduledUserMessageUpdateParams` 58 | - Added `TotalScheduledMessageCountParams` 59 | - Added `ScheduledMessageListOrder` 60 | - Added `ScheduledMessageListQuery` 61 | - Added `ScheduledMessageListQueryParams` 62 | - Added `getScheduledMessage()` in `MessageModule` 63 | - Added `createScheduledMessageListQuery()` in `GroupChannelModule` 64 | - Added `getTotalScheduledMessageCount()` in `SendbirdChat` 65 | - Added `createScheduledUserMessage()`, `updateScheduledUserMessage()`, `createScheduledFileMessage()`, `updateScheduledFileMessage()`, `cancelScheduledMessage()`, `sendScheduledMessageNow()` in `GroupChannel` 66 | 67 | ### v4.0.0-beta.9 (May 13, 2022) 68 | - Bug Fix in sending a message 69 | 70 | ### v4.0.0-beta.8 (May 11, 2022) 71 | - Improve stabilize 72 | 73 | ### v4.0.0-beta.7 (May 10, 2022) 74 | - Improve stabilize 75 | 76 | ### v4.0.0-beta.6 (May 03, 2022) 77 | - Improve stabilize 78 | 79 | ### v4.0.0-beta.4 (Apr 15, 2022) 80 | - Improve stabilize 81 | 82 | ### v4.0.0-beta.3 (Apr 14, 2022) 83 | - Bug Fixes 84 | 85 | ### v4.0.0-beta (Apr 12, 2022) 86 | - No callback. Use `Promise` 87 | 88 | ```ts 89 | // v3 90 | sb.connect(userId, (err, user) => {}); 91 | 92 | // v4 93 | const user = await sb.connect(userId); 94 | ``` 95 | 96 | - `Treeshaking` applied. The classes, interfaces, enums, types come to be `import`-able with treeshaking. See [SDK reference](https://sendbird.com/docs/chat/v4/javascript/ref/index.html) page for detailed list of exports. 97 | 98 | ```ts 99 | // v3 100 | sb.GroupChannel 101 | sb.LogLevel 102 | ... 103 | 104 | // v4 105 | import { LogLevel } from '@sendbird/chat'; 106 | import { GroupChannel } from '@sendbird/groupChannel'; 107 | ... 108 | ``` 109 | 110 | - `static` object relocation 111 | 112 | |`v3`|`v4`| 113 | |-|-| 114 | |`sb.GroupChannel`|`sb.groupChannel`*| 115 | |`sb.OpenChannel`|`sb.openChannel`**| 116 | |`sb.BaseMessage`|`sb.message`| 117 | 118 | > \* Should declare `GroupChannelModule` in `SendbirdChat.init()` 119 | > ** Should declare `OpenChannelModule` in `SendbirdChat.init()` 120 | 121 | ## New features 122 | 123 | - Added `onConnected()`, `onDisconnected()` to `ConnectionHandler` 124 | - Added `translationTargetLanguages` in `UserMessage` 125 | - Added `translationTargetLanguages` in `UserMessageUpdateParamsProperties` 126 | - Scheduled message support: 127 | - Added `scheduledInfo` in `BaseMessage` 128 | - Added `ScheduledStatus` 129 | - Added `SCHEDULED` in `SendingStatus` 130 | - Added `ScheduledMessageRetrievalParams` 131 | - Added `ScheduledFileMessageCreateParams` 132 | - Added `ScheduledFileMessageUpdateParams` 133 | - Added `ScheduledUserMessageCreateParams` 134 | - Added `ScheduledUserMessageUpdateParams` 135 | - Added `TotalScheduledMessageCountParams` 136 | - Added `ScheduledMessageListOrder` 137 | - Added `ScheduledMessageListQuery` 138 | - Added `ScheduledMessageListQueryParams` 139 | - Added `getScheduledMessage()` in `MessageModule` 140 | - Added `createScheduledMessageListQuery()` in `GroupChannelModule` 141 | - Added `getTotalScheduledMessageCount()` in `SendbirdChat` 142 | - Added `createScheduledUserMessage()`, `updateScheduledUserMessage()`, `createScheduledFileMessage()`, `updateScheduledFileMessage()`, `cancelScheduledMessage()`, `sendScheduledMessageNow()` in `GroupChannel` 143 | 144 | ## Changes 145 | 146 | - Changed initialization interface 147 | 148 | ```ts 149 | // v3 150 | import SendBird from 'sendbird'; 151 | import AsyncStorage from '@react-native-async-storage/async-storage'; 152 | 153 | const sb = new SendBird({ 154 | appId: APP_ID, 155 | localCacheEnabled: true, 156 | }); 157 | sb.setLogLevel(sb.LogLevel.WARN); 158 | sb.appVersion = APP_VERSION; 159 | sb.Options.useMemberAsMessageSender = true; 160 | 161 | // only for React Native 162 | sb.useAsyncStorageAsDatabase(AsyncStorage); 163 | 164 | // v4 165 | import SendbirdChat, { 166 | SendbirdChatOptions, 167 | Loglevel 168 | } from '@sendbird/chat'; 169 | import AsyncStorage from '@react-native-async-storage/async-storage'; 170 | 171 | const sb = SendbirdChat.init({ 172 | appId: APP_ID, 173 | appVersion: APP_VERSION, 174 | modules, 175 | options: new SendbirdChatOptions({ 176 | useMemberAsMessageSender: true, 177 | }), 178 | logLevel: LogLevel.WARN, 179 | localCacheEnabled: true, 180 | useAsyncStorageStore: AsyncStorage, // only for React Native 181 | }); 182 | ``` 183 | 184 | - Replaced `ChannelHandler` to `GroupChannelHandler` and `OpenChannelHandler` 185 | 186 | ```ts 187 | // v3 188 | const channelHandler = new sb.ChannelHandler(); 189 | channelHandler.onChannelChanged = (channel) => { 190 | ... 191 | }; 192 | sb.addChannelHandler(EVENT_ID, channelHandler); 193 | sb.removeChannelHandler(EVENT_ID); 194 | 195 | // v4 196 | import { GroupChannelHandler } from '@sendbird/chat/groupChannel'; 197 | 198 | const channelHandler = new GroupChannelHandler({ 199 | onChannelChanged: (channel) => { 200 | ... 201 | }, 202 | }); 203 | sb.groupChannel.addGroupChannelHandler(EVENT_ID, channelHandler); 204 | sb.groupChannel.removeGroupChannelHandler(EVENT_ID); 205 | ``` 206 | 207 | - No builder pattern for `Collection`s 208 | 209 | ```ts 210 | // v3 211 | const groupChannelFilter = new sb.GroupChannelFilter(); 212 | const gc = sb.GroupChannel.createGroupChannelCollection() 213 | .setOrder(sb.GroupChannelCollection.GroupChannelOrder.LATEST_LAST_MESSAGE) 214 | .setFilter(groupChannelFilter) 215 | .build(); 216 | 217 | const messageFilter = new sb.MessageFilter(); 218 | const mc = channel.createMessageCollection() 219 | .setFilter(messageFilter) 220 | .setStartingPoint(startingPoint) 221 | .build(); 222 | 223 | // v4 224 | import { 225 | GroupChannelFilter, 226 | GroupChannelListOrder 227 | } from '@sendbird/chat/groupChannel'; 228 | import { MessageFilter } from '@sendbird/chat/message'; 229 | 230 | const groupChannelFilter = new GroupChannelFilter(); 231 | const gc = sb.groupChannel.createGroupChannelCollection({ 232 | filter: groupChannelFilter, 233 | order: GroupChannelListOrder.LATEST_LAST_MESSAGE, 234 | }); 235 | 236 | const messageFilter = new MessageFilter(); 237 | const mc = channel.createMessageCollection({ 238 | filter: messageFilter, 239 | startingPoint: Date.now(), 240 | }); 241 | ``` 242 | 243 | - Changed `sb.updateCurrentUserInfo()` to take `UserUpdateParams` as a parameter 244 | 245 | ```ts 246 | // v3 247 | sb.updateCurrentUserInfo(NICKNAME, PROFILE_URL); 248 | sb.updateCurrentUserInfoWithProfileImage(NICKNAME, PROFILE_IMAGE); 249 | 250 | // v4 251 | sb.updateCurrentUserInfo({ 252 | nickname: NICKNAME, 253 | profileUrl: PROFILE_URL, 254 | // or you can put a file as `profileImage` to upload the profile 255 | }); 256 | // no sb.updateCurrentUserInfoWithProfileImage() 257 | ``` 258 | 259 | - Changed `sb.getUnreadItemCount()` to take `UnreadItemCountParams` as a parameter 260 | 261 | ```ts 262 | // v3 263 | sb.getUnreadItemCount(KEYS); 264 | 265 | // v4 266 | sb.getUnreadItemCount({ 267 | keys: KEYS, 268 | }); 269 | ``` 270 | 271 | - Changed `sb.getTotalUnreadMessageCount()` to take `TotalUnreadMessageCountParams` as a parameter 272 | 273 | ```ts 274 | // v3 275 | sb.getTotalUnreadMessageCount(CHANNEL_CUSTOM_TYPES); 276 | // no super channel filter support 277 | 278 | // v4 279 | sb.getTotalUnreadMessageCount({ 280 | channelCustomTypesFilter: CHANNEL_CUSTOM_TYPES, 281 | superChannelFilter: SUPER_CHANNEL_FILTER, 282 | }); 283 | ``` 284 | 285 | - Changed `sendUserMessage()` and `sendFileMessage()` interface to chain the callbacks for pending/failed/succeeded messages 286 | 287 | ```ts 288 | // v3 289 | const pendingMessage = channel.sendUserMessage(params, (err, message) => { 290 | if (err) { 291 | // message is a failed message 292 | } else { 293 | // message is a succeeded message 294 | } 295 | }); 296 | 297 | // v4 298 | channel.sendUserMessage(params) 299 | .onPending((pendingMessage: UserMessage) => {}) 300 | .onFailed((err: Error, failedMessage: UserMessage) => {}) 301 | .onSucceeded((succeededMessage: UserMessage) => {}); 302 | ``` 303 | 304 | - Changed all classes whose namespace ends with params to interfaces 305 | 306 | ```ts 307 | // v3 308 | const params = new sb.UserMessageParams(); 309 | params.message = 'message'; 310 | 311 | const pendingMessage = channel.sendUserMessage(params, (err, message) => { 312 | if (err) { 313 | // message is a failed message 314 | } else { 315 | // message is a succeeded message 316 | } 317 | }); 318 | 319 | // v4 320 | import { UserMessageParams } from '@sendbird/chat/message'; 321 | 322 | channel.sendUserMessage({ 323 | message: 'message', 324 | }) 325 | .onPending((pendingMessage: UserMessage) => {}) 326 | .onFailed((err: Error, failedMessage: UserMessage) => {}) 327 | .onSucceeded((succeededMessage: UserMessage) => {}); 328 | ``` 329 | 330 | - Separated update params from create params 331 | 332 | ```ts 333 | // v3 334 | GroupChannelParams // both for create/update 335 | OpenChannelParams // both for create/update 336 | UserMessageParams // both for send/update 337 | FileMessageParams // both for send/update 338 | 339 | // v4 340 | GroupChannelCreateParams 341 | GroupChannelUpdateParams 342 | OpenChannelCreateParams 343 | OpenChannelUpdateParams 344 | UserMessageCreateParams 345 | UserMessageUpdateParams 346 | FileMessageCreateParams 347 | FileMessageUpdateParams 348 | ``` 349 | 350 | - Changed to accept properties in `~Query` constructors. The query properties are immutable later on 351 | 352 | ```ts 353 | // v3 354 | const query = sb.GroupChannel.createMyGroupChannelListQuery(); 355 | query.customTypesFilter = ['a', 'b']; 356 | query.order = 'latest_last_message'; 357 | 358 | // v4 359 | import { GroupChannelListOrder } from '@sendbird/chat/groupChannel'; 360 | 361 | const query = sb.groupChannel.createMyGroupChannelListQuery({ 362 | customTypesFilter: ['a', 'b'], 363 | order: GroupChannelListOrder.LATEST_LAST_MESSAGE, 364 | }); 365 | query.customTypesFilter = ['a', 'b']; // ERROR! IMMUTABLE PROPERTY! 366 | ``` 367 | 368 | - Changed `buildFromSerializedData()` paths 369 | 370 | ```ts 371 | // v3 372 | sb.AdminMessage.buildFromSerializedData() 373 | sb.FileMessage.buildFromSerializedData() 374 | sb.UserMessage.buildFromSerializedData() 375 | sb.Sender.buildFromSerializedData() 376 | 377 | sb.GroupChannel.buildFromSerializedData() 378 | sb.GroupChannelListQuery.buildFromSerializedData() 379 | sb.Member.buildFromSerializedData() 380 | 381 | sb.OpenChannel.buildFromSerializedData() 382 | 383 | sb.User.buildFromSerializedData() 384 | 385 | // v4 386 | sb.message.buildMessageFromSerializedData() // admin/file/user altogether 387 | sb.message.buildSenderFromSerializedData() 388 | 389 | sb.groupChannel.buildGroupChannelFromSerializedData() 390 | sb.groupChannel.buildGroupChannelListQueryFromSerializedData() 391 | sb.groupChannel.buildMemberFromSerializedData() 392 | 393 | sb.openChannel.buildOpenChannelFromSerializedData() 394 | 395 | sb.buildUserFromSerializedData() 396 | ``` 397 | 398 | - Turned some getter functions to read-only properties 399 | 400 | ```ts 401 | // v3 402 | SendBird.getInstance() 403 | sb.getApplicationId() 404 | sb.getConnectionState() 405 | sb.getLastConnectedAt() 406 | channel.getCachedMetaData() 407 | message.isResendable() 408 | 409 | // v4 410 | SendbirdChat.instance 411 | sb.appId 412 | sb.connectionState 413 | sb.lastConnectedAt 414 | channel.cachedMetaData 415 | message.isResendable 416 | ``` 417 | 418 | - Relocations 419 | 420 | |v3|v4| 421 | |-|-| 422 | |`sb.getMyGroupChannelChangeLogsByToken()`|`sb.groupChannel.getMyGroupChannelChangeLogsByToken()`| 423 | |`sb.getMyGroupChannelChangeLogsByTimestamp()`|`sb.groupChannel.getMyGroupChannelChangeLogsByTimestamp()`| 424 | 425 | - Renames 426 | 427 | |v3|v4| 428 | |-|-| 429 | |`SendBird`|`SendbirdChat`| 430 | |`SendBirdException`|`SendbirdError`| 431 | |`GCMPushToken`|`FCMPushToken`*| 432 | |`sb.initializeDatabase()`|`sb.initializeCache()`| 433 | |`sb.clearDatabase()`|`sb.clearCache()`| 434 | |`channelHandler.onReadReceiptUpdated()`|`groupChannelHandler.onUnreadMemberStatusUpdated()`| 435 | |`channelHandler.onDeliveryReceiptUpdated()`|`groupChannelHandler.onUndeliveredMemberStatusUpdated()`| 436 | |`groupChannel.cachedReadReceiptStatus`|`groupChannel.cachedUnreadMemberState`| 437 | |`groupChannel.cachedDeliveryReceiptStatus`|`groupChannel.cachedUndeliveredMemberState`| 438 | |`message.requestedMentionUserIds`|`message.mentionedUserIds`| 439 | |`Options.useMemberAsMessageSender`|`SendbirdChatOptions.useMemberInfoInMessage`| 440 | > \* But stilling meaning the token for Android 441 | 442 | ## Removes 443 | 444 | - Removed `channel.getMessagesByID()`. 445 | - Removed `ScheduledUserMessageParams`. 446 | - Removed `ScheduledUserMessage`. 447 | - Removed `groupChannel.registerScheduledUserMessage()`. 448 | - Removed `MessageCollectionInitPolicy.CACHE_ONLY`. -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # SendBird SDK LICENSE 2 | 3 | This is an agreement between You ("You") and SendBird, Inc., the developer of SendBird, located at 400 1st Ave, San Mateo, CA 94401, ("SendBird") regarding Your use of the SendBird SDK and any associated documentation or other materials made available by SendBird (collectively the "SDK"). This agreement applies to any updates or supplements for the SDK, unless other terms accompany those items. If so, those other terms apply. 4 | 5 | By installing, accessing or otherwise using the SDK, You accept the terms of this agreement. If You do not agree to the terms of this agreement, do not install, access or use the SDK. 6 | 7 | If You comply with this agreement, You have the rights below. 8 | 9 | (1) USE OF THE SDK. Subject to Your compliance with this agreement, SendBird hereby authorizes You to use the SDK solely for the purpose of creating mobile applications designed to operate with the Services (referred to as "Authorized Applications"). You may not rent, lease or lend any of Your rights in the SDK or access to the Services. You may make a reasonable number of copies of the SDK for the purposes set forth herein, provided that You reproduce only complete copies, including without limitation all "read me" files, copyright notices, and other legal notices and terms that SendBird has included in the SDK. 10 | 11 | (2) SCOPE OF LICENSE. The SDK is licensed, not sold. This agreement only gives You some rights to use the SDK. SendBird specifically does not grant any express or implied rights under its patents with respect to your Authorized Applications. In doing so, You must comply with any technical limitations in the SDK that only allow You to use it in certain ways. You may not: (a) reverse engineer, decompile, distribute or disassemble the SDK, except and only to the extent that applicable law expressly permits; or (b) make more copies of the SDK than specified in this agreement, except and only to the extent applicable law expressly permits; or (c) publish the SDK for others to copy; or (d) rent, lease or lend the SDK. 12 | 13 | (3) USE OF THE SERVICES. Your use of the Services, and the use of the Services by anyone hosting or using your Authorized Application, is governed by the then-current Terms of Services (“TOS”) which can be found at: https://sendbird.com/terms. 14 | 15 | (4) EXPORT RESTRICTIONS. THE SDK IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE SDK. 16 | 17 | (5) FEEDBACK. By submitting feedback to SendBird, either via email at support@sendbird.com or by any other means: You automatically grant to SendBird a perpetual, irrevocable, transferable, royalty-free license to use Your feedback for any and all purposes without any compensation to You. 18 | 19 | (6) TERMINATION. SendBird reserves the right to discontinue offering the SDK or Services or to modify the SDK or Services at any time in its sole discretion. This Section and Sections 3, 4, 5, 8, 9, 10, 11, and 12 will survive termination of this agreement or any discontinuation of the offering of the SDK or Services along with any other provisions that would reasonably be deemed to survive such events. 20 | 21 | (7) RESERVATION OF RIGHTS. You are not authorized to alter, modify, copy, edit, format, create derivative works of or otherwise use any materials, content or technology provided under this agreement except as explicitly provided in this agreement or approved in advance in writing by SendBird. 22 | 23 | (8) MODIFICATIONS; NOTICES. If we change this contract, then we will give you notice before the change is in force. If you do not agree to these changes, then you must cancel and stop using the SDK and Services before the changes are in force. If you do not stop using the SDK or Services, then your use of the SDK or Services will continue under the changed contract. SendBird may give notices to You, at SendBird's option, by posting on any portion of sendbird.com or by electronic mail to any e-mail address provided by You to SendBird. 24 | 25 | (9) ENTIRE AGREEMENT. This agreement, and any applicable TOS or contract for Services, are the entire agreement with respect to the SDK or Services. 26 | 27 | (10) APPLICABLE LAW AND VENUE. California state law governs the interpretation of this agreement and applies to claims for breach of it, regardless of conflict of laws principles. The laws of the state where You live govern all other claims, including claims under state consumer protection laws, unfair competition laws, and in tort. You agree that any action brought under this agreement will be subject to exclusive jurisdiction and venue in the state and federal courts located in San Francisco, California. 28 | 29 | (11) DISCLAIMER OF WARRANTY. The SDK is licensed "as-is." You bear the risk of using it. SendBird gives no express or implied warranties, guarantees or conditions. You may have additional consumer rights under Your local laws which this agreement cannot change. To the extent permitted under Your local laws, SendBird excludes the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SendBird does not represent or warrant that the SDK or the Services will always be available, uninterrupted, secure, or error free. 30 | 31 | (12) LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. You can recover from SendBird and its suppliers only direct damages up to U.S. $5.00. You cannot recover any other damages, including consequential, lost profits, special, indirect or incidental damages. This limitation applies to: 32 | 33 | a. anything related to the SDK, services, or content (including code) on third party Internet sites, or third party programs; and 34 | 35 | b. claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law. 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Sendbird](https://sendbird.com) Chat SDK for JavaScript 2 | 3 | ![Platform](https://img.shields.io/badge/platform-JAVASCRIPT-orange.svg) 4 | ![Languages](https://img.shields.io/badge/language-TYPESCRIPT-orange.svg) 5 | [![npm](https://img.shields.io/npm/v/@sendbird/chat.svg?style=popout&colorB=red)](https://www.npmjs.com/package/@sendbird/chat) 6 | 7 | ## Table of contents 8 | 9 | 1. [Introduction](#introduction) 10 | 1. [Requirements](#requirements) 11 | 1. [Getting started](#getting-started) 12 | 1. [Sending your first message](#sending-your-first-message) 13 | 1. [Additional information](#additional-information) 14 | 15 | ## Introduction 16 | 17 | The Sendbird Chat SDK for JavaScript allows you to add real-time chat into your client app with minimal effort. Sendbird offers a feature rich, scalable, and proven chat solution depended on by companies like Reddit, Hinge, PubG and Paytm. 18 | 19 | ### How it works 20 | 21 | The Chat SDK provides the full functionality to provide a rich chat experience, implementing it begins by adding a user login, listing the available channels, selecting or creating an [open channel](https://sendbird.com/docs/chat/v4/javascript/guides/open-channel) or [group channel](https://sendbird.com/docs/chat/v4/javascript/guides/group-channel), and receive messages and other events through [channel event delegates](https://sendbird.com/docs/chat/v4/javascript/guides/event-delegate) and the ability to send a message. Once this basic functionality is in place, congratulations, you now have a chat app! 22 | 23 | Once this is in place, take a look at [all the other features](https://sendbird.com/features/chat-messaging/features) that Sendbird supports and add what works best for your users. 24 | 25 | ### Documentation 26 | 27 | Find out more about Sendbird Chat for JavaScript in [the documentation](https://sendbird.com/docs/chat/v4/javascript/getting-started/send-first-message). If you have any comments, questions or feature requests, let us know in the [Sendbird community](https://community.sendbird.com). 28 | 29 |
30 | 31 | ## Requirements 32 | 33 | This section shows you the prerequisites you need to check for using Sendbird Chat SDK for JavaScript. If you have any comments or questions regarding bugs and feature requests, visit [Sendbird community](https://community.sendbird.com). 34 | 35 | ### Supported browsers 36 | 37 | | Browser | Supported versions | 38 | | :---------------: | :--------------------- | 39 | | Internet Explorer | Not supported | 40 | | Edge | 13 or higher | 41 | | Chrome | 16 or higher | 42 | | Firefox | 11 or higher | 43 | | Safari | 7 or higher | 44 | | Opera | 12.1 or higher | 45 | | iOS Safari | 7 or higher | 46 | | Android Browser | 4.4 (Kitkat) or higher | 47 | 48 |
49 | 50 | ## Getting started 51 | 52 | The quickest way to get started is by using one of the sample apps from the [samples repo](https://github.com/sendbird/sendbird-chat-sample-react), create an application in the [Sendbird dashboard](https://dashboard.sendbird.com) and copy the `App ID` to the sample app and you’re ready to go. 53 |
54 | 55 | ## Step by step 56 | 57 | ### Step 1: Create a Sendbird application from your dashboard 58 | 59 | Before installing Sendbird Chat SDK, you need to create a Sendbird application on the [Sendbird Dashboard](https://dashboard.sendbird.com). You will need the `App ID` of your Sendbird application when initializing the Chat SDK. 60 | 61 | > **Note**: Each Sendbird application can be integrated with a single client app. Within the same application, users can communicate with each other across all platforms, whether they are on mobile devices or on the web. 62 | 63 |
64 | 65 | ### Step 2: Install the Chat SDK 66 | 67 | You can install the Chat SDK with either `npm` or `yarn`. 68 | 69 | **npm** 70 | 71 | ```bash 72 | $ npm install @sendbird/chat 73 | ``` 74 | 75 | > Note: To use npm to install the Chat SDK, Node.js must be first installed on your system. 76 | 77 | **yarn** 78 | 79 | ```bash 80 | $ yarn add @sendbird/chat 81 | ``` 82 | 83 | ### Step 3: Import the Chat SDk 84 | 85 | ```javascript 86 | import SendbirdChat from "@sendbird/chat"; 87 | // your chat app implementation 88 | ``` 89 | 90 | If you are using TypeScript and have trouble importing Sendbird, please check your `tsconfig.json` file and change the value of `allowSyntheticDefaultImports` to true in `compilerOptions`. 91 | 92 |
93 | 94 | ## Sending your first message 95 | 96 | Now that the Chat SDK has been imported, we're ready to start sending a message. 97 | 98 | ### Authentication 99 | 100 | In order to use the features of the Chat SDK, you should initiate the `SendbirdChatSDK` instance through user authentication with Sendbird server. This instance communicates and interacts with the server based on an authenticated user account, and then the user’s client app can use the Chat SDK's features. 101 | 102 | Here are the steps to sending your first message using Chat SDK: 103 | 104 | ### Step 4: Initialize the Chat SDK 105 | 106 | Before authentication, you need to intialize the SDK by calling `SendbirdChat.init`. 107 | 108 | The `init` method requires an appId, which is available from your Sendbird dashboard. 109 | 110 | To improve performance, this SDK is modular. You must import and provide the required modules when calling `init`. 111 | 112 | ```javascript 113 | import SendbirdChat from "@sendbird/chat"; 114 | import { OpenChannelModule } from "@sendbird/chat/openChannel"; 115 | 116 | const sb = SendbirdChat.init({ 117 | appId: APP_ID, 118 | modules: [new OpenChannelModule()], 119 | }); 120 | ``` 121 | 122 | ### Step 5: Connect to Sendbird server 123 | 124 | Once the SDK is initialized, your client app can then connect to the Sendbird server. If you attempt to call a Sendbird SDK method without connecting, an `ERR_CONNECTION_REQUIRED (800101)` error would return. 125 | 126 | Connect a user to Sendbird server either through a unique user ID or in combination with an access or session token. Sendbird prefers the latter method, as it ensures privacy with the user. The former is useful during the developmental phase or if your service doesn't require additional security. 127 | 128 | #### A. Using a unique user ID 129 | 130 | Connect a user to Sendbird server using their unique user ID. By default, Sendbird server can authenticate a user by a unique user ID. Upon request for a connection, the server queries the database to check for a match. Any untaken user ID is automatically registered as a new user to the Sendbird system, while an existing ID is allowed to log indirectly. The ID must be unique within a Sendbird application, such as a hashed email address or phone number in your service. 131 | 132 | This allows you to get up and running without having to go deep into the details of the token registration process, however make sure to enable enforcing tokens before launching as it is a security risk to launch without. 133 | 134 | ```javascript 135 | // The USER_ID below should be unique to your Sendbird application. 136 | try { 137 | const user = await sb.connect(USER_ID); 138 | // The user is connected to Sendbird server. 139 | } catch (err) { 140 | // Handle error. 141 | } 142 | ``` 143 | 144 | #### B. Using a combination of unique user ID and token 145 | 146 | Sendbird prefers that users connect using an access or session token, as it ensures privacy and security for the users. 147 | When [Creating a user](https://sendbird.com/docs/chat/v3/platform-api/guides/user#2-create-a-user) you can choose to generate a users access token or session token. 148 | A comparison between an access tokens and session tokens can be found [here](https://sendbird.com/docs/chat/v3/platform-api/user/managing-session-tokens/issue-a-session-token). 149 | Once a token is issued, a user is required to provide the issued token in the `sb.connect()` method which is used for logging in. 150 | 151 | 1. Using the Chat Platform API, create a Sendbird user with the information submitted when a user signs up your service. 152 | 2. Save the user ID along with the issued access token to your persistent storage which is securely managed. 153 | 3. When the user attempts to log in to the Sendbird application, load the user ID and access token from the storage, and then pass them to the `sb.connect()` method. 154 | 4. Periodically replacing the user's access token is recommended to protect the account. 155 | 156 | ```javascript 157 | try { 158 | const user = await sb.connect(USER_ID, ACCESS_TOKEN); 159 | // The user is connected to Sendbird server. 160 | } catch (err) { 161 | // Handle error. 162 | } 163 | ``` 164 | 165 | ### Step 6: Create a new open channel 166 | 167 | Create an open channel in the following way. [Open channels](https://sendbird.com/docs/chat/v4/ios/guides/open-channel) are where all users in your Sendbird application can easily participate without an invitation. 168 | 169 | ```javascript 170 | try { 171 | const params = new OpenChannelParams(); 172 | const channel = await sb.openChannel.createChannel(params); 173 | 174 | // An open channel is successfully created. 175 | // Channel data is return from a successful call to createChannel 176 | ... 177 | } catch (err) { 178 | // Handle error. 179 | } 180 | ``` 181 | 182 | ### Step 7: Enter the channel 183 | 184 | Enter the channel to send and receive messages. 185 | 186 | ```javascript 187 | await channel.enter(); 188 | // The current user successfully enters the open channel 189 | // and can chat with other users in the channel. 190 | ... 191 | ``` 192 | 193 | ### Step 8: Send a message to the channel 194 | 195 | Finally, send a message to the channel. There are [three types](https://sendbird.com/docs/chat/v4/platform-api/guides/messages#-3-resource-representation): a user message, which is a plain text, a file message, which is a binary file, such as an image or PDF, and an admin message, which is a plain text sent through the [dashboard](https://dashboard.sendbird.com/auth/signin) or [Chat Platform API](https://sendbird.com/docs/chat/v4/platform-api/guides/messages#2-send-a-message). 196 | 197 | ```javascript 198 | const params = new UserMessageParams(); 199 | params.message = TEXT_MESSAGE; 200 | 201 | channel.sendUserMessage(params) 202 | .onFailed((err: Error, message: UserMessage) => { 203 | // Handle error. 204 | }) 205 | .onSucceeded((message: UserMessage) => { 206 | // The message is successfully sent to the channel. 207 | // The current user can receive messages from other users through the onMessageReceived() method of the channel event handler. 208 | ... 209 | }); 210 | ``` 211 | 212 |
213 | 214 | ## Additional information 215 | 216 | Sendbird wants customers to be confident that Chat SDK will be useful, work well, and fit within their needs. Thus, we have compiled a couple of optional guidelines. Take a few minutes to read and apply them at your convenience. 217 | 218 | ### XSS prevention 219 | 220 | XSS (Cross-site scripting) is a type of computer security vulnerability. XSS helps attackers inject client-side scripts into web pages viewed by other users. Users can send any type of string data without restriction through Chat SDKs. Make sure that you check the safety of received data from other users before rendering it into your DOM. 221 | 222 | > **Note**: For more about the XSS prevention, visit the [OWASP's XSS Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html) page. 223 | 224 | ### Use functions of Sendbird objects with Immutable-js 225 | 226 | If you are using the [Immutable-js](https://immutable-js.github.io/immutable-js/) in your web app, instead of the `Immutable.Map()`, call the `Immutable.fromJS()` which converts deeply nested objects to an `Immutable Map`. 227 | So you can call the functions of Sendbird objects because the `fromJS()` method returns internal objects. But if you use a `Map` function, you can't call any functions of a Sendbird object. 228 | 229 | ```javascript 230 | const userIds = ["John", "Harry"]; 231 | 232 | const channel = await sb.groupChannel.createChannelWithUserIds( 233 | userIds, 234 | false, 235 | NAME, 236 | COVER_URL, 237 | DATA 238 | ); 239 | 240 | const immutableObject = Immutable.fromJS(channel); 241 | ``` 242 | -------------------------------------------------------------------------------- /aiAgent.d.ts: -------------------------------------------------------------------------------- 1 | export { 2 | AIAgentInfo, 3 | AIAgentMessageTemplateListParams, 4 | AIAgentMessageTemplateListResult, 5 | AIAgentModule, 6 | Conversation, 7 | ConversationChannelInfo, 8 | ConversationHandoff, 9 | ConversationListOrder, 10 | ConversationListQuery, 11 | ConversationListQueryParams, 12 | ConversationResolution, 13 | ConversationStatus, 14 | ConversationType, 15 | MessageTemplate, 16 | MessengerSettingsParams, 17 | } from './lib/__definition.js'; 18 | -------------------------------------------------------------------------------- /aiAgent.js: -------------------------------------------------------------------------------- 1 | import{c as t,A as n,b6 as r,e as s,f as i,g as o,a as u,$ as l,_ as h,b as v,V as f,j as g,a2 as p,an as m,aM as _,t as y,u as k,aS as A,F as w}from"./lib/__bundle-bf8c7310.js";export{b7 as AIAgentInfo}from"./lib/__bundle-bf8c7310.js";import{C as T,a as q}from"./lib/__bundle-becd93d5.js";export{C as Conversation,e as ConversationChannelInfo,c as ConversationHandoff,d as ConversationResolution,a as ConversationStatus,b as ConversationType}from"./lib/__bundle-becd93d5.js";var I,S=function(e){function i(t){var i=t.aiAgentId,a=t.userId,o=t.language,u=t.country,c=t.context,l=t.forceCreateChannel,h=e.call(this)||this;return h.method=n.POST,h.path="".concat(r,"/ai_agents/").concat(encodeURIComponent(i),"/messenger_settings"),h.requireAuth=!1,h.params=s({user_id:a,country:u,language:o,context:c,force_create:l}),h}return t(i,e),i}(i),x=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.settings=n,r}return t(n,e),n}(o),M=function(e){function i(t){var i=this,a=t.token,o=t.limit,u=t.aiAgentId,c=t.status,l=t.reverse,h=t.order;return(i=e.call(this)||this).method=n.GET,i.path="".concat(r,"/my_conversations"),i.params=s({token:a,limit:o,reverse:l,order:h,status:c,bot_userid:u}),i}return t(i,e),i}(i),Q=function(e){function n(t,n){var r=e.call(this,t,n)||this;r.conversations=[];var s=n.next_token,i=n.conversations;return r.token=s,i&&i.length>0&&(r.conversations=i.map((function(t){return new T(t)}))),r}return t(n,e),n}(o),P={limit:10},D=function(e){function i(t){var i=this,a=t.limit,o=void 0===a?P.limit:a,u=t.keys,c=t.token;return(i=e.call(this)||this).method=n.GET,i.path="".concat(r,"/sdk_message_templates"),i.params=s({limit:o,keys:u,token:c}),i}return t(i,e),i}(i),E=function(e){function n(t,n){var r=e.call(this,t,n)||this,s=n.templates,i=n.template_list_token;return r.token=i,r.templates=s.map((function(t){return{template:JSON.stringify(t)}})),r}return t(n,e),n}(o),j=function(e){function s(t){var s=this,i=t.key;return(s=e.call(this)||this).method=n.GET,s.path="".concat(r,"/sdk_message_templates/").concat(i),s}return t(s,e),s}(i),L=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.template=JSON.stringify(n),r}return t(n,e),n}(o),N={},R=function(){function t(t,e){var n=e.sdkState,r=e.requestQueue,s=e.logger;this._iid=t,this._sdkState=n,this._requestQueue=r,this._logger=s,N[t]=this}return t.of=function(t){return N[t]},t.prototype.requestMessengerSettings=function(t){return h(this,void 0,void 0,(function(){var e,n,r;return v(this,(function(s){switch(s.label){case 0:return e=f.of(this._iid).requestQueue,n=new S(t),[4,e.commandRouter.send(n)];case 1:return r=s.sent(),[2,r.as(x).settings]}}))}))},t.prototype.getConversations=function(t,e,n){return h(this,void 0,void 0,(function(){var r,s,i,a,o,u;return v(this,(function(c){switch(c.label){case 0:return r=f.of(this._iid).requestQueue,s=new M(g(g({},e),{token:t,limit:n})),[4,r.send(s)];case 1:return i=c.sent(),a=i.as(Q),o=a.conversations,u=a.token,[2,{conversations:o,token:u}]}}))}))},t.prototype.getMessageTemplates=function(t){return void 0===t&&(t={}),h(this,void 0,void 0,(function(){var e,n,r,s,i,a,o;return v(this,(function(u){switch(u.label){case 0:return e=t.keys,n=t.limit,r=new D({keys:e,limit:n}),[4,this._requestQueue.send(r)];case 1:return s=u.sent(),i=s.as(E),a=i.templates,o=i.token,[2,{templates:a,token:o}]}}))}))},t.prototype.getMessageTemplate=function(t){return h(this,void 0,void 0,(function(){var e,n;return v(this,(function(r){switch(r.label){case 0:return e=new j({key:t}),[4,this._requestQueue.send(e)];case 1:return n=r.sent(),[2,{template:n.as(L).template}]}}))}))},t}();!function(t){t.CREATED_AT="created_at",t.UPDATED_AT="updated_at"}(I||(I={}));var G={status:void 0,aiAgentId:void 0,reverse:!1,order:I.UPDATED_AT},O=function(e){function n(t,n){var r,s,i,a,o=this;return(o=e.call(this,t,n)||this).status=null!==(r=n.status)&&void 0!==r?r:void 0,o.aiAgentId=null!==(s=n.aiAgentId)&&void 0!==s?s:void 0,o.reverse=null!==(i=n.reverse)&&void 0!==i?i:G.reverse,o.order=null!==(a=n.order)&&void 0!==a?a:G.order,o}return t(n,e),n.prototype._validate=function(){return e.prototype._validate.call(this)&&p(q,this.status,!0)&&u("string",this.aiAgentId,!0)&&u("boolean",this.reverse)&&p(I,this.order)},n.prototype.serialize=function(){return m(this)},n.prototype.next=function(){return h(this,void 0,void 0,(function(){var t,e,n,r;return v(this,(function(s){switch(s.label){case 0:return t=R.of(this._iid),this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,t.getConversations(this._token,k(g({},this)),this.limit)]):[3,2]:[3,5];case 1:return e=s.sent(),n=e.conversations,r=e.token,this._token=r,this._hasNext=!!r,this._isLoading=!1,[2,n];case 2:return[2,[]];case 3:throw y.queryInProgress;case 4:return[3,6];case 5:throw y.invalidParameters;case 6:return[2]}}))}))},n}(_),U=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="aiAgent",t}return t(n,e),n.prototype.init=function(t,n){var r=n.sdkState,s=n.dispatcher,i=n.sessionManager,a=n.requestQueue,o=n.logger,u=n.onlineDetector,c=n.cacheContext;e.prototype.init.call(this,t,{sdkState:r,dispatcher:s,sessionManager:i,requestQueue:a,logger:o,onlineDetector:u,cacheContext:c}),this._manager=new R(t,{sdkState:r,requestQueue:a,logger:o})},n.prototype.requestMessengerSettings=function(t){return h(this,void 0,void 0,(function(){var e,n,r,s,i,a;return v(this,(function(o){return e=t.aiAgentId,n=t.userId,r=t.language,s=t.country,i=t.context,a=t.forceCreateChannel,w(u("string",e)&&u("string",n,!0)&&u("string",r,!0)&&u("string",s,!0)&&u("object",i,!0)&&u("boolean",a,!0)).throw(y.invalidParameters),[2,this._manager.requestMessengerSettings(t)]}))}))},n.prototype.createConversationListQuery=function(t){return void 0===t&&(t={}),new O(this._iid,t)},n.prototype.getMessageTemplates=function(t){return void 0===t&&(t={}),h(this,void 0,void 0,(function(){var e;return v(this,(function(n){return e=g(g({},P),t),w(function(t){return u("number",t.limit,!0)&&l("string",t.keys,!0)}(e)).throw(y.invalidParameters),[2,this._manager.getMessageTemplates(t)]}))}))},n.prototype.getMessageTemplate=function(t){return h(this,void 0,void 0,(function(){return v(this,(function(e){return w(u("string",t)).throw(y.invalidParameters),[2,this._manager.getMessageTemplate(t)]}))}))},n}(A);export{U as AIAgentModule,I as ConversationListOrder,O as ConversationListQuery}; 2 | -------------------------------------------------------------------------------- /catalog-info.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: backstage.io/v1alpha1 2 | kind: Component 3 | metadata: 4 | name: sendbird-chat-sdk-javascript 5 | description: Sendbird Chat SDK for JavaScript 6 | annotations: 7 | github.com/project-slug: sendbird/sendbird-chat-sdk-javascript 8 | spec: 9 | type: library 10 | lifecycle: production 11 | owner: dep-client-platform 12 | system: sendbird-chat 13 | -------------------------------------------------------------------------------- /cjs/aiAgent.cjs: -------------------------------------------------------------------------------- 1 | Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-a6c826ee.cjs"),t=require("./lib/__bundle-a7cea5ad.cjs");class s extends e.APIRequestCommand{constructor({aiAgentId:t,userId:s,language:n,country:r,context:i,forceCreateChannel:o}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_AI_AGENT}/ai_agents/${encodeURIComponent(t)}/messenger_settings`,this.requireAuth=!1,this.params=e.deundefined({user_id:s,country:r,language:n,context:i,force_create:o})}}class n extends e.APIResponseCommand{constructor(e,t){super(e,t),this.settings=t}}class r extends e.APIRequestCommand{constructor(t){const{token:s,limit:n,aiAgentId:r,status:i,reverse:o,order:a}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_AI_AGENT}/my_conversations`,this.params=e.deundefined({token:s,limit:n,reverse:o,order:a,status:i,bot_userid:r})}}class i extends e.APIResponseCommand{constructor(e,s){super(e,s),this.conversations=[];const{next_token:n,conversations:r}=s;this.token=n,r&&r.length>0&&(this.conversations=r.map((e=>new t.Conversation(e))))}}const o={limit:10};class a extends e.APIRequestCommand{constructor(t){const{limit:s=o.limit,keys:n,token:r}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_AI_AGENT}/sdk_message_templates`,this.params=e.deundefined({limit:s,keys:n,token:r})}}class u extends e.APIResponseCommand{constructor(e,t){super(e,t);const{templates:s,template_list_token:n}=t;this.token=n,this.templates=s.map((e=>({template:JSON.stringify(e)})))}}class d extends e.APIRequestCommand{constructor(t){const{key:s}=t;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_AI_AGENT}/sdk_message_templates/${s}`}}class c extends e.APIResponseCommand{constructor(e,t){super(e,t),this.template=JSON.stringify(t)}}const l={};class h{constructor(e,{sdkState:t,requestQueue:s,logger:n}){this._iid=e,this._sdkState=t,this._requestQueue=s,this._logger=n,l[e]=this}static of(e){return l[e]}requestMessengerSettings(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:r}=e.Vault.of(this._iid),i=new s(t),o=yield r.commandRouter.send(i),{settings:a}=o.as(n);return a}))}getConversations(t,s,n){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:o}=e.Vault.of(this._iid),a=new r(Object.assign(Object.assign({},s),{token:t,limit:n})),u=yield o.send(a),{conversations:d,token:c}=u.as(i);return{conversations:d,token:c}}))}getMessageTemplates(t={}){return e.__awaiter(this,void 0,void 0,(function*(){const{keys:e,limit:s}=t,n=new a({keys:e,limit:s}),r=yield this._requestQueue.send(n),{templates:i,token:o}=r.as(u);return{templates:i,token:o}}))}getMessageTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=new d({key:t}),s=yield this._requestQueue.send(e),{template:n}=s.as(c);return{template:n}}))}}var g;exports.ConversationListOrder=void 0,(g=exports.ConversationListOrder||(exports.ConversationListOrder={})).CREATED_AT="created_at",g.UPDATED_AT="updated_at";const p={status:void 0,aiAgentId:void 0,reverse:!1,order:exports.ConversationListOrder.UPDATED_AT};class _ extends e.BaseListQuery{constructor(e,t){var s,n,r,i;super(e,t),this.status=null!==(s=t.status)&&void 0!==s?s:void 0,this.aiAgentId=null!==(n=t.aiAgentId)&&void 0!==n?n:void 0,this.reverse=null!==(r=t.reverse)&&void 0!==r?r:p.reverse,this.order=null!==(i=t.order)&&void 0!==i?i:p.order}_validate(){return super._validate()&&e.isEnumOf(t.ConversationStatus,this.status,!0)&&e.isTypeOf("string",this.aiAgentId,!0)&&e.isTypeOf("boolean",this.reverse)&&e.isEnumOf(exports.ConversationListOrder,this.order)}serialize(){return e.serialize(this)}next(){return e.__awaiter(this,void 0,void 0,(function*(){const t=h.of(this._iid);if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{conversations:s,token:n}=yield t.getConversations(this._token,e.undefineNullProps(Object.assign({},this)),this.limit);return this._token=n,this._hasNext=!!n,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class m extends e.Module{constructor(){super(...arguments),this.name="aiAgent"}init(e,{sdkState:t,dispatcher:s,sessionManager:n,requestQueue:r,logger:i,onlineDetector:o,cacheContext:a}){super.init(e,{sdkState:t,dispatcher:s,sessionManager:n,requestQueue:r,logger:i,onlineDetector:o,cacheContext:a}),this._manager=new h(e,{sdkState:t,requestQueue:r,logger:i})}requestMessengerSettings(t){return e.__awaiter(this,void 0,void 0,(function*(){const{aiAgentId:s,userId:n,language:r,country:i,context:o,forceCreateChannel:a}=t;return e.unless(e.isTypeOf("string",s)&&e.isTypeOf("string",n,!0)&&e.isTypeOf("string",r,!0)&&e.isTypeOf("string",i,!0)&&e.isTypeOf("object",o,!0)&&e.isTypeOf("boolean",a,!0)).throw(e.SendbirdError.invalidParameters),this._manager.requestMessengerSettings(t)}))}createConversationListQuery(e={}){return new _(this._iid,e)}getMessageTemplates(t={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},o),t);return e.unless((t=>e.isTypeOf("number",t.limit,!0)&&e.isArrayOf("string",t.keys,!0))(s)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplates(t)}))}getMessageTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplate(t)}))}}exports.AIAgentInfo=e.AIAgentInfo,exports.Conversation=t.Conversation,exports.ConversationChannelInfo=t.ConversationChannelInfo,exports.ConversationHandoff=t.ConversationHandoff,exports.ConversationResolution=t.ConversationResolution,Object.defineProperty(exports,"ConversationStatus",{enumerable:!0,get:function(){return t.ConversationStatus}}),Object.defineProperty(exports,"ConversationType",{enumerable:!0,get:function(){return t.ConversationType}}),exports.AIAgentModule=m,exports.ConversationListQuery=_; 2 | -------------------------------------------------------------------------------- /cjs/aiAgent.d.cts: -------------------------------------------------------------------------------- 1 | export { 2 | AIAgentInfo, 3 | AIAgentMessageTemplateListParams, 4 | AIAgentMessageTemplateListResult, 5 | AIAgentModule, 6 | Conversation, 7 | ConversationChannelInfo, 8 | ConversationHandoff, 9 | ConversationListOrder, 10 | ConversationListQuery, 11 | ConversationListQueryParams, 12 | ConversationResolution, 13 | ConversationStatus, 14 | ConversationType, 15 | MessageTemplate, 16 | MessengerSettingsParams, 17 | } from './lib/__definition.cjs'; 18 | -------------------------------------------------------------------------------- /cjs/feedChannel.d.cts: -------------------------------------------------------------------------------- 1 | export { 2 | FeedChannel, 3 | FeedChannelChangelogs, 4 | FeedChannelChangeLogsParams, 5 | FeedChannelEventContext, 6 | FeedChannelHandler, 7 | FeedChannelListQuery, 8 | FeedChannelListQueryParams, 9 | FeedChannelModule, 10 | GlobalNotificationChannelSetting, 11 | NotificationCategory, 12 | NotificationCollection, 13 | NotificationCollectionEventHandler, 14 | NotificationCollectionParams, 15 | NotificationData, 16 | NotificationEventContext, 17 | NotificationMessage, 18 | NotificationMessageStatus, 19 | NotificationTemplate, 20 | NotificationTemplateList, 21 | NotificationTemplateListParams, 22 | SendbirdFeedChat, 23 | } from './lib/__definition.cjs'; 24 | -------------------------------------------------------------------------------- /cjs/groupChannel.d.cts: -------------------------------------------------------------------------------- 1 | export { 2 | CountPreference, 3 | DeliveryStatus, 4 | GroupChannel, 5 | GroupChannelChangelogs, 6 | GroupChannelChangeLogsParams, 7 | GroupChannelCollection, 8 | GroupChannelCollectionEventHandler, 9 | GroupChannelCollectionParams, 10 | GroupChannelCountParams, 11 | GroupChannelCreateParams, 12 | GroupChannelEventContext, 13 | GroupChannelEventSource, 14 | GroupChannelFilter, 15 | GroupChannelFilterParams, 16 | GroupChannelHandler, 17 | GroupChannelHideParams, 18 | GroupChannelListOrder, 19 | GroupChannelListQuery, 20 | GroupChannelListQueryParams, 21 | GroupChannelModule, 22 | GroupChannelSearchField, 23 | GroupChannelSearchFilter, 24 | GroupChannelUpdateParams, 25 | GroupChannelUserIdsFilter, 26 | HiddenChannelFilter, 27 | HiddenState, 28 | Member, 29 | MemberListOrder, 30 | MemberListQuery, 31 | MemberListQueryParams, 32 | MembershipFilter, 33 | MemberState, 34 | MemberStateFilter, 35 | MessageCollection, 36 | MessageCollectionEventHandler, 37 | MessageCollectionInitHandler, 38 | MessageCollectionInitPolicy, 39 | MessageCollectionInitResultHandler, 40 | MessageCollectionParams, 41 | MessageEventContext, 42 | MessageEventSource, 43 | MessageFilter, 44 | MessageFilterParams, 45 | MutedMemberFilter, 46 | MutedState, 47 | MyMemberStateFilter, 48 | OperatorFilter, 49 | PinnedMessage, 50 | PinnedMessageListQuery, 51 | PinnedMessageListQueryParams, 52 | PublicChannelFilter, 53 | PublicGroupChannelListOrder, 54 | PublicGroupChannelListQuery, 55 | PublicGroupChannelListQueryParams, 56 | QueryType, 57 | ReadStatus, 58 | ScheduledFileMessageCreateParams, 59 | ScheduledFileMessageUpdateParams, 60 | ScheduledMessageListOrder, 61 | ScheduledMessageListQuery, 62 | ScheduledMessageListQueryParams, 63 | ScheduledStatus, 64 | ScheduledUserMessageCreateParams, 65 | ScheduledUserMessageUpdateParams, 66 | SendbirdGroupChat, 67 | SuperChannelFilter, 68 | TotalScheduledMessageCountParams, 69 | TotalUnreadMessageCountParams, 70 | UnreadChannelFilter, 71 | UnreadItemCount, 72 | UnreadItemCountParams, 73 | UnreadItemKey, 74 | UnreadMessageCount, 75 | } from './lib/__definition.cjs'; 76 | -------------------------------------------------------------------------------- /cjs/index.d.cts: -------------------------------------------------------------------------------- 1 | import './message.d.cts'; 2 | import './groupChannel.d.cts'; 3 | import './openChannel.d.cts'; 4 | import './poll.d.cts'; 5 | import './feedChannel.d.cts'; 6 | import './aiAgent.d.cts'; 7 | import './node.d.cts'; 8 | 9 | export { 10 | AppInfo, 11 | ApplicationUserListQuery, 12 | ApplicationUserListQueryParams, 13 | BannedUserListQuery, 14 | BannedUserListQueryParams, 15 | BaseChannel, 16 | BlockedUserListQuery, 17 | BlockedUserListQueryParams, 18 | CachedChannelInfo, 19 | CachedDataClearOrder, 20 | ChannelType, 21 | CollectionEventSource, 22 | ConnectionHandler, 23 | ConnectionState, 24 | DeviceOsInfo, 25 | DeviceOsPlatform, 26 | DoNotDisturbPreference, 27 | Emoji, 28 | EmojiCategory, 29 | EmojiContainer, 30 | Encryption, 31 | FileCompat, 32 | FileUploadParams, 33 | FileUploadResult, 34 | FriendChangelogs, 35 | FriendDiscovery, 36 | FriendListQuery, 37 | FriendListQueryParams, 38 | InvitationPreference, 39 | LastMessageThreadingPolicy, 40 | LocalCacheConfig, 41 | LocalCacheConfigParams, 42 | LogLevel, 43 | MemoryStore, 44 | MemoryStoreParams, 45 | MetaCounter, 46 | MetaData, 47 | MutedInfo, 48 | MutedUserListQuery, 49 | MutedUserListQueryParams, 50 | NotificationInfo, 51 | OnlineDetectorListener, 52 | OperatorListQuery, 53 | OperatorListQueryParams, 54 | Participant, 55 | Plugin, 56 | PushTemplate, 57 | PushTokenRegistrationState, 58 | PushTokens, 59 | PushTokenType, 60 | PushTriggerOption, 61 | ReportCategory, 62 | ReportCategoryInfo, 63 | RestrictedUser, 64 | RestrictionInfo, 65 | RestrictionType, 66 | Role, 67 | SendbirdChatOptions, 68 | SendbirdChatParams, 69 | SendbirdChatWith, 70 | SendbirdError, 71 | SendbirdErrorCode, 72 | SendbirdPlatform, 73 | SendbirdProduct, 74 | SendbirdSdkInfo, 75 | SessionHandler, 76 | SnoozePeriod, 77 | StoreItem, 78 | UIKitConfigInfo, 79 | UnreadCountThreadingPolicy, 80 | UploadProgressHandler, 81 | UploadStartedHandler, 82 | User, 83 | UserEventHandler, 84 | UserOnlineState, 85 | UserUpdateParams, 86 | } from './lib/__definition.cjs'; 87 | 88 | import { SendbirdChat } from './lib/__definition.cjs'; 89 | export default SendbirdChat; 90 | -------------------------------------------------------------------------------- /cjs/lib/__bundle-093a1164.cjs: -------------------------------------------------------------------------------- 1 | require("./__bundle-a7decc5d.cjs"); 2 | -------------------------------------------------------------------------------- /cjs/lib/__bundle-1df85995.cjs: -------------------------------------------------------------------------------- 1 | var e=require("./__bundle-a6c826ee.cjs");exports.xmlHttpRequest=(r,s)=>new Promise(((t,o)=>{if("undefined"!=typeof XMLHttpRequest){const{dispatcher:n,logger:d}=e.Vault.of(r),{requestId:a,method:i,url:u,headers:p={},data:c="",uploadProgressHandler:l}=s;let m=!1;const E=new XMLHttpRequest;E.open(i,u),Object.keys(p).forEach((e=>{E.setRequestHeader(e,p[e])})),l&&E.upload.addEventListener("progress",(e=>{e.lengthComputable?l(a,e.loaded,e.total):d.debug("Progress computing failed: `Content-Length` header is not given.")})),E.onabort=()=>{o(e.SendbirdError.requestCanceled)},E.onerror=r=>{o(e.SendbirdError.networkError)},E.onreadystatechange=()=>{if(E.readyState===XMLHttpRequest.DONE&&!m)if(0===E.status||E.status>=200&&E.status<400)try{const s=JSON.parse(E.responseText);t(new e.APIResponseCommand(r,s))}catch(r){o(e.SendbirdError.networkError)}else try{const r=JSON.parse(E.responseText);if(r){const s=new e.SendbirdError(r);if(s.isSessionExpiredError){if(n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message})),!(E instanceof e.SessionRefreshAPICommand)){const r=new e.Deferred;return n.dispatch(new e.RequestResendCommand({request:E,deferred:r,error:s})),r.promise}}else s.isSessionInvalidatedError&&n.dispatch(new e.SessionExpiredCommand({reason:s.code,message:s.message}));o(s)}else o(e.SendbirdError.requestFailed)}catch(r){o(e.SendbirdError.requestFailed)}},n.on((r=>{r instanceof e.CancelXMLHttpRequestCommand&&(r.requestId&&r.requestId!==a||(m=!0,E.abort()))})),E.send(c)}else o(e.SendbirdError.xmlHttpRequestNotSupported)})); 2 | -------------------------------------------------------------------------------- /cjs/lib/__bundle-2ce6b383.cjs: -------------------------------------------------------------------------------- 1 | var o=require("./__bundle-a6c826ee.cjs");exports.BaseChannelHandlerParams=class{constructor(){this.onUserMuted=o.noop,this.onUserUnmuted=o.noop,this.onUserBanned=o.noop,this.onUserUnbanned=o.noop,this.onChannelChanged=o.noop,this.onChannelDeleted=o.noop,this.onChannelFrozen=o.noop,this.onChannelUnfrozen=o.noop,this.onOperatorUpdated=o.noop,this.onChannelMemberCountChanged=o.noop,this.onMetaDataCreated=o.noop,this.onMetaDataUpdated=o.noop,this.onMetaDataDeleted=o.noop,this.onMetaCounterCreated=o.noop,this.onMetaCounterUpdated=o.noop,this.onMetaCounterDeleted=o.noop,this.onMessageReceived=o.noop,this.onMessageUpdated=o.noop,this.onMessageDeleted=o.noop,this.onMentionReceived=o.noop,this.onReactionUpdated=o.noop,this.onThreadInfoUpdated=o.noop}}; 2 | -------------------------------------------------------------------------------- /cjs/lib/__bundle-38c66c0d.cjs: -------------------------------------------------------------------------------- 1 | var t="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{},e="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,o="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),n="FormData"in t,s="ArrayBuffer"in t;if(s)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(t){return t&&i.indexOf(Object.prototype.toString.call(t))>-1};function h(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function u(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function c(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function l(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function y(t){var e=new FileReader,r=l(e);return e.readAsArrayBuffer(t),r}function p(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){var r;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:n&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:e&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&o&&((r=t)&&DataView.prototype.isPrototypeOf(r))?(this._bodyArrayBuffer=p(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this._bodyArrayBuffer=p(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var t=c(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=c(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(o)return this.blob().then(y);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,o,n,s=c(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=l(e),o=/charset=([A-Za-z0-9_-]+)/.exec(t.type),n=o?o[1]:"utf-8",e.readAsText(t,n),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),o=0;o-1?n:o),this.mode=r.mode||this.mode||null,this.signal=r.signal||this.signal||function(){if("AbortController"in t)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==r.cache&&"no-cache"!==r.cache)){var i=/([?&])_=[^&]*/;if(i.test(this.url))this.url=this.url.replace(i,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function g(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}})),e}function v(t,e){if(!(this instanceof v))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},b.call(w.prototype),b.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var A=[301,302,303,307,308];v.redirect=function(t,e){if(-1===A.indexOf(e))throw new RangeError("Invalid status code");return new v(null,{status:e,headers:{location:t}})};var T=t.DOMException;try{new T}catch(t){(T=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack}).prototype=Object.create(Error.prototype),T.prototype.constructor=T}function _(e,r){return new Promise((function(n,i){var a=new w(e,r);if(a.signal&&a.signal.aborted)return i(new T("Aborted","AbortError"));var f=new XMLHttpRequest;function c(){f.abort()}if(f.onload=function(){var t,e,r={statusText:f.statusText,headers:(t=f.getAllResponseHeaders()||"",e=new d,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();try{e.append(o,n)}catch(t){console.warn("Response "+t.message)}}})),e)};0===a.url.indexOf("file://")&&(f.status<200||f.status>599)?r.status=200:r.status=f.status,r.url="responseURL"in f?f.responseURL:r.headers.get("X-Request-URL");var o="response"in f?f.response:f.responseText;setTimeout((function(){n(new v(o,r))}),0)},f.onerror=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},f.ontimeout=function(){setTimeout((function(){i(new TypeError("Network request timed out"))}),0)},f.onabort=function(){setTimeout((function(){i(new T("Aborted","AbortError"))}),0)},f.open(a.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?f.withCredentials=!0:"omit"===a.credentials&&(f.withCredentials=!1),"responseType"in f&&(o?f.responseType="blob":s&&(f.responseType="arraybuffer")),r&&"object"==typeof r.headers&&!(r.headers instanceof d||t.Headers&&r.headers instanceof t.Headers)){var l=[];Object.getOwnPropertyNames(r.headers).forEach((function(t){l.push(h(t)),f.setRequestHeader(t,u(r.headers[t]))})),a.headers.forEach((function(t,e){-1===l.indexOf(e)&&f.setRequestHeader(e,t)}))}else a.headers.forEach((function(t,e){f.setRequestHeader(e,t)}));a.signal&&(a.signal.addEventListener("abort",c),f.onreadystatechange=function(){4===f.readyState&&a.signal.removeEventListener("abort",c)}),f.send(void 0===a._bodyInit?null:a._bodyInit)}))}_.polyfill=!0,t.fetch||(t.fetch=_,t.Headers=d,t.Request=w,t.Response=v);const E="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null};E.fetch||(E.fetch=_); 2 | -------------------------------------------------------------------------------- /cjs/lib/__bundle-431295de.cjs: -------------------------------------------------------------------------------- 1 | var e=require("./__bundle-a6c826ee.cjs"),s=require("./__bundle-e762fd36.cjs"),t=require("./__bundle-b4546809.cjs");class n extends e.APIRequestCommand{constructor({channelType:s,channelUrl:t,limit:n,token:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(s)}/${encodeURIComponent(t)}/messages/parent_thread_message`,this.params=e.deundefined(e.undefineNullProps({limit:n,token:i}))}}class i extends e.APIResponseCommand{constructor(e,s){super(e,s),this.token=s.next,this.messages=s.messages.map((s=>t.parseMessagePayload(e,s)))}}class a extends s.ChannelDataListQuery{constructor(e,s,t,n){super(e,s,t,n),this._edge=""}_validate(){return super._validate()}load(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:s}=e.Vault.of(this._iid),t=new n({channelType:this.channelType,channelUrl:this.channelUrl,token:this._edge,limit:this.limit}),a=yield s.send(t),{messages:r,token:d}=a.as(i);return this._edge=d,this._hasNext=!!d,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}exports.ThreadedParentMessageListQuery=a; 2 | -------------------------------------------------------------------------------- /cjs/lib/__bundle-81e2a005.cjs: -------------------------------------------------------------------------------- 1 | var e,t,s,n=require("./__bundle-a6c826ee.cjs"),r=require("./__bundle-b4546809.cjs"),i=require("./__bundle-e762fd36.cjs");exports.GroupChannelListOrder=void 0,(e=exports.GroupChannelListOrder||(exports.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.PublicGroupChannelListOrder=void 0,(t=exports.PublicGroupChannelListOrder||(exports.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",t.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",t.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.ScheduledMessageListOrder=void 0,(s=exports.ScheduledMessageListOrder||(exports.ScheduledMessageListOrder={})).CREATED_AT="created_at",s.SCHEDULED_AT="scheduled_at";class o extends n.BaseCommand{constructor({message:e}){super(),this.message=e}}const a={};var d,c;exports.UserEventCategory=void 0,(d=exports.UserEventCategory||(exports.UserEventCategory={}))[d.USER_BLOCK=20001]="USER_BLOCK",d[d.USER_UNBLOCK=2e4]="USER_UNBLOCK",d[d.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED";class u{constructor(e){this.category=e.cat,this.data=e.data}static getDataAsUserBlockEvent(e,t){const{blocker:s,blockee:r}=t.data;return{blocker:new n.User(e,s),blockee:new n.User(e,r)}}static getDataAsFriendDiscoveredEvent(e,t){const{friend_discoveries:s}=t.data;return{friendDiscoveries:Array.isArray(s)?s.map((t=>new n.User(e,t))):[]}}}class h extends n.BaseCommand{constructor(e,{userId:t}){super(),this._iid=e,this.userId=t}}class _ extends n.BaseCommand{constructor(){super()}}class l extends n.BaseCommand{constructor({configTs:e}){super(),this.configTs=e}}class g extends n.WebSocketEventCommand{constructor(e,t,s){super(e,"USEV",s),this.event=new u(s)}}class p extends n.BaseCommand{constructor({appConfigsInfo:e,configTs:t}){super(),this.appConfigsInfo={},this.configTs=0,this.appConfigsInfo=e,this.configTs=t}}!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(c||(c={}));class A extends n.EventDispatcher{constructor(e,t,s=2,n=10){super(),this._state=c.IDLE,this._retryCount=0,this._retryLimit=3,this.priority=0,this._worker=t}get isIdle(){return this._state===c.IDLE}get isRunning(){return this._state===c.RUNNING}get isDone(){return this._state===c.END}get retryCount(){return this._retryCount}get retryLimit(){return this._retryLimit}_run(e){return n.__awaiter(this,void 0,void 0,(function*(){if(this.isRunning)try{const t=yield this._worker(e);this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end()}catch(t){this.dispatch("error",t),this._retryCount{if(e instanceof n.ConnectionStateChangeCommand)switch(e.stateType){case n.ConnectionStateType.CONNECTED:this._isProcessingAutoResend||this.processAutoResendRegisteredPendingMessages().then((()=>this._processNextAutoResend()));break;case n.ConnectionStateType.INTERNAL_DISCONNECTED:case n.ConnectionStateType.EXTERNAL_DISCONNECTED:this._isProcessingAutoResend=!1}}))}static of(e){return a[e]}processNonAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){this._enableAutoResend&&(yield n.runOrNothing((()=>n.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const t of e)0===t.errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",t.reqId),t.sendingStatus=n.SendingStatus.FAILED,t.errorCode=n.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new i.MessageUpdateEventCommand({messages:[t],source:i.CollectionEventSource.LOCAL_MESSAGE_FAILED})))})))))}))}processAutoResendRegisteredPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){yield n.runOrNothing((()=>n.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const t of e)if(this._enableAutoResend&&t.errorCode&&n.isAutoResendableError(t.errorCode)){const e=(new Date).getTime(),s=t.createdAt+2592e5;this._enableAutoResend&&e<=s?this._autoResendQueue.map((e=>e.reqId)).indexOf(t.reqId)<0&&this._autoResendQueue.push(t):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(s).toLocaleString()),t.sendingStatus=n.SendingStatus.FAILED,this._dispatcher.dispatch(new i.MessageUpdateEventCommand({messages:[t],source:i.CollectionEventSource.LOCAL_MESSAGE_FAILED})))}}))))}))}completeCurrentAndProcessNextAutoResend(e){if(this._localCacheEnabled&&this._enableAutoResend&&(e.sendingStatus===n.SendingStatus.SUCCEEDED||e.sendingStatus===n.SendingStatus.FAILED&&!n.isAutoResendableError(e.errorCode))){const t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}}_fetchAllCachedPendingMessages(){return n.__awaiter(this,void 0,void 0,(function*(){const e=r.UnsentMessageCache.of(this._iid),t=new r.MessageFilter;return t.replyType=n.ReplyType.ALL,yield e.fetch({sendingStatus:n.SendingStatus.PENDING,backward:!0,filter:t})}))}indexOf(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((e=>e.reqId)).indexOf(e.reqId):-1}_processNextAutoResend(){return n.__awaiter(this,void 0,void 0,(function*(){if(this._localCacheEnabled&&this._enableAutoResend&&"foreground"===this._sdkState.appState)try{if(this._autoResendQueue.length>0){this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0);const e=this._autoResendQueue[0];this._dispatcher.dispatch(new o({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)}else this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}}))}},exports.AutoResendRequestCommand=o,exports.DatabaseOpenCommand=h,exports.ReduceDBSizeEventCommand=_,exports.SaveAppConfigsInfoEventCommand=l,exports.Sync=A,exports.UserEvent=u,exports.UserEventCommand=g,exports.getGroupChannelIndexBy=e=>{switch(e){case exports.GroupChannelListOrder.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case exports.GroupChannelListOrder.CHRONOLOGICAL:return["-createdAt","syncIndex"];case exports.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}}; 2 | -------------------------------------------------------------------------------- /cjs/lib/__bundle-a7cea5ad.cjs: -------------------------------------------------------------------------------- 1 | var t,s,e=require("./__bundle-a6c826ee.cjs");class o{constructor(t){this.url=t.channel_url,this.lastMessageTs=t.last_message_ts}static payloadify(t){return{channel_url:t.url,last_message_ts:t.lastMessageTs}}}class i{constructor(t){var s,e;this.type=t.type,this.ticketId=null!==(s=t.ticket_id)&&void 0!==s?s:void 0,this.timestamp=null!==(e=t.timestamp)&&void 0!==e?e:void 0}static payloadify(t){return e.deundefined({type:t.type,ticket_id:t.ticketId,timestamp:t.timestamp})}}class a{constructor(t){this.isResolved=t.is_resolved,this.determinedBy=t.determined_by}static payloadify(t){return{is_resolved:t.isResolved,determined_by:t.determinedBy}}}exports.ConversationType=void 0,(t=exports.ConversationType||(exports.ConversationType={})).DEFAULT="default",t.PROACTIVE="proactive",exports.ConversationStatus=void 0,(s=exports.ConversationStatus||(exports.ConversationStatus={})).OPEN="open",s.CLOSED="closed";exports.Conversation=class{static payloadify(t){return e.deundefined(e.undefineNullProps({id:t.id,conversation_type:t.type,status:t.status,channel:o.payloadify(t.channelInfo),csat:t.csat,csat_reason:t.csatReason,csat_expire_at:t.csatExpireAt,resolution:t.resolution&&a.payloadify(t.resolution),topics:t.topics,handoff:t.handoff&&i.payloadify(t.handoff)}))}constructor(t){var s,e,n,r;this.id=t.id,this.type=t.conversation_type,this.status=t.status,this.channelInfo=new o(t.channel),this.csat=null!==(s=t.csat)&&void 0!==s?s:void 0,this.csatReason=null!==(e=t.csat_reason)&&void 0!==e?e:void 0,this.csatExpireAt=null!==(n=t.csat_expire_at)&&void 0!==n?n:void 0,this.resolution=t.resolution?new a(t.resolution):void 0,this.topics=null!==(r=t.topics)&&void 0!==r?r:[],this.handoff=t.handoff?new i(t.handoff):void 0}},exports.ConversationChannelInfo=o,exports.ConversationHandoff=i,exports.ConversationResolution=a; 2 | -------------------------------------------------------------------------------- /cjs/lib/__bundle-a7decc5d.cjs: -------------------------------------------------------------------------------- 1 | var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(){function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw i}}}}var d=function(){function e(){t(this,e),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return n(e,[{key:"addEventListener",value:function(e,t,r){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:r})}},{key:"removeEventListener",value:function(e,t){if(e in this.listeners)for(var r=this.listeners[e],n=0,o=r.length;n["-lastMessageUpdatedAt","-createdAt","syncIndex"]; 2 | -------------------------------------------------------------------------------- /cjs/lib/__bundle-dae7bdf2.cjs: -------------------------------------------------------------------------------- 1 | exports.PollUpdateEvent=class{constructor(s,l){this.pollId=0,this.messageId=0,this.pollId=l.poll.id,this.messageId=l.poll.message_id,this._iid=s,this._payload=l}}; 2 | -------------------------------------------------------------------------------- /cjs/lib/__bundle-e762fd36.cjs: -------------------------------------------------------------------------------- 1 | var e,t=require("./__bundle-a6c826ee.cjs");exports.CollectionEventSource=void 0,(e=exports.CollectionEventSource||(exports.CollectionEventSource={})).UNKNOWN="UNKNOWN",e.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",e.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",e.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",e.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",e.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",e.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",e.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",e.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",e.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",e.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",e.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",e.EVENT_CHANNEL_BANNED="EVENT_CHANNEL_BANNED",e.EVENT_CHANNEL_UNBANNED="EVENT_CHANNEL_UNBANNED",e.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",e.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",e.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",e.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",e.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",e.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",e.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",e.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",e.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",e.EVENT_CHANNEL_METADATA_CREATED="EVENT_CHANNEL_METADATA_CREATED",e.EVENT_CHANNEL_METADATA_UPDATED="EVENT_CHANNEL_METADATA_UPDATED",e.EVENT_CHANNEL_METADATA_DELETED="EVENT_CHANNEL_METADATA_DELETED",e.EVENT_CHANNEL_METACOUNTER_CREATED="EVENT_CHANNEL_METACOUNTER_CREATED",e.EVENT_CHANNEL_METACOUNTER_UPDATED="EVENT_CHANNEL_METACOUNTER_UPDATED",e.EVENT_CHANNEL_METACOUNTER_DELETED="EVENT_CHANNEL_METACOUNTER_DELETED",e.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",e.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",e.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",e.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",e.REQUEST_CHANNEL="REQUEST_CHANNEL",e.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",e.REFRESH_CHANNEL="REFRESH_CHANNEL",e.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",e.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",e.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS",e.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",e.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",e.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",e.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",e.EVENT_MESSAGE_FEEDBACK_ADDED="EVENT_MESSAGE_FEEDBACK_ADDED",e.EVENT_MESSAGE_FEEDBACK_UPDATED="EVENT_MESSAGE_FEEDBACK_UPDATED",e.EVENT_MESSAGE_FEEDBACK_DELETED="EVENT_MESSAGE_FEEDBACK_DELETED",e.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",e.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",e.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",e.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",e.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",e.REQUEST_MESSAGE="REQUEST_MESSAGE",e.EVENT_THREAD_INFO_UPDATED="EVENT_THREADINFO_UPDATED",e.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",e.EVENT_POLL_VOTED="EVENT_POLL_VOTED",e.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",e.EVENT_CHANNEL_CSAT_SUBMITTED="EVENT_CHANNEL_CSAT_SUBMITTED",e.EVENT_CHANNEL_CONVERSATION_HANDEDOFF="EVENT_CHANNEL_CONVERSATION_HANDEDOFF",e.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",e.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",e.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",e.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",e.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",e.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",e.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",e.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",e.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",e.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";const s=Object.assign({},exports.CollectionEventSource);class E extends t.BaseCommand{constructor({messages:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messages=e,this.source=t,this.isWebSocketEventComing=s}}class o extends t.BaseCommand{constructor({messageIds:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messageIds=e,this.source=t,this.isWebSocketEventComing=s}}class n extends t.BaseCommand{constructor({messageDeletionTimestamp:e,channelUrl:t,source:s}){super(),this.messageDeletionTimestamp=e,this.channelUrl=t,this.source=s}}class l extends t.BaseCommand{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}}class i extends t.BaseCommand{constructor({event:e,source:t,isWebSocketEventComing:s=!1}){super(),this.event=e,this.source=t,this.isWebSocketEventComing=s}}class a extends t.BaseCommand{constructor({reqId:e,source:t}){super(),this.reqId=e,this.source=t}}class _ extends t.BaseCommand{constructor({polls:e,source:t}){super(),this.polls=e,this.source=t}}class r extends t.BaseCommand{constructor({event:e,source:t}){super(),this.event=e,this.source=t}}class d extends t.BaseCommand{constructor({event:e,source:t}){super(),this.event=e,this.source=t}}var N;exports.PollStatus=void 0,(N=exports.PollStatus||(exports.PollStatus={})).OPEN="open",N.CLOSED="closed";const u=e=>{switch(e){case"open":return exports.PollStatus.OPEN;case"closed":return exports.PollStatus.CLOSED;default:return null}},A=e=>!e||!!e.text&&t.isTypeOf("string",e.text);class p extends t.InstancedObject{constructor(e,t){var s,E,o,n,l,i,a;super(e),this.pollId=0,this.id=0,this.text=null,this.voteCount=0,this.createdBy=null,this.createdAt=0,this.updatedAt=0,this._lastVotedAt=0,this.pollId=null!==(s=t.poll_id)&&void 0!==s?s:0,this.id=null!==(E=t.id)&&void 0!==E?E:0,this.text=null!==(o=t.text)&&void 0!==o?o:null,this.voteCount=null!==(n=t.vote_count)&&void 0!==n?n:0,this.createdBy=null!==(l=t.created_by)&&void 0!==l?l:null,this.createdAt=null!==(i=t.created_at)&&void 0!==i?i:0,this.updatedAt=null!==(a=t.updated_at)&&void 0!==a?a:0}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})))}}class T extends t.InstancedObject{constructor(e,t){var s,E,o,n,l,i,a,_,r,d,N,A,T;super(e),this.id=0,this.title=null,this.createdAt=0,this.updatedAt=0,this.closeAt=-1,this.status=exports.PollStatus.CLOSED,this.messageId=0,this.data=null,this.voterCount=-1,this.options=[],this.createdBy=null,this.allowUserSuggestion=!1,this.allowMultipleVotes=!1,this.votedPollOptionIds=[],this.id=null!==(s=t.id)&&void 0!==s?s:0,this.title=null!==(E=t.title)&&void 0!==E?E:null,this.createdAt=null!==(o=t.created_at)&&void 0!==o?o:0,this.updatedAt=null!==(n=t.updated_at)&&void 0!==n?n:0,this.closeAt=null!==(l=t.close_at)&&void 0!==l?l:-1,this.status=null!==(i=u(t.status))&&void 0!==i?i:exports.PollStatus.CLOSED,this.messageId=null!==(a=t.message_id)&&void 0!==a?a:0,this.data=null!==(_=t.data)&&void 0!==_?_:null,this.voterCount=null!==(r=t.voter_count)&&void 0!==r?r:-1,this.options=t.options?t.options.map((e=>new p(this._iid,e))):[],this.createdBy=null!==(d=t.created_by)&&void 0!==d?d:null,this.allowUserSuggestion=null!==(N=t.allow_user_suggestion)&&void 0!==N&&N,this.allowMultipleVotes=null!==(A=t.allow_multiple_votes)&&void 0!==A&&A,this.votedPollOptionIds=null!==(T=t.voted_option_ids)&&void 0!==T?T:[]}_applyPollUpdatePayload(e){var t,s,E,o,n,l,i,a;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(s=e.updated_at)&&void 0!==s?s:this.updatedAt,this.closeAt=null!==(E=e.close_at)&&void 0!==E?E:this.closeAt,this.status=null!==(o=u(e.status))&&void 0!==o?o:this.status,this.data=null!==(n=e.data)&&void 0!==n?n:this.data,this.voterCount=null!==(l=e.voter_count)&&void 0!==l?l:this.voterCount,e.options&&(this.options=e.options.map((e=>new p(this._iid,e))),this.votedPollOptionIds=e.options.filter((e=>e.vote_count>0)).map((e=>e.id))),this.allowUserSuggestion=null!==(i=e.allow_user_suggestion)&&void 0!==i?i:this.allowUserSuggestion,this.allowMultipleVotes=null!==(a=e.allow_multiple_votes)&&void 0!==a?a:this.allowMultipleVotes}static payloadify(e){return t.deundefined(t.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((e=>p.payloadify(e))),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}applyPollUpdateEvent(e){const t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_ate.id)),E=e._payload,o=Math.floor(E.ts/1e3);return E.updated_vote_counts.forEach((e=>{const E=s.indexOf(e.option_id);if(E>-1){const s=t[E];o>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=o)}})),E.req_id&&E.voted_option_ids&&(this.votedPollOptionIds=E.voted_option_ids),"number"==typeof E.voter_count&&(this.voterCount=E.voter_count),!0}serialize(){return t.serialize(this)}}class h extends t.BaseListQuery{constructor(e,t,s,E){super(e,E),this.channelUrl=t,this.channelType=s}_validate(){return super._validate()&&t.isTypeOf("string",this.channelUrl)&&t.isEnumOf(t.ChannelType,this.channelType)}}class c extends t.APIRequestCommand{constructor({title:e,optionTexts:s,data:E,allowUserSuggestion:o,allowMultipleVotes:n,closeAt:l}){super(),this.method=t.APIRequestMethod.POST,this.path=t.API_PATH_POLLS,this.params={title:e,options:s,data:E,allow_user_suggestion:o,allow_multiple_votes:n,close_at:l}}}class S extends t.APIResponseCommand{constructor(e,t){super(e,t),this.poll=new T(e,t)}}class C extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,pollId:E}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(E)}`,this.params={channel_url:e,channel_type:s}}}class D extends t.APIResponseCommand{constructor(e,t){super(e,t),this.poll=new T(e,t)}}class L extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,pollId:E,pollOptionId:o}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(E)}/options/${encodeURIComponent(o)}`,this.params={channel_url:e,channel_type:s}}}class v extends t.APIResponseCommand{constructor(e,t){super(e,t),this.pollOption=new p(e,t)}}class m extends t.APIRequestCommand{constructor({channelType:e,channelUrl:s,timestamp:E,token:o}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.getChannelApiPathByType(e)}/${encodeURIComponent(s)}/polls/changelogs`,this.params=t.deundefined({change_ts:E,token:o})}}class P extends t.APIResponseCommand{constructor(e,t){super(e,t),this.updatedPolls=t.updated.map((t=>((e,t)=>new T(e,t))(e,t))),this.deletedPollIds=t.deleted.map((e=>e)),this.hasMore=t.has_more,this.nextToken=t.next}}const O={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},I=e=>{return t.isTypeOf("string",e.title)&&(s=e.optionTexts,t.isArrayOf("string",s)&&s.every((e=>""!==e.trim())))&&A(e.data)&&t.isTypeOf("boolean",e.allowUserSuggestion,!0)&&t.isTypeOf("boolean",e.allowMultipleVotes,!0)&&t.isTypeOf("number",e.closeAt,!0);var s},V={channelUrl:"",channelType:t.ChannelType.BASE,pollId:0,pollOptionId:0},U=e=>t.isTypeOf("string",e.channelUrl)&&""!==e.channelUrl&&t.isEnumOf(t.ChannelType,e.channelType)&&t.isTypeOf("number",e.pollId)&&e.pollId>0&&t.isTypeOf("number",e.pollOptionId)&&e.pollOptionId>0,R={channelUrl:"",channelType:t.ChannelType.BASE,pollId:0},H=e=>t.isTypeOf("string",e.channelUrl)&&""!==e.channelUrl&&t.isEnumOf(t.ChannelType,e.channelType)&&t.isTypeOf("number",e.pollId),M={};class G extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,token:E,limit:o}){super(),this.method=t.APIRequestMethod.GET,this.path=t.API_PATH_POLLS,this.params={channel_url:e,channel_type:s,token:E,limit:o}}}class g extends t.APIResponseCommand{constructor(e,t){var s;super(e,t),this.polls=(null!==(s=t.polls)&&void 0!==s?s:[]).map((t=>new T(e,t))),this.token=t.next}}class x extends t.APIRequestCommand{constructor({channelUrl:e,channelType:s,pollId:E,pollOptionId:o,token:n,limit:l}){super(),this.method=t.APIRequestMethod.GET,this.path=`${t.API_PATH_POLLS}/${encodeURIComponent(E)}/options/${encodeURIComponent(o)}/voters`,this.params={channel_url:e,channel_type:s,token:n,limit:l}}}class y extends t.APIResponseCommand{constructor(e,s){var E;super(e,s),this.voters=(null!==(E=s.voters)&&void 0!==E?E:[]).map((s=>new t.User(e,s))),this.token=s.next}}exports.ChannelDataListQuery=h,exports.MessageEventSource=s,exports.MessageRemoveEventCommand=o,exports.MessageRetentionEventCommand=n,exports.MessageUpdateEventCommand=E,exports.POLL_REMOVED_STATUS="removed",exports.Poll=T,exports.PollChangeLogEventCommand=_,exports.PollCreateParamsDefault=O,exports.PollListQuery=class extends h{constructor(e,t){super(e,t.channelUrl,t.channelType,t)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new G(Object.assign(Object.assign({},this),{token:this._token})),E=yield e.send(s),{polls:o,token:n}=E.as(g);return this._token=n,this._hasNext=!!n,this._isLoading=!1,o}return[]}throw t.SendbirdError.invalidParameters}))}},exports.PollManager=class{constructor(e,{sdkState:t,dispatcher:s,sessionManager:E,requestQueue:o,logger:n}){this._iid=e,this._sdkState=t,this._sessionManager=E,this._requestQueue=o,this._dispatcher=s,this._logger=n,M[e]=this}static of(e){return M[e]}buildPollFromSerializedData(e){const s=t.deserialize(e);return new T(this._iid,T.payloadify(s))}get(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(H(e)).throw(t.SendbirdError.invalidParameters);const s=new C(Object.assign({},e)),E=yield this._requestQueue.send(s),{poll:o}=E.as(D);return o}))}create(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(I(e)).throw(t.SendbirdError.invalidParameters);const s=new c(Object.assign({},e)),E=yield this._requestQueue.send(s),{poll:o}=E.as(S);return o}))}getOption(e){return t.__awaiter(this,void 0,void 0,(function*(){t.unless(U(e)).throw(t.SendbirdError.invalidParameters);const s=new L(Object.assign({},e)),E=yield this._requestQueue.send(s),{pollOption:o}=E.as(v);return o}))}getPollChangeLogs(e,s,E,o=exports.CollectionEventSource.SYNC_POLL_CHANGELOGS){return t.__awaiter(this,void 0,void 0,(function*(){const n=new m(t.undefineNullProps({channelType:s,channelUrl:e,timestamp:"number"==typeof E?E:null,token:"string"==typeof E?E:null})),l=yield this._requestQueue.send(n),{updatedPolls:i,deletedPollIds:a,hasMore:r,nextToken:d}=l.as(P);return i.length>0&&this._dispatcher.dispatch(new _({polls:i,source:o})),{updatedPolls:i,deletedPollIds:a,hasMore:r,token:d}}))}},exports.PollOption=p,exports.PollOptionRetrievalParamsDefault=V,exports.PollRetrievalParamsDefault=R,exports.PollUpdateInternalEventCommand=r,exports.PollVoteEvent=class{constructor(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e}},exports.PollVoteInternalEventCommand=d,exports.PollVoterListQuery=class extends h{constructor(e,t){super(e,t.channelUrl,t.channelType,t),this.pollId=t.pollId,this.pollOptionId=t.pollOptionId}_validate(){return super._validate()&&t.isTypeOf("number",this.pollId)&&t.isTypeOf("number",this.pollOptionId)}next(){return t.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw t.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=t.Vault.of(this._iid),s=new x(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),E=yield e.send(s),{voters:o,token:n}=E.as(y);return this._token=n,this._hasNext=!!n,this._isLoading=!1,o}return[]}throw t.SendbirdError.invalidParameters}))}},exports.ReactionUpdateEventCommand=l,exports.ThreadUpdateEventCommand=i,exports.UnsentMessageRemoveEventCommand=a,exports.parsePollStatusPayload=u,exports.shouldGiveEvent=e=>e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===exports.CollectionEventSource.SYNC_MESSAGE_FILL||e===exports.CollectionEventSource.SYNC_MESSAGE_CHANGELOGS||e===exports.CollectionEventSource.SYNC_POLL_CHANGELOGS,exports.validatePollCreateParams=I,exports.validatePollData=A,exports.validatePollOptionRetrievalParams=U,exports.validatePollRetrievalParams=H; 2 | -------------------------------------------------------------------------------- /cjs/lib/__bundle-f86328d4.cjs: -------------------------------------------------------------------------------- 1 | var e,t=require("./__bundle-a6c826ee.cjs"),s=require("./__bundle-b4546809.cjs"),n=require("./__bundle-dae7bdf2.cjs"),a=require("./__bundle-e762fd36.cjs");exports.ChannelEventCategory=void 0,(e=exports.ChannelEventCategory||(exports.ChannelEventCategory={}))[e.NONE=0]="NONE",e[e.CHANNEL_ENTER=10102]="CHANNEL_ENTER",e[e.CHANNEL_EXIT=10103]="CHANNEL_EXIT",e[e.USER_CHANNEL_MUTE=10201]="USER_CHANNEL_MUTE",e[e.USER_CHANNEL_UNMUTE=10200]="USER_CHANNEL_UNMUTE",e[e.USER_CHANNEL_BAN=10601]="USER_CHANNEL_BAN",e[e.USER_CHANNEL_UNBAN=10600]="USER_CHANNEL_UNBAN",e[e.CHANNEL_FREEZE=10701]="CHANNEL_FREEZE",e[e.CHANNEL_UNFREEZE=10700]="CHANNEL_UNFREEZE",e[e.TYPING_START=10900]="TYPING_START",e[e.TYPING_END=10901]="TYPING_END",e[e.CHANNEL_JOIN=1e4]="CHANNEL_JOIN",e[e.CHANNEL_LEAVE=10001]="CHANNEL_LEAVE",e[e.CHANNEL_OPERATOR_UPDATE=10002]="CHANNEL_OPERATOR_UPDATE",e[e.CHANNEL_INVITE=10020]="CHANNEL_INVITE",e[e.CHANNEL_ACCEPT_INVITE=10021]="CHANNEL_ACCEPT_INVITE",e[e.CHANNEL_DECLINE_INVITE=10022]="CHANNEL_DECLINE_INVITE",e[e.CHANNEL_PROP_CHANGED=11e3]="CHANNEL_PROP_CHANGED",e[e.CHANNEL_DELETED=12e3]="CHANNEL_DELETED",e[e.CHANNEL_META_DATA_CHANGED=11100]="CHANNEL_META_DATA_CHANGED",e[e.CHANNEL_META_COUNTERS_CHANGED=11200]="CHANNEL_META_COUNTERS_CHANGED",e[e.CHANNEL_HIDE=13e3]="CHANNEL_HIDE",e[e.CHANNEL_UNHIDE=13001]="CHANNEL_UNHIDE",e[e.PINNED_MESSAGE_CHANGED=11300]="PINNED_MESSAGE_CHANGED";class o{constructor(e){var t;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(t=e.data)&&void 0!==t?t:{},this.ts=e.ts}get isGroupChannelEvent(){return this.channelType===t.ChannelType.GROUP}get isOpenChannelEvent(){return this.channelType===t.ChannelType.OPEN}}class r extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.event=new o(s)}}class i extends t.WebSocketEventCommand{constructor(e,t,n){var a;super(e,"SYEV",n),this.pinnedMessageIds=[],this.latestPinnedMessage=null,this.ts=0,n.data&&(this.pinnedMessageIds=null!==(a=n.data.pinned_message_ids)&&void 0!==a?a:[],this.latestPinnedMessage=n.data.latest_pinned_message?s.parseMessagePayload(e,Object.assign({},n.data.latest_pinned_message)):null),this.ts=n.ts}}class E extends t.InstancedObject{get _messageBroadcast(){return s.MessageBroadcast.of(this._iid)}constructor(e,t){super(e),this._logger=t.logger,this._sdkState=t.sdkState,this._sessionManager=t.sessionManager,this._requestQueue=t.requestQueue,this._dispatcher=t.dispatcher,this._cacheContext=t.cacheContext,this._channelType=t.channelType}subscribeMessageEvent(e,t){this._messageBroadcast.subscribe(e,t)}unsubscribeMessageEvent(e){this._messageBroadcast.unsubscribe(e)}getMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){return null}))}getExactlyMatchingMessagesForTokenFromCache(e,s,n){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getMessagesFromCache(e,s,n,a,o,r){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getPollMessagesFromCache(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}getCachedMessageCountBetween(e,s,n,a){return t.__awaiter(this,void 0,void 0,(function*(){return 0}))}getUnsentMessagesFromCache(e,s){return t.__awaiter(this,void 0,void 0,(function*(){return[]}))}removeFailedMessageFromCache(e){return t.__awaiter(this,void 0,void 0,(function*(){}))}}class d extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E;super(e,"ADMM",a),this.message=new s.AdminMessage(e,a);const{sdkState:d}=t.Vault.of(e);this.isMentioned=t.checkIfMentioned(this.message.mentionType,null!==(i=null!==(o=this.message.mentionedUserIds)&&void 0!==o?o:null===(r=this.message.mentionedUsers)||void 0===r?void 0:r.map((e=>e.userId)))&&void 0!==i?i:[],d.userId),this.forceUpdateLastMessage=null!==(E=a.force_update_last_message)&&void 0!==E&&E}}class _ extends t.WebSocketEventCommand{constructor(e,n,a){var o,r,i,E,d;super(e,"AEDI",a),this.message=new s.AdminMessage(e,a);const{sdkState:_}=t.Vault.of(e);this.mentionCountChange=t.calculateMentionCountChange({mentionType:null===(o=a.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(i=null===(r=a.old_values)||void 0===r?void 0:r.mentioned_user_ids)&&void 0!==i?i:[]},t.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(E=this.message.mentionedUserIds)&&void 0!==E?E:null===(d=this.message.mentionedUsers)||void 0===d?void 0:d.map((e=>e.userId))}),_.userId)}}class N extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MRCT",n),this.channelUrl=n.channel_url,this.channelType=n.channel_type,this.event=new s.ReactionEvent(n)}}class c extends t.WebSocketEventCommand{constructor(e,t,n){super(e,"MTHD",n),this.event=new s.ThreadInfoUpdateEvent(e,n)}}class l extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"MCNT",s),this.groupChannelMemberCounts=s.group_channels.map((e=>({channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}))),this.openChannelMemberCounts=s.open_channels.map((e=>({channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts})))}}class u extends t.WebSocketEventCommand{constructor(e,t,s){super(e,"PEDI",s),this.event=new n.PollUpdateEvent(e,s),this.status=a.parsePollStatusPayload(s.poll.status)||s.poll.status,this.channelUrl=s.channel_url,this.channelType=s.channel_type}}exports.AdminMessageEventCommand=d,exports.BaseChannelManager=E,exports.ChannelEventCommand=r,exports.MemberCountUpdateEventCommand=l,exports.OperatorUpdateEventCommand=class extends r{constructor(e,s,n){super(e,s,n);const{operators:a=[]}=n.data;this.operators=a.map((e=>new t.User(this._iid,e)))}},exports.PollUpdateEventCommand=u,exports.ReactionEventCommand=N,exports.ThreadInfoUpdateEventCommand=c,exports.UpdateAdminMessageEventCommand=_,exports.UpdatePinnedMessageEventCommand=i; 2 | -------------------------------------------------------------------------------- /cjs/message.cjs: -------------------------------------------------------------------------------- 1 | Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-a6c826ee.cjs"),s=require("./lib/__bundle-b4546809.cjs"),t=require("./lib/__bundle-431295de.cjs");require("./lib/__bundle-e762fd36.cjs");const r={channelUrl:"",scheduledMessageId:0},a={reverse:!1,limit:20};class n extends e.Module{constructor(){super(...arguments),this.name="message"}init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}){super.init(e,{sdkState:t,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}),this._manager=new s.MessageManager(e,{sdkState:t,dispatcher:r,requestQueue:n,onlineDetector:o,cacheContext:u})}buildMessageFromSerializedData(e){return this._manager.buildMessageFromSerializedData(e)}buildSenderFromSerializedData(e){return this._manager.buildSenderFromSerializedData(e)}getMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},s.MessageRetrievalParamsDefault),t);e.unless(s.validateMessageRetrievalParams(r)).throw(e.SendbirdError.invalidParameters);const a=yield this._manager.getMessage(r);if(a instanceof s.BaseMessage||a instanceof s.NotificationMessage||null===a)return a;throw"Unknown message type is given."}))}getScheduledMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},r),s);return e.unless((s=>e.isTypeOf("string",s.channelUrl)&&""!==s.channelUrl&&e.isTypeOf("number",s.scheduledMessageId)&&s.scheduledMessageId>0)(t)).throw(e.SendbirdError.invalidParameters),this._manager.getScheduledMessage(t)}))}getMessageTemplatesByToken(s,t={}){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},a),t);return e.unless(e.isTypeOf("string",s,!0)&&(s=>e.isTypeOf("boolean",s.reverse,!0)&&e.isTypeOf("number",s.limit,!0)&&e.isArrayOf("string",s.keys,!0))(r)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplatesByToken(s,r)}))}getMessageTemplate(s){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(e.isTypeOf("string",s)).throw(e.SendbirdError.invalidParameters),this._manager.getMessageTemplate(s)}))}}Object.defineProperty(exports,"MentionType",{enumerable:!0,get:function(){return e.MentionType}}),Object.defineProperty(exports,"MessageReviewStatus",{enumerable:!0,get:function(){return e.MessageReviewStatus}}),Object.defineProperty(exports,"MessageType",{enumerable:!0,get:function(){return e.MessageType}}),Object.defineProperty(exports,"MessageTypeFilter",{enumerable:!0,get:function(){return e.MessageTypeFilter}}),Object.defineProperty(exports,"PushNotificationDeliveryOption",{enumerable:!0,get:function(){return e.PushNotificationDeliveryOption}}),Object.defineProperty(exports,"ReplyType",{enumerable:!0,get:function(){return e.ReplyType}}),Object.defineProperty(exports,"SendingStatus",{enumerable:!0,get:function(){return e.SendingStatus}}),exports.AdminMessage=s.AdminMessage,exports.AppleCriticalAlertOptions=s.AppleCriticalAlertOptions,exports.BaseMessage=s.BaseMessage,exports.Feedback=s.Feedback,Object.defineProperty(exports,"FeedbackRating",{enumerable:!0,get:function(){return s.FeedbackRating}}),exports.FileMessage=s.FileMessage,exports.MessageForm=s.MessageForm,exports.MessageFormItem=s.MessageFormItem,Object.defineProperty(exports,"MessageFormItemLayout",{enumerable:!0,get:function(){return s.MessageFormItemLayout}}),exports.MessageMetaArray=s.MessageMetaArray,exports.MessageRequestHandler=s.MessageRequestHandler,exports.MessageReviewInfo=s.MessageReviewInfo,Object.defineProperty(exports,"MessageSearchOrder",{enumerable:!0,get:function(){return s.MessageSearchOrder}}),exports.MessageSearchQuery=s.MessageSearchQuery,exports.MultipleFilesMessage=s.MultipleFilesMessage,exports.MultipleFilesMessageRequestHandler=s.MultipleFilesMessageRequestHandler,exports.OGImage=s.OGImage,exports.OGMetaData=s.OGMetaData,exports.PreviousMessageListQuery=s.PreviousMessageListQuery,exports.ReactedUserInfo=s.ReactedUserInfo,exports.Reaction=s.Reaction,exports.ReactionEvent=s.ReactionEvent,Object.defineProperty(exports,"ReactionEventOperation",{enumerable:!0,get:function(){return s.ReactionEventOperation}}),exports.Sender=s.Sender,exports.ThreadInfo=s.ThreadInfo,exports.ThreadInfoUpdateEvent=s.ThreadInfoUpdateEvent,exports.Thumbnail=s.Thumbnail,exports.UploadedFileInfo=s.UploadedFileInfo,exports.UserMessage=s.UserMessage,exports.ThreadedParentMessageListQuery=t.ThreadedParentMessageListQuery,exports.MessageModule=n; 2 | -------------------------------------------------------------------------------- /cjs/message.d.cts: -------------------------------------------------------------------------------- 1 | export { 2 | AdminMessage, 3 | AppleCriticalAlertOptions, 4 | BaseMessage, 5 | BaseMessageCreateParams, 6 | BaseMessageUpdateParams, 7 | FailedMessageHandler, 8 | Feedback, 9 | FeedbackRating, 10 | FeedbackStatus, 11 | FileInfo, 12 | FileMessage, 13 | FileMessageCreateParams, 14 | FileMessageUpdateParams, 15 | FileUploadHandler, 16 | MentionType, 17 | MessageChangelogs, 18 | MessageChangeLogsParams, 19 | MessageForm, 20 | MessageFormItem, 21 | MessageFormItemLayout, 22 | MessageFormItemResultCount, 23 | MessageFormItemStyle, 24 | MessageHandler, 25 | MessageListParams, 26 | MessageMetaArray, 27 | MessageModule, 28 | MessageRequestHandler, 29 | MessageRetrievalParams, 30 | MessageReviewInfo, 31 | MessageReviewStatus, 32 | MessageSearchOrder, 33 | MessageSearchQuery, 34 | MessageSearchQueryParams, 35 | MessageTemplate, 36 | MessageTemplateListParams, 37 | MessageTemplateListResult, 38 | MessageType, 39 | MessageTypeFilter, 40 | MultipleFilesMessage, 41 | MultipleFilesMessageCreateParams, 42 | MultipleFilesMessageRequestHandler, 43 | OGImage, 44 | OGMetaData, 45 | OriginalMessageInfo, 46 | PreviousMessageListQuery, 47 | PreviousMessageListQueryParams, 48 | PushNotificationDeliveryOption, 49 | ReactedUserInfo, 50 | Reaction, 51 | ReactionEvent, 52 | ReactionEventOperation, 53 | ReplyType, 54 | ScheduledInfo, 55 | ScheduledMessageRetrievalParams, 56 | Sender, 57 | SendingStatus, 58 | ThreadedMessageListParams, 59 | ThreadedParentMessageListQuery, 60 | ThreadedParentMessageListQueryParams, 61 | ThreadInfo, 62 | ThreadInfoUpdateEvent, 63 | Thumbnail, 64 | ThumbnailSize, 65 | UploadableFileInfo, 66 | UploadedFileInfo, 67 | UserMessage, 68 | UserMessageCreateParams, 69 | UserMessageUpdateParams, 70 | } from './lib/__definition.cjs'; 71 | -------------------------------------------------------------------------------- /cjs/node.d.cts: -------------------------------------------------------------------------------- 1 | export {} from './lib/__definition.cjs'; 2 | -------------------------------------------------------------------------------- /cjs/openChannel.cjs: -------------------------------------------------------------------------------- 1 | Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-a6c826ee.cjs"),n=require("./lib/__bundle-b4546809.cjs"),t=require("./lib/__bundle-e762fd36.cjs"),a=require("./lib/__bundle-f86328d4.cjs"),s=require("./lib/__bundle-a9ae393e.cjs"),i=require("./lib/__bundle-2ce6b383.cjs");require("./lib/__bundle-dae7bdf2.cjs");class r extends e.InstancedObject{constructor(){super(...arguments),this._channels=new Map,this._enteredChannelUrls=[]}get enteredChannels(){return this._enteredChannelUrls.map((e=>this._channels.get(e))).filter((e=>!!e))}isEnteredChannel(e){return this._enteredChannelUrls.includes(e)}enter(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}exit(e){const n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)}exitAll(){this._enteredChannelUrls=[]}get(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._channels.get(n)}))}upsert(n){return e.__awaiter(this,void 0,void 0,(function*(){const e=[];return n.forEach((n=>{if(this._channels.has(n.url)){const t=this._channels.get(n.url);Object.assign(t,n),e.push(t)}else this._channels.set(n.url,n),e.push(n)})),e}))}remove(n){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.delete(n),this.exit(n)}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.clear(),this._enteredChannelUrls=[]}))}}const o={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0};class l extends e.APIRequestCommand{constructor({channelUrl:n,isInternalCall:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${t?e.API_PATH_OPEN_CHANNELS_INTERNAL:e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(n)}`,this.params={show_pinned_messages:!0}}}class d extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new M(e,n)}}class h extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,operatorUserIds:o,isEphemeral:l}=n;super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined(e.undefineNullProps({channel_url:t,cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:i,custom_type:r,operators:o,is_ephemeral:l}))}}class c extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"ENTR",payload:{channel_url:e},ackRequired:!0})}}class u extends a.ChannelEventCommand{constructor(n,t,a){var s,i;super(n,"SYEV",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}class p extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"EXIT",payload:{channel_url:e},ackRequired:!0})}}class C extends a.ChannelEventCommand{constructor(n,t,a){var s,i;super(n,"EXIT",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(i=a.data.edge_ts)&&void 0!==i?i:0)}}const _={};class v extends a.BaseChannelManager{constructor(n,t){super(n,Object.assign(Object.assign({},t),{channelType:e.ChannelType.OPEN})),this.subscribeChannelEvent=e.noop,this.unsubscribeChannelEvent=e.noop,this.refreshChannel=()=>e.__awaiter(this,void 0,void 0,(function*(){return e.noop()})),this._openChannelCache=new r(n),this._openChannelHandlers=new Map,this._dispatcher.on((n=>{if(n instanceof e.WebSocketEventCommand)this._handleEvent(n).catch((n=>{if(e.isThrowingOutside(n)&&"foreground"===this._sdkState.appState)throw n}));else if(n instanceof e.ConnectionStateChangeCommand&&n.stateType===e.ConnectionStateType.CONNECTED){const{enteredChannels:e}=this._openChannelCache;for(const n of e)n.enter()}})),_[n]||(_[n]=this)}static of(e){return _[e]}buildOpenChannelFromSerializedData(n){const t=e.deserialize(n);return new M(this._iid,M.payloadify(t))}getChannelFromCache(n){var t;return e.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._openChannelCache.get(n))&&void 0!==t?t:null}))}upsertChannelsToCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._openChannelCache.upsert(n)}))}removeChannelsFromCache(n){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of n)yield this._openChannelCache.remove(e)}))}setEnteredToCache(e){this._openChannelCache.enter(e.url)}setExitedToCache(e){this._openChannelCache.exit(e.url)}get handlers(){return[...this._openChannelHandlers.values()]}_handleEvent(s){return e.__awaiter(this,void 0,void 0,(function*(){try{switch(s.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{let t=null;if("MESG"===s.code?t=s.as(n.UserMessageEventCommand):"FILE"===s.code?t=s.as(n.FileMessageEventCommand):"ADMM"!==s.code&&"BRDM"!=s.code||(t=s.as(a.AdminMessageEventCommand)),t){const{message:n,isMentioned:a}=t;if(n.channelType===e.ChannelType.OPEN){const t=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&(e.onMessageReceived&&e.onMessageReceived(t,n),a&&e.onMentionReceived&&e.onMentionReceived(t,n))}))))}}break}case"MEDI":case"FEDI":case"AEDI":{let t=null;if("MEDI"===s.code?t=s.as(n.UpdateUserMessageEventCommand):"FEDI"===s.code?t=s.as(n.UpdateFileMessageEventCommand):"AEDI"===s.code&&(t=s.as(a.UpdateAdminMessageEventCommand)),t){const{message:n,mentionCountChange:a}=t;if(n.channelType===e.ChannelType.OPEN){const t=yield this.getChannel(n.channelUrl,!0);let s=!1;if(t.lastPinnedMessage&&t.lastPinnedMessage.messageId===n.messageId&&t.lastPinnedMessage.updatedAte.__awaiter(this,void 0,void 0,(function*(){var e,i;for(const r of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&(s&&(null===(e=r.onPinnedMessageUpdated)||void 0===e||e.call(r,t),null===(i=r.onChannelChanged)||void 0===i||i.call(r,t)),r.onMessageUpdated&&r.onMessageUpdated(t,n),a>0&&r.onMentionReceived&&r.onMentionReceived(t,n))}))))}}break}case"DELM":{const{channelUrl:n,channelType:t,messageId:a}=s.as(e.DeleteMessageEventCommand);if(t===e.ChannelType.OPEN){const t=yield this.getChannel(n,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&e.onMessageDeleted&&e.onMessageDeleted(t,a)}))))}break}case"MRCT":{const{channelUrl:n,channelType:t,event:i}=s.as(a.ReactionEventCommand);if(t===e.ChannelType.OPEN){const t=yield this.getChannel(n,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&e.onReactionUpdated&&e.onReactionUpdated(t,i)}))))}break}case"MTHD":{const{event:n}=s.as(a.ThreadInfoUpdateEventCommand);if(n.channelType===e.ChannelType.OPEN){const t=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&e.onThreadInfoUpdated&&e.onThreadInfoUpdated(t,n)}))))}break}case"MCNT":{const{openChannelMemberCounts:n}=s.as(a.MemberCountUpdateEventCommand),t=[];for(const e of n){const{channelUrl:n,participantCount:a,updatedAt:s}=e,i=yield this.getChannelFromCache(n);i&&i._updateParticipantCount(a,s)&&t.push(i)}if(t.length>0){const n=yield this.upsertChannelsToCache(t);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged(n)}))))}break}case"PEDI":{const{event:n,status:i,channelUrl:r,channelType:o}=s.as(a.PollUpdateEventCommand);if(r&&o===e.ChannelType.OPEN){const a=yield this.getChannel(r,!0);this._dispatcher.dispatch(new t.PollUpdateInternalEventCommand({event:n,source:t.CollectionEventSource.EVENT_POLL_UPDATED})),i===t.POLL_REMOVED_STATUS?e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollDeleted&&e.onPollDeleted(a,n.pollId)})))):e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollUpdated&&e.onPollUpdated(a,n)}))))}break}case"VOTE":{const{event:a,channelUrl:i,channelType:r}=s.as(n.PollVoteEventCommand);if(i&&r===e.ChannelType.OPEN){const n=yield this.getChannel(i,!0);this._dispatcher.dispatch(new t.PollVoteInternalEventCommand({event:a,source:t.CollectionEventSource.EVENT_POLL_VOTED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollVoted&&e.onPollVoted(n,a)}))))}break}case"SYEV":{const{event:t}=s.as(a.ChannelEventCommand);if(t.isOpenChannelEvent)switch(t.category){case a.ChannelEventCategory.CHANNEL_ENTER:{const n=yield this.getChannel(t.channelUrl,!0),{participantCount:a,user:i}=s.as(u),r=n._updateParticipantCount(a,t.ts),{requestDeduplicator:o}=e.Vault.of(this._iid);o.updatePendingResponse(n,Date.now()),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserEntered&&e.onUserEntered(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case a.ChannelEventCategory.CHANNEL_EXIT:{const n=yield this.getChannel(t.channelUrl,!0),{participantCount:a,user:i}=s.as(C),r=n._updateParticipantCount(a,t.ts),{requestDeduplicator:o}=e.Vault.of(this._iid);o.updatePendingResponse(n,Date.now()),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserExited&&e.onUserExited(n,i),r&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case a.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const n=yield this.getChannel(t.channelUrl,!0),{operators:i}=s.as(a.OperatorUpdateEventCommand);n.operators=i;const{requestDeduplicator:r}=e.Vault.of(this._iid);r.updatePendingResponse(n,Date.now()),yield this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(n,i)}))}))));break}case a.ChannelEventCategory.USER_CHANNEL_MUTE:case a.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const i=yield this.getChannel(t.channelUrl,!0),r=t.category===a.ChannelEventCategory.USER_CHANNEL_MUTE,{user:o}=s.as(r?n.MuteUserEventCommand:n.UnmuteUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserMuted&&e.onUserMuted(i,o):e.onUserUnmuted&&e.onUserUnmuted(i,o)}))}))));break}case a.ChannelEventCategory.USER_CHANNEL_BAN:case a.ChannelEventCategory.USER_CHANNEL_UNBAN:{const i=yield this.getChannel(t.channelUrl,!0),r=t.category===a.ChannelEventCategory.USER_CHANNEL_BAN,{user:o}=s.as(r?n.BanUserEventCommand:n.UnbanUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onUserBanned&&e.onUserBanned(i,o):e.onUserUnbanned&&e.onUserUnbanned(i,o)}))}))));break}case a.ChannelEventCategory.CHANNEL_FREEZE:case a.ChannelEventCategory.CHANNEL_UNFREEZE:{const a=yield this.getChannel(t.channelUrl,!0),{freeze:i}=s.as(n.FreezeEventCommand);a.isFrozen=i;const{requestDeduplicator:r}=e.Vault.of(this._iid);r.updatePendingResponse(a,Date.now()),yield this.upsertChannelsToCache([a]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onChannelFrozen&&e.onChannelFrozen(a):e.onChannelUnfrozen&&e.onChannelUnfrozen(a)}))}))));break}case a.ChannelEventCategory.CHANNEL_DELETED:yield this.removeChannelsFromCache([t.channelUrl]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((n=>{n.onChannelDeleted&&n.onChannelDeleted(t.channelUrl,e.ChannelType.OPEN)}))}))));break;case a.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(t.channelUrl,!0,!1);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}case a.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const a=yield this.getChannel(t.channelUrl,!0),{created:i,updated:r,deleted:o}=s.as(n.UpdateMetaDataEventCommand);if(i&&a._upsertCachedMetaData(i,t.ts),r&&a._upsertCachedMetaData(r,t.ts),o&&a._removeFromCachedMetaData(o,t.ts),i||r||o){const{requestDeduplicator:n}=e.Vault.of(this._iid);n.updatePendingResponse(a,Date.now())}e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaDataCreated&&e.onMetaDataCreated(a,i),r&&e.onMetaDataUpdated&&e.onMetaDataUpdated(a,r),o&&e.onMetaDataDeleted&&e.onMetaDataDeleted(a,o)}))}))));break}case a.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const a=yield this.getChannel(t.channelUrl,!0),{created:i,updated:r,deleted:o}=s.as(n.UpdateMetaCounterEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i&&e.onMetaCounterCreated&&e.onMetaCounterCreated(a,i),r&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(a,r),o&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(a,o)}))}))));break}case a.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const n=yield this.getChannel(t.channelUrl,!0),{pinnedMessageIds:i,latestPinnedMessage:r,ts:o}=s.as(a.UpdatePinnedMessageEventCommand);if(o>n._pinnedMessagesUpdatedAt){n.pinnedMessageIds=i,n.lastPinnedMessage=r,n._pinnedMessagesUpdatedAt=o;const{requestDeduplicator:t}=e.Vault.of(this._iid);t.updatePendingResponse(n,Date.now()),yield this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(n)})))),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(n)}))}))))}break}}break}}}catch(n){if(e.isThrowingOutside(n))throw n}}))}addHandler(e,n){this._openChannelHandlers.set(e,n)}removeHandler(e){this._openChannelHandlers.delete(e)}clearHandler(){this._openChannelHandlers.clear()}getChannel(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(n);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(n,t)}))}getChannelWithoutCache(n,t=!1,a=!0){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const{requestDeduplicator:s}=e.Vault.of(this._iid),i=new l({channelUrl:n,isInternalCall:t}),r=yield s.requestGetChannel(i.path,(()=>this._requestQueue.send(i)),i.params,a),{channel:o}=r.as(d);return(yield this.upsertChannelsToCache([o]))[0]}))}createChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},o),n);e.unless((n=>e.isArrayOf("string",n.operatorUserIds,!0)&&(e.isTypeOf("string",n.coverUrlOrImage,!0)||e.isFile(n.coverUrlOrImage,!0))&&e.isTypeOf("string",n.name,!0)&&e.isTypeOf("string",n.data,!0)&&e.isTypeOf("string",n.customType,!0)&&(e.isTypeOf("string",n.channelUrl)&&/^\w+$/.test(n.channelUrl)||null===n.channelUrl||void 0===n.channelUrl)&&e.isTypeOf("boolean",n.isEphemeral,!0))(t)).throw(e.SendbirdError.invalidParameters);const a=new h(t),s=yield this._requestQueue.send(a),{channel:i}=s.as(d);return yield this.upsertChannelsToCache([i]),i}))}}const g={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0};class m extends e.APIRequestCommand{constructor(n){const{channelUrl:t,token:a,limit:s}=n;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}/participants`,this.params={token:a,limit:s}}}class f extends e.APIResponseCommand{constructor(e,n){super(e,n),this.participants=[];const{next:t,participants:a}=n;this.token=t,this.participants=a.map((n=>new s.Participant(e,n)))}}class E extends t.ChannelDataListQuery{constructor(n,t,a){super(n,t,e.ChannelType.OPEN,a)}_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new m(Object.assign(Object.assign({},this),{token:this._token})),a=yield n.send(t),{participants:s,token:i}=a.as(f);return this._token=i,this._hasNext=!!i,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class U extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:i,customType:r,operatorUserIds:o}=n;super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`,this.params=e.deundefined(e.undefineNullProps({cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:i,custom_type:r,operators:o}))}}class y extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new M(e,n)}}class P extends e.APIRequestCommand{constructor(n){const{channelUrl:t}=n;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`}}class M extends n.BaseChannel{constructor(t,a){var s;super(t,a),this._lastParticipantCountUpdated=0,this.participantCount=0,this.operators=[],this.lastPinnedMessage=null,this._pinnedMessagesUpdatedAt=0,this.channelType=e.ChannelType.OPEN,this.participantCount=null!==(s=a.participant_count)&&void 0!==s?s:0,this.operators=Array.isArray(a.operators)?a.operators.map((n=>new e.User(t,n))):[],this.lastPinnedMessage=a.latest_pinned_message?n.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},a.latest_pinned_message)):null}static payloadify(t,a=!1){const s=Object.assign(Object.assign({},n.BaseChannel.payloadify(t,a)),{participant_count:t.participantCount,operators:t.operators.map((n=>e.User.payloadify(n))),latest_pinned_message:t.lastPinnedMessage?n.payloadifyMessage(t.lastPinnedMessage):null});return a?s:e.deundefined(e.undefineNullProps(s))}serialize(){return e.serialize(this)}isOperator(n){return n instanceof e.User?this.isOperator(n.userId):this.operators.some((e=>e.userId===n))}_updateParticipantCount(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)}createParticipantListQuery(e){return new E(this._iid,this.url,e)}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){const e=v.of(this._iid);return yield e.getChannelWithoutCache(this.url)}))}enter(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new c({channelUrl:this.url}),a=yield n.send(t),{participantCount:s,ts:i}=a.as(u);this._updateParticipantCount(s,i);v.of(this._iid).setEnteredToCache(this)}))}exit(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),a=new p({channelUrl:this.url}),s=yield t.send(a),{participantCount:i,ts:r}=s.as(C);this._updateParticipantCount(i,r);v.of(this._iid).setExitedToCache(this);n.MessageManager.of(this._iid).fileMessageQueue.cancel(this)}))}updateChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},g),n);e.unless((n=>e.isArrayOf("string",n.operatorUserIds,!0)&&(e.isTypeOf("string",n.coverUrlOrImage,!0)||e.isFile(n.coverUrlOrImage,!0))&&e.isTypeOf("string",n.name,!0)&&e.isTypeOf("string",n.data,!0)&&e.isTypeOf("string",n.customType,!0))(t)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),s=new U(Object.assign({channelUrl:this.url},t)),i=yield a.send(s),{channel:r}=i.as(y);this._update(r);const o=v.of(this._iid);return yield o.upsertChannelsToCache([r]),this}))}updateChannelWithOperatorUserIds(n,t,a,s,i){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},g),{name:n,coverUrlOrImage:t,data:a,operatorUserIds:s,customType:i});return this.updateChannel(e)}))}delete(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new P({channelUrl:this.url});yield n.send(t);const a=v.of(this._iid);yield a.removeChannelsFromCache([this.url])}))}updateUserMessage(n,t){const a=Object.create(null,{updateUserMessage:{get:()=>super.updateUserMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateUserMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){v.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){v.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}updateFileMessage(n,t){const a=Object.create(null,{updateFileMessage:{get:()=>super.updateFileMessage}});return e.__awaiter(this,void 0,void 0,(function*(){const e=yield a.updateFileMessage.call(this,n,t);let s=!1,i=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===e.messageId&&(this.lastPinnedMessage=e,s=!0,i=!0),s){v.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}if(i){v.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return e}))}}class T extends i.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserEntered=e.noop,this.onUserExited=e.noop,this.onChannelParticipantCountChanged=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop,this.onPinnedMessageUpdated=e.noop}}class b extends e.APIRequestCommand{constructor(n){const{token:t,limit:a,nameKeyword:s,urlKeyword:i,customTypes:r,includeFrozen:o,includeMetaData:l}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined({token:t,limit:a,name_contains:s,url_contains:i,custom_types:r,show_frozen:o,show_metadata:l,show_pinned_messages:!0})}}class A extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:t,channels:a,ts:s}=n;this.token=t,a&&a.length>0&&(this.channels=a.map((n=>new M(e,n)))),this.ts="number"==typeof s?s:null}}class w extends e.BaseListQuery{constructor(e,n){var t,a,s,i,r;super(e,n),this.includeFrozen=!0,this.includeMetaData=!0,this.nameKeyword=null,this.urlKeyword=null,this.customTypes=null,this.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,this.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,this.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,this.urlKeyword=null!==(i=n.urlKeyword)&&void 0!==i?i:null,this.customTypes=null!==(r=n.customTypes)&&void 0!==r?r:null}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.nameKeyword,!0)&&e.isTypeOf("string",this.urlKeyword,!0)&&e.isArrayOf("string",this.customTypes,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new b(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),a=yield n.send(t),{channels:s,token:i}=a.as(A);this._token=i,this._hasNext=!!i;const r=v.of(this._iid);return yield r.upsertChannelsToCache(s),this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class O extends e.Module{constructor(){super(...arguments),this.name="openChannel"}init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}){super.init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:i,onlineDetector:r,cacheContext:o}),this._manager=new v(e,{sdkState:n,dispatcher:t,requestQueue:s,logger:i,cacheContext:o,sessionManager:a})}createOpenChannelListQuery(e={}){return new w(this._iid,e)}addOpenChannelHandler(e,n){this._manager.addHandler(e,n)}removeOpenChannelHandler(e){this._manager.removeHandler(e)}removeAllOpenChannelHandlers(){this._manager.clearHandler()}buildOpenChannelFromSerializedData(e){return this._manager.buildOpenChannelFromSerializedData(e)}getChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.getChannel(n)}))}getChannelWithoutCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.getChannelWithoutCache(n)}))}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.createChannel(n)}))}createChannelWithOperatorUserIds(n,t,a,s,i){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign({},o);return e.name=n,e.coverUrlOrImage=t,e.data=a,e.operatorUserIds=s,e.customType=i,this._manager.createChannel(e)}))}}exports.OpenChannel=M,exports.OpenChannelHandler=class extends T{constructor(e={}){super(),Object.keys(e).forEach((n=>{this.hasOwnProperty(n)&&(this[n]=e[n])}))}},exports.OpenChannelListQuery=w,exports.OpenChannelModule=O,exports.ParticipantListQuery=E; 2 | -------------------------------------------------------------------------------- /cjs/openChannel.d.cts: -------------------------------------------------------------------------------- 1 | export { 2 | OpenChannel, 3 | OpenChannelCreateParams, 4 | OpenChannelHandler, 5 | OpenChannelListQuery, 6 | OpenChannelListQueryParams, 7 | OpenChannelModule, 8 | OpenChannelUpdateParams, 9 | ParticipantListQuery, 10 | ParticipantListQueryParams, 11 | SendbirdOpenChat, 12 | } from './lib/__definition.cjs'; 13 | -------------------------------------------------------------------------------- /cjs/poll.cjs: -------------------------------------------------------------------------------- 1 | Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-a6c826ee.cjs"),t=require("./lib/__bundle-e762fd36.cjs"),r=require("./lib/__bundle-dae7bdf2.cjs");class a extends e.Module{constructor(){super(...arguments),this.name="poll"}init(e,{sdkState:r,dispatcher:a,sessionManager:l,requestQueue:o,logger:s,onlineDetector:i,cacheContext:n}){super.init(e,{sdkState:r,dispatcher:a,sessionManager:l,requestQueue:o,logger:s,onlineDetector:i,cacheContext:n}),this._manager=new t.PollManager(e,{sdkState:r,dispatcher:a,sessionManager:l,requestQueue:o,logger:s,onlineDetector:i,cacheContext:n})}create(r){return e.__awaiter(this,void 0,void 0,(function*(){const a=Object.assign(Object.assign({},t.PollCreateParamsDefault),r);return e.unless(t.validatePollCreateParams(a)).throw(e.SendbirdError.invalidParameters),this._manager.create(a)}))}get(r){return e.__awaiter(this,void 0,void 0,(function*(){const a=Object.assign(Object.assign({},t.PollRetrievalParamsDefault),r);return e.unless(t.validatePollRetrievalParams(a)).throw(e.SendbirdError.invalidParameters),this._manager.get(a)}))}getOption(r){return e.__awaiter(this,void 0,void 0,(function*(){const a=Object.assign(Object.assign({},t.PollOptionRetrievalParamsDefault),r);return e.unless(t.validatePollOptionRetrievalParams(a)).throw(e.SendbirdError.invalidParameters),this._manager.getOption(a)}))}buildPollFromSerializedData(e){return this._manager.buildPollFromSerializedData(e)}}exports.Poll=t.Poll,exports.PollListQuery=t.PollListQuery,exports.PollOption=t.PollOption,Object.defineProperty(exports,"PollStatus",{enumerable:!0,get:function(){return t.PollStatus}}),exports.PollVoteEvent=t.PollVoteEvent,exports.PollVoterListQuery=t.PollVoterListQuery,exports.PollUpdateEvent=r.PollUpdateEvent,exports.PollModule=a; 2 | -------------------------------------------------------------------------------- /cjs/poll.d.cts: -------------------------------------------------------------------------------- 1 | export { 2 | Poll, 3 | PollChangelogs, 4 | PollCreateParams, 5 | PollData, 6 | PollListQuery, 7 | PollListQueryParams, 8 | PollModule, 9 | PollOption, 10 | PollOptionRetrievalParams, 11 | PollRetrievalParams, 12 | PollStatus, 13 | PollUpdateEvent, 14 | PollUpdateParams, 15 | PollVoteEvent, 16 | PollVoterListQuery, 17 | PollVoterListQueryParams, 18 | } from './lib/__definition.cjs'; 19 | -------------------------------------------------------------------------------- /feedChannel.d.ts: -------------------------------------------------------------------------------- 1 | export { 2 | FeedChannel, 3 | FeedChannelChangelogs, 4 | FeedChannelChangeLogsParams, 5 | FeedChannelEventContext, 6 | FeedChannelHandler, 7 | FeedChannelListQuery, 8 | FeedChannelListQueryParams, 9 | FeedChannelModule, 10 | GlobalNotificationChannelSetting, 11 | NotificationCategory, 12 | NotificationCollection, 13 | NotificationCollectionEventHandler, 14 | NotificationCollectionParams, 15 | NotificationData, 16 | NotificationEventContext, 17 | NotificationMessage, 18 | NotificationMessageStatus, 19 | NotificationTemplate, 20 | NotificationTemplateList, 21 | NotificationTemplateListParams, 22 | SendbirdFeedChat, 23 | } from './lib/__definition.js'; 24 | -------------------------------------------------------------------------------- /groupChannel.d.ts: -------------------------------------------------------------------------------- 1 | export { 2 | CountPreference, 3 | DeliveryStatus, 4 | GroupChannel, 5 | GroupChannelChangelogs, 6 | GroupChannelChangeLogsParams, 7 | GroupChannelCollection, 8 | GroupChannelCollectionEventHandler, 9 | GroupChannelCollectionParams, 10 | GroupChannelCountParams, 11 | GroupChannelCreateParams, 12 | GroupChannelEventContext, 13 | GroupChannelEventSource, 14 | GroupChannelFilter, 15 | GroupChannelFilterParams, 16 | GroupChannelHandler, 17 | GroupChannelHideParams, 18 | GroupChannelListOrder, 19 | GroupChannelListQuery, 20 | GroupChannelListQueryParams, 21 | GroupChannelModule, 22 | GroupChannelSearchField, 23 | GroupChannelSearchFilter, 24 | GroupChannelUpdateParams, 25 | GroupChannelUserIdsFilter, 26 | HiddenChannelFilter, 27 | HiddenState, 28 | Member, 29 | MemberListOrder, 30 | MemberListQuery, 31 | MemberListQueryParams, 32 | MembershipFilter, 33 | MemberState, 34 | MemberStateFilter, 35 | MessageCollection, 36 | MessageCollectionEventHandler, 37 | MessageCollectionInitHandler, 38 | MessageCollectionInitPolicy, 39 | MessageCollectionInitResultHandler, 40 | MessageCollectionParams, 41 | MessageEventContext, 42 | MessageEventSource, 43 | MessageFilter, 44 | MessageFilterParams, 45 | MutedMemberFilter, 46 | MutedState, 47 | MyMemberStateFilter, 48 | OperatorFilter, 49 | PinnedMessage, 50 | PinnedMessageListQuery, 51 | PinnedMessageListQueryParams, 52 | PublicChannelFilter, 53 | PublicGroupChannelListOrder, 54 | PublicGroupChannelListQuery, 55 | PublicGroupChannelListQueryParams, 56 | QueryType, 57 | ReadStatus, 58 | ScheduledFileMessageCreateParams, 59 | ScheduledFileMessageUpdateParams, 60 | ScheduledMessageListOrder, 61 | ScheduledMessageListQuery, 62 | ScheduledMessageListQueryParams, 63 | ScheduledStatus, 64 | ScheduledUserMessageCreateParams, 65 | ScheduledUserMessageUpdateParams, 66 | SendbirdGroupChat, 67 | SuperChannelFilter, 68 | TotalScheduledMessageCountParams, 69 | TotalUnreadMessageCountParams, 70 | UnreadChannelFilter, 71 | UnreadItemCount, 72 | UnreadItemCountParams, 73 | UnreadItemKey, 74 | UnreadMessageCount, 75 | } from './lib/__definition.js'; 76 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | import './message.d.ts'; 2 | import './groupChannel.d.ts'; 3 | import './openChannel.d.ts'; 4 | import './poll.d.ts'; 5 | import './feedChannel.d.ts'; 6 | import './aiAgent.d.ts'; 7 | import './node.d.ts'; 8 | 9 | export { 10 | AppInfo, 11 | ApplicationUserListQuery, 12 | ApplicationUserListQueryParams, 13 | BannedUserListQuery, 14 | BannedUserListQueryParams, 15 | BaseChannel, 16 | BlockedUserListQuery, 17 | BlockedUserListQueryParams, 18 | CachedChannelInfo, 19 | CachedDataClearOrder, 20 | ChannelType, 21 | CollectionEventSource, 22 | ConnectionHandler, 23 | ConnectionState, 24 | DeviceOsInfo, 25 | DeviceOsPlatform, 26 | DoNotDisturbPreference, 27 | Emoji, 28 | EmojiCategory, 29 | EmojiContainer, 30 | Encryption, 31 | FileCompat, 32 | FileUploadParams, 33 | FileUploadResult, 34 | FriendChangelogs, 35 | FriendDiscovery, 36 | FriendListQuery, 37 | FriendListQueryParams, 38 | InvitationPreference, 39 | LastMessageThreadingPolicy, 40 | LocalCacheConfig, 41 | LocalCacheConfigParams, 42 | LogLevel, 43 | MemoryStore, 44 | MemoryStoreParams, 45 | MetaCounter, 46 | MetaData, 47 | MutedInfo, 48 | MutedUserListQuery, 49 | MutedUserListQueryParams, 50 | NotificationInfo, 51 | OnlineDetectorListener, 52 | OperatorListQuery, 53 | OperatorListQueryParams, 54 | Participant, 55 | Plugin, 56 | PushTemplate, 57 | PushTokenRegistrationState, 58 | PushTokens, 59 | PushTokenType, 60 | PushTriggerOption, 61 | ReportCategory, 62 | ReportCategoryInfo, 63 | RestrictedUser, 64 | RestrictionInfo, 65 | RestrictionType, 66 | Role, 67 | SendbirdChatOptions, 68 | SendbirdChatParams, 69 | SendbirdChatWith, 70 | SendbirdError, 71 | SendbirdErrorCode, 72 | SendbirdPlatform, 73 | SendbirdProduct, 74 | SendbirdSdkInfo, 75 | SessionHandler, 76 | SnoozePeriod, 77 | StoreItem, 78 | UIKitConfigInfo, 79 | UnreadCountThreadingPolicy, 80 | UploadProgressHandler, 81 | UploadStartedHandler, 82 | User, 83 | UserEventHandler, 84 | UserOnlineState, 85 | UserUpdateParams, 86 | } from './lib/__definition.js'; 87 | 88 | import { SendbirdChat } from './lib/__definition.js'; 89 | export default SendbirdChat; 90 | -------------------------------------------------------------------------------- /lib/__bundle-0a529541.js: -------------------------------------------------------------------------------- 1 | import{V as e,t,g as s,X as r,b8 as a,aA as n,b9 as o,ay as d}from"./__bundle-bf8c7310.js";var i=function(i,u){return new Promise((function(c,p){if("undefined"!=typeof XMLHttpRequest){var f=e.of(i),l=f.dispatcher,g=f.logger,h=u.requestId,m=u.method,q=u.url,v=u.headers,w=void 0===v?{}:v,b=u.data,E=void 0===b?"":b,y=u.uploadProgressHandler,H=!1,S=new XMLHttpRequest;S.open(m,q),Object.keys(w).forEach((function(e){S.setRequestHeader(e,w[e])})),y&&S.upload.addEventListener("progress",(function(e){e.lengthComputable?y(h,e.loaded,e.total):g.debug("Progress computing failed: `Content-Length` header is not given.")})),S.onabort=function(){p(t.requestCanceled)},S.onerror=function(e){p(t.networkError)},S.onreadystatechange=function(){if(S.readyState===XMLHttpRequest.DONE&&!H)if(0===S.status||S.status>=200&&S.status<400)try{var e=JSON.parse(S.responseText);c(new s(i,e))}catch(u){p(t.networkError)}else try{var d=JSON.parse(S.responseText);if(d){var u=new t(d);if(u.isSessionExpiredError){if(l.dispatch(new r({reason:u.code,message:u.message})),!(S instanceof a)){var f=new n;return l.dispatch(new o({request:S,deferred:f,error:u})),f.promise}}else u.isSessionInvalidatedError&&l.dispatch(new r({reason:u.code,message:u.message}));p(u)}else p(t.requestFailed)}catch(u){p(t.requestFailed)}},l.on((function(e){e instanceof d&&(e.requestId&&e.requestId!==h||(H=!0,S.abort()))})),S.send(E)}else p(t.xmlHttpRequestNotSupported)}))};export{i as xmlHttpRequest}; 2 | -------------------------------------------------------------------------------- /lib/__bundle-14c04e55.js: -------------------------------------------------------------------------------- 1 | import{c as t,aU as n}from"./__bundle-bf8c7310.js";var a=function(t){return["-lastMessageUpdatedAt","-createdAt","syncIndex"]},e=function(n){function a(){return null!==n&&n.apply(this,arguments)||this}return t(a,n),a}(n);export{e as N,a as g}; 2 | -------------------------------------------------------------------------------- /lib/__bundle-1e2e2638.js: -------------------------------------------------------------------------------- 1 | import{j as t,c as e,aU as E,a as n,$ as o,e as i,u as l,ak as s,an as a,a2 as r,C as _,aM as u,A as N,aI as c,f as A,g as d,aq as T,G as h,_ as p,b as S,F as C,t as D,V as L,U as v}from"./__bundle-bf8c7310.js";var V;!function(t){t.UNKNOWN="UNKNOWN",t.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",t.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",t.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",t.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",t.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",t.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",t.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",t.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",t.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",t.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",t.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",t.EVENT_CHANNEL_BANNED="EVENT_CHANNEL_BANNED",t.EVENT_CHANNEL_UNBANNED="EVENT_CHANNEL_UNBANNED",t.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",t.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",t.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",t.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",t.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",t.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",t.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",t.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",t.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",t.EVENT_CHANNEL_METADATA_CREATED="EVENT_CHANNEL_METADATA_CREATED",t.EVENT_CHANNEL_METADATA_UPDATED="EVENT_CHANNEL_METADATA_UPDATED",t.EVENT_CHANNEL_METADATA_DELETED="EVENT_CHANNEL_METADATA_DELETED",t.EVENT_CHANNEL_METACOUNTER_CREATED="EVENT_CHANNEL_METACOUNTER_CREATED",t.EVENT_CHANNEL_METACOUNTER_UPDATED="EVENT_CHANNEL_METACOUNTER_UPDATED",t.EVENT_CHANNEL_METACOUNTER_DELETED="EVENT_CHANNEL_METACOUNTER_DELETED",t.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",t.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",t.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",t.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",t.REQUEST_CHANNEL="REQUEST_CHANNEL",t.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",t.REFRESH_CHANNEL="REFRESH_CHANNEL",t.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",t.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",t.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS",t.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",t.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",t.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",t.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",t.EVENT_MESSAGE_FEEDBACK_ADDED="EVENT_MESSAGE_FEEDBACK_ADDED",t.EVENT_MESSAGE_FEEDBACK_UPDATED="EVENT_MESSAGE_FEEDBACK_UPDATED",t.EVENT_MESSAGE_FEEDBACK_DELETED="EVENT_MESSAGE_FEEDBACK_DELETED",t.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",t.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",t.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",t.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",t.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",t.REQUEST_MESSAGE="REQUEST_MESSAGE",t.EVENT_THREAD_INFO_UPDATED="EVENT_THREADINFO_UPDATED",t.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",t.EVENT_POLL_VOTED="EVENT_POLL_VOTED",t.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",t.EVENT_CHANNEL_CSAT_SUBMITTED="EVENT_CHANNEL_CSAT_SUBMITTED",t.EVENT_CHANNEL_CONVERSATION_HANDEDOFF="EVENT_CHANNEL_CONVERSATION_HANDEDOFF",t.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",t.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",t.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",t.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",t.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",t.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",t.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",t.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",t.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",t.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED"}(V||(V={}));var f,U=t({},V),I=function(t){return t.startsWith("EVENT_")||t.startsWith("LOCAL_MESSAGE_")||t===V.SYNC_MESSAGE_FILL||t===V.SYNC_MESSAGE_CHANGELOGS||t===V.SYNC_POLL_CHANGELOGS},H=function(t){function E(e){var E=e.messages,n=e.source,o=e.isWebSocketEventComing,i=void 0!==o&&o,l=t.call(this)||this;return l.messages=E,l.source=n,l.isWebSocketEventComing=i,l}return e(E,t),E}(E),G=function(t){function E(e){var E=e.messageIds,n=e.source,o=e.isWebSocketEventComing,i=void 0!==o&&o,l=t.call(this)||this;return l.messageIds=E,l.source=n,l.isWebSocketEventComing=i,l}return e(E,t),E}(E),O=function(t){function E(e){var E=e.messageDeletionTimestamp,n=e.channelUrl,o=e.source,i=t.call(this)||this;return i.messageDeletionTimestamp=E,i.channelUrl=n,i.source=o,i}return e(E,t),E}(E),M=function(t){function E(e){var E=e.event,n=e.source,o=e.isWebSocketEventComing,i=void 0!==o&&o,l=t.call(this)||this;return l.event=E,l.source=n,l.isWebSocketEventComing=i,l}return e(E,t),E}(E),m=function(t){function E(e){var E=e.event,n=e.source,o=e.isWebSocketEventComing,i=void 0!==o&&o,l=t.call(this)||this;return l.event=E,l.source=n,l.isWebSocketEventComing=i,l}return e(E,t),E}(E),R=function(t){function E(e){var E=e.reqId,n=e.source,o=t.call(this)||this;return o.reqId=E,o.source=n,o}return e(E,t),E}(E),P=function(t){function E(e){var E=e.polls,n=e.source,o=t.call(this)||this;return o.polls=E,o.source=n,o}return e(E,t),E}(E),g=function(t){function E(e){var E=e.event,n=e.source,o=t.call(this)||this;return o.event=E,o.source=n,o}return e(E,t),E}(E),y=function(t){function E(e){var E=e.event,n=e.source,o=t.call(this)||this;return o.event=E,o.source=n,o}return e(E,t),E}(E);!function(t){t.OPEN="open",t.CLOSED="closed"}(f||(f={}));var w="removed",F=function(t){switch(t){case"open":return f.OPEN;case"closed":return f.CLOSED;default:return null}},b=function(t){return!t||!!t.text&&n("string",t.text)},k=function(E){function n(t,e){var n,o,i,l,s,a,r,_=this;return(_=E.call(this,t)||this).pollId=0,_.id=0,_.text=null,_.voteCount=0,_.createdBy=null,_.createdAt=0,_.updatedAt=0,_._lastVotedAt=0,_.pollId=null!==(n=e.poll_id)&&void 0!==n?n:0,_.id=null!==(o=e.id)&&void 0!==o?o:0,_.text=null!==(i=e.text)&&void 0!==i?i:null,_.voteCount=null!==(l=e.vote_count)&&void 0!==l?l:0,_.createdBy=null!==(s=e.created_by)&&void 0!==s?s:null,_.createdAt=null!==(a=e.created_at)&&void 0!==a?a:0,_.updatedAt=null!==(r=e.updated_at)&&void 0!==r?r:0,_}return e(n,E),n.payloadify=function(e){return i(l(t(t({},E.payloadify.call(this,e)),{vote_count:e.voteCount,poll_id:e.pollId,text:e.text,created_at:e.createdAt,id:e.id,created_by:e.createdBy,updated_at:e.updatedAt})))},n}(s),B=function(E){function n(t,e){var n,o,i,l,s,a,r,_,u,N,c,A,d,T=this;return(T=E.call(this,t)||this).id=0,T.title=null,T.createdAt=0,T.updatedAt=0,T.closeAt=-1,T.status=f.CLOSED,T.messageId=0,T.data=null,T.voterCount=-1,T.options=[],T.createdBy=null,T.allowUserSuggestion=!1,T.allowMultipleVotes=!1,T.votedPollOptionIds=[],T.id=null!==(n=e.id)&&void 0!==n?n:0,T.title=null!==(o=e.title)&&void 0!==o?o:null,T.createdAt=null!==(i=e.created_at)&&void 0!==i?i:0,T.updatedAt=null!==(l=e.updated_at)&&void 0!==l?l:0,T.closeAt=null!==(s=e.close_at)&&void 0!==s?s:-1,T.status=null!==(a=F(e.status))&&void 0!==a?a:f.CLOSED,T.messageId=null!==(r=e.message_id)&&void 0!==r?r:0,T.data=null!==(_=e.data)&&void 0!==_?_:null,T.voterCount=null!==(u=e.voter_count)&&void 0!==u?u:-1,T.options=e.options?e.options.map((function(t){return new k(T._iid,t)})):[],T.createdBy=null!==(N=e.created_by)&&void 0!==N?N:null,T.allowUserSuggestion=null!==(c=e.allow_user_suggestion)&&void 0!==c&&c,T.allowMultipleVotes=null!==(A=e.allow_multiple_votes)&&void 0!==A&&A,T.votedPollOptionIds=null!==(d=e.voted_option_ids)&&void 0!==d?d:[],T}return e(n,E),n.prototype._applyPollUpdatePayload=function(t){var e,E,n,o,i,l,s,a,r=this;this.title=null!==(e=t.title)&&void 0!==e?e:this.title,this.updatedAt=null!==(E=t.updated_at)&&void 0!==E?E:this.updatedAt,this.closeAt=null!==(n=t.close_at)&&void 0!==n?n:this.closeAt,this.status=null!==(o=F(t.status))&&void 0!==o?o:this.status,this.data=null!==(i=t.data)&&void 0!==i?i:this.data,this.voterCount=null!==(l=t.voter_count)&&void 0!==l?l:this.voterCount,t.options&&(this.options=t.options.map((function(t){return new k(r._iid,t)})),this.votedPollOptionIds=t.options.filter((function(t){return t.vote_count>0})).map((function(t){return t.id}))),this.allowUserSuggestion=null!==(s=t.allow_user_suggestion)&&void 0!==s?s:this.allowUserSuggestion,this.allowMultipleVotes=null!==(a=t.allow_multiple_votes)&&void 0!==a?a:this.allowMultipleVotes},n.payloadify=function(e){return i(l(t(t({},E.payloadify.call(this,e)),{id:e.id,title:e.title,created_at:e.createdAt,updated_at:e.updatedAt,close_at:e.closeAt,status:e.status,message_id:e.messageId,data:e.data,voter_count:e.voterCount,options:e.options.map((function(t){return k.payloadify(t)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))},n.prototype.applyPollUpdateEvent=function(t){var e=t._payload.poll;return!(!e||this.id!==e.id||e.updated_at-1){var i=e[n];o>=i._lastVotedAt&&(i.voteCount=t.vote_count,i._lastVotedAt=o)}})),n.req_id&&n.voted_option_ids&&(this.votedPollOptionIds=n.voted_option_ids),"number"==typeof n.voter_count&&(this.voterCount=n.voter_count),!0},n.prototype.serialize=function(){return a(this)},n}(s),x=function(t){function E(e,E,n,o){var i=t.call(this,e,o)||this;return i.channelUrl=E,i.channelType=n,i}return e(E,t),E.prototype._validate=function(){return t.prototype._validate.call(this)&&n("string",this.channelUrl)&&r(_,this.channelType)},E}(u),Q=function(t){this.pollId=0,this.messageId=0,this.pollId=t.poll_id,this.messageId=t.message_id,this._payload=t},Y=function(t){function E(e){var E=e.title,n=e.optionTexts,o=e.data,i=e.allowUserSuggestion,l=e.allowMultipleVotes,s=e.closeAt,a=t.call(this)||this;return a.method=N.POST,a.path=c,a.params={title:E,options:n,data:o,allow_user_suggestion:i,allow_multiple_votes:l,close_at:s},a}return e(E,t),E}(A),q=function(t){function E(e,E){var n=t.call(this,e,E)||this;return n.poll=new B(e,E),n}return e(E,t),E}(d),K=function(t){function E(e){var E=e.channelUrl,n=e.channelType,o=e.pollId,i=t.call(this)||this;return i.method=N.GET,i.path="".concat(c,"/").concat(encodeURIComponent(o)),i.params={channel_url:E,channel_type:n},i}return e(E,t),E}(A),W=function(t){function E(e,E){var n=t.call(this,e,E)||this;return n.poll=new B(e,E),n}return e(E,t),E}(d),Z=function(t){function E(e){var E=e.channelUrl,n=e.channelType,o=e.pollId,i=e.pollOptionId,l=t.call(this)||this;return l.method=N.GET,l.path="".concat(c,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(i)),l.params={channel_url:E,channel_type:n},l}return e(E,t),E}(A),j=function(t){function E(e,E){var n=t.call(this,e,E)||this;return n.pollOption=new k(e,E),n}return e(E,t),E}(d),z=function(t){function E(e){var E=e.channelType,n=e.channelUrl,o=e.timestamp,l=e.token,s=t.call(this)||this;return s.method=N.GET,s.path="".concat(T(E),"/").concat(encodeURIComponent(n),"/polls/changelogs"),s.params=i({change_ts:o,token:l}),s}return e(E,t),E}(A),J=function(t){function E(e,E){var n=t.call(this,e,E)||this;return n.updatedPolls=E.updated.map((function(t){return function(t,e){return new B(t,e)}(e,t)})),n.deletedPollIds=E.deleted.map((function(t){return t})),n.hasMore=E.has_more,n.nextToken=E.next,n}return e(E,t),E}(d),$={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},X=function(t){return n("string",t.title)&&(e=t.optionTexts,o("string",e)&&e.every((function(t){return""!==t.trim()})))&&b(t.data)&&n("boolean",t.allowUserSuggestion,!0)&&n("boolean",t.allowMultipleVotes,!0)&&n("number",t.closeAt,!0);var e},tt={channelUrl:"",channelType:_.BASE,pollId:0,pollOptionId:0},et=function(t){return n("string",t.channelUrl)&&""!==t.channelUrl&&r(_,t.channelType)&&n("number",t.pollId)&&t.pollId>0&&n("number",t.pollOptionId)&&t.pollOptionId>0},Et={channelUrl:"",channelType:_.BASE,pollId:0},nt=function(t){return n("string",t.channelUrl)&&""!==t.channelUrl&&r(_,t.channelType)&&n("number",t.pollId)},ot={},it=function(){function e(t,e){var E=e.sdkState,n=e.dispatcher,o=e.sessionManager,i=e.requestQueue,l=e.logger;this._iid=t,this._sdkState=E,this._sessionManager=o,this._requestQueue=i,this._dispatcher=n,this._logger=l,ot[t]=this}return e.of=function(t){return ot[t]},e.prototype.buildPollFromSerializedData=function(t){var e=h(t);return new B(this._iid,B.payloadify(e))},e.prototype.get=function(e){return p(this,void 0,void 0,(function(){var E,n;return S(this,(function(o){switch(o.label){case 0:return C(nt(e)).throw(D.invalidParameters),E=new K(t({},e)),[4,this._requestQueue.send(E)];case 1:return n=o.sent(),[2,n.as(W).poll]}}))}))},e.prototype.create=function(e){return p(this,void 0,void 0,(function(){var E,n;return S(this,(function(o){switch(o.label){case 0:return C(X(e)).throw(D.invalidParameters),E=new Y(t({},e)),[4,this._requestQueue.send(E)];case 1:return n=o.sent(),[2,n.as(q).poll]}}))}))},e.prototype.getOption=function(e){return p(this,void 0,void 0,(function(){var E,n;return S(this,(function(o){switch(o.label){case 0:return C(et(e)).throw(D.invalidParameters),E=new Z(t({},e)),[4,this._requestQueue.send(E)];case 1:return n=o.sent(),[2,n.as(j).pollOption]}}))}))},e.prototype.getPollChangeLogs=function(t,e,E,n){return void 0===n&&(n=V.SYNC_POLL_CHANGELOGS),p(this,void 0,void 0,(function(){var o,i,s,a,r,_,u;return S(this,(function(N){switch(N.label){case 0:return o=new z(l({channelType:e,channelUrl:t,timestamp:"number"==typeof E?E:null,token:"string"==typeof E?E:null})),[4,this._requestQueue.send(o)];case 1:return i=N.sent(),s=i.as(J),a=s.updatedPolls,r=s.deletedPollIds,_=s.hasMore,u=s.nextToken,a.length>0&&this._dispatcher.dispatch(new P({polls:a,source:n})),[2,{updatedPolls:a,deletedPollIds:r,hasMore:_,token:u}]}}))}))},e}(),lt=function(t){function E(e){var E=e.channelUrl,n=e.channelType,o=e.token,i=e.limit,l=t.call(this)||this;return l.method=N.GET,l.path=c,l.params={channel_url:E,channel_type:n,token:o,limit:i},l}return e(E,t),E}(A),st=function(t){function E(e,E){var n,o=this;return(o=t.call(this,e,E)||this).polls=(null!==(n=E.polls)&&void 0!==n?n:[]).map((function(t){return new B(e,t)})),o.token=E.next,o}return e(E,t),E}(d),at=function(E){function n(t,e){return E.call(this,t,e.channelUrl,e.channelType,e)||this}return e(n,E),n.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,E,n,o,i,l;return S(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=L.of(this._iid).requestQueue,E=new lt(t(t({},this),{token:this._token})),[4,e.send(E)]):[3,2]:[3,5];case 1:return n=s.sent(),o=n.as(st),i=o.polls,l=o.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw D.queryInProgress;case 4:return[3,6];case 5:throw D.invalidParameters;case 6:return[2]}}))}))},n}(x),rt=function(t){function E(e){var E=e.channelUrl,n=e.channelType,o=e.pollId,i=e.pollOptionId,l=e.token,s=e.limit,a=t.call(this)||this;return a.method=N.GET,a.path="".concat(c,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(i),"/voters"),a.params={channel_url:E,channel_type:n,token:l,limit:s},a}return e(E,t),E}(A),_t=function(t){function E(e,E){var n,o=this;return(o=t.call(this,e,E)||this).voters=(null!==(n=E.voters)&&void 0!==n?n:[]).map((function(t){return new v(e,t)})),o.token=E.next,o}return e(E,t),E}(d),ut=function(E){function o(t,e){var n=E.call(this,t,e.channelUrl,e.channelType,e)||this;return n.pollId=e.pollId,n.pollOptionId=e.pollOptionId,n}return e(o,E),o.prototype._validate=function(){return E.prototype._validate.call(this)&&n("number",this.pollId)&&n("number",this.pollOptionId)},o.prototype.next=function(){return p(this,void 0,void 0,(function(){var e,E,n,o,i,l;return S(this,(function(s){switch(s.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=L.of(this._iid).requestQueue,E=new rt(t(t({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,e.send(E)]):[3,2]:[3,5];case 1:return n=s.sent(),o=n.as(_t),i=o.voters,l=o.token,this._token=l,this._hasNext=!!l,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw D.queryInProgress;case 4:return[3,6];case 5:throw D.invalidParameters;case 6:return[2]}}))}))},o}(x);export{V as C,H as M,at as P,M as R,m as T,R as U,ut as a,B as b,x as c,Q as d,y as e,it as f,O as g,g as h,P as i,G as j,$ as k,X as l,Et as m,nt as n,tt as o,et as p,k as q,f as r,U as s,w as t,I as u,b as v,F as w}; 2 | -------------------------------------------------------------------------------- /lib/__bundle-46d64517.js: -------------------------------------------------------------------------------- 1 | var t="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{},e="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,o="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),n="FormData"in t,s="ArrayBuffer"in t;if(s)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(t){return t&&i.indexOf(Object.prototype.toString.call(t))>-1};function h(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function u(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function c(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function l(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function y(t){var e=new FileReader,r=l(e);return e.readAsArrayBuffer(t),r}function p(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){var r;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:n&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:e&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&o&&((r=t)&&DataView.prototype.isPrototypeOf(r))?(this._bodyArrayBuffer=p(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this._bodyArrayBuffer=p(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var t=c(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=c(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(o)return this.blob().then(y);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,o,n,s=c(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=l(e),o=/charset=([A-Za-z0-9_-]+)/.exec(t.type),n=o?o[1]:"utf-8",e.readAsText(t,n),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),o=0;o-1?n:o),this.mode=r.mode||this.mode||null,this.signal=r.signal||this.signal||function(){if("AbortController"in t)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==r.cache&&"no-cache"!==r.cache)){var i=/([?&])_=[^&]*/;if(i.test(this.url))this.url=this.url.replace(i,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function g(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}})),e}function v(t,e){if(!(this instanceof v))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},b.call(w.prototype),b.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var A=[301,302,303,307,308];v.redirect=function(t,e){if(-1===A.indexOf(e))throw new RangeError("Invalid status code");return new v(null,{status:e,headers:{location:t}})};var T=t.DOMException;try{new T}catch(t){(T=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack}).prototype=Object.create(Error.prototype),T.prototype.constructor=T}function _(e,r){return new Promise((function(n,i){var a=new w(e,r);if(a.signal&&a.signal.aborted)return i(new T("Aborted","AbortError"));var f=new XMLHttpRequest;function c(){f.abort()}if(f.onload=function(){var t,e,r={statusText:f.statusText,headers:(t=f.getAllResponseHeaders()||"",e=new d,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();try{e.append(o,n)}catch(t){console.warn("Response "+t.message)}}})),e)};0===a.url.indexOf("file://")&&(f.status<200||f.status>599)?r.status=200:r.status=f.status,r.url="responseURL"in f?f.responseURL:r.headers.get("X-Request-URL");var o="response"in f?f.response:f.responseText;setTimeout((function(){n(new v(o,r))}),0)},f.onerror=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},f.ontimeout=function(){setTimeout((function(){i(new TypeError("Network request timed out"))}),0)},f.onabort=function(){setTimeout((function(){i(new T("Aborted","AbortError"))}),0)},f.open(a.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?f.withCredentials=!0:"omit"===a.credentials&&(f.withCredentials=!1),"responseType"in f&&(o?f.responseType="blob":s&&(f.responseType="arraybuffer")),r&&"object"==typeof r.headers&&!(r.headers instanceof d||t.Headers&&r.headers instanceof t.Headers)){var l=[];Object.getOwnPropertyNames(r.headers).forEach((function(t){l.push(h(t)),f.setRequestHeader(t,u(r.headers[t]))})),a.headers.forEach((function(t,e){-1===l.indexOf(e)&&f.setRequestHeader(e,t)}))}else a.headers.forEach((function(t,e){f.setRequestHeader(e,t)}));a.signal&&(a.signal.addEventListener("abort",c),f.onreadystatechange=function(){4===f.readyState&&a.signal.removeEventListener("abort",c)}),f.send(void 0===a._bodyInit?null:a._bodyInit)}))}_.polyfill=!0,t.fetch||(t.fetch=_,t.Headers=d,t.Request=w,t.Response=v);var E="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null};E.fetch||(E.fetch=_); 2 | -------------------------------------------------------------------------------- /lib/__bundle-5dbfca78.js: -------------------------------------------------------------------------------- 1 | var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}!function(){function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw i}}}}var d=function(){function e(){t(this,e),Object.defineProperty(this,"listeners",{value:{},writable:!0,configurable:!0})}return n(e,[{key:"addEventListener",value:function(e,t,r){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push({callback:t,options:r})}},{key:"removeEventListener",value:function(e,t){if(e in this.listeners)for(var r=this.listeners[e],n=0,o=r.length;n=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}},e.prototype._fetchAllCachedPendingMessages=function(){return n(this,void 0,void 0,(function(){var e,t;return s(this,(function(n){switch(n.label){case 0:return e=g.of(this._iid),(t=new p).replyType=h.ALL,[4,e.fetch({sendingStatus:r.PENDING,backward:!0,filter:t})];case 1:return[2,n.sent()]}}))}))},e.prototype.indexOf=function(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((function(e){return e.reqId})).indexOf(e.reqId):-1},e.prototype._processNextAutoResend=function(){return n(this,void 0,void 0,(function(){var e;return s(this,(function(t){if(this._localCacheEnabled&&this._enableAutoResend&&"foreground"===this._sdkState.appState)try{this._autoResendQueue.length>0?(this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0),e=this._autoResendQueue[0],this._dispatcher.dispatch(new N({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)):(this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1)}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}return[2]}))}))},e}();!function(e){e[e.USER_BLOCK=20001]="USER_BLOCK",e[e.USER_UNBLOCK=2e4]="USER_UNBLOCK",e[e.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED"}(R||(R={}));var D,T=function(){function e(e){this.category=e.cat,this.data=e.data}return e.getDataAsUserBlockEvent=function(e,t){var n=t.data,s=n.blocker,r=n.blockee;return{blocker:new l(e,s),blockee:new l(e,r)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new l(e,t)})):[]}},e}(),m=function(t){function n(e,n){var s=n.userId,r=t.call(this)||this;return r._iid=e,r.userId=s,r}return e(n,t),n}(t),S=function(t){function n(){return t.call(this)||this}return e(n,t),n}(t),O=function(t){function n(e){var n=e.configTs,s=t.call(this)||this;return s.configTs=n,s}return e(n,t),n}(t),w=function(t){function n(e,n,s){var r=t.call(this,e,"USEV",s)||this;return r.event=new T(s),r}return e(n,t),n}(f),P=function(t){function n(e){var n=e.appConfigsInfo,s=e.configTs,r=t.call(this)||this;return r.appConfigsInfo={},r.configTs=0,r.appConfigsInfo=n,r.configTs=s,r}return e(n,t),n}(t);!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(D||(D={}));var U=function(t){function r(e,n,s,r){var i=t.call(this)||this;return i._state=D.IDLE,i._retryCount=0,i._retryLimit=3,i.priority=0,i._worker=n,i}return e(r,t),Object.defineProperty(r.prototype,"isIdle",{get:function(){return this._state===D.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isRunning",{get:function(){return this._state===D.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isDone",{get:function(){return this._state===D.END},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"retryCount",{get:function(){return this._retryCount},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"retryLimit",{get:function(){return this._retryLimit},enumerable:!1,configurable:!0}),r.prototype._run=function(e){return n(this,void 0,void 0,(function(){var t,n;return s(this,(function(s){switch(s.label){case 0:if(!this.isRunning)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._worker(e)];case 2:return t=s.sent(),this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end(),[3,4];case 3:return n=s.sent(),this.dispatch("error",n),this._retryCount", 7 | "keywords": [ 8 | "sendbird", 9 | "sendbird.com", 10 | "messaging", 11 | "chat", 12 | "js" 13 | ], 14 | "license": "SEE LICENSE IN LICENSE.md", 15 | "homepage": "https://sendbird.com", 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/sendbird/sendbird-chat-sdk-javascript" 19 | }, 20 | "peerDependencies": { 21 | "@react-native-async-storage/async-storage": "^1.17.6", 22 | "react-native-mmkv": ">=2.0.0" 23 | }, 24 | "peerDependenciesMeta": { 25 | "@react-native-async-storage/async-storage": { 26 | "optional": true 27 | }, 28 | "react-native-mmkv": { 29 | "optional": true 30 | } 31 | }, 32 | "type": "module", 33 | "main": "cjs/index.cjs", 34 | "module": "index.js", 35 | "types": "index.d.ts", 36 | "react-native": "./index.js", 37 | "exports": { 38 | "./package.json": "./package.json", 39 | ".": { 40 | "import": { 41 | "types": "./index.d.ts", 42 | "default": "./index.js" 43 | }, 44 | "require": { 45 | "types": "./cjs/index.d.cts", 46 | "default": "./cjs/index.cjs" 47 | } 48 | }, 49 | "./message": { 50 | "import": { 51 | "types": "./message.d.ts", 52 | "default": "./message.js" 53 | }, 54 | "require": { 55 | "types": "./cjs/message.d.cts", 56 | "default": "./cjs/message.cjs" 57 | } 58 | }, 59 | "./groupChannel": { 60 | "import": { 61 | "types": "./groupChannel.d.ts", 62 | "default": "./groupChannel.js" 63 | }, 64 | "require": { 65 | "types": "./cjs/groupChannel.d.cts", 66 | "default": "./cjs/groupChannel.cjs" 67 | } 68 | }, 69 | "./openChannel": { 70 | "import": { 71 | "types": "./openChannel.d.ts", 72 | "default": "./openChannel.js" 73 | }, 74 | "require": { 75 | "types": "./cjs/openChannel.d.cts", 76 | "default": "./cjs/openChannel.cjs" 77 | } 78 | }, 79 | "./poll": { 80 | "import": { 81 | "types": "./poll.d.ts", 82 | "default": "./poll.js" 83 | }, 84 | "require": { 85 | "types": "./cjs/poll.d.cts", 86 | "default": "./cjs/poll.cjs" 87 | } 88 | }, 89 | "./feedChannel": { 90 | "import": { 91 | "types": "./feedChannel.d.ts", 92 | "default": "./feedChannel.js" 93 | }, 94 | "require": { 95 | "types": "./cjs/feedChannel.d.cts", 96 | "default": "./cjs/feedChannel.cjs" 97 | } 98 | }, 99 | "./aiAgent": { 100 | "import": { 101 | "types": "./aiAgent.d.ts", 102 | "default": "./aiAgent.js" 103 | }, 104 | "require": { 105 | "types": "./cjs/aiAgent.d.cts", 106 | "default": "./cjs/aiAgent.cjs" 107 | } 108 | }, 109 | "./node": { 110 | "import": { 111 | "types": "./node.d.ts", 112 | "default": "./node.js" 113 | }, 114 | "require": { 115 | "types": "./cjs/node.d.cts", 116 | "default": "./cjs/node.cjs" 117 | } 118 | } 119 | }, 120 | "typesVersions": { 121 | "*": { 122 | "message": [ 123 | "./message.d.ts" 124 | ], 125 | "groupChannel": [ 126 | "./groupChannel.d.ts" 127 | ], 128 | "openChannel": [ 129 | "./openChannel.d.ts" 130 | ], 131 | "poll": [ 132 | "./poll.d.ts" 133 | ], 134 | "feedChannel": [ 135 | "./feedChannel.d.ts" 136 | ], 137 | "aiAgent": [ 138 | "./aiAgent.d.ts" 139 | ], 140 | "node": [ 141 | "./node.d.ts" 142 | ] 143 | } 144 | } 145 | } -------------------------------------------------------------------------------- /poll.d.ts: -------------------------------------------------------------------------------- 1 | export { 2 | Poll, 3 | PollChangelogs, 4 | PollCreateParams, 5 | PollData, 6 | PollListQuery, 7 | PollListQueryParams, 8 | PollModule, 9 | PollOption, 10 | PollOptionRetrievalParams, 11 | PollRetrievalParams, 12 | PollStatus, 13 | PollUpdateEvent, 14 | PollUpdateParams, 15 | PollVoteEvent, 16 | PollVoterListQuery, 17 | PollVoterListQueryParams, 18 | } from './lib/__definition.js'; 19 | -------------------------------------------------------------------------------- /poll.js: -------------------------------------------------------------------------------- 1 | import{c as t,_ as e,aS as n,b as o,j as i,F as s,t as l}from"./lib/__bundle-bf8c7310.js";import{f as u,k as c,l as p,m as h,n as f,o as g,p as m}from"./lib/__bundle-1e2e2638.js";export{b as Poll,P as PollListQuery,q as PollOption,r as PollStatus,d as PollVoteEvent,a as PollVoterListQuery}from"./lib/__bundle-1e2e2638.js";export{P as PollUpdateEvent}from"./lib/__bundle-acd77193.js";var v=function(r){function a(){var t=null!==r&&r.apply(this,arguments)||this;return t.name="poll",t}return t(a,r),a.prototype.init=function(t,e){var a=e.sdkState,n=e.dispatcher,o=e.sessionManager,i=e.requestQueue,s=e.logger,l=e.onlineDetector,c=e.cacheContext;r.prototype.init.call(this,t,{sdkState:a,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:l,cacheContext:c}),this._manager=new u(t,{sdkState:a,dispatcher:n,sessionManager:o,requestQueue:i,logger:s,onlineDetector:l,cacheContext:c})},a.prototype.create=function(t){return e(this,void 0,void 0,(function(){var e;return o(this,(function(r){return e=i(i({},c),t),s(p(e)).throw(l.invalidParameters),[2,this._manager.create(e)]}))}))},a.prototype.get=function(t){return e(this,void 0,void 0,(function(){var e;return o(this,(function(r){return e=i(i({},h),t),s(f(e)).throw(l.invalidParameters),[2,this._manager.get(e)]}))}))},a.prototype.getOption=function(t){return e(this,void 0,void 0,(function(){var e;return o(this,(function(r){return e=i(i({},g),t),s(m(e)).throw(l.invalidParameters),[2,this._manager.getOption(e)]}))}))},a.prototype.buildPollFromSerializedData=function(t){return this._manager.buildPollFromSerializedData(t)},a}(n);export{v as PollModule}; 2 | --------------------------------------------------------------------------------