@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.
- package/dist/commonjs/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.js +1 -6
- package/dist/commonjs/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.js.map +1 -1
- package/dist/commonjs/features/fluency/components/Fluency.js +6 -12
- package/dist/commonjs/features/fluency/components/Fluency.js.map +1 -1
- package/dist/commonjs/features/fluency/components/select-math-operator/SelectMathOperator.js +5 -13
- package/dist/commonjs/features/fluency/components/select-math-operator/SelectMathOperator.js.map +1 -1
- package/dist/commonjs/features/fluency/model/FluencyModel.js +0 -21
- package/dist/commonjs/features/fluency/model/FluencyModel.js.map +1 -1
- package/dist/commonjs/features/fluency/shared/fluency.constants.js +1 -6
- package/dist/commonjs/features/fluency/shared/fluency.constants.js.map +1 -1
- package/dist/commonjs/features/fluency/shared/fluency.helpers.js +1 -3
- package/dist/commonjs/features/fluency/shared/fluency.helpers.js.map +1 -1
- package/dist/commonjs/features/pmProgress/model/PmProgressModel.js +1 -7
- package/dist/commonjs/features/pmProgress/model/PmProgressModel.js.map +1 -1
- package/dist/commonjs/features/pmProgress/model/PmRecommendationsModel.js +4 -20
- package/dist/commonjs/features/pmProgress/model/PmRecommendationsModel.js.map +1 -1
- package/dist/commonjs/features/pmProgress/shared/pmProgress.helpers.js +1 -22
- package/dist/commonjs/features/pmProgress/shared/pmProgress.helpers.js.map +1 -1
- package/dist/commonjs/features/translation/constants.js +11 -0
- package/dist/commonjs/features/translation/constants.js.map +1 -0
- package/dist/commonjs/features/translation/helpers.js +60 -0
- package/dist/commonjs/features/translation/helpers.js.map +1 -0
- package/dist/commonjs/features/translation/index.js +105 -0
- package/dist/commonjs/features/translation/index.js.map +1 -0
- package/dist/commonjs/features/translation/model/TranslationModel.js +122 -0
- package/dist/commonjs/features/translation/model/TranslationModel.js.map +1 -0
- package/dist/commonjs/features/translation/model/TranslationPreprocessor.js +142 -0
- package/dist/commonjs/features/translation/model/TranslationPreprocessor.js.map +1 -0
- package/dist/commonjs/features/translation/model/TranslationService.js +112 -0
- package/dist/commonjs/features/translation/model/TranslationService.js.map +1 -0
- package/dist/commonjs/features/translation/preserve/wordsToPreserve.js +314 -0
- package/dist/commonjs/features/translation/preserve/wordsToPreserve.js.map +1 -0
- package/dist/commonjs/features/translation/providers/google/GoogleTranslationProvider.js +50 -0
- package/dist/commonjs/features/translation/providers/google/GoogleTranslationProvider.js.map +1 -0
- package/dist/commonjs/features/translation/providers/google/supportedLanguages.js +230 -0
- package/dist/commonjs/features/translation/providers/google/supportedLanguages.js.map +1 -0
- package/dist/commonjs/features/translation/providers/google.types.js +2 -0
- package/dist/commonjs/features/translation/providers/google.types.js.map +1 -0
- package/dist/commonjs/features/translation/providers/translation.interface.js +49 -0
- package/dist/commonjs/features/translation/providers/translation.interface.js.map +1 -0
- package/dist/commonjs/features/translation/types.js +2 -0
- package/dist/commonjs/features/translation/types.js.map +1 -0
- package/dist/commonjs/features/voice/index.js +15 -4
- package/dist/commonjs/features/voice/index.js.map +1 -1
- package/dist/commonjs/features/voice/playing/components/VoiceIcon.js +1 -1
- package/dist/commonjs/features/voice/playing/components/VoiceIcon.js.map +1 -1
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js +44 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js +107 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js.map +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js +66 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +1 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +58 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.js → useDropdownAnimation.js} +8 -7
- package/dist/commonjs/features/voice/playing/hooks/useDropdownAnimation.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoicePlayerLifecycle.js +53 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoicePlayerLifecycle.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.js +111 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.js → Dropdown.model.js} +4 -4
- package/dist/commonjs/features/voice/playing/model/Dropdown.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/PlaybackController.js +192 -0
- package/dist/commonjs/features/voice/playing/model/PlaybackController.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/Player.model.js +50 -5
- package/dist/commonjs/features/voice/playing/model/Player.model.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/{VoiceTranscriptionsCollection.js → TranscriptionsCollection.js} +4 -4
- package/dist/commonjs/features/voice/playing/model/TranscriptionsCollection.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js +83 -0
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/Translation.model.js +62 -0
- package/dist/commonjs/features/voice/playing/model/Translation.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/VoiceFileDownloader.model.js +2 -2
- package/dist/commonjs/features/voice/playing/model/VoiceFileDownloader.model.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js +58 -172
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
- package/dist/commonjs/features/voice/recording/components/VoiceRecordDivider.js +1 -1
- package/dist/commonjs/features/voice/recording/components/VoiceRecordDivider.js.map +1 -1
- package/dist/commonjs/features/voice/types.js +12 -1
- package/dist/commonjs/features/voice/types.js.map +1 -1
- package/dist/commonjs/index.js +12 -0
- package/dist/commonjs/index.js.map +1 -1
- package/dist/module/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.js +2 -7
- package/dist/module/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.js.map +1 -1
- package/dist/module/features/fluency/components/Fluency.js +8 -14
- package/dist/module/features/fluency/components/Fluency.js.map +1 -1
- package/dist/module/features/fluency/components/select-math-operator/SelectMathOperator.js +5 -13
- package/dist/module/features/fluency/components/select-math-operator/SelectMathOperator.js.map +1 -1
- package/dist/module/features/fluency/model/FluencyModel.js +1 -22
- package/dist/module/features/fluency/model/FluencyModel.js.map +1 -1
- package/dist/module/features/fluency/shared/fluency.constants.js +0 -5
- package/dist/module/features/fluency/shared/fluency.constants.js.map +1 -1
- package/dist/module/features/fluency/shared/fluency.helpers.js +0 -1
- package/dist/module/features/fluency/shared/fluency.helpers.js.map +1 -1
- package/dist/module/features/pmProgress/model/PmProgressModel.js +1 -7
- package/dist/module/features/pmProgress/model/PmProgressModel.js.map +1 -1
- package/dist/module/features/pmProgress/model/PmRecommendationsModel.js +4 -20
- package/dist/module/features/pmProgress/model/PmRecommendationsModel.js.map +1 -1
- package/dist/module/features/pmProgress/shared/pmProgress.helpers.js +0 -20
- package/dist/module/features/pmProgress/shared/pmProgress.helpers.js.map +1 -1
- package/dist/module/features/translation/constants.js +7 -0
- package/dist/module/features/translation/constants.js.map +1 -0
- package/dist/module/features/translation/helpers.js +53 -0
- package/dist/module/features/translation/helpers.js.map +1 -0
- package/dist/module/features/translation/index.js +12 -0
- package/dist/module/features/translation/index.js.map +1 -0
- package/dist/module/features/translation/model/TranslationModel.js +117 -0
- package/dist/module/features/translation/model/TranslationModel.js.map +1 -0
- package/dist/module/features/translation/model/TranslationPreprocessor.js +137 -0
- package/dist/module/features/translation/model/TranslationPreprocessor.js.map +1 -0
- package/dist/module/features/translation/model/TranslationService.js +107 -0
- package/dist/module/features/translation/model/TranslationService.js.map +1 -0
- package/dist/module/features/translation/preserve/wordsToPreserve.js +310 -0
- package/dist/module/features/translation/preserve/wordsToPreserve.js.map +1 -0
- package/dist/module/features/translation/providers/google/GoogleTranslationProvider.js +45 -0
- package/dist/module/features/translation/providers/google/GoogleTranslationProvider.js.map +1 -0
- package/dist/module/features/translation/providers/google/supportedLanguages.js +225 -0
- package/dist/module/features/translation/providers/google/supportedLanguages.js.map +1 -0
- package/dist/module/features/translation/providers/google.types.js +2 -0
- package/dist/module/features/translation/providers/google.types.js.map +1 -0
- package/dist/module/features/translation/providers/translation.interface.js +44 -0
- package/dist/module/features/translation/providers/translation.interface.js.map +1 -0
- package/dist/module/features/translation/types.js +2 -0
- package/dist/module/features/translation/types.js.map +1 -0
- package/dist/module/features/voice/index.js +2 -1
- package/dist/module/features/voice/index.js.map +1 -1
- package/dist/module/features/voice/playing/components/VoiceIcon.js +2 -2
- package/dist/module/features/voice/playing/components/VoiceIcon.js.map +1 -1
- package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js +38 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -0
- package/dist/module/features/voice/playing/components/VoiceTranscription.js +101 -0
- package/dist/module/features/voice/playing/components/VoiceTranscription.js.map +1 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js +58 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +1 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +52 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.js → useDropdownAnimation.js} +6 -5
- package/dist/module/features/voice/playing/hooks/useDropdownAnimation.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/useVoicePlayerLifecycle.js +48 -0
- package/dist/module/features/voice/playing/hooks/useVoicePlayerLifecycle.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionController.js +106 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionController.js.map +1 -0
- package/dist/module/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.js → Dropdown.model.js} +2 -2
- package/dist/module/features/voice/playing/model/Dropdown.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/PlaybackController.js +187 -0
- package/dist/module/features/voice/playing/model/PlaybackController.js.map +1 -0
- package/dist/module/features/voice/playing/model/Player.model.js +51 -4
- package/dist/module/features/voice/playing/model/Player.model.js.map +1 -1
- package/dist/module/features/voice/playing/model/{VoiceTranscriptionsCollection.js → TranscriptionsCollection.js} +2 -2
- package/dist/module/features/voice/playing/model/TranscriptionsCollection.js.map +1 -0
- package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js +78 -0
- package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/Translation.model.js +57 -0
- package/dist/module/features/voice/playing/model/Translation.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/VoiceFileDownloader.model.js +2 -2
- package/dist/module/features/voice/playing/model/VoiceFileDownloader.model.js.map +1 -1
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js +60 -174
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
- package/dist/module/features/voice/recording/components/VoiceRecordDivider.js +2 -2
- package/dist/module/features/voice/recording/components/VoiceRecordDivider.js.map +1 -1
- package/dist/module/features/voice/types.js +11 -0
- package/dist/module/features/voice/types.js.map +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/index.js.map +1 -1
- package/dist/typescript/commonjs/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/fluency/components/Fluency.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/fluency/components/select-math-operator/SelectMathOperator.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/fluency/model/FluencyModel.d.ts +0 -3
- package/dist/typescript/commonjs/features/fluency/model/FluencyModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/fluency/shared/fluency.constants.d.ts +0 -4
- package/dist/typescript/commonjs/features/fluency/shared/fluency.constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/fluency/shared/fluency.helpers.d.ts +0 -1
- package/dist/typescript/commonjs/features/fluency/shared/fluency.helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/pmProgress/model/PmProgressModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/pmProgress/model/PmRecommendationsModel.d.ts +38 -9
- package/dist/typescript/commonjs/features/pmProgress/model/PmRecommendationsModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/pmProgress/shared/pmProgress.helpers.d.ts +0 -1
- package/dist/typescript/commonjs/features/pmProgress/shared/pmProgress.helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/translation/constants.d.ts +5 -0
- package/dist/typescript/commonjs/features/translation/constants.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/helpers.d.ts +9 -0
- package/dist/typescript/commonjs/features/translation/helpers.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/index.d.ts +12 -0
- package/dist/typescript/commonjs/features/translation/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationModel.d.ts +33 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationModel.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationPreprocessor.d.ts +34 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationPreprocessor.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationService.d.ts +40 -0
- package/dist/typescript/commonjs/features/translation/model/TranslationService.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/preserve/wordsToPreserve.d.ts +3 -0
- package/dist/typescript/commonjs/features/translation/preserve/wordsToPreserve.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/providers/google/GoogleTranslationProvider.d.ts +17 -0
- package/dist/typescript/commonjs/features/translation/providers/google/GoogleTranslationProvider.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/providers/google/supportedLanguages.d.ts +209 -0
- package/dist/typescript/commonjs/features/translation/providers/google/supportedLanguages.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/providers/google.types.d.ts +15 -0
- package/dist/typescript/commonjs/features/translation/providers/google.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/providers/translation.interface.d.ts +30 -0
- package/dist/typescript/commonjs/features/translation/providers/translation.interface.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/translation/types.d.ts +27 -0
- package/dist/typescript/commonjs/features/translation/types.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/index.d.ts +3 -1
- package/dist/typescript/commonjs/features/voice/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts +8 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts +16 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +10 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts +12 -0
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.d.ts → useDropdownAnimation.d.ts} +3 -3
- package/dist/typescript/commonjs/features/voice/playing/hooks/useDropdownAnimation.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoicePlayerLifecycle.d.ts +15 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoicePlayerLifecycle.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts +30 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts.map +1 -0
- package/dist/typescript/{module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts → commonjs/features/voice/playing/model/Dropdown.model.d.ts} +2 -2
- package/dist/typescript/commonjs/features/voice/playing/model/Dropdown.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/PlaybackController.d.ts +28 -0
- package/dist/typescript/commonjs/features/voice/playing/model/PlaybackController.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/Player.model.d.ts +4 -0
- package/dist/typescript/commonjs/features/voice/playing/model/Player.model.d.ts.map +1 -1
- package/dist/typescript/{module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts → commonjs/features/voice/playing/model/TranscriptionsCollection.d.ts} +2 -2
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsCollection.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +19 -0
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/Translation.model.d.ts +25 -0
- package/dist/typescript/commonjs/features/voice/playing/model/Translation.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceFileDownloader.model.d.ts +2 -2
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceFileDownloader.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts +19 -18
- package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/types.d.ts +14 -2
- package/dist/typescript/commonjs/features/voice/types.d.ts.map +1 -1
- package/dist/typescript/commonjs/index.d.ts +1 -0
- package/dist/typescript/commonjs/index.d.ts.map +1 -1
- package/dist/typescript/module/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.d.ts.map +1 -1
- package/dist/typescript/module/features/fluency/components/Fluency.d.ts.map +1 -1
- package/dist/typescript/module/features/fluency/components/select-math-operator/SelectMathOperator.d.ts.map +1 -1
- package/dist/typescript/module/features/fluency/model/FluencyModel.d.ts +0 -3
- package/dist/typescript/module/features/fluency/model/FluencyModel.d.ts.map +1 -1
- package/dist/typescript/module/features/fluency/shared/fluency.constants.d.ts +0 -4
- package/dist/typescript/module/features/fluency/shared/fluency.constants.d.ts.map +1 -1
- package/dist/typescript/module/features/fluency/shared/fluency.helpers.d.ts +0 -1
- package/dist/typescript/module/features/fluency/shared/fluency.helpers.d.ts.map +1 -1
- package/dist/typescript/module/features/pmProgress/model/PmProgressModel.d.ts.map +1 -1
- package/dist/typescript/module/features/pmProgress/model/PmRecommendationsModel.d.ts +38 -9
- package/dist/typescript/module/features/pmProgress/model/PmRecommendationsModel.d.ts.map +1 -1
- package/dist/typescript/module/features/pmProgress/shared/pmProgress.helpers.d.ts +0 -1
- package/dist/typescript/module/features/pmProgress/shared/pmProgress.helpers.d.ts.map +1 -1
- package/dist/typescript/module/features/translation/constants.d.ts +5 -0
- package/dist/typescript/module/features/translation/constants.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/helpers.d.ts +9 -0
- package/dist/typescript/module/features/translation/helpers.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/index.d.ts +12 -0
- package/dist/typescript/module/features/translation/index.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/model/TranslationModel.d.ts +33 -0
- package/dist/typescript/module/features/translation/model/TranslationModel.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/model/TranslationPreprocessor.d.ts +34 -0
- package/dist/typescript/module/features/translation/model/TranslationPreprocessor.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/model/TranslationService.d.ts +40 -0
- package/dist/typescript/module/features/translation/model/TranslationService.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/preserve/wordsToPreserve.d.ts +3 -0
- package/dist/typescript/module/features/translation/preserve/wordsToPreserve.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/providers/google/GoogleTranslationProvider.d.ts +17 -0
- package/dist/typescript/module/features/translation/providers/google/GoogleTranslationProvider.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/providers/google/supportedLanguages.d.ts +209 -0
- package/dist/typescript/module/features/translation/providers/google/supportedLanguages.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/providers/google.types.d.ts +15 -0
- package/dist/typescript/module/features/translation/providers/google.types.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/providers/translation.interface.d.ts +30 -0
- package/dist/typescript/module/features/translation/providers/translation.interface.d.ts.map +1 -0
- package/dist/typescript/module/features/translation/types.d.ts +27 -0
- package/dist/typescript/module/features/translation/types.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/index.d.ts +3 -1
- package/dist/typescript/module/features/voice/index.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts +8 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts +16 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +10 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts +12 -0
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.d.ts → useDropdownAnimation.d.ts} +3 -3
- package/dist/typescript/module/features/voice/playing/hooks/useDropdownAnimation.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoicePlayerLifecycle.d.ts +15 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoicePlayerLifecycle.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts +30 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts.map +1 -0
- package/dist/typescript/{commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts → module/features/voice/playing/model/Dropdown.model.d.ts} +2 -2
- package/dist/typescript/module/features/voice/playing/model/Dropdown.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/PlaybackController.d.ts +28 -0
- package/dist/typescript/module/features/voice/playing/model/PlaybackController.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/Player.model.d.ts +4 -0
- package/dist/typescript/module/features/voice/playing/model/Player.model.d.ts.map +1 -1
- package/dist/typescript/{commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts → module/features/voice/playing/model/TranscriptionsCollection.d.ts} +2 -2
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsCollection.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +19 -0
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/Translation.model.d.ts +25 -0
- package/dist/typescript/module/features/voice/playing/model/Translation.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceFileDownloader.model.d.ts +2 -2
- package/dist/typescript/module/features/voice/playing/model/VoiceFileDownloader.model.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts +19 -18
- package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/types.d.ts +14 -2
- package/dist/typescript/module/features/voice/types.d.ts.map +1 -1
- package/dist/typescript/module/index.d.ts +1 -0
- package/dist/typescript/module/index.d.ts.map +1 -1
- package/package.json +37 -10
- package/src/features/endOfAssignment/components/CorrectAnswer/CorrectAnswer.tsx +2 -9
- package/src/features/fluency/components/Fluency.tsx +9 -17
- package/src/features/fluency/components/select-math-operator/SelectMathOperator.tsx +5 -13
- package/src/features/fluency/model/FluencyModel.ts +1 -25
- package/src/features/fluency/shared/fluency.constants.ts +0 -5
- package/src/features/fluency/shared/fluency.helpers.ts +0 -3
- package/src/features/pmProgress/model/PmProgressModel.ts +1 -4
- package/src/features/pmProgress/model/PmRecommendationsModel.ts +6 -22
- package/src/features/pmProgress/shared/pmProgress.helpers.ts +0 -33
- package/src/features/translation/constants.ts +4 -0
- package/src/features/translation/helpers.ts +63 -0
- package/src/features/translation/index.ts +30 -0
- package/src/features/translation/model/TranslationModel.ts +174 -0
- package/src/features/translation/model/TranslationPreprocessor.ts +171 -0
- package/src/features/translation/model/TranslationService.ts +148 -0
- package/src/features/translation/preserve/wordsToPreserve.ts +87 -0
- package/src/features/translation/providers/google/GoogleTranslationProvider.ts +50 -0
- package/src/features/translation/providers/google/supportedLanguages.ts +229 -0
- package/src/features/translation/providers/google.types.ts +16 -0
- package/src/features/translation/providers/translation.interface.ts +63 -0
- package/src/features/translation/types.ts +30 -0
- package/src/features/voice/index.ts +3 -1
- package/src/features/voice/playing/components/VoiceIcon.tsx +2 -2
- package/src/features/voice/playing/components/VoiceTranscriptContent.tsx +44 -0
- package/src/features/voice/playing/components/VoiceTranscription.tsx +117 -0
- package/src/features/voice/playing/components/VoiceTranscriptionCollapsible.tsx +59 -0
- package/src/features/voice/playing/components/VoiceTranscriptionHeaderActions.tsx +61 -0
- package/src/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.ts → useDropdownAnimation.ts} +5 -5
- package/src/features/voice/playing/hooks/useVoicePlayerLifecycle.ts +64 -0
- package/src/features/voice/playing/hooks/useVoiceTranscriptionController.ts +148 -0
- package/src/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.ts → Dropdown.model.ts} +2 -2
- package/src/features/voice/playing/model/PlaybackController.ts +221 -0
- package/src/features/voice/playing/model/Player.model.ts +52 -4
- package/src/features/voice/playing/model/{VoiceTranscriptionsCollection.ts → TranscriptionsCollection.ts} +1 -1
- package/src/features/voice/playing/model/TranscriptionsDownloader.model.ts +88 -0
- package/src/features/voice/playing/model/Translation.model.ts +75 -0
- package/src/features/voice/playing/model/VoiceFileDownloader.model.ts +2 -2
- package/src/features/voice/playing/model/VoicePlayer.model.ts +68 -192
- package/src/features/voice/recording/components/VoiceRecordDivider.tsx +2 -2
- package/src/features/voice/types.ts +21 -1
- package/src/i18n/.generated/schema.json +3 -7
- package/src/index.ts +1 -0
- package/dist/commonjs/features/fluency/components/FluencyStatusOverlay.js +0 -101
- package/dist/commonjs/features/fluency/components/FluencyStatusOverlay.js.map +0 -1
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js +0 -245
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +0 -1
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +0 -109
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +0 -1
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +0 -1
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +0 -34
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +0 -1
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js +0 -66
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +0 -1
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +0 -1
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +0 -1
- package/dist/module/features/fluency/components/FluencyStatusOverlay.js +0 -95
- package/dist/module/features/fluency/components/FluencyStatusOverlay.js.map +0 -1
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js +0 -238
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdown.js.map +0 -1
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js +0 -103
- package/dist/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.js.map +0 -1
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.js.map +0 -1
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js +0 -29
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.js.map +0 -1
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js +0 -61
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +0 -1
- package/dist/module/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +0 -1
- package/dist/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.js.map +0 -1
- package/dist/typescript/commonjs/features/fluency/components/FluencyStatusOverlay.d.ts +0 -8
- package/dist/typescript/commonjs/features/fluency/components/FluencyStatusOverlay.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts +0 -16
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +0 -12
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +0 -11
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +0 -15
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +0 -1
- package/dist/typescript/module/features/fluency/components/FluencyStatusOverlay.d.ts +0 -8
- package/dist/typescript/module/features/fluency/components/FluencyStatusOverlay.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts +0 -16
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdown.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts +0 -12
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionsDropdownItem.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts +0 -11
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +0 -15
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsDropdown.model.d.ts.map +0 -1
- package/src/features/fluency/components/FluencyStatusOverlay.tsx +0 -101
- package/src/features/voice/playing/components/VoiceTranscriptionsDropdown.tsx +0 -296
- package/src/features/voice/playing/components/VoiceTranscriptionsDropdownItem.tsx +0 -128
- package/src/features/voice/playing/hooks/useVoiceTranscriptionsDropdownItemAnimation.ts +0 -40
- package/src/features/voice/playing/model/TranscriptionsDownloaderModel.ts +0 -80
|
@@ -4,15 +4,16 @@ import { useEffect } from 'react';
|
|
|
4
4
|
import { useUnit } from 'effector-react';
|
|
5
5
|
import { useAnimatedStyle, useSharedValue, withTiming, interpolate } from 'react-native-reanimated';
|
|
6
6
|
import { DROPDOWN_MAX_CONTENT_HEIGHT } from "../../constants.js";
|
|
7
|
-
export const
|
|
7
|
+
export const useDropdownAnimation = model => {
|
|
8
8
|
const isExpanded = useUnit(model.$isExpanded);
|
|
9
9
|
const contentHeight = useSharedValue(0);
|
|
10
10
|
const animationProgress = useSharedValue(isExpanded ? 1 : 0);
|
|
11
11
|
const onListLayout = event => {
|
|
12
12
|
const measuredHeight = event.nativeEvent.layout.height;
|
|
13
|
-
if (measuredHeight
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (measuredHeight <= 0) return;
|
|
14
|
+
contentHeight.value = contentHeight.value === 0 ? measuredHeight : withTiming(measuredHeight, {
|
|
15
|
+
duration: 180
|
|
16
|
+
});
|
|
16
17
|
};
|
|
17
18
|
const listAnimatedStyle = useAnimatedStyle(() => {
|
|
18
19
|
const height = interpolate(animationProgress.value, [0, 1], [0, contentHeight.value || DROPDOWN_MAX_CONTENT_HEIGHT]);
|
|
@@ -42,4 +43,4 @@ export const useVoiceTranscriptionsDropdown = model => {
|
|
|
42
43
|
onListLayout
|
|
43
44
|
};
|
|
44
45
|
};
|
|
45
|
-
//# sourceMappingURL=
|
|
46
|
+
//# sourceMappingURL=useDropdownAnimation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useUnit","useAnimatedStyle","useSharedValue","withTiming","interpolate","DROPDOWN_MAX_CONTENT_HEIGHT","useDropdownAnimation","model","isExpanded","$isExpanded","contentHeight","animationProgress","onListLayout","event","measuredHeight","nativeEvent","layout","height","value","duration","listAnimatedStyle","opacity","iconAnimatedStyle","rotation","transform","rotate"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useDropdownAnimation.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,OAAO,QAAQ,gBA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AAW,CAACO,iBAAiB,CAACO,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAEvE,OAAO;MACLM,SAAS,EAAE,CAAC;QAAEC,MAAM,EAAE,GAAGF,QAAQ;MAAM,CAAC;IAC1C,CAAC;EACH,CAAC,EAAE,CAACZ,iBAAiB,CAAC,CAAC;EAEvBZ,SAAS,CAAC,MAAM;IACdY,iBAAiB,CAACO,KAAK,GAAGf,UAAU,CAACK,UAAU,GAAG,CAAC,GAAG,CAAC,EAAE;MAAEW,QAAQ,EAAE;IAAI,CAAC,CAAC;EAC7E,CAAC,EAAE,CAACX,UAAU,EAAEG,iBAAiB,CAAC,CAAC;EAEnC,OAAO;IACLH,UAAU;IACVY,iBAAiB;IACjBE,iBAAiB;IACjBV;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
4
|
+
import { getActiveAttempt } from "../../helpers.js";
|
|
5
|
+
// Owns playback engine mutations (init/reset/setCurrentAttempt/stopAudio).
|
|
6
|
+
// VoiceTranscription stays read-only; consumers call this once per page.
|
|
7
|
+
export const useVoicePlayerLifecycle = ({
|
|
8
|
+
model,
|
|
9
|
+
answers,
|
|
10
|
+
attemptOffset,
|
|
11
|
+
attemptsCount,
|
|
12
|
+
problemId
|
|
13
|
+
}) => {
|
|
14
|
+
const activeAttempt = getActiveAttempt(attemptOffset, attemptsCount);
|
|
15
|
+
const answersKey = useMemo(() => answers.map(a => `${a._id}:${a.audioFileId ?? ''}`).join(','), [answers]);
|
|
16
|
+
const hasAnyAudio = useMemo(() => answers.some(a => !!a.audioFileId), [answers]);
|
|
17
|
+
const answersRef = useRef(answers);
|
|
18
|
+
answersRef.current = answers;
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
model.reinitializePlayer();
|
|
21
|
+
// No stopAudio cleanup: this hook re-runs across normal renders in some
|
|
22
|
+
// host components, and tearing down audio in the cleanup races with
|
|
23
|
+
// play() requests from other consumers (e.g. TimelineManager). The page
|
|
24
|
+
// unmount path (resetPlayer / cleanup) still releases audio properly.
|
|
25
|
+
}, [model]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
model.resetPlayer();
|
|
28
|
+
}, [problemId]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (answersRef.current.some(a => a.audioFileId)) {
|
|
31
|
+
model.initializeWithAudios(answersRef.current);
|
|
32
|
+
}
|
|
33
|
+
}, [model, answersKey]);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
// No stopAudio: VoiceSource (timeline) and VoiceTranscription (manual play
|
|
36
|
+
// button) drive playback transitions themselves. Calling stopAudio here
|
|
37
|
+
// races with concurrent play() requests and aborts in-flight audio.play().
|
|
38
|
+
model.setCurrentAttempt(activeAttempt);
|
|
39
|
+
if (activeAttempt !== null) {
|
|
40
|
+
model.loader.loadTranscriptForAttempt(activeAttempt);
|
|
41
|
+
}
|
|
42
|
+
}, [model, activeAttempt, answersKey]);
|
|
43
|
+
return {
|
|
44
|
+
activeAttempt,
|
|
45
|
+
hasAnyAudio
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=useVoicePlayerLifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useMemo","useRef","getActiveAttempt","useVoicePlayerLifecycle","model","answers","attemptOffset","attemptsCount","problemId","activeAttempt","answersKey","map","a","_id","audioFileId","join","hasAnyAudio","some","answersRef","current","reinitializePlayer","resetPlayer","initializeWithAudios","setCurrentAttempt","loader","loadTranscriptForAttempt"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useVoicePlayerLifecycle.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAClD,SAASC,gBAAgB,QAAQ,kBAA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,IAAI,EAAE;MAC1BL,KAAK,CAACoB,MAAM,CAACC,wBAAwB,CAAChB,aAAa,CAAC;IACtD;EACF,CAAC,EAAE,CAACL,KAAK,EAAEK,aAAa,EAAEC,UAAU,CAAC,CAAC;EAEtC,OAAO;IAAED,aAAa;IAAEO;EAAY,CAAC;AACvC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useUnit } from 'effector-react';
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { NO_AUDIO_BE_MESSAGE } from "../../constants.js";
|
|
7
|
+
import { getActiveAttempt } from "../../helpers.js";
|
|
8
|
+
import { resolveGoogleLanguageCode } from "../../../translation/providers/google/supportedLanguages.js";
|
|
9
|
+
import { useText } from "../../../../i18n/i18n.js";
|
|
10
|
+
export const useVoiceTranscriptionController = ({
|
|
11
|
+
model,
|
|
12
|
+
answers,
|
|
13
|
+
attemptOffset,
|
|
14
|
+
attemptsCount,
|
|
15
|
+
problemId
|
|
16
|
+
}) => {
|
|
17
|
+
const t = useText();
|
|
18
|
+
const {
|
|
19
|
+
i18n
|
|
20
|
+
} = useTranslation();
|
|
21
|
+
const [playerState, isLoadingTranscripts, isTranslationActive, translations, isTranslating] = useUnit([model.$playerState, model.loader.loadTranscriptForAttempt.pending, model.translation.$isActive, model.translation.$translations, model.translation.translate.pending]);
|
|
22
|
+
// Auto-activate translation once per (problemId, activeAttempt) when translatable
|
|
23
|
+
const autoActivatedAttempts = useRef(new Set());
|
|
24
|
+
const activeAttempt = getActiveAttempt(attemptOffset, attemptsCount);
|
|
25
|
+
const activeAudioFileId = activeAttempt !== null ? answers?.[activeAttempt - 1]?.audioFileId : undefined;
|
|
26
|
+
const hasActiveAudio = activeAudioFileId !== undefined;
|
|
27
|
+
const anyAttemptHasAudio = useMemo(() => answers.some(a => !!a.audioFileId), [answers]);
|
|
28
|
+
const cachedEntry = activeAudioFileId ? model.loader.getCachedTranscript(activeAudioFileId) : undefined;
|
|
29
|
+
const activeTranscript = cachedEntry?.text ?? null;
|
|
30
|
+
const hasTranscriptText = !!activeTranscript && activeTranscript !== NO_AUDIO_BE_MESSAGE;
|
|
31
|
+
const isActiveTranscriptLoading = isLoadingTranscripts && hasActiveAudio && !activeTranscript;
|
|
32
|
+
const isSourceSameAsTarget = !!cachedEntry?.language && resolveGoogleLanguageCode(cachedEntry.language) === resolveGoogleLanguageCode(i18n.language);
|
|
33
|
+
const canTranslate = hasTranscriptText && !isSourceSameAsTarget;
|
|
34
|
+
const cachedTranslation = activeAttempt !== null ? translations[activeAttempt] : undefined;
|
|
35
|
+
const showTranslation = isTranslationActive && canTranslate;
|
|
36
|
+
const isTranslationLoading = showTranslation && !cachedTranslation && isTranslating;
|
|
37
|
+
const displayText = showTranslation ? cachedTranslation ?? activeTranscript : hasTranscriptText ? activeTranscript : t('voice.transcriptNotAvailable');
|
|
38
|
+
|
|
39
|
+
// UI-only lifecycle: collapse the dropdown on mount/unmount and on problem
|
|
40
|
+
// change. Playback engine mutations (init/reset/setCurrentAttempt/stopAudio)
|
|
41
|
+
// are owned by useVoicePlayerLifecycle, called by the page-level consumer.
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
return () => {
|
|
44
|
+
model.dropdown.setExpanded(false);
|
|
45
|
+
};
|
|
46
|
+
}, [model]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
model.dropdown.setExpanded(false);
|
|
49
|
+
}, [problemId]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
autoActivatedAttempts.current.clear();
|
|
52
|
+
}, [problemId]);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (canTranslate && activeAttempt !== null && !autoActivatedAttempts.current.has(activeAttempt)) {
|
|
55
|
+
autoActivatedAttempts.current.add(activeAttempt);
|
|
56
|
+
model.translation.setActive(true);
|
|
57
|
+
}
|
|
58
|
+
}, [canTranslate, activeAttempt, model]);
|
|
59
|
+
|
|
60
|
+
// Trigger translate when we should show translation but don't have it cached
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (showTranslation && activeAttempt !== null && !cachedTranslation && !isTranslating) {
|
|
63
|
+
model.translation.translate({
|
|
64
|
+
attemptNumber: activeAttempt,
|
|
65
|
+
targetLanguage: i18n.language
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}, [showTranslation, activeAttempt, cachedTranslation, isTranslating, i18n.language, model]);
|
|
69
|
+
|
|
70
|
+
// Auto-open dropdown when a translation successfully completes
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
return model.translation.translate.doneData.watch(result => {
|
|
73
|
+
if (result) {
|
|
74
|
+
model.dropdown.setExpanded(true);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}, [model]);
|
|
78
|
+
const onPlayPress = useCallback(() => {
|
|
79
|
+
if (activeAttempt) {
|
|
80
|
+
model.translation.setActive(false);
|
|
81
|
+
model.togglePlayPause(activeAttempt);
|
|
82
|
+
}
|
|
83
|
+
}, [model, activeAttempt]);
|
|
84
|
+
const onTranslationToggle = useCallback(() => {
|
|
85
|
+
model.translation.toggle();
|
|
86
|
+
model.dropdown.setExpanded(true);
|
|
87
|
+
}, [model]);
|
|
88
|
+
return {
|
|
89
|
+
display: {
|
|
90
|
+
text: displayText,
|
|
91
|
+
isLoading: isActiveTranscriptLoading || isTranslationLoading
|
|
92
|
+
},
|
|
93
|
+
flags: {
|
|
94
|
+
playerState: playerState,
|
|
95
|
+
hasActiveAudio,
|
|
96
|
+
anyAttemptHasAudio,
|
|
97
|
+
canTranslate,
|
|
98
|
+
isTranslationActive
|
|
99
|
+
},
|
|
100
|
+
actions: {
|
|
101
|
+
onPlayPress,
|
|
102
|
+
onTranslationToggle
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=useVoiceTranscriptionController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useUnit","useCallback","useEffect","useMemo","useRef","useTranslation","NO_AUDIO_BE_MESSAGE","getActiveAttempt","resolveGoogleLanguageCode","useText","useVoiceTranscriptionController","model","answers","attemptOffset","attemptsCount","problemId","t","i18n","playerState","isLoadingTranscripts","isTranslationActive","translations","isTranslating","$playerState","loader","loadTranscriptForAttempt","pending","translation","$isActive","$translations","translate","autoActivatedAttempts","Set","activeAttempt","activeAudioFileId","audioFileId","undefined","hasActiveAudio","anyAttemptHasAudio","some","a","cachedEntry","getCachedTranscript","activeTranscript","text","hasTranscriptText","isActiveTranscriptLoading","isSourceSameAsTarget","language","canTranslate","cachedTranslation","showTranslation","isTranslationLoading","displayText","dropdown","setExpanded","current","clear","has","add","setActive","attemptNumber","targetLanguage","doneData","watch","result","onPlayPress","togglePlayPause","onTranslationToggle","toggle","display","isLoading","flags","actions"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useVoiceTranscriptionController.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,gBAAgB;AACxC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC/D,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,mBAAmB,QAAQ,oBAAiB;AACrD,SAASC,gBAAgB,QAAQ,kBAAe;AAEhD,SAASC,yBAAyB,QAAQ,6DAA0D;AACpG,SAASC,OAAO,QAAQ,0BAAuB;AAc/C,OAAO,MAAMC,+BAA+B,GAAGA,CAAC;EAC9CC,KAAK;EACLC,OAAO;EACPC,aAAa;EACbC,aAAa;EACbC;AACM,CAAC,KAAK;EACZ,MAAMC,CAAC,GAAGP,OAAO,CAAC,CAAC;EACnB,MAAM;IAAEQ;EAAK,CAAC,GAAGZ,cAAc,CAAC,CAAC;EAEjC,MAAM,CAACa,WAAW,EAAEC,oBAAoB,EAAEC,mBAAmB,EAAEC,YAAY,EAAEC,aAAa,CAAC,GACzFtB,OAAO,CAAC,CACNW,KAA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P,WAAW;MACXE;IACF;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { createEvent, restore } from 'effector';
|
|
4
|
-
export class
|
|
4
|
+
export class DropdownModel {
|
|
5
5
|
toggleExpand = createEvent();
|
|
6
6
|
setExpanded = createEvent();
|
|
7
7
|
reset = createEvent();
|
|
8
8
|
$isExpanded = restore(this.setExpanded, false).on(this.toggleExpand, state => !state).reset(this.reset);
|
|
9
9
|
}
|
|
10
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=Dropdown.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createEvent","restore","DropdownModel","toggleExpand","setExpanded","reset","$isExpanded","on","state"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/Dropdown.model.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,OAAO,QAAQ,UAAU;AAE/C,OAAO,MAAMC,aAAa,CAAC;EACTC,YAAY,GAAGH,WAAW,CAAC,CAAC;EAC5BI,WAAW,GAAGJ,WAAW,CAAU,CAAC;EACpCK,KAAK,GAAGL,WAAW,CAAC,CAAC;EAErBM,WAAW,GAAGL,OAAO,CAAC,IAAI,CAACG,WAAW,EAAE,KAAK,CAAC,CAC3DG,EAAE,CAAC,IAAI,CAACJ,YAAY,EAAGK,KAAK,IAAK,CAACA,KAAK,CAAC,CACxCH,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;AACtB","ignoreList":[]}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createEffect } from 'effector';
|
|
4
|
+
import { PlayerState } from "./Player.model.js";
|
|
5
|
+
export class PlaybackController {
|
|
6
|
+
currentPlayingAttempt = null;
|
|
7
|
+
shouldPreventPlayback = false;
|
|
8
|
+
constructor(deps) {
|
|
9
|
+
this.collection = deps.collection;
|
|
10
|
+
this.player = deps.player;
|
|
11
|
+
this.downloader = deps.downloader;
|
|
12
|
+
this.player.playbackFinished.watch(() => this.clearCurrentAttempt());
|
|
13
|
+
}
|
|
14
|
+
togglePlayPause = attemptNumber => {
|
|
15
|
+
const playerState = this.player.$playerState.getState();
|
|
16
|
+
if (this.currentPlayingAttempt === attemptNumber && playerState === PlayerState.PLAYING) {
|
|
17
|
+
this.player.pause();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.handlePlayAttempt(attemptNumber);
|
|
21
|
+
};
|
|
22
|
+
preloadAudio = createEffect(async attemptNumber => {
|
|
23
|
+
const item = this.collection.get(attemptNumber);
|
|
24
|
+
if (!item) return;
|
|
25
|
+
if (this.collection.hasAudio(attemptNumber)) {
|
|
26
|
+
this.primePlayerIfIdle(attemptNumber);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (item.audioDownloadPromise) {
|
|
30
|
+
try {
|
|
31
|
+
await item.audioDownloadPromise;
|
|
32
|
+
} catch {}
|
|
33
|
+
this.primePlayerIfIdle(attemptNumber);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
await this.downloadAudio(attemptNumber);
|
|
38
|
+
this.primePlayerIfIdle(attemptNumber);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (error instanceof Error && error.name === 'AbortError') return;
|
|
41
|
+
console.error('Audio preload error:', error);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
primePlayerIfIdle(attemptNumber) {
|
|
45
|
+
if (this.player.$playerState.getState() !== PlayerState.IDLE) return;
|
|
46
|
+
if (this.currentPlayingAttempt !== null) return;
|
|
47
|
+
const audioUri = this.collection.get(attemptNumber)?.audioUri;
|
|
48
|
+
if (!audioUri) return;
|
|
49
|
+
this.player.prime(audioUri);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Non-destructive halt: pause + IDLE, keep audio loaded so a subsequent
|
|
53
|
+
// play() can resume the same uri without re-fetch. Previously this called
|
|
54
|
+
// player.stop() which did replace('') and set stopped=true — that corrupted
|
|
55
|
+
// the AudioPlayer (isLoaded stuck false) and aborted any in-flight play()'s
|
|
56
|
+
// waitForLoad, when the lifecycle hook re-fired stopAudio mid-play.
|
|
57
|
+
halt() {
|
|
58
|
+
this.shouldPreventPlayback = true;
|
|
59
|
+
this.abortAllDownloads();
|
|
60
|
+
if (this.player.player && this.player.$playerState.getState() !== PlayerState.IDLE) {
|
|
61
|
+
this.player.player.pause();
|
|
62
|
+
this.player.setPlayerState(PlayerState.IDLE);
|
|
63
|
+
}
|
|
64
|
+
this.clearCurrentAttempt();
|
|
65
|
+
}
|
|
66
|
+
releaseResources() {
|
|
67
|
+
this.collection.getAll().forEach(item => {
|
|
68
|
+
if (item.controller) {
|
|
69
|
+
this.downloader.abortDownload(item.controller);
|
|
70
|
+
}
|
|
71
|
+
if (item.audioUri?.startsWith('blob:')) {
|
|
72
|
+
try {
|
|
73
|
+
URL.revokeObjectURL(item.audioUri);
|
|
74
|
+
} catch (e) {}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
clearCurrentAttempt() {
|
|
79
|
+
this.currentPlayingAttempt = null;
|
|
80
|
+
}
|
|
81
|
+
abortAllDownloads() {
|
|
82
|
+
this.collection.getAll().forEach(item => {
|
|
83
|
+
if (item.controller && item.audioLoading) {
|
|
84
|
+
this.downloader.abortDownload(item.controller);
|
|
85
|
+
this.collection.update(item.attemptNumber, {
|
|
86
|
+
audioLoading: false,
|
|
87
|
+
controller: undefined,
|
|
88
|
+
audioDownloadPromise: undefined
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async downloadAudio(attemptNumber) {
|
|
94
|
+
const item = this.collection.get(attemptNumber);
|
|
95
|
+
if (!item) return;
|
|
96
|
+
const {
|
|
97
|
+
collectionItem,
|
|
98
|
+
downloadPromise
|
|
99
|
+
} = await this.downloader.download({
|
|
100
|
+
audioFileId: item.audioFileId,
|
|
101
|
+
attemptNumber
|
|
102
|
+
});
|
|
103
|
+
this.collection.update(attemptNumber, collectionItem);
|
|
104
|
+
try {
|
|
105
|
+
const result = await downloadPromise;
|
|
106
|
+
this.collection.update(attemptNumber, {
|
|
107
|
+
audioUri: result.uri,
|
|
108
|
+
audioLoading: false,
|
|
109
|
+
audioError: undefined,
|
|
110
|
+
controller: undefined,
|
|
111
|
+
audioDownloadPromise: undefined
|
|
112
|
+
});
|
|
113
|
+
} catch (error) {
|
|
114
|
+
const isAbort = error instanceof Error && error.name === 'AbortError';
|
|
115
|
+
this.collection.update(attemptNumber, {
|
|
116
|
+
audioLoading: false,
|
|
117
|
+
audioError: isAbort ? undefined : error instanceof Error ? error.message : 'Failed to download audio',
|
|
118
|
+
controller: undefined,
|
|
119
|
+
audioDownloadPromise: undefined
|
|
120
|
+
});
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
handlePlayAttempt = createEffect(async attemptNumber => {
|
|
125
|
+
this.shouldPreventPlayback = false;
|
|
126
|
+
const item = this.collection.get(attemptNumber);
|
|
127
|
+
if (!item) return;
|
|
128
|
+
if (this.currentPlayingAttempt !== null && this.currentPlayingAttempt !== attemptNumber) {
|
|
129
|
+
this.abortAllDownloads();
|
|
130
|
+
}
|
|
131
|
+
if (this.collection.hasAudio(attemptNumber)) {
|
|
132
|
+
this.playAudioFx(attemptNumber);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
this.player.setPlayerState(PlayerState.LOADING);
|
|
137
|
+
if (item.audioDownloadPromise) {
|
|
138
|
+
await item.audioDownloadPromise;
|
|
139
|
+
} else {
|
|
140
|
+
await this.downloadAudio(attemptNumber);
|
|
141
|
+
}
|
|
142
|
+
if (this.shouldPreventPlayback) {
|
|
143
|
+
this.player.setPlayerState(PlayerState.IDLE);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.player.setPlayerState(PlayerState.IDLE);
|
|
147
|
+
this.playAudioFx(attemptNumber);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
150
|
+
this.player.setPlayerState(PlayerState.IDLE);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
console.error('Audio download error:', error);
|
|
154
|
+
this.player.setPlayerState(PlayerState.IDLE);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
playAudioFx = createEffect(async attemptNumber => {
|
|
158
|
+
if (this.shouldPreventPlayback) return;
|
|
159
|
+
const item = this.collection.get(attemptNumber);
|
|
160
|
+
if (!item?.audioUri) {
|
|
161
|
+
console.warn('No audio URI available for attempt:', attemptNumber);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
if (this.currentPlayingAttempt !== null && this.currentPlayingAttempt !== attemptNumber) {
|
|
166
|
+
this.player.player?.remove();
|
|
167
|
+
}
|
|
168
|
+
if (this.currentPlayingAttempt === attemptNumber && this.player.player?.playing) {
|
|
169
|
+
this.player.pause();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (this.currentPlayingAttempt === attemptNumber && !this.player.player?.playing) {
|
|
173
|
+
this.player.resume();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
this.currentPlayingAttempt = attemptNumber;
|
|
177
|
+
await this.player.play(item.audioUri);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error('Error playing audio:', error);
|
|
180
|
+
this.player.setPlayerState(PlayerState.IDLE);
|
|
181
|
+
this.collection.update(attemptNumber, {
|
|
182
|
+
audioError: error instanceof Error ? error.message : 'Failed to play audio'
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=PlaybackController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createEffect","PlayerState","PlaybackController","currentPlayingAttempt","shouldPreventPlayback","constructor","deps","collection","player","downloader","playbackFinished","watch","clearCurrentAttempt","togglePlayPause","attemptNumber","playerState","$playerState","getState","PLAYING","pause","handlePlayAttempt","preloadAudio","item","get","hasAudio","primePlayerIfIdle","audioDownloadPromise","downloadAudio","error","Error","name","console","IDLE","audioUri","prime","halt","abortAllDownloads","setPlayerState","releaseResources","getAll","forEach","controller","abortDownload","startsWith","URL","revokeObjectURL","e","audioLoading","update","undefined","collectionItem","downloadPromise","download","audioFileId","result","uri","audioError","isAbort","message","playAudioFx","LOADING","warn","remove","playing","resume","play"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/PlaybackController.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,UAAU;AACvC,SAAsBC,WAAW,QAAQ,mBAAgB;AAUzD,OAAO,MAAMC,kBAAkB,CAAC;EAItBC,qBAAqB,GAAkB,IAAI;EAC3CC,qBAAqB,GAAG,KAAK;EAErCC,WAAWA,CAACC,IAA4B,EAAE;IACxC,IAAI,CAACC,UAAU,GAAGD,IAAI,CAACC,UAAU;IACjC,IAAI,CAACC,MAAM,GAAGF,IAAI,CAACE,MAAM;IACzB,IAAI,CAACC,UAAU,GAAGH,IAAI,CAACG,UAAU;IACjC,IAAI,CAACD,MAAM,CAACE,gBAAgB,CAACC,KAAK,CAAC,MAAM,IAAI,CAACC,mBAAmB,CAAC,CAAC,CAAC;EACtE;EAEgBC,eAAe,GAAIC,aAAqB,IAAK;IAC3D,MAAMC,WAAW,GAAG,IAAI,CAACP,MAAM,CAACQ,YAAY,CAACC,QAAQ,CAAC,CAAC;IACvD,IAAI,IAAI,CAACd,qBAAqB,KAAKW,aAAa,IAAIC,WAAW,KAAKd,WAAW,CAACiB,OAAO,EAAE;MACvF,IAAI,CAACV,MAAM,CAACW,KAAK,CAAC,CAAC;MACnB;IACF;IACA,IAAI,CAACC,iBAAiB,CAACN,aAAa,CAAC;EACvC,CAAC;EAEeO,YAAY,GAAGrB,YAAY,CAAC,MAAOc,aAAqB,IAA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","ignoreList":[]}
|
|
@@ -9,9 +9,24 @@ export let PlayerState = /*#__PURE__*/function (PlayerState) {
|
|
|
9
9
|
PlayerState["IDLE"] = "idle";
|
|
10
10
|
return PlayerState;
|
|
11
11
|
}({});
|
|
12
|
+
|
|
13
|
+
// audio.play() returns a promise that rejects with AbortError when a subsequent
|
|
14
|
+
// pause() interrupts it. That's expected during pause/resume cycles; suppress noise.
|
|
15
|
+
const safePlay = audio => {
|
|
16
|
+
const result = audio.play();
|
|
17
|
+
if (result && typeof result.catch === 'function') {
|
|
18
|
+
;
|
|
19
|
+
result.catch(err => {
|
|
20
|
+
if (err?.name === 'AbortError') return;
|
|
21
|
+
throw err;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
12
25
|
export class PlayerModel {
|
|
13
26
|
player = createAudioPlayer();
|
|
14
27
|
stopped = false;
|
|
28
|
+
primedUri = null;
|
|
29
|
+
pendingSeek = null;
|
|
15
30
|
reset = createEvent();
|
|
16
31
|
setPlayerState = createEvent();
|
|
17
32
|
playbackFinished = createEvent();
|
|
@@ -35,14 +50,33 @@ export class PlayerModel {
|
|
|
35
50
|
this.stopped = true;
|
|
36
51
|
if (this.player) {
|
|
37
52
|
this.player.replace('');
|
|
53
|
+
this.primedUri = null;
|
|
54
|
+
this.pendingSeek = null;
|
|
38
55
|
this.setPlayerState(PlayerState.IDLE);
|
|
39
56
|
} else {
|
|
40
57
|
console.warn('Cannot stop: audio player not initialized');
|
|
41
58
|
}
|
|
42
59
|
});
|
|
60
|
+
prime = createEffect(uri => {
|
|
61
|
+
if (!this.player) return;
|
|
62
|
+
if (this.primedUri === uri) return;
|
|
63
|
+
this.primedUri = uri;
|
|
64
|
+
this.player.replace(uri);
|
|
65
|
+
});
|
|
66
|
+
seek = createEffect(async seconds => {
|
|
67
|
+
// When not loaded, defer the seek so play()'s waitForLoad can apply it
|
|
68
|
+
// before starting playback — otherwise the requested offset is lost and
|
|
69
|
+
// audio starts from 0 after a scrub-across-attempt that halted the player.
|
|
70
|
+
if (!this.player?.isLoaded) {
|
|
71
|
+
this.pendingSeek = seconds;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.pendingSeek = null;
|
|
75
|
+
await this.player.seekTo(seconds);
|
|
76
|
+
});
|
|
43
77
|
resume = createEffect(() => {
|
|
44
78
|
if (this.player) {
|
|
45
|
-
this.player
|
|
79
|
+
safePlay(this.player);
|
|
46
80
|
this.setPlayerState(PlayerState.PLAYING);
|
|
47
81
|
} else {
|
|
48
82
|
console.warn('Cannot resume: audio player not initialized');
|
|
@@ -54,10 +88,21 @@ export class PlayerModel {
|
|
|
54
88
|
return;
|
|
55
89
|
}
|
|
56
90
|
this.stopped = false;
|
|
57
|
-
this.player.
|
|
58
|
-
|
|
91
|
+
if (this.primedUri !== uri || !this.player.isLoaded) {
|
|
92
|
+
this.player.replace(uri);
|
|
93
|
+
this.primedUri = uri;
|
|
94
|
+
}
|
|
95
|
+
const waitForLoad = async () => {
|
|
59
96
|
if (this.stopped) return;
|
|
60
97
|
if (this.player && this.player.isLoaded) {
|
|
98
|
+
if (this.pendingSeek !== null) {
|
|
99
|
+
const target = this.pendingSeek;
|
|
100
|
+
this.pendingSeek = null;
|
|
101
|
+
try {
|
|
102
|
+
await this.player.seekTo(target);
|
|
103
|
+
} catch {}
|
|
104
|
+
if (this.stopped) return;
|
|
105
|
+
}
|
|
61
106
|
const unsubscribe = this.player.addListener('playbackStatusUpdate', status => {
|
|
62
107
|
if (status.didJustFinish) {
|
|
63
108
|
this.playbackFinished();
|
|
@@ -65,7 +110,7 @@ export class PlayerModel {
|
|
|
65
110
|
this.setPlayerState(PlayerState.IDLE);
|
|
66
111
|
}
|
|
67
112
|
});
|
|
68
|
-
this.player
|
|
113
|
+
safePlay(this.player);
|
|
69
114
|
this.setPlayerState(PlayerState.PLAYING);
|
|
70
115
|
} else {
|
|
71
116
|
setTimeout(waitForLoad, 10);
|
|
@@ -87,6 +132,8 @@ export class PlayerModel {
|
|
|
87
132
|
this.player.release();
|
|
88
133
|
this.player = null;
|
|
89
134
|
}
|
|
135
|
+
this.primedUri = null;
|
|
136
|
+
this.pendingSeek = null;
|
|
90
137
|
this.reset();
|
|
91
138
|
}
|
|
92
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createEffect","createEvent","restore","createAudioPlayer","setAudioModeAsync","PlayerState","PlayerModel","player","stopped","reset","setPlayerState","playbackFinished","$playerState","IDLE","setupAudioMode","playsInSilentMode","shouldPlayInBackground","interruptionMode","pause","PAUSED","console","warn","stop","replace","
|
|
1
|
+
{"version":3,"names":["createEffect","createEvent","restore","createAudioPlayer","setAudioModeAsync","PlayerState","safePlay","audio","result","play","catch","err","name","PlayerModel","player","stopped","primedUri","pendingSeek","reset","setPlayerState","playbackFinished","$playerState","IDLE","setupAudioMode","playsInSilentMode","shouldPlayInBackground","interruptionMode","pause","PAUSED","console","warn","stop","replace","prime","uri","seek","seconds","isLoaded","seekTo","resume","PLAYING","waitForLoad","target","unsubscribe","addListener","status","didJustFinish","remove","setTimeout","reinitialize","release","error"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/Player.model.ts"],"mappings":";;AAAA,SAASA,YAAY,EAAEC,WAAW,EAAEC,OAAO,QAAQ,UAAU;AAC7D,SAAsBC,iBAAiB,EAAEC,iBAAiB,QAAQ,YAAY;AAE9E,WAAkBC,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;;AAO7B;AACA;AACA,MAAMC,QAAQ,GAAIC,KAAkB,IAAK;EACvC,MAAMC,MAAM,GAAGD,KAAK,CAACE,IAAI,CAAC,CAAY;EACtC,IAAID,MAAM,IAAI,OAAQA,MAAM,CAAsBE,KAAK,KAAK,UAAU,EAAE;IACtE;IAAEF,MAAM,CAAsBE,KAAK,CAAEC,GAAY,IAAK;MACpD,IAAKA,GAAG,EAAwBC,IAAI,KAAK,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IAAI,CAAC,CAAC;QACX,IAAI,CAACjB,MAAM,CAACiC,MAAM,CAAC,CAAC;MACtB,CAAC,CAAC,OAAOI,KAAK,EAAE,CAAC;MACjB,IAAI,CAACrC,MAAM,CAACoC,OAAO,CAAC,CAAC;MACrB,IAAI,CAACpC,MAAM,GAAG,IAAI;IACpB;IACA,IAAI,CAACE,SAAS,GAAG,IAAI;IACrB,IAAI,CAACC,WAAW,GAAG,IAAI;IACvB,IAAI,CAACC,KAAK,CAAC,CAAC;EACd;AACF","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
export class
|
|
3
|
+
export class TranscriptionsCollection {
|
|
4
4
|
collection = new Map();
|
|
5
5
|
add(attemptNumber, item) {
|
|
6
6
|
this.collection.set(attemptNumber, item);
|
|
@@ -33,4 +33,4 @@ export class VoiceTranscriptionsCollection {
|
|
|
33
33
|
return !!item?.audioUri;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
//# sourceMappingURL=
|
|
36
|
+
//# 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"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/TranscriptionsCollection.ts"],"mappings":";;AAEA,OAAO,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","ignoreList":[]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createEffect } from 'effector';
|
|
4
|
+
import { TranscriptionStatus } from "../../types.js";
|
|
5
|
+
import { NO_AUDIO_BE_MESSAGE, TRANSCRIPT_MAX_RETRIES, TRANSCRIPT_RETRY_INTERVAL_MS } from "../../constants.js";
|
|
6
|
+
export class TranscriptionsDownloaderModel {
|
|
7
|
+
inflightFetches = new Map();
|
|
8
|
+
transcriptCache = new Map();
|
|
9
|
+
constructor(collection, api) {
|
|
10
|
+
this.collection = collection;
|
|
11
|
+
this.api = api;
|
|
12
|
+
}
|
|
13
|
+
async fetchTranscriptWithRetry(audioFileId) {
|
|
14
|
+
const cached = this.transcriptCache.get(audioFileId);
|
|
15
|
+
if (cached) return cached;
|
|
16
|
+
const existing = this.inflightFetches.get(audioFileId);
|
|
17
|
+
if (existing) return existing;
|
|
18
|
+
const promise = this.runFetchWithRetry(audioFileId).then(result => {
|
|
19
|
+
this.transcriptCache.set(audioFileId, result);
|
|
20
|
+
return result;
|
|
21
|
+
}).finally(() => {
|
|
22
|
+
this.inflightFetches.delete(audioFileId);
|
|
23
|
+
});
|
|
24
|
+
this.inflightFetches.set(audioFileId, promise);
|
|
25
|
+
return promise;
|
|
26
|
+
}
|
|
27
|
+
async runFetchWithRetry(audioFileId) {
|
|
28
|
+
for (let attempt = 0; attempt < TRANSCRIPT_MAX_RETRIES; attempt++) {
|
|
29
|
+
const response = await this.api.getAudioFileTranscript(audioFileId);
|
|
30
|
+
if (response.status === TranscriptionStatus.COMPLETED) {
|
|
31
|
+
return {
|
|
32
|
+
text: response.text,
|
|
33
|
+
language: response.language
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (response.status === TranscriptionStatus.FAILED) {
|
|
37
|
+
return {
|
|
38
|
+
text: NO_AUDIO_BE_MESSAGE
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (attempt < TRANSCRIPT_MAX_RETRIES - 1) {
|
|
42
|
+
await new Promise(resolve => setTimeout(resolve, TRANSCRIPT_RETRY_INTERVAL_MS));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
text: NO_AUDIO_BE_MESSAGE
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
loadTranscriptForAttempt = createEffect(async attemptNumber => {
|
|
50
|
+
const item = this.collection.get(attemptNumber);
|
|
51
|
+
if (!item?.audioFileId) return;
|
|
52
|
+
if (item.transcript || item.transcriptLoading) return;
|
|
53
|
+
this.collection.update(attemptNumber, {
|
|
54
|
+
transcriptLoading: true
|
|
55
|
+
});
|
|
56
|
+
try {
|
|
57
|
+
const {
|
|
58
|
+
text,
|
|
59
|
+
language
|
|
60
|
+
} = await this.fetchTranscriptWithRetry(item.audioFileId);
|
|
61
|
+
this.collection.update(attemptNumber, {
|
|
62
|
+
transcript: text,
|
|
63
|
+
transcriptLanguage: language,
|
|
64
|
+
transcriptLoading: false,
|
|
65
|
+
transcriptError: undefined
|
|
66
|
+
});
|
|
67
|
+
} catch (error) {
|
|
68
|
+
this.collection.update(attemptNumber, {
|
|
69
|
+
transcriptLoading: false,
|
|
70
|
+
transcriptError: error instanceof Error ? error.message : 'Failed to load transcript'
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
getCachedTranscript(audioFileId) {
|
|
75
|
+
return this.transcriptCache.get(audioFileId);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=TranscriptionsDownloader.model.js.map
|