@magmamath/students-features 1.3.23-rc.15 → 1.3.23-rc.16
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/voice/playing/components/VoiceTranscription.js +19 -70
- package/dist/commonjs/features/voice/playing/components/VoiceTranscription.js.map +1 -1
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js +2 -2
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +1 -1
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +5 -7
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -1
- package/dist/commonjs/features/voice/playing/hooks/{useVoiceTranscription.js → useDropdownAnimation.js} +8 -7
- package/dist/commonjs/features/voice/playing/hooks/useDropdownAnimation.js.map +1 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.js +127 -0
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/{VoiceTranscription.model.js → Dropdown.model.js} +4 -4
- package/dist/commonjs/features/voice/playing/model/Dropdown.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/PlaybackController.js +148 -0
- package/dist/commonjs/features/voice/playing/model/PlaybackController.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/{VoiceTranscriptionsCollection.js → TranscriptionsCollection.js} +4 -4
- package/dist/commonjs/features/voice/playing/model/TranscriptionsCollection.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js +82 -0
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/{VoiceTranscriptionTranslation.model.js → Translation.model.js} +4 -4
- package/dist/commonjs/features/voice/playing/model/Translation.model.js.map +1 -0
- package/dist/commonjs/features/voice/playing/model/VoiceFileDownloader.model.js +2 -2
- package/dist/commonjs/features/voice/playing/model/VoiceFileDownloader.model.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js +41 -176
- package/dist/commonjs/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
- package/dist/commonjs/shared/components/PlayButton.js +1 -1
- package/dist/commonjs/shared/components/PlayButton.js.map +1 -1
- package/dist/module/features/voice/playing/components/VoiceTranscription.js +19 -68
- package/dist/module/features/voice/playing/components/VoiceTranscription.js.map +1 -1
- package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js +2 -2
- package/dist/module/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map +1 -1
- package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js +7 -7
- package/dist/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map +1 -1
- package/dist/module/features/voice/playing/hooks/{useVoiceTranscription.js → useDropdownAnimation.js} +6 -5
- package/dist/module/features/voice/playing/hooks/useDropdownAnimation.js.map +1 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionController.js +122 -0
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionController.js.map +1 -0
- package/dist/module/features/voice/playing/model/{VoiceTranscription.model.js → Dropdown.model.js} +2 -2
- package/dist/module/features/voice/playing/model/Dropdown.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/PlaybackController.js +143 -0
- package/dist/module/features/voice/playing/model/PlaybackController.js.map +1 -0
- package/dist/module/features/voice/playing/model/{VoiceTranscriptionsCollection.js → TranscriptionsCollection.js} +2 -2
- package/dist/module/features/voice/playing/model/TranscriptionsCollection.js.map +1 -0
- package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js +77 -0
- package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/{VoiceTranscriptionTranslation.model.js → Translation.model.js} +2 -2
- package/dist/module/features/voice/playing/model/Translation.model.js.map +1 -0
- package/dist/module/features/voice/playing/model/VoiceFileDownloader.model.js +2 -2
- package/dist/module/features/voice/playing/model/VoiceFileDownloader.model.js.map +1 -1
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js +43 -178
- package/dist/module/features/voice/playing/model/VoicePlayer.model.js.map +1 -1
- package/dist/module/shared/components/PlayButton.js +2 -2
- package/dist/module/shared/components/PlayButton.js.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +2 -2
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +1 -1
- package/dist/typescript/{module/features/voice/playing/hooks/useVoiceTranscription.d.ts → commonjs/features/voice/playing/hooks/useDropdownAnimation.d.ts} +3 -3
- package/dist/typescript/commonjs/features/voice/playing/hooks/useDropdownAnimation.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts +30 -0
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/{VoiceTranscription.model.d.ts → Dropdown.model.d.ts} +2 -2
- package/dist/typescript/commonjs/features/voice/playing/model/Dropdown.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/PlaybackController.d.ts +27 -0
- package/dist/typescript/commonjs/features/voice/playing/model/PlaybackController.d.ts.map +1 -0
- package/dist/typescript/{module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts → commonjs/features/voice/playing/model/TranscriptionsCollection.d.ts} +2 -2
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsCollection.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +19 -0
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -0
- package/dist/typescript/{module/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts → commonjs/features/voice/playing/model/Translation.model.d.ts} +4 -4
- package/dist/typescript/commonjs/features/voice/playing/model/Translation.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceFileDownloader.model.d.ts +2 -2
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceFileDownloader.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts +16 -20
- package/dist/typescript/commonjs/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscription.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts +2 -2
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionCollapsible.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptionHeaderActions.d.ts.map +1 -1
- package/dist/typescript/{commonjs/features/voice/playing/hooks/useVoiceTranscription.d.ts → module/features/voice/playing/hooks/useDropdownAnimation.d.ts} +3 -3
- package/dist/typescript/module/features/voice/playing/hooks/useDropdownAnimation.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts +30 -0
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionController.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/{VoiceTranscription.model.d.ts → Dropdown.model.d.ts} +2 -2
- package/dist/typescript/module/features/voice/playing/model/Dropdown.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/PlaybackController.d.ts +27 -0
- package/dist/typescript/module/features/voice/playing/model/PlaybackController.d.ts.map +1 -0
- package/dist/typescript/{commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts → module/features/voice/playing/model/TranscriptionsCollection.d.ts} +2 -2
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsCollection.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +19 -0
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -0
- package/dist/typescript/{commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts → module/features/voice/playing/model/Translation.model.d.ts} +4 -4
- package/dist/typescript/module/features/voice/playing/model/Translation.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/playing/model/VoiceFileDownloader.model.d.ts +2 -2
- package/dist/typescript/module/features/voice/playing/model/VoiceFileDownloader.model.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts +16 -20
- package/dist/typescript/module/features/voice/playing/model/VoicePlayer.model.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/features/voice/playing/components/VoiceTranscription.tsx +17 -109
- package/src/features/voice/playing/components/VoiceTranscriptionCollapsible.tsx +4 -4
- package/src/features/voice/playing/components/VoiceTranscriptionHeaderActions.tsx +8 -10
- package/src/features/voice/playing/hooks/{useVoiceTranscription.ts → useDropdownAnimation.ts} +5 -5
- package/src/features/voice/playing/hooks/useVoiceTranscriptionController.ts +170 -0
- package/src/features/voice/playing/model/{VoiceTranscription.model.ts → Dropdown.model.ts} +1 -1
- package/src/features/voice/playing/model/PlaybackController.ts +176 -0
- package/src/features/voice/playing/model/{VoiceTranscriptionsCollection.ts → TranscriptionsCollection.ts} +1 -1
- package/src/features/voice/playing/model/TranscriptionsDownloader.model.ts +88 -0
- package/src/features/voice/playing/model/{VoiceTranscriptionTranslation.model.ts → Translation.model.ts} +4 -4
- package/src/features/voice/playing/model/VoiceFileDownloader.model.ts +2 -2
- package/src/features/voice/playing/model/VoicePlayer.model.ts +52 -200
- package/src/shared/components/PlayButton.tsx +2 -2
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscription.js.map +0 -1
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.js +0 -46
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.js.map +0 -1
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.js +0 -26
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.js.map +0 -1
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.js +0 -36
- package/dist/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.js.map +0 -1
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js +0 -88
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +0 -1
- package/dist/commonjs/features/voice/playing/model/VoiceTranscription.model.js.map +0 -1
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.js.map +0 -1
- package/dist/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +0 -1
- package/dist/module/features/voice/playing/hooks/useVoiceTranscription.js.map +0 -1
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.js +0 -41
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.js.map +0 -1
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.js +0 -21
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.js.map +0 -1
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.js +0 -31
- package/dist/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.js.map +0 -1
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js +0 -83
- package/dist/module/features/voice/playing/model/TranscriptionsDownloaderModel.js.map +0 -1
- package/dist/module/features/voice/playing/model/VoiceTranscription.model.js.map +0 -1
- package/dist/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.js.map +0 -1
- package/dist/module/features/voice/playing/model/VoiceTranscriptionsCollection.js.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscription.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.d.ts +0 -16
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.d.ts +0 -10
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts +0 -12
- package/dist/typescript/commonjs/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +0 -17
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscription.model.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscription.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.d.ts +0 -16
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.d.ts +0 -10
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts +0 -12
- package/dist/typescript/module/features/voice/playing/hooks/useVoiceTranscriptionEffects.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts +0 -17
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloaderModel.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscription.model.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionTranslation.model.d.ts.map +0 -1
- package/dist/typescript/module/features/voice/playing/model/VoiceTranscriptionsCollection.d.ts.map +0 -1
- package/src/features/voice/playing/hooks/useVoiceTranscriptionAutoExpand.ts +0 -57
- package/src/features/voice/playing/hooks/useVoiceTranscriptionAutoTranslate.ts +0 -32
- package/src/features/voice/playing/hooks/useVoiceTranscriptionEffects.ts +0 -43
- package/src/features/voice/playing/model/TranscriptionsDownloaderModel.ts +0 -94
|
@@ -5,26 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.VoiceTranscription = void 0;
|
|
7
7
|
var _reactNativeUi = require("@magmamath/react-native-ui");
|
|
8
|
-
var
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _reactI18next = require("react-i18next");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
9
|
var _reactNative = require("react-native");
|
|
12
10
|
var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
|
|
13
|
-
var _constants = require("../../constants.js");
|
|
14
|
-
var _helpers = require("../../helpers.js");
|
|
15
11
|
var _types = require("../../types.js");
|
|
16
|
-
var _supportedLanguages = require("../../../translation/providers/google/supportedLanguages.js");
|
|
17
12
|
var _i18n = require("../../../../i18n/i18n.js");
|
|
18
|
-
var
|
|
19
|
-
var _useVoiceTranscriptionAutoTranslate = require("../hooks/useVoiceTranscriptionAutoTranslate.js");
|
|
20
|
-
var _useVoiceTranscriptionAutoExpand = require("../hooks/useVoiceTranscriptionAutoExpand.js");
|
|
13
|
+
var _useVoiceTranscriptionController = require("../hooks/useVoiceTranscriptionController.js");
|
|
21
14
|
var _VoiceTranscriptContent = require("./VoiceTranscriptContent.js");
|
|
22
15
|
var _VoiceTranscriptionCollapsible = require("./VoiceTranscriptionCollapsible.js");
|
|
23
16
|
var _VoiceTranscriptionHeaderActions = require("./VoiceTranscriptionHeaderActions.js");
|
|
24
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
26
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
27
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
28
19
|
const VoiceTranscription = ({
|
|
29
20
|
style,
|
|
30
21
|
model,
|
|
@@ -36,59 +27,17 @@ const VoiceTranscription = ({
|
|
|
36
27
|
}) => {
|
|
37
28
|
const t = (0, _i18n.useText)();
|
|
38
29
|
const {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const isLargeVariant = variant === _types.VoiceTranscriptionVariant.LARGE;
|
|
44
|
-
const answersKey = (0, _react.useMemo)(() => answers.map(a => `${a._id}:${a.audioFileId ?? ''}`).join(','), [answers]);
|
|
45
|
-
(0, _useVoiceTranscriptionEffects.useVoiceTranscriptionEffects)({
|
|
30
|
+
display,
|
|
31
|
+
flags,
|
|
32
|
+
actions
|
|
33
|
+
} = (0, _useVoiceTranscriptionController.useVoiceTranscriptionController)({
|
|
46
34
|
model,
|
|
47
35
|
answers,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
activeAttempt
|
|
51
|
-
});
|
|
52
|
-
const isContentReady = loadedForAnswersKey === answersKey;
|
|
53
|
-
const hasActiveAudio = activeAttempt !== null && answers?.[activeAttempt - 1]?.audioFileId !== undefined;
|
|
54
|
-
const activeTranscript = isContentReady && activeAttempt !== null ? model.loader.getTranscript(activeAttempt) : null;
|
|
55
|
-
const hasTranscriptText = !!activeTranscript && activeTranscript !== _constants.NO_AUDIO_BE_MESSAGE;
|
|
56
|
-
const isActiveTranscriptLoading = isLoadingTranscripts && hasActiveAudio && !activeTranscript;
|
|
57
|
-
const transcriptLanguage = isContentReady && activeAttempt !== null ? model.loader.getTranscriptLanguage(activeAttempt) : undefined;
|
|
58
|
-
const isSourceSameAsTarget = !!transcriptLanguage && (0, _supportedLanguages.resolveGoogleLanguageCode)(transcriptLanguage) === (0, _supportedLanguages.resolveGoogleLanguageCode)(i18n.language);
|
|
59
|
-
const canTranslate = hasTranscriptText && !isSourceSameAsTarget;
|
|
60
|
-
const cachedTranslation = activeAttempt !== null ? translations[activeAttempt] : undefined;
|
|
61
|
-
const showTranslation = isTranslationActive && canTranslate;
|
|
62
|
-
const isTranslationLoading = showTranslation && !cachedTranslation && isTranslating;
|
|
63
|
-
const displayText = showTranslation ? cachedTranslation ?? activeTranscript : hasTranscriptText ? activeTranscript : t('voice.transcriptNotAvailable');
|
|
64
|
-
(0, _useVoiceTranscriptionAutoTranslate.useVoiceTranscriptionAutoTranslate)({
|
|
65
|
-
translationModel: model.translation,
|
|
66
|
-
canTranslate,
|
|
67
|
-
activeAttempt,
|
|
36
|
+
attemptOffset,
|
|
37
|
+
attemptsCount,
|
|
68
38
|
problemId
|
|
69
39
|
});
|
|
70
|
-
|
|
71
|
-
model,
|
|
72
|
-
activeAttempt,
|
|
73
|
-
targetLanguage: i18n.language
|
|
74
|
-
});
|
|
75
|
-
(0, _react.useEffect)(() => {
|
|
76
|
-
if (showTranslation && activeAttempt !== null && !cachedTranslation && !isTranslating) {
|
|
77
|
-
model.translation.translate({
|
|
78
|
-
attemptNumber: activeAttempt,
|
|
79
|
-
targetLanguage: i18n.language
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}, [showTranslation, activeAttempt, cachedTranslation, isTranslating, i18n.language, model]);
|
|
83
|
-
const handlePlayPress = (0, _react.useCallback)(() => {
|
|
84
|
-
if (activeAttempt) {
|
|
85
|
-
model.translation.setActive(false);
|
|
86
|
-
model.togglePlayPause(activeAttempt);
|
|
87
|
-
}
|
|
88
|
-
}, [model, activeAttempt]);
|
|
89
|
-
const handleTranslationToggle = (0, _react.useCallback)(() => {
|
|
90
|
-
model.translation.toggle();
|
|
91
|
-
}, [model]);
|
|
40
|
+
const isLargeVariant = variant === _types.VoiceTranscriptionVariant.LARGE;
|
|
92
41
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeReanimated.default.View, {
|
|
93
42
|
style: [styles.container, isLargeVariant && styles.largeContainer, style],
|
|
94
43
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
@@ -97,19 +46,19 @@ const VoiceTranscription = ({
|
|
|
97
46
|
style: styles.title,
|
|
98
47
|
variant: "h7",
|
|
99
48
|
children: t('voice.transcriptions')
|
|
100
|
-
}),
|
|
101
|
-
playerState: playerState,
|
|
102
|
-
isTranslationActive: isTranslationActive,
|
|
103
|
-
canTranslate: canTranslate,
|
|
104
|
-
onPlayPress:
|
|
105
|
-
onTranslationPress:
|
|
49
|
+
}), flags.anyAttemptHasAudio && /*#__PURE__*/(0, _jsxRuntime.jsx)(_VoiceTranscriptionHeaderActions.VoiceTranscriptionHeaderActions, {
|
|
50
|
+
playerState: flags.playerState,
|
|
51
|
+
isTranslationActive: flags.isTranslationActive,
|
|
52
|
+
canTranslate: flags.canTranslate,
|
|
53
|
+
onPlayPress: actions.onPlayPress,
|
|
54
|
+
onTranslationPress: actions.onTranslationToggle
|
|
106
55
|
})]
|
|
107
56
|
}), isLargeVariant ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_VoiceTranscriptContent.VoiceTranscriptContent, {
|
|
108
|
-
text:
|
|
109
|
-
isLoading:
|
|
57
|
+
text: display.text,
|
|
58
|
+
isLoading: display.isLoading
|
|
110
59
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_VoiceTranscriptionCollapsible.VoiceTranscriptionCollapsible, {
|
|
111
|
-
text:
|
|
112
|
-
isLoading:
|
|
60
|
+
text: display.text,
|
|
61
|
+
isLoading: display.isLoading,
|
|
113
62
|
dropdown: model.dropdown
|
|
114
63
|
})]
|
|
115
64
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeUi","require","
|
|
1
|
+
{"version":3,"names":["_reactNativeUi","require","_react","_interopRequireDefault","_reactNative","_reactNativeReanimated","_types","_i18n","_useVoiceTranscriptionController","_VoiceTranscriptContent","_VoiceTranscriptionCollapsible","_VoiceTranscriptionHeaderActions","_jsxRuntime","e","__esModule","default","VoiceTranscription","style","model","answers","attemptOffset","attemptsCount","problemId","variant","VoiceTranscriptionVariant","SMALL","t","useText","display","flags","actions","useVoiceTranscriptionController","isLargeVariant","LARGE","jsxs","View","styles","container","largeContainer","children","header","jsx","Typography","title","anyAttemptHasAudio","VoiceTranscriptionHeaderActions","playerState","isTranslationActive","canTranslate","onPlayPress","onTranslationPress","onTranslationToggle","VoiceTranscriptContent","text","isLoading","VoiceTranscriptionCollapsible","dropdown","exports","StyleSheet","create","position","top","left","width","maxHeight","minHeight","padding","boxShadow","borderRadius","backgroundColor","COLORS","NEUTRAL_1","overflow","height","flexDirection","justifyContent","alignItems","marginBottom","color","NEUTRAL_9","marginLeft"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/components/VoiceTranscription.tsx"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,MAAA,GAAAL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AM,EAAE;EACV,CAAC;EACDjC,MAAM,EAAE;IACNkC,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE,eAAe;IAC/BC,UAAU,EAAE,QAAQ;IACpBV,OAAO,EAAE,CAAC;IACVW,YAAY,EAAE,CAAC;IACfJ,MAAM,EAAE;EACV,CAAC;EACD9B,KAAK,EAAE;IACLmC,KAAK,EAAER,qBAAM,CAACS,SAAS;IACvBC,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -8,7 +8,7 @@ var _reactNativeUi = require("@magmamath/react-native-ui");
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _reactNative = require("react-native");
|
|
10
10
|
var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
|
|
11
|
-
var
|
|
11
|
+
var _useDropdownAnimation = require("../hooks/useDropdownAnimation.js");
|
|
12
12
|
var _VoiceTranscriptContent = require("./VoiceTranscriptContent.js");
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -24,7 +24,7 @@ const VoiceTranscriptionCollapsible = ({
|
|
|
24
24
|
listAnimatedStyle,
|
|
25
25
|
iconAnimatedStyle,
|
|
26
26
|
onListLayout
|
|
27
|
-
} = (0,
|
|
27
|
+
} = (0, _useDropdownAnimation.useDropdownAnimation)(dropdown);
|
|
28
28
|
const handleToggle = (0, _react.useCallback)(() => {
|
|
29
29
|
dropdown.toggleExpand();
|
|
30
30
|
}, [dropdown]);
|
package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionCollapsible.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeUi","require","_react","_interopRequireWildcard","_reactNative","_reactNativeReanimated","_interopRequireDefault","
|
|
1
|
+
{"version":3,"names":["_reactNativeUi","require","_react","_interopRequireWildcard","_reactNative","_reactNativeReanimated","_interopRequireDefault","_useDropdownAnimation","_VoiceTranscriptContent","_jsxRuntime","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","AnimatedTouchableOpacity","Animated","createAnimatedComponent","TouchableOpacity","VoiceTranscriptionCollapsible","text","isLoading","dropdown","listAnimatedStyle","iconAnimatedStyle","onListLayout","useDropdownAnimation","handleToggle","useCallback","toggleExpand","jsxs","Fragment","children","jsx","View","style","styles","collapsibleContent","onLayout","transcriptContainer","VoiceTranscriptContent","expandButton","onPress","CaretDownIcon","size","exports","StyleSheet","create","overflow","position","width","paddingHorizontal","justifyContent","alignItems"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/components/VoiceTranscriptionCollapsible.tsx"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AAEA,IAAAO,uBAAA,GAAAP,OAAA;AAAiE,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAK,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,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AAA,CAAAO,OAAQ,CAACqC,IAAI;MAACC,KAAK,EAAE,CAACZ,iBAAiB,EAAEa,MAAM,CAACC,kBAAkB,CAAE;MAAAL,QAAA,eACnE,IAAAtC,WAAA,CAAAuC,GAAA,EAAC5C,YAAA,CAAA6C,IAAI;QAACI,QAAQ,EAAEb,YAAa;QAACU,KAAK,EAAEC,MAAM,CAACG,mBAAoB;QAAAP,QAAA,eAC9D,IAAAtC,WAAA,CAAAuC,GAAA,EAACxC,uBAAA,CAAA+C,sBAAsB;UAACpB,IAAI,EAAEA,IAAK;UAACC,SAAS,EAAEA;QAAU,CAAE;MAAC,CACxD;IAAC,CACM,CAAC,eAChB,IAAA3B,WAAA,CAAAuC,GAAA,EAAClB,wBAAwB;MACvBoB,KAAK,EAAE,CAACC,MAAM,CAACK,YAAY,EAAEjB,iBAAiB,CAAE;MAChDkB,OAAO,EAAEf,YAAa;MAAAK,QAAA,eAEtB,IAAAtC,WAAA,CAAAuC,GAAA,EAAChD,cAAA,CAAA0D,aAAa;QAACC,IAAI,EAAE;MAAG,CAAE;IAAC,CACH,CAAC;EAAA,CAC3B,CAAC;AAEP,CAAC;AAAAC,OAAA,CAAA1B,6BAAA,GAAAA,6BAAA;AAED,MAAMiB,MAAM,GAAGU,uBAAU,CAACC,MAAM,CAAC;EAC/BV,kBAAkB,EAAE;IAClBW,QAAQ,EAAE;EACZ,CAAC;EACDT,mBAAmB,EAAE;IACnBU,QAAQ,EAAE,UAAU;IACpBC,KAAK,EAAE,MAAM;IACbC,iBAAiB,EAAE;EACrB,CAAC;EACDV,YAAY,EAAE;IACZW,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -7,14 +7,11 @@ exports.VoiceTranscriptionHeaderActions = void 0;
|
|
|
7
7
|
var _reactNativeUi = require("@magmamath/react-native-ui");
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactNative = require("react-native");
|
|
10
|
-
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
11
10
|
var _styleTypes = require("../../../chatbot/types/style.types.js");
|
|
12
11
|
var _PlayButton = require("../../../../shared/components/PlayButton.js");
|
|
13
12
|
var _index = require("../model/index.js");
|
|
14
13
|
var _helpers = require("../../helpers.js");
|
|
15
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
16
|
const VoiceTranscriptionHeaderActions = ({
|
|
20
17
|
playerState,
|
|
@@ -28,15 +25,13 @@ const VoiceTranscriptionHeaderActions = ({
|
|
|
28
25
|
isLoading: playerState === _index.PlayerState.LOADING,
|
|
29
26
|
status: (0, _helpers.getAudioStatus)(playerState)
|
|
30
27
|
};
|
|
31
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
32
|
-
entering: _reactNativeReanimated.FadeIn.duration(120),
|
|
33
|
-
exiting: _reactNativeReanimated.FadeOut.duration(120),
|
|
28
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
34
29
|
style: styles.container,
|
|
35
30
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PlayButton.PlayButton, {
|
|
36
31
|
state: playButtonState,
|
|
37
32
|
onPress: onPlayPress,
|
|
38
33
|
activityIndicatorColor: _reactNativeUi.COLORS.NEUTRAL_1
|
|
39
|
-
}), canTranslate && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeUi.
|
|
34
|
+
}), canTranslate && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeUi.Button, {
|
|
40
35
|
variant: "secondary",
|
|
41
36
|
size: "small",
|
|
42
37
|
colorScheme: _styleTypes.ColorScheme.Blue,
|
|
@@ -54,6 +49,9 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
54
49
|
flexDirection: 'row',
|
|
55
50
|
alignItems: 'center',
|
|
56
51
|
gap: _reactNativeUi.SPACING[200]
|
|
52
|
+
},
|
|
53
|
+
hidden: {
|
|
54
|
+
opacity: 0
|
|
57
55
|
}
|
|
58
56
|
});
|
|
59
57
|
//# sourceMappingURL=VoiceTranscriptionHeaderActions.js.map
|
package/dist/commonjs/features/voice/playing/components/VoiceTranscriptionHeaderActions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeUi","require","_react","_interopRequireDefault","_reactNative","
|
|
1
|
+
{"version":3,"names":["_reactNativeUi","require","_react","_interopRequireDefault","_reactNative","_styleTypes","_PlayButton","_index","_helpers","_jsxRuntime","e","__esModule","default","VoiceTranscriptionHeaderActions","playerState","isTranslationActive","canTranslate","onPlayPress","onTranslationPress","playButtonState","isActive","PlayerState","IDLE","isLoading","LOADING","status","getAudioStatus","jsxs","View","style","styles","container","children","jsx","PlayButton","state","onPress","activityIndicatorColor","COLORS","NEUTRAL_1","Button","variant","size","colorScheme","ColorScheme","Blue","icon","GlobeIcon","color","NEUTRAL_9","exports","StyleSheet","create","flexDirection","alignItems","gap","SPACING","hidden","opacity"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/components/VoiceTranscriptionHeaderActions.tsx"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OA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jC,cAAA,CAAA+C,SAAS;QAACC,KAAK,EAAEjC,mBAAmB,GAAGuB,qBAAM,CAACC,SAAS,GAAGD,qBAAM,CAACW;MAAU,CAAE;IAAE,CACvF,CACF;EAAA,CACG,CAAC;AAEX,CAAC;AAAAC,OAAA,CAAArC,+BAAA,GAAAA,+BAAA;AAED,MAAMiB,MAAM,GAAGqB,uBAAU,CAACC,MAAM,CAAC;EAC/BrB,SAAS,EAAE;IACTsB,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBC,GAAG,EAAEC,sBAAO,CAAC,GAAG;EAClB,CAAC;EACDC,MAAM,EAAE;IACNC,OAAO,EAAE;EACX;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -3,20 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.useDropdownAnimation = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _effectorReact = require("effector-react");
|
|
9
9
|
var _reactNativeReanimated = require("react-native-reanimated");
|
|
10
10
|
var _constants = require("../../constants.js");
|
|
11
|
-
const
|
|
11
|
+
const useDropdownAnimation = model => {
|
|
12
12
|
const isExpanded = (0, _effectorReact.useUnit)(model.$isExpanded);
|
|
13
13
|
const contentHeight = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
14
14
|
const animationProgress = (0, _reactNativeReanimated.useSharedValue)(isExpanded ? 1 : 0);
|
|
15
15
|
const onListLayout = event => {
|
|
16
16
|
const measuredHeight = event.nativeEvent.layout.height;
|
|
17
|
-
if (measuredHeight
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
if (measuredHeight <= 0) return;
|
|
18
|
+
contentHeight.value = contentHeight.value === 0 ? measuredHeight : (0, _reactNativeReanimated.withTiming)(measuredHeight, {
|
|
19
|
+
duration: 180
|
|
20
|
+
});
|
|
20
21
|
};
|
|
21
22
|
const listAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
22
23
|
const height = (0, _reactNativeReanimated.interpolate)(animationProgress.value, [0, 1], [0, contentHeight.value || _constants.DROPDOWN_MAX_CONTENT_HEIGHT]);
|
|
@@ -46,5 +47,5 @@ const useVoiceTranscriptionDropdown = model => {
|
|
|
46
47
|
onListLayout
|
|
47
48
|
};
|
|
48
49
|
};
|
|
49
|
-
exports.
|
|
50
|
-
//# sourceMappingURL=
|
|
50
|
+
exports.useDropdownAnimation = useDropdownAnimation;
|
|
51
|
+
//# sourceMappingURL=useDropdownAnimation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_effectorReact","_reactNativeReanimated","_constants","useDropdownAnimation","model","isExpanded","useUnit","$isExpanded","contentHeight","useSharedValue","animationProgress","onListLayout","event","measuredHeight","nativeEvent","layout","height","value","withTiming","duration","listAnimatedStyle","useAnimatedStyle","interpolate","DROPDOWN_MAX_CONTENT_HEIGHT","opacity","iconAnimatedStyle","rotation","transform","rotate","useEffect","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useDropdownAnimation.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AAGO,MAAMI,oBAAoB,GAAIC,KAAoB,IAAK;EAC5D,MAAMC,UAAU,GAAG,IAAAC,sBAAO,EAACF,KAAK,CAACG,WAAW,CAAC;EAE7C,MAAMC,aAAa,GAAG,IAAAC,qCAAc,EAAC,CAAC,CAAC;EACvC,MAAMC,iBAAiB,GAAG,IAAAD,qCAAc,EAACJ,UAAU,GAAG,CAAC,GAAG,CAAC,CAAC;EAE5D,MAAMM,YAAY,GAAIC,KAAwB,IAAK;IACjD,MAAMC,cAAc,GAAGD,KAAK,CAACE,WAAW,CAACC,MAAM,CAACC,MAAM;IACtD,IAAIH,cAA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K,iBAAiB,CAAC,CAAC;EAEnC,OAAO;IACLL,UAAU;IACVe,iBAAiB;IACjBK,iBAAiB;IACjBd;EACF,CAAC;AACH,CAAC;AAAAmB,OAAA,CAAA3B,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useVoiceTranscriptionController = void 0;
|
|
7
|
+
var _effectorReact = require("effector-react");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _reactI18next = require("react-i18next");
|
|
10
|
+
var _constants = require("../../constants.js");
|
|
11
|
+
var _helpers = require("../../helpers.js");
|
|
12
|
+
var _supportedLanguages = require("../../../translation/providers/google/supportedLanguages.js");
|
|
13
|
+
var _i18n = require("../../../../i18n/i18n.js");
|
|
14
|
+
const useVoiceTranscriptionController = ({
|
|
15
|
+
model,
|
|
16
|
+
answers,
|
|
17
|
+
attemptOffset,
|
|
18
|
+
attemptsCount,
|
|
19
|
+
problemId
|
|
20
|
+
}) => {
|
|
21
|
+
const t = (0, _i18n.useText)();
|
|
22
|
+
const {
|
|
23
|
+
i18n
|
|
24
|
+
} = (0, _reactI18next.useTranslation)();
|
|
25
|
+
const [playerState, isLoadingTranscripts, isTranslationActive, translations, isTranslating] = (0, _effectorReact.useUnit)([model.$playerState, model.loader.loadTranscriptForAttempt.pending, model.translation.$isActive, model.translation.$translations, model.translation.translate.pending]);
|
|
26
|
+
const activeAttempt = (0, _helpers.getActiveAttempt)(attemptOffset, attemptsCount);
|
|
27
|
+
const answersKey = (0, _react.useMemo)(() => answers.map(a => `${a._id}:${a.audioFileId ?? ''}`).join(','), [answers]);
|
|
28
|
+
const activeAudioFileId = activeAttempt !== null ? answers?.[activeAttempt - 1]?.audioFileId : undefined;
|
|
29
|
+
const hasActiveAudio = activeAudioFileId !== undefined;
|
|
30
|
+
const anyAttemptHasAudio = (0, _react.useMemo)(() => answers.some(a => !!a.audioFileId), [answers]);
|
|
31
|
+
const cachedEntry = activeAudioFileId ? model.loader.getCachedTranscript(activeAudioFileId) : undefined;
|
|
32
|
+
const activeTranscript = cachedEntry?.text ?? null;
|
|
33
|
+
const hasTranscriptText = !!activeTranscript && activeTranscript !== _constants.NO_AUDIO_BE_MESSAGE;
|
|
34
|
+
const isActiveTranscriptLoading = isLoadingTranscripts && hasActiveAudio && !activeTranscript;
|
|
35
|
+
const isSourceSameAsTarget = !!cachedEntry?.language && (0, _supportedLanguages.resolveGoogleLanguageCode)(cachedEntry.language) === (0, _supportedLanguages.resolveGoogleLanguageCode)(i18n.language);
|
|
36
|
+
const canTranslate = hasTranscriptText && !isSourceSameAsTarget;
|
|
37
|
+
const cachedTranslation = activeAttempt !== null ? translations[activeAttempt] : undefined;
|
|
38
|
+
const showTranslation = isTranslationActive && canTranslate;
|
|
39
|
+
const isTranslationLoading = showTranslation && !cachedTranslation && isTranslating;
|
|
40
|
+
const displayText = showTranslation ? cachedTranslation ?? activeTranscript : hasTranscriptText ? activeTranscript : t('voice.transcriptNotAvailable');
|
|
41
|
+
|
|
42
|
+
// Lifecycle effects
|
|
43
|
+
const answersRef = (0, _react.useRef)(answers);
|
|
44
|
+
answersRef.current = answers;
|
|
45
|
+
(0, _react.useEffect)(() => {
|
|
46
|
+
model.reinitializePlayer();
|
|
47
|
+
return () => {
|
|
48
|
+
model.stopAudio();
|
|
49
|
+
model.dropdown.setExpanded(false);
|
|
50
|
+
};
|
|
51
|
+
}, [model]);
|
|
52
|
+
(0, _react.useEffect)(() => {
|
|
53
|
+
model.dropdown.setExpanded(false);
|
|
54
|
+
model.resetPlayer();
|
|
55
|
+
}, [problemId]);
|
|
56
|
+
(0, _react.useEffect)(() => {
|
|
57
|
+
if (answersRef.current.some(a => a.audioFileId)) {
|
|
58
|
+
model.initializeWithAudios(answersRef.current);
|
|
59
|
+
}
|
|
60
|
+
}, [model, answersKey]);
|
|
61
|
+
(0, _react.useEffect)(() => {
|
|
62
|
+
model.stopAudio();
|
|
63
|
+
if (activeAttempt !== null) {
|
|
64
|
+
model.loader.loadTranscriptForAttempt(activeAttempt);
|
|
65
|
+
}
|
|
66
|
+
}, [model, activeAttempt, answersKey]);
|
|
67
|
+
|
|
68
|
+
// Auto-activate translation once per (problemId, activeAttempt) when translatable
|
|
69
|
+
const autoActivatedAttempts = (0, _react.useRef)(new Set());
|
|
70
|
+
(0, _react.useEffect)(() => {
|
|
71
|
+
autoActivatedAttempts.current.clear();
|
|
72
|
+
}, [problemId]);
|
|
73
|
+
(0, _react.useEffect)(() => {
|
|
74
|
+
if (canTranslate && activeAttempt !== null && !autoActivatedAttempts.current.has(activeAttempt)) {
|
|
75
|
+
autoActivatedAttempts.current.add(activeAttempt);
|
|
76
|
+
model.translation.setActive(true);
|
|
77
|
+
}
|
|
78
|
+
}, [canTranslate, activeAttempt, model]);
|
|
79
|
+
|
|
80
|
+
// Trigger translate when we should show translation but don't have it cached
|
|
81
|
+
(0, _react.useEffect)(() => {
|
|
82
|
+
if (showTranslation && activeAttempt !== null && !cachedTranslation && !isTranslating) {
|
|
83
|
+
model.translation.translate({
|
|
84
|
+
attemptNumber: activeAttempt,
|
|
85
|
+
targetLanguage: i18n.language
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}, [showTranslation, activeAttempt, cachedTranslation, isTranslating, i18n.language, model]);
|
|
89
|
+
|
|
90
|
+
// Auto-open dropdown when a translation successfully completes
|
|
91
|
+
(0, _react.useEffect)(() => {
|
|
92
|
+
return model.translation.translate.doneData.watch(result => {
|
|
93
|
+
if (result) {
|
|
94
|
+
model.dropdown.setExpanded(true);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}, [model]);
|
|
98
|
+
const onPlayPress = (0, _react.useCallback)(() => {
|
|
99
|
+
if (activeAttempt) {
|
|
100
|
+
model.translation.setActive(false);
|
|
101
|
+
model.togglePlayPause(activeAttempt);
|
|
102
|
+
}
|
|
103
|
+
}, [model, activeAttempt]);
|
|
104
|
+
const onTranslationToggle = (0, _react.useCallback)(() => {
|
|
105
|
+
model.translation.toggle();
|
|
106
|
+
model.dropdown.setExpanded(true);
|
|
107
|
+
}, [model]);
|
|
108
|
+
return {
|
|
109
|
+
display: {
|
|
110
|
+
text: displayText,
|
|
111
|
+
isLoading: isActiveTranscriptLoading || isTranslationLoading
|
|
112
|
+
},
|
|
113
|
+
flags: {
|
|
114
|
+
playerState: playerState,
|
|
115
|
+
hasActiveAudio,
|
|
116
|
+
anyAttemptHasAudio,
|
|
117
|
+
canTranslate,
|
|
118
|
+
isTranslationActive
|
|
119
|
+
},
|
|
120
|
+
actions: {
|
|
121
|
+
onPlayPress,
|
|
122
|
+
onTranslationToggle
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
exports.useVoiceTranscriptionController = useVoiceTranscriptionController;
|
|
127
|
+
//# sourceMappingURL=useVoiceTranscriptionController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_effectorReact","require","_react","_reactI18next","_constants","_helpers","_supportedLanguages","_i18n","useVoiceTranscriptionController","model","answers","attemptOffset","attemptsCount","problemId","t","useText","i18n","useTranslation","playerState","isLoadingTranscripts","isTranslationActive","translations","isTranslating","useUnit","$playerState","loader","loadTranscriptForAttempt","pending","translation","$isActive","$translations","translate","activeAttempt","getActiveAttempt","answersKey","useMemo","map","a","_id","audioFileId","join","activeAudioFileId","undefined","hasActiveAudio","anyAttemptHasAudio","some","cachedEntry","getCachedTranscript","activeTranscript","text","hasTranscriptText","NO_AUDIO_BE_MESSAGE","isActiveTranscriptLoading","isSourceSameAsTarget","language","resolveGoogleLanguageCode","canTranslate","cachedTranslation","showTranslation","isTranslationLoading","displayText","answersRef","useRef","current","useEffect","reinitializePlayer","stopAudio","dropdown","setExpanded","resetPlayer","initializeWithAudios","autoActivatedAttempts","Set","clear","has","add","setActive","attemptNumber","targetLanguage","doneData","watch","result","onPlayPress","useCallback","togglePlayPause","onTranslationToggle","toggle","display","isLoading","flags","actions","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/hooks/useVoiceTranscriptionController.ts"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAEA,IAAAK,mBAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAcO,MAAMO,+BAA+B,GAAGA,CAAC;EAC9CC,KAAK;EACLC,OAAO;EACPC,aAAa;EACbC,aAAa;EACbC;AACM,CAAC,KAAK;EACZ,MAAMC,CAAC,GAAG,IAAAC,aAAO,EAAC,CAAC;EACnB,MAAM;IAAEC;EAAK,CAAC,GAAG,IAAAC,4BAAc,EAAC,CAAC;EAEjC,MAAM,CAACC,WAAW,EAAEC,oBAAoB,EAAEC,mBAAmB,EAAEC,YAAY,EAAEC,aAAa,CAAC,GACzF,IAAAC,sBAAO,EAAC,CACNd,KAAK,CAACe,YAAY,EAClBf,KAAK,CAACgB,MAAM,CAACC,wBAAwB,CAACC,OAAO,EAC7ClB,KAAK,CAACmB,WAAW,CAACC,SAAS,EAC3BpB,KAAK,CAACmB,WAAW,CAACE,aAAa,EAC/BrB,KAAK,CAACmB,WAAW,CAACG,SAAS,CAACJ,OAAO,CACpC,CAAC;EAEJ,MAAMK,aAAa,GAAG,IAAAC,yBAAgB,EAACtB,aAAa,EAAEC,aAAa,CAAC;EAEpE,MAAMsB,UAAU,GAAG,IAAAC,cAAO,EACxB,MAAMzB,OAAO,CAAC0B,GAAG,CAAEC,CAAC,IAAK,GAAGA,CAAC,CAACC,GAAG,IAAID,CAAC,CAACE,WAAW,IAAI,EAAE,EAAE,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC,EACrE,CAAC9B,OAAO,CACV,CAAC;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C,EAAE,CAACvB,KAAK,EAAEuB,aAAa,CAAC,CAAC;EAE1B,MAAMqD,mBAAmB,GAAG,IAAAF,kBAAW,EAAC,MAAM;IAC5C1E,KAAK,CAACmB,WAAW,CAAC0D,MAAM,CAAC,CAAC;IAC1B7E,KAAK,CAAC0D,QAAQ,CAACC,WAAW,CAAC,IAAI,CAAC;EAClC,CAAC,EAAE,CAAC3D,KAAK,CAAC,CAAC;EAEX,OAAO;IACL8E,OAAO,EAAE;MACPtC,IAAI,EAAEW,WAAW;MACjB4B,SAAS,EAAEpC,yBAAyB,IAAIO;IAC1C,CAAC;IACD8B,KAAK,EAAE;MACLvE,WAAW,EAAEA,WAA0B;MACvCyB,cAAc;MACdC,kBAAkB;MAClBY,YAAY;MACZpC;IACF,CAAC;IACDsE,OAAO,EAAE;MACPR,WAAW;MACXG;IACF;EACF,CAAC;AACH,CAAC;AAAAM,OAAA,CAAAnF,+BAAA,GAAAA,+BAAA","ignoreList":[]}
|
package/dist/commonjs/features/voice/playing/model/{VoiceTranscription.model.js → Dropdown.model.js}
RENAMED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.DropdownModel = void 0;
|
|
7
7
|
var _effector = require("effector");
|
|
8
|
-
class
|
|
8
|
+
class DropdownModel {
|
|
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.DropdownModel = DropdownModel;
|
|
15
|
+
//# sourceMappingURL=Dropdown.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_effector","require","DropdownModel","toggleExpand","createEvent","setExpanded","reset","$isExpanded","restore","on","state","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/Dropdown.model.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,aAAa,CAAC;EACTC,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,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PlaybackController = void 0;
|
|
7
|
+
var _effector = require("effector");
|
|
8
|
+
var _PlayerModel = require("./Player.model.js");
|
|
9
|
+
class PlaybackController {
|
|
10
|
+
currentPlayingAttempt = null;
|
|
11
|
+
shouldPreventPlayback = false;
|
|
12
|
+
constructor(deps) {
|
|
13
|
+
this.collection = deps.collection;
|
|
14
|
+
this.player = deps.player;
|
|
15
|
+
this.downloader = deps.downloader;
|
|
16
|
+
this.onCurrentAttemptChange = deps.onCurrentAttemptChange;
|
|
17
|
+
this.player.playbackFinished.watch(() => this.clearCurrentAttempt());
|
|
18
|
+
}
|
|
19
|
+
togglePlayPause = attemptNumber => {
|
|
20
|
+
const playerState = this.player.$playerState.getState();
|
|
21
|
+
if (this.currentPlayingAttempt === attemptNumber && playerState === _PlayerModel.PlayerState.PLAYING) {
|
|
22
|
+
this.player.pause();
|
|
23
|
+
} else {
|
|
24
|
+
this.handlePlayAttempt(attemptNumber);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
halt() {
|
|
28
|
+
this.shouldPreventPlayback = true;
|
|
29
|
+
this.abortAllDownloads();
|
|
30
|
+
this.player.stop();
|
|
31
|
+
this.clearCurrentAttempt();
|
|
32
|
+
}
|
|
33
|
+
releaseResources() {
|
|
34
|
+
this.collection.getAll().forEach(item => {
|
|
35
|
+
if (item.controller) {
|
|
36
|
+
this.downloader.abortDownload(item.controller);
|
|
37
|
+
}
|
|
38
|
+
if (item.audioUri?.startsWith('blob:')) {
|
|
39
|
+
try {
|
|
40
|
+
URL.revokeObjectURL(item.audioUri);
|
|
41
|
+
} catch (e) {}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
clearCurrentAttempt() {
|
|
46
|
+
this.currentPlayingAttempt = null;
|
|
47
|
+
this.onCurrentAttemptChange(null);
|
|
48
|
+
}
|
|
49
|
+
abortAllDownloads() {
|
|
50
|
+
this.collection.getAll().forEach(item => {
|
|
51
|
+
if (item.controller && item.audioLoading) {
|
|
52
|
+
this.downloader.abortDownload(item.controller);
|
|
53
|
+
this.collection.update(item.attemptNumber, {
|
|
54
|
+
audioLoading: false,
|
|
55
|
+
controller: undefined,
|
|
56
|
+
audioDownloadPromise: undefined
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
handlePlayAttempt = (0, _effector.createEffect)(async attemptNumber => {
|
|
62
|
+
this.shouldPreventPlayback = false;
|
|
63
|
+
const item = this.collection.get(attemptNumber);
|
|
64
|
+
if (!item) return;
|
|
65
|
+
if (this.currentPlayingAttempt !== null && this.currentPlayingAttempt !== attemptNumber) {
|
|
66
|
+
this.abortAllDownloads();
|
|
67
|
+
}
|
|
68
|
+
if (this.collection.hasAudio(attemptNumber)) {
|
|
69
|
+
this.playAudioFx(attemptNumber);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
this.player.setPlayerState(_PlayerModel.PlayerState.LOADING);
|
|
74
|
+
const {
|
|
75
|
+
collectionItem,
|
|
76
|
+
downloadPromise
|
|
77
|
+
} = await this.downloader.download({
|
|
78
|
+
audioFileId: item.audioFileId,
|
|
79
|
+
attemptNumber
|
|
80
|
+
});
|
|
81
|
+
if (this.shouldPreventPlayback) {
|
|
82
|
+
collectionItem.controller?.abort();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.collection.update(attemptNumber, collectionItem);
|
|
86
|
+
const result = await downloadPromise;
|
|
87
|
+
if (this.shouldPreventPlayback) {
|
|
88
|
+
if (result.uri?.startsWith('blob:')) {
|
|
89
|
+
URL.revokeObjectURL(result.uri);
|
|
90
|
+
}
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this.collection.update(attemptNumber, {
|
|
94
|
+
audioUri: result.uri,
|
|
95
|
+
audioLoading: false,
|
|
96
|
+
audioError: undefined,
|
|
97
|
+
controller: undefined,
|
|
98
|
+
audioDownloadPromise: undefined
|
|
99
|
+
});
|
|
100
|
+
this.player.setPlayerState(_PlayerModel.PlayerState.IDLE);
|
|
101
|
+
this.playAudioFx(attemptNumber);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error('Audio download error:', error);
|
|
104
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
105
|
+
this.player.setPlayerState(_PlayerModel.PlayerState.IDLE);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
this.collection.update(attemptNumber, {
|
|
109
|
+
audioLoading: false,
|
|
110
|
+
audioError: error instanceof Error ? error.message : 'Failed to download audio',
|
|
111
|
+
controller: undefined,
|
|
112
|
+
audioDownloadPromise: undefined
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
playAudioFx = (0, _effector.createEffect)(async attemptNumber => {
|
|
117
|
+
if (this.shouldPreventPlayback) return;
|
|
118
|
+
const item = this.collection.get(attemptNumber);
|
|
119
|
+
if (!item?.audioUri) {
|
|
120
|
+
console.warn('No audio URI available for attempt:', attemptNumber);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
if (this.currentPlayingAttempt !== null && this.currentPlayingAttempt !== attemptNumber) {
|
|
125
|
+
this.player.player?.remove();
|
|
126
|
+
}
|
|
127
|
+
if (this.currentPlayingAttempt === attemptNumber && this.player.player?.playing) {
|
|
128
|
+
this.player.pause();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (this.currentPlayingAttempt === attemptNumber && !this.player.player?.playing) {
|
|
132
|
+
this.player.resume();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this.currentPlayingAttempt = attemptNumber;
|
|
136
|
+
this.onCurrentAttemptChange(attemptNumber);
|
|
137
|
+
await this.player.play(item.audioUri);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
console.error('Error playing audio:', error);
|
|
140
|
+
this.player.setPlayerState(_PlayerModel.PlayerState.IDLE);
|
|
141
|
+
this.collection.update(attemptNumber, {
|
|
142
|
+
audioError: error instanceof Error ? error.message : 'Failed to play audio'
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
exports.PlaybackController = PlaybackController;
|
|
148
|
+
//# sourceMappingURL=PlaybackController.js.map
|