@magmamath/students-features 1.3.22 → 1.3.23-rc.10
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/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 +4 -4
- package/dist/commonjs/features/voice/index.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 +142 -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 +59 -0
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.js → useVoiceTranscription.js} +4 -4
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscription.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.js +26 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.js +37 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js +18 -4
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js +6 -2
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.js → VoiceTranscription.model.js} +4 -4
- package/dist/commonjs/features/voice/playing/model/VoiceTranscription.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.js +62 -0
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.js.map +1 -0
- package/dist/commonjs/features/voice/types.js +6 -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/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 +1 -1
- package/dist/module/features/voice/index.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 +134 -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 +51 -0
- package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.js → useVoiceTranscription.js} +2 -2
- package/dist/module/features/voice/playing/hooks/useVoiceTranscription.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.js +21 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.js +32 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.js.map +1 -0
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js +18 -4
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +1 -1
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js +6 -2
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
- package/dist/module/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.js → VoiceTranscription.model.js} +2 -2
- package/dist/module/features/voice/playing/model/VoiceTranscription.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.js +57 -0
- package/dist/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.js.map +1 -0
- package/dist/module/features/voice/types.js +5 -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/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 +1 -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/{module/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts → commonjs/features/voice/playing/hooks/useVoiceTranscription.d.ts} +3 -3
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscription.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.d.ts +10 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts +12 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts +4 -2
- package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.d.ts → VoiceTranscription.model.d.ts} +2 -2
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscription.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts +25 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/types.d.ts +9 -1
- 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/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 +1 -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/{commonjs/features/voice/playing/hooks/useVoiceTranscriptionsDropdown.d.ts → module/features/voice/playing/hooks/useVoiceTranscription.d.ts} +3 -3
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscription.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.d.ts +10 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts +12 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +1 -0
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts +4 -2
- package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.d.ts → VoiceTranscription.model.d.ts} +2 -2
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscription.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts +25 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/types.d.ts +9 -1
- 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 +1 -1
- 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 +1 -1
- package/src/features/voice/playing/components/VoiceTranscriptContent.tsx +37 -0
- package/src/features/voice/playing/components/VoiceTranscription.tsx +175 -0
- package/src/features/voice/playing/components/VoiceTranscriptionCollapsible.tsx +59 -0
- package/src/features/voice/playing/components/VoiceTranscriptionHeaderActions.tsx +62 -0
- package/src/features/voice/playing/hooks/{useVoiceTranscriptionsDropdown.ts → useVoiceTranscription.ts} +2 -2
- package/src/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.ts +32 -0
- package/src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts +44 -0
- package/src/features/voice/playing/model/TranscriptionsDownloaderModel.ts +12 -5
- package/src/features/voice/playing/model/VoicePlayer.model.ts +7 -2
- package/src/features/voice/playing/model/{VoiceTranscriptionsDropdown.model.ts → VoiceTranscription.model.ts} +2 -2
- package/src/features/voice/playing/model/VoiceTranscriptionTranslation.model.ts +75 -0
- package/src/features/voice/types.ts +15 -0
- package/src/index.ts +1 -0
- 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/VoiceTranscriptionsDropdown.model.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/VoiceTranscriptionsDropdown.model.js.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/VoiceTranscriptionsDropdown.model.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/VoiceTranscriptionsDropdown.model.d.ts.map +0 -1
- 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { VoiceTranscriptionsCollection } from './VoiceTranscriptionsCollection';
|
|
2
2
|
import { VoiceFileDownloaderModel } from './VoiceFileDownloader.model';
|
|
3
|
-
import {
|
|
3
|
+
import { VoiceTranscriptionModel } from './VoiceTranscription.model';
|
|
4
|
+
import { VoiceTranscriptionTranslationModel } from './VoiceTranscriptionTranslation.model';
|
|
4
5
|
import { AnswerAudio, VoicePlayerApi, VoiceTranscriptionItem } from '../../types';
|
|
5
6
|
import { PlayerModel, PlayerState } from './Player.model';
|
|
6
7
|
import { TranscriptionsDownloaderModel } from './TranscriptionsDownloaderModel';
|
|
@@ -11,7 +12,8 @@ type VoiceTranscriptionsPlayerModelParams = {
|
|
|
11
12
|
export declare class VoicePlayerModel {
|
|
12
13
|
readonly collection: VoiceTranscriptionsCollection;
|
|
13
14
|
readonly downloader: VoiceFileDownloaderModel;
|
|
14
|
-
readonly dropdown:
|
|
15
|
+
readonly dropdown: VoiceTranscriptionModel;
|
|
16
|
+
readonly translation: VoiceTranscriptionTranslationModel;
|
|
15
17
|
readonly playerModel: PlayerModel;
|
|
16
18
|
readonly loader: TranscriptionsDownloaderModel;
|
|
17
19
|
readonly api: VoicePlayerApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoicePlayer.model.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/VoicePlayer.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"VoicePlayer.model.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/VoicePlayer.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,kCAAkC,EAAE,MAAM,uCAAuC,CAAA;AAC1F,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAE/E,KAAK,oCAAoC,GAAG;IAC1C,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;CACvB,CAAA;AAMD,qBAAa,gBAAgB;IAC3B,SAAgB,UAAU,gCAAsC;IAChE,SAAgB,UAAU,2BAAiC;IAC3D,SAAgB,QAAQ,0BAAgC;IACxD,SAAgB,WAAW,EAAE,kCAAkC,CAAA;IAC/D,SAAgB,WAAW,cAAoB;IAC/C,SAAgB,MAAM,EAAE,6BAA6B,CAAA;IACrD,SAAgB,GAAG,EAAE,cAAc,CAAA;IACnC,OAAO,CAAC,qBAAqB,CAAsB;IACnD,OAAO,CAAC,qBAAqB,CAAQ;IAErC,SAAgB,iBAAiB,kDAA+B;IAChE,SAAgB,KAAK,yCAAgB;IAErC,SAAgB,eAAe,kDAA0D;IACzF,SAAgB,YAAY,gDAAgC;IAE5D,SAAgB,UAAU,+CAAyB;IAEnD,SAAgB,SAAS,aAMxB;IAED,SAAgB,WAAW,aAQ1B;gBAEW,MAAM,EAAE,oCAAoC;IAkBjD,oBAAoB,CAAC,WAAW,EAAE,WAAW,EAAE;IAMtD,OAAO,CAAC,8BAA8B;IAoBtC,OAAO,CAAC,0BAA0B;IAalC,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CA6DhC;IAEF,OAAO,CAAC,WAAW,CAmCjB;IAEK,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;IAI9C,cAAc,IAAI,sBAAsB,EAAE;IAI1C,kBAAkB;IAIlB,OAAO;IAWP,eAAe,iDAUpB;CACH"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class VoiceTranscriptionModel {
|
|
2
2
|
readonly toggleExpand: import("effector").EventCallable<void>;
|
|
3
3
|
readonly setExpanded: import("effector").EventCallable<boolean>;
|
|
4
4
|
readonly reset: import("effector").EventCallable<void>;
|
|
5
5
|
readonly $isExpanded: import("effector").StoreWritable<boolean>;
|
|
6
6
|
}
|
|
7
|
-
//# sourceMappingURL=
|
|
7
|
+
//# sourceMappingURL=VoiceTranscription.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VoiceTranscription.model.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/VoiceTranscription.model.ts"],"names":[],"mappings":"AAEA,qBAAa,uBAAuB;IAClC,SAAgB,YAAY,yCAAgB;IAC5C,SAAgB,WAAW,4CAAyB;IACpD,SAAgB,KAAK,yCAAgB;IAErC,SAAgB,WAAW,4CAEP;CACrB"}
|
package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { VoiceTranscriptionsCollection } from './VoiceTranscriptionsCollection';
|
|
2
|
+
import { VoicePlayerApi } from '../../types';
|
|
3
|
+
type TranslateParams = {
|
|
4
|
+
attemptNumber: number;
|
|
5
|
+
targetLanguage: string;
|
|
6
|
+
};
|
|
7
|
+
type TranslateResult = {
|
|
8
|
+
attemptNumber: number;
|
|
9
|
+
text: string;
|
|
10
|
+
};
|
|
11
|
+
export declare class VoiceTranscriptionTranslationModel {
|
|
12
|
+
private readonly collection;
|
|
13
|
+
private readonly service;
|
|
14
|
+
readonly toggle: import("effector").EventCallable<void>;
|
|
15
|
+
readonly setActive: import("effector").EventCallable<boolean>;
|
|
16
|
+
readonly clearCache: import("effector").EventCallable<void>;
|
|
17
|
+
readonly reset: import("effector").EventCallable<void>;
|
|
18
|
+
readonly $isActive: import("effector").StoreWritable<boolean>;
|
|
19
|
+
readonly translate: import("effector").Effect<TranslateParams, TranslateResult | null, Error>;
|
|
20
|
+
readonly $translations: import("effector").StoreWritable<Record<number, string>>;
|
|
21
|
+
constructor(collection: VoiceTranscriptionsCollection, api: VoicePlayerApi);
|
|
22
|
+
getTranslation(attemptNumber: number): string | undefined;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=VoiceTranscriptionTranslation.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VoiceTranscriptionTranslation.model.d.ts","sourceRoot":"","sources":["../../../../../../../src/features/voice/playing/model/VoiceTranscriptionTranslation.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAQ5C,KAAK,eAAe,GAAG;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,qBAAa,kCAAkC;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA+B;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAE5C,SAAgB,MAAM,yCAAgB;IACtC,SAAgB,SAAS,4CAAyB;IAClD,SAAgB,UAAU,yCAAgB;IAC1C,SAAgB,KAAK,yCAAgB;IAErC,SAAgB,SAAS,4CAEL;IAEpB,SAAgB,SAAS,4EAexB;IAED,SAAgB,aAAa,2DAKQ;gBAEzB,UAAU,EAAE,6BAA6B,EAAE,GAAG,EAAE,cAAc;IAcnE,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAGjE"}
|
|
@@ -2,6 +2,8 @@ import { WithAbortSignal } from 'src/types/common.types';
|
|
|
2
2
|
import { getAvailableInputs } from './helpers';
|
|
3
3
|
import { VoiceRecordModel } from './recording/model/VoiceRecord.model';
|
|
4
4
|
import { AxiosResponse } from 'axios';
|
|
5
|
+
import type { GoogleTranslateProps as GoogleTranslatePayload, GoogleTranslateResponse } from '../translation/providers/google.types';
|
|
6
|
+
export type { GoogleTranslatePayload, GoogleTranslateResponse };
|
|
5
7
|
export type VoiceRecordNotificationTypes = {
|
|
6
8
|
success: (message: string) => void;
|
|
7
9
|
info: (message: string) => void;
|
|
@@ -46,6 +48,7 @@ export type VoiceRecorderApi = {
|
|
|
46
48
|
type TranscriptionStatus = 'pending' | 'completed' | 'failed';
|
|
47
49
|
export type AudioTranscriptResponse = {
|
|
48
50
|
text: string;
|
|
51
|
+
language: string;
|
|
49
52
|
status: TranscriptionStatus;
|
|
50
53
|
};
|
|
51
54
|
export type VoicePlayerApi = {
|
|
@@ -53,12 +56,14 @@ export type VoicePlayerApi = {
|
|
|
53
56
|
downloadAudioFile: (audioFileId: string, options?: {
|
|
54
57
|
signal?: AbortSignal;
|
|
55
58
|
}) => Promise<AxiosResponse<Blob>>;
|
|
59
|
+
translateText: (payload: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>;
|
|
56
60
|
};
|
|
57
61
|
export type VoiceTranscriptionItem = {
|
|
58
62
|
attemptNumber: number;
|
|
59
63
|
audioFileId: string;
|
|
60
64
|
_id: string;
|
|
61
65
|
transcript?: string;
|
|
66
|
+
transcriptLanguage?: string;
|
|
62
67
|
transcriptLoading?: boolean;
|
|
63
68
|
transcriptError?: string;
|
|
64
69
|
audioUri?: string;
|
|
@@ -72,5 +77,8 @@ export declare enum RecordButtonVariant {
|
|
|
72
77
|
DEFAULT = "default",
|
|
73
78
|
ADVANCED = "advanced"
|
|
74
79
|
}
|
|
75
|
-
export {
|
|
80
|
+
export declare enum VoiceTranscriptionVariant {
|
|
81
|
+
SMALL = "small",
|
|
82
|
+
LARGE = "large"
|
|
83
|
+
}
|
|
76
84
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/features/voice/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/features/voice/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { MaskSegmentParams } from './types'
|
|
2
|
+
|
|
3
|
+
export function replaceMappedTokens(input: string, map: Record<string, string>): string {
|
|
4
|
+
let result = input
|
|
5
|
+
|
|
6
|
+
for (const [original, override] of Object.entries(map)) {
|
|
7
|
+
const escaped = original.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
8
|
+
const regex = new RegExp(`\\b${escaped}\\b`, 'gi')
|
|
9
|
+
|
|
10
|
+
result = result.replace(regex, override)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return result
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Masks text segments matched by `regex` with a placeholder,
|
|
18
|
+
* while preserving spaces around the original match.
|
|
19
|
+
*/
|
|
20
|
+
export const maskSegment = ({
|
|
21
|
+
text,
|
|
22
|
+
regex,
|
|
23
|
+
placeholder,
|
|
24
|
+
replacements,
|
|
25
|
+
shouldSkip,
|
|
26
|
+
}: MaskSegmentParams): string => {
|
|
27
|
+
return text.replace(regex, (match, ...args) => {
|
|
28
|
+
if (shouldSkip?.(match)) return match
|
|
29
|
+
|
|
30
|
+
const offset = args[args.length - 2] as number
|
|
31
|
+
const input = args[args.length - 1] as string
|
|
32
|
+
|
|
33
|
+
const before = offset > 0 ? input[offset - 1] : ''
|
|
34
|
+
const afterIdx = offset + match.length
|
|
35
|
+
const after = afterIdx < input.length ? input[afterIdx] : ''
|
|
36
|
+
|
|
37
|
+
const leftPad = /\s/.test(before)
|
|
38
|
+
const rightPad = /\s/.test(after)
|
|
39
|
+
|
|
40
|
+
replacements.push({ placeholder, original: match, leftPad, rightPad })
|
|
41
|
+
|
|
42
|
+
return placeholder
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const HTML_NAMED_ENTITIES: Record<string, string> = {
|
|
47
|
+
'&': '&',
|
|
48
|
+
'<': '<',
|
|
49
|
+
'>': '>',
|
|
50
|
+
'"': '"',
|
|
51
|
+
''': "'",
|
|
52
|
+
' ': ' ',
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const decodeHtmlEntities = (text: string): string => {
|
|
56
|
+
return text
|
|
57
|
+
.replace(/&#(\d+);/g, (_, code: string) => String.fromCharCode(parseInt(code, 10)))
|
|
58
|
+
.replace(/&#x([0-9a-f]+);/gi, (_, code: string) => String.fromCharCode(parseInt(code, 16)))
|
|
59
|
+
.replace(
|
|
60
|
+
/&(amp|lt|gt|quot|apos|nbsp);/g,
|
|
61
|
+
(match) => HTML_NAMED_ENTITIES[match] ?? match,
|
|
62
|
+
)
|
|
63
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export { TranslationModel } from './model/TranslationModel'
|
|
2
|
+
export { TranslationService, type TranslateConfigProps } from './model/TranslationService'
|
|
3
|
+
export { TranslationKatexPreprocessor } from './model/TranslationPreprocessor'
|
|
4
|
+
export { TranslationProvider, type LanguageGlossary } from './providers/translation.interface'
|
|
5
|
+
export { GoogleTranslationProvider } from './providers/google/GoogleTranslationProvider'
|
|
6
|
+
export { GoogleTranslateLanguage } from './providers/google/supportedLanguages'
|
|
7
|
+
export type {
|
|
8
|
+
GoogleTranslateProps,
|
|
9
|
+
GoogleTranslateResponse,
|
|
10
|
+
GoogleTranslation,
|
|
11
|
+
} from './providers/google.types'
|
|
12
|
+
export { wordsToPreserve, preservedWordsReplacers } from './preserve/wordsToPreserve'
|
|
13
|
+
export {
|
|
14
|
+
GBD_TEXT_CACHE_SUFFIX,
|
|
15
|
+
DESCRIPTION_CACHE_KEY_SUFFIX,
|
|
16
|
+
CHOICES_CACHE_KEY_SUFFIX,
|
|
17
|
+
PRACTICE_THEORY_CACHE_KEY_SUFFIX,
|
|
18
|
+
} from './constants'
|
|
19
|
+
export {
|
|
20
|
+
replaceMappedTokens,
|
|
21
|
+
maskSegment,
|
|
22
|
+
decodeHtmlEntities,
|
|
23
|
+
} from './helpers'
|
|
24
|
+
export type {
|
|
25
|
+
TranslatableProblem,
|
|
26
|
+
TranslateAllFxParams,
|
|
27
|
+
TranslateFxParams,
|
|
28
|
+
Replacement,
|
|
29
|
+
MaskSegmentParams,
|
|
30
|
+
} from './types'
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import {
|
|
2
|
+
attach,
|
|
3
|
+
combine,
|
|
4
|
+
createEffect,
|
|
5
|
+
createEvent,
|
|
6
|
+
restore,
|
|
7
|
+
sample,
|
|
8
|
+
split,
|
|
9
|
+
Store,
|
|
10
|
+
Unit,
|
|
11
|
+
} from 'effector'
|
|
12
|
+
import { GoogleTranslationProvider } from '../providers/google/GoogleTranslationProvider'
|
|
13
|
+
import {
|
|
14
|
+
GoogleTranslateProps,
|
|
15
|
+
GoogleTranslateResponse,
|
|
16
|
+
} from '../providers/google.types'
|
|
17
|
+
import { TranslationService } from './TranslationService'
|
|
18
|
+
import {
|
|
19
|
+
preservedWordsReplacers,
|
|
20
|
+
wordsToPreserve,
|
|
21
|
+
} from '../preserve/wordsToPreserve'
|
|
22
|
+
import {
|
|
23
|
+
CHOICES_CACHE_KEY_SUFFIX,
|
|
24
|
+
DESCRIPTION_CACHE_KEY_SUFFIX,
|
|
25
|
+
GBD_TEXT_CACHE_SUFFIX,
|
|
26
|
+
} from '../constants'
|
|
27
|
+
import {
|
|
28
|
+
TranslatableProblem,
|
|
29
|
+
TranslateAllFxParams,
|
|
30
|
+
TranslateFxParams,
|
|
31
|
+
} from '../types'
|
|
32
|
+
|
|
33
|
+
type TranslationModelProps<TProblem extends TranslatableProblem> = {
|
|
34
|
+
$problem: Store<TProblem | null>
|
|
35
|
+
$problemId: Store<string>
|
|
36
|
+
$assignmentId: Store<string>
|
|
37
|
+
$currentProblemIndex: Store<number>
|
|
38
|
+
$translationLanguageCode: Store<string>
|
|
39
|
+
$contentLanguageCode?: Store<string>
|
|
40
|
+
$isTranslationLocked: Store<boolean>
|
|
41
|
+
languageChanged: Unit<unknown>
|
|
42
|
+
api: {
|
|
43
|
+
translateRequest: (payload: GoogleTranslateProps) => Promise<GoogleTranslateResponse>
|
|
44
|
+
}
|
|
45
|
+
getGreatWorkFeedbackText?: () => string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class TranslationModel<TProblem extends TranslatableProblem = TranslatableProblem> {
|
|
49
|
+
private readonly service: TranslationService
|
|
50
|
+
|
|
51
|
+
public readonly toggle = createEvent()
|
|
52
|
+
public readonly setTranslated = createEvent<boolean>()
|
|
53
|
+
public readonly reset = createEvent()
|
|
54
|
+
|
|
55
|
+
public readonly $isTranslationActive = restore(this.setTranslated, false).reset(this.reset)
|
|
56
|
+
public readonly $isTranslated = this.$isTranslationActive
|
|
57
|
+
public readonly $isTranslationPending
|
|
58
|
+
|
|
59
|
+
public readonly translateFx
|
|
60
|
+
public readonly translateAllFx
|
|
61
|
+
|
|
62
|
+
constructor({
|
|
63
|
+
$problem,
|
|
64
|
+
$problemId,
|
|
65
|
+
$assignmentId,
|
|
66
|
+
$currentProblemIndex,
|
|
67
|
+
$translationLanguageCode,
|
|
68
|
+
$contentLanguageCode,
|
|
69
|
+
$isTranslationLocked,
|
|
70
|
+
languageChanged,
|
|
71
|
+
api,
|
|
72
|
+
getGreatWorkFeedbackText,
|
|
73
|
+
}: TranslationModelProps<TProblem>) {
|
|
74
|
+
this.service = new TranslationService({
|
|
75
|
+
preserve: {
|
|
76
|
+
map: wordsToPreserve,
|
|
77
|
+
replacers: preservedWordsReplacers,
|
|
78
|
+
},
|
|
79
|
+
providers: [new GoogleTranslationProvider({ api })],
|
|
80
|
+
onError: () => this.reset(),
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
this.service.bindCustomCacheKey(
|
|
84
|
+
$problemId,
|
|
85
|
+
(problemId, { target }) => `${problemId}::${target}`,
|
|
86
|
+
)
|
|
87
|
+
this.service.bindTargetLanguage($translationLanguageCode)
|
|
88
|
+
if ($contentLanguageCode) {
|
|
89
|
+
this.service.bindSourceLanguage($contentLanguageCode)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.translateAllFx = attach({
|
|
93
|
+
source: {
|
|
94
|
+
problem: $problem,
|
|
95
|
+
translationLanguageCode: $translationLanguageCode,
|
|
96
|
+
},
|
|
97
|
+
mapParams: (_: void, source) => source,
|
|
98
|
+
effect: createEffect(({ problem, translationLanguageCode }: TranslateAllFxParams<TProblem>) => {
|
|
99
|
+
if (!problem) return
|
|
100
|
+
|
|
101
|
+
const promises: Promise<unknown>[] = [
|
|
102
|
+
this.service.translate(problem.richDescription || problem.description, {
|
|
103
|
+
cacheKeySuffix: DESCRIPTION_CACHE_KEY_SUFFIX,
|
|
104
|
+
}),
|
|
105
|
+
this.service.translate(problem.answerVariants, {
|
|
106
|
+
cacheKeySuffix: CHOICES_CACHE_KEY_SUFFIX,
|
|
107
|
+
}),
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
if (getGreatWorkFeedbackText) {
|
|
111
|
+
promises.push(
|
|
112
|
+
this.service.translate(getGreatWorkFeedbackText(), {
|
|
113
|
+
cacheKey: `${translationLanguageCode}${GBD_TEXT_CACHE_SUFFIX}`,
|
|
114
|
+
}),
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return Promise.all(promises)
|
|
119
|
+
}),
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
this.translateFx = createEffect(({ cacheKey, text }: TranslateFxParams) => {
|
|
123
|
+
return this.service.translate(text, { cacheKey })
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
this.$isTranslationActive.on(this.translateAllFx.doneData, () => true)
|
|
127
|
+
this.$isTranslationActive.on(this.translateAllFx.fail, () => false)
|
|
128
|
+
|
|
129
|
+
split({
|
|
130
|
+
source: sample({
|
|
131
|
+
clock: this.toggle,
|
|
132
|
+
source: this.$isTranslationActive,
|
|
133
|
+
}),
|
|
134
|
+
match: {
|
|
135
|
+
on: (isTranslated) => !isTranslated,
|
|
136
|
+
off: (isTranslated) => isTranslated,
|
|
137
|
+
},
|
|
138
|
+
cases: {
|
|
139
|
+
on: this.translateAllFx,
|
|
140
|
+
off: this.reset,
|
|
141
|
+
},
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
sample({
|
|
145
|
+
clock: languageChanged,
|
|
146
|
+
fn: () => false,
|
|
147
|
+
target: this.setTranslated,
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
sample({
|
|
151
|
+
clock: [$currentProblemIndex, $assignmentId, this.$isTranslationActive],
|
|
152
|
+
source: {
|
|
153
|
+
isTranslated: this.$isTranslationActive,
|
|
154
|
+
isLocked: $isTranslationLocked,
|
|
155
|
+
},
|
|
156
|
+
filter: ({ isTranslated, isLocked }) => isLocked || isTranslated,
|
|
157
|
+
target: this.translateAllFx,
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
this.$isTranslationPending = combine(
|
|
161
|
+
this.translateAllFx.pending,
|
|
162
|
+
this.translateFx.pending,
|
|
163
|
+
(isAllPending, isOnePending) => isAllPending || isOnePending,
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
public getTranslated<T extends string | string[]>(key: string): T | undefined {
|
|
168
|
+
return this.service.getCached<T>(key)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public clearCache() {
|
|
172
|
+
this.service.reset()
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { LanguageGlossary } from '../providers/translation.interface'
|
|
2
|
+
import { maskSegment, replaceMappedTokens } from '../helpers'
|
|
3
|
+
import { Replacement } from '../types'
|
|
4
|
+
|
|
5
|
+
const KATEX_REGEX = /\$(.+?)\$/g
|
|
6
|
+
const NEWLINE_REGEX = /\n/g
|
|
7
|
+
const QUOTE_REGEX = /\\(['"])/g
|
|
8
|
+
const DOLLAR_REGEX = /\\\$/gm
|
|
9
|
+
const COMMA_REGEX = /,/gm
|
|
10
|
+
const DOT_REGEX = /\./gm
|
|
11
|
+
|
|
12
|
+
const wrapNoTranslate = (content: string) => `<span translate="no">${content}</span>`
|
|
13
|
+
|
|
14
|
+
const KATEX_PLACEHOLDER = wrapNoTranslate('{{@}}')
|
|
15
|
+
const NEWLINE__PLACEHOLDER = wrapNoTranslate('{{#}}')
|
|
16
|
+
const QUOTE_PLACEHOLDER = wrapNoTranslate('{{""}}')
|
|
17
|
+
const DOLLAR_PLACEHOLDER = wrapNoTranslate('{{!}}')
|
|
18
|
+
const COMMA_PLACEHOLDER = wrapNoTranslate('{{,}}')
|
|
19
|
+
const DOT_PLACEHOLDER = wrapNoTranslate('{{.}}')
|
|
20
|
+
|
|
21
|
+
const defaultOrderedReplacersMap = [
|
|
22
|
+
[DOLLAR_REGEX, DOLLAR_PLACEHOLDER],
|
|
23
|
+
[KATEX_REGEX, KATEX_PLACEHOLDER],
|
|
24
|
+
[NEWLINE_REGEX, NEWLINE__PLACEHOLDER],
|
|
25
|
+
[QUOTE_REGEX, QUOTE_PLACEHOLDER],
|
|
26
|
+
[COMMA_REGEX, COMMA_PLACEHOLDER],
|
|
27
|
+
[DOT_REGEX, DOT_PLACEHOLDER],
|
|
28
|
+
] as const
|
|
29
|
+
|
|
30
|
+
type SetupPreservableProps = {
|
|
31
|
+
glossaryToPreserve: LanguageGlossary
|
|
32
|
+
preserveWordsReplacers: [RegExp, string][]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class TranslationKatexPreprocessor {
|
|
36
|
+
private static plaintextConverter: (text: string) => string = (text) => text
|
|
37
|
+
|
|
38
|
+
public static setPlaintextConverter(converter: (text: string) => string) {
|
|
39
|
+
this.plaintextConverter = converter
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public static shouldSkipTranslation(text: string | string[] = '') {
|
|
43
|
+
if (Array.isArray(text)) {
|
|
44
|
+
return text.every(
|
|
45
|
+
(t) => this.isMathExpressionOnly(t) || this.isSingleLetter(t) || this.isMathSymbolsOnly(t),
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
this.isMathExpressionOnly(text) || this.isSingleLetter(text) || this.isMathSymbolsOnly(text)
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public static isMathExpressionOnly(text: string) {
|
|
55
|
+
return /^[\d\s+\-*/^=().\\><%!|]+$/.test(text.trim())
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public static isSingleLetter(text: string) {
|
|
59
|
+
return /^[a-zA-Z]$/.test(text)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public static isMathSymbolsOnly(text: string) {
|
|
63
|
+
const plainText = this.plaintextConverter(text)
|
|
64
|
+
const cleanedUp = plainText.replace(/(\\\\|\\|\$|\−|\+|\=|\*|kr|pln|€|£|x|y|\{|\}|\÷)/gi, '')
|
|
65
|
+
const mathOnlyRegex = /^(?=.*\d)[0-9+\-×÷*/^().\s]+$/u
|
|
66
|
+
return cleanedUp.length > 0 && mathOnlyRegex.test(cleanedUp)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private globalTargetLanguage: string | null = null
|
|
70
|
+
private preserveWordsMap: LanguageGlossary = {}
|
|
71
|
+
private preserveWordsReplacers: [RegExp, string][] = []
|
|
72
|
+
|
|
73
|
+
private normalizePlaceholderSpacing(text: string) {
|
|
74
|
+
return text
|
|
75
|
+
.replace(/\s+(<span[^>]*translate="no"[^>]*>)/g, '$1')
|
|
76
|
+
.replace(/(<\/span>)\s+/g, '$1')
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public sanitize(text: string): { sanitized: string; replacements: Replacement[] } {
|
|
80
|
+
const language = this.globalTargetLanguage ?? ''
|
|
81
|
+
const replacements: Replacement[] = []
|
|
82
|
+
let sanitizedText = text
|
|
83
|
+
|
|
84
|
+
defaultOrderedReplacersMap.forEach(([regex, placeholder]) => {
|
|
85
|
+
sanitizedText = maskSegment({
|
|
86
|
+
text: sanitizedText,
|
|
87
|
+
regex,
|
|
88
|
+
placeholder,
|
|
89
|
+
replacements,
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
this.preserveWordsReplacers.forEach(([regex, placeholder]) => {
|
|
94
|
+
const preserveWordsMapTarget = this.preserveWordsMap[language]
|
|
95
|
+
|
|
96
|
+
sanitizedText = maskSegment({
|
|
97
|
+
text: sanitizedText,
|
|
98
|
+
regex,
|
|
99
|
+
placeholder,
|
|
100
|
+
replacements,
|
|
101
|
+
shouldSkip: (match) =>
|
|
102
|
+
this.skipCustomReplacerSanitizeWithoutGlossary(match, preserveWordsMapTarget),
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
return { sanitized: sanitizedText, replacements }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public restore(text: string, replacements: Replacement[]) {
|
|
110
|
+
let restored = this.normalizePlaceholderSpacing(text)
|
|
111
|
+
replacements.forEach(({ placeholder, original, leftPad, rightPad }) => {
|
|
112
|
+
const wrapped = `${leftPad ? ' ' : ''}${original}${rightPad ? ' ' : ''}`
|
|
113
|
+
restored = restored.replace(placeholder, wrapped)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
return this.applyPreserved(restored)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public sanitizeBatch(texts: string[]): { sanitized: string[]; replacements: Replacement[][] } {
|
|
120
|
+
const sanitized: string[] = []
|
|
121
|
+
const replacements: Replacement[][] = []
|
|
122
|
+
|
|
123
|
+
texts.forEach((t) => {
|
|
124
|
+
const { sanitized: s, replacements: r } = this.sanitize(t)
|
|
125
|
+
sanitized.push(s)
|
|
126
|
+
replacements.push(r)
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
return { sanitized, replacements }
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public restoreBatch(texts: string[], replacementsArray: Replacement[][]) {
|
|
133
|
+
return texts.map((t, i) => {
|
|
134
|
+
const restored = this.restore(t, replacementsArray[i])
|
|
135
|
+
return this.applyPreserved(restored)
|
|
136
|
+
})
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Glossaries apply after translation response and do not remove words from payload.
|
|
140
|
+
// This replaces words from the string before sending request to API to completely avoid
|
|
141
|
+
// translating it. We use it to avoid "context localization" e.g. Google API changes numbers
|
|
142
|
+
// when units are passed and target language is from a different region. We must preserve
|
|
143
|
+
// words like "miles" and the exact number in this case.
|
|
144
|
+
public setupPreservable({ glossaryToPreserve, preserveWordsReplacers }: SetupPreservableProps) {
|
|
145
|
+
this.preserveWordsMap = glossaryToPreserve
|
|
146
|
+
this.preserveWordsReplacers = preserveWordsReplacers
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public setupTarget(language: string) {
|
|
150
|
+
this.globalTargetLanguage = language
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private skipCustomReplacerSanitizeWithoutGlossary(
|
|
154
|
+
match: string,
|
|
155
|
+
preserveWordsMapTarget?: Record<string, string>,
|
|
156
|
+
) {
|
|
157
|
+
if (!preserveWordsMapTarget) return true
|
|
158
|
+
|
|
159
|
+
const normalized = match.toLowerCase()
|
|
160
|
+
const glossaryKeys = Object.keys(preserveWordsMapTarget).map((key) => key.toLowerCase())
|
|
161
|
+
|
|
162
|
+
return !glossaryKeys.includes(normalized)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private applyPreserved(restored: string) {
|
|
166
|
+
const language = this.globalTargetLanguage ?? ''
|
|
167
|
+
const preservedMap = this.preserveWordsMap[language]
|
|
168
|
+
|
|
169
|
+
return preservedMap ? replaceMappedTokens(restored, preservedMap) : restored
|
|
170
|
+
}
|
|
171
|
+
}
|