@magmamath/students-features 1.4.6 → 1.5.0-rc.20

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 (412) hide show
  1. package/dist/commonjs/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.js +1 -6
  2. package/dist/commonjs/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.js.map +1 -1
  3. package/dist/commonjs/features/fluency/components/Fluency.js +6 -12
  4. package/dist/commonjs/features/fluency/components/Fluency.js.map +1 -1
  5. package/dist/commonjs/features/fluency/components/select-math-operator/SelectMathOperator.js +5 -13
  6. package/dist/commonjs/features/fluency/components/select-math-operator/SelectMathOperator.js.map +1 -1
  7. package/dist/commonjs/features/fluency/model/FluencyModel.js +0 -21
  8. package/dist/commonjs/features/fluency/model/FluencyModel.js.map +1 -1
  9. package/dist/commonjs/features/fluency/shared/fluency.constants.js +1 -6
  10. package/dist/commonjs/features/fluency/shared/fluency.constants.js.map +1 -1
  11. package/dist/commonjs/features/fluency/shared/fluency.helpers.js +1 -3
  12. package/dist/commonjs/features/fluency/shared/fluency.helpers.js.map +1 -1
  13. package/dist/commonjs/features/pmProgress/model/PmProgressModel.js +1 -7
  14. package/dist/commonjs/features/pmProgress/model/PmProgressModel.js.map +1 -1
  15. package/dist/commonjs/features/pmProgress/model/PmRecommendationsModel.js +4 -20
  16. package/dist/commonjs/features/pmProgress/model/PmRecommendationsModel.js.map +1 -1
  17. package/dist/commonjs/features/pmProgress/shared/pmProgress.helpers.js +1 -22
  18. package/dist/commonjs/features/pmProgress/shared/pmProgress.helpers.js.map +1 -1
  19. package/dist/commonjs/features/translation/constants.js +11 -0
  20. package/dist/commonjs/features/translation/constants.js.map +1 -0
  21. package/dist/commonjs/features/translation/helpers.js +60 -0
  22. package/dist/commonjs/features/translation/helpers.js.map +1 -0
  23. package/dist/commonjs/features/translation/index.js +105 -0
  24. package/dist/commonjs/features/translation/index.js.map +1 -0
  25. package/dist/commonjs/features/translation/model/TranslationModel.js +122 -0
  26. package/dist/commonjs/features/translation/model/TranslationModel.js.map +1 -0
  27. package/dist/commonjs/features/translation/model/TranslationPreprocessor.js +142 -0
  28. package/dist/commonjs/features/translation/model/TranslationPreprocessor.js.map +1 -0
  29. package/dist/commonjs/features/translation/model/TranslationService.js +112 -0
  30. package/dist/commonjs/features/translation/model/TranslationService.js.map +1 -0
  31. package/dist/commonjs/features/translation/preserve/wordsToPreserve.js +314 -0
  32. package/dist/commonjs/features/translation/preserve/wordsToPreserve.js.map +1 -0
  33. package/dist/commonjs/features/translation/providers/google/GoogleTranslationProvider.js +50 -0
  34. package/dist/commonjs/features/translation/providers/google/GoogleTranslationProvider.js.map +1 -0
  35. package/dist/commonjs/features/translation/providers/google/supportedLanguages.js +230 -0
  36. package/dist/commonjs/features/translation/providers/google/supportedLanguages.js.map +1 -0
  37. package/dist/commonjs/features/translation/providers/google.types.js +2 -0
  38. package/dist/commonjs/features/translation/providers/google.types.js.map +1 -0
  39. package/dist/commonjs/features/translation/providers/translation.interface.js +49 -0
  40. package/dist/commonjs/features/translation/providers/translation.interface.js.map +1 -0
  41. package/dist/commonjs/features/translation/types.js +2 -0
  42. package/dist/commonjs/features/translation/types.js.map +1 -0
  43. package/dist/commonjs/features/voice/index.js +15 -4
  44. package/dist/commonjs/features/voice/index.js.map +1 -1
  45. package/dist/commonjs/features/voice/playing/components/VoiceIcon.js +1 -1
  46. package/dist/commonjs/features/voice/playing/components/VoiceIcon.js.map +1 -1
  47. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js +44 -0
  48. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -0
  49. package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js +107 -0
  50. package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js.map +1 -0
  51. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js +66 -0
  52. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +1 -0
  53. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +58 -0
  54. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -0
  55. package/dist/commonjs/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.js → useDropdownAnimation.js} +8 -7
  56. package/dist/commonjs/features/voice/playing/hooks/useDropdownAnimation.js.map +1 -0
  57. package/dist/commonjs/features/voice/playing/hooks/useVoicePlayerLifecycle.js +53 -0
  58. package/dist/commonjs/features/voice/playing/hooks/useVoicePlayerLifecycle.js.map +1 -0
  59. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.js +111 -0
  60. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.js.map +1 -0
  61. package/dist/commonjs/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.js → Dropdown.model.js} +4 -4
  62. package/dist/commonjs/features/voice/playing/model/Dropdown.model.js.map +1 -0
  63. package/dist/commonjs/features/voice/playing/model/PlaybackController.js +192 -0
  64. package/dist/commonjs/features/voice/playing/model/PlaybackController.js.map +1 -0
  65. package/dist/commonjs/features/voice/playing/model/Player.model.js +50 -5
  66. package/dist/commonjs/features/voice/playing/model/Player.model.js.map +1 -1
  67. package/dist/commonjs/features/voice/playing/model/{VoiceTranscriptionsCollection.js → TranscriptionsCollection.js} +4 -4
  68. package/dist/commonjs/features/voice/playing/model/TranscriptionsCollection.js.map +1 -0
  69. package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js +83 -0
  70. package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -0
  71. package/dist/commonjs/features/voice/playing/model/Translation.model.js +62 -0
  72. package/dist/commonjs/features/voice/playing/model/Translation.model.js.map +1 -0
  73. package/dist/commonjs/features/voice/playing/model/VoiceFileDownloader.model.js +2 -2
  74. package/dist/commonjs/features/voice/playing/model/VoiceFileDownloader.model.js.map +1 -1
  75. package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js +58 -172
  76. package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
  77. package/dist/commonjs/features/voice/recording/components/VoiceRecordDivider.js +1 -1
  78. package/dist/commonjs/features/voice/recording/components/VoiceRecordDivider.js.map +1 -1
  79. package/dist/commonjs/features/voice/types.js +12 -1
  80. package/dist/commonjs/features/voice/types.js.map +1 -1
  81. package/dist/commonjs/index.js +12 -0
  82. package/dist/commonjs/index.js.map +1 -1
  83. package/dist/module/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.js +2 -7
  84. package/dist/module/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.js.map +1 -1
  85. package/dist/module/features/fluency/components/Fluency.js +8 -14
  86. package/dist/module/features/fluency/components/Fluency.js.map +1 -1
  87. package/dist/module/features/fluency/components/select-math-operator/SelectMathOperator.js +5 -13
  88. package/dist/module/features/fluency/components/select-math-operator/SelectMathOperator.js.map +1 -1
  89. package/dist/module/features/fluency/model/FluencyModel.js +1 -22
  90. package/dist/module/features/fluency/model/FluencyModel.js.map +1 -1
  91. package/dist/module/features/fluency/shared/fluency.constants.js +0 -5
  92. package/dist/module/features/fluency/shared/fluency.constants.js.map +1 -1
  93. package/dist/module/features/fluency/shared/fluency.helpers.js +0 -1
  94. package/dist/module/features/fluency/shared/fluency.helpers.js.map +1 -1
  95. package/dist/module/features/pmProgress/model/PmProgressModel.js +1 -7
  96. package/dist/module/features/pmProgress/model/PmProgressModel.js.map +1 -1
  97. package/dist/module/features/pmProgress/model/PmRecommendationsModel.js +4 -20
  98. package/dist/module/features/pmProgress/model/PmRecommendationsModel.js.map +1 -1
  99. package/dist/module/features/pmProgress/shared/pmProgress.helpers.js +0 -20
  100. package/dist/module/features/pmProgress/shared/pmProgress.helpers.js.map +1 -1
  101. package/dist/module/features/translation/constants.js +7 -0
  102. package/dist/module/features/translation/constants.js.map +1 -0
  103. package/dist/module/features/translation/helpers.js +53 -0
  104. package/dist/module/features/translation/helpers.js.map +1 -0
  105. package/dist/module/features/translation/index.js +12 -0
  106. package/dist/module/features/translation/index.js.map +1 -0
  107. package/dist/module/features/translation/model/TranslationModel.js +117 -0
  108. package/dist/module/features/translation/model/TranslationModel.js.map +1 -0
  109. package/dist/module/features/translation/model/TranslationPreprocessor.js +137 -0
  110. package/dist/module/features/translation/model/TranslationPreprocessor.js.map +1 -0
  111. package/dist/module/features/translation/model/TranslationService.js +107 -0
  112. package/dist/module/features/translation/model/TranslationService.js.map +1 -0
  113. package/dist/module/features/translation/preserve/wordsToPreserve.js +310 -0
  114. package/dist/module/features/translation/preserve/wordsToPreserve.js.map +1 -0
  115. package/dist/module/features/translation/providers/google/GoogleTranslationProvider.js +45 -0
  116. package/dist/module/features/translation/providers/google/GoogleTranslationProvider.js.map +1 -0
  117. package/dist/module/features/translation/providers/google/supportedLanguages.js +225 -0
  118. package/dist/module/features/translation/providers/google/supportedLanguages.js.map +1 -0
  119. package/dist/module/features/translation/providers/google.types.js +2 -0
  120. package/dist/module/features/translation/providers/google.types.js.map +1 -0
  121. package/dist/module/features/translation/providers/translation.interface.js +44 -0
  122. package/dist/module/features/translation/providers/translation.interface.js.map +1 -0
  123. package/dist/module/features/translation/types.js +2 -0
  124. package/dist/module/features/translation/types.js.map +1 -0
  125. package/dist/module/features/voice/index.js +2 -1
  126. package/dist/module/features/voice/index.js.map +1 -1
  127. package/dist/module/features/voice/playing/components/VoiceIcon.js +2 -2
  128. package/dist/module/features/voice/playing/components/VoiceIcon.js.map +1 -1
  129. package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js +38 -0
  130. package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -0
  131. package/dist/module/features/voice/playing/components/VoiceTranscription.js +101 -0
  132. package/dist/module/features/voice/playing/components/VoiceTranscription.js.map +1 -0
  133. package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js +58 -0
  134. package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +1 -0
  135. package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +52 -0
  136. package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -0
  137. package/dist/module/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.js → useDropdownAnimation.js} +6 -5
  138. package/dist/module/features/voice/playing/hooks/useDropdownAnimation.js.map +1 -0
  139. package/dist/module/features/voice/playing/hooks/useVoicePlayerLifecycle.js +48 -0
  140. package/dist/module/features/voice/playing/hooks/useVoicePlayerLifecycle.js.map +1 -0
  141. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionController.js +106 -0
  142. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionController.js.map +1 -0
  143. package/dist/module/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.js → Dropdown.model.js} +2 -2
  144. package/dist/module/features/voice/playing/model/Dropdown.model.js.map +1 -0
  145. package/dist/module/features/voice/playing/model/PlaybackController.js +187 -0
  146. package/dist/module/features/voice/playing/model/PlaybackController.js.map +1 -0
  147. package/dist/module/features/voice/playing/model/Player.model.js +51 -4
  148. package/dist/module/features/voice/playing/model/Player.model.js.map +1 -1
  149. package/dist/module/features/voice/playing/model/{VoiceTranscriptionsCollection.js → TranscriptionsCollection.js} +2 -2
  150. package/dist/module/features/voice/playing/model/TranscriptionsCollection.js.map +1 -0
  151. package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js +78 -0
  152. package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -0
  153. package/dist/module/features/voice/playing/model/Translation.model.js +57 -0
  154. package/dist/module/features/voice/playing/model/Translation.model.js.map +1 -0
  155. package/dist/module/features/voice/playing/model/VoiceFileDownloader.model.js +2 -2
  156. package/dist/module/features/voice/playing/model/VoiceFileDownloader.model.js.map +1 -1
  157. package/dist/module/features/voice/playing/model/VoicePlayer.model.js +60 -174
  158. package/dist/module/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
  159. package/dist/module/features/voice/recording/components/VoiceRecordDivider.js +2 -2
  160. package/dist/module/features/voice/recording/components/VoiceRecordDivider.js.map +1 -1
  161. package/dist/module/features/voice/types.js +11 -0
  162. package/dist/module/features/voice/types.js.map +1 -1
  163. package/dist/module/index.js +1 -0
  164. package/dist/module/index.js.map +1 -1
  165. package/dist/typescript/commonjs/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.d.ts.map +1 -1
  166. package/dist/typescript/commonjs/features/fluency/components/Fluency.d.ts.map +1 -1
  167. package/dist/typescript/commonjs/features/fluency/components/select-math-operator/SelectMathOperator.d.ts.map +1 -1
  168. package/dist/typescript/commonjs/features/fluency/model/FluencyModel.d.ts +0 -3
  169. package/dist/typescript/commonjs/features/fluency/model/FluencyModel.d.ts.map +1 -1
  170. package/dist/typescript/commonjs/features/fluency/shared/fluency.constants.d.ts +0 -4
  171. package/dist/typescript/commonjs/features/fluency/shared/fluency.constants.d.ts.map +1 -1
  172. package/dist/typescript/commonjs/features/fluency/shared/fluency.helpers.d.ts +0 -1
  173. package/dist/typescript/commonjs/features/fluency/shared/fluency.helpers.d.ts.map +1 -1
  174. package/dist/typescript/commonjs/features/pmProgress/model/PmProgressModel.d.ts.map +1 -1
  175. package/dist/typescript/commonjs/features/pmProgress/model/PmRecommendationsModel.d.ts +38 -9
  176. package/dist/typescript/commonjs/features/pmProgress/model/PmRecommendationsModel.d.ts.map +1 -1
  177. package/dist/typescript/commonjs/features/pmProgress/shared/pmProgress.helpers.d.ts +0 -1
  178. package/dist/typescript/commonjs/features/pmProgress/shared/pmProgress.helpers.d.ts.map +1 -1
  179. package/dist/typescript/commonjs/features/translation/constants.d.ts +5 -0
  180. package/dist/typescript/commonjs/features/translation/constants.d.ts.map +1 -0
  181. package/dist/typescript/commonjs/features/translation/helpers.d.ts +9 -0
  182. package/dist/typescript/commonjs/features/translation/helpers.d.ts.map +1 -0
  183. package/dist/typescript/commonjs/features/translation/index.d.ts +12 -0
  184. package/dist/typescript/commonjs/features/translation/index.d.ts.map +1 -0
  185. package/dist/typescript/commonjs/features/translation/model/TranslationModel.d.ts +33 -0
  186. package/dist/typescript/commonjs/features/translation/model/TranslationModel.d.ts.map +1 -0
  187. package/dist/typescript/commonjs/features/translation/model/TranslationPreprocessor.d.ts +34 -0
  188. package/dist/typescript/commonjs/features/translation/model/TranslationPreprocessor.d.ts.map +1 -0
  189. package/dist/typescript/commonjs/features/translation/model/TranslationService.d.ts +40 -0
  190. package/dist/typescript/commonjs/features/translation/model/TranslationService.d.ts.map +1 -0
  191. package/dist/typescript/commonjs/features/translation/preserve/wordsToPreserve.d.ts +3 -0
  192. package/dist/typescript/commonjs/features/translation/preserve/wordsToPreserve.d.ts.map +1 -0
  193. package/dist/typescript/commonjs/features/translation/providers/google/GoogleTranslationProvider.d.ts +17 -0
  194. package/dist/typescript/commonjs/features/translation/providers/google/GoogleTranslationProvider.d.ts.map +1 -0
  195. package/dist/typescript/commonjs/features/translation/providers/google/supportedLanguages.d.ts +209 -0
  196. package/dist/typescript/commonjs/features/translation/providers/google/supportedLanguages.d.ts.map +1 -0
  197. package/dist/typescript/commonjs/features/translation/providers/google.types.d.ts +15 -0
  198. package/dist/typescript/commonjs/features/translation/providers/google.types.d.ts.map +1 -0
  199. package/dist/typescript/commonjs/features/translation/providers/translation.interface.d.ts +30 -0
  200. package/dist/typescript/commonjs/features/translation/providers/translation.interface.d.ts.map +1 -0
  201. package/dist/typescript/commonjs/features/translation/types.d.ts +27 -0
  202. package/dist/typescript/commonjs/features/translation/types.d.ts.map +1 -0
  203. package/dist/typescript/commonjs/features/voice/index.d.ts +3 -1
  204. package/dist/typescript/commonjs/features/voice/index.d.ts.map +1 -1
  205. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts +8 -0
  206. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -0
  207. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts +16 -0
  208. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -0
  209. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +10 -0
  210. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +1 -0
  211. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts +12 -0
  212. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +1 -0
  213. package/dist/typescript/commonjs/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.d.ts → useDropdownAnimation.d.ts} +3 -3
  214. package/dist/typescript/commonjs/features/voice/playing/hooks/useDropdownAnimation.d.ts.map +1 -0
  215. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoicePlayerLifecycle.d.ts +15 -0
  216. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoicePlayerLifecycle.d.ts.map +1 -0
  217. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts +30 -0
  218. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts.map +1 -0
  219. package/dist/typescript/{module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts → commonjs/features/voice/playing/model/Dropdown.model.d.ts} +2 -2
  220. package/dist/typescript/commonjs/features/voice/playing/model/Dropdown.model.d.ts.map +1 -0
  221. package/dist/typescript/commonjs/features/voice/playing/model/PlaybackController.d.ts +28 -0
  222. package/dist/typescript/commonjs/features/voice/playing/model/PlaybackController.d.ts.map +1 -0
  223. package/dist/typescript/commonjs/features/voice/playing/model/Player.model.d.ts +4 -0
  224. package/dist/typescript/commonjs/features/voice/playing/model/Player.model.d.ts.map +1 -1
  225. package/dist/typescript/{module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts → commonjs/features/voice/playing/model/TranscriptionsCollection.d.ts} +2 -2
  226. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsCollection.d.ts.map +1 -0
  227. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +19 -0
  228. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -0
  229. package/dist/typescript/commonjs/features/voice/playing/model/Translation.model.d.ts +25 -0
  230. package/dist/typescript/commonjs/features/voice/playing/model/Translation.model.d.ts.map +1 -0
  231. package/dist/typescript/commonjs/features/voice/playing/model/VoiceFileDownloader.model.d.ts +2 -2
  232. package/dist/typescript/commonjs/features/voice/playing/model/VoiceFileDownloader.model.d.ts.map +1 -1
  233. package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts +19 -18
  234. package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
  235. package/dist/typescript/commonjs/features/voice/types.d.ts +14 -2
  236. package/dist/typescript/commonjs/features/voice/types.d.ts.map +1 -1
  237. package/dist/typescript/commonjs/index.d.ts +1 -0
  238. package/dist/typescript/commonjs/index.d.ts.map +1 -1
  239. package/dist/typescript/module/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.d.ts.map +1 -1
  240. package/dist/typescript/module/features/fluency/components/Fluency.d.ts.map +1 -1
  241. package/dist/typescript/module/features/fluency/components/select-math-operator/SelectMathOperator.d.ts.map +1 -1
  242. package/dist/typescript/module/features/fluency/model/FluencyModel.d.ts +0 -3
  243. package/dist/typescript/module/features/fluency/model/FluencyModel.d.ts.map +1 -1
  244. package/dist/typescript/module/features/fluency/shared/fluency.constants.d.ts +0 -4
  245. package/dist/typescript/module/features/fluency/shared/fluency.constants.d.ts.map +1 -1
  246. package/dist/typescript/module/features/fluency/shared/fluency.helpers.d.ts +0 -1
  247. package/dist/typescript/module/features/fluency/shared/fluency.helpers.d.ts.map +1 -1
  248. package/dist/typescript/module/features/pmProgress/model/PmProgressModel.d.ts.map +1 -1
  249. package/dist/typescript/module/features/pmProgress/model/PmRecommendationsModel.d.ts +38 -9
  250. package/dist/typescript/module/features/pmProgress/model/PmRecommendationsModel.d.ts.map +1 -1
  251. package/dist/typescript/module/features/pmProgress/shared/pmProgress.helpers.d.ts +0 -1
  252. package/dist/typescript/module/features/pmProgress/shared/pmProgress.helpers.d.ts.map +1 -1
  253. package/dist/typescript/module/features/translation/constants.d.ts +5 -0
  254. package/dist/typescript/module/features/translation/constants.d.ts.map +1 -0
  255. package/dist/typescript/module/features/translation/helpers.d.ts +9 -0
  256. package/dist/typescript/module/features/translation/helpers.d.ts.map +1 -0
  257. package/dist/typescript/module/features/translation/index.d.ts +12 -0
  258. package/dist/typescript/module/features/translation/index.d.ts.map +1 -0
  259. package/dist/typescript/module/features/translation/model/TranslationModel.d.ts +33 -0
  260. package/dist/typescript/module/features/translation/model/TranslationModel.d.ts.map +1 -0
  261. package/dist/typescript/module/features/translation/model/TranslationPreprocessor.d.ts +34 -0
  262. package/dist/typescript/module/features/translation/model/TranslationPreprocessor.d.ts.map +1 -0
  263. package/dist/typescript/module/features/translation/model/TranslationService.d.ts +40 -0
  264. package/dist/typescript/module/features/translation/model/TranslationService.d.ts.map +1 -0
  265. package/dist/typescript/module/features/translation/preserve/wordsToPreserve.d.ts +3 -0
  266. package/dist/typescript/module/features/translation/preserve/wordsToPreserve.d.ts.map +1 -0
  267. package/dist/typescript/module/features/translation/providers/google/GoogleTranslationProvider.d.ts +17 -0
  268. package/dist/typescript/module/features/translation/providers/google/GoogleTranslationProvider.d.ts.map +1 -0
  269. package/dist/typescript/module/features/translation/providers/google/supportedLanguages.d.ts +209 -0
  270. package/dist/typescript/module/features/translation/providers/google/supportedLanguages.d.ts.map +1 -0
  271. package/dist/typescript/module/features/translation/providers/google.types.d.ts +15 -0
  272. package/dist/typescript/module/features/translation/providers/google.types.d.ts.map +1 -0
  273. package/dist/typescript/module/features/translation/providers/translation.interface.d.ts +30 -0
  274. package/dist/typescript/module/features/translation/providers/translation.interface.d.ts.map +1 -0
  275. package/dist/typescript/module/features/translation/types.d.ts +27 -0
  276. package/dist/typescript/module/features/translation/types.d.ts.map +1 -0
  277. package/dist/typescript/module/features/voice/index.d.ts +3 -1
  278. package/dist/typescript/module/features/voice/index.d.ts.map +1 -1
  279. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts +8 -0
  280. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -0
  281. package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts +16 -0
  282. package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -0
  283. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +10 -0
  284. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +1 -0
  285. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts +12 -0
  286. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +1 -0
  287. package/dist/typescript/module/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.d.ts → useDropdownAnimation.d.ts} +3 -3
  288. package/dist/typescript/module/features/voice/playing/hooks/useDropdownAnimation.d.ts.map +1 -0
  289. package/dist/typescript/module/features/voice/playing/hooks/useVoicePlayerLifecycle.d.ts +15 -0
  290. package/dist/typescript/module/features/voice/playing/hooks/useVoicePlayerLifecycle.d.ts.map +1 -0
  291. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts +30 -0
  292. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts.map +1 -0
  293. package/dist/typescript/{commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts → module/features/voice/playing/model/Dropdown.model.d.ts} +2 -2
  294. package/dist/typescript/module/features/voice/playing/model/Dropdown.model.d.ts.map +1 -0
  295. package/dist/typescript/module/features/voice/playing/model/PlaybackController.d.ts +28 -0
  296. package/dist/typescript/module/features/voice/playing/model/PlaybackController.d.ts.map +1 -0
  297. package/dist/typescript/module/features/voice/playing/model/Player.model.d.ts +4 -0
  298. package/dist/typescript/module/features/voice/playing/model/Player.model.d.ts.map +1 -1
  299. package/dist/typescript/{commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts → module/features/voice/playing/model/TranscriptionsCollection.d.ts} +2 -2
  300. package/dist/typescript/module/features/voice/playing/model/TranscriptionsCollection.d.ts.map +1 -0
  301. package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +19 -0
  302. package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -0
  303. package/dist/typescript/module/features/voice/playing/model/Translation.model.d.ts +25 -0
  304. package/dist/typescript/module/features/voice/playing/model/Translation.model.d.ts.map +1 -0
  305. package/dist/typescript/module/features/voice/playing/model/VoiceFileDownloader.model.d.ts +2 -2
  306. package/dist/typescript/module/features/voice/playing/model/VoiceFileDownloader.model.d.ts.map +1 -1
  307. package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts +19 -18
  308. package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
  309. package/dist/typescript/module/features/voice/types.d.ts +14 -2
  310. package/dist/typescript/module/features/voice/types.d.ts.map +1 -1
  311. package/dist/typescript/module/index.d.ts +1 -0
  312. package/dist/typescript/module/index.d.ts.map +1 -1
  313. package/package.json +37 -10
  314. package/src/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.tsx +2 -9
  315. package/src/features/fluency/components/Fluency.tsx +9 -17
  316. package/src/features/fluency/components/select-math-operator/SelectMathOperator.tsx +5 -13
  317. package/src/features/fluency/model/FluencyModel.ts +1 -25
  318. package/src/features/fluency/shared/fluency.constants.ts +0 -5
  319. package/src/features/fluency/shared/fluency.helpers.ts +0 -3
  320. package/src/features/pmProgress/model/PmProgressModel.ts +1 -4
  321. package/src/features/pmProgress/model/PmRecommendationsModel.ts +6 -22
  322. package/src/features/pmProgress/shared/pmProgress.helpers.ts +0 -33
  323. package/src/features/translation/constants.ts +4 -0
  324. package/src/features/translation/helpers.ts +63 -0
  325. package/src/features/translation/index.ts +30 -0
  326. package/src/features/translation/model/TranslationModel.ts +174 -0
  327. package/src/features/translation/model/TranslationPreprocessor.ts +171 -0
  328. package/src/features/translation/model/TranslationService.ts +148 -0
  329. package/src/features/translation/preserve/wordsToPreserve.ts +87 -0
  330. package/src/features/translation/providers/google/GoogleTranslationProvider.ts +50 -0
  331. package/src/features/translation/providers/google/supportedLanguages.ts +229 -0
  332. package/src/features/translation/providers/google.types.ts +16 -0
  333. package/src/features/translation/providers/translation.interface.ts +63 -0
  334. package/src/features/translation/types.ts +30 -0
  335. package/src/features/voice/index.ts +3 -1
  336. package/src/features/voice/playing/components/VoiceIcon.tsx +2 -2
  337. package/src/features/voice/playing/components/VoiceTranscriptContent.tsx +44 -0
  338. package/src/features/voice/playing/components/VoiceTranscription.tsx +117 -0
  339. package/src/features/voice/playing/components/VoiceTranscriptionCollapsible.tsx +59 -0
  340. package/src/features/voice/playing/components/VoiceTranscriptionHeaderActions.tsx +61 -0
  341. package/src/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.ts → useDropdownAnimation.ts} +5 -5
  342. package/src/features/voice/playing/hooks/useVoicePlayerLifecycle.ts +64 -0
  343. package/src/features/voice/playing/hooks/useVoiceTranscriptionController.ts +148 -0
  344. package/src/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.ts → Dropdown.model.ts} +2 -2
  345. package/src/features/voice/playing/model/PlaybackController.ts +221 -0
  346. package/src/features/voice/playing/model/Player.model.ts +52 -4
  347. package/src/features/voice/playing/model/{VoiceTranscriptionsCollection.ts → TranscriptionsCollection.ts} +1 -1
  348. package/src/features/voice/playing/model/TranscriptionsDownloader.model.ts +88 -0
  349. package/src/features/voice/playing/model/Translation.model.ts +75 -0
  350. package/src/features/voice/playing/model/VoiceFileDownloader.model.ts +2 -2
  351. package/src/features/voice/playing/model/VoicePlayer.model.ts +68 -192
  352. package/src/features/voice/recording/components/VoiceRecordDivider.tsx +2 -2
  353. package/src/features/voice/types.ts +21 -1
  354. package/src/i18n/.generated/schema.json +3 -7
  355. package/src/index.ts +1 -0
  356. package/dist/commonjs/features/fluency/components/FluencyStatusOverlay.js +0 -101
  357. package/dist/commonjs/features/fluency/components/FluencyStatusOverlay.js.map +0 -1
  358. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js +0 -245
  359. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +0 -1
  360. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +0 -109
  361. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +0 -1
  362. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +0 -1
  363. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +0 -34
  364. package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +0 -1
  365. package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js +0 -66
  366. package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +0 -1
  367. package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +0 -1
  368. package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +0 -1
  369. package/dist/module/features/fluency/components/FluencyStatusOverlay.js +0 -95
  370. package/dist/module/features/fluency/components/FluencyStatusOverlay.js.map +0 -1
  371. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js +0 -238
  372. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +0 -1
  373. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +0 -103
  374. package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +0 -1
  375. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +0 -1
  376. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +0 -29
  377. package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +0 -1
  378. package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js +0 -61
  379. package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +0 -1
  380. package/dist/module/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +0 -1
  381. package/dist/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +0 -1
  382. package/dist/typescript/commonjs/features/fluency/components/FluencyStatusOverlay.d.ts +0 -8
  383. package/dist/typescript/commonjs/features/fluency/components/FluencyStatusOverlay.d.ts.map +0 -1
  384. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts +0 -16
  385. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +0 -1
  386. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +0 -12
  387. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +0 -1
  388. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +0 -1
  389. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +0 -11
  390. package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +0 -1
  391. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +0 -15
  392. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +0 -1
  393. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +0 -1
  394. package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +0 -1
  395. package/dist/typescript/module/features/fluency/components/FluencyStatusOverlay.d.ts +0 -8
  396. package/dist/typescript/module/features/fluency/components/FluencyStatusOverlay.d.ts.map +0 -1
  397. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts +0 -16
  398. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +0 -1
  399. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +0 -12
  400. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +0 -1
  401. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +0 -1
  402. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +0 -11
  403. package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +0 -1
  404. package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +0 -15
  405. package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +0 -1
  406. package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +0 -1
  407. package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +0 -1
  408. package/src/features/fluency/components/FluencyStatusOverlay.tsx +0 -101
  409. package/src/features/voice/playing/components/VoiceTranscriptionsDropdown.tsx +0 -296
  410. package/src/features/voice/playing/components/VoiceTranscriptionsDropdownItem.tsx +0 -128
  411. package/src/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.ts +0 -40
  412. package/src/features/voice/playing/model/TranscriptionsDownloaderModel.ts +0 -80
@@ -0,0 +1,63 @@
1
+ import { replaceMappedTokens } from '../helpers'
2
+
3
+ export type LanguageGlossary = {
4
+ [languageCode: string]: Record<string, string>
5
+ }
6
+
7
+ type TranslationProviderProps = {
8
+ supportedLanguages: string[]
9
+ glossaries?: LanguageGlossary
10
+ }
11
+
12
+ export abstract class TranslationProvider {
13
+ protected readonly supportedLanguages: ReadonlySet<string>
14
+ protected readonly glossaries: LanguageGlossary = {}
15
+
16
+ protected constructor({ supportedLanguages, glossaries = {} }: TranslationProviderProps) {
17
+ this.supportedLanguages = new Set(supportedLanguages)
18
+ this.glossaries = glossaries
19
+ }
20
+
21
+ public abstract request(
22
+ text: string,
23
+ targetLanguage: string,
24
+ sourceLanguage?: string,
25
+ ): Promise<string>
26
+ public abstract requestBatch(
27
+ text: string[],
28
+ targetLanguage: string,
29
+ sourceLanguage?: string,
30
+ ): Promise<string[]>
31
+
32
+ public isTargetSupported(language: string) {
33
+ return this.resolveLanguage(language) !== null
34
+ }
35
+
36
+ /**
37
+ * Returns the provider-supported variant of `language`, falling back to the base
38
+ * language part (e.g. "en-SE" → "en") when the exact locale is not listed.
39
+ * Subclasses may override to add their own resolution (e.g. language names).
40
+ * Returns null when the language cannot be resolved.
41
+ */
42
+ public resolveLanguage(language: string): string | null {
43
+ if (!language) return null
44
+ if (this.supportedLanguages.has(language)) return language
45
+ const base = language.split('-')[0]
46
+ if (base !== language && this.supportedLanguages.has(base)) return base
47
+ return null
48
+ }
49
+
50
+ public getSupportedLanguages() {
51
+ return this.supportedLanguages.values()
52
+ }
53
+
54
+ /**
55
+ * Replaces full standalone words in text using a custom glossary for the target language,
56
+ * matching words like "Hello", or "Hej" regardless of case, but not when they appear inside other words.
57
+ */
58
+ public applyGlossary(text: string, targetLanguage: string): string {
59
+ const glossary = this.glossaries[targetLanguage]
60
+ if (!glossary) return text
61
+ return replaceMappedTokens(text, glossary)
62
+ }
63
+ }
@@ -0,0 +1,30 @@
1
+ export type TranslatableProblem = {
2
+ description: string
3
+ richDescription?: string
4
+ answerVariants: string[]
5
+ }
6
+
7
+ export type TranslateAllFxParams<TProblem extends TranslatableProblem = TranslatableProblem> = {
8
+ problem: TProblem | null
9
+ translationLanguageCode?: string | null
10
+ }
11
+
12
+ export type TranslateFxParams = {
13
+ cacheKey: string
14
+ text: string
15
+ }
16
+
17
+ export type Replacement = {
18
+ placeholder: string
19
+ original: string
20
+ leftPad?: boolean
21
+ rightPad?: boolean
22
+ }
23
+
24
+ export type MaskSegmentParams = {
25
+ text: string
26
+ regex: RegExp
27
+ placeholder: string
28
+ replacements: Replacement[]
29
+ shouldSkip?: (match: string) => boolean
30
+ }
@@ -4,8 +4,10 @@ export * from './recording/modal/VoiceRecordDeleteModal'
4
4
  export * from './recording/modal/VoiceRecordUndoModal'
5
5
 
6
6
  export * from './playing/model/VoicePlayer.model'
7
- export * from './playing/components/VoiceTranscriptionsDropdown'
7
+ export * from './playing/components/VoiceTranscription'
8
+ export * from './playing/hooks/useVoicePlayerLifecycle'
8
9
 
9
10
  export * from './playing/components/VoiceIcon'
10
11
  export * from './constants'
11
12
  export * from './types'
13
+ export type { WithAbortSignal } from '../../types/common.types'
@@ -1,6 +1,6 @@
1
1
  import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native'
2
2
  import React from 'react'
3
- import { COLORS, MicrophoneIcon } from '@magmamath/react-native-ui'
3
+ import { COLORS, MicrophoneIcon, SPACING } from '@magmamath/react-native-ui'
4
4
  import Animated, { FadeIn } from 'react-native-reanimated'
5
5
 
6
6
  type VoiceIconProps = {
@@ -28,7 +28,7 @@ const styles = StyleSheet.create({
28
28
  height: '80%',
29
29
  aspectRatio: 1,
30
30
  alignSelf: 'center',
31
- padding: 24,
31
+ padding: SPACING[600],
32
32
  borderWidth: 4,
33
33
  borderColor: COLORS.NEUTRAL_5,
34
34
  borderRadius: 400,
@@ -0,0 +1,44 @@
1
+ import {
2
+ COLORS,
3
+ Loader,
4
+ LoaderColor,
5
+ LoaderSize,
6
+ SPACING,
7
+ Typography,
8
+ } from '@magmamath/react-native-ui'
9
+ import React from 'react'
10
+ import { StyleSheet, View } from 'react-native'
11
+
12
+ type VoiceTranscriptContentProps = {
13
+ text: string
14
+ isLoading: boolean
15
+ }
16
+
17
+ export const VoiceTranscriptContent = ({ text, isLoading }: VoiceTranscriptContentProps) => {
18
+ if (isLoading) {
19
+ return (
20
+ <View style={styles.loaderContainer}>
21
+ <Loader size={LoaderSize.SMALL} color={LoaderColor.BLUE} />
22
+ </View>
23
+ )
24
+ }
25
+
26
+ return (
27
+ <Typography variant="h8" style={styles.text}>
28
+ {text}
29
+ </Typography>
30
+ )
31
+ }
32
+
33
+ const styles = StyleSheet.create({
34
+ text: {
35
+ color: COLORS.NEUTRAL_7,
36
+ paddingHorizontal: SPACING[200],
37
+ paddingVertical: SPACING[200],
38
+ },
39
+ loaderContainer: {
40
+ justifyContent: 'center',
41
+ alignItems: 'center',
42
+ paddingVertical: SPACING[200],
43
+ },
44
+ })
@@ -0,0 +1,117 @@
1
+ import { Typography, COLORS, SPACING } from '@magmamath/react-native-ui'
2
+ import React from 'react'
3
+ import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native'
4
+ import Animated from 'react-native-reanimated'
5
+ import { AnswerAudio, VoiceTranscriptionVariant } from '../../types'
6
+ import { useText } from '../../../../i18n/i18n'
7
+ import { useVoiceTranscriptionController } from '../hooks/useVoiceTranscriptionController'
8
+ import { VoicePlayerModel } from '../model'
9
+ import { VoiceTranscriptContent } from './VoiceTranscriptContent'
10
+ import { VoiceTranscriptionCollapsible } from './VoiceTranscriptionCollapsible'
11
+ import { VoiceTranscriptionHeaderActions } from './VoiceTranscriptionHeaderActions'
12
+
13
+ type VoiceTranscriptionProps = {
14
+ style?: StyleProp<ViewStyle>
15
+ model: VoicePlayerModel
16
+ answers: AnswerAudio[]
17
+ attemptOffset: number
18
+ attemptsCount: number
19
+ problemId: string
20
+ variant?: VoiceTranscriptionVariant
21
+ }
22
+
23
+ export const VoiceTranscription = ({
24
+ style,
25
+ model,
26
+ answers,
27
+ attemptOffset,
28
+ attemptsCount,
29
+ problemId,
30
+ variant = VoiceTranscriptionVariant.SMALL,
31
+ }: VoiceTranscriptionProps) => {
32
+ const t = useText()
33
+ const { display, flags, actions } = useVoiceTranscriptionController({
34
+ model,
35
+ answers,
36
+ attemptOffset,
37
+ attemptsCount,
38
+ problemId,
39
+ })
40
+ const isLargeVariant = variant === VoiceTranscriptionVariant.LARGE
41
+
42
+ return (
43
+ <Animated.View
44
+ style={[
45
+ styles.container,
46
+ isLargeVariant ? styles.largeContainer : styles.smallContainer,
47
+ style,
48
+ ]}
49
+ >
50
+ <View style={styles.header}>
51
+ <Typography style={styles.title} variant="h7">
52
+ {t('voice.transcriptions')}
53
+ </Typography>
54
+ {flags.anyAttemptHasAudio && (
55
+ <VoiceTranscriptionHeaderActions
56
+ playerState={flags.playerState}
57
+ isTranslationActive={flags.isTranslationActive}
58
+ canTranslate={flags.canTranslate}
59
+ onPlayPress={actions.onPlayPress}
60
+ onTranslationPress={actions.onTranslationToggle}
61
+ />
62
+ )}
63
+ </View>
64
+
65
+ {isLargeVariant ? (
66
+ <VoiceTranscriptContent text={display.text} isLoading={display.isLoading} />
67
+ ) : (
68
+ <VoiceTranscriptionCollapsible
69
+ text={display.text}
70
+ isLoading={display.isLoading}
71
+ dropdown={model.dropdown}
72
+ />
73
+ )}
74
+ </Animated.View>
75
+ )
76
+ }
77
+
78
+ const styles = StyleSheet.create({
79
+ container: {
80
+ padding: SPACING[100],
81
+ boxShadow: '0px 1px 3px 0px rgba(51, 51, 51, 0.25)',
82
+ borderRadius: 12,
83
+ backgroundColor: COLORS.NEUTRAL_1,
84
+ overflow: 'hidden',
85
+ },
86
+ // SMALL: floats over the drawing area; consumer-positioned siblings sit
87
+ // beneath it. Absolute positioning is intentional here.
88
+ smallContainer: {
89
+ position: 'absolute',
90
+ top: 56,
91
+ left: SPACING[200],
92
+ width: 222,
93
+ maxHeight: 405,
94
+ minHeight: 51,
95
+ },
96
+ // LARGE: rendered as a flex child of the SolutionCard's column flow,
97
+ // between the header and footer. Auto-sizes to whatever space the footer
98
+ // (with or without the playable timeline) leaves — no magic numbers.
99
+ largeContainer: {
100
+ flex: 1,
101
+ marginHorizontal: SPACING[200],
102
+ marginTop: SPACING[200],
103
+ marginBottom: SPACING[200],
104
+ },
105
+ header: {
106
+ flexDirection: 'row',
107
+ justifyContent: 'space-between',
108
+ alignItems: 'center',
109
+ padding: SPACING[100],
110
+ marginBottom: SPACING[100],
111
+ height: 32,
112
+ },
113
+ title: {
114
+ color: COLORS.NEUTRAL_9,
115
+ marginLeft: SPACING[100],
116
+ },
117
+ })
@@ -0,0 +1,59 @@
1
+ import { CaretDownIcon } from '@magmamath/react-native-ui'
2
+ import React, { useCallback } from 'react'
3
+ import { StyleSheet, TouchableOpacity, View } from 'react-native'
4
+ import Animated from 'react-native-reanimated'
5
+ import { useDropdownAnimation } from '../hooks/useDropdownAnimation'
6
+ import { DropdownModel } from '../model/Dropdown.model'
7
+ import { VoiceTranscriptContent } from './VoiceTranscriptContent'
8
+
9
+ const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpacity)
10
+
11
+ type VoiceTranscriptionCollapsibleProps = {
12
+ text: string
13
+ isLoading: boolean
14
+ dropdown: DropdownModel
15
+ }
16
+
17
+ export const VoiceTranscriptionCollapsible = ({
18
+ text,
19
+ isLoading,
20
+ dropdown,
21
+ }: VoiceTranscriptionCollapsibleProps) => {
22
+ const { listAnimatedStyle, iconAnimatedStyle, onListLayout } =
23
+ useDropdownAnimation(dropdown)
24
+
25
+ const handleToggle = useCallback(() => {
26
+ dropdown.toggleExpand()
27
+ }, [dropdown])
28
+
29
+ return (
30
+ <>
31
+ <Animated.View style={[listAnimatedStyle, styles.collapsibleContent]}>
32
+ <View onLayout={onListLayout} style={styles.transcriptContainer}>
33
+ <VoiceTranscriptContent text={text} isLoading={isLoading} />
34
+ </View>
35
+ </Animated.View>
36
+ <AnimatedTouchableOpacity
37
+ style={[styles.expandButton, iconAnimatedStyle]}
38
+ onPress={handleToggle}
39
+ >
40
+ <CaretDownIcon size={22} />
41
+ </AnimatedTouchableOpacity>
42
+ </>
43
+ )
44
+ }
45
+
46
+ const styles = StyleSheet.create({
47
+ collapsibleContent: {
48
+ overflow: 'hidden',
49
+ },
50
+ transcriptContainer: {
51
+ position: 'absolute',
52
+ width: '100%',
53
+ paddingHorizontal: 4,
54
+ },
55
+ expandButton: {
56
+ justifyContent: 'center',
57
+ alignItems: 'center',
58
+ },
59
+ })
@@ -0,0 +1,61 @@
1
+ import { Button, COLORS, GlobeIcon, SPACING } from '@magmamath/react-native-ui'
2
+ import React from 'react'
3
+ import { StyleSheet, View } from 'react-native'
4
+ import { ColorScheme } from '../../../chatbot/types/style.types'
5
+ import { PlayButton } from '../../../../shared/components/PlayButton'
6
+ import { PlayerState } from '../model'
7
+ import { getAudioStatus } from '../../helpers'
8
+
9
+ type VoiceTranscriptionsHeaderActionsProps = {
10
+ playerState: PlayerState
11
+ isTranslationActive: boolean
12
+ canTranslate: boolean
13
+ onPlayPress: () => void
14
+ onTranslationPress: () => void
15
+ }
16
+
17
+ export const VoiceTranscriptionHeaderActions = ({
18
+ playerState,
19
+ isTranslationActive,
20
+ canTranslate,
21
+ onPlayPress,
22
+ onTranslationPress,
23
+ }: VoiceTranscriptionsHeaderActionsProps) => {
24
+ const playButtonState = {
25
+ isActive: playerState !== PlayerState.IDLE,
26
+ isLoading: playerState === PlayerState.LOADING,
27
+ status: getAudioStatus(playerState),
28
+ }
29
+
30
+ return (
31
+ <View style={styles.container}>
32
+ <PlayButton
33
+ state={playButtonState}
34
+ onPress={onPlayPress}
35
+ activityIndicatorColor={COLORS.NEUTRAL_1}
36
+ colorScheme={ColorScheme.Yellow}
37
+ />
38
+ {canTranslate && (
39
+ <Button
40
+ variant="secondary"
41
+ size="small"
42
+ colorScheme={ColorScheme.Yellow}
43
+ isActive={isTranslationActive}
44
+ onPress={onTranslationPress}
45
+ icon={<GlobeIcon color={isTranslationActive ? COLORS.NEUTRAL_1 : COLORS.NEUTRAL_9} />}
46
+ />
47
+ )}
48
+ </View>
49
+ )
50
+ }
51
+
52
+ const styles = StyleSheet.create({
53
+ container: {
54
+ flexDirection: 'row',
55
+ alignItems: 'center',
56
+ gap: SPACING[200],
57
+ },
58
+ hidden: {
59
+ opacity: 0,
60
+ },
61
+ })
@@ -1,11 +1,11 @@
1
1
  import { useEffect } from 'react'
2
2
  import { useUnit } from 'effector-react'
3
3
  import { useAnimatedStyle, useSharedValue, withTiming, interpolate } from 'react-native-reanimated'
4
- import { VoiceTranscriptionsDropdownModel } from '../model/VoiceTranscriptionsDropdown.model'
4
+ import { DropdownModel } from '../model/Dropdown.model'
5
5
  import { DROPDOWN_MAX_CONTENT_HEIGHT } from '../../constants'
6
6
  import { LayoutChangeEvent } from 'react-native'
7
7
 
8
- export const useVoiceTranscriptionsDropdown = (model: VoiceTranscriptionsDropdownModel) => {
8
+ export const useDropdownAnimation = (model: DropdownModel) => {
9
9
  const isExpanded = useUnit(model.$isExpanded)
10
10
 
11
11
  const contentHeight = useSharedValue(0)
@@ -13,9 +13,9 @@ export const useVoiceTranscriptionsDropdown = (model: VoiceTranscriptionsDropdow
13
13
 
14
14
  const onListLayout = (event: LayoutChangeEvent) => {
15
15
  const measuredHeight = event.nativeEvent.layout.height
16
- if (measuredHeight > 0) {
17
- contentHeight.value = measuredHeight
18
- }
16
+ if (measuredHeight <= 0) return
17
+ contentHeight.value =
18
+ contentHeight.value === 0 ? measuredHeight : withTiming(measuredHeight, { duration: 180 })
19
19
  }
20
20
 
21
21
  const listAnimatedStyle = useAnimatedStyle(() => {
@@ -0,0 +1,64 @@
1
+ import { useEffect, useMemo, useRef } from 'react'
2
+ import { getActiveAttempt } from '../../helpers'
3
+ import { AnswerAudio } from '../../types'
4
+ import { VoicePlayerModel } from '../model'
5
+
6
+ type Params = {
7
+ model: VoicePlayerModel
8
+ answers: AnswerAudio[]
9
+ attemptOffset: number
10
+ attemptsCount: number
11
+ problemId: string
12
+ }
13
+
14
+ // Owns playback engine mutations (init/reset/setCurrentAttempt/stopAudio).
15
+ // VoiceTranscription stays read-only; consumers call this once per page.
16
+ export const useVoicePlayerLifecycle = ({
17
+ model,
18
+ answers,
19
+ attemptOffset,
20
+ attemptsCount,
21
+ problemId,
22
+ }: Params) => {
23
+ const activeAttempt = getActiveAttempt(attemptOffset, attemptsCount)
24
+
25
+ const answersKey = useMemo(
26
+ () => answers.map((a) => `${a._id}:${a.audioFileId ?? ''}`).join(','),
27
+ [answers],
28
+ )
29
+
30
+ const hasAnyAudio = useMemo(() => answers.some((a) => !!a.audioFileId), [answers])
31
+
32
+ const answersRef = useRef(answers)
33
+ answersRef.current = answers
34
+
35
+ useEffect(() => {
36
+ model.reinitializePlayer()
37
+ // No stopAudio cleanup: this hook re-runs across normal renders in some
38
+ // host components, and tearing down audio in the cleanup races with
39
+ // play() requests from other consumers (e.g. TimelineManager). The page
40
+ // unmount path (resetPlayer / cleanup) still releases audio properly.
41
+ }, [model])
42
+
43
+ useEffect(() => {
44
+ model.resetPlayer()
45
+ }, [problemId])
46
+
47
+ useEffect(() => {
48
+ if (answersRef.current.some((a) => a.audioFileId)) {
49
+ model.initializeWithAudios(answersRef.current)
50
+ }
51
+ }, [model, answersKey])
52
+
53
+ useEffect(() => {
54
+ // No stopAudio: VoiceSource (timeline) and VoiceTranscription (manual play
55
+ // button) drive playback transitions themselves. Calling stopAudio here
56
+ // races with concurrent play() requests and aborts in-flight audio.play().
57
+ model.setCurrentAttempt(activeAttempt)
58
+ if (activeAttempt !== null) {
59
+ model.loader.loadTranscriptForAttempt(activeAttempt)
60
+ }
61
+ }, [model, activeAttempt, answersKey])
62
+
63
+ return { activeAttempt, hasAnyAudio }
64
+ }
@@ -0,0 +1,148 @@
1
+ import { useUnit } from 'effector-react'
2
+ import { useCallback, useEffect, useMemo, useRef } from 'react'
3
+ import { useTranslation } from 'react-i18next'
4
+ import { NO_AUDIO_BE_MESSAGE } from '../../constants'
5
+ import { getActiveAttempt } from '../../helpers'
6
+ import { AnswerAudio } from '../../types'
7
+ import { resolveGoogleLanguageCode } from '../../../translation/providers/google/supportedLanguages'
8
+ import { useText } from '../../../../i18n/i18n'
9
+ import { VoicePlayerModel } from '../model'
10
+ import { PlayerState } from '../model/Player.model'
11
+
12
+ type Params = {
13
+ model: VoicePlayerModel
14
+ answers: AnswerAudio[]
15
+ attemptOffset: number
16
+ attemptsCount: number
17
+ problemId: string
18
+ }
19
+
20
+ export type VoiceTranscriptionController = ReturnType<typeof useVoiceTranscriptionController>
21
+
22
+ export const useVoiceTranscriptionController = ({
23
+ model,
24
+ answers,
25
+ attemptOffset,
26
+ attemptsCount,
27
+ problemId,
28
+ }: Params) => {
29
+ const t = useText()
30
+ const { i18n } = useTranslation()
31
+
32
+ const [playerState, isLoadingTranscripts, isTranslationActive, translations, isTranslating] =
33
+ useUnit([
34
+ model.$playerState,
35
+ model.loader.loadTranscriptForAttempt.pending,
36
+ model.translation.$isActive,
37
+ model.translation.$translations,
38
+ model.translation.translate.pending,
39
+ ])
40
+ // Auto-activate translation once per (problemId, activeAttempt) when translatable
41
+ const autoActivatedAttempts = useRef(new Set<number>())
42
+
43
+ const activeAttempt = getActiveAttempt(attemptOffset, attemptsCount)
44
+
45
+ const activeAudioFileId =
46
+ activeAttempt !== null ? answers?.[activeAttempt - 1]?.audioFileId : undefined
47
+ const hasActiveAudio = activeAudioFileId !== undefined
48
+ const anyAttemptHasAudio = useMemo(() => answers.some((a) => !!a.audioFileId), [answers])
49
+
50
+ const cachedEntry = activeAudioFileId
51
+ ? model.loader.getCachedTranscript(activeAudioFileId)
52
+ : undefined
53
+ const activeTranscript = cachedEntry?.text ?? null
54
+ const hasTranscriptText = !!activeTranscript && activeTranscript !== NO_AUDIO_BE_MESSAGE
55
+ const isActiveTranscriptLoading = isLoadingTranscripts && hasActiveAudio && !activeTranscript
56
+
57
+ const isSourceSameAsTarget =
58
+ !!cachedEntry?.language &&
59
+ resolveGoogleLanguageCode(cachedEntry.language) === resolveGoogleLanguageCode(i18n.language)
60
+
61
+ const canTranslate = hasTranscriptText && !isSourceSameAsTarget
62
+
63
+ const cachedTranslation = activeAttempt !== null ? translations[activeAttempt] : undefined
64
+ const showTranslation = isTranslationActive && canTranslate
65
+ const isTranslationLoading = showTranslation && !cachedTranslation && isTranslating
66
+
67
+ const displayText = showTranslation
68
+ ? (cachedTranslation ?? activeTranscript!)
69
+ : hasTranscriptText
70
+ ? activeTranscript!
71
+ : t('voice.transcriptNotAvailable')
72
+
73
+ // UI-only lifecycle: collapse the dropdown on mount/unmount and on problem
74
+ // change. Playback engine mutations (init/reset/setCurrentAttempt/stopAudio)
75
+ // are owned by useVoicePlayerLifecycle, called by the page-level consumer.
76
+ useEffect(() => {
77
+ return () => {
78
+ model.dropdown.setExpanded(false)
79
+ }
80
+ }, [model])
81
+
82
+ useEffect(() => {
83
+ model.dropdown.setExpanded(false)
84
+ }, [problemId])
85
+
86
+ useEffect(() => {
87
+ autoActivatedAttempts.current.clear()
88
+ }, [problemId])
89
+ useEffect(() => {
90
+ if (
91
+ canTranslate &&
92
+ activeAttempt !== null &&
93
+ !autoActivatedAttempts.current.has(activeAttempt)
94
+ ) {
95
+ autoActivatedAttempts.current.add(activeAttempt)
96
+ model.translation.setActive(true)
97
+ }
98
+ }, [canTranslate, activeAttempt, model])
99
+
100
+ // Trigger translate when we should show translation but don't have it cached
101
+ useEffect(() => {
102
+ if (showTranslation && activeAttempt !== null && !cachedTranslation && !isTranslating) {
103
+ model.translation.translate({
104
+ attemptNumber: activeAttempt,
105
+ targetLanguage: i18n.language,
106
+ })
107
+ }
108
+ }, [showTranslation, activeAttempt, cachedTranslation, isTranslating, i18n.language, model])
109
+
110
+ // Auto-open dropdown when a translation successfully completes
111
+ useEffect(() => {
112
+ return model.translation.translate.doneData.watch((result) => {
113
+ if (result) {
114
+ model.dropdown.setExpanded(true)
115
+ }
116
+ })
117
+ }, [model])
118
+
119
+ const onPlayPress = useCallback(() => {
120
+ if (activeAttempt) {
121
+ model.translation.setActive(false)
122
+ model.togglePlayPause(activeAttempt)
123
+ }
124
+ }, [model, activeAttempt])
125
+
126
+ const onTranslationToggle = useCallback(() => {
127
+ model.translation.toggle()
128
+ model.dropdown.setExpanded(true)
129
+ }, [model])
130
+
131
+ return {
132
+ display: {
133
+ text: displayText,
134
+ isLoading: isActiveTranscriptLoading || isTranslationLoading,
135
+ },
136
+ flags: {
137
+ playerState: playerState as PlayerState,
138
+ hasActiveAudio,
139
+ anyAttemptHasAudio,
140
+ canTranslate,
141
+ isTranslationActive,
142
+ },
143
+ actions: {
144
+ onPlayPress,
145
+ onTranslationToggle,
146
+ },
147
+ }
148
+ }
@@ -1,6 +1,6 @@
1
- import { createEvent, createStore, restore } from 'effector'
1
+ import { createEvent, restore } from 'effector'
2
2
 
3
- export class VoiceTranscriptionsDropdownModel {
3
+ export class DropdownModel {
4
4
  public readonly toggleExpand = createEvent()
5
5
  public readonly setExpanded = createEvent<boolean>()
6
6
  public readonly reset = createEvent()