@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
|
@@ -7,13 +7,14 @@ exports.VoicePlayerModel = void 0;
|
|
|
7
7
|
var _effector = require("effector");
|
|
8
8
|
var _VoiceTranscriptionsCollection = require("./VoiceTranscriptionsCollection.js");
|
|
9
9
|
var _VoiceFileDownloaderModel = require("./VoiceFileDownloader.model.js");
|
|
10
|
-
var
|
|
10
|
+
var _VoiceTranscriptionModel = require("./VoiceTranscription.model.js");
|
|
11
|
+
var _VoiceTranscriptionTranslationModel = require("./VoiceTranscriptionTranslation.model.js");
|
|
11
12
|
var _PlayerModel = require("./Player.model.js");
|
|
12
13
|
var _TranscriptionsDownloaderModel = require("./TranscriptionsDownloaderModel.js");
|
|
13
14
|
class VoicePlayerModel {
|
|
14
15
|
collection = new _VoiceTranscriptionsCollection.VoiceTranscriptionsCollection();
|
|
15
16
|
downloader = new _VoiceFileDownloaderModel.VoiceFileDownloaderModel();
|
|
16
|
-
dropdown = new
|
|
17
|
+
dropdown = new _VoiceTranscriptionModel.VoiceTranscriptionModel();
|
|
17
18
|
playerModel = new _PlayerModel.PlayerModel();
|
|
18
19
|
currentPlayingAttempt = null;
|
|
19
20
|
shouldPreventPlayback = false;
|
|
@@ -36,10 +37,12 @@ class VoicePlayerModel {
|
|
|
36
37
|
this.currentPlayingAttempt = null;
|
|
37
38
|
this.setCurrentAttempt(null);
|
|
38
39
|
this.collection.clear();
|
|
40
|
+
this.translation.clearCache();
|
|
39
41
|
};
|
|
40
42
|
constructor(params) {
|
|
41
43
|
this.api = params.api;
|
|
42
44
|
this.loader = new _TranscriptionsDownloaderModel.TranscriptionsDownloaderModel(this.collection, params.api);
|
|
45
|
+
this.translation = new _VoiceTranscriptionTranslationModel.VoiceTranscriptionTranslationModel(this.collection, params.api);
|
|
43
46
|
this.downloader.setApi(params.api);
|
|
44
47
|
this.playerModel.playbackFinished.watch(() => {
|
|
45
48
|
this.currentPlayingAttempt = null;
|
|
@@ -199,6 +202,7 @@ class VoicePlayerModel {
|
|
|
199
202
|
this.reset();
|
|
200
203
|
this.loader.reset();
|
|
201
204
|
this.dropdown.reset();
|
|
205
|
+
this.translation.reset();
|
|
202
206
|
this.playerModel.release();
|
|
203
207
|
}
|
|
204
208
|
togglePlayPause = (0, _effector.attach)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_effector","require","_VoiceTranscriptionsCollection","_VoiceFileDownloaderModel","
|
|
1
|
+
{"version":3,"names":["_effector","require","_VoiceTranscriptionsCollection","_VoiceFileDownloaderModel","_VoiceTranscriptionModel","_VoiceTranscriptionTranslationModel","_PlayerModel","_TranscriptionsDownloaderModel","VoicePlayerModel","collection","VoiceTranscriptionsCollection","downloader","VoiceFileDownloaderModel","dropdown","VoiceTranscriptionModel","playerModel","PlayerModel","currentPlayingAttempt","shouldPreventPlayback","setCurrentAttempt","createEvent","reset","$currentAttempt","restore","$playerState","pauseAudio","pause","stopAudio","abortAllDownloads","stop","resetPlayer","releaseCollectionResources","clear","translation","clearCache","constructor","params","api","loader","TranscriptionsDownloaderModel","VoiceTranscriptionTranslationModel","setApi","playbackFinished","watch","audios","initializeCollectionFromAudios","setupAudioMode","initializeWithAudios","answerAudio","setTranscriptsLoaded","console","warn","forEach","audio","index","attemptNumber","audioFileId","add","_id","hasDrawing","drawing","getAll","item","controller","abortDownload","audioUri","startsWith","URL","revokeObjectURL","e","audioLoading","update","undefined","audioDownloadPromise","handlePlayAttempt","createEffect","get","hasAudio","playAudioFx","setPlayerState","PlayerState","LOADING","collectionItem","downloadPromise","download","abort","result","uri","audioError","IDLE","error","Error","name","message","player","remove","playing","resume","play","isAudioLoading","getAllAttempts","reinitializePlayer","reinitialize","cleanup","release","togglePlayPause","attach","source","mapParams","playerState","effect","PLAYING","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/VoicePlayer.model.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,8BAAA,GAAAD,OAAA;AACA,IAAAE,yBAAA,GAAAF,OAAA;AACA,IAAAG,wBAAA,GAAAH,OAAA;AACA,IAAAI,mCAAA,GAAAJ,OAAA;AAEA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,8BAAA,GAAAN,OAAA;AAWO,MAAMO,gBAAgB,CAAC;EACZC,UAAU,GAAG,IAAIC,4DAA6B,CAAC,CAAC;EAChDC,UAAU,GAAG,IAAIC,kDAAwB,CAAC,CAAC;EAC3CC,QAAQ,GAAG,IAAIC,gDAAuB,CAAC,CAAC;EAExCC,WAAW,GAAG,IAAIC,wBAAW,CAAC,CAAC;EAGvCC,qBAAqB,GAAkB,IAAI;EAC3CC,qBAAqB,GAAG,KAAK;EAErBC,iBAAiB,GAAG,IAAAC,qBAAW,EAAgB,CAAC;EAChDC,KAAK,GAAG,IAAAD,qBAAW,EAAC,CAAC;EAErBE,eAAe,GAAG,IAAAC,iBAAO,EAAC,IAAI,CAACJ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mC,CAAC,KAAK;MAC9E,IAAI,IAAI,CAAC5F,qBAAqB,KAAKsC,aAAa,IAAIsD,WAAW,KAAK7B,wBAAW,CAAC+B,OAAO,EAAE;QACvF,IAAI,CAACtF,UAAU,CAAC,CAAC;MACnB,CAAC,MAAM;QACL,IAAI,CAACiD,iBAAiB,CAACnB,aAAa,CAAC;MACvC;IACF,CAAC;EACH,CAAC,CAAC;AACJ;AAACyD,OAAA,CAAAxG,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.VoiceTranscriptionModel = void 0;
|
|
7
7
|
var _effector = require("effector");
|
|
8
|
-
class
|
|
8
|
+
class VoiceTranscriptionModel {
|
|
9
9
|
toggleExpand = (0, _effector.createEvent)();
|
|
10
10
|
setExpanded = (0, _effector.createEvent)();
|
|
11
11
|
reset = (0, _effector.createEvent)();
|
|
12
12
|
$isExpanded = (0, _effector.restore)(this.setExpanded, false).on(this.toggleExpand, state => !state).reset(this.reset);
|
|
13
13
|
}
|
|
14
|
-
exports.
|
|
15
|
-
//# sourceMappingURL=
|
|
14
|
+
exports.VoiceTranscriptionModel = VoiceTranscriptionModel;
|
|
15
|
+
//# sourceMappingURL=VoiceTranscription.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_effector","require","VoiceTranscriptionModel","toggleExpand","createEvent","setExpanded","reset","$isExpanded","restore","on","state","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/VoiceTranscription.model.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,uBAAuB,CAAC;EACnBC,YAAY,GAAG,IAAAC,qBAAW,EAAC,CAAC;EAC5BC,WAAW,GAAG,IAAAD,qBAAW,EAAU,CAAC;EACpCE,KAAK,GAAG,IAAAF,qBAAW,EAAC,CAAC;EAErBG,WAAW,GAAG,IAAAC,iBAAO,EAAC,IAAI,CAACH,WAAW,EAAE,KAAK,CAAC,CAC3DI,EAAE,CAAC,IAAI,CAACN,YAAY,EAAGO,KAAK,IAAK,CAACA,KAAK,CAAC,CACxCJ,KAAK,CAAC,IAAI,CAACA,KAAK,CAAC;AACtB;AAACK,OAAA,CAAAT,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.VoiceTranscriptionTranslationModel = void 0;
|
|
7
|
+
var _effector = require("effector");
|
|
8
|
+
var _TranslationService = require("../../../translation/model/TranslationService.js");
|
|
9
|
+
var _GoogleTranslationProvider = require("../../../translation/providers/google/GoogleTranslationProvider.js");
|
|
10
|
+
var _wordsToPreserve = require("../../../translation/preserve/wordsToPreserve.js");
|
|
11
|
+
class VoiceTranscriptionTranslationModel {
|
|
12
|
+
toggle = (0, _effector.createEvent)();
|
|
13
|
+
setActive = (0, _effector.createEvent)();
|
|
14
|
+
clearCache = (0, _effector.createEvent)();
|
|
15
|
+
reset = (0, _effector.createEvent)();
|
|
16
|
+
$isActive = (0, _effector.restore)(this.setActive, false).on(this.toggle, state => !state).reset(this.reset);
|
|
17
|
+
translate = (0, _effector.createEffect)(async ({
|
|
18
|
+
attemptNumber,
|
|
19
|
+
targetLanguage
|
|
20
|
+
}) => {
|
|
21
|
+
const item = this.collection.get(attemptNumber);
|
|
22
|
+
if (!item?.transcript) return null;
|
|
23
|
+
const text = await this.service.translate(item.transcript, {
|
|
24
|
+
targetLang: targetLanguage,
|
|
25
|
+
sourceLang: item.transcriptLanguage,
|
|
26
|
+
cacheKey: `voice::${attemptNumber}::${targetLanguage}`
|
|
27
|
+
});
|
|
28
|
+
if (!text) return null;
|
|
29
|
+
return {
|
|
30
|
+
attemptNumber,
|
|
31
|
+
text
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
$translations = (0, _effector.createStore)({}).on(this.translate.doneData, (state, result) => {
|
|
35
|
+
if (!result) return state;
|
|
36
|
+
return {
|
|
37
|
+
...state,
|
|
38
|
+
[result.attemptNumber]: result.text
|
|
39
|
+
};
|
|
40
|
+
}).reset(this.reset, this.clearCache);
|
|
41
|
+
constructor(collection, api) {
|
|
42
|
+
this.collection = collection;
|
|
43
|
+
this.service = new _TranslationService.TranslationService({
|
|
44
|
+
preserve: {
|
|
45
|
+
map: _wordsToPreserve.wordsToPreserve,
|
|
46
|
+
replacers: _wordsToPreserve.preservedWordsReplacers
|
|
47
|
+
},
|
|
48
|
+
providers: [new _GoogleTranslationProvider.GoogleTranslationProvider({
|
|
49
|
+
api: {
|
|
50
|
+
translateRequest: api.translateText
|
|
51
|
+
}
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
54
|
+
this.clearCache.watch(() => this.service.reset());
|
|
55
|
+
this.reset.watch(() => this.service.reset());
|
|
56
|
+
}
|
|
57
|
+
getTranslation(attemptNumber) {
|
|
58
|
+
return this.$translations.getState()[attemptNumber];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.VoiceTranscriptionTranslationModel = VoiceTranscriptionTranslationModel;
|
|
62
|
+
//# sourceMappingURL=VoiceTranscriptionTranslation.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_effector","require","_TranslationService","_GoogleTranslationProvider","_wordsToPreserve","VoiceTranscriptionTranslationModel","toggle","createEvent","setActive","clearCache","reset","$isActive","restore","on","state","translate","createEffect","attemptNumber","targetLanguage","item","collection","get","transcript","text","service","targetLang","sourceLang","transcriptLanguage","cacheKey","$translations","createStore","doneData","result","constructor","api","TranslationService","preserve","map","wordsToPreserve","replacers","preservedWordsReplacers","providers","GoogleTranslationProvider","translateRequest","translateText","watch","getTranslation","getState","exports"],"sourceRoot":"../../../../../../src","sources":["features/vo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S,CAACgB,QAAQ,EAAE,CAACjB,KAAK,EAAEkB,MAAM,KAAK;IAC9C,IAAI,CAACA,MAAM,EAAE,OAAOlB,KAAK;IACzB,OAAO;MAAE,GAAGA,KAAK;MAAE,CAACkB,MAAM,CAACf,aAAa,GAAGe,MAAM,CAACT;IAAK,CAAC;EAC1D,CAAC,CAAC,CACDb,KAAK,CAAC,IAAI,CAACA,KAAK,EAAE,IAAI,CAACD,UAAU,CAAC;EAErCwB,WAAWA,CAACb,UAAyC,EAAEc,GAAmB,EAAE;IAC1E,IAAI,CAACd,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACI,OAAO,GAAG,IAAIW,sCAAkB,CAAC;MACpCC,QAAQ,EAAE;QACRC,GAAG,EAAEC,gCAAe;QACpBC,SAAS,EAAEC;MACb,CAAC;MACDC,SAAS,EAAE,CAAC,IAAIC,oDAAyB,CAAC;QAAER,GAAG,EAAE;UAAES,gBAAgB,EAAET,GAAG,CAACU;QAAc;MAAE,CAAC,CAAC;IAC7F,CAAC,CAAC;IAEF,IAAI,CAACnC,UAAU,CAACoC,KAAK,CAAC,MAAM,IAAI,CAACrB,OAAO,CAACd,KAAK,CAAC,CAAC,CAAC;IACjD,IAAI,CAACA,KAAK,CAACmC,KAAK,CAAC,MAAM,IAAI,CAACrB,OAAO,CAACd,KAAK,CAAC,CAAC,CAAC;EAC9C;EAEOoC,cAAcA,CAAC7B,aAAqB,EAAsB;IAC/D,OAAO,IAAI,CAACY,aAAa,CAACkB,QAAQ,CAAC,CAAC,CAAC9B,aAAa,CAAC;EACrD;AACF;AAAC+B,OAAA,CAAA3C,kCAAA,GAAAA,kCAAA","ignoreList":[]}
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.RecordButtonVariant = void 0;
|
|
6
|
+
exports.VoiceTranscriptionVariant = exports.RecordButtonVariant = void 0;
|
|
7
7
|
let RecordButtonVariant = exports.RecordButtonVariant = /*#__PURE__*/function (RecordButtonVariant) {
|
|
8
8
|
RecordButtonVariant["DEFAULT"] = "default";
|
|
9
9
|
RecordButtonVariant["ADVANCED"] = "advanced";
|
|
10
10
|
return RecordButtonVariant;
|
|
11
11
|
}({});
|
|
12
|
+
let VoiceTranscriptionVariant = exports.VoiceTranscriptionVariant = /*#__PURE__*/function (VoiceTranscriptionVariant) {
|
|
13
|
+
VoiceTranscriptionVariant["SMALL"] = "small";
|
|
14
|
+
VoiceTranscriptionVariant["LARGE"] = "large";
|
|
15
|
+
return VoiceTranscriptionVariant;
|
|
16
|
+
}({});
|
|
12
17
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RecordButtonVariant","exports"],"sourceRoot":"../../../../src","sources":["features/voice/types.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"names":["RecordButtonVariant","exports","VoiceTranscriptionVariant"],"sourceRoot":"../../../../src","sources":["features/voice/types.ts"],"mappings":";;;;;;IA8FYA,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA;AAAA,IAKnBE,yBAAyB,GAAAD,OAAA,CAAAC,yBAAA,0BAAzBA,yBAAyB;EAAzBA,yBAAyB;EAAzBA,yBAAyB;EAAA,OAAzBA,yBAAyB;AAAA","ignoreList":[]}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -193,4 +193,16 @@ Object.keys(_index15).forEach(function (key) {
|
|
|
193
193
|
}
|
|
194
194
|
});
|
|
195
195
|
});
|
|
196
|
+
var _index16 = require("./features/translation/index.js");
|
|
197
|
+
Object.keys(_index16).forEach(function (key) {
|
|
198
|
+
if (key === "default" || key === "__esModule") return;
|
|
199
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
200
|
+
if (key in exports && exports[key] === _index16[key]) return;
|
|
201
|
+
Object.defineProperty(exports, key, {
|
|
202
|
+
enumerable: true,
|
|
203
|
+
get: function () {
|
|
204
|
+
return _index16[key];
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
});
|
|
196
208
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_helpers","require","_index","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_index2","_index3","_index4","_index5","_index6","_index7","_index8","_index9","_index10","_index11","_index12","_index13","_index14","_index15"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,OAAA,GAAAd,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAW,OAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,OAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,G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AS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAY,QAAA,CAAApB,GAAA;IAAA;EAAA;AAAA;AACA,IAAAqB,QAAA,GAAA1B,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAuB,QAAA,EAAAtB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAqB,QAAA,CAAArB,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAa,QAAA,CAAArB,GAAA;IAAA;EAAA;AAAA;AACA,IAAAsB,QAAA,GAAA3B,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAwB,QAAA,EAAAvB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAsB,QAAA,CAAAtB,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAc,QAAA,CAAAtB,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_helpers","require","_index","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_index2","_index3","_index4","_index5","_index6","_index7","_index8","_index9","_index10","_index11","_index12","_index13","_index14","_index15","_index16"],"sourceRoot":"../../src","sources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::gbd';
|
|
4
|
+
export const DESCRIPTION_CACHE_KEY_SUFFIX = '::description';
|
|
5
|
+
export const CHOICES_CACHE_KEY_SUFFIX = '::choices';
|
|
6
|
+
export const PRACTICE_THEORY_CACHE_KEY_SUFFIX = '::practice-theory';
|
|
7
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GBD_TEXT_CACHE_SUFFIX","DESCRIPTION_CACHE_KEY_SUFFIX","CHOICES_CACHE_KEY_SUFFIX","PRACTICE_THEORY_CACHE_KEY_SUFFIX"],"sourceRoot":"../../../../src","sources":["features/translation/constants.ts"],"mappings":";;AAAA,OAAO,MAAMA,qBAAqB,GAAG,OAAO;AAC5C,OAAO,MAAMC,4BAA4B,GAAG,eAAe;AAC3D,OAAO,MAAMC,wBAAwB,GAAG,WAAW;AACnD,OAAO,MAAMC,gCAAgC,GAAG,mBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export function replaceMappedTokens(input, map) {
|
|
4
|
+
let result = input;
|
|
5
|
+
for (const [original, override] of Object.entries(map)) {
|
|
6
|
+
const escaped = original.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
7
|
+
const regex = new RegExp(`\\b${escaped}\\b`, 'gi');
|
|
8
|
+
result = result.replace(regex, override);
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Masks text segments matched by `regex` with a placeholder,
|
|
15
|
+
* while preserving spaces around the original match.
|
|
16
|
+
*/
|
|
17
|
+
export const maskSegment = ({
|
|
18
|
+
text,
|
|
19
|
+
regex,
|
|
20
|
+
placeholder,
|
|
21
|
+
replacements,
|
|
22
|
+
shouldSkip
|
|
23
|
+
}) => {
|
|
24
|
+
return text.replace(regex, (match, ...args) => {
|
|
25
|
+
if (shouldSkip?.(match)) return match;
|
|
26
|
+
const offset = args[args.length - 2];
|
|
27
|
+
const input = args[args.length - 1];
|
|
28
|
+
const before = offset > 0 ? input[offset - 1] : '';
|
|
29
|
+
const afterIdx = offset + match.length;
|
|
30
|
+
const after = afterIdx < input.length ? input[afterIdx] : '';
|
|
31
|
+
const leftPad = /\s/.test(before);
|
|
32
|
+
const rightPad = /\s/.test(after);
|
|
33
|
+
replacements.push({
|
|
34
|
+
placeholder,
|
|
35
|
+
original: match,
|
|
36
|
+
leftPad,
|
|
37
|
+
rightPad
|
|
38
|
+
});
|
|
39
|
+
return placeholder;
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const HTML_NAMED_ENTITIES = {
|
|
43
|
+
'&': '&',
|
|
44
|
+
'<': '<',
|
|
45
|
+
'>': '>',
|
|
46
|
+
'"': '"',
|
|
47
|
+
''': "'",
|
|
48
|
+
' ': ' '
|
|
49
|
+
};
|
|
50
|
+
export const decodeHtmlEntities = text => {
|
|
51
|
+
return text.replace(/&#(\d+);/g, (_, code) => String.fromCharCode(parseInt(code, 10))).replace(/&#x([0-9a-f]+);/gi, (_, code) => String.fromCharCode(parseInt(code, 16))).replace(/&(amp|lt|gt|quot|apos|nbsp);/g, match => HTML_NAMED_ENTITIES[match] ?? match);
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["replaceMappedTokens","input","map","result","original","override","Object","entries","escaped","replace","regex","RegExp","maskSegment","text","placeholder","replacements","shouldSkip","match","args","offset","length","before","afterIdx","after","leftPad","test","rightPad","push","HTML_NAMED_ENTITIES","decodeHtmlEntities","_","code","String","fromCharCode","parseInt"],"sourceRoot":"../../../../src","sources":["features/translation/helpers.ts"],"mappings":";;AAEA,OAAO,SAASA,mBAAmBA,CAACC,KAAa,EAAEC,GAA2B,EAAU;EACtF,IAAIC,MAAM,GAAGF,KAAK;EAElB,KAAK,MAAM,CAACG,QAAQ,EAAEC,QAAQ,CAAC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AAEE;IAAS,CAAC,CAAC;IAEtE,OAAOZ,WAAW;EACpB,CAAC,CAAC;AACJ,CAAC;AAED,MAAMc,mBAA2C,GAAG;EAClD,OAAO,EAAE,GAAG;EACZ,MAAM,EAAE,GAAG;EACX,MAAM,EAAE,GAAG;EACX,QAAQ,EAAE,GAAG;EACb,QAAQ,EAAE,GAAG;EACb,QAAQ,EAAE;AACZ,CAAC;AAED,OAAO,MAAMC,kBAAkB,GAAIhB,IAAY,IAAa;EAC1D,OAAOA,IAAI,CACRJ,OAAO,CAAC,WAAW,EAAE,CAACqB,CAAC,EAAEC,IAAY,KAAKC,MAAM,CAACC,YAAY,CAACC,QAAQ,CAACH,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAClFtB,OAAO,CAAC,mBAAmB,EAAE,CAACqB,CAAC,EAAEC,IAAY,KAAKC,MAAM,CAACC,YAAY,CAACC,QAAQ,CAACH,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAC1FtB,OAAO,CACN,+BAA+B,EAC9BQ,KAAK,IAAKW,mBAAmB,CAACX,KAAK,CAAC,IAAIA,KAC3C,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export { TranslationModel } from "./model/TranslationModel.js";
|
|
4
|
+
export { TranslationService } from "./model/TranslationService.js";
|
|
5
|
+
export { TranslationKatexPreprocessor } from "./model/TranslationPreprocessor.js";
|
|
6
|
+
export { TranslationProvider } from "./providers/translation.interface.js";
|
|
7
|
+
export { GoogleTranslationProvider } from "./providers/google/GoogleTranslationProvider.js";
|
|
8
|
+
export { GoogleTranslateLanguage } from "./providers/google/supportedLanguages.js";
|
|
9
|
+
export { wordsToPreserve, preservedWordsReplacers } from "./preserve/wordsToPreserve.js";
|
|
10
|
+
export { GBD_TEXT_CACHE_SUFFIX, DESCRIPTION_CACHE_KEY_SUFFIX, CHOICES_CACHE_KEY_SUFFIX, PRACTICE_THEORY_CACHE_KEY_SUFFIX } from "./constants.js";
|
|
11
|
+
export { replaceMappedTokens, maskSegment, decodeHtmlEntities } from "./helpers.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TranslationModel","TranslationService","TranslationKatexPreprocessor","TranslationProvider","GoogleTranslationProvider","GoogleTranslateLanguage","wordsToPreserve","preservedWordsReplacers","GBD_TEXT_CACHE_SUFFIX","DESCRIPTION_CACHE_KEY_SUFFIX","CHOICES_CACHE_KEY_SUFFIX","PRACTICE_THEORY_CACHE_KEY_SUFFIX","replaceMappedTokens","maskSegment","decodeHtmlEntities"],"sourceRoot":"../../../../src","sources":["features/translation/index.ts"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,6BAA0B;AAC3D,SAASC,kBAAkB,QAAmC,+BAA4B;AAC1F,SAASC,4BAA4B,QAAQ,oCAAiC;AAC9E,SAASC,mBAAmB,QAA+B,sCAAmC;AAC9F,SAASC,yBAAyB,QAAQ,iDAA8C;AACxF,SAASC,uBAAuB,QAAQ,0CAAuC;AAM/E,SAASC,eAAe,EAAEC,uBAAuB,QAAQ,+BAA4B;AACrF,SACEC,qBAAqB,EACrBC,4BAA4B,EAC5BC,wBAAwB,EACxBC,gCAAgC,QAC3B,gBAAa;AACpB,SACEC,mBAAmB,EACnBC,WAAW,EACXC,kBAAkB,QACb,cAAW","ignoreList":[]}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { attach, combine, createEffect, createEvent, restore, sample, split } from 'effector';
|
|
4
|
+
import { GoogleTranslationProvider } from "../providers/google/GoogleTranslationProvider.js";
|
|
5
|
+
import { TranslationService } from "./TranslationService.js";
|
|
6
|
+
import { preservedWordsReplacers, wordsToPreserve } from "../preserve/wordsToPreserve.js";
|
|
7
|
+
import { CHOICES_CACHE_KEY_SUFFIX, DESCRIPTION_CACHE_KEY_SUFFIX, GBD_TEXT_CACHE_SUFFIX } from "../constants.js";
|
|
8
|
+
export class TranslationModel {
|
|
9
|
+
toggle = createEvent();
|
|
10
|
+
setTranslated = createEvent();
|
|
11
|
+
reset = createEvent();
|
|
12
|
+
$isTranslationActive = restore(this.setTranslated, false).reset(this.reset);
|
|
13
|
+
$isTranslated = this.$isTranslationActive;
|
|
14
|
+
constructor({
|
|
15
|
+
$problem,
|
|
16
|
+
$problemId,
|
|
17
|
+
$assignmentId,
|
|
18
|
+
$currentProblemIndex,
|
|
19
|
+
$translationLanguageCode,
|
|
20
|
+
$contentLanguageCode,
|
|
21
|
+
$isTranslationLocked,
|
|
22
|
+
languageChanged,
|
|
23
|
+
api,
|
|
24
|
+
getGreatWorkFeedbackText
|
|
25
|
+
}) {
|
|
26
|
+
this.service = new TranslationService({
|
|
27
|
+
preserve: {
|
|
28
|
+
map: wordsToPreserve,
|
|
29
|
+
replacers: preservedWordsReplacers
|
|
30
|
+
},
|
|
31
|
+
providers: [new GoogleTranslationProvider({
|
|
32
|
+
api
|
|
33
|
+
})],
|
|
34
|
+
onError: () => this.reset()
|
|
35
|
+
});
|
|
36
|
+
this.service.bindCustomCacheKey($problemId, (problemId, {
|
|
37
|
+
target
|
|
38
|
+
}) => `${problemId}::${target}`);
|
|
39
|
+
this.service.bindTargetLanguage($translationLanguageCode);
|
|
40
|
+
if ($contentLanguageCode) {
|
|
41
|
+
this.service.bindSourceLanguage($contentLanguageCode);
|
|
42
|
+
}
|
|
43
|
+
this.translateAllFx = attach({
|
|
44
|
+
source: {
|
|
45
|
+
problem: $problem,
|
|
46
|
+
translationLanguageCode: $translationLanguageCode
|
|
47
|
+
},
|
|
48
|
+
mapParams: (_, source) => source,
|
|
49
|
+
effect: createEffect(({
|
|
50
|
+
problem,
|
|
51
|
+
translationLanguageCode
|
|
52
|
+
}) => {
|
|
53
|
+
if (!problem) return;
|
|
54
|
+
const promises = [this.service.translate(problem.richDescription || problem.description, {
|
|
55
|
+
cacheKeySuffix: DESCRIPTION_CACHE_KEY_SUFFIX
|
|
56
|
+
}), this.service.translate(problem.answerVariants, {
|
|
57
|
+
cacheKeySuffix: CHOICES_CACHE_KEY_SUFFIX
|
|
58
|
+
})];
|
|
59
|
+
if (getGreatWorkFeedbackText) {
|
|
60
|
+
promises.push(this.service.translate(getGreatWorkFeedbackText(), {
|
|
61
|
+
cacheKey: `${translationLanguageCode}${GBD_TEXT_CACHE_SUFFIX}`
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
return Promise.all(promises);
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
this.translateFx = createEffect(({
|
|
68
|
+
cacheKey,
|
|
69
|
+
text
|
|
70
|
+
}) => {
|
|
71
|
+
return this.service.translate(text, {
|
|
72
|
+
cacheKey
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
this.$isTranslationActive.on(this.translateAllFx.doneData, () => true);
|
|
76
|
+
this.$isTranslationActive.on(this.translateAllFx.fail, () => false);
|
|
77
|
+
split({
|
|
78
|
+
source: sample({
|
|
79
|
+
clock: this.toggle,
|
|
80
|
+
source: this.$isTranslationActive
|
|
81
|
+
}),
|
|
82
|
+
match: {
|
|
83
|
+
on: isTranslated => !isTranslated,
|
|
84
|
+
off: isTranslated => isTranslated
|
|
85
|
+
},
|
|
86
|
+
cases: {
|
|
87
|
+
on: this.translateAllFx,
|
|
88
|
+
off: this.reset
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
sample({
|
|
92
|
+
clock: languageChanged,
|
|
93
|
+
fn: () => false,
|
|
94
|
+
target: this.setTranslated
|
|
95
|
+
});
|
|
96
|
+
sample({
|
|
97
|
+
clock: [$currentProblemIndex, $assignmentId, this.$isTranslationActive],
|
|
98
|
+
source: {
|
|
99
|
+
isTranslated: this.$isTranslationActive,
|
|
100
|
+
isLocked: $isTranslationLocked
|
|
101
|
+
},
|
|
102
|
+
filter: ({
|
|
103
|
+
isTranslated,
|
|
104
|
+
isLocked
|
|
105
|
+
}) => isLocked || isTranslated,
|
|
106
|
+
target: this.translateAllFx
|
|
107
|
+
});
|
|
108
|
+
this.$isTranslationPending = combine(this.translateAllFx.pending, this.translateFx.pending, (isAllPending, isOnePending) => isAllPending || isOnePending);
|
|
109
|
+
}
|
|
110
|
+
getTranslated(key) {
|
|
111
|
+
return this.service.getCached(key);
|
|
112
|
+
}
|
|
113
|
+
clearCache() {
|
|
114
|
+
this.service.reset();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=TranslationModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["attach","combine","createEffect","createEvent","restore","sample","split","GoogleTranslationProvider","TranslationService","preservedWordsReplacers","wordsToPreserve","CHOICES_CACHE_KEY_SUFFIX","DESCRIPTION_CACHE_KEY_SUFFIX","GBD_TEXT_CACHE_SUFFIX","TranslationModel","toggle","setTranslated","reset","$isTranslationActive","$isTranslated","constructor","$problem","$problemId","$assignmentId","$currentProblemIndex","$translationLanguageCode","$contentLanguageCode","$isTranslationLocked","languageChanged","api","getGreatWorkFeedbackText","service","preserve","map","replacers","providers","onError","bindCustomCacheKey","problemId","target","bindTargetLanguage","bindSourceLanguage","translateAllFx","source","problem","translationLanguageCode","mapParams","_","effect","promises","translate","richDescription","description","cacheKeySuffix","answerVariants","push","cacheKey","Promise","all","translateFx","text","on","doneData","fail","clock","match","isTranslated","off","cases","fn","isLocked","filter","$isTranslationPending","pending","isAllPending","isOnePending","getTranslated","key","getCached","clearCache"],"sourceRoot":"../../../../../src","sources":["features/translation/model/TranslationModel.ts"],"mappings":";;AAAA,SACEA,MAAM,EACNC,OAAO,EACPC,YAAY,EACZC,WAAW,EACXC,OAAO,EACPC,MAAM,EACNC,KAAK,QAGA,UAAU;AACjB,SAASC,yBAAyB,QAAQ,kDAA+C;AAKzF,SAASC,kBAAkB,QAAQ,yBAAsB;AACzD,SACEC,uBAAuB,EACvBC,eAAe,QACV,gCAA6B;AACpC,SACEC,wBAAwB,EACxB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ment, replaceMappedTokens } from "../helpers.js";
|
|
4
|
+
const KATEX_REGEX = /\$(.+?)\$/g;
|
|
5
|
+
const NEWLINE_REGEX = /\n/g;
|
|
6
|
+
const QUOTE_REGEX = /\\(['"])/g;
|
|
7
|
+
const DOLLAR_REGEX = /\\\$/gm;
|
|
8
|
+
const COMMA_REGEX = /,/gm;
|
|
9
|
+
const DOT_REGEX = /\./gm;
|
|
10
|
+
const wrapNoTranslate = content => `<span translate="no">${content}</span>`;
|
|
11
|
+
const KATEX_PLACEHOLDER = wrapNoTranslate('{{@}}');
|
|
12
|
+
const NEWLINE__PLACEHOLDER = wrapNoTranslate('{{#}}');
|
|
13
|
+
const QUOTE_PLACEHOLDER = wrapNoTranslate('{{""}}');
|
|
14
|
+
const DOLLAR_PLACEHOLDER = wrapNoTranslate('{{!}}');
|
|
15
|
+
const COMMA_PLACEHOLDER = wrapNoTranslate('{{,}}');
|
|
16
|
+
const DOT_PLACEHOLDER = wrapNoTranslate('{{.}}');
|
|
17
|
+
const defaultOrderedReplacersMap = [[DOLLAR_REGEX, DOLLAR_PLACEHOLDER], [KATEX_REGEX, KATEX_PLACEHOLDER], [NEWLINE_REGEX, NEWLINE__PLACEHOLDER], [QUOTE_REGEX, QUOTE_PLACEHOLDER], [COMMA_REGEX, COMMA_PLACEHOLDER], [DOT_REGEX, DOT_PLACEHOLDER]];
|
|
18
|
+
export class TranslationKatexPreprocessor {
|
|
19
|
+
static plaintextConverter = text => text;
|
|
20
|
+
static setPlaintextConverter(converter) {
|
|
21
|
+
this.plaintextConverter = converter;
|
|
22
|
+
}
|
|
23
|
+
static shouldSkipTranslation(text = '') {
|
|
24
|
+
if (Array.isArray(text)) {
|
|
25
|
+
return text.every(t => this.isMathExpressionOnly(t) || this.isSingleLetter(t) || this.isMathSymbolsOnly(t));
|
|
26
|
+
}
|
|
27
|
+
return this.isMathExpressionOnly(text) || this.isSingleLetter(text) || this.isMathSymbolsOnly(text);
|
|
28
|
+
}
|
|
29
|
+
static isMathExpressionOnly(text) {
|
|
30
|
+
return /^[\d\s+\-*/^=().\\><%!|]+$/.test(text.trim());
|
|
31
|
+
}
|
|
32
|
+
static isSingleLetter(text) {
|
|
33
|
+
return /^[a-zA-Z]$/.test(text);
|
|
34
|
+
}
|
|
35
|
+
static isMathSymbolsOnly(text) {
|
|
36
|
+
const plainText = this.plaintextConverter(text);
|
|
37
|
+
const cleanedUp = plainText.replace(/(\\\\|\\|\$|\−|\+|\=|\*|kr|pln|€|£|x|y|\{|\}|\÷)/gi, '');
|
|
38
|
+
const mathOnlyRegex = /^(?=.*\d)[0-9+\-×÷*/^().\s]+$/u;
|
|
39
|
+
return cleanedUp.length > 0 && mathOnlyRegex.test(cleanedUp);
|
|
40
|
+
}
|
|
41
|
+
globalTargetLanguage = null;
|
|
42
|
+
preserveWordsMap = {};
|
|
43
|
+
preserveWordsReplacers = [];
|
|
44
|
+
normalizePlaceholderSpacing(text) {
|
|
45
|
+
return text.replace(/\s+(<span[^>]*translate="no"[^>]*>)/g, '$1').replace(/(<\/span>)\s+/g, '$1');
|
|
46
|
+
}
|
|
47
|
+
sanitize(text) {
|
|
48
|
+
const language = this.globalTargetLanguage ?? '';
|
|
49
|
+
const replacements = [];
|
|
50
|
+
let sanitizedText = text;
|
|
51
|
+
defaultOrderedReplacersMap.forEach(([regex, placeholder]) => {
|
|
52
|
+
sanitizedText = maskSegment({
|
|
53
|
+
text: sanitizedText,
|
|
54
|
+
regex,
|
|
55
|
+
placeholder,
|
|
56
|
+
replacements
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
this.preserveWordsReplacers.forEach(([regex, placeholder]) => {
|
|
60
|
+
const preserveWordsMapTarget = this.preserveWordsMap[language];
|
|
61
|
+
sanitizedText = maskSegment({
|
|
62
|
+
text: sanitizedText,
|
|
63
|
+
regex,
|
|
64
|
+
placeholder,
|
|
65
|
+
replacements,
|
|
66
|
+
shouldSkip: match => this.skipCustomReplacerSanitizeWithoutGlossary(match, preserveWordsMapTarget)
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
return {
|
|
70
|
+
sanitized: sanitizedText,
|
|
71
|
+
replacements
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
restore(text, replacements) {
|
|
75
|
+
let restored = this.normalizePlaceholderSpacing(text);
|
|
76
|
+
replacements.forEach(({
|
|
77
|
+
placeholder,
|
|
78
|
+
original,
|
|
79
|
+
leftPad,
|
|
80
|
+
rightPad
|
|
81
|
+
}) => {
|
|
82
|
+
const wrapped = `${leftPad ? ' ' : ''}${original}${rightPad ? ' ' : ''}`;
|
|
83
|
+
restored = restored.replace(placeholder, wrapped);
|
|
84
|
+
});
|
|
85
|
+
return this.applyPreserved(restored);
|
|
86
|
+
}
|
|
87
|
+
sanitizeBatch(texts) {
|
|
88
|
+
const sanitized = [];
|
|
89
|
+
const replacements = [];
|
|
90
|
+
texts.forEach(t => {
|
|
91
|
+
const {
|
|
92
|
+
sanitized: s,
|
|
93
|
+
replacements: r
|
|
94
|
+
} = this.sanitize(t);
|
|
95
|
+
sanitized.push(s);
|
|
96
|
+
replacements.push(r);
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
sanitized,
|
|
100
|
+
replacements
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
restoreBatch(texts, replacementsArray) {
|
|
104
|
+
return texts.map((t, i) => {
|
|
105
|
+
const restored = this.restore(t, replacementsArray[i]);
|
|
106
|
+
return this.applyPreserved(restored);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Glossaries apply after translation response and do not remove words from payload.
|
|
111
|
+
// This replaces words from the string before sending request to API to completely avoid
|
|
112
|
+
// translating it. We use it to avoid "context localization" e.g. Google API changes numbers
|
|
113
|
+
// when units are passed and target language is from a different region. We must preserve
|
|
114
|
+
// words like "miles" and the exact number in this case.
|
|
115
|
+
setupPreservable({
|
|
116
|
+
glossaryToPreserve,
|
|
117
|
+
preserveWordsReplacers
|
|
118
|
+
}) {
|
|
119
|
+
this.preserveWordsMap = glossaryToPreserve;
|
|
120
|
+
this.preserveWordsReplacers = preserveWordsReplacers;
|
|
121
|
+
}
|
|
122
|
+
setupTarget(language) {
|
|
123
|
+
this.globalTargetLanguage = language;
|
|
124
|
+
}
|
|
125
|
+
skipCustomReplacerSanitizeWithoutGlossary(match, preserveWordsMapTarget) {
|
|
126
|
+
if (!preserveWordsMapTarget) return true;
|
|
127
|
+
const normalized = match.toLowerCase();
|
|
128
|
+
const glossaryKeys = Object.keys(preserveWordsMapTarget).map(key => key.toLowerCase());
|
|
129
|
+
return !glossaryKeys.includes(normalized);
|
|
130
|
+
}
|
|
131
|
+
applyPreserved(restored) {
|
|
132
|
+
const language = this.globalTargetLanguage ?? '';
|
|
133
|
+
const preservedMap = this.preserveWordsMap[language];
|
|
134
|
+
return preservedMap ? replaceMappedTokens(restored, preservedMap) : restored;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=TranslationPreprocessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["maskSegment","replaceMappedTokens","KATEX_REGEX","NEWLINE_REGEX","QUOTE_REGEX","DOLLAR_REGEX","COMMA_REGEX","DOT_REGEX","wrapNoTranslate","content","KATEX_PLACEHOLDER","NEWLINE__PLACEHOLDER","QUOTE_PLACEHOLDER","DOLLAR_PLACEHOLDER","COMMA_PLACEHOLDER","DOT_PLACEHOLDER","defaultOrderedReplacersMap","TranslationKatexPreprocessor","plaintextConverter","text","setPlaintextConverter","converter","shouldSkipTranslation","Array","isArray","every","t","isMathExpressionOnly","isSingleLetter","isMathSymbolsOnly","test","trim","plainText","cleanedUp","replace","mathOnlyRegex","length","globalTargetLanguage","preserveWordsMap","preserveWordsReplacers","normalizePlaceholderSpacing","sanitize","language","replacements","sanitizedText","forEach","regex","placeholder","preserveWordsMapTarget","shouldSkip","match","skipCustomReplacerSanitizeWithoutGlossary","sanitized","restore","restored","original","leftPad","rightPad","wrapped","applyPreserved","sanitizeBatch","texts","s","r","push","restoreBatch","replacementsArray","map","i","setupPreservable","glossaryToPreserve","setupTarget","normalized","toLowerCase","glossaryKeys","Object","keys","key","includes","preservedMap"],"sourceRoot":"../../../../../src","sources":["features/translation/model/TranslationPreprocessor.ts"],"mappings":";;AACA,SAASA,WAAW,EAAEC,mBAAmB,QAAQ,eAAY;AAG7D,MAAMC,WAAW,GAAG,YAAY;AAChC,MAAMC,aAAa,GAAG,KAAK;AAC3B,MAAMC,WAAW,GAAG,WAAW;AAC/B,MAAMC,YAAY,GAAG,QAAQ;AAC7B,MAAMC,WAAW,GAAG,KAAK;AACzB,MAAMC,SAAS,GAAG,MAAM;AAExB,MAAMC,eAAe,GAAIC,OAAe,IAAK,wBAAwBA,OAAO,SAAS;AAErF,MAAMC,iBAAiB,GAAGF,eAAe,CAAC,OAAO,CAAC;AAClD,MAAMG,oBAAoB,GAAGH,eAAe,CAAC,OAAO,CAAC;AACrD,MAAMI,iBAAiB,GAAGJ,eAAe,CAAC,QAAQ,CAAC;AACnD,MAAMK,kBAAkB,GAAGL,eAAe,CAAC,OAAO,CAAC;AACnD,MAAMM,iBAAiB,GAAGN,eAAe,CAAC,OAAO,CAAC;AAClD,MAAMO,eAAe,GAAGP,eAAe,CAAC,OAAO,CAAC;AAEhD,MAAMQ,0BAA0B,GAAG,CACjC,CAACX,YAAY,EAAEQ,kBAAkB,CAAC,EAClC,CAACX,WAAW,EAAEQ,iBAAiB,CAAC,EAChC,CAACP,aAAa,EAAEQ,oBAAoB,CAAC,EACrC,CAACP,WAAW,EAAEQ,iBAAiB,CAAC,EAChC,CAACN,WAAW,EAAEQ,iBAAiB,CAAC,EAChC,CAACP,SAAS,EAAEQ,eAAe,CAAC,CACpB;AAOV,OAAO,MAAME,4BAA4B,CAAC;EACxC,OAAeC,kBAAkB,GAA8BC,IAAI,IAAKA,IAAI;EAE5E,OAAcC,qBAAqBA,CAACC,SAAmC,EAAE;IACvE,IAAI,CAACH,kBAAkB,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