@magmamath/students-features 1.3.23-rc.2 → 1.3.23-rc.21

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 (306) hide show
  1. package/dist/commonjs/features/translation/constants.js +11 -0
  2. package/dist/commonjs/features/translation/constants.js.map +1 -0
  3. package/dist/commonjs/features/translation/helpers.js +60 -0
  4. package/dist/commonjs/features/translation/helpers.js.map +1 -0
  5. package/dist/commonjs/features/translation/index.js +105 -0
  6. package/dist/commonjs/features/translation/index.js.map +1 -0
  7. package/dist/commonjs/features/translation/model/TranslationModel.js +122 -0
  8. package/dist/commonjs/features/translation/model/TranslationModel.js.map +1 -0
  9. package/dist/commonjs/features/translation/model/TranslationPreprocessor.js +142 -0
  10. package/dist/commonjs/features/translation/model/TranslationPreprocessor.js.map +1 -0
  11. package/dist/commonjs/features/translation/model/TranslationService.js +112 -0
  12. package/dist/commonjs/features/translation/model/TranslationService.js.map +1 -0
  13. package/dist/commonjs/features/translation/preserve/wordsToPreserve.js +314 -0
  14. package/dist/commonjs/features/translation/preserve/wordsToPreserve.js.map +1 -0
  15. package/dist/commonjs/features/translation/providers/google/GoogleTranslationProvider.js +50 -0
  16. package/dist/commonjs/features/translation/providers/google/GoogleTranslationProvider.js.map +1 -0
  17. package/dist/commonjs/features/translation/providers/google/supportedLanguages.js +230 -0
  18. package/dist/commonjs/features/translation/providers/google/supportedLanguages.js.map +1 -0
  19. package/dist/commonjs/features/translation/providers/google.types.js +2 -0
  20. package/dist/commonjs/features/translation/providers/google.types.js.map +1 -0
  21. package/dist/commonjs/features/translation/providers/translation.interface.js +49 -0
  22. package/dist/commonjs/features/translation/providers/translation.interface.js.map +1 -0
  23. package/dist/commonjs/features/translation/types.js +2 -0
  24. package/dist/commonjs/features/translation/types.js.map +1 -0
  25. package/dist/commonjs/features/voice/index.js +4 -4
  26. package/dist/commonjs/features/voice/index.js.map +1 -1
  27. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js +44 -0
  28. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -0
  29. package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js +107 -0
  30. package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js.map +1 -0
  31. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js +66 -0
  32. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +1 -0
  33. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +58 -0
  34. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -0
  35. package/dist/commonjs/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.js → useDropdownAnimation.js} +8 -7
  36. package/dist/commonjs/features/voice/playing/hooks/useDropdownAnimation.js.map +1 -0
  37. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.js +128 -0
  38. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.js.map +1 -0
  39. package/dist/commonjs/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.js → Dropdown.model.js} +4 -4
  40. package/dist/commonjs/features/voice/playing/model/Dropdown.model.js.map +1 -0
  41. package/dist/commonjs/features/voice/playing/model/PlaybackController.js +183 -0
  42. package/dist/commonjs/features/voice/playing/model/PlaybackController.js.map +1 -0
  43. package/dist/commonjs/features/voice/playing/model/Player.model.js +24 -1
  44. package/dist/commonjs/features/voice/playing/model/Player.model.js.map +1 -1
  45. package/dist/commonjs/features/voice/playing/model/{VoiceTranscriptionsCollection.js → TranscriptionsCollection.js} +4 -4
  46. package/dist/commonjs/features/voice/playing/model/TranscriptionsCollection.js.map +1 -0
  47. package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js +82 -0
  48. package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -0
  49. package/dist/commonjs/features/voice/playing/model/Translation.model.js +62 -0
  50. package/dist/commonjs/features/voice/playing/model/Translation.model.js.map +1 -0
  51. package/dist/commonjs/features/voice/playing/model/VoiceFileDownloader.model.js +2 -2
  52. package/dist/commonjs/features/voice/playing/model/VoiceFileDownloader.model.js.map +1 -1
  53. package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js +46 -172
  54. package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
  55. package/dist/commonjs/features/voice/types.js.map +1 -1
  56. package/dist/commonjs/index.js +12 -0
  57. package/dist/commonjs/index.js.map +1 -1
  58. package/dist/module/features/translation/constants.js +7 -0
  59. package/dist/module/features/translation/constants.js.map +1 -0
  60. package/dist/module/features/translation/helpers.js +53 -0
  61. package/dist/module/features/translation/helpers.js.map +1 -0
  62. package/dist/module/features/translation/index.js +12 -0
  63. package/dist/module/features/translation/index.js.map +1 -0
  64. package/dist/module/features/translation/model/TranslationModel.js +117 -0
  65. package/dist/module/features/translation/model/TranslationModel.js.map +1 -0
  66. package/dist/module/features/translation/model/TranslationPreprocessor.js +137 -0
  67. package/dist/module/features/translation/model/TranslationPreprocessor.js.map +1 -0
  68. package/dist/module/features/translation/model/TranslationService.js +107 -0
  69. package/dist/module/features/translation/model/TranslationService.js.map +1 -0
  70. package/dist/module/features/translation/preserve/wordsToPreserve.js +310 -0
  71. package/dist/module/features/translation/preserve/wordsToPreserve.js.map +1 -0
  72. package/dist/module/features/translation/providers/google/GoogleTranslationProvider.js +45 -0
  73. package/dist/module/features/translation/providers/google/GoogleTranslationProvider.js.map +1 -0
  74. package/dist/module/features/translation/providers/google/supportedLanguages.js +225 -0
  75. package/dist/module/features/translation/providers/google/supportedLanguages.js.map +1 -0
  76. package/dist/module/features/translation/providers/google.types.js +2 -0
  77. package/dist/module/features/translation/providers/google.types.js.map +1 -0
  78. package/dist/module/features/translation/providers/translation.interface.js +44 -0
  79. package/dist/module/features/translation/providers/translation.interface.js.map +1 -0
  80. package/dist/module/features/translation/types.js +2 -0
  81. package/dist/module/features/translation/types.js.map +1 -0
  82. package/dist/module/features/voice/index.js +1 -1
  83. package/dist/module/features/voice/index.js.map +1 -1
  84. package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js +38 -0
  85. package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -0
  86. package/dist/module/features/voice/playing/components/VoiceTranscription.js +101 -0
  87. package/dist/module/features/voice/playing/components/VoiceTranscription.js.map +1 -0
  88. package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js +58 -0
  89. package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +1 -0
  90. package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +52 -0
  91. package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -0
  92. package/dist/module/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.js → useDropdownAnimation.js} +6 -5
  93. package/dist/module/features/voice/playing/hooks/useDropdownAnimation.js.map +1 -0
  94. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionController.js +123 -0
  95. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionController.js.map +1 -0
  96. package/dist/module/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.js → Dropdown.model.js} +2 -2
  97. package/dist/module/features/voice/playing/model/Dropdown.model.js.map +1 -0
  98. package/dist/module/features/voice/playing/model/PlaybackController.js +178 -0
  99. package/dist/module/features/voice/playing/model/PlaybackController.js.map +1 -0
  100. package/dist/module/features/voice/playing/model/Player.model.js +24 -1
  101. package/dist/module/features/voice/playing/model/Player.model.js.map +1 -1
  102. package/dist/module/features/voice/playing/model/{VoiceTranscriptionsCollection.js → TranscriptionsCollection.js} +2 -2
  103. package/dist/module/features/voice/playing/model/TranscriptionsCollection.js.map +1 -0
  104. package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js +77 -0
  105. package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -0
  106. package/dist/module/features/voice/playing/model/Translation.model.js +57 -0
  107. package/dist/module/features/voice/playing/model/Translation.model.js.map +1 -0
  108. package/dist/module/features/voice/playing/model/VoiceFileDownloader.model.js +2 -2
  109. package/dist/module/features/voice/playing/model/VoiceFileDownloader.model.js.map +1 -1
  110. package/dist/module/features/voice/playing/model/VoicePlayer.model.js +48 -174
  111. package/dist/module/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
  112. package/dist/module/features/voice/types.js.map +1 -1
  113. package/dist/module/index.js +1 -0
  114. package/dist/module/index.js.map +1 -1
  115. package/dist/typescript/commonjs/features/translation/constants.d.ts +5 -0
  116. package/dist/typescript/commonjs/features/translation/constants.d.ts.map +1 -0
  117. package/dist/typescript/commonjs/features/translation/helpers.d.ts +9 -0
  118. package/dist/typescript/commonjs/features/translation/helpers.d.ts.map +1 -0
  119. package/dist/typescript/commonjs/features/translation/index.d.ts +12 -0
  120. package/dist/typescript/commonjs/features/translation/index.d.ts.map +1 -0
  121. package/dist/typescript/commonjs/features/translation/model/TranslationModel.d.ts +33 -0
  122. package/dist/typescript/commonjs/features/translation/model/TranslationModel.d.ts.map +1 -0
  123. package/dist/typescript/commonjs/features/translation/model/TranslationPreprocessor.d.ts +34 -0
  124. package/dist/typescript/commonjs/features/translation/model/TranslationPreprocessor.d.ts.map +1 -0
  125. package/dist/typescript/commonjs/features/translation/model/TranslationService.d.ts +40 -0
  126. package/dist/typescript/commonjs/features/translation/model/TranslationService.d.ts.map +1 -0
  127. package/dist/typescript/commonjs/features/translation/preserve/wordsToPreserve.d.ts +3 -0
  128. package/dist/typescript/commonjs/features/translation/preserve/wordsToPreserve.d.ts.map +1 -0
  129. package/dist/typescript/commonjs/features/translation/providers/google/GoogleTranslationProvider.d.ts +17 -0
  130. package/dist/typescript/commonjs/features/translation/providers/google/GoogleTranslationProvider.d.ts.map +1 -0
  131. package/dist/typescript/commonjs/features/translation/providers/google/supportedLanguages.d.ts +209 -0
  132. package/dist/typescript/commonjs/features/translation/providers/google/supportedLanguages.d.ts.map +1 -0
  133. package/dist/typescript/commonjs/features/translation/providers/google.types.d.ts +15 -0
  134. package/dist/typescript/commonjs/features/translation/providers/google.types.d.ts.map +1 -0
  135. package/dist/typescript/commonjs/features/translation/providers/translation.interface.d.ts +30 -0
  136. package/dist/typescript/commonjs/features/translation/providers/translation.interface.d.ts.map +1 -0
  137. package/dist/typescript/commonjs/features/translation/types.d.ts +27 -0
  138. package/dist/typescript/commonjs/features/translation/types.d.ts.map +1 -0
  139. package/dist/typescript/commonjs/features/voice/index.d.ts +2 -1
  140. package/dist/typescript/commonjs/features/voice/index.d.ts.map +1 -1
  141. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts +8 -0
  142. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -0
  143. package/dist/typescript/{module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts → commonjs/features/voice/playing/components/VoiceTranscription.d.ts} +3 -4
  144. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -0
  145. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +10 -0
  146. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +1 -0
  147. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts +12 -0
  148. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +1 -0
  149. package/dist/typescript/{module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts → commonjs/features/voice/playing/hooks/useDropdownAnimation.d.ts} +3 -3
  150. package/dist/typescript/commonjs/features/voice/playing/hooks/useDropdownAnimation.d.ts.map +1 -0
  151. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts +30 -0
  152. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts.map +1 -0
  153. package/dist/typescript/{module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts → commonjs/features/voice/playing/model/Dropdown.model.d.ts} +2 -2
  154. package/dist/typescript/commonjs/features/voice/playing/model/Dropdown.model.d.ts.map +1 -0
  155. package/dist/typescript/commonjs/features/voice/playing/model/PlaybackController.d.ts +28 -0
  156. package/dist/typescript/commonjs/features/voice/playing/model/PlaybackController.d.ts.map +1 -0
  157. package/dist/typescript/commonjs/features/voice/playing/model/Player.model.d.ts +3 -0
  158. package/dist/typescript/commonjs/features/voice/playing/model/Player.model.d.ts.map +1 -1
  159. package/dist/typescript/{module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts → commonjs/features/voice/playing/model/TranscriptionsCollection.d.ts} +2 -2
  160. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsCollection.d.ts.map +1 -0
  161. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +19 -0
  162. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -0
  163. package/dist/typescript/commonjs/features/voice/playing/model/Translation.model.d.ts +25 -0
  164. package/dist/typescript/commonjs/features/voice/playing/model/Translation.model.d.ts.map +1 -0
  165. package/dist/typescript/commonjs/features/voice/playing/model/VoiceFileDownloader.model.d.ts +2 -2
  166. package/dist/typescript/commonjs/features/voice/playing/model/VoiceFileDownloader.model.d.ts.map +1 -1
  167. package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts +18 -18
  168. package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
  169. package/dist/typescript/commonjs/features/voice/types.d.ts +5 -1
  170. package/dist/typescript/commonjs/features/voice/types.d.ts.map +1 -1
  171. package/dist/typescript/commonjs/index.d.ts +1 -0
  172. package/dist/typescript/commonjs/index.d.ts.map +1 -1
  173. package/dist/typescript/module/features/translation/constants.d.ts +5 -0
  174. package/dist/typescript/module/features/translation/constants.d.ts.map +1 -0
  175. package/dist/typescript/module/features/translation/helpers.d.ts +9 -0
  176. package/dist/typescript/module/features/translation/helpers.d.ts.map +1 -0
  177. package/dist/typescript/module/features/translation/index.d.ts +12 -0
  178. package/dist/typescript/module/features/translation/index.d.ts.map +1 -0
  179. package/dist/typescript/module/features/translation/model/TranslationModel.d.ts +33 -0
  180. package/dist/typescript/module/features/translation/model/TranslationModel.d.ts.map +1 -0
  181. package/dist/typescript/module/features/translation/model/TranslationPreprocessor.d.ts +34 -0
  182. package/dist/typescript/module/features/translation/model/TranslationPreprocessor.d.ts.map +1 -0
  183. package/dist/typescript/module/features/translation/model/TranslationService.d.ts +40 -0
  184. package/dist/typescript/module/features/translation/model/TranslationService.d.ts.map +1 -0
  185. package/dist/typescript/module/features/translation/preserve/wordsToPreserve.d.ts +3 -0
  186. package/dist/typescript/module/features/translation/preserve/wordsToPreserve.d.ts.map +1 -0
  187. package/dist/typescript/module/features/translation/providers/google/GoogleTranslationProvider.d.ts +17 -0
  188. package/dist/typescript/module/features/translation/providers/google/GoogleTranslationProvider.d.ts.map +1 -0
  189. package/dist/typescript/module/features/translation/providers/google/supportedLanguages.d.ts +209 -0
  190. package/dist/typescript/module/features/translation/providers/google/supportedLanguages.d.ts.map +1 -0
  191. package/dist/typescript/module/features/translation/providers/google.types.d.ts +15 -0
  192. package/dist/typescript/module/features/translation/providers/google.types.d.ts.map +1 -0
  193. package/dist/typescript/module/features/translation/providers/translation.interface.d.ts +30 -0
  194. package/dist/typescript/module/features/translation/providers/translation.interface.d.ts.map +1 -0
  195. package/dist/typescript/module/features/translation/types.d.ts +27 -0
  196. package/dist/typescript/module/features/translation/types.d.ts.map +1 -0
  197. package/dist/typescript/module/features/voice/index.d.ts +2 -1
  198. package/dist/typescript/module/features/voice/index.d.ts.map +1 -1
  199. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts +8 -0
  200. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -0
  201. package/dist/typescript/{commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts → module/features/voice/playing/components/VoiceTranscription.d.ts} +3 -4
  202. package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -0
  203. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +10 -0
  204. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +1 -0
  205. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts +12 -0
  206. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +1 -0
  207. package/dist/typescript/{commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts → module/features/voice/playing/hooks/useDropdownAnimation.d.ts} +3 -3
  208. package/dist/typescript/module/features/voice/playing/hooks/useDropdownAnimation.d.ts.map +1 -0
  209. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts +30 -0
  210. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts.map +1 -0
  211. package/dist/typescript/{commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts → module/features/voice/playing/model/Dropdown.model.d.ts} +2 -2
  212. package/dist/typescript/module/features/voice/playing/model/Dropdown.model.d.ts.map +1 -0
  213. package/dist/typescript/module/features/voice/playing/model/PlaybackController.d.ts +28 -0
  214. package/dist/typescript/module/features/voice/playing/model/PlaybackController.d.ts.map +1 -0
  215. package/dist/typescript/module/features/voice/playing/model/Player.model.d.ts +3 -0
  216. package/dist/typescript/module/features/voice/playing/model/Player.model.d.ts.map +1 -1
  217. package/dist/typescript/{commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts → module/features/voice/playing/model/TranscriptionsCollection.d.ts} +2 -2
  218. package/dist/typescript/module/features/voice/playing/model/TranscriptionsCollection.d.ts.map +1 -0
  219. package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +19 -0
  220. package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -0
  221. package/dist/typescript/module/features/voice/playing/model/Translation.model.d.ts +25 -0
  222. package/dist/typescript/module/features/voice/playing/model/Translation.model.d.ts.map +1 -0
  223. package/dist/typescript/module/features/voice/playing/model/VoiceFileDownloader.model.d.ts +2 -2
  224. package/dist/typescript/module/features/voice/playing/model/VoiceFileDownloader.model.d.ts.map +1 -1
  225. package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts +18 -18
  226. package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
  227. package/dist/typescript/module/features/voice/types.d.ts +5 -1
  228. package/dist/typescript/module/features/voice/types.d.ts.map +1 -1
  229. package/dist/typescript/module/index.d.ts +1 -0
  230. package/dist/typescript/module/index.d.ts.map +1 -1
  231. package/package.json +28 -1
  232. package/src/features/translation/constants.ts +4 -0
  233. package/src/features/translation/helpers.ts +63 -0
  234. package/src/features/translation/index.ts +30 -0
  235. package/src/features/translation/model/TranslationModel.ts +174 -0
  236. package/src/features/translation/model/TranslationPreprocessor.ts +171 -0
  237. package/src/features/translation/model/TranslationService.ts +148 -0
  238. package/src/features/translation/preserve/wordsToPreserve.ts +87 -0
  239. package/src/features/translation/providers/google/GoogleTranslationProvider.ts +50 -0
  240. package/src/features/translation/providers/google/supportedLanguages.ts +229 -0
  241. package/src/features/translation/providers/google.types.ts +16 -0
  242. package/src/features/translation/providers/translation.interface.ts +63 -0
  243. package/src/features/translation/types.ts +30 -0
  244. package/src/features/voice/index.ts +2 -1
  245. package/src/features/voice/playing/components/VoiceTranscriptContent.tsx +37 -0
  246. package/src/features/voice/playing/components/VoiceTranscription.tsx +117 -0
  247. package/src/features/voice/playing/components/VoiceTranscriptionCollapsible.tsx +59 -0
  248. package/src/features/voice/playing/components/VoiceTranscriptionHeaderActions.tsx +61 -0
  249. package/src/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.ts → useDropdownAnimation.ts} +5 -5
  250. package/src/features/voice/playing/hooks/useVoiceTranscriptionController.ts +171 -0
  251. package/src/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.ts → Dropdown.model.ts} +2 -2
  252. package/src/features/voice/playing/model/PlaybackController.ts +213 -0
  253. package/src/features/voice/playing/model/Player.model.ts +26 -1
  254. package/src/features/voice/playing/model/{VoiceTranscriptionsCollection.ts → TranscriptionsCollection.ts} +1 -1
  255. package/src/features/voice/playing/model/TranscriptionsDownloader.model.ts +88 -0
  256. package/src/features/voice/playing/model/Translation.model.ts +75 -0
  257. package/src/features/voice/playing/model/VoiceFileDownloader.model.ts +2 -2
  258. package/src/features/voice/playing/model/VoicePlayer.model.ts +57 -194
  259. package/src/features/voice/types.ts +10 -0
  260. package/src/index.ts +1 -0
  261. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js +0 -251
  262. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +0 -1
  263. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +0 -109
  264. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +0 -1
  265. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +0 -1
  266. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +0 -34
  267. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +0 -1
  268. package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js +0 -66
  269. package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +0 -1
  270. package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +0 -1
  271. package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +0 -1
  272. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js +0 -244
  273. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +0 -1
  274. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +0 -103
  275. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +0 -1
  276. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +0 -1
  277. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +0 -29
  278. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +0 -1
  279. package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js +0 -61
  280. package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +0 -1
  281. package/dist/module/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +0 -1
  282. package/dist/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +0 -1
  283. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +0 -1
  284. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +0 -12
  285. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +0 -1
  286. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +0 -1
  287. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +0 -11
  288. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +0 -1
  289. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +0 -15
  290. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +0 -1
  291. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +0 -1
  292. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +0 -1
  293. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +0 -1
  294. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +0 -12
  295. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +0 -1
  296. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +0 -1
  297. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +0 -11
  298. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +0 -1
  299. package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +0 -15
  300. package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +0 -1
  301. package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +0 -1
  302. package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +0 -1
  303. package/src/features/voice/playing/components/VoiceTranscriptionsDropdown.tsx +0 -302
  304. package/src/features/voice/playing/components/VoiceTranscriptionsDropdownItem.tsx +0 -128
  305. package/src/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.ts +0 -40
  306. package/src/features/voice/playing/model/TranscriptionsDownloaderModel.ts +0 -80
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PlaybackController = void 0;
7
+ var _effector = require("effector");
8
+ var _PlayerModel = require("./Player.model.js");
9
+ class PlaybackController {
10
+ currentPlayingAttempt = null;
11
+ shouldPreventPlayback = false;
12
+ constructor(deps) {
13
+ this.collection = deps.collection;
14
+ this.player = deps.player;
15
+ this.downloader = deps.downloader;
16
+ this.player.playbackFinished.watch(() => this.clearCurrentAttempt());
17
+ }
18
+ togglePlayPause = attemptNumber => {
19
+ const playerState = this.player.$playerState.getState();
20
+ if (this.currentPlayingAttempt === attemptNumber && playerState === _PlayerModel.PlayerState.PLAYING) {
21
+ this.player.pause();
22
+ } else {
23
+ this.handlePlayAttempt(attemptNumber);
24
+ }
25
+ };
26
+ preloadAudio = (0, _effector.createEffect)(async attemptNumber => {
27
+ const item = this.collection.get(attemptNumber);
28
+ if (!item) return;
29
+ if (this.collection.hasAudio(attemptNumber)) {
30
+ this.primePlayerIfIdle(attemptNumber);
31
+ return;
32
+ }
33
+ if (item.audioDownloadPromise) {
34
+ try {
35
+ await item.audioDownloadPromise;
36
+ } catch {}
37
+ this.primePlayerIfIdle(attemptNumber);
38
+ return;
39
+ }
40
+ try {
41
+ await this.downloadAudio(attemptNumber);
42
+ this.primePlayerIfIdle(attemptNumber);
43
+ } catch (error) {
44
+ if (error instanceof Error && error.name === 'AbortError') return;
45
+ console.error('Audio preload error:', error);
46
+ }
47
+ });
48
+ primePlayerIfIdle(attemptNumber) {
49
+ if (this.player.$playerState.getState() !== _PlayerModel.PlayerState.IDLE) return;
50
+ if (this.currentPlayingAttempt !== null) return;
51
+ const audioUri = this.collection.get(attemptNumber)?.audioUri;
52
+ if (!audioUri) return;
53
+ this.player.prime(audioUri);
54
+ }
55
+ halt() {
56
+ this.shouldPreventPlayback = true;
57
+ this.abortAllDownloads();
58
+ this.player.stop();
59
+ this.clearCurrentAttempt();
60
+ }
61
+ releaseResources() {
62
+ this.collection.getAll().forEach(item => {
63
+ if (item.controller) {
64
+ this.downloader.abortDownload(item.controller);
65
+ }
66
+ if (item.audioUri?.startsWith('blob:')) {
67
+ try {
68
+ URL.revokeObjectURL(item.audioUri);
69
+ } catch (e) {}
70
+ }
71
+ });
72
+ }
73
+ clearCurrentAttempt() {
74
+ this.currentPlayingAttempt = null;
75
+ }
76
+ abortAllDownloads() {
77
+ this.collection.getAll().forEach(item => {
78
+ if (item.controller && item.audioLoading) {
79
+ this.downloader.abortDownload(item.controller);
80
+ this.collection.update(item.attemptNumber, {
81
+ audioLoading: false,
82
+ controller: undefined,
83
+ audioDownloadPromise: undefined
84
+ });
85
+ }
86
+ });
87
+ }
88
+ async downloadAudio(attemptNumber) {
89
+ const item = this.collection.get(attemptNumber);
90
+ if (!item) return;
91
+ const {
92
+ collectionItem,
93
+ downloadPromise
94
+ } = await this.downloader.download({
95
+ audioFileId: item.audioFileId,
96
+ attemptNumber
97
+ });
98
+ this.collection.update(attemptNumber, collectionItem);
99
+ try {
100
+ const result = await downloadPromise;
101
+ this.collection.update(attemptNumber, {
102
+ audioUri: result.uri,
103
+ audioLoading: false,
104
+ audioError: undefined,
105
+ controller: undefined,
106
+ audioDownloadPromise: undefined
107
+ });
108
+ } catch (error) {
109
+ const isAbort = error instanceof Error && error.name === 'AbortError';
110
+ this.collection.update(attemptNumber, {
111
+ audioLoading: false,
112
+ audioError: isAbort ? undefined : error instanceof Error ? error.message : 'Failed to download audio',
113
+ controller: undefined,
114
+ audioDownloadPromise: undefined
115
+ });
116
+ throw error;
117
+ }
118
+ }
119
+ handlePlayAttempt = (0, _effector.createEffect)(async attemptNumber => {
120
+ this.shouldPreventPlayback = false;
121
+ const item = this.collection.get(attemptNumber);
122
+ if (!item) return;
123
+ if (this.currentPlayingAttempt !== null && this.currentPlayingAttempt !== attemptNumber) {
124
+ this.abortAllDownloads();
125
+ }
126
+ if (this.collection.hasAudio(attemptNumber)) {
127
+ this.playAudioFx(attemptNumber);
128
+ return;
129
+ }
130
+ try {
131
+ this.player.setPlayerState(_PlayerModel.PlayerState.LOADING);
132
+ if (item.audioDownloadPromise) {
133
+ await item.audioDownloadPromise;
134
+ } else {
135
+ await this.downloadAudio(attemptNumber);
136
+ }
137
+ if (this.shouldPreventPlayback) {
138
+ this.player.setPlayerState(_PlayerModel.PlayerState.IDLE);
139
+ return;
140
+ }
141
+ this.player.setPlayerState(_PlayerModel.PlayerState.IDLE);
142
+ this.playAudioFx(attemptNumber);
143
+ } catch (error) {
144
+ if (error instanceof Error && error.name === 'AbortError') {
145
+ this.player.setPlayerState(_PlayerModel.PlayerState.IDLE);
146
+ return;
147
+ }
148
+ console.error('Audio download error:', error);
149
+ this.player.setPlayerState(_PlayerModel.PlayerState.IDLE);
150
+ }
151
+ });
152
+ playAudioFx = (0, _effector.createEffect)(async attemptNumber => {
153
+ if (this.shouldPreventPlayback) return;
154
+ const item = this.collection.get(attemptNumber);
155
+ if (!item?.audioUri) {
156
+ console.warn('No audio URI available for attempt:', attemptNumber);
157
+ return;
158
+ }
159
+ try {
160
+ if (this.currentPlayingAttempt !== null && this.currentPlayingAttempt !== attemptNumber) {
161
+ this.player.player?.remove();
162
+ }
163
+ if (this.currentPlayingAttempt === attemptNumber && this.player.player?.playing) {
164
+ this.player.pause();
165
+ return;
166
+ }
167
+ if (this.currentPlayingAttempt === attemptNumber && !this.player.player?.playing) {
168
+ this.player.resume();
169
+ return;
170
+ }
171
+ this.currentPlayingAttempt = attemptNumber;
172
+ await this.player.play(item.audioUri);
173
+ } catch (error) {
174
+ console.error('Error playing audio:', error);
175
+ this.player.setPlayerState(_PlayerModel.PlayerState.IDLE);
176
+ this.collection.update(attemptNumber, {
177
+ audioError: error instanceof Error ? error.message : 'Failed to play audio'
178
+ });
179
+ }
180
+ });
181
+ }
182
+ exports.PlaybackController = PlaybackController;
183
+ //# sourceMappingURL=PlaybackController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_effector","require","_PlayerModel","PlaybackController","currentPlayingAttempt","shouldPreventPlayback","constructor","deps","collection","player","downloader","playbackFinished","watch","clearCurrentAttempt","togglePlayPause","attemptNumber","playerState","$playerState","getState","PlayerState","PLAYING","pause","handlePlayAttempt","preloadAudio","createEffect","item","get","hasAudio","primePlayerIfIdle","audioDownloadPromise","downloadAudio","error","Error","name","console","IDLE","audioUri","prime","halt","abortAllDownloads","stop","releaseResources","getAll","forEach","controller","abortDownload","startsWith","URL","revokeObjectURL","e","audioLoading","update","undefined","collectionItem","downloadPromise","download","audioFileId","result","uri","audioError","isAbort","message","playAudioFx","setPlayerState","LOADING","warn","remove","playing","resume","play","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/PlaybackController.ts"],"mappings":";;;;;;AAAA,IAA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I,CAAC,IAAI,CAACN,MAAM,CAACA,MAAM,EAAE0D,OAAO,EAAE;QAChF,IAAI,CAAC1D,MAAM,CAAC2D,MAAM,CAAC,CAAC;QACpB;MACF;MAEA,IAAI,CAAChE,qBAAqB,GAAGW,aAAa;MAC1C,MAAM,IAAI,CAACN,MAAM,CAAC4D,IAAI,CAAC5C,IAAI,CAACW,QAAQ,CAAC;IACvC,CAAC,CAAC,OAAOL,KAAK,EAAE;MACdG,OAAO,CAACH,KAAK,CAAC,sBAAsB,EAAEA,KAAK,CAAC;MAC5C,IAAI,CAACtB,MAAM,CAACsD,cAAc,CAAC5C,wBAAW,CAACgB,IAAI,CAAC;MAE5C,IAAI,CAAC3B,UAAU,CAAC2C,MAAM,CAACpC,aAAa,EAAE;QACpC4C,UAAU,EAAE5B,KAAK,YAAYC,KAAK,GAAGD,KAAK,CAAC8B,OAAO,GAAG;MACvD,CAAC,CAAC;IACJ;EACF,CAAC,CAAC;AACJ;AAACS,OAAA,CAAAnE,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -16,6 +16,7 @@ let PlayerState = exports.PlayerState = /*#__PURE__*/function (PlayerState) {
16
16
  class PlayerModel {
17
17
  player = (0, _expoAudio.createAudioPlayer)();
18
18
  stopped = false;
19
+ primedUri = null;
19
20
  reset = (0, _effector.createEvent)();
20
21
  setPlayerState = (0, _effector.createEvent)();
21
22
  playbackFinished = (0, _effector.createEvent)();
@@ -39,11 +40,29 @@ class PlayerModel {
39
40
  this.stopped = true;
40
41
  if (this.player) {
41
42
  this.player.replace('');
43
+ this.primedUri = null;
42
44
  this.setPlayerState(PlayerState.IDLE);
43
45
  } else {
44
46
  console.warn('Cannot stop: audio player not initialized');
45
47
  }
46
48
  });
49
+ prime = (0, _effector.createEffect)(uri => {
50
+ if (!this.player) return;
51
+ if (this.primedUri === uri) return;
52
+ this.primedUri = uri;
53
+ this.player.replace(uri);
54
+ });
55
+ seek = (0, _effector.createEffect)(async seconds => {
56
+ if (!this.player) {
57
+ console.warn('Cannot seek: audio player not initialized');
58
+ return;
59
+ }
60
+ if (!this.player.isLoaded) {
61
+ console.warn('Cannot seek: audio player not loaded');
62
+ return;
63
+ }
64
+ await this.player.seekTo(seconds);
65
+ });
47
66
  resume = (0, _effector.createEffect)(() => {
48
67
  if (this.player) {
49
68
  this.player.play();
@@ -58,7 +77,10 @@ class PlayerModel {
58
77
  return;
59
78
  }
60
79
  this.stopped = false;
61
- this.player.replace(uri);
80
+ if (this.primedUri !== uri) {
81
+ this.player.replace(uri);
82
+ this.primedUri = uri;
83
+ }
62
84
  const waitForLoad = () => {
63
85
  if (this.stopped) return;
64
86
  if (this.player && this.player.isLoaded) {
@@ -91,6 +113,7 @@ class PlayerModel {
91
113
  this.player.release();
92
114
  this.player = null;
93
115
  }
116
+ this.primedUri = null;
94
117
  this.reset();
95
118
  }
96
119
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_effector","require","_expoAudio","PlayerState","exports","PlayerModel","player","createAudioPlayer","stopped","reset","createEvent","setPlayerState","playbackFinished","$playerState","restore","IDLE","setupAudioMode","createEffect","setAudioModeAsync","playsInSilentMode","shouldPlayInBackground","interruptionMode","pause","PAUSED","console","warn","stop","replace","resume","play","PLAYING","uri","waitForLoad","isLoaded","unsubscribe","addListener","status","didJustFinish","remove","setTimeout","reinitialize","release","error"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/Player.model.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAA8E,IAE5DE,WAAW,GAAAC,OAAA,CAAAD,WAAA,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAOtB,MAAME,WAAW,CAAC;EAChBC,MAAM,GAAuB,IAAAC,4BAAiB,EAAC,CAAC;EAC/CC,OAAO,GAAG,KAAK;EAEPC,KAAK,GAAG,IAAAC,qBAAW,EAAC,CAAC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X,IAAI,CAACpB,MAAM,CAACgC,MAAM,CAAC,CAAC;MACtB,CAAC,CAAC,OAAOI,KAAK,EAAE,CAAC;MACjB,IAAI,CAACpC,MAAM,CAACmC,OAAO,CAAC,CAAC;MACrB,IAAI,CAACnC,MAAM,GAAG,IAAI;IACpB;IACA,IAAI,CAACG,KAAK,CAAC,CAAC;EACd;AACF;AAACL,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"names":["_effector","require","_expoAudio","PlayerState","exports","PlayerModel","player","createAudioPlayer","stopped","primedUri","reset","createEvent","setPlayerState","playbackFinished","$playerState","restore","IDLE","setupAudioMode","createEffect","setAudioModeAsync","playsInSilentMode","shouldPlayInBackground","interruptionMode","pause","PAUSED","console","warn","stop","replace","prime","uri","seek","seconds","isLoaded","seekTo","resume","play","PLAYING","waitForLoad","unsubscribe","addListener","status","didJustFinish","remove","setTimeout","reinitialize","release","error"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/Player.model.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAA8E,IAE5DE,WAAW,GAAAC,OAAA,CAAAD,WAAA,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAOtB,MAAME,WAAW,CAAC;EAChBC,MAAM,GAAuB,IAAAC,4BAAiB,EAAC,CAAC;EAC/CC,OAAO,GAAG,KAAK;EACfC,SAAS,GAAkB,IAAI;EAEvBC,KAAK,GAAG,IAAAC,qBAAW,EAAC,CAAC;EACrBC,cAAc,GAAG,IAAAD,qBAAW,EAAc,CAAC;EAC3CE,gBAAgB,GAAG,IAAAF,qBAAW,EAAC,CAAC;EAEhCG,YAAY,GAAG,IAAAC,iBAAO,EAAC,IAAI,CAACH,cAAc,EAAET,WAAW,CAACa,IAAI,CAAC,CAACN,KAAK,CAAC,IAAI,CAACA,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AC/B,cAAc,CAACT,WAAW,CAACa,IAAI,CAAC;UACvC;QACF,CAAC,CAAC;QAEF,IAAI,CAACV,MAAM,CAAC8B,IAAI,CAAC,CAAC;QAClB,IAAI,CAACxB,cAAc,CAACT,WAAW,CAACkC,OAAO,CAAC;MAC1C,CAAC,MAAM;QACLO,UAAU,CAACN,WAAW,EAAE,EAAE,CAAC;MAC7B;IACF,CAAC;IAEDA,WAAW,CAAC,CAAC;EACf,CAAC,CAAC;EAEKO,YAAYA,CAAA,EAAG;IACpB,IAAI,CAAC,IAAI,CAACvC,MAAM,EAAE;MAChB,IAAI,CAACA,MAAM,GAAG,IAAAC,4BAAiB,EAAC,CAAC;IACnC;EACF;EAEOuC,OAAOA,CAAA,EAAG;IACf,IAAI,IAAI,CAACxC,MAAM,EAAE;MACf,IAAI;QACF,IAAI,CAACqB,IAAI,CAAC,CAAC;QACX,IAAI,CAACrB,MAAM,CAACqC,MAAM,CAAC,CAAC;MACtB,CAAC,CAAC,OAAOI,KAAK,EAAE,CAAC;MACjB,IAAI,CAACzC,MAAM,CAACwC,OAAO,CAAC,CAAC;MACrB,IAAI,CAACxC,MAAM,GAAG,IAAI;IACpB;IACA,IAAI,CAACG,SAAS,GAAG,IAAI;IACrB,IAAI,CAACC,KAAK,CAAC,CAAC;EACd;AACF;AAACN,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.VoiceTranscriptionsCollection = void 0;
7
- class VoiceTranscriptionsCollection {
6
+ exports.TranscriptionsCollection = void 0;
7
+ class TranscriptionsCollection {
8
8
  collection = new Map();
9
9
  add(attemptNumber, item) {
10
10
  this.collection.set(attemptNumber, item);
@@ -37,5 +37,5 @@ class VoiceTranscriptionsCollection {
37
37
  return !!item?.audioUri;
38
38
  }
39
39
  }
40
- exports.VoiceTranscriptionsCollection = VoiceTranscriptionsCollection;
41
- //# sourceMappingURL=VoiceTranscriptionsCollection.js.map
40
+ exports.TranscriptionsCollection = TranscriptionsCollection;
41
+ //# sourceMappingURL=TranscriptionsCollection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TranscriptionsCollection","collection","Map","add","attemptNumber","item","set","update","existingItem","get","delete","getAll","Array","from","values","clear","hasTranscript","transcript","hasAudio","audioUri","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/TranscriptionsCollection.ts"],"mappings":";;;;;;AAEO,MAAMA,wBAAwB,CAAC;EACpBC,UAAU,GAAwC,IAAIC,GAAG,CAAC,CAAC;EAEpEC,GAAGA,CAACC,aAAqB,EAAEC,IAA4B,EAAE;IAC9D,IAAI,CAACJ,UAAU,CAACK,GAAG,CAACF,aAAa,EAAEC,IAAI,CAAC;EAC1C;EAEOE,MAAMA,CAACH,aAAqB,EAAEC,IAAqC,EAAE;IAC1E,MAAMG,YAAY,GAAG,IAAI,CAACP,UAAU,CAACQ,GAAG,CAACL,aAAa,CAAC,IAAK,CAAC,CAA4B;IACzF,IAAI,CAACH,UAAU,CAACK,GAAG,CAACF,aAAa,EAAE;MAAE,GAAGI,YAAY;MAAE,GAAGH;IAAK,CAAC,CAAC;EAClE;EAEOK,MAAMA,CAACN,aAAqB,EAAE;IACnC,IAAI,CAACH,UAAU,CAACS,MAAM,CAACN,aAAa,CAAC;EACvC;EAEOK,GAAGA,CAACL,aAAqB,EAAE;IAChC,OAAO,IAAI,CAACH,UAAU,CAACQ,GAAG,CAACL,aAAa,CAAC;EAC3C;EAEOO,MAAMA,CAAA,EAAG;IACd,OAAOC,KAAK,CAACC,IAAI,CAAC,IAAI,CAACZ,UAAU,CAACa,MAAM,CAAC,CAAC,CAAC;EAC7C;EAEOC,KAAKA,CAAA,EAAG;IACb,IAAI,CAACd,UAAU,CAACc,KAAK,CAAC,CAAC;EACzB;EAEOC,aAAaA,CAACZ,aAAqB,EAAE;IAC1C,MAAMC,IAAI,GAAG,IAAI,CAACJ,UAAU,CAACQ,GAAG,CAACL,aAAa,CAAC;IAC/C,OAAO,CAAC,CAACC,IAAI,EAAEY,UAAU;EAC3B;EAEOC,QAAQA,CAACd,aAAqB,EAAE;IACrC,MAAMC,IAAI,GAAG,IAAI,CAACJ,UAAU,CAACQ,GAAG,CAACL,aAAa,CAAC;IAC/C,OAAO,CAAC,CAACC,IAAI,EAAEc,QAAQ;EACzB;AACF;AAACC,OAAA,CAAApB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TranscriptionsDownloaderModel = void 0;
7
+ var _effector = require("effector");
8
+ var _constants = require("../../constants.js");
9
+ class TranscriptionsDownloaderModel {
10
+ inflightFetches = new Map();
11
+ transcriptCache = new Map();
12
+ constructor(collection, api) {
13
+ this.collection = collection;
14
+ this.api = api;
15
+ }
16
+ fetchTranscriptWithRetry(audioFileId) {
17
+ const cached = this.transcriptCache.get(audioFileId);
18
+ if (cached) return Promise.resolve(cached);
19
+ const existing = this.inflightFetches.get(audioFileId);
20
+ if (existing) return existing;
21
+ const promise = this.runFetchWithRetry(audioFileId).then(result => {
22
+ this.transcriptCache.set(audioFileId, result);
23
+ return result;
24
+ }).finally(() => {
25
+ this.inflightFetches.delete(audioFileId);
26
+ });
27
+ this.inflightFetches.set(audioFileId, promise);
28
+ return promise;
29
+ }
30
+ async runFetchWithRetry(audioFileId) {
31
+ for (let attempt = 0; attempt < _constants.TRANSCRIPT_MAX_RETRIES; attempt++) {
32
+ const response = await this.api.getAudioFileTranscript(audioFileId);
33
+ if (response.status === 'completed') {
34
+ return {
35
+ text: response.text,
36
+ language: response.language
37
+ };
38
+ }
39
+ if (response.status === 'failed') {
40
+ return {
41
+ text: _constants.NO_AUDIO_BE_MESSAGE
42
+ };
43
+ }
44
+ if (attempt < _constants.TRANSCRIPT_MAX_RETRIES - 1) {
45
+ await new Promise(resolve => setTimeout(resolve, _constants.TRANSCRIPT_RETRY_INTERVAL_MS));
46
+ }
47
+ }
48
+ return {
49
+ text: _constants.NO_AUDIO_BE_MESSAGE
50
+ };
51
+ }
52
+ loadTranscriptForAttempt = (0, _effector.createEffect)(async attemptNumber => {
53
+ const item = this.collection.get(attemptNumber);
54
+ if (!item?.audioFileId) return;
55
+ if (item.transcript || item.transcriptLoading) return;
56
+ this.collection.update(attemptNumber, {
57
+ transcriptLoading: true
58
+ });
59
+ try {
60
+ const {
61
+ text,
62
+ language
63
+ } = await this.fetchTranscriptWithRetry(item.audioFileId);
64
+ this.collection.update(attemptNumber, {
65
+ transcript: text,
66
+ transcriptLanguage: language,
67
+ transcriptLoading: false,
68
+ transcriptError: undefined
69
+ });
70
+ } catch (error) {
71
+ this.collection.update(attemptNumber, {
72
+ transcriptLoading: false,
73
+ transcriptError: error instanceof Error ? error.message : 'Failed to load transcript'
74
+ });
75
+ }
76
+ });
77
+ getCachedTranscript(audioFileId) {
78
+ return this.transcriptCache.get(audioFileId);
79
+ }
80
+ }
81
+ exports.TranscriptionsDownloaderModel = TranscriptionsDownloaderModel;
82
+ //# sourceMappingURL=TranscriptionsDownloader.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_effector","require","_constants","TranscriptionsDownloaderModel","inflightFetches","Map","transcriptCache","constructor","collection","api","fetchTranscriptWithRetry","audioFileId","cached","get","Promise","resolve","existing","promise","runFetchWithRetry","then","result","set","finally","delete","attempt","TRANSCRIPT_MAX_RETRIES","response","getAudioFileTranscript","status","text","language","NO_AUDIO_BE_MESSAGE","setTimeout","TRANSCRIPT_RETRY_INTERVAL_MS","loadTranscriptForAttempt","createEffect","attemptNumber","item","transcript","transcriptLoading","update","transcriptLanguage","transcriptError","undefined","error","Error","message","getCachedTranscript","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/TranscriptionsDownloader.model.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAGA,IAAAC,UAAA,GAAAD,O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AGD,KAAK,CAACE,OAAO,GAAG;MAC5D,CAAC,CAAC;IACJ;EACF,CAAC,CAAC;EAEKC,mBAAmBA,CAACpC,WAAmB,EAAgC;IAC5E,OAAO,IAAI,CAACL,eAAe,CAACO,GAAG,CAACF,WAAW,CAAC;EAC9C;AACF;AAACqC,OAAA,CAAA7C,6BAAA,GAAAA,6BAAA","ignoreList":[]}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TranslationModel = void 0;
7
+ var _effector = require("effector");
8
+ var _TranslationService = require("../../../translation/model/TranslationService.js");
9
+ var _GoogleTranslationProvider = require("../../../translation/providers/google/GoogleTranslationProvider.js");
10
+ var _wordsToPreserve = require("../../../translation/preserve/wordsToPreserve.js");
11
+ class TranslationModel {
12
+ toggle = (0, _effector.createEvent)();
13
+ setActive = (0, _effector.createEvent)();
14
+ clearCache = (0, _effector.createEvent)();
15
+ reset = (0, _effector.createEvent)();
16
+ $isActive = (0, _effector.restore)(this.setActive, false).on(this.toggle, state => !state).reset(this.reset);
17
+ translate = (0, _effector.createEffect)(async ({
18
+ attemptNumber,
19
+ targetLanguage
20
+ }) => {
21
+ const item = this.collection.get(attemptNumber);
22
+ if (!item?.transcript) return null;
23
+ const text = await this.service.translate(item.transcript, {
24
+ targetLang: targetLanguage,
25
+ sourceLang: item.transcriptLanguage,
26
+ cacheKey: `voice::${attemptNumber}::${targetLanguage}`
27
+ });
28
+ if (!text) return null;
29
+ return {
30
+ attemptNumber,
31
+ text
32
+ };
33
+ });
34
+ $translations = (0, _effector.createStore)({}).on(this.translate.doneData, (state, result) => {
35
+ if (!result) return state;
36
+ return {
37
+ ...state,
38
+ [result.attemptNumber]: result.text
39
+ };
40
+ }).reset(this.reset, this.clearCache);
41
+ constructor(collection, api) {
42
+ this.collection = collection;
43
+ this.service = new _TranslationService.TranslationService({
44
+ preserve: {
45
+ map: _wordsToPreserve.wordsToPreserve,
46
+ replacers: _wordsToPreserve.preservedWordsReplacers
47
+ },
48
+ providers: [new _GoogleTranslationProvider.GoogleTranslationProvider({
49
+ api: {
50
+ translateRequest: api.translateText
51
+ }
52
+ })]
53
+ });
54
+ this.clearCache.watch(() => this.service.reset());
55
+ this.reset.watch(() => this.service.reset());
56
+ }
57
+ getTranslation(attemptNumber) {
58
+ return this.$translations.getState()[attemptNumber];
59
+ }
60
+ }
61
+ exports.TranslationModel = TranslationModel;
62
+ //# sourceMappingURL=Translation.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_effector","require","_TranslationService","_GoogleTranslationProvider","_wordsToPreserve","TranslationModel","toggle","createEvent","setActive","clearCache","reset","$isActive","restore","on","state","translate","createEffect","attemptNumber","targetLanguage","item","collection","get","transcript","text","service","targetLang","sourceLang","transcriptLanguage","cacheKey","$translations","createStore","doneData","result","constructor","api","TranslationService","preserve","map","wordsToPreserve","replacers","preservedWordsReplacers","providers","GoogleTranslationProvider","translateRequest","translateText","watch","getTranslation","getState","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/Translation.model.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAGA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,0BAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAeO,MAAMI,gBAAgB,CAAC;EAIZC,MAAM,GAAG,IAAAC,qBAAW,EAAC,CAAC;EACtBC,SAAS,GAAG,IAAAD,qBAAW,EAAU,CAAC;EAClCE,UAAU,GAAG,IAAAF,qBAAW,EAAC,CAAC;EAC1BG,KAAK,GAAG,IAAAH,qBAAW,EAAC,CAAC;EAErBI,SAAS,GAAG,IAAAC,iBAAO,EAAC,IAAI,CAACJ,SAAS,EAAE,KAAK,CAAC,CACvDK,EAAE,CAAC,IAAI,CAACP,MAAM,EAAGQ,KAAK,IAAK,CAACA,KAAK,CAAC,CAClCJ,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC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G,CAACU;QAAc;MAAE,CAAC,CAAC;IAC7F,CAAC,CAAC;IAEF,IAAI,CAACnC,UAAU,CAACoC,KAAK,CAAC,MAAM,IAAI,CAACrB,OAAO,CAACd,KAAK,CAAC,CAAC,CAAC;IACjD,IAAI,CAACA,KAAK,CAACmC,KAAK,CAAC,MAAM,IAAI,CAACrB,OAAO,CAACd,KAAK,CAAC,CAAC,CAAC;EAC9C;EAEOoC,cAAcA,CAAC7B,aAAqB,EAAsB;IAC/D,OAAO,IAAI,CAACY,aAAa,CAACkB,QAAQ,CAAC,CAAC,CAAC9B,aAAa,CAAC;EACrD;AACF;AAAC+B,OAAA,CAAA3C,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -7,9 +7,9 @@ exports.VoiceFileDownloaderModel = void 0;
7
7
  var _effector = require("effector");
8
8
  var _helpers = require("../../helpers.js");
9
9
  class VoiceFileDownloaderModel {
10
- setApi = api => {
10
+ constructor(api) {
11
11
  this.api = api;
12
- };
12
+ }
13
13
  download = (0, _effector.createEffect)(async ({
14
14
  audioFileId,
15
15
  attemptNumber
@@ -1 +1 @@
1
- {"version":3,"names":["_effector","require","_helpers","VoiceFileDownloaderModel","setApi","api","download","createEffect","audioFileId","attemptNumber","downloadAudio","controller","downloadAudioFileRequestGenerator","downloadPromise","collectionItem","audioLoading","audioDownloadPromise","abortDownload","abort","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/VoiceFileDownloader.model.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAYO,MAAME,wBAAwB,CAAC;EAGpBC,MAAM,GAAIC,GAAmB,IAAK;IAChD,IAAI,CAACA,GAAG,GAAGA,GAAG;EAChB,CAAC;EAEeC,QAAQ,GAAG,IAAAC,sBAAY,EACrC,OAAO;IAAEC,WAAW;IAAEC;EAA8B,CAAC,KAA8B;IACjF,MAAM;MAAEC,aAAa;MAAEC;IAAW,CAAC,GAAG,IAAAC,0CAAiC,EAACJ,WAAW,EAAE,IAAI,CAACH,GAAG,CAAC;IAC9F,MAAMQ,eAAe,GAAGH,aAAa,CAAC,CAAC;IAEvC,MAAMI,cAA+C,GAAG;MACtDL,aAAa;MACbD,WAAW;MACXO,YAAY,EAAE,IAAI;MAClBC,oBAAoB,EAAEH,eAAe;MACrCF;IACF,CAAC;IAED,OAAO;MAAEG,cAAc;MAAED;IAAgB,CAAC;EAC5C,CACF,CAAC;EAEeI,aAAa,GAAIN,UAA4B,IAAK;IAChEA,UAAU,EAAEO,KAAK,CAAC,CAAC;EACrB,CAAC;AACH;AAACC,OAAA,CAAAhB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_effector","require","_helpers","VoiceFileDownloaderModel","constructor","api","download","createEffect","audioFileId","attemptNumber","downloadAudio","controller","downloadAudioFileRequestGenerator","downloadPromise","collectionItem","audioLoading","audioDownloadPromise","abortDownload","abort","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/VoiceFileDownloader.model.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAYO,MAAME,wBAAwB,CAAC;EAGpCC,WAAWA,CAACC,GAAmB,EAAE;IAC/B,IAAI,CAACA,GAAG,GAAGA,GAAG;EAChB;EAEgBC,QAAQ,GAAG,IAAAC,sBAAY,EACrC,OAAO;IAAEC,WAAW;IAAEC;EAA8B,CAAC,KAA8B;IACjF,MAAM;MAAEC,aAAa;MAAEC;IAAW,CAAC,GAAG,IAAAC,0CAAiC,EAACJ,WAAW,EAAE,IAAI,CAACH,GAAG,CAAC;IAC9F,MAAMQ,eAAe,GAAGH,aAAa,CAAC,CAAC;IAEvC,MAAMI,cAA+C,GAAG;MACtDL,aAAa;MACbD,WAAW;MACXO,YAAY,EAAE,IAAI;MAClBC,oBAAoB,EAAEH,eAAe;MACrCF;IACF,CAAC;IAED,OAAO;MAAEG,cAAc;MAAED;IAAgB,CAAC;EAC5C,CACF,CAAC;EAEeI,aAAa,GAAIN,UAA4B,IAAK;IAChEA,UAAU,EAAEO,KAAK,CAAC,CAAC;EACrB,CAAC;AACH;AAACC,OAAA,CAAAhB,wBAAA,GAAAA,wBAAA","ignoreList":[]}