@azure/communication-react 1.30.0 → 1.31.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (381) hide show
  1. package/dist/communication-react.d.ts +1373 -24
  2. package/dist/dist-cjs/communication-react/ChatMessageComponentAsRichTextEditBox-DdSFdo_m.js +213 -0
  3. package/dist/dist-cjs/communication-react/ChatMessageComponentAsRichTextEditBox-DdSFdo_m.js.map +1 -0
  4. package/dist/dist-cjs/communication-react/RichTextSendBoxWrapper-C2HrwCVY.js +49 -0
  5. package/dist/dist-cjs/communication-react/RichTextSendBoxWrapper-C2HrwCVY.js.map +1 -0
  6. package/dist/dist-cjs/communication-react/index-CH39vOsT.js +46344 -0
  7. package/dist/dist-cjs/communication-react/index-CH39vOsT.js.map +1 -0
  8. package/dist/dist-cjs/communication-react/index.js +174 -40373
  9. package/dist/dist-cjs/communication-react/index.js.map +1 -1
  10. package/dist/dist-esm/acs-ui-common/src/common.d.ts +13 -0
  11. package/dist/dist-esm/acs-ui-common/src/common.js.map +1 -1
  12. package/dist/dist-esm/acs-ui-common/src/constants.d.ts +5 -0
  13. package/dist/dist-esm/acs-ui-common/src/constants.js +5 -0
  14. package/dist/dist-esm/acs-ui-common/src/constants.js.map +1 -1
  15. package/dist/dist-esm/acs-ui-common/src/dataConversion.d.ts +6 -0
  16. package/dist/dist-esm/acs-ui-common/src/dataConversion.js +20 -0
  17. package/dist/dist-esm/acs-ui-common/src/dataConversion.js.map +1 -0
  18. package/dist/dist-esm/acs-ui-common/src/index.d.ts +4 -0
  19. package/dist/dist-esm/acs-ui-common/src/index.js +3 -0
  20. package/dist/dist-esm/acs-ui-common/src/index.js.map +1 -1
  21. package/dist/dist-esm/acs-ui-common/src/removeImageTags.d.ts +7 -0
  22. package/dist/dist-esm/acs-ui-common/src/removeImageTags.js +18 -0
  23. package/dist/dist-esm/acs-ui-common/src/removeImageTags.js.map +1 -0
  24. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js +1 -1
  25. package/dist/dist-esm/acs-ui-common/src/telemetryVersion.js.map +1 -1
  26. package/dist/dist-esm/calling-component-bindings/src/baseSelectors.js +2 -0
  27. package/dist/dist-esm/calling-component-bindings/src/baseSelectors.js.map +1 -1
  28. package/dist/dist-esm/calling-component-bindings/src/handlers/createCommonHandlers.d.ts +2 -0
  29. package/dist/dist-esm/calling-component-bindings/src/handlers/createCommonHandlers.js +6 -0
  30. package/dist/dist-esm/calling-component-bindings/src/handlers/createCommonHandlers.js.map +1 -1
  31. package/dist/dist-esm/calling-component-bindings/src/handlers/createTeamsCallHandlers.js +25 -1
  32. package/dist/dist-esm/calling-component-bindings/src/handlers/createTeamsCallHandlers.js.map +1 -1
  33. package/dist/dist-esm/calling-component-bindings/src/participantListSelector.d.ts +1 -0
  34. package/dist/dist-esm/calling-component-bindings/src/participantListSelector.js +3 -1
  35. package/dist/dist-esm/calling-component-bindings/src/participantListSelector.js.map +1 -1
  36. package/dist/dist-esm/calling-stateful-client/src/CallAgentDeclarativeCommon.js +4 -0
  37. package/dist/dist-esm/calling-stateful-client/src/CallAgentDeclarativeCommon.js.map +1 -1
  38. package/dist/dist-esm/calling-stateful-client/src/CallClientState.d.ts +42 -2
  39. package/dist/dist-esm/calling-stateful-client/src/CallClientState.js.map +1 -1
  40. package/dist/dist-esm/calling-stateful-client/src/CallContext.d.ts +6 -0
  41. package/dist/dist-esm/calling-stateful-client/src/CallContext.js +35 -0
  42. package/dist/dist-esm/calling-stateful-client/src/CallContext.js.map +1 -1
  43. package/dist/dist-esm/calling-stateful-client/src/CallSubscriber.d.ts +4 -0
  44. package/dist/dist-esm/calling-stateful-client/src/CallSubscriber.js +24 -4
  45. package/dist/dist-esm/calling-stateful-client/src/CallSubscriber.js.map +1 -1
  46. package/dist/dist-esm/calling-stateful-client/src/Converter.js +3 -0
  47. package/dist/dist-esm/calling-stateful-client/src/Converter.js.map +1 -1
  48. package/dist/dist-esm/calling-stateful-client/src/LocalRecordingSubscriber.d.ts +17 -0
  49. package/dist/dist-esm/calling-stateful-client/src/LocalRecordingSubscriber.js +33 -0
  50. package/dist/dist-esm/calling-stateful-client/src/LocalRecordingSubscriber.js.map +1 -0
  51. package/dist/dist-esm/calling-stateful-client/src/RecordingSubscriber.d.ts +1 -0
  52. package/dist/dist-esm/calling-stateful-client/src/RecordingSubscriber.js +7 -1
  53. package/dist/dist-esm/calling-stateful-client/src/RecordingSubscriber.js.map +1 -1
  54. package/dist/dist-esm/calling-stateful-client/src/TeamsCallDeclarative.js +17 -0
  55. package/dist/dist-esm/calling-stateful-client/src/TeamsCallDeclarative.js.map +1 -1
  56. package/dist/dist-esm/calling-stateful-client/src/index-public.d.ts +1 -0
  57. package/dist/dist-esm/calling-stateful-client/src/index-public.js.map +1 -1
  58. package/dist/dist-esm/chat-component-bindings/src/handlers/createHandlers.d.ts +6 -2
  59. package/dist/dist-esm/chat-component-bindings/src/handlers/createHandlers.js +36 -2
  60. package/dist/dist-esm/chat-component-bindings/src/handlers/createHandlers.js.map +1 -1
  61. package/dist/dist-esm/chat-component-bindings/src/hooks/usePropsFor.d.ts +2 -1
  62. package/dist/dist-esm/chat-component-bindings/src/hooks/usePropsFor.js +4 -0
  63. package/dist/dist-esm/chat-component-bindings/src/hooks/usePropsFor.js.map +1 -1
  64. package/dist/dist-esm/chat-component-bindings/src/messageThreadSelector.js +25 -2
  65. package/dist/dist-esm/chat-component-bindings/src/messageThreadSelector.js.map +1 -1
  66. package/dist/dist-esm/chat-component-bindings/src/utils/getImageAttachmentsFromHTMLContent.d.ts +6 -0
  67. package/dist/dist-esm/chat-component-bindings/src/utils/getImageAttachmentsFromHTMLContent.js +20 -0
  68. package/dist/dist-esm/chat-component-bindings/src/utils/getImageAttachmentsFromHTMLContent.js.map +1 -0
  69. package/dist/dist-esm/chat-component-bindings/src/utils/updateMessagesWithAttached.js +3 -3
  70. package/dist/dist-esm/chat-component-bindings/src/utils/updateMessagesWithAttached.js.map +1 -1
  71. package/dist/dist-esm/chat-stateful-client/src/ChatClientState.d.ts +15 -1
  72. package/dist/dist-esm/chat-stateful-client/src/ChatClientState.js.map +1 -1
  73. package/dist/dist-esm/chat-stateful-client/src/EventSubscriber.js +2 -1
  74. package/dist/dist-esm/chat-stateful-client/src/EventSubscriber.js.map +1 -1
  75. package/dist/dist-esm/chat-stateful-client/src/index.d.ts +1 -0
  76. package/dist/dist-esm/chat-stateful-client/src/index.js.map +1 -1
  77. package/dist/dist-esm/communication-react/src/index.d.ts +21 -0
  78. package/dist/dist-esm/communication-react/src/index.js +3 -0
  79. package/dist/dist-esm/communication-react/src/index.js.map +1 -1
  80. package/dist/dist-esm/react-components/src/components/Attachment/AttachmentDownloadCards.d.ts +2 -0
  81. package/dist/dist-esm/react-components/src/components/Attachment/AttachmentDownloadCards.js +1 -0
  82. package/dist/dist-esm/react-components/src/components/Attachment/AttachmentDownloadCards.js.map +1 -1
  83. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentWrapper.d.ts +13 -1
  84. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentWrapper.js +9 -3
  85. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageComponentWrapper.js.map +1 -1
  86. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.d.ts +11 -0
  87. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.js +32 -2
  88. package/dist/dist-esm/react-components/src/components/ChatMessage/ChatMessageContent.js.map +1 -1
  89. package/dist/dist-esm/react-components/src/components/ChatMessage/MentionRenderer.d.ts +10 -0
  90. package/dist/dist-esm/react-components/src/components/ChatMessage/MentionRenderer.js +15 -0
  91. package/dist/dist-esm/react-components/src/components/ChatMessage/MentionRenderer.js.map +1 -0
  92. package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/ChatMessageComponentAsMessageBubble.d.ts +8 -1
  93. package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/ChatMessageComponentAsMessageBubble.js +9 -5
  94. package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/ChatMessageComponentAsMessageBubble.js.map +1 -1
  95. package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/FluentChatMessageComponent.d.ts +2 -1
  96. package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/FluentChatMessageComponent.js +4 -4
  97. package/dist/dist-esm/react-components/src/components/ChatMessage/MessageComponents/FluentChatMessageComponent.js.map +1 -1
  98. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBox.d.ts +4 -1
  99. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBox.js +31 -6
  100. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBox.js.map +1 -1
  101. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBoxPicker.d.ts +15 -1
  102. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBoxPicker.js +9 -0
  103. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsEditBoxPicker.js.map +1 -1
  104. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.d.ts +24 -0
  105. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js +203 -0
  106. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox.js.map +1 -0
  107. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponent.d.ts +23 -2
  108. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponent.js +17 -6
  109. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponent.js.map +1 -1
  110. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponentAsMessageBubble.d.ts +8 -1
  111. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponentAsMessageBubble.js +10 -6
  112. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/ChatMyMessageComponentAsMessageBubble.js.map +1 -1
  113. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/FluentChatMyMessageComponent.js +5 -5
  114. package/dist/dist-esm/react-components/src/components/ChatMessage/MyMessageComponents/FluentChatMyMessageComponent.js.map +1 -1
  115. package/dist/dist-esm/react-components/src/components/DevicePermissions/BrowserPermissionDenied.d.ts +69 -0
  116. package/dist/dist-esm/react-components/src/components/DevicePermissions/BrowserPermissionDenied.js +36 -0
  117. package/dist/dist-esm/react-components/src/components/DevicePermissions/BrowserPermissionDenied.js.map +1 -0
  118. package/dist/dist-esm/react-components/src/components/DevicePermissions/BrowserPermissionDeniedIOS.d.ts +75 -0
  119. package/dist/dist-esm/react-components/src/components/DevicePermissions/BrowserPermissionDeniedIOS.js +67 -0
  120. package/dist/dist-esm/react-components/src/components/DevicePermissions/BrowserPermissionDeniedIOS.js.map +1 -0
  121. package/dist/dist-esm/react-components/src/components/DevicePermissions/SitePermissions.d.ts +105 -0
  122. package/dist/dist-esm/react-components/src/components/DevicePermissions/SitePermissions.js +51 -0
  123. package/dist/dist-esm/react-components/src/components/DevicePermissions/SitePermissions.js.map +1 -0
  124. package/dist/dist-esm/react-components/src/components/DevicePermissions/SitePermissionsScaffolding.d.ts +86 -0
  125. package/dist/dist-esm/react-components/src/components/DevicePermissions/SitePermissionsScaffolding.js +40 -0
  126. package/dist/dist-esm/react-components/src/components/DevicePermissions/SitePermissionsScaffolding.js.map +1 -0
  127. package/dist/dist-esm/react-components/src/components/ImageOverlay.js +2 -0
  128. package/dist/dist-esm/react-components/src/components/ImageOverlay.js.map +1 -1
  129. package/dist/dist-esm/react-components/src/components/InputBoxComponent.d.ts +2 -0
  130. package/dist/dist-esm/react-components/src/components/InputBoxComponent.js +15 -0
  131. package/dist/dist-esm/react-components/src/components/InputBoxComponent.js.map +1 -1
  132. package/dist/dist-esm/react-components/src/components/MentionPopover.d.ts +121 -0
  133. package/dist/dist-esm/react-components/src/components/MentionPopover.js +119 -0
  134. package/dist/dist-esm/react-components/src/components/MentionPopover.js.map +1 -0
  135. package/dist/dist-esm/react-components/src/components/MessageThread.d.ts +81 -5
  136. package/dist/dist-esm/react-components/src/components/MessageThread.js +13 -3
  137. package/dist/dist-esm/react-components/src/components/MessageThread.js.map +1 -1
  138. package/dist/dist-esm/react-components/src/components/ParticipantList.d.ts +15 -0
  139. package/dist/dist-esm/react-components/src/components/ParticipantList.js +12 -3
  140. package/dist/dist-esm/react-components/src/components/ParticipantList.js.map +1 -1
  141. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/ContextMenuPlugin.d.ts +9 -0
  142. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/ContextMenuPlugin.js +29 -0
  143. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/ContextMenuPlugin.js.map +1 -0
  144. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.d.ts +30 -0
  145. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.js +98 -0
  146. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/CopyPastePlugin.js.map +1 -0
  147. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/KeyboardInputPlugin.d.ts +19 -0
  148. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/KeyboardInputPlugin.js +43 -0
  149. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/KeyboardInputPlugin.js.map +1 -0
  150. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/PlaceholderPlugin.d.ts +15 -0
  151. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/PlaceholderPlugin.js +42 -0
  152. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/PlaceholderPlugin.js.map +1 -0
  153. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/RichTextToolbarPlugin.d.ts +24 -0
  154. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/RichTextToolbarPlugin.js +64 -0
  155. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/RichTextToolbarPlugin.js.map +1 -0
  156. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/TableEditContextMenuProvider.d.ts +20 -0
  157. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/TableEditContextMenuProvider.js +45 -0
  158. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/TableEditContextMenuProvider.js.map +1 -0
  159. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UndoRedoPlugin.d.ts +14 -0
  160. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UndoRedoPlugin.js +42 -0
  161. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UndoRedoPlugin.js.map +1 -0
  162. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UpdateContentPlugin.d.ts +30 -0
  163. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UpdateContentPlugin.js +99 -0
  164. package/dist/dist-esm/react-components/src/components/RichTextEditor/Plugins/UpdateContentPlugin.js.map +1 -0
  165. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.d.ts +59 -0
  166. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.js +334 -0
  167. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextEditor.js.map +1 -0
  168. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.d.ts +37 -0
  169. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.js +78 -0
  170. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextInputBoxComponent.js.map +1 -0
  171. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.d.ts +215 -0
  172. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js +184 -0
  173. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBox.js.map +1 -0
  174. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxErrors.d.ts +16 -0
  175. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxErrors.js +75 -0
  176. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxErrors.js.map +1 -0
  177. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxUtils.d.ts +9 -0
  178. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxUtils.js +16 -0
  179. package/dist/dist-esm/react-components/src/components/RichTextEditor/RichTextSendBoxUtils.js.map +1 -0
  180. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/RichTextToolbar.d.ts +19 -0
  181. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/RichTextToolbar.js +229 -0
  182. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/RichTextToolbar.js.map +1 -0
  183. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTableCommandBarItem.d.ts +7 -0
  184. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTableCommandBarItem.js +51 -0
  185. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTableCommandBarItem.js.map +1 -0
  186. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTablePane.d.ts +15 -0
  187. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTablePane.js +64 -0
  188. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextInsertTablePane.js.map +1 -0
  189. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextToolbarTableIcon.d.ts +6 -0
  190. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextToolbarTableIcon.js +13 -0
  191. package/dist/dist-esm/react-components/src/components/RichTextEditor/Toolbar/Table/RichTextToolbarTableIcon.js.map +1 -0
  192. package/dist/dist-esm/react-components/src/components/SendBox.d.ts +51 -1
  193. package/dist/dist-esm/react-components/src/components/SendBox.js +58 -6
  194. package/dist/dist-esm/react-components/src/components/SendBox.js.map +1 -1
  195. package/dist/dist-esm/react-components/src/components/SendBoxErrorBar.d.ts +56 -0
  196. package/dist/dist-esm/react-components/src/components/SendBoxErrorBar.js +75 -0
  197. package/dist/dist-esm/react-components/src/components/SendBoxErrorBar.js.map +1 -0
  198. package/dist/dist-esm/react-components/src/components/SendBoxErrors.d.ts +14 -0
  199. package/dist/dist-esm/react-components/src/components/SendBoxErrors.js +18 -0
  200. package/dist/dist-esm/react-components/src/components/SendBoxErrors.js.map +1 -0
  201. package/dist/dist-esm/react-components/src/components/TextFieldWithMention/TextFieldWithMention.d.ts +24 -0
  202. package/dist/dist-esm/react-components/src/components/TextFieldWithMention/TextFieldWithMention.js +550 -0
  203. package/dist/dist-esm/react-components/src/components/TextFieldWithMention/TextFieldWithMention.js.map +1 -0
  204. package/dist/dist-esm/react-components/src/components/TextFieldWithMention/mentionTagUtils.d.ts +152 -0
  205. package/dist/dist-esm/react-components/src/components/TextFieldWithMention/mentionTagUtils.js +819 -0
  206. package/dist/dist-esm/react-components/src/components/TextFieldWithMention/mentionTagUtils.js.map +1 -0
  207. package/dist/dist-esm/react-components/src/components/index.d.ts +21 -0
  208. package/dist/dist-esm/react-components/src/components/index.js +8 -0
  209. package/dist/dist-esm/react-components/src/components/index.js.map +1 -1
  210. package/dist/dist-esm/react-components/src/components/styles/AttachmentCard.styles.d.ts +1 -1
  211. package/dist/dist-esm/react-components/src/components/styles/AttachmentCardGroup.styles.d.ts +1 -1
  212. package/dist/dist-esm/react-components/src/components/styles/BrowserPermissionDenied.styles.d.ts +58 -0
  213. package/dist/dist-esm/react-components/src/components/styles/BrowserPermissionDenied.styles.js +144 -0
  214. package/dist/dist-esm/react-components/src/components/styles/BrowserPermissionDenied.styles.js.map +1 -0
  215. package/dist/dist-esm/react-components/src/components/styles/MentionPopover.style.d.ts +26 -0
  216. package/dist/dist-esm/react-components/src/components/styles/MentionPopover.style.js +69 -0
  217. package/dist/dist-esm/react-components/src/components/styles/MentionPopover.style.js.map +1 -0
  218. package/dist/dist-esm/react-components/src/components/styles/MessageThread.styles.d.ts +3 -3
  219. package/dist/dist-esm/react-components/src/components/styles/MessageThread.styles.js +8 -0
  220. package/dist/dist-esm/react-components/src/components/styles/MessageThread.styles.js.map +1 -1
  221. package/dist/dist-esm/react-components/src/components/styles/RichTextEditor.styles.d.ts +82 -0
  222. package/dist/dist-esm/react-components/src/components/styles/RichTextEditor.styles.js +328 -0
  223. package/dist/dist-esm/react-components/src/components/styles/RichTextEditor.styles.js.map +1 -0
  224. package/dist/dist-esm/react-components/src/components/styles/RichTextInputBoxComponent.styles.d.ts +21 -0
  225. package/dist/dist-esm/react-components/src/components/styles/RichTextInputBoxComponent.styles.js +38 -0
  226. package/dist/dist-esm/react-components/src/components/styles/RichTextInputBoxComponent.styles.js.map +1 -0
  227. package/dist/dist-esm/react-components/src/components/styles/SitePermissions.styles.d.ts +38 -0
  228. package/dist/dist-esm/react-components/src/components/styles/SitePermissions.styles.js +99 -0
  229. package/dist/dist-esm/react-components/src/components/styles/SitePermissions.styles.js.map +1 -0
  230. package/dist/dist-esm/react-components/src/components/styles/Stack.style.d.ts +5 -0
  231. package/dist/dist-esm/react-components/src/components/styles/Stack.style.js +32 -0
  232. package/dist/dist-esm/react-components/src/components/styles/Stack.style.js.map +1 -0
  233. package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentAsEditBoxUtils.d.ts +38 -1
  234. package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentAsEditBoxUtils.js +30 -3
  235. package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentAsEditBoxUtils.js.map +1 -1
  236. package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentUtils.d.ts +4 -2
  237. package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentUtils.js +9 -2
  238. package/dist/dist-esm/react-components/src/components/utils/ChatMessageComponentUtils.js.map +1 -1
  239. package/dist/dist-esm/react-components/src/components/utils/RichTextEditorUtils.d.ts +73 -0
  240. package/dist/dist-esm/react-components/src/components/utils/RichTextEditorUtils.js +178 -0
  241. package/dist/dist-esm/react-components/src/components/utils/RichTextEditorUtils.js.map +1 -0
  242. package/dist/dist-esm/react-components/src/components/utils/RichTextTableUtils.d.ts +33 -0
  243. package/dist/dist-esm/react-components/src/components/utils/RichTextTableUtils.js +119 -0
  244. package/dist/dist-esm/react-components/src/components/utils/RichTextTableUtils.js.map +1 -0
  245. package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.d.ts +47 -1
  246. package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js +154 -4
  247. package/dist/dist-esm/react-components/src/components/utils/SendBoxUtils.js.map +1 -1
  248. package/dist/dist-esm/react-components/src/components/utils/common.js +2 -0
  249. package/dist/dist-esm/react-components/src/components/utils/common.js.map +1 -1
  250. package/dist/dist-esm/react-components/src/components/utils/getParticipantsWhoHaveReadMessage.d.ts +2 -1
  251. package/dist/dist-esm/react-components/src/components/utils/getParticipantsWhoHaveReadMessage.js.map +1 -1
  252. package/dist/dist-esm/react-components/src/components/utils/merge.d.ts +7 -0
  253. package/dist/dist-esm/react-components/src/components/utils/merge.js +16 -0
  254. package/dist/dist-esm/react-components/src/components/utils/merge.js.map +1 -0
  255. package/dist/dist-esm/react-components/src/identifiers/IdentifierProvider.d.ts +4 -0
  256. package/dist/dist-esm/react-components/src/identifiers/IdentifierProvider.js +3 -1
  257. package/dist/dist-esm/react-components/src/identifiers/IdentifierProvider.js.map +1 -1
  258. package/dist/dist-esm/react-components/src/index.d.ts +1 -0
  259. package/dist/dist-esm/react-components/src/index.js.map +1 -1
  260. package/dist/dist-esm/react-components/src/localization/LocalizationProvider.d.ts +45 -0
  261. package/dist/dist-esm/react-components/src/localization/LocalizationProvider.js.map +1 -1
  262. package/dist/dist-esm/react-components/src/theming/icons.d.ts +24 -0
  263. package/dist/dist-esm/react-components/src/theming/icons.js +67 -0
  264. package/dist/dist-esm/react-components/src/theming/icons.js.map +1 -1
  265. package/dist/dist-esm/react-components/src/theming/icons.styles.d.ts +6 -0
  266. package/dist/dist-esm/react-components/src/theming/icons.styles.js +25 -0
  267. package/dist/dist-esm/react-components/src/theming/icons.styles.js.map +1 -0
  268. package/dist/dist-esm/react-components/src/theming/themes.d.ts +6 -0
  269. package/dist/dist-esm/react-components/src/theming/themes.js +9 -0
  270. package/dist/dist-esm/react-components/src/theming/themes.js.map +1 -1
  271. package/dist/dist-esm/react-components/src/types/Attachment.d.ts +13 -0
  272. package/dist/dist-esm/react-components/src/types/Attachment.js.map +1 -1
  273. package/dist/dist-esm/react-components/src/types/ChatMessage.d.ts +20 -1
  274. package/dist/dist-esm/react-components/src/types/ChatMessage.js.map +1 -1
  275. package/dist/dist-esm/react-composites/src/composites/CallComposite/CallComposite.d.ts +59 -0
  276. package/dist/dist-esm/react-composites/src/composites/CallComposite/CallComposite.js +15 -10
  277. package/dist/dist-esm/react-composites/src/composites/CallComposite/CallComposite.js.map +1 -1
  278. package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.d.ts +38 -6
  279. package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.js +12 -1
  280. package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/AzureCommunicationCallAdapter.js.map +1 -1
  281. package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/index.d.ts +2 -0
  282. package/dist/dist-esm/react-composites/src/composites/CallComposite/adapter/index.js.map +1 -1
  283. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallReadinessModal.d.ts +46 -0
  284. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallReadinessModal.js +200 -0
  285. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/CallReadinessModal.js.map +1 -0
  286. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageCameraDropdown.d.ts +2 -0
  287. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageCameraDropdown.js +19 -0
  288. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageCameraDropdown.js.map +1 -1
  289. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageErrorBar.js +10 -2
  290. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageErrorBar.js.map +1 -1
  291. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageMicDropdown.d.ts +2 -0
  292. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageMicDropdown.js +19 -0
  293. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/ConfigurationPageMicDropdown.js.map +1 -1
  294. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/LocalDeviceSettings.d.ts +1 -0
  295. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/LocalDeviceSettings.js +5 -3
  296. package/dist/dist-esm/react-composites/src/composites/CallComposite/components/LocalDeviceSettings.js.map +1 -1
  297. package/dist/dist-esm/react-composites/src/composites/CallComposite/hooks/useHandlers.js +3 -0
  298. package/dist/dist-esm/react-composites/src/composites/CallComposite/hooks/useHandlers.js.map +1 -1
  299. package/dist/dist-esm/react-composites/src/composites/CallComposite/index.d.ts +3 -0
  300. package/dist/dist-esm/react-composites/src/composites/CallComposite/index.js.map +1 -1
  301. package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/CallPage.js +2 -2
  302. package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/CallPage.js.map +1 -1
  303. package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/ConfigurationPage.d.ts +7 -0
  304. package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/ConfigurationPage.js +43 -5
  305. package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/ConfigurationPage.js.map +1 -1
  306. package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/HoldPage.js +2 -2
  307. package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/HoldPage.js.map +1 -1
  308. package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/LobbyPage.js +2 -2
  309. package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/LobbyPage.js.map +1 -1
  310. package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/TransferPage.js +2 -2
  311. package/dist/dist-esm/react-composites/src/composites/CallComposite/pages/TransferPage.js.map +1 -1
  312. package/dist/dist-esm/react-composites/src/composites/CallComposite/utils/Utils.d.ts +8 -0
  313. package/dist/dist-esm/react-composites/src/composites/CallComposite/utils/Utils.js +68 -0
  314. package/dist/dist-esm/react-composites/src/composites/CallComposite/utils/Utils.js.map +1 -1
  315. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/CallWithChatComposite.d.ts +52 -0
  316. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/CallWithChatComposite.js +10 -4
  317. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/CallWithChatComposite.js.map +1 -1
  318. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.d.ts +10 -3
  319. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js +20 -2
  320. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/AzureCommunicationCallWithChatAdapter.js.map +1 -1
  321. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.d.ts +16 -2
  322. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatAdapter.js.map +1 -1
  323. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.d.ts +10 -4
  324. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js +14 -2
  325. package/dist/dist-esm/react-composites/src/composites/CallWithChatComposite/adapter/CallWithChatBackedChatAdapter.js.map +1 -1
  326. package/dist/dist-esm/react-composites/src/composites/ChatComposite/AttachmentDownloadErrorBar.d.ts +15 -0
  327. package/dist/dist-esm/react-composites/src/composites/ChatComposite/AttachmentDownloadErrorBar.js +23 -0
  328. package/dist/dist-esm/react-composites/src/composites/ChatComposite/AttachmentDownloadErrorBar.js.map +1 -0
  329. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatComposite.d.ts +27 -0
  330. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatComposite.js +2 -1
  331. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatComposite.js.map +1 -1
  332. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.d.ts +2 -0
  333. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js +189 -11
  334. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreen.js.map +1 -1
  335. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreenPeoplePane.d.ts +18 -0
  336. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreenPeoplePane.js +18 -0
  337. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ChatScreenPeoplePane.js.map +1 -0
  338. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadReducer.d.ts +49 -0
  339. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadReducer.js +44 -0
  340. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadReducer.js.map +1 -0
  341. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadUtils.d.ts +39 -0
  342. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadUtils.js +267 -0
  343. package/dist/dist-esm/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadUtils.js.map +1 -0
  344. package/dist/dist-esm/react-composites/src/composites/ChatComposite/Strings.d.ts +20 -0
  345. package/dist/dist-esm/react-composites/src/composites/ChatComposite/Strings.js.map +1 -1
  346. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.d.ts +6 -2
  347. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js +36 -0
  348. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/AzureCommunicationChatAdapter.js.map +1 -1
  349. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.d.ts +12 -2
  350. package/dist/dist-esm/react-composites/src/composites/ChatComposite/adapter/ChatAdapter.js.map +1 -1
  351. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.d.ts +80 -0
  352. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.js +36 -0
  353. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUpload.js.map +1 -0
  354. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.d.ts +38 -0
  355. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.js +66 -0
  356. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/AttachmentUploadButton.js.map +1 -0
  357. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/index.d.ts +5 -0
  358. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/index.js +5 -0
  359. package/dist/dist-esm/react-composites/src/composites/ChatComposite/file-sharing/index.js.map +1 -0
  360. package/dist/dist-esm/react-composites/src/composites/ChatComposite/hooks/useHandlers.js +13 -2
  361. package/dist/dist-esm/react-composites/src/composites/ChatComposite/hooks/useHandlers.js.map +1 -1
  362. package/dist/dist-esm/react-composites/src/composites/ChatComposite/index.d.ts +2 -0
  363. package/dist/dist-esm/react-composites/src/composites/ChatComposite/index.js.map +1 -1
  364. package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.d.ts +4 -0
  365. package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.js +4 -0
  366. package/dist/dist-esm/react-composites/src/composites/ChatComposite/selectors/baseSelectors.js.map +1 -1
  367. package/dist/dist-esm/react-composites/src/composites/common/ParticipantContainer.js +2 -1
  368. package/dist/dist-esm/react-composites/src/composites/common/ParticipantContainer.js.map +1 -1
  369. package/dist/dist-esm/react-composites/src/composites/common/RichTextSendBoxWrapper.d.ts +10 -0
  370. package/dist/dist-esm/react-composites/src/composites/common/RichTextSendBoxWrapper.js +16 -0
  371. package/dist/dist-esm/react-composites/src/composites/common/RichTextSendBoxWrapper.js.map +1 -0
  372. package/dist/dist-esm/react-composites/src/composites/common/SendBoxPicker.d.ts +41 -2
  373. package/dist/dist-esm/react-composites/src/composites/common/SendBoxPicker.js +21 -0
  374. package/dist/dist-esm/react-composites/src/composites/common/SendBoxPicker.js.map +1 -1
  375. package/dist/dist-esm/react-composites/src/composites/common/constants.d.ts +5 -0
  376. package/dist/dist-esm/react-composites/src/composites/common/constants.js +5 -0
  377. package/dist/dist-esm/react-composites/src/composites/common/constants.js.map +1 -1
  378. package/dist/dist-esm/react-composites/src/composites/common/icons.d.ts +26 -1
  379. package/dist/dist-esm/react-composites/src/composites/common/icons.js +2 -0
  380. package/dist/dist-esm/react-composites/src/composites/common/icons.js.map +1 -1
  381. package/package.json +4 -4
@@ -0,0 +1,267 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ // Copyright (c) Microsoft Corporation.
11
+ // Licensed under the MIT License.
12
+ import { _IMAGE_ATTRIBUTE_INLINE_IMAGE_FILE_NAME_KEY } from "../../../../../acs-ui-common/src";
13
+ import { AttachmentUploadActionType } from '../file-sharing/AttachmentUpload';
14
+ import { _DEFAULT_INLINE_IMAGE_FILE_NAME, SEND_BOX_UPLOADS_KEY_VALUE } from '../../common/constants';
15
+ import { nanoid } from 'nanoid';
16
+ const MAX_INLINE_IMAGE_UPLOAD_SIZE_MB = 20;
17
+ const fetchBlobData = (resource, options) => __awaiter(void 0, void 0, void 0, function* () {
18
+ // default timeout is 30 seconds
19
+ const { timeout = 30000, abortController } = options;
20
+ const id = setTimeout(() => {
21
+ abortController.abort();
22
+ }, timeout);
23
+ const response = yield fetch(resource, Object.assign(Object.assign({}, options), { signal: abortController.signal }));
24
+ clearTimeout(id);
25
+ return response;
26
+ });
27
+ /**
28
+ * @private
29
+ */
30
+ export const getInlineImageData = (image) => __awaiter(void 0, void 0, void 0, function* () {
31
+ if (image.startsWith('blob') || image.startsWith('http')) {
32
+ try {
33
+ const res = yield fetchBlobData(image, {
34
+ abortController: new AbortController()
35
+ });
36
+ const blobImage = yield res.blob();
37
+ return blobImage;
38
+ }
39
+ catch (error) {
40
+ console.error('Error fetching image data', error);
41
+ return;
42
+ }
43
+ }
44
+ return;
45
+ });
46
+ /**
47
+ * @internal
48
+ */
49
+ export const getEditBoxMessagesInlineImages = (editBoxInlineImageUploads) => {
50
+ if (!editBoxInlineImageUploads) {
51
+ return;
52
+ }
53
+ const messagesInlineImagesWithProgress = {};
54
+ Object.entries(editBoxInlineImageUploads || {}).map(([messageId, attachmentUploads]) => {
55
+ const messageUploads = attachmentUploads.map(upload => {
56
+ return upload.metadata;
57
+ });
58
+ messagesInlineImagesWithProgress[messageId] = messageUploads;
59
+ });
60
+ return messagesInlineImagesWithProgress;
61
+ };
62
+ /**
63
+ * @internal
64
+ */
65
+ export const getSendBoxInlineImages = (sendBoxInlineImageUploads) => {
66
+ var _a;
67
+ if (!sendBoxInlineImageUploads) {
68
+ return;
69
+ }
70
+ return (_a = sendBoxInlineImageUploads[SEND_BOX_UPLOADS_KEY_VALUE]) === null || _a === void 0 ? void 0 : _a.map(upload => upload.metadata);
71
+ };
72
+ const inlineImageUploadHandler = (uploadTasks, adapter, strings) => __awaiter(void 0, void 0, void 0, function* () {
73
+ var _a, _b, _c;
74
+ for (const task of uploadTasks) {
75
+ const uploadTask = task;
76
+ const image = uploadTask.image;
77
+ if (!image) {
78
+ uploadTask.notifyUploadFailed(strings.uploadImageDataNotProvided);
79
+ continue;
80
+ }
81
+ if (image && image.size > MAX_INLINE_IMAGE_UPLOAD_SIZE_MB * 1024 * 1024) {
82
+ uploadTask.notifyUploadFailed(strings.uploadImageIsTooLarge.replace('{maxImageSize}', `${MAX_INLINE_IMAGE_UPLOAD_SIZE_MB}`));
83
+ continue;
84
+ }
85
+ const SUPPORTED_FILES = ['jpg', 'jpeg', 'png', 'gif', 'heic', 'webp'];
86
+ const imageExtension = (_b = (_a = task.metadata) === null || _a === void 0 ? void 0 : _a.name.split('.').pop()) !== null && _b !== void 0 ? _b : '';
87
+ if (!SUPPORTED_FILES.includes(imageExtension)) {
88
+ uploadTask.notifyUploadFailed(strings.uploadImageExtensionIsNotAllowed.replace('{imageExtension}', imageExtension));
89
+ continue;
90
+ }
91
+ try {
92
+ const response = yield adapter.uploadImage(image, (_c = task.metadata) === null || _c === void 0 ? void 0 : _c.name);
93
+ // Use response id as the image src because we need to keep the original image id as a reference to find the image.
94
+ // Also the html content we send to ChatSDK does not need image src,
95
+ // it only need the response id to match the uploaded image, url is not needed.
96
+ uploadTask.notifyUploadCompleted(task.metadata.id, response.id);
97
+ }
98
+ catch (error) {
99
+ console.error(error);
100
+ uploadTask.notifyUploadFailed(strings.uploadImageFailed);
101
+ }
102
+ }
103
+ });
104
+ const generateUploadTask = (imageAttributes, fileName, messageId, inlineImageUploadActionHandler) => __awaiter(void 0, void 0, void 0, function* () {
105
+ if (!imageAttributes.src) {
106
+ console.error('Cannot upload image - Image src is not provided');
107
+ return;
108
+ }
109
+ if (!imageAttributes.id) {
110
+ console.error('Cannot upload image - Image id is not provided');
111
+ return;
112
+ }
113
+ const imageData = yield getInlineImageData(imageAttributes.src);
114
+ if (!imageData) {
115
+ return;
116
+ }
117
+ const taskId = nanoid();
118
+ const uploadTask = {
119
+ image: imageData,
120
+ taskId,
121
+ metadata: {
122
+ id: imageAttributes.id,
123
+ name: fileName,
124
+ url: imageAttributes.src,
125
+ progress: 0
126
+ },
127
+ notifyUploadProgressChanged: (value) => {
128
+ inlineImageUploadActionHandler({
129
+ type: AttachmentUploadActionType.Progress,
130
+ taskId,
131
+ progress: value,
132
+ messageId
133
+ });
134
+ },
135
+ notifyUploadCompleted: (id, url) => {
136
+ inlineImageUploadActionHandler({
137
+ type: AttachmentUploadActionType.Completed,
138
+ taskId,
139
+ id,
140
+ url,
141
+ messageId
142
+ });
143
+ },
144
+ notifyUploadFailed: (message) => {
145
+ inlineImageUploadActionHandler({
146
+ type: AttachmentUploadActionType.Failed,
147
+ taskId,
148
+ message,
149
+ messageId
150
+ });
151
+ // remove the failed upload task when error banner is auto dismissed after 10 seconds
152
+ // so the banner won't be shown again on UI re-rendering.
153
+ setTimeout(() => {
154
+ inlineImageUploadActionHandler({
155
+ type: AttachmentUploadActionType.Remove,
156
+ id: taskId,
157
+ messageId
158
+ });
159
+ }, 10 * 1000);
160
+ }
161
+ };
162
+ return uploadTask;
163
+ });
164
+ /**
165
+ * @internal
166
+ */
167
+ export const onInsertInlineImageForEditBox = (imageAttributes, fileName, messageId, adapter, handleEditBoxInlineImageUploadAction, chatCompositeStrings) => __awaiter(void 0, void 0, void 0, function* () {
168
+ const uploadTask = yield generateUploadTask(imageAttributes, fileName, messageId, handleEditBoxInlineImageUploadAction);
169
+ if (!uploadTask) {
170
+ return;
171
+ }
172
+ handleEditBoxInlineImageUploadAction({
173
+ type: AttachmentUploadActionType.Set,
174
+ newUploads: [uploadTask],
175
+ messageId
176
+ });
177
+ inlineImageUploadHandler([uploadTask], adapter, chatCompositeStrings);
178
+ });
179
+ /**
180
+ * @internal
181
+ */
182
+ export const onInsertInlineImageForSendBox = (imageAttributes, fileName, adapter, handleSendBoxInlineImageUploadAction, chatCompositeStrings) => __awaiter(void 0, void 0, void 0, function* () {
183
+ const uploadTask = yield generateUploadTask(imageAttributes, fileName, SEND_BOX_UPLOADS_KEY_VALUE, handleSendBoxInlineImageUploadAction);
184
+ if (!uploadTask) {
185
+ return;
186
+ }
187
+ handleSendBoxInlineImageUploadAction({
188
+ type: AttachmentUploadActionType.Set,
189
+ newUploads: [uploadTask],
190
+ messageId: SEND_BOX_UPLOADS_KEY_VALUE
191
+ });
192
+ inlineImageUploadHandler([uploadTask], adapter, chatCompositeStrings);
193
+ });
194
+ /**
195
+ * @internal
196
+ */
197
+ export const cancelInlineImageUpload = (imageAttributes, imageUploads, messageId, inlineImageUploadActionHandler, adapter) => {
198
+ var _a;
199
+ if (!imageAttributes.id) {
200
+ console.error('Cannot cancel image upload - Image id is not provided');
201
+ return;
202
+ }
203
+ if (!imageUploads || !imageUploads[messageId]) {
204
+ deleteExistingInlineImageForEditBox(imageAttributes.id, messageId, adapter);
205
+ return;
206
+ }
207
+ const imageUpload = (_a = imageUploads[messageId]) === null || _a === void 0 ? void 0 : _a.find(upload => upload.metadata.id === imageAttributes.id);
208
+ if (!imageUpload || !(imageUpload === null || imageUpload === void 0 ? void 0 : imageUpload.metadata.id)) {
209
+ deleteExistingInlineImageForEditBox(imageAttributes.id, messageId, adapter);
210
+ return;
211
+ }
212
+ inlineImageUploadActionHandler({
213
+ type: AttachmentUploadActionType.Remove,
214
+ id: imageUpload === null || imageUpload === void 0 ? void 0 : imageUpload.metadata.id,
215
+ messageId
216
+ });
217
+ if ((imageUpload === null || imageUpload === void 0 ? void 0 : imageUpload.metadata.progress) === 1 && (imageUpload === null || imageUpload === void 0 ? void 0 : imageUpload.metadata.url)) {
218
+ // The image id that we got back from the ChatSDK response is stored in the image src attribute,
219
+ // while the metadata id is the internal image id that we assigned to the image when it was pasted in.
220
+ deleteInlineImageFromServer(imageUpload === null || imageUpload === void 0 ? void 0 : imageUpload.metadata.url, adapter);
221
+ }
222
+ };
223
+ const deleteInlineImageFromServer = (imageId, adapter) => {
224
+ try {
225
+ adapter.deleteImage(imageId);
226
+ }
227
+ catch (error) {
228
+ console.error(error);
229
+ }
230
+ }; // This function is used to delete the inline image that existed before editing starts
231
+ const deleteExistingInlineImageForEditBox = (imageId, messageId, adapter) => {
232
+ if (messageId !== SEND_BOX_UPLOADS_KEY_VALUE) {
233
+ deleteInlineImageFromServer(imageId, adapter);
234
+ }
235
+ };
236
+ /**
237
+ * @internal
238
+ */
239
+ export const updateContentStringWithUploadedInlineImages = (content, imageUploads, messageId = SEND_BOX_UPLOADS_KEY_VALUE) => {
240
+ if (!imageUploads || !imageUploads[messageId]) {
241
+ return content;
242
+ }
243
+ const messageUploads = imageUploads[messageId];
244
+ const document = new DOMParser().parseFromString(content !== null && content !== void 0 ? content : '', 'text/html');
245
+ document.querySelectorAll('img').forEach(img => {
246
+ var _a;
247
+ const uploadInlineImage = messageUploads === null || messageUploads === void 0 ? void 0 : messageUploads.find(upload => !upload.metadata.error && upload.metadata.progress === 1 && upload.metadata.id === img.id);
248
+ if (uploadInlineImage) {
249
+ // ChatSDK uses the respond id provided by the upload response. We store the response id in the image src attribute previously.
250
+ img.id = (_a = uploadInlineImage.metadata.url) !== null && _a !== void 0 ? _a : img.id;
251
+ img.src = '';
252
+ }
253
+ });
254
+ content = document.body.innerHTML;
255
+ return content;
256
+ };
257
+ /**
258
+ * @internal
259
+ */
260
+ export const getImageFileNameFromAttributes = (imageAttributes) => {
261
+ const fileName = imageAttributes[_IMAGE_ATTRIBUTE_INLINE_IMAGE_FILE_NAME_KEY];
262
+ if (!fileName || fileName === '' || fileName === 'undefined' || fileName === 'null') {
263
+ return _DEFAULT_INLINE_IMAGE_FILE_NAME;
264
+ }
265
+ return fileName;
266
+ };
267
+ //# sourceMappingURL=ImageUploadUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageUploadUtils.js","sourceRoot":"","sources":["../../../../../../../preprocess-dist/react-composites/src/composites/ChatComposite/ImageUpload/ImageUploadUtils.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAgC,2CAA2C,EAAE,yCAAgC;AACpH,OAAO,EAAoB,0BAA0B,EAAwB,MAAM,kCAAkC,CAAC;AACtH,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAIrG,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAC3C,MAAM,aAAa,GAAG,CAAO,QAAgC,EAAE,OAI9D,EAAqB,EAAE;IACtB,gCAAgC;IAChC,MAAM,EACJ,OAAO,GAAG,KAAK,EACf,eAAe,EAChB,GAAG,OAAO,CAAC;IACZ,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,EAAE;QACzB,eAAe,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC,EAAE,OAAO,CAAC,CAAC;IACZ,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,QAAQ,kCAChC,OAAO,KACV,MAAM,EAAE,eAAe,CAAC,MAAM,IAC9B,CAAC;IACH,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AACF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAO,KAAa,EAA6B,EAAE;IACnF,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAA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ui-common';\nimport { AttachmentUpload, AttachmentUploadActionType, AttachmentUploadTask } from '../file-sharing/AttachmentUpload';\nimport { _DEFAULT_INLINE_IMAGE_FILE_NAME, SEND_BOX_UPLOADS_KEY_VALUE } from '../../common/constants';\nimport { ChatAdapter } from '../adapter/ChatAdapter';\nimport { Dispatch } from 'react';\nimport { ImageActions } from './ImageUploadReducer';\nimport { nanoid } from 'nanoid';\nimport { ChatCompositeStrings } from '../Strings';\nconst MAX_INLINE_IMAGE_UPLOAD_SIZE_MB = 20;\nconst fetchBlobData = async (resource: string | URL | Request, options: {\n timeout?: number;\n headers?: Headers;\n abortController: AbortController;\n}): Promise<Response> => {\n // default timeout is 30 seconds\n const {\n timeout = 30000,\n abortController\n } = options;\n const id = setTimeout(() => {\n abortController.abort();\n }, timeout);\n const response = await fetch(resource, {\n ...options,\n signal: abortController.signal\n });\n clearTimeout(id);\n return response;\n};\n/**\n * @private\n */\nexport const getInlineImageData = async (image: string): Promise<Blob | undefined> => {\n if (image.startsWith('blob') || image.startsWith('http')) {\n try {\n const res = await fetchBlobData(image, {\n abortController: new AbortController()\n });\n const blobImage = await res.blob();\n return blobImage;\n } catch (error) {\n console.error('Error fetching image data', error);\n return;\n }\n }\n return;\n};\n/**\n * @internal\n */\nexport const getEditBoxMessagesInlineImages = (editBoxInlineImageUploads: Record<string, AttachmentUpload[]> | undefined): Record<string, AttachmentMetadataInProgress[]> | undefined => {\n if (!editBoxInlineImageUploads) {\n return;\n }\n const messagesInlineImagesWithProgress: Record<string, AttachmentMetadataInProgress[]> = {};\n Object.entries(editBoxInlineImageUploads || {}).map(([messageId, attachmentUploads]) => {\n const messageUploads = attachmentUploads.map(upload => {\n return upload.metadata;\n });\n messagesInlineImagesWithProgress[messageId] = messageUploads;\n });\n return messagesInlineImagesWithProgress;\n};\n/**\n * @internal\n */\nexport const getSendBoxInlineImages = (sendBoxInlineImageUploads: Record<string, AttachmentUpload[]> | undefined): AttachmentMetadataInProgress[] | undefined => {\n if (!sendBoxInlineImageUploads) {\n return;\n }\n return sendBoxInlineImageUploads[SEND_BOX_UPLOADS_KEY_VALUE]?.map(upload => upload.metadata);\n};\nconst inlineImageUploadHandler = async (uploadTasks: AttachmentUpload[], adapter: ChatAdapter, strings: ChatCompositeStrings): Promise<void> => {\n for (const task of uploadTasks) {\n const uploadTask = task as AttachmentUploadTask;\n const image: Blob | undefined = uploadTask.image;\n if (!image) {\n uploadTask.notifyUploadFailed(strings.uploadImageDataNotProvided);\n continue;\n }\n if (image && image.size > MAX_INLINE_IMAGE_UPLOAD_SIZE_MB * 1024 * 1024) {\n uploadTask.notifyUploadFailed(strings.uploadImageIsTooLarge.replace('{maxImageSize}', `${MAX_INLINE_IMAGE_UPLOAD_SIZE_MB}`));\n continue;\n }\n const SUPPORTED_FILES: Array<string> = ['jpg', 'jpeg', 'png', 'gif', 'heic', 'webp'];\n const imageExtension = task.metadata?.name.split('.').pop() ?? '';\n if (!SUPPORTED_FILES.includes(imageExtension)) {\n uploadTask.notifyUploadFailed(strings.uploadImageExtensionIsNotAllowed.replace('{imageExtension}', imageExtension));\n continue;\n }\n try {\n const response = await adapter.uploadImage(image, task.metadata?.name);\n // Use response id as the image src because we need to keep the original image id as a reference to find the image.\n // Also the html content we send to ChatSDK does not need image src,\n // it only need the response id to match the uploaded image, url is not needed.\n uploadTask.notifyUploadCompleted(task.metadata.id, response.id);\n } catch (error) {\n console.error(error);\n uploadTask.notifyUploadFailed(strings.uploadImageFailed);\n }\n }\n};\nconst generateUploadTask = async (imageAttributes: Record<string, string>, fileName: string, messageId: string, inlineImageUploadActionHandler: Dispatch<ImageActions>): Promise<AttachmentUpload | undefined> => {\n if (!imageAttributes.src) {\n console.error('Cannot upload image - Image src is not provided');\n return;\n }\n if (!imageAttributes.id) {\n console.error('Cannot upload image - Image id is not provided');\n return;\n }\n const imageData = await getInlineImageData(imageAttributes.src);\n if (!imageData) {\n return;\n }\n const taskId = nanoid();\n const uploadTask: AttachmentUpload = {\n image: imageData,\n taskId,\n metadata: {\n id: imageAttributes.id,\n name: fileName,\n url: imageAttributes.src,\n progress: 0\n },\n notifyUploadProgressChanged: (value: number) => {\n inlineImageUploadActionHandler({\n type: AttachmentUploadActionType.Progress,\n taskId,\n progress: value,\n messageId\n });\n },\n notifyUploadCompleted: (id: string, url: string) => {\n inlineImageUploadActionHandler({\n type: AttachmentUploadActionType.Completed,\n taskId,\n id,\n url,\n messageId\n });\n },\n notifyUploadFailed: (message: string) => {\n inlineImageUploadActionHandler({\n type: AttachmentUploadActionType.Failed,\n taskId,\n message,\n messageId\n });\n // remove the failed upload task when error banner is auto dismissed after 10 seconds\n // so the banner won't be shown again on UI re-rendering.\n setTimeout(() => {\n inlineImageUploadActionHandler({\n type: AttachmentUploadActionType.Remove,\n id: taskId,\n messageId\n });\n }, 10 * 1000);\n }\n };\n return uploadTask;\n};\n/**\n * @internal\n */\nexport const onInsertInlineImageForEditBox = async (imageAttributes: Record<string, string>, fileName: string, messageId: string, adapter: ChatAdapter, handleEditBoxInlineImageUploadAction: Dispatch<ImageActions>, chatCompositeStrings: ChatCompositeStrings): Promise<void> => {\n const uploadTask: AttachmentUpload | undefined = await generateUploadTask(imageAttributes, fileName, messageId, handleEditBoxInlineImageUploadAction);\n if (!uploadTask) {\n return;\n }\n handleEditBoxInlineImageUploadAction({\n type: AttachmentUploadActionType.Set,\n newUploads: [uploadTask],\n messageId\n });\n inlineImageUploadHandler([uploadTask], adapter, chatCompositeStrings);\n};\n/**\n * @internal\n */\nexport const onInsertInlineImageForSendBox = async (imageAttributes: Record<string, string>, fileName: string, adapter: ChatAdapter, handleSendBoxInlineImageUploadAction: Dispatch<ImageActions>, chatCompositeStrings: ChatCompositeStrings): Promise<void> => {\n const uploadTask: AttachmentUpload | undefined = await generateUploadTask(imageAttributes, fileName, SEND_BOX_UPLOADS_KEY_VALUE, handleSendBoxInlineImageUploadAction);\n if (!uploadTask) {\n return;\n }\n handleSendBoxInlineImageUploadAction({\n type: AttachmentUploadActionType.Set,\n newUploads: [uploadTask],\n messageId: SEND_BOX_UPLOADS_KEY_VALUE\n });\n inlineImageUploadHandler([uploadTask], adapter, chatCompositeStrings);\n};\n/**\n * @internal\n */\nexport const cancelInlineImageUpload = (imageAttributes: Record<string, string>, imageUploads: Record<string, AttachmentUpload[]> | undefined, messageId: string, inlineImageUploadActionHandler: Dispatch<ImageActions>, adapter: ChatAdapter): void => {\n if (!imageAttributes.id) {\n console.error('Cannot cancel image upload - Image id is not provided');\n return;\n }\n if (!imageUploads || !imageUploads[messageId]) {\n deleteExistingInlineImageForEditBox(imageAttributes.id, messageId, adapter);\n return;\n }\n const imageUpload = imageUploads[messageId]?.find(upload => upload.metadata.id === imageAttributes.id);\n if (!imageUpload || !imageUpload?.metadata.id) {\n deleteExistingInlineImageForEditBox(imageAttributes.id, messageId, adapter);\n return;\n }\n inlineImageUploadActionHandler({\n type: AttachmentUploadActionType.Remove,\n id: imageUpload?.metadata.id,\n messageId\n });\n if (imageUpload?.metadata.progress === 1 && imageUpload?.metadata.url) {\n // The image id that we got back from the ChatSDK response is stored in the image src attribute,\n // while the metadata id is the internal image id that we assigned to the image when it was pasted in.\n deleteInlineImageFromServer(imageUpload?.metadata.url, adapter);\n }\n};\nconst deleteInlineImageFromServer = (imageId: string, adapter: ChatAdapter): void => {\n try {\n adapter.deleteImage(imageId);\n } catch (error) {\n console.error(error);\n }\n}; // This function is used to delete the inline image that existed before editing starts\nconst deleteExistingInlineImageForEditBox = (imageId: string, messageId: string, adapter: ChatAdapter): void => {\n if (messageId !== SEND_BOX_UPLOADS_KEY_VALUE) {\n deleteInlineImageFromServer(imageId, adapter);\n }\n};\n/**\n * @internal\n */\nexport const updateContentStringWithUploadedInlineImages = (content: string, imageUploads: Record<string, AttachmentUpload[]> | undefined, messageId: string = SEND_BOX_UPLOADS_KEY_VALUE): string => {\n if (!imageUploads || !imageUploads[messageId]) {\n return content;\n }\n const messageUploads = imageUploads[messageId];\n const document = new DOMParser().parseFromString(content ?? '', 'text/html');\n document.querySelectorAll('img').forEach(img => {\n const uploadInlineImage = messageUploads?.find(upload => !upload.metadata.error && upload.metadata.progress === 1 && upload.metadata.id === img.id);\n if (uploadInlineImage) {\n // ChatSDK uses the respond id provided by the upload response. We store the response id in the image src attribute previously.\n img.id = uploadInlineImage.metadata.url ?? img.id;\n img.src = '';\n }\n });\n content = document.body.innerHTML;\n return content;\n};\n/**\n * @internal\n */\nexport const getImageFileNameFromAttributes = (imageAttributes: Record<string, string>): string => {\n const fileName = imageAttributes[_IMAGE_ATTRIBUTE_INLINE_IMAGE_FILE_NAME_KEY];\n if (!fileName || fileName === '' || fileName === 'undefined' || fileName === 'null') {\n return _DEFAULT_INLINE_IMAGE_FILE_NAME;\n }\n return fileName;\n};"]}
@@ -10,5 +10,25 @@ export interface ChatCompositeStrings {
10
10
  * Chat list header text
11
11
  */
12
12
  chatListHeader: string;
13
+ /**
14
+ * Upload Attachment Button text
15
+ */
16
+ uploadAttachment: string;
17
+ /**
18
+ * Error Message for image data is not provided for image upload
19
+ */
20
+ uploadImageDataNotProvided: string;
21
+ /**
22
+ * Error Message for upload image is too large
23
+ */
24
+ uploadImageIsTooLarge: string;
25
+ /**
26
+ * Error Message for unsupported image extension for image upload
27
+ */
28
+ uploadImageExtensionIsNotAllowed: string;
29
+ /**
30
+ * Error Message for unable to upload image
31
+ */
32
+ uploadImageFailed: string;
13
33
  }
14
34
  //# sourceMappingURL=Strings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Strings.js","sourceRoot":"","sources":["../../../../../../preprocess-dist/react-composites/src/composites/ChatComposite/Strings.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Strings used by the {@link ChatComposite} directly.\n *\n * This strings are in addition to those used by the components from the component library.\n *\n * @public\n */\nexport interface ChatCompositeStrings {\n /**\n * Chat list header text\n */\n chatListHeader: string;\n}"]}
1
+ {"version":3,"file":"Strings.js","sourceRoot":"","sources":["../../../../../../preprocess-dist/react-composites/src/composites/ChatComposite/Strings.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Strings used by the {@link ChatComposite} directly.\n *\n * This strings are in addition to those used by the components from the component library.\n *\n * @public\n */\nexport interface ChatCompositeStrings {\n /**\n * Chat list header text\n */\n chatListHeader: string;\n /**\n * Upload Attachment Button text\n */\n uploadAttachment: string;\n /**\n * Error Message for image data is not provided for image upload\n */\n uploadImageDataNotProvided: string;\n /**\n * Error Message for upload image is too large\n */\n uploadImageIsTooLarge: string;\n /**\n * Error Message for unsupported image extension for image upload\n */\n uploadImageExtensionIsNotAllowed: string;\n /**\n * Error Message for unable to upload image\n */\n uploadImageFailed: string;\n}"]}
@@ -1,10 +1,12 @@
1
1
  import { ChatClientState, StatefulChatClient } from "../../../../../chat-stateful-client/src";
2
2
  import { ChatThreadClient, SendMessageOptions } from '@azure/communication-chat';
3
3
  import { CommunicationTokenCredential, CommunicationUserIdentifier } from '@azure/communication-common';
4
+ import type { UploadChatImageResult } from "../../../../../acs-ui-common/src";
4
5
  import { _TelemetryImplementationHint } from "../../../../../acs-ui-common/src";
5
6
  import { ChatAdapter, ChatAdapterState, MessageDeletedListener, MessageEditedListener, MessageReadListener, MessageReceivedListener, ParticipantsAddedListener, ParticipantsRemovedListener, TopicChangedListener } from './ChatAdapter';
6
7
  import { ResourceDetails } from './ChatAdapter';
7
8
  import { AdapterError } from '../../common/adapters';
9
+ import { MessageOptions } from "../../../../../acs-ui-common/src";
8
10
  import type { OnFetchChatProfileCallback } from './OnFetchProfileCallback';
9
11
  /**
10
12
  * @private
@@ -54,13 +56,15 @@ export declare class AzureCommunicationChatAdapter implements ChatAdapter {
54
56
  getState(): ChatAdapterState;
55
57
  onStateChange(handler: (state: ChatAdapterState) => void): void;
56
58
  offStateChange(handler: (state: ChatAdapterState) => void): void;
57
- sendMessage(content: string, options?: SendMessageOptions): Promise<void>;
59
+ sendMessage(content: string, options?: SendMessageOptions | MessageOptions): Promise<void>;
60
+ uploadImage(image: Blob, imageFilename: string): Promise<UploadChatImageResult>;
61
+ deleteImage(imageId: string): Promise<void>;
58
62
  sendReadReceipt(chatMessageId: string): Promise<void>;
59
63
  sendTypingIndicator(): Promise<void>;
60
64
  removeParticipant(userId: string): Promise<void>;
61
65
  setTopic(topicName: string): Promise<void>;
62
66
  loadPreviousChatMessages(messagesToLoad: number): Promise<boolean>;
63
- updateMessage(messageId: string, content: string, options?: Record<string, string>): Promise<void>;
67
+ updateMessage(messageId: string, content: string, options?: Record<string, string> | MessageOptions): Promise<void>;
64
68
  deleteMessage(messageId: string): Promise<void>;
65
69
  downloadResourceToCache(resourceDetails: ResourceDetails): Promise<void>;
66
70
  removeResourceFromCache(resourceDetails: ResourceDetails): void;
@@ -74,6 +74,7 @@ export class ChatContext {
74
74
  thread,
75
75
  latestErrors: clientState.latestErrors
76
76
  };
77
+ updatedState = Object.assign({}, updatedState);
77
78
  this.setState(updatedState);
78
79
  }
79
80
  }
@@ -106,6 +107,8 @@ export class AzureCommunicationChatAdapter {
106
107
  this.dispose = this.dispose.bind(this);
107
108
  this.fetchInitialData = this.fetchInitialData.bind(this);
108
109
  this.sendMessage = this.sendMessage.bind(this);
110
+ this.uploadImage = this.uploadImage.bind(this);
111
+ this.deleteImage = this.deleteImage.bind(this);
109
112
  this.sendReadReceipt = this.sendReadReceipt.bind(this);
110
113
  this.sendTypingIndicator = this.sendTypingIndicator.bind(this);
111
114
  this.updateMessage = this.updateMessage.bind(this);
@@ -166,6 +169,20 @@ export class AzureCommunicationChatAdapter {
166
169
  }));
167
170
  });
168
171
  }
172
+ uploadImage(image, imageFilename) {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ return yield this.asyncTeeErrorToEventEmitter(() => __awaiter(this, void 0, void 0, function* () {
175
+ return yield this.handlers.onUploadImage(image, imageFilename);
176
+ }));
177
+ });
178
+ }
179
+ deleteImage(imageId) {
180
+ return __awaiter(this, void 0, void 0, function* () {
181
+ return yield this.asyncTeeErrorToEventEmitter(() => __awaiter(this, void 0, void 0, function* () {
182
+ return yield this.handlers.onDeleteImage(imageId);
183
+ }));
184
+ });
185
+ }
169
186
  sendReadReceipt(chatMessageId) {
170
187
  return __awaiter(this, void 0, void 0, function* () {
171
188
  yield this.asyncTeeErrorToEventEmitter(() => __awaiter(this, void 0, void 0, function* () {
@@ -204,6 +221,25 @@ export class AzureCommunicationChatAdapter {
204
221
  updateMessage(messageId, content, options) {
205
222
  return __awaiter(this, void 0, void 0, function* () {
206
223
  return yield this.asyncTeeErrorToEventEmitter(() => __awaiter(this, void 0, void 0, function* () {
224
+ var _a;
225
+ const messageOptions = {};
226
+ if (options && (
227
+ // if options.attachments is an array or undefined (for removal all attachments),
228
+ // then given options is a MessageOptions
229
+ Array.isArray(options.attachments) || options.attachments === undefined)) {
230
+ messageOptions.attachments = (_a = options.attachments) !== null && _a !== void 0 ? _a : [];
231
+ }
232
+ if (options &&
233
+ // if options.metadata is provided, we need to add it in MessageOptions
234
+ options.metadata && typeof options.metadata === 'object') {
235
+ messageOptions.metadata = options.metadata;
236
+ }
237
+ if (options && !('attachments' in options) && !('metadata' in options)) {
238
+ // if options don't have attachments or metadata,
239
+ // then it is a Record<string, string>
240
+ return yield this.handlers.onUpdateMessage(messageId, content, options);
241
+ }
242
+ return yield this.handlers.onUpdateMessage(messageId, content, messageOptions);
207
243
  // metadata is never used in the current stable
208
244
  return yield this.handlers.onUpdateMessage(messageId, content);
209
245
  }));