@magmamath/students-features 0.9.113 → 0.9.114-rc.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 (367) hide show
  1. package/dist/commonjs/features/chatbot/components/ChatInput/RequestHintButton.js.map +1 -1
  2. package/dist/commonjs/features/chatbot/components/ChatMessage/MessageButtonsBlock.js.map +1 -1
  3. package/dist/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.js +8 -48
  4. package/dist/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.js.map +1 -1
  5. package/dist/commonjs/features/chatbot/constants.js +4 -4
  6. package/dist/commonjs/features/chatbot/constants.js.map +1 -1
  7. package/dist/commonjs/features/gifCelebrations/helpers.js +1 -0
  8. package/dist/commonjs/features/gifCelebrations/helpers.js.map +1 -1
  9. package/dist/commonjs/features/voice/constants.js +22 -0
  10. package/dist/commonjs/features/voice/constants.js.map +1 -0
  11. package/dist/commonjs/features/voice/helpers.js +211 -0
  12. package/dist/commonjs/features/voice/helpers.js.map +1 -0
  13. package/dist/commonjs/features/voice/index.js +138 -0
  14. package/dist/commonjs/features/voice/index.js.map +1 -0
  15. package/dist/commonjs/features/voice/model/index.js +68 -0
  16. package/dist/commonjs/features/voice/model/index.js.map +1 -0
  17. package/dist/commonjs/features/voice/playing/components/VoiceIcon.js +49 -0
  18. package/dist/commonjs/features/voice/playing/components/VoiceIcon.js.map +1 -0
  19. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js +208 -0
  20. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +1 -0
  21. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +108 -0
  22. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +1 -0
  23. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js +50 -0
  24. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +1 -0
  25. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +34 -0
  26. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +1 -0
  27. package/dist/commonjs/features/voice/playing/model/Player.model.js +87 -0
  28. package/dist/commonjs/features/voice/playing/model/Player.model.js.map +1 -0
  29. package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js +244 -0
  30. package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js.map +1 -0
  31. package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.js +41 -0
  32. package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +1 -0
  33. package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsDownloader.model.js +39 -0
  34. package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsDownloader.model.js.map +1 -0
  35. package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js +15 -0
  36. package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +1 -0
  37. package/dist/commonjs/features/voice/playing/model/index.js +47 -0
  38. package/dist/commonjs/features/voice/playing/model/index.js.map +1 -0
  39. package/dist/commonjs/features/voice/recording/components/VoiceRecord.js +74 -0
  40. package/dist/commonjs/features/voice/recording/components/VoiceRecord.js.map +1 -0
  41. package/dist/commonjs/features/voice/recording/components/VoiceRecordButton.js +61 -0
  42. package/dist/commonjs/features/voice/recording/components/VoiceRecordButton.js.map +1 -0
  43. package/dist/commonjs/features/voice/recording/components/VoiceRecordDeleteButton.js +35 -0
  44. package/dist/commonjs/features/voice/recording/components/VoiceRecordDeleteButton.js.map +1 -0
  45. package/dist/commonjs/features/voice/recording/components/VoiceRecordDevider.js +27 -0
  46. package/dist/commonjs/features/voice/recording/components/VoiceRecordDevider.js.map +1 -0
  47. package/dist/commonjs/features/voice/recording/components/VoiceRecordTimer.js +50 -0
  48. package/dist/commonjs/features/voice/recording/components/VoiceRecordTimer.js.map +1 -0
  49. package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorder.js +59 -0
  50. package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorder.js.map +1 -0
  51. package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.js +22 -0
  52. package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.js.map +1 -0
  53. package/dist/commonjs/features/voice/recording/modal/ModalFooterButtons.js +53 -0
  54. package/dist/commonjs/features/voice/recording/modal/ModalFooterButtons.js.map +1 -0
  55. package/dist/commonjs/features/voice/recording/modal/VoiceRecordDeleteModal.js +78 -0
  56. package/dist/commonjs/features/voice/recording/modal/VoiceRecordDeleteModal.js.map +1 -0
  57. package/dist/commonjs/features/voice/recording/modal/VoiceRecordUndoModal.js +51 -0
  58. package/dist/commonjs/features/voice/recording/modal/VoiceRecordUndoModal.js.map +1 -0
  59. package/dist/commonjs/features/voice/recording/model/Recorder.model.js +54 -0
  60. package/dist/commonjs/features/voice/recording/model/Recorder.model.js.map +1 -0
  61. package/dist/commonjs/features/voice/recording/model/Uploader.model.js +44 -0
  62. package/dist/commonjs/features/voice/recording/model/Uploader.model.js.map +1 -0
  63. package/dist/commonjs/features/voice/recording/model/VoiceRecord.model.js +239 -0
  64. package/dist/commonjs/features/voice/recording/model/VoiceRecord.model.js.map +1 -0
  65. package/dist/commonjs/features/voice/recording/model/VoiceRecordCollection.js +30 -0
  66. package/dist/commonjs/features/voice/recording/model/VoiceRecordCollection.js.map +1 -0
  67. package/dist/commonjs/features/voice/recording/model/index.js +34 -0
  68. package/dist/commonjs/features/voice/recording/model/index.js.map +1 -0
  69. package/dist/commonjs/features/voice/types.js +6 -0
  70. package/dist/commonjs/features/voice/types.js.map +1 -0
  71. package/dist/commonjs/index.js +12 -0
  72. package/dist/commonjs/index.js.map +1 -1
  73. package/dist/commonjs/shared/components/PlayButton.js +70 -0
  74. package/dist/commonjs/shared/components/PlayButton.js.map +1 -0
  75. package/dist/commonjs/shared/translation/localization/ca.json +17 -0
  76. package/dist/commonjs/shared/translation/localization/de.json +17 -0
  77. package/dist/commonjs/shared/translation/localization/en.json +17 -0
  78. package/dist/commonjs/shared/translation/localization/gb.json +17 -0
  79. package/dist/commonjs/shared/translation/localization/sct.json +17 -0
  80. package/dist/commonjs/shared/translation/localization/sw.json +17 -0
  81. package/dist/module/features/chatbot/components/ChatInput/RequestHintButton.js.map +1 -1
  82. package/dist/module/features/chatbot/components/ChatMessage/MessageButtonsBlock.js.map +1 -1
  83. package/dist/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.js +9 -49
  84. package/dist/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.js.map +1 -1
  85. package/dist/module/features/chatbot/constants.js +5 -5
  86. package/dist/module/features/chatbot/constants.js.map +1 -1
  87. package/dist/module/features/gifCelebrations/helpers.js +1 -0
  88. package/dist/module/features/gifCelebrations/helpers.js.map +1 -1
  89. package/dist/module/features/voice/constants.js +18 -0
  90. package/dist/module/features/voice/constants.js.map +1 -0
  91. package/dist/module/features/voice/helpers.js +194 -0
  92. package/dist/module/features/voice/helpers.js.map +1 -0
  93. package/dist/module/features/voice/index.js +20 -0
  94. package/dist/module/features/voice/index.js.map +1 -0
  95. package/dist/module/features/voice/model/index.js +15 -0
  96. package/dist/module/features/voice/model/index.js.map +1 -0
  97. package/dist/module/features/voice/playing/components/VoiceIcon.js +41 -0
  98. package/dist/module/features/voice/playing/components/VoiceIcon.js.map +1 -0
  99. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js +201 -0
  100. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +1 -0
  101. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +102 -0
  102. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +1 -0
  103. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js +45 -0
  104. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +1 -0
  105. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +29 -0
  106. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +1 -0
  107. package/dist/module/features/voice/playing/model/Player.model.js +82 -0
  108. package/dist/module/features/voice/playing/model/Player.model.js.map +1 -0
  109. package/dist/module/features/voice/playing/model/VoicePlayer.model.js +234 -0
  110. package/dist/module/features/voice/playing/model/VoicePlayer.model.js.map +1 -0
  111. package/dist/module/features/voice/playing/model/VoiceTranscriptionsCollection.js +36 -0
  112. package/dist/module/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +1 -0
  113. package/dist/module/features/voice/playing/model/VoiceTranscriptionsDownloader.model.js +34 -0
  114. package/dist/module/features/voice/playing/model/VoiceTranscriptionsDownloader.model.js.map +1 -0
  115. package/dist/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js +10 -0
  116. package/dist/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +1 -0
  117. package/dist/module/features/voice/playing/model/index.js +8 -0
  118. package/dist/module/features/voice/playing/model/index.js.map +1 -0
  119. package/dist/module/features/voice/recording/components/VoiceRecord.js +67 -0
  120. package/dist/module/features/voice/recording/components/VoiceRecord.js.map +1 -0
  121. package/dist/module/features/voice/recording/components/VoiceRecordButton.js +55 -0
  122. package/dist/module/features/voice/recording/components/VoiceRecordButton.js.map +1 -0
  123. package/dist/module/features/voice/recording/components/VoiceRecordDeleteButton.js +29 -0
  124. package/dist/module/features/voice/recording/components/VoiceRecordDeleteButton.js.map +1 -0
  125. package/dist/module/features/voice/recording/components/VoiceRecordDevider.js +21 -0
  126. package/dist/module/features/voice/recording/components/VoiceRecordDevider.js.map +1 -0
  127. package/dist/module/features/voice/recording/components/VoiceRecordTimer.js +44 -0
  128. package/dist/module/features/voice/recording/components/VoiceRecordTimer.js.map +1 -0
  129. package/dist/module/features/voice/recording/hooks/useVoiceRecorder.js +54 -0
  130. package/dist/module/features/voice/recording/hooks/useVoiceRecorder.js.map +1 -0
  131. package/dist/module/features/voice/recording/hooks/useVoiceRecorderAnimation.js +17 -0
  132. package/dist/module/features/voice/recording/hooks/useVoiceRecorderAnimation.js.map +1 -0
  133. package/dist/module/features/voice/recording/modal/ModalFooterButtons.js +47 -0
  134. package/dist/module/features/voice/recording/modal/ModalFooterButtons.js.map +1 -0
  135. package/dist/module/features/voice/recording/modal/VoiceRecordDeleteModal.js +71 -0
  136. package/dist/module/features/voice/recording/modal/VoiceRecordDeleteModal.js.map +1 -0
  137. package/dist/module/features/voice/recording/modal/VoiceRecordUndoModal.js +45 -0
  138. package/dist/module/features/voice/recording/modal/VoiceRecordUndoModal.js.map +1 -0
  139. package/dist/module/features/voice/recording/model/Recorder.model.js +49 -0
  140. package/dist/module/features/voice/recording/model/Recorder.model.js.map +1 -0
  141. package/dist/module/features/voice/recording/model/Uploader.model.js +39 -0
  142. package/dist/module/features/voice/recording/model/Uploader.model.js.map +1 -0
  143. package/dist/module/features/voice/recording/model/VoiceRecord.model.js +234 -0
  144. package/dist/module/features/voice/recording/model/VoiceRecord.model.js.map +1 -0
  145. package/dist/module/features/voice/recording/model/VoiceRecordCollection.js +25 -0
  146. package/dist/module/features/voice/recording/model/VoiceRecordCollection.js.map +1 -0
  147. package/dist/module/features/voice/recording/model/index.js +7 -0
  148. package/dist/module/features/voice/recording/model/index.js.map +1 -0
  149. package/dist/module/features/voice/types.js +4 -0
  150. package/dist/module/features/voice/types.js.map +1 -0
  151. package/dist/module/index.js +1 -0
  152. package/dist/module/index.js.map +1 -1
  153. package/dist/module/shared/components/PlayButton.js +64 -0
  154. package/dist/module/shared/components/PlayButton.js.map +1 -0
  155. package/dist/module/shared/translation/localization/ca.json +17 -0
  156. package/dist/module/shared/translation/localization/de.json +17 -0
  157. package/dist/module/shared/translation/localization/en.json +17 -0
  158. package/dist/module/shared/translation/localization/gb.json +17 -0
  159. package/dist/module/shared/translation/localization/sct.json +17 -0
  160. package/dist/module/shared/translation/localization/sw.json +17 -0
  161. package/dist/typescript/commonjs/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +1 -1
  162. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageButtonsBlock.d.ts.map +1 -1
  163. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts +2 -2
  164. package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts.map +1 -1
  165. package/dist/typescript/commonjs/features/chatbot/constants.d.ts +5 -5
  166. package/dist/typescript/commonjs/features/chatbot/constants.d.ts.map +1 -1
  167. package/dist/typescript/commonjs/features/gifCelebrations/helpers.d.ts.map +1 -1
  168. package/dist/typescript/commonjs/features/voice/constants.d.ts +15 -0
  169. package/dist/typescript/commonjs/features/voice/constants.d.ts.map +1 -0
  170. package/dist/typescript/commonjs/features/voice/helpers.d.ts +46 -0
  171. package/dist/typescript/commonjs/features/voice/helpers.d.ts.map +1 -0
  172. package/dist/typescript/commonjs/features/voice/index.d.ts +13 -0
  173. package/dist/typescript/commonjs/features/voice/index.d.ts.map +1 -0
  174. package/dist/typescript/commonjs/features/voice/model/index.d.ts +11 -0
  175. package/dist/typescript/commonjs/features/voice/model/index.d.ts.map +1 -0
  176. package/dist/typescript/commonjs/features/voice/playing/components/VoiceIcon.d.ts +8 -0
  177. package/dist/typescript/commonjs/features/voice/playing/components/VoiceIcon.d.ts.map +1 -0
  178. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts +15 -0
  179. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +1 -0
  180. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +12 -0
  181. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +1 -0
  182. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts +16 -0
  183. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +1 -0
  184. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +11 -0
  185. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +1 -0
  186. package/dist/typescript/commonjs/features/voice/playing/model/Player.model.d.ts +21 -0
  187. package/dist/typescript/commonjs/features/voice/playing/model/Player.model.d.ts.map +1 -0
  188. package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts +41 -0
  189. package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -0
  190. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts +26 -0
  191. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +1 -0
  192. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsDownloader.model.d.ts +18 -0
  193. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsDownloader.model.d.ts.map +1 -0
  194. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts +7 -0
  195. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +1 -0
  196. package/dist/typescript/commonjs/features/voice/playing/model/index.d.ts +7 -0
  197. package/dist/typescript/commonjs/features/voice/playing/model/index.d.ts.map +1 -0
  198. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecord.d.ts +10 -0
  199. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecord.d.ts.map +1 -0
  200. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordButton.d.ts +10 -0
  201. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordButton.d.ts.map +1 -0
  202. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordDeleteButton.d.ts +8 -0
  203. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordDeleteButton.d.ts.map +1 -0
  204. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordDevider.d.ts +3 -0
  205. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordDevider.d.ts.map +1 -0
  206. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordTimer.d.ts +11 -0
  207. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordTimer.d.ts.map +1 -0
  208. package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorder.d.ts +5 -0
  209. package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorder.d.ts.map +1 -0
  210. package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts +6 -0
  211. package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts.map +1 -0
  212. package/dist/typescript/commonjs/features/voice/recording/modal/ModalFooterButtons.d.ts +12 -0
  213. package/dist/typescript/commonjs/features/voice/recording/modal/ModalFooterButtons.d.ts.map +1 -0
  214. package/dist/typescript/commonjs/features/voice/recording/modal/VoiceRecordDeleteModal.d.ts +11 -0
  215. package/dist/typescript/commonjs/features/voice/recording/modal/VoiceRecordDeleteModal.d.ts.map +1 -0
  216. package/dist/typescript/commonjs/features/voice/recording/modal/VoiceRecordUndoModal.d.ts +11 -0
  217. package/dist/typescript/commonjs/features/voice/recording/modal/VoiceRecordUndoModal.d.ts.map +1 -0
  218. package/dist/typescript/commonjs/features/voice/recording/model/Recorder.model.d.ts +19 -0
  219. package/dist/typescript/commonjs/features/voice/recording/model/Recorder.model.d.ts.map +1 -0
  220. package/dist/typescript/commonjs/features/voice/recording/model/Uploader.model.d.ts +18 -0
  221. package/dist/typescript/commonjs/features/voice/recording/model/Uploader.model.d.ts.map +1 -0
  222. package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecord.model.d.ts +50 -0
  223. package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecord.model.d.ts.map +1 -0
  224. package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecordCollection.d.ts +10 -0
  225. package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecordCollection.d.ts.map +1 -0
  226. package/dist/typescript/commonjs/features/voice/recording/model/index.d.ts +5 -0
  227. package/dist/typescript/commonjs/features/voice/recording/model/index.d.ts.map +1 -0
  228. package/dist/typescript/commonjs/features/voice/types.d.ts +58 -0
  229. package/dist/typescript/commonjs/features/voice/types.d.ts.map +1 -0
  230. package/dist/typescript/commonjs/index.d.ts +1 -0
  231. package/dist/typescript/commonjs/index.d.ts.map +1 -1
  232. package/dist/typescript/commonjs/shared/components/PlayButton.d.ts +18 -0
  233. package/dist/typescript/commonjs/shared/components/PlayButton.d.ts.map +1 -0
  234. package/dist/typescript/commonjs/shared/translation/constants.d.ts +102 -0
  235. package/dist/typescript/commonjs/shared/translation/constants.d.ts.map +1 -1
  236. package/dist/typescript/commonjs/shared/translation/model.d.ts +34 -0
  237. package/dist/typescript/commonjs/shared/translation/model.d.ts.map +1 -1
  238. package/dist/typescript/commonjs/types/common.types.d.ts +3 -0
  239. package/dist/typescript/commonjs/types/common.types.d.ts.map +1 -1
  240. package/dist/typescript/module/features/chatbot/components/ChatInput/RequestHintButton.d.ts.map +1 -1
  241. package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageButtonsBlock.d.ts.map +1 -1
  242. package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts +2 -2
  243. package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts.map +1 -1
  244. package/dist/typescript/module/features/chatbot/constants.d.ts +5 -5
  245. package/dist/typescript/module/features/chatbot/constants.d.ts.map +1 -1
  246. package/dist/typescript/module/features/gifCelebrations/helpers.d.ts.map +1 -1
  247. package/dist/typescript/module/features/voice/constants.d.ts +15 -0
  248. package/dist/typescript/module/features/voice/constants.d.ts.map +1 -0
  249. package/dist/typescript/module/features/voice/helpers.d.ts +46 -0
  250. package/dist/typescript/module/features/voice/helpers.d.ts.map +1 -0
  251. package/dist/typescript/module/features/voice/index.d.ts +13 -0
  252. package/dist/typescript/module/features/voice/index.d.ts.map +1 -0
  253. package/dist/typescript/module/features/voice/model/index.d.ts +11 -0
  254. package/dist/typescript/module/features/voice/model/index.d.ts.map +1 -0
  255. package/dist/typescript/module/features/voice/playing/components/VoiceIcon.d.ts +8 -0
  256. package/dist/typescript/module/features/voice/playing/components/VoiceIcon.d.ts.map +1 -0
  257. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts +15 -0
  258. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +1 -0
  259. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +12 -0
  260. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +1 -0
  261. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts +16 -0
  262. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +1 -0
  263. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +11 -0
  264. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +1 -0
  265. package/dist/typescript/module/features/voice/playing/model/Player.model.d.ts +21 -0
  266. package/dist/typescript/module/features/voice/playing/model/Player.model.d.ts.map +1 -0
  267. package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts +41 -0
  268. package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -0
  269. package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts +26 -0
  270. package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +1 -0
  271. package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsDownloader.model.d.ts +18 -0
  272. package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsDownloader.model.d.ts.map +1 -0
  273. package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts +7 -0
  274. package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +1 -0
  275. package/dist/typescript/module/features/voice/playing/model/index.d.ts +7 -0
  276. package/dist/typescript/module/features/voice/playing/model/index.d.ts.map +1 -0
  277. package/dist/typescript/module/features/voice/recording/components/VoiceRecord.d.ts +10 -0
  278. package/dist/typescript/module/features/voice/recording/components/VoiceRecord.d.ts.map +1 -0
  279. package/dist/typescript/module/features/voice/recording/components/VoiceRecordButton.d.ts +10 -0
  280. package/dist/typescript/module/features/voice/recording/components/VoiceRecordButton.d.ts.map +1 -0
  281. package/dist/typescript/module/features/voice/recording/components/VoiceRecordDeleteButton.d.ts +8 -0
  282. package/dist/typescript/module/features/voice/recording/components/VoiceRecordDeleteButton.d.ts.map +1 -0
  283. package/dist/typescript/module/features/voice/recording/components/VoiceRecordDevider.d.ts +3 -0
  284. package/dist/typescript/module/features/voice/recording/components/VoiceRecordDevider.d.ts.map +1 -0
  285. package/dist/typescript/module/features/voice/recording/components/VoiceRecordTimer.d.ts +11 -0
  286. package/dist/typescript/module/features/voice/recording/components/VoiceRecordTimer.d.ts.map +1 -0
  287. package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorder.d.ts +5 -0
  288. package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorder.d.ts.map +1 -0
  289. package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts +6 -0
  290. package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorderAnimation.d.ts.map +1 -0
  291. package/dist/typescript/module/features/voice/recording/modal/ModalFooterButtons.d.ts +12 -0
  292. package/dist/typescript/module/features/voice/recording/modal/ModalFooterButtons.d.ts.map +1 -0
  293. package/dist/typescript/module/features/voice/recording/modal/VoiceRecordDeleteModal.d.ts +11 -0
  294. package/dist/typescript/module/features/voice/recording/modal/VoiceRecordDeleteModal.d.ts.map +1 -0
  295. package/dist/typescript/module/features/voice/recording/modal/VoiceRecordUndoModal.d.ts +11 -0
  296. package/dist/typescript/module/features/voice/recording/modal/VoiceRecordUndoModal.d.ts.map +1 -0
  297. package/dist/typescript/module/features/voice/recording/model/Recorder.model.d.ts +19 -0
  298. package/dist/typescript/module/features/voice/recording/model/Recorder.model.d.ts.map +1 -0
  299. package/dist/typescript/module/features/voice/recording/model/Uploader.model.d.ts +18 -0
  300. package/dist/typescript/module/features/voice/recording/model/Uploader.model.d.ts.map +1 -0
  301. package/dist/typescript/module/features/voice/recording/model/VoiceRecord.model.d.ts +50 -0
  302. package/dist/typescript/module/features/voice/recording/model/VoiceRecord.model.d.ts.map +1 -0
  303. package/dist/typescript/module/features/voice/recording/model/VoiceRecordCollection.d.ts +10 -0
  304. package/dist/typescript/module/features/voice/recording/model/VoiceRecordCollection.d.ts.map +1 -0
  305. package/dist/typescript/module/features/voice/recording/model/index.d.ts +5 -0
  306. package/dist/typescript/module/features/voice/recording/model/index.d.ts.map +1 -0
  307. package/dist/typescript/module/features/voice/types.d.ts +58 -0
  308. package/dist/typescript/module/features/voice/types.d.ts.map +1 -0
  309. package/dist/typescript/module/index.d.ts +1 -0
  310. package/dist/typescript/module/index.d.ts.map +1 -1
  311. package/dist/typescript/module/shared/components/PlayButton.d.ts +18 -0
  312. package/dist/typescript/module/shared/components/PlayButton.d.ts.map +1 -0
  313. package/dist/typescript/module/shared/translation/constants.d.ts +102 -0
  314. package/dist/typescript/module/shared/translation/constants.d.ts.map +1 -1
  315. package/dist/typescript/module/shared/translation/model.d.ts +34 -0
  316. package/dist/typescript/module/shared/translation/model.d.ts.map +1 -1
  317. package/dist/typescript/module/types/common.types.d.ts +3 -0
  318. package/dist/typescript/module/types/common.types.d.ts.map +1 -1
  319. package/package.json +11 -4
  320. package/src/features/chatbot/components/ChatInput/RequestHintButton.tsx +0 -1
  321. package/src/features/chatbot/components/ChatMessage/MessageButtonsBlock.tsx +1 -1
  322. package/src/features/chatbot/components/ChatMessage/MessageTextToSpeech.tsx +9 -51
  323. package/src/features/chatbot/constants.ts +4 -4
  324. package/src/features/gifCelebrations/helpers.ts +1 -0
  325. package/src/features/voice/constants.ts +14 -0
  326. package/src/features/voice/helpers.ts +254 -0
  327. package/src/features/voice/index.ts +17 -0
  328. package/src/features/voice/model/index.ts +13 -0
  329. package/src/features/voice/playing/components/VoiceIcon.tsx +38 -0
  330. package/src/features/voice/playing/components/VoiceTranscriptionsDropdown.tsx +239 -0
  331. package/src/features/voice/playing/components/VoiceTranscriptionsDropdownItem.tsx +127 -0
  332. package/src/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.ts +54 -0
  333. package/src/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.ts +40 -0
  334. package/src/features/voice/playing/model/Player.model.ts +92 -0
  335. package/src/features/voice/playing/model/VoicePlayer.model.ts +282 -0
  336. package/src/features/voice/playing/model/VoiceTranscriptionsCollection.ts +53 -0
  337. package/src/features/voice/playing/model/VoiceTranscriptionsDownloader.model.ts +43 -0
  338. package/src/features/voice/playing/model/VoiceTranscriptionsDropdown.model.ts +12 -0
  339. package/src/features/voice/playing/model/index.ts +6 -0
  340. package/src/features/voice/recording/components/VoiceRecord.tsx +65 -0
  341. package/src/features/voice/recording/components/VoiceRecordButton.tsx +63 -0
  342. package/src/features/voice/recording/components/VoiceRecordDeleteButton.tsx +25 -0
  343. package/src/features/voice/recording/components/VoiceRecordDevider.tsx +17 -0
  344. package/src/features/voice/recording/components/VoiceRecordTimer.tsx +49 -0
  345. package/src/features/voice/recording/hooks/useVoiceRecorder.ts +62 -0
  346. package/src/features/voice/recording/hooks/useVoiceRecorderAnimation.ts +19 -0
  347. package/src/features/voice/recording/modal/ModalFooterButtons.tsx +54 -0
  348. package/src/features/voice/recording/modal/VoiceRecordDeleteModal.tsx +82 -0
  349. package/src/features/voice/recording/modal/VoiceRecordUndoModal.tsx +50 -0
  350. package/src/features/voice/recording/model/Recorder.model.ts +62 -0
  351. package/src/features/voice/recording/model/Uploader.model.ts +48 -0
  352. package/src/features/voice/recording/model/VoiceRecord.model.ts +278 -0
  353. package/src/features/voice/recording/model/VoiceRecordCollection.ts +26 -0
  354. package/src/features/voice/recording/model/index.ts +4 -0
  355. package/src/features/voice/types.ts +69 -0
  356. package/src/index.ts +1 -0
  357. package/src/shared/components/PlayButton.tsx +84 -0
  358. package/src/shared/translation/localization/ca.json +17 -0
  359. package/src/shared/translation/localization/de.json +17 -0
  360. package/src/shared/translation/localization/en.json +17 -0
  361. package/src/shared/translation/localization/gb.json +17 -0
  362. package/src/shared/translation/localization/sct.json +17 -0
  363. package/src/shared/translation/localization/sw.json +17 -0
  364. package/src/types/common.types.ts +1 -0
  365. package/dist/commonjs/features/chatbot/TTS_HIGHLIGHTING.md +0 -120
  366. package/dist/module/features/chatbot/TTS_HIGHLIGHTING.md +0 -120
  367. package/src/features/chatbot/TTS_HIGHLIGHTING.md +0 -120
@@ -0,0 +1,19 @@
1
+ import { useAnimatedStyle, withTiming } from 'react-native-reanimated'
2
+ import { VOICE_RECORDER_CONTAINER_SIZES } from '../../constants'
3
+
4
+ export const useVoiceRecorderAnimation = (isExpanded: boolean) => {
5
+ const containerAnimatedStyle = useAnimatedStyle(() => {
6
+ return {
7
+ height: withTiming(
8
+ isExpanded
9
+ ? VOICE_RECORDER_CONTAINER_SIZES.EXPANDED
10
+ : VOICE_RECORDER_CONTAINER_SIZES.COLLAPSED,
11
+ {
12
+ duration: 280,
13
+ },
14
+ ),
15
+ }
16
+ }, [isExpanded])
17
+
18
+ return { containerAnimatedStyle }
19
+ }
@@ -0,0 +1,54 @@
1
+ import React from 'react'
2
+ import { Button, ButtonColor, ButtonSize, ButtonVariant, SPACING } from '@magmamath/react-native-ui'
3
+ import { StyleSheet, View } from 'react-native'
4
+ import { useText } from '../../../../shared/translation'
5
+ import { TranslationKeys } from '../../../../shared/translation/types'
6
+
7
+ type ModalFooterButtonsProps = {
8
+ onCancel: () => void
9
+ onConfirm: () => void
10
+ confirmLabel: TranslationKeys
11
+ confirmColor?: ButtonColor
12
+ }
13
+
14
+ export const ModalFooterButtons = ({
15
+ onCancel,
16
+ onConfirm,
17
+ confirmLabel,
18
+ confirmColor = ButtonColor.BLUE,
19
+ }: ModalFooterButtonsProps) => {
20
+ const t = useText()
21
+
22
+ return (
23
+ <View style={styles.container}>
24
+ <Button
25
+ style={{ text: styles.buttonLabel }}
26
+ variant={ButtonVariant.TERTIARY}
27
+ size={ButtonSize.LARGE}
28
+ onPress={onCancel}
29
+ >
30
+ {t('voice.cancel')}
31
+ </Button>
32
+ <Button
33
+ colorScheme={confirmColor}
34
+ variant={ButtonVariant.PRIMARY}
35
+ size={ButtonSize.LARGE}
36
+ onPress={onConfirm}
37
+ style={{ text: styles.buttonLabel }}
38
+ >
39
+ {t(confirmLabel)}
40
+ </Button>
41
+ </View>
42
+ )
43
+ }
44
+
45
+ const styles = StyleSheet.create({
46
+ container: {
47
+ flexDirection: 'row',
48
+ alignItems: 'center',
49
+ gap: SPACING[200],
50
+ },
51
+ buttonLabel: {
52
+ textTransform: 'uppercase',
53
+ },
54
+ })
@@ -0,0 +1,82 @@
1
+ import React, { useEffect } from 'react'
2
+ import { BaseModal, ButtonColor } from '@magmamath/react-native-ui'
3
+ import { StyleSheet } from 'react-native'
4
+ import { useUnit } from 'effector-react'
5
+ import { VoiceRecorderState } from '../../constants'
6
+ import { useText } from '../../../../shared/translation'
7
+ import { ModalFooterButtons } from './ModalFooterButtons'
8
+ import { VoiceRecordModalParams } from '../../types'
9
+
10
+ type VoiceRecordDeleteModalComponentProps = {
11
+ modal: {
12
+ closeModal: () => void
13
+ params: VoiceRecordModalParams
14
+ }
15
+ }
16
+
17
+ export const VoiceRecordDeleteModal = ({
18
+ modal: { closeModal, params },
19
+ }: VoiceRecordDeleteModalComponentProps) => {
20
+ const t = useText()
21
+ const { model } = params
22
+
23
+ const recorderState = useUnit(model.recorderModel.$voiceRecordState)
24
+
25
+ const handleDelete = () => {
26
+ if (recorderState === VoiceRecorderState.PAUSED) {
27
+ // if recording is paused, we need to start it again to ensure the recorder is in a consistent state before deletion
28
+ // without .record() browser still will use microphone
29
+ model.recorderModel.recorder.record()
30
+ setTimeout(() => {
31
+ model.stop()
32
+ model.deleteCurrentRecording()
33
+ }, 50)
34
+ closeModal()
35
+ return
36
+ }
37
+
38
+ model.deleteCurrentRecording()
39
+ closeModal()
40
+ }
41
+
42
+ useEffect(() => {
43
+ if (recorderState === VoiceRecorderState.RECORDING) {
44
+ model.recorderModel.recorder.pause()
45
+ }
46
+
47
+ return () => {
48
+ if (model.recorderModel.$voiceRecordState.getState() === VoiceRecorderState.PAUSED) {
49
+ try {
50
+ model.recorderModel.recorder.record()
51
+ } catch (error) {
52
+ console.error(`Failed to resume recording: ${error}`)
53
+ }
54
+ }
55
+ }
56
+ }, [])
57
+
58
+ return (
59
+ <BaseModal
60
+ style={{
61
+ container: styles.modalContainer,
62
+ }}
63
+ header={t('voice.deleteRecording')}
64
+ content={t('voice.youWontBeAbleToRecover')}
65
+ footer={
66
+ <ModalFooterButtons
67
+ onCancel={closeModal}
68
+ onConfirm={handleDelete}
69
+ confirmLabel="voice.delete"
70
+ confirmColor={ButtonColor.RED}
71
+ />
72
+ }
73
+ />
74
+ )
75
+ }
76
+
77
+ const styles = StyleSheet.create({
78
+ modalContainer: {
79
+ width: 600,
80
+ height: 268,
81
+ },
82
+ })
@@ -0,0 +1,50 @@
1
+ import React from 'react'
2
+ import { BaseModal } from '@magmamath/react-native-ui'
3
+ import { StyleSheet } from 'react-native'
4
+ import { useText } from '../../../../shared/translation'
5
+ import { ModalFooterButtons } from './ModalFooterButtons'
6
+ import { VoiceRecordModalParams } from '../../types'
7
+
8
+ type VoiceRecordUndoModalProps = {
9
+ modal: {
10
+ closeModal: () => void
11
+ params: VoiceRecordModalParams
12
+ }
13
+ }
14
+
15
+ export const VoiceRecordUndoModal = ({
16
+ modal: { closeModal, params },
17
+ }: VoiceRecordUndoModalProps) => {
18
+ const t = useText()
19
+ const { model } = params
20
+
21
+ const handleRedo = () => {
22
+ model.deleteCurrentRecording({ notification: false })
23
+ closeModal()
24
+ model.initializeRecording()
25
+ }
26
+
27
+ return (
28
+ <BaseModal
29
+ style={{
30
+ container: styles.modalStyle,
31
+ }}
32
+ header={t('voice.redoRecording')}
33
+ content={t('voice.thisWillRemoveRecording')}
34
+ footer={
35
+ <ModalFooterButtons
36
+ onCancel={closeModal}
37
+ onConfirm={handleRedo}
38
+ confirmLabel="voice.redo"
39
+ />
40
+ }
41
+ />
42
+ )
43
+ }
44
+
45
+ const styles = StyleSheet.create({
46
+ modalStyle: {
47
+ width: 600,
48
+ height: 268,
49
+ },
50
+ })
@@ -0,0 +1,62 @@
1
+ import { createEffect, createEvent, restore } from 'effector'
2
+ import { AudioRecorder, setAudioModeAsync } from 'expo-audio'
3
+ import { VoiceRecorderState } from '../../constants'
4
+ import { AvailableAudioInputs } from '../../types'
5
+
6
+ const AUDIO_MODE_CONFIG = {
7
+ playsInSilentMode: true,
8
+ allowsRecording: true,
9
+ } as const
10
+
11
+ type StopResolver<T> = (result: T) => void
12
+
13
+ export class RecorderModel<T = unknown> {
14
+ public recorder!: AudioRecorder
15
+ private stopResolver: StopResolver<T> | null = null
16
+
17
+ public readonly reset = createEvent()
18
+ public readonly setVoiceRecordState = createEvent<VoiceRecorderState>()
19
+ public readonly setAvailableInputs = createEvent<AvailableAudioInputs>()
20
+ public readonly setLastKnownDurationMs = createEvent<number>()
21
+
22
+ public readonly $voiceRecordState = restore(
23
+ this.setVoiceRecordState,
24
+ VoiceRecorderState.IDLE,
25
+ ).reset(this.reset)
26
+ public readonly $availableInputs = restore(this.setAvailableInputs, [])
27
+ public readonly $lastKnownDurationMs = restore(this.setLastKnownDurationMs, 0).reset(this.reset)
28
+
29
+ public readonly start = createEffect(async () => {
30
+ try {
31
+ await setAudioModeAsync(AUDIO_MODE_CONFIG)
32
+ await this.recorder.prepareToRecordAsync()
33
+ this.recorder.record()
34
+ } catch (error) {
35
+ console.error('Error starting recording:', error)
36
+ throw error
37
+ }
38
+ })
39
+
40
+ public readonly stop = createEffect(() => {
41
+ if (!this.recorder.getStatus().isRecording) return
42
+ return this.recorder.stop()
43
+ })
44
+
45
+ public stopAndAwaitResult(): Promise<T> {
46
+ return new Promise((resolve) => {
47
+ this.stopResolver = resolve
48
+ this.recorder.getStatus().isRecording && this.recorder.stop()
49
+ })
50
+ }
51
+
52
+ public resolveRecord(result: T): void {
53
+ if (this.stopResolver) {
54
+ this.stopResolver(result)
55
+ this.stopResolver = null
56
+ }
57
+ }
58
+
59
+ public clearStopResolver(): void {
60
+ this.stopResolver = null
61
+ }
62
+ }
@@ -0,0 +1,48 @@
1
+ import { createEffect } from 'effector'
2
+ import { VoiceRecordCollectionItem, VoiceRecorderApi } from '../../types'
3
+ import { generateAudioFormData, uploadAudioFileRequestGenerator } from '../../helpers'
4
+
5
+ type UploadParams = {
6
+ uri: string
7
+ fileName: string
8
+ durationMs: number
9
+ }
10
+
11
+ type UploadResult = {
12
+ collectionItem: VoiceRecordCollectionItem
13
+ uploadPromise: Promise<any>
14
+ }
15
+
16
+ export class UploaderModel {
17
+ private api!: VoiceRecorderApi
18
+
19
+ public readonly setApi = (api: VoiceRecorderApi) => {
20
+ this.api = api
21
+ }
22
+
23
+ public readonly upload = createEffect(
24
+ async ({ uri, fileName, durationMs }: UploadParams): Promise<UploadResult> => {
25
+ const formData = await generateAudioFormData({
26
+ audioFileUri: uri,
27
+ durationMs,
28
+ fileName,
29
+ })
30
+
31
+ const { uploadAudio, controller } = uploadAudioFileRequestGenerator(formData, this.api)
32
+ const uploadPromise = uploadAudio()
33
+
34
+ const collectionItem: VoiceRecordCollectionItem = {
35
+ durationMs,
36
+ audioUploadPromise: uploadPromise,
37
+ controller,
38
+ uri,
39
+ }
40
+
41
+ return { collectionItem, uploadPromise }
42
+ },
43
+ )
44
+
45
+ public readonly abortUpload = (controller?: AbortController) => {
46
+ controller?.abort()
47
+ }
48
+ }
@@ -0,0 +1,278 @@
1
+ import { attach, combine, createEffect, createEvent, restore, sample, StoreValue } from 'effector'
2
+ import { RecorderModel } from './Recorder.model'
3
+ import { VoiceRecordsCollection } from './VoiceRecordCollection'
4
+ import { UploaderModel } from './Uploader.model'
5
+ import { VoiceRecorderState } from '../../constants'
6
+ import {
7
+ VoiceRecordCollectionItem,
8
+ VoiceRecorderApi,
9
+ VoiceRecordNotificationTypes,
10
+ } from '../../types'
11
+ import { ensureRecordingPermissions, getAvailableInputs } from '../../helpers'
12
+ import { t } from '../../../../shared/translation'
13
+
14
+ type VoiceRecordModelParams = {
15
+ api: VoiceRecorderApi
16
+ notification: VoiceRecordNotificationTypes
17
+ events: VoiceRecordEvents
18
+ }
19
+
20
+ type UploadParams = {
21
+ uri: string
22
+ currentKey: string
23
+ durationMs: number
24
+ }
25
+ type GetRecordingItemParams = {
26
+ key: string
27
+ recorderState: VoiceRecorderState
28
+ }
29
+
30
+ type VoiceRecordEvents = {
31
+ deleteRecord: () => void
32
+ undoRecord: () => void
33
+ }
34
+
35
+ type DeleteCurrentRecordingProps = {
36
+ notification?: boolean
37
+ }
38
+ type DeleteCurrentRecordingValues = {
39
+ currentKey: string
40
+ notification?: boolean
41
+ }
42
+ type RecorderButtonHandlerParams = {
43
+ currentKey: StoreValue<typeof VoiceRecordModel.prototype.$currentKey>
44
+ recorderState: StoreValue<typeof VoiceRecordModel.prototype.recorderModel.$voiceRecordState>
45
+ }
46
+
47
+ export class VoiceRecordModel {
48
+ public readonly recorderModel = new RecorderModel<VoiceRecordCollectionItem>()
49
+ public readonly collection = new VoiceRecordsCollection()
50
+ public readonly uploader = new UploaderModel()
51
+ public readonly api: VoiceRecorderApi
52
+ public readonly notification: VoiceRecordNotificationTypes
53
+ public readonly events: VoiceRecordEvents
54
+ private shouldDiscardRecording = false
55
+
56
+ public readonly setCurrentKey = createEvent<string>()
57
+ public readonly setCurrentRecord = createEvent<any>()
58
+ public readonly reset = createEvent()
59
+ public readonly setIsButtonDisabled = createEvent<boolean>()
60
+ public readonly startAudioUpload = createEvent<string>()
61
+
62
+ public readonly $currentKey = restore(this.setCurrentKey, '')
63
+ public readonly $currentRecord = restore(this.setCurrentRecord, null).reset(this.reset)
64
+
65
+ public readonly $isButtonDisabled = restore(this.setIsButtonDisabled, false)
66
+
67
+ public readonly $isExpanded = combine(
68
+ this.recorderModel.$voiceRecordState,
69
+ this.$currentRecord,
70
+ (recorderState, currentRecord) => {
71
+ if (recorderState !== VoiceRecorderState.IDLE || currentRecord) return true
72
+ return false
73
+ },
74
+ )
75
+
76
+ public readonly deleteAudioRecord = createEffect(async (audioFileId: string) => {
77
+ await this.api.deleteAudioFile(audioFileId)
78
+ })
79
+
80
+ public readonly deleteCurrentRecording = attach({
81
+ source: this.$currentKey,
82
+ mapParams: (props: DeleteCurrentRecordingProps | void, currentKey) => ({
83
+ notification: true,
84
+ ...props,
85
+ currentKey,
86
+ }),
87
+ effect: createEffect(({ currentKey, notification }: DeleteCurrentRecordingValues) => {
88
+ const recordingItem = this.collection.get(currentKey)
89
+
90
+ if (recordingItem?.id) {
91
+ this.deleteAudioRecord(recordingItem.id)
92
+ }
93
+
94
+ this.abortUploadIfInProgress(recordingItem)
95
+ this.resetRecordingState(currentKey)
96
+
97
+ if (notification) {
98
+ this.notification.success(t('voice.recordingDeleted'))
99
+ }
100
+ }),
101
+ })
102
+
103
+ public readonly initializeRecording = attach({
104
+ source: this.$currentRecord,
105
+ effect: createEffect(async (currentRecord: StoreValue<typeof this.$currentRecord>) => {
106
+ if (currentRecord) {
107
+ this.deleteCurrentRecording({ notification: false })
108
+ }
109
+
110
+ const hasPermissions = await ensureRecordingPermissions()
111
+ if (!hasPermissions) {
112
+ this.notification.error(t('voice.noMicrophoneAccess'))
113
+ return
114
+ }
115
+
116
+ const inputs = await getAvailableInputs(this.recorderModel.recorder)
117
+ this.recorderModel.setAvailableInputs(inputs)
118
+
119
+ if (inputs.length === 0) {
120
+ this.notification.error(t('voice.noMicrophoneFound'))
121
+ return
122
+ }
123
+
124
+ return this.recorderModel.start().catch((error) => {
125
+ if (error.name === 'NotAllowedError') {
126
+ this.notification.error(t('voice.noMicrophoneAccessBySystem'))
127
+ }
128
+ })
129
+ }),
130
+ })
131
+
132
+ public readonly stop = createEffect(async () => {
133
+ this.shouldDiscardRecording = true
134
+ await this.recorderModel.stop()
135
+ this.recorderModel.clearStopResolver()
136
+ this.recorderModel.reset()
137
+ })
138
+
139
+ public readonly cleanup = async () => {
140
+ if (this.recorderModel.recorder.getStatus().isRecording) {
141
+ await this.recorderModel.recorder.stop()
142
+ }
143
+ this.recorderModel.reset()
144
+ }
145
+
146
+ public readonly recordingStatusUpdate = (status: any) => {
147
+ if (status.error) {
148
+ this.notification.error(`Recorder error: ${status.error}`)
149
+ this.recorderModel.clearStopResolver()
150
+ this.shouldDiscardRecording = false
151
+ return
152
+ }
153
+ if (status.isFinished && status.url) {
154
+ if (!this.shouldDiscardRecording) {
155
+ this.startAudioUpload(status.url)
156
+ }
157
+ this.shouldDiscardRecording = false
158
+ }
159
+ }
160
+
161
+ public readonly getRecordingItem = attach({
162
+ source: this.recorderModel.$voiceRecordState,
163
+ mapParams: (key: string, recorderState) => ({ key, recorderState }),
164
+ effect: createEffect(async ({ key, recorderState }: GetRecordingItemParams) => {
165
+ try {
166
+ const isRecording = recorderState === VoiceRecorderState.RECORDING
167
+
168
+ if (isRecording) {
169
+ return await this.recorderModel.stopAndAwaitResult()
170
+ }
171
+
172
+ return this.collection.get(key)
173
+ } catch (error) {
174
+ console.error(`Failed to get recording item: ${error}`)
175
+ this.notification.error(t('voice.uploadFailed'))
176
+ return undefined
177
+ }
178
+ }),
179
+ })
180
+
181
+ private abortUploadIfInProgress(recordingItem: ReturnType<VoiceRecordsCollection['get']>) {
182
+ if (!recordingItem?.id && recordingItem?.controller) {
183
+ this.uploader.abortUpload(recordingItem.controller)
184
+ }
185
+ }
186
+
187
+ private resetRecordingState(currentKey: string) {
188
+ this.recorderModel.reset()
189
+ this.reset()
190
+ this.collection.delete(currentKey)
191
+ }
192
+
193
+ private handleAudioUpload = createEffect(
194
+ async ({ uri, currentKey, durationMs }: UploadParams) => {
195
+ const { collectionItem, uploadPromise } = await this.uploader.upload({
196
+ uri,
197
+ fileName: currentKey,
198
+ durationMs,
199
+ })
200
+
201
+ this.collection.add(currentKey, collectionItem)
202
+ this.setCurrentRecord(collectionItem)
203
+ this.recorderModel.resolveRecord(collectionItem)
204
+
205
+ uploadPromise
206
+ .then((data) => {
207
+ if (this.collection.get(currentKey)) {
208
+ this.collection.update(currentKey, { id: data.id })
209
+ }
210
+ })
211
+ .catch((error) => {
212
+ if (error.name === 'CanceledError') return
213
+ this.collection.delete(currentKey)
214
+ this.reset()
215
+ this.notification.error(t('voice.uploadFailed'))
216
+ })
217
+
218
+ return uploadPromise
219
+ },
220
+ )
221
+
222
+ private setupUploadHandler() {
223
+ sample({
224
+ clock: this.startAudioUpload,
225
+ source: {
226
+ currentKey: this.$currentKey,
227
+ durationMs: this.recorderModel.$lastKnownDurationMs,
228
+ },
229
+ filter: ({ currentKey }, uri) => !!uri && !!currentKey,
230
+ fn: ({ currentKey, durationMs }, uri) => ({ currentKey, durationMs, uri }),
231
+ target: this.handleAudioUpload,
232
+ })
233
+ }
234
+
235
+ private setupCurrentRecordSync() {
236
+ sample({
237
+ source: this.$currentKey,
238
+ fn: (currentKey) => this.collection.get(currentKey),
239
+ target: createEffect((recordingItem?: VoiceRecordCollectionItem) => {
240
+ if (!recordingItem) {
241
+ this.reset()
242
+ return
243
+ }
244
+
245
+ this.setCurrentRecord(recordingItem)
246
+ }),
247
+ })
248
+ }
249
+
250
+ public readonly recorderButtonHandler = attach({
251
+ source: {
252
+ currentKey: this.$currentKey,
253
+ recorderState: this.recorderModel.$voiceRecordState,
254
+ },
255
+ effect: createEffect(({ currentKey, recorderState }: RecorderButtonHandlerParams) => {
256
+ if (recorderState === VoiceRecorderState.RECORDING) {
257
+ this.recorderModel.stop()
258
+ return
259
+ }
260
+ if (this.collection.get(currentKey)) {
261
+ this.events.undoRecord()
262
+ return
263
+ }
264
+
265
+ this.initializeRecording()
266
+ }),
267
+ })
268
+
269
+ constructor({ api, notification, events }: VoiceRecordModelParams) {
270
+ this.api = api
271
+ this.notification = notification
272
+ this.events = events
273
+ this.uploader.setApi(api)
274
+
275
+ this.setupUploadHandler()
276
+ this.setupCurrentRecordSync()
277
+ }
278
+ }
@@ -0,0 +1,26 @@
1
+ import { VoiceRecordCollectionItem } from '../../types'
2
+
3
+ export class VoiceRecordsCollection {
4
+ public readonly collection: Map<string, VoiceRecordCollectionItem> = new Map()
5
+
6
+ public add(key: string, item: VoiceRecordCollectionItem) {
7
+ this.collection.set(key, item)
8
+ }
9
+
10
+ public update(key: string, item: Partial<VoiceRecordCollectionItem>) {
11
+ const existingItem = this.collection.get(key) || {}
12
+ this.collection.set(key, { ...existingItem, ...item })
13
+ }
14
+
15
+ public delete(key: string) {
16
+ this.collection.delete(key)
17
+ }
18
+
19
+ public get(key: string) {
20
+ return this.collection.get(key)
21
+ }
22
+
23
+ public clear() {
24
+ this.collection.clear()
25
+ }
26
+ }
@@ -0,0 +1,4 @@
1
+ export { VoiceRecordModel } from './VoiceRecord.model'
2
+ export { VoiceRecordsCollection } from './VoiceRecordCollection'
3
+ export { RecorderModel } from './Recorder.model'
4
+ export { UploaderModel } from './Uploader.model'
@@ -0,0 +1,69 @@
1
+ import { WithAbortSignal } from 'src/types/common.types'
2
+ import { getAvailableInputs } from './helpers'
3
+ import { VoiceRecordModel } from './recording/model/VoiceRecord.model'
4
+ import { AxiosResponse } from 'axios'
5
+
6
+ export type VoiceRecordNotificationTypes = {
7
+ success: (message: string) => void
8
+ info: (message: string) => void
9
+ error: (message: string) => void
10
+ warning: (message: string) => void
11
+ }
12
+
13
+ export type UploadAudioPayload = WithAbortSignal<{
14
+ audioFileFormData: FormData
15
+ }>
16
+
17
+ type UploadAudioResponse = {
18
+ id: string
19
+ fileName: string
20
+ fileType: string
21
+ }
22
+
23
+ export type VoiceRecordCollectionItem = {
24
+ solutionId?: string
25
+ id?: string //it exists after upload to server
26
+ durationMs?: number
27
+ uri?: string
28
+ audioUploadPromise?: Promise<void | UploadAudioResponse>
29
+ controller?: AbortController
30
+ }
31
+
32
+ export type VoiceRecordStack = {
33
+ [problemId: string]: VoiceRecordCollectionItem
34
+ }
35
+
36
+ export type AvailableAudioInputs = Awaited<ReturnType<typeof getAvailableInputs>>
37
+
38
+ export type VoiceRecordModalParams = {
39
+ model: VoiceRecordModel
40
+ }
41
+
42
+ export type AnswerAudio = {
43
+ drawing: string
44
+ _id: string
45
+ audioFileId?: string
46
+ }
47
+
48
+ export type DownloadAudioPayload = {
49
+ audioFileId: string
50
+ }
51
+
52
+ export type VoiceRecorderApi = {
53
+ uploadAudioFile: (data: UploadAudioPayload) => Promise<UploadAudioResponse>
54
+ deleteAudioFile: (audioFileId: string) => Promise<void>
55
+ }
56
+
57
+ type TranscriptionStatus = 'pending' | 'completed' | 'failed'
58
+ export type AudioTranscriptResponse = {
59
+ text: string
60
+ status: TranscriptionStatus
61
+ }
62
+
63
+ export type VoicePlayerApi = {
64
+ getAudioFileTranscript: (audioFileId: string) => Promise<AudioTranscriptResponse>
65
+ downloadAudioFile: (
66
+ audioFileId: string,
67
+ options?: { signal?: AbortSignal },
68
+ ) => Promise<AxiosResponse<Blob>>
69
+ }
package/src/index.ts CHANGED
@@ -11,3 +11,4 @@ export * from './features/exampleSolution'
11
11
  export * from './features/keyboard'
12
12
  export * from './features/openEnded'
13
13
  export * from './shared/icons'
14
+ export * from './features/voice'