@magmamath/students-features 1.7.9 → 1.7.10-rc.2
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/constants.js +42 -3
- package/dist/commonjs/features/voice/constants.js.map +1 -1
- package/dist/commonjs/features/voice/helpers.js +67 -1
- package/dist/commonjs/features/voice/helpers.js.map +1 -1
- package/dist/commonjs/features/voice/index.js +77 -0
- package/dist/commonjs/features/voice/index.js.map +1 -1
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js +22 -9
- package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -1
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js +4 -27
- package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -1
- package/dist/commonjs/features/voice/recording/components/VoiceRecordWithTranscript.js +49 -0
- package/dist/commonjs/features/voice/recording/components/VoiceRecordWithTranscript.js.map +1 -0
- package/dist/commonjs/features/voice/recording/components/VoiceTranscriptPanel.js +253 -0
- package/dist/commonjs/features/voice/recording/components/VoiceTranscriptPanel.js.map +1 -0
- package/dist/commonjs/features/voice/recording/components/VoiceWaveform.js +93 -0
- package/dist/commonjs/features/voice/recording/components/VoiceWaveform.js.map +1 -0
- package/dist/commonjs/features/voice/recording/hooks/useTranscriptPanelAnimation.js +42 -0
- package/dist/commonjs/features/voice/recording/hooks/useTranscriptPanelAnimation.js.map +1 -0
- package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorder.js +17 -2
- package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorder.js.map +1 -1
- package/dist/commonjs/features/voice/recording/hooks/useVoiceWaveform.js +43 -0
- package/dist/commonjs/features/voice/recording/hooks/useVoiceWaveform.js.map +1 -0
- package/dist/commonjs/features/voice/recording/model/Recorder.model.js +3 -0
- package/dist/commonjs/features/voice/recording/model/Recorder.model.js.map +1 -1
- package/dist/commonjs/features/voice/recording/model/VoiceRecordWithTranscript.model.js +100 -0
- package/dist/commonjs/features/voice/recording/model/VoiceRecordWithTranscript.model.js.map +1 -0
- package/dist/commonjs/features/voice/recording/model/VoiceTranscriptPanel.model.js +115 -0
- package/dist/commonjs/features/voice/recording/model/VoiceTranscriptPanel.model.js.map +1 -0
- package/dist/commonjs/features/voice/transcript.helpers.js +36 -0
- package/dist/commonjs/features/voice/transcript.helpers.js.map +1 -0
- package/dist/commonjs/features/voice/types.js +11 -7
- package/dist/commonjs/features/voice/types.js.map +1 -1
- package/dist/module/features/voice/constants.js +41 -0
- package/dist/module/features/voice/constants.js.map +1 -1
- package/dist/module/features/voice/helpers.js +65 -1
- package/dist/module/features/voice/helpers.js.map +1 -1
- package/dist/module/features/voice/index.js +7 -0
- package/dist/module/features/voice/index.js.map +1 -1
- package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js +20 -9
- package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -1
- package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js +4 -27
- package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -1
- package/dist/module/features/voice/recording/components/VoiceRecordWithTranscript.js +43 -0
- package/dist/module/features/voice/recording/components/VoiceRecordWithTranscript.js.map +1 -0
- package/dist/module/features/voice/recording/components/VoiceTranscriptPanel.js +246 -0
- package/dist/module/features/voice/recording/components/VoiceTranscriptPanel.js.map +1 -0
- package/dist/module/features/voice/recording/components/VoiceWaveform.js +86 -0
- package/dist/module/features/voice/recording/components/VoiceWaveform.js.map +1 -0
- package/dist/module/features/voice/recording/hooks/useTranscriptPanelAnimation.js +37 -0
- package/dist/module/features/voice/recording/hooks/useTranscriptPanelAnimation.js.map +1 -0
- package/dist/module/features/voice/recording/hooks/useVoiceRecorder.js +20 -3
- package/dist/module/features/voice/recording/hooks/useVoiceRecorder.js.map +1 -1
- package/dist/module/features/voice/recording/hooks/useVoiceWaveform.js +38 -0
- package/dist/module/features/voice/recording/hooks/useVoiceWaveform.js.map +1 -0
- package/dist/module/features/voice/recording/model/Recorder.model.js +3 -0
- package/dist/module/features/voice/recording/model/Recorder.model.js.map +1 -1
- package/dist/module/features/voice/recording/model/VoiceRecordWithTranscript.model.js +95 -0
- package/dist/module/features/voice/recording/model/VoiceRecordWithTranscript.model.js.map +1 -0
- package/dist/module/features/voice/recording/model/VoiceTranscriptPanel.model.js +110 -0
- package/dist/module/features/voice/recording/model/VoiceTranscriptPanel.model.js.map +1 -0
- package/dist/module/features/voice/transcript.helpers.js +31 -0
- package/dist/module/features/voice/transcript.helpers.js.map +1 -0
- package/dist/module/features/voice/types.js +4 -6
- package/dist/module/features/voice/types.js.map +1 -1
- package/dist/typescript/commonjs/features/voice/__tests__/VoiceRecordWithTranscript.model.test.d.ts +2 -0
- package/dist/typescript/commonjs/features/voice/__tests__/VoiceRecordWithTranscript.model.test.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/__tests__/VoiceTranscriptPanel.model.test.d.ts +2 -0
- package/dist/typescript/commonjs/features/voice/__tests__/VoiceTranscriptPanel.model.test.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/constants.d.ts +34 -0
- package/dist/typescript/commonjs/features/voice/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/helpers.d.ts +3 -0
- package/dist/typescript/commonjs/features/voice/helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/index.d.ts +7 -0
- package/dist/typescript/commonjs/features/voice/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts +3 -1
- package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +2 -7
- package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordWithTranscript.d.ts +13 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordWithTranscript.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceTranscriptPanel.d.ts +11 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceTranscriptPanel.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceWaveform.d.ts +8 -0
- package/dist/typescript/commonjs/features/voice/recording/components/VoiceWaveform.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/hooks/useTranscriptPanelAnimation.d.ts +18 -0
- package/dist/typescript/commonjs/features/voice/recording/hooks/useTranscriptPanelAnimation.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorder.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceWaveform.d.ts +7 -0
- package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceWaveform.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/model/Recorder.model.d.ts +2 -0
- package/dist/typescript/commonjs/features/voice/recording/model/Recorder.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecordWithTranscript.model.d.ts +16 -0
- package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecordWithTranscript.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/recording/model/VoiceTranscriptPanel.model.d.ts +31 -0
- package/dist/typescript/commonjs/features/voice/recording/model/VoiceTranscriptPanel.model.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/transcript.helpers.d.ts +8 -0
- package/dist/typescript/commonjs/features/voice/transcript.helpers.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/voice/types.d.ts +2 -5
- package/dist/typescript/commonjs/features/voice/types.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/__tests__/VoiceRecordWithTranscript.model.test.d.ts +2 -0
- package/dist/typescript/module/features/voice/__tests__/VoiceRecordWithTranscript.model.test.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/__tests__/VoiceTranscriptPanel.model.test.d.ts +2 -0
- package/dist/typescript/module/features/voice/__tests__/VoiceTranscriptPanel.model.test.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/constants.d.ts +34 -0
- package/dist/typescript/module/features/voice/constants.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/helpers.d.ts +3 -0
- package/dist/typescript/module/features/voice/helpers.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/index.d.ts +7 -0
- package/dist/typescript/module/features/voice/index.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts +3 -1
- package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +2 -7
- package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/recording/components/VoiceRecordWithTranscript.d.ts +13 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceRecordWithTranscript.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceTranscriptPanel.d.ts +11 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceTranscriptPanel.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceWaveform.d.ts +8 -0
- package/dist/typescript/module/features/voice/recording/components/VoiceWaveform.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/hooks/useTranscriptPanelAnimation.d.ts +18 -0
- package/dist/typescript/module/features/voice/recording/hooks/useTranscriptPanelAnimation.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorder.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/recording/hooks/useVoiceWaveform.d.ts +7 -0
- package/dist/typescript/module/features/voice/recording/hooks/useVoiceWaveform.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/model/Recorder.model.d.ts +2 -0
- package/dist/typescript/module/features/voice/recording/model/Recorder.model.d.ts.map +1 -1
- package/dist/typescript/module/features/voice/recording/model/VoiceRecordWithTranscript.model.d.ts +16 -0
- package/dist/typescript/module/features/voice/recording/model/VoiceRecordWithTranscript.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/recording/model/VoiceTranscriptPanel.model.d.ts +31 -0
- package/dist/typescript/module/features/voice/recording/model/VoiceTranscriptPanel.model.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/transcript.helpers.d.ts +8 -0
- package/dist/typescript/module/features/voice/transcript.helpers.d.ts.map +1 -0
- package/dist/typescript/module/features/voice/types.d.ts +2 -5
- package/dist/typescript/module/features/voice/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/features/voice/__tests__/VoiceRecordWithTranscript.model.test.ts +228 -0
- package/src/features/voice/__tests__/VoiceTranscriptPanel.model.test.ts +237 -0
- package/src/features/voice/constants.ts +43 -0
- package/src/features/voice/helpers.ts +85 -1
- package/src/features/voice/index.ts +7 -0
- package/src/features/voice/playing/components/VoiceTranscriptContent.tsx +27 -8
- package/src/features/voice/playing/model/TranscriptionsDownloader.model.ts +8 -30
- package/src/features/voice/recording/components/VoiceRecordWithTranscript.tsx +52 -0
- package/src/features/voice/recording/components/VoiceTranscriptPanel.tsx +293 -0
- package/src/features/voice/recording/components/VoiceWaveform.tsx +102 -0
- package/src/features/voice/recording/hooks/useTranscriptPanelAnimation.ts +49 -0
- package/src/features/voice/recording/hooks/useVoiceRecorder.ts +26 -3
- package/src/features/voice/recording/hooks/useVoiceWaveform.ts +46 -0
- package/src/features/voice/recording/model/Recorder.model.ts +3 -0
- package/src/features/voice/recording/model/VoiceRecordWithTranscript.model.ts +104 -0
- package/src/features/voice/recording/model/VoiceTranscriptPanel.model.ts +131 -0
- package/src/features/voice/transcript.helpers.ts +37 -0
- package/src/features/voice/types.ts +5 -6
- package/src/i18n/.generated/schema.json +6 -5
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { createEffect } from 'effector';
|
|
4
|
-
import {
|
|
5
|
-
import { NO_AUDIO_BE_MESSAGE, TRANSCRIPT_MAX_RETRIES, TRANSCRIPT_RETRY_INTERVAL_MS } from "../../constants.js";
|
|
4
|
+
import { fetchTranscriptWithRetry } from "../../transcript.helpers.js";
|
|
6
5
|
export class TranscriptionsDownloaderModel {
|
|
7
6
|
inflightFetches = new Map();
|
|
8
7
|
transcriptCache = new Map();
|
|
@@ -10,12 +9,12 @@ export class TranscriptionsDownloaderModel {
|
|
|
10
9
|
this.collection = collection;
|
|
11
10
|
this.api = api;
|
|
12
11
|
}
|
|
13
|
-
async
|
|
12
|
+
async fetchTranscript(audioFileId) {
|
|
14
13
|
const cached = this.transcriptCache.get(audioFileId);
|
|
15
14
|
if (cached) return cached;
|
|
16
15
|
const existing = this.inflightFetches.get(audioFileId);
|
|
17
16
|
if (existing) return existing;
|
|
18
|
-
const promise = this.
|
|
17
|
+
const promise = fetchTranscriptWithRetry(id => this.api.getAudioFileTranscript(id), audioFileId).then(result => {
|
|
19
18
|
this.transcriptCache.set(audioFileId, result);
|
|
20
19
|
return result;
|
|
21
20
|
}).finally(() => {
|
|
@@ -24,28 +23,6 @@ export class TranscriptionsDownloaderModel {
|
|
|
24
23
|
this.inflightFetches.set(audioFileId, promise);
|
|
25
24
|
return promise;
|
|
26
25
|
}
|
|
27
|
-
async runFetchWithRetry(audioFileId) {
|
|
28
|
-
for (let attempt = 0; attempt < TRANSCRIPT_MAX_RETRIES; attempt++) {
|
|
29
|
-
const response = await this.api.getAudioFileTranscript(audioFileId);
|
|
30
|
-
if (response.status === TranscriptionStatus.COMPLETED) {
|
|
31
|
-
return {
|
|
32
|
-
text: response.text,
|
|
33
|
-
language: response.language
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
if (response.status === TranscriptionStatus.FAILED) {
|
|
37
|
-
return {
|
|
38
|
-
text: NO_AUDIO_BE_MESSAGE
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
if (attempt < TRANSCRIPT_MAX_RETRIES - 1) {
|
|
42
|
-
await new Promise(resolve => setTimeout(resolve, TRANSCRIPT_RETRY_INTERVAL_MS));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
text: NO_AUDIO_BE_MESSAGE
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
26
|
loadTranscriptForAttempt = createEffect(async attemptNumber => {
|
|
50
27
|
const item = this.collection.get(attemptNumber);
|
|
51
28
|
if (!item?.audioFileId) return;
|
|
@@ -57,7 +34,7 @@ export class TranscriptionsDownloaderModel {
|
|
|
57
34
|
const {
|
|
58
35
|
text,
|
|
59
36
|
language
|
|
60
|
-
} = await this.
|
|
37
|
+
} = await this.fetchTranscript(item.audioFileId);
|
|
61
38
|
this.collection.update(attemptNumber, {
|
|
62
39
|
transcript: text,
|
|
63
40
|
transcriptLanguage: language,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createEffect","
|
|
1
|
+
{"version":3,"names":["createEffect","fetchTranscriptWithRetry","TranscriptionsDownloaderModel","inflightFetches","Map","transcriptCache","constructor","collection","api","fetchTranscript","audioFileId","cached","get","existing","promise","id","getAudioFileTranscript","then","result","set","finally","delete","loadTranscriptForAttempt","attemptNumber","item","transcript","transcriptLoading","update","text","language","transcriptLanguage","transcriptError","undefined","error","Error","message","getCachedTranscript"],"sourceRoot":"../../../../../../src","sources":["features/voice/playing/model/TranscriptionsDownloader.model.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,UAAU;AAGvC,SAASC,wBAAwB,QAA0B,6BAA0B;AAErF,OAAO,MAAMC,6BAA6B,CAAC;EAGxBC,eAAe,GAAG,IAAIC,GAAG,CAAoC,CAAC;EAC9DC,eAAe,GAAG,IAAID,GAAG,CAA2B,CAAC;EAEtEE,WAAWA,CAACC,UAAoC,EAAEC,GAAmB,EAAE;IACrE,IAAI,CAACD,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,GAAG,GAA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,MAAM,CAACJ,aAAa,EAAE;QACpCE,UAAU,EAAEG,IAAI;QAChBE,kBAAkB,EAAED,QAAQ;QAC5BH,iBAAiB,EAAE,KAAK;QACxBK,eAAe,EAAEC;MACnB,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOC,KAAK,EAAE;MACd,IAAI,CAAC1B,UAAU,CAACoB,MAAM,CAACJ,aAAa,EAAE;QACpCG,iBAAiB,EAAE,KAAK;QACxBK,eAAe,EAAEE,KAAK,YAAYC,KAAK,GAAGD,KAAK,CAACE,OAAO,GAAG;MAC5D,CAAC,CAAC;IACJ;EACF,CAAC,CAAC;EAEKC,mBAAmBA,CAAC1B,WAAmB,EAAgC;IAC5E,OAAO,IAAI,CAACL,eAAe,CAACO,GAAG,CAACF,WAAW,CAAC;EAC9C;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { StyleSheet, View } from 'react-native';
|
|
5
|
+
import { SPACING } from '@magmamath/react-native-ui';
|
|
6
|
+
import { useUnit } from 'effector-react';
|
|
7
|
+
import { VoiceRecord } from "./VoiceRecord.js";
|
|
8
|
+
import { VoiceTranscriptPanel } from "./VoiceTranscriptPanel.js";
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
// Drop-in replacement for VoiceRecord that opens the waveform/transcript panel
|
|
11
|
+
// to the right of the record control (per the "Voice on Drawboard" design).
|
|
12
|
+
export const VoiceRecordWithTranscript = ({
|
|
13
|
+
model,
|
|
14
|
+
buttonVariant,
|
|
15
|
+
style,
|
|
16
|
+
panelStyle
|
|
17
|
+
}) => {
|
|
18
|
+
const metering = useUnit(model.record.recorderModel.$metering);
|
|
19
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
20
|
+
style: [styles.container, style],
|
|
21
|
+
children: [/*#__PURE__*/_jsx(VoiceRecord, {
|
|
22
|
+
model: model.record,
|
|
23
|
+
buttonVariant: buttonVariant
|
|
24
|
+
}), /*#__PURE__*/_jsx(VoiceTranscriptPanel, {
|
|
25
|
+
model: model.panel,
|
|
26
|
+
metering: metering,
|
|
27
|
+
style: [styles.panel, panelStyle]
|
|
28
|
+
})]
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const styles = StyleSheet.create({
|
|
32
|
+
// Hug the record control so the panel's `left: 100%` lands right next to it
|
|
33
|
+
container: {
|
|
34
|
+
alignSelf: 'flex-start'
|
|
35
|
+
},
|
|
36
|
+
panel: {
|
|
37
|
+
position: 'absolute',
|
|
38
|
+
left: '100%',
|
|
39
|
+
top: 0,
|
|
40
|
+
marginLeft: SPACING[200]
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=VoiceRecordWithTranscript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","StyleSheet","View","SPACING","useUnit","VoiceRecord","VoiceTranscriptPanel","jsx","_jsx","jsxs","_jsxs","VoiceRecordWithTranscript","model","buttonVariant","style","panelStyle","metering","record","recorderModel","$metering","styles","container","children","panel","create","alignSelf","position","left","top","marginLeft"],"sourceRoot":"../../../../../../src","sources":["features/voice/recording/components/VoiceRecordWithTranscript.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAoBC,UAAU,EAAEC,IAAI,QAAmB,cAAc;AAErE,SAASC,OAAO,QAAQ,4BAA4B;AACpD,SAASC,OAAO,QAAQ,gBAAgB;AAIxC,SAASC,WAAW,QAAQ,kBAAe;AAC3C,SAASC,oBAAoB,QAAQ,2BAAwB;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAS7D;AACA;AACA,OAAO,MAAMC,yBAAyB,GAAGA,CAAC;EACxCC,KAAK;EACLC,aAAa;EACbC,KAAK;EACLC;AAC8B,CAAC,KAAK;EACpC,MAAMC,QAAQ,GAAGZ,OAAO,CAACQ,KAAK,CAACK,MAAM,CAACC,aAAa,CAACC,SAAS,CAAC;EAE9D,oBACET,KAAA,CAACR,IAAI;IAACY,KAAK,EAAE,CAACM,MAAM,CAACC,SAAS,EAAEP,KAAK,CAAE;IAAAQ,QAAA,gBACrCd,IAAA,CAACH,WAAW;MAACO,KAAK,EAAEA,KAAK,CAACK,MAAO;MAACJ,aAAa,EAAEA;IAAc,CAAE,CAAC,eAClEL,IAAA,CAACF,oBAAoB;MACnBM,KAAK,EAAEA,KAAK,CAACW,KAAM;MACnBP,QAAQ,EAAEA,QAAS;MACnBF,KAAK,EAAE,CAACM,MAAM,CAACG,KAAK,EAAER,UAAU;IAAE,CACnC,CAAC;EAAA,CACE,CAAC;AAEX,CAAC;AAED,MAAMK,MAAM,GAAGnB,UAAU,CAACuB,MAAM,CAAC;EAC/B;EACAH,SAAS,EAAE;IACTI,SAAS,EAAE;EACb,CAAC;EACDF,KAAK,EAAE;IACLG,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,MAAM;IACZC,GAAG,EAAE,CAAC;IACNC,UAAU,EAAE1B,OAAO,CAAC,GAAG;EACzB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useEffect, useState } from 'react';
|
|
4
|
+
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
5
|
+
import { BORDER_RADIUS, CaretDownIcon, COLORS, Loader, LoaderColor, LoaderSize, ScrollableListScrollView, SHADOWS, SPACING, Typography } from '@magmamath/react-native-ui';
|
|
6
|
+
import { useUnit } from 'effector-react';
|
|
7
|
+
import Animated, { Easing, FadeIn, FadeOut, useAnimatedStyle, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated';
|
|
8
|
+
import { useText } from "../../../../i18n/i18n.js";
|
|
9
|
+
import { VOICE_TRANSCRIPT_PANEL } from "../../constants.js";
|
|
10
|
+
import { VoiceTranscriptContent } from "../../playing/components/VoiceTranscriptContent.js";
|
|
11
|
+
import { useTranscriptPanelAnimation } from "../hooks/useTranscriptPanelAnimation.js";
|
|
12
|
+
import { useVoiceWaveform } from "../hooks/useVoiceWaveform.js";
|
|
13
|
+
import { VoiceWaveform } from "./VoiceWaveform.js";
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpacity);
|
|
16
|
+
const RECORDING_DOT_SIZE = 8;
|
|
17
|
+
const BLINK_DURATION_MS = 700;
|
|
18
|
+
const RECORDING_DOT_MIN_OPACITY = 0.2;
|
|
19
|
+
const CARET_SIZE = 22;
|
|
20
|
+
const DIMMED_OPACITY = VOICE_TRANSCRIPT_PANEL.DIMMED_OPACITY;
|
|
21
|
+
const PREVIEW_LINE_COUNT = 3;
|
|
22
|
+
// Cosmetic only (fade overlay height) — roughly the Typography h8 line height
|
|
23
|
+
const PREVIEW_LINE_HEIGHT = 19.6;
|
|
24
|
+
const PREVIEW_FADE_WIDTH = 72;
|
|
25
|
+
const PREVIEW_FADE_STRIPES_COUNT = 12;
|
|
26
|
+
// Rounding slack when comparing the two measured text heights
|
|
27
|
+
const PREVIEW_HEIGHT_TOLERANCE = 2;
|
|
28
|
+
const WAVEFORM_WIDTH = VOICE_TRANSCRIPT_PANEL.WIDTH - SPACING[200] * 2 - RECORDING_DOT_SIZE - SPACING[200];
|
|
29
|
+
const RecordingDot = () => {
|
|
30
|
+
const opacity = useSharedValue(1);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
opacity.value = withRepeat(withTiming(RECORDING_DOT_MIN_OPACITY, {
|
|
33
|
+
duration: BLINK_DURATION_MS,
|
|
34
|
+
easing: Easing.inOut(Easing.ease)
|
|
35
|
+
}), -1, true);
|
|
36
|
+
}, [opacity]);
|
|
37
|
+
|
|
38
|
+
// Explicit deps: consumers compile this library without the Reanimated Babel plugin
|
|
39
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
40
|
+
opacity: opacity.value
|
|
41
|
+
}), [opacity]);
|
|
42
|
+
return /*#__PURE__*/_jsx(Animated.View, {
|
|
43
|
+
style: [styles.recordingDot, animatedStyle]
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Stripes of the panel background with rising opacity imitate the text
|
|
48
|
+
// dissolving at the end of the last preview line (no gradient dependency)
|
|
49
|
+
const PreviewLineFade = () => /*#__PURE__*/_jsx(View, {
|
|
50
|
+
style: styles.previewFade,
|
|
51
|
+
pointerEvents: "none",
|
|
52
|
+
children: Array.from({
|
|
53
|
+
length: PREVIEW_FADE_STRIPES_COUNT
|
|
54
|
+
}, (_, index) => /*#__PURE__*/_jsx(View, {
|
|
55
|
+
style: [styles.previewFadeStripe, {
|
|
56
|
+
opacity: (index + 1) / PREVIEW_FADE_STRIPES_COUNT
|
|
57
|
+
}]
|
|
58
|
+
}, index))
|
|
59
|
+
});
|
|
60
|
+
export const VoiceTranscriptPanel = ({
|
|
61
|
+
model,
|
|
62
|
+
metering,
|
|
63
|
+
style
|
|
64
|
+
}) => {
|
|
65
|
+
const t = useText();
|
|
66
|
+
const {
|
|
67
|
+
flags,
|
|
68
|
+
transcript,
|
|
69
|
+
hasError,
|
|
70
|
+
isExpanded,
|
|
71
|
+
isDimmed
|
|
72
|
+
} = useUnit({
|
|
73
|
+
flags: model.$flags,
|
|
74
|
+
transcript: model.$transcript,
|
|
75
|
+
hasError: model.$hasError,
|
|
76
|
+
isExpanded: model.dropdown.$isExpanded,
|
|
77
|
+
isDimmed: model.$isDimmed
|
|
78
|
+
});
|
|
79
|
+
const [fullTextHeight, setFullTextHeight] = useState(0);
|
|
80
|
+
const [previewHeight, setPreviewHeight] = useState(0);
|
|
81
|
+
const levels = useVoiceWaveform({
|
|
82
|
+
metering,
|
|
83
|
+
isActive: flags.isRecording
|
|
84
|
+
});
|
|
85
|
+
const panelAnimation = useTranscriptPanelAnimation(isExpanded);
|
|
86
|
+
if (!flags.isOpen) return null;
|
|
87
|
+
const transcriptText = hasError ? t('voice.transcriptNotAvailable') : transcript;
|
|
88
|
+
|
|
89
|
+
// Both heights are measured, so the comparison stays correct regardless of
|
|
90
|
+
// the text's font metrics or paddings
|
|
91
|
+
const isTruncated = fullTextHeight > 0 && previewHeight > 0 && fullTextHeight > previewHeight + PREVIEW_HEIGHT_TOLERANCE;
|
|
92
|
+
const measureFullText = event => {
|
|
93
|
+
const {
|
|
94
|
+
height
|
|
95
|
+
} = event.nativeEvent.layout;
|
|
96
|
+
if (height > 0) setFullTextHeight(height);
|
|
97
|
+
};
|
|
98
|
+
const measurePreview = event => {
|
|
99
|
+
const {
|
|
100
|
+
height
|
|
101
|
+
} = event.nativeEvent.layout;
|
|
102
|
+
// Expanded shows the full text — only the collapsed (3-line) layout counts
|
|
103
|
+
if (height > 0 && !isExpanded) setPreviewHeight(height);
|
|
104
|
+
};
|
|
105
|
+
return /*#__PURE__*/_jsxs(Animated.View, {
|
|
106
|
+
entering: FadeIn,
|
|
107
|
+
exiting: FadeOut,
|
|
108
|
+
style: [styles.container, panelAnimation.containerAnimatedStyle, style],
|
|
109
|
+
children: [flags.isRecording && /*#__PURE__*/_jsxs(View, {
|
|
110
|
+
style: styles.recordingRow,
|
|
111
|
+
children: [/*#__PURE__*/_jsx(RecordingDot, {}), /*#__PURE__*/_jsx(VoiceWaveform, {
|
|
112
|
+
levels: levels,
|
|
113
|
+
width: WAVEFORM_WIDTH
|
|
114
|
+
})]
|
|
115
|
+
}), flags.isProcessing && /*#__PURE__*/_jsxs(View, {
|
|
116
|
+
style: styles.processing,
|
|
117
|
+
children: [/*#__PURE__*/_jsx(Loader, {
|
|
118
|
+
size: LoaderSize.SMALL,
|
|
119
|
+
color: LoaderColor.BLUE
|
|
120
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
|
121
|
+
variant: "h8",
|
|
122
|
+
style: styles.processingText,
|
|
123
|
+
children: `${t('voice.preparingTranscript')}...`
|
|
124
|
+
})]
|
|
125
|
+
}), flags.isDone && /*#__PURE__*/_jsxs(View, {
|
|
126
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
127
|
+
style: [styles.contentCollapsed, styles.fullTextMeasure],
|
|
128
|
+
pointerEvents: "none",
|
|
129
|
+
onLayout: measureFullText,
|
|
130
|
+
children: /*#__PURE__*/_jsx(VoiceTranscriptContent, {
|
|
131
|
+
text: transcriptText,
|
|
132
|
+
isLoading: false
|
|
133
|
+
})
|
|
134
|
+
}), /*#__PURE__*/_jsx(Typography, {
|
|
135
|
+
variant: "h5",
|
|
136
|
+
style: [styles.title, isDimmed && styles.dimmed],
|
|
137
|
+
children: t('voice.transcriptions')
|
|
138
|
+
}), /*#__PURE__*/_jsx(Animated.View, {
|
|
139
|
+
style: [styles.transcriptBody, panelAnimation.bodyAnimatedStyle],
|
|
140
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
141
|
+
style: [styles.transcriptBodyInner, isExpanded ? styles.contentExpanded : styles.contentCollapsed],
|
|
142
|
+
onLayout: panelAnimation.onContentLayout,
|
|
143
|
+
children: [/*#__PURE__*/_jsx(ScrollableListScrollView, {
|
|
144
|
+
style: styles.transcriptScroll,
|
|
145
|
+
scrollbarWidth: VOICE_TRANSCRIPT_PANEL.SCROLLBAR_WIDTH,
|
|
146
|
+
scrollEnabled: isExpanded,
|
|
147
|
+
hideShadow: true,
|
|
148
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
149
|
+
onLayout: measurePreview,
|
|
150
|
+
children: /*#__PURE__*/_jsx(VoiceTranscriptContent, {
|
|
151
|
+
text: transcriptText,
|
|
152
|
+
isLoading: false,
|
|
153
|
+
numberOfLines: isExpanded ? undefined : PREVIEW_LINE_COUNT,
|
|
154
|
+
dimmed: isDimmed
|
|
155
|
+
})
|
|
156
|
+
})
|
|
157
|
+
}), !isExpanded && isTruncated && /*#__PURE__*/_jsx(PreviewLineFade, {})]
|
|
158
|
+
})
|
|
159
|
+
}), isTruncated && /*#__PURE__*/_jsx(AnimatedTouchableOpacity, {
|
|
160
|
+
style: [styles.expandButton, panelAnimation.caretAnimatedStyle],
|
|
161
|
+
onPress: () => model.dropdown.toggleExpand(),
|
|
162
|
+
children: /*#__PURE__*/_jsx(CaretDownIcon, {
|
|
163
|
+
size: CARET_SIZE
|
|
164
|
+
})
|
|
165
|
+
})]
|
|
166
|
+
})]
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
const styles = StyleSheet.create({
|
|
170
|
+
container: {
|
|
171
|
+
padding: SPACING[200],
|
|
172
|
+
borderRadius: BORDER_RADIUS[300],
|
|
173
|
+
backgroundColor: COLORS.NEUTRAL_1,
|
|
174
|
+
overflow: 'hidden',
|
|
175
|
+
...SHADOWS['4']
|
|
176
|
+
},
|
|
177
|
+
recordingRow: {
|
|
178
|
+
flexDirection: 'row',
|
|
179
|
+
alignItems: 'center',
|
|
180
|
+
gap: SPACING[200]
|
|
181
|
+
},
|
|
182
|
+
recordingDot: {
|
|
183
|
+
width: RECORDING_DOT_SIZE,
|
|
184
|
+
height: RECORDING_DOT_SIZE,
|
|
185
|
+
borderRadius: RECORDING_DOT_SIZE / 2,
|
|
186
|
+
backgroundColor: COLORS.PRIMARY_RED
|
|
187
|
+
},
|
|
188
|
+
title: {
|
|
189
|
+
color: COLORS.NEUTRAL_10,
|
|
190
|
+
marginLeft: SPACING[100]
|
|
191
|
+
},
|
|
192
|
+
dimmed: {
|
|
193
|
+
opacity: DIMMED_OPACITY
|
|
194
|
+
},
|
|
195
|
+
transcriptBody: {
|
|
196
|
+
overflow: 'hidden'
|
|
197
|
+
},
|
|
198
|
+
// Absolute so its measured height stays the content's natural height,
|
|
199
|
+
// independent of the animated wrapper height around it
|
|
200
|
+
transcriptBodyInner: {
|
|
201
|
+
position: 'absolute',
|
|
202
|
+
top: 0,
|
|
203
|
+
left: 0
|
|
204
|
+
},
|
|
205
|
+
// Fixed per-state widths: the text snaps to its final layout once while the
|
|
206
|
+
// panel frame animates around it
|
|
207
|
+
contentCollapsed: {
|
|
208
|
+
width: VOICE_TRANSCRIPT_PANEL.WIDTH - SPACING[200] * 2
|
|
209
|
+
},
|
|
210
|
+
fullTextMeasure: {
|
|
211
|
+
position: 'absolute',
|
|
212
|
+
opacity: 0
|
|
213
|
+
},
|
|
214
|
+
contentExpanded: {
|
|
215
|
+
width: VOICE_TRANSCRIPT_PANEL.WIDTH_DONE - SPACING[200] * 2
|
|
216
|
+
},
|
|
217
|
+
transcriptScroll: {
|
|
218
|
+
maxHeight: VOICE_TRANSCRIPT_PANEL.TRANSCRIPT_MAX_HEIGHT
|
|
219
|
+
},
|
|
220
|
+
previewFade: {
|
|
221
|
+
position: 'absolute',
|
|
222
|
+
right: SPACING[200],
|
|
223
|
+
bottom: SPACING[100],
|
|
224
|
+
width: PREVIEW_FADE_WIDTH,
|
|
225
|
+
height: PREVIEW_LINE_HEIGHT,
|
|
226
|
+
flexDirection: 'row'
|
|
227
|
+
},
|
|
228
|
+
previewFadeStripe: {
|
|
229
|
+
flex: 1,
|
|
230
|
+
backgroundColor: COLORS.NEUTRAL_1
|
|
231
|
+
},
|
|
232
|
+
expandButton: {
|
|
233
|
+
justifyContent: 'center',
|
|
234
|
+
alignItems: 'center'
|
|
235
|
+
},
|
|
236
|
+
processing: {
|
|
237
|
+
alignItems: 'center',
|
|
238
|
+
justifyContent: 'center',
|
|
239
|
+
gap: SPACING[200],
|
|
240
|
+
paddingVertical: SPACING[200]
|
|
241
|
+
},
|
|
242
|
+
processingText: {
|
|
243
|
+
color: COLORS.NEUTRAL_7
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
//# sourceMappingURL=VoiceTranscriptPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useEffect","useState","StyleSheet","TouchableOpacity","View","BORDER_RADIUS","CaretDownIcon","COLORS","Loader","LoaderColor","LoaderSize","ScrollableListScrollView","SHADOWS","SPACING","Typography","useUnit","Animated","Easing","FadeIn","FadeOut","useAnimatedStyle","useSharedValue","withRepeat","withTiming","useText","VOICE_TRANSCRIPT_PANEL","VoiceTranscriptContent","useTranscriptPanelAnimation","useVoiceWaveform","VoiceWaveform","jsx","_jsx","jsxs","_jsxs","AnimatedTouchableOpacity","createAnimatedComponent","RECORDING_DOT_SIZE","BLINK_DURATION_MS","RECORDING_DOT_MIN_OPACITY","CARET_SIZE","DIMMED_OPACITY","PREVIEW_LINE_COUNT","PREVIEW_LINE_HEIGHT","PREVIEW_FADE_WIDTH","PREVIEW_FADE_STRIPES_COUNT","PREVIEW_HEIGHT_TOLERANCE","WAVEFORM_WIDTH","WIDTH","RecordingDot","opacity","value","duration","easing","inOut","ease","animatedStyle","style","styles","recordingDot","PreviewLineFade","previewFade","pointerEvents","children","Array","from","length","_","index","previewFadeStripe","VoiceTranscriptPanel","model","metering","t","flags","transcript","hasError","isExpanded","isDimmed","$flags","$transcript","$hasError","dropdown","$isExpanded","$isDimmed","fullTextHeight","setFullTextHeight","previewHeight","setPreviewHeight","levels","isActive","isRecording","panelAnimation","isOpen","transcriptText","isTruncated","measureFullText","event","height","nativeEvent","layout","measurePreview","entering","exiting","container","containerAnimatedStyle","recordingRow","width","isProcessing","processing","size","SMALL","color","BLUE","variant","processingText","isDone","contentCollapsed","fullTextMeasure","onLayout","text","isLoading","title","dimmed","transcriptBody","bodyAnimatedStyle","transcriptBodyInner","contentExpanded","onContentLayout","transcriptScroll","scrollbarWidth","SCROLLBAR_WIDTH","scrollEnabled","hideShadow","numberOfLines","undefined","expandButton","caretAnimatedStyle","onPress","toggleExpand","create","padding","borderRadius","backgroundColor","NEUTRAL_1","overflow","flexDirection","alignItems","gap","PRIMARY_RED","NEUTRAL_10","marginLeft","position","top","left","WIDTH_DONE","maxHeight","TRANSCRIPT_MAX_HEIGHT","right","bottom","flex","justifyContent","paddingVertical","NEUTRAL_7"],"sourceRoot":"../../../../../../src","sources":["features/voice/recording/components/VoiceTranscriptPanel.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EA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IACpBC,GAAG,EAAE,CAAC;IACNC,IAAI,EAAE;EACR,CAAC;EACD;EACA;EACArC,gBAAgB,EAAE;IAChBV,KAAK,EAAEjF,sBAAsB,CAACsB,KAAK,GAAGlC,OAAO,CAAC,GAAG,CAAC,GAAG;EACvD,CAAC;EACDwG,eAAe,EAAE;IACfkC,QAAQ,EAAE,UAAU;IACpBtG,OAAO,EAAE;EACX,CAAC;EACD6E,eAAe,EAAE;IACfpB,KAAK,EAAEjF,sBAAsB,CAACiI,UAAU,GAAG7I,OAAO,CAAC,GAAG,CAAC,GAAG;EAC5D,CAAC;EACDmH,gBAAgB,EAAE;IAChB2B,SAAS,EAAElI,sBAAsB,CAACmI;EACpC,CAAC;EACDhG,WAAW,EAAE;IACX2F,QAAQ,EAAE,UAAU;IACpBM,KAAK,EAAEhJ,OAAO,CAAC,GAAG,CAAC;IACnBiJ,MAAM,EAAEjJ,OAAO,CAAC,GAAG,CAAC;IACpB6F,KAAK,EAAE/D,kBAAkB;IACzBsD,MAAM,EAAEvD,mBAAmB;IAC3BuG,aAAa,EAAE;EACjB,CAAC;EACD7E,iBAAiB,EAAE;IACjB2F,IAAI,EAAE,CAAC;IACPjB,eAAe,EAAEvI,MAAM,CAACwI;EAC1B,CAAC;EACDR,YAAY,EAAE;IACZyB,cAAc,EAAE,QAAQ;IACxBd,UAAU,EAAE;EACd,CAAC;EACDtC,UAAU,EAAE;IACVsC,UAAU,EAAE,QAAQ;IACpBc,cAAc,EAAE,QAAQ;IACxBb,GAAG,EAAEtI,OAAO,CAAC,GAAG,CAAC;IACjBoJ,eAAe,EAAEpJ,OAAO,CAAC,GAAG;EAC9B,CAAC;EACDqG,cAAc,EAAE;IACdH,KAAK,EAAExG,MAAM,CAAC2J;EAChB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useEffect } from 'react';
|
|
4
|
+
import { StyleSheet, View } from 'react-native';
|
|
5
|
+
import { COLORS } from '@magmamath/react-native-ui';
|
|
6
|
+
import Animated, { Easing, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
7
|
+
import { VOICE_WAVEFORM } from "../../constants.js";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const BAR_STEP = VOICE_WAVEFORM.BAR_WIDTH + VOICE_WAVEFORM.BAR_GAP;
|
|
10
|
+
// One extra bar is rendered off-screen on the right and slides in as the row
|
|
11
|
+
// shifts — that is what makes the scroll continuous instead of stepping
|
|
12
|
+
const OFFSCREEN_BARS = 1;
|
|
13
|
+
const getVisibleBarsCount = width => {
|
|
14
|
+
const barsForWidth = Math.floor(width / BAR_STEP);
|
|
15
|
+
return Math.max(VOICE_WAVEFORM.MIN_BARS, barsForWidth);
|
|
16
|
+
};
|
|
17
|
+
const getBarHeight = level => Math.max(VOICE_WAVEFORM.MIN_BAR_HEIGHT, Math.round(level * (VOICE_WAVEFORM.HEIGHT - VOICE_WAVEFORM.AMPLITUDE_PADDING)));
|
|
18
|
+
|
|
19
|
+
// Older bars (toward the left) fade out, mirroring the dotted lead-in in the
|
|
20
|
+
// design. Opacity ramps from 0 up to full across the first FADE_RATIO of bars.
|
|
21
|
+
const getBarOpacity = (index, count) => {
|
|
22
|
+
const fadeBars = count * VOICE_WAVEFORM.FADE_RATIO;
|
|
23
|
+
return Math.min(1, index / fadeBars);
|
|
24
|
+
};
|
|
25
|
+
export const VoiceWaveform = ({
|
|
26
|
+
levels,
|
|
27
|
+
width
|
|
28
|
+
}) => {
|
|
29
|
+
const count = getVisibleBarsCount(width);
|
|
30
|
+
const visibleLevels = levels.slice(-(count + OFFSCREEN_BARS));
|
|
31
|
+
|
|
32
|
+
// Conveyor-belt motion: each new sample shifts the buffer one slot left and
|
|
33
|
+
// snaps the row back, then the row glides left by one step until the next
|
|
34
|
+
// sample lands — the two cancel out into continuous movement.
|
|
35
|
+
const shift = useSharedValue(0);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
shift.value = 0;
|
|
38
|
+
shift.value = withTiming(-BAR_STEP, {
|
|
39
|
+
duration: VOICE_WAVEFORM.SAMPLE_INTERVAL_MS,
|
|
40
|
+
easing: Easing.linear
|
|
41
|
+
});
|
|
42
|
+
}, [levels, shift]);
|
|
43
|
+
|
|
44
|
+
// Explicit deps: consumers compile this library without the Reanimated Babel plugin
|
|
45
|
+
const rowAnimatedStyle = useAnimatedStyle(() => ({
|
|
46
|
+
transform: [{
|
|
47
|
+
translateX: shift.value
|
|
48
|
+
}]
|
|
49
|
+
}), [shift]);
|
|
50
|
+
return /*#__PURE__*/_jsx(View, {
|
|
51
|
+
style: [styles.container, {
|
|
52
|
+
width
|
|
53
|
+
}],
|
|
54
|
+
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
55
|
+
style: [styles.row, rowAnimatedStyle],
|
|
56
|
+
children: visibleLevels.map((level, index) => /*#__PURE__*/_jsx(View, {
|
|
57
|
+
style: [styles.bar, {
|
|
58
|
+
height: getBarHeight(level),
|
|
59
|
+
opacity: getBarOpacity(index, visibleLevels.length)
|
|
60
|
+
}]
|
|
61
|
+
}, index))
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
const styles = StyleSheet.create({
|
|
66
|
+
container: {
|
|
67
|
+
height: VOICE_WAVEFORM.HEIGHT,
|
|
68
|
+
overflow: 'hidden'
|
|
69
|
+
},
|
|
70
|
+
// Hangs one step past the right edge so the newest bar starts hidden
|
|
71
|
+
row: {
|
|
72
|
+
position: 'absolute',
|
|
73
|
+
top: 0,
|
|
74
|
+
bottom: 0,
|
|
75
|
+
right: -BAR_STEP,
|
|
76
|
+
flexDirection: 'row',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
gap: VOICE_WAVEFORM.BAR_GAP
|
|
79
|
+
},
|
|
80
|
+
bar: {
|
|
81
|
+
width: VOICE_WAVEFORM.BAR_WIDTH,
|
|
82
|
+
borderRadius: VOICE_WAVEFORM.BAR_WIDTH / 2,
|
|
83
|
+
backgroundColor: COLORS.NEUTRAL_7
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=VoiceWaveform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useEffect","StyleSheet","View","COLORS","Animated","Easing","useAnimatedStyle","useSharedValue","withTiming","VOICE_WAVEFORM","jsx","_jsx","BAR_STEP","BAR_WIDTH","BAR_GAP","OFFSCREEN_BARS","getVisibleBarsCount","width","barsForWidth","Math","floor","max","MIN_BARS","getBarHeight","level","MIN_BAR_HEIGHT","round","HEIGHT","AMPLITUDE_PADDING","getBarOpacity","index","count","fadeBars","FADE_RATIO","min","VoiceWaveform","levels","visibleLevels","slice","shift","value","duration","SAMPLE_INTERVAL_MS","easing","linear","rowAnimatedStyle","transform","translateX","style","styles","container","children","row","map","bar","height","opacity","length","create","overflow","position","top","bottom","right","flexDirection","alignItems","gap","borderRadius","backgroundColor","NEUTRAL_7"],"sourceRoot":"../../../../../../src","sources":["features/voice/recording/components/VoiceWaveform.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAE/C,SAASC,MAAM,QAAQ,4BAA4B;AACnD,OAAOC,QAAQ,IACbC,MAAM,EACNC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAEhC,SAASC,cAAc,QAAQ,oBAAiB;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAOhD,MAAMC,QAAQ,GAAGH,cAAc,CAACI,SAAS,GAAGJ,cAAc,CAACK,OAAO;AAClE;AACA;AACA,MAAMC,cAAc,GAAG,CAAC;AAExB,MAAMC,mBAAmB,GAAIC,KAAa,IAAK;EAC7C,MAAMC,YAAY,GAAGC,IAAI,CAACC,KAAK,CAACH,KAAK,GAAGL,QAAQ,CAAC;EACjD,OAAOO,IAAI,CAACE,GA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react-native-reanimated';
|
|
4
|
+
import { VOICE_TRANSCRIPT_PANEL } from "../../constants.js";
|
|
5
|
+
const TIMING = {
|
|
6
|
+
duration: 170
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// Width and height are animated as explicit numbers instead of reanimated
|
|
10
|
+
// layout transitions: on web those run as FLIP animations that scale the
|
|
11
|
+
// subtree, visibly stretching the text while the panel resizes.
|
|
12
|
+
export const useTranscriptPanelAnimation = isExpanded => {
|
|
13
|
+
const contentHeight = useSharedValue(0);
|
|
14
|
+
const onContentLayout = event => {
|
|
15
|
+
const height = event.nativeEvent.layout.height;
|
|
16
|
+
if (height <= 0) return;
|
|
17
|
+
contentHeight.value = contentHeight.value === 0 ? height : withTiming(height, TIMING);
|
|
18
|
+
};
|
|
19
|
+
const containerAnimatedStyle = useAnimatedStyle(() => ({
|
|
20
|
+
width: withTiming(isExpanded ? VOICE_TRANSCRIPT_PANEL.WIDTH_DONE : VOICE_TRANSCRIPT_PANEL.WIDTH, TIMING)
|
|
21
|
+
}), [isExpanded]);
|
|
22
|
+
const bodyAnimatedStyle = useAnimatedStyle(() => contentHeight.value === 0 ? {} : {
|
|
23
|
+
height: contentHeight.value
|
|
24
|
+
}, [contentHeight]);
|
|
25
|
+
const caretAnimatedStyle = useAnimatedStyle(() => ({
|
|
26
|
+
transform: [{
|
|
27
|
+
rotate: withTiming(isExpanded ? '180deg' : '0deg', TIMING)
|
|
28
|
+
}]
|
|
29
|
+
}), [isExpanded]);
|
|
30
|
+
return {
|
|
31
|
+
onContentLayout,
|
|
32
|
+
containerAnimatedStyle,
|
|
33
|
+
bodyAnimatedStyle,
|
|
34
|
+
caretAnimatedStyle
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=useTranscriptPanelAnimation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useAnimatedStyle","useSharedValue","withTiming","VOICE_TRANSCRIPT_PANEL","TIMING","duration","useTranscriptPanelAnimation","isExpanded","contentHeight","onContentLayout","event","height","nativeEvent","layout","value","containerAnimatedStyle","width","WIDTH_DONE","WIDTH","bodyAnimatedStyle","caretAnimatedStyle","transform","rotate"],"sourceRoot":"../../../../../../src","sources":["features/voice/recording/hooks/useTranscriptPanelAnimation.ts"],"mappings":";;AAEA,SACEA,gBAAgB,EAChBC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAEhC,SAASC,sBAAsB,QAAQ,oBAAiB;AAExD,MAAMC,MAAM,GAAG;EAAEC,QAAQ,EAAE;AAAI,CAAU;;AAEzC;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAIC,UAAmB,IAAK;EAClE,MAAMC,aAAa,GAAGP,cAAc,CAAC,CAAC,CAAC;EAEvC,MAAMQ,eAAe,GAAIC,KAAwB,IAAK;IACpD,MAAMC,MAAM,GAAGD,KAAK,CAACE,WAAW,CAACC,MAAM,CAACF,MAAM;IAC9C,IAAIA,MAAM,IAAI,CAAC,EAAE;IACjBH,aAAa,CAACM,KAAK,GACjBN,aAAa,CAACM,KAAK,KAAK,CAAC,GAAGH,MAAM,GAAGT,UAAU,CAACS,MAAM,EAAEP,MAAM,CAAC;EACnE,CAAC;EAED,MAAMW,sBAAsB,GAAGf,gBAAgB,CAC7C,OAAO;IACLgB,KAAK,EAAEd,UAAU,CACfK,UAAU,GAAGJ,sBAAsB,CAACc,UAAU,GAAGd,sBAAsB,CAACe,KAAK,EAC7Ed,MACF;EACF,CAAC,CAAC,EACF,CAACG,UAAU,CACb,CAAC;EAED,MAAMY,iBAAiB,GAAGnB,gBAAgB,CACxC,MAAOQ,aAAa,CAACM,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG;IAAEH,MAAM,EAAEH,aAAa,CAACM;EAAM,CAAE,EACxE,CAACN,aAAa,CAChB,CAAC;EAED,MAAMY,kBAAkB,GAAGpB,gBAAgB,CACzC,OAAO;IACLqB,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAEpB,UAAU,CAACK,UAAU,GAAG,QAAQ,GAAG,MAAM,EAAEH,MAAM;IAAE,CAAC;EAC5E,CAAC,CAAC,EACF,CAACG,UAAU,CACb,CAAC;EAED,OAAO;IAAEE,eAAe;IAAEM,sBAAsB;IAAEI,iBAAiB;IAAEC;EAAmB,CAAC;AAC3F,CAAC","ignoreList":[]}
|
|
@@ -4,10 +4,27 @@ import { RecordingPresets, useAudioRecorder, useAudioRecorderState } from 'expo-
|
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
5
|
import { IS_WEB } from '@magmamath/react-native-ui';
|
|
6
6
|
import { VOICE_RECORDER_MAX_DURATION_MS, VoiceRecorderState } from "../../constants.js";
|
|
7
|
-
import { addAudioInputsListenerWeb, getAvailableInputs } from "../../helpers.js";
|
|
7
|
+
import { addAudioInputsListenerWeb, createWebMeteringMonitor, getAvailableInputs } from "../../helpers.js";
|
|
8
|
+
import { METERING_UPDATE_INTERVAL_MS } from "../../constants.js";
|
|
9
|
+
|
|
10
|
+
// Metering powers the live recording waveform (recorderState.metering).
|
|
11
|
+
// Only native respects it — on web the level is measured by
|
|
12
|
+
// createWebMeteringMonitor instead.
|
|
13
|
+
const RECORDING_OPTIONS = {
|
|
14
|
+
...RecordingPresets.LOW_QUALITY,
|
|
15
|
+
isMeteringEnabled: true
|
|
16
|
+
};
|
|
8
17
|
export const useVoiceRecorder = model => {
|
|
9
|
-
const recorder = useAudioRecorder(
|
|
10
|
-
const recorderState = useAudioRecorderState(recorder);
|
|
18
|
+
const recorder = useAudioRecorder(RECORDING_OPTIONS, model.recordingStatusUpdate);
|
|
19
|
+
const recorderState = useAudioRecorderState(recorder, METERING_UPDATE_INTERVAL_MS);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (IS_WEB) return;
|
|
22
|
+
model.recorderModel.setMetering(recorderState.metering ?? null);
|
|
23
|
+
}, [recorderState.metering, model.recorderModel]);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!IS_WEB || !recorderState.isRecording) return;
|
|
26
|
+
return createWebMeteringMonitor(recorder, model.recorderModel.setMetering);
|
|
27
|
+
}, [recorderState.isRecording, recorder, model.recorderModel]);
|
|
11
28
|
useEffect(() => {
|
|
12
29
|
if (recorderState.durationMillis >= VOICE_RECORDER_MAX_DURATION_MS && recorderState.isRecording) {
|
|
13
30
|
model.recorderModel.stop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RecordingPresets","useAudioRecorder","useAudioRecorderState","useEffect","IS_WEB","VOICE_RECORDER_MAX_DURATION_MS","VoiceRecorderState","addAudioInputsListenerWeb","getAvailableInputs","useVoiceRecorder","model","recorder","
|
|
1
|
+
{"version":3,"names":["RecordingPresets","useAudioRecorder","useAudioRecorderState","useEffect","IS_WEB","VOICE_RECORDER_MAX_DURATION_MS","VoiceRecorderState","addAudioInputsListenerWeb","createWebMeteringMonitor","getAvailableInputs","METERING_UPDATE_INTERVAL_MS","RECORDING_OPTIONS","LOW_QUALITY","isMeteringEnabled","useVoiceRecorder","model","recorder","recordingStatusUpdate","recorderState","recorderModel","setMetering","metering","isRecording","durationMillis","stop","setLastKnownDurationMs","then","inputs","setAvailableInputs","removeListener","devices","setVoiceRecordState","RECORDING","PAUSED","IDLE","reset"],"sourceRoot":"../../../../../../src","sources":["features/voice/recording/hooks/useVoiceRecorder.ts"],"mappings":";;AAAA,SAASA,gBAAgB,EAAEC,gBAAgB,EAAEC,qBAAqB,QAAQ,YAAY;AAEtF,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,MAAM,QAAQ,4BAA4B;AACnD,SAASC,8BAA8B,EAAEC,kBAAkB,QAAQ,oBAAiB;AACpF,SACEC,yBAAyB,EACzBC,wBAAwB,EACxBC,kBAAkB,QACb,kBAAe;AACtB,SAASC,2BAA2B,QAAQ,oBAAiB;;AAE7D;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG;EACxB,GAAGX,gBAAgB,CAACY,WAAW;EAC/BC,iBAAiB,EAAE;AACrB,CAAC;AAED,OAAO,MAAM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F;IACF;IAEA,MAAME,cAAc,GAAGtB,yBAAyB,CAAEuB,OAAO,IAAK;MAC5Df,KAAK,CAACI,aAAa,CAACS,kBAAkB,CAACE,OAAO,CAAC;IACjD,CAAC,CAAC;IAEF,OAAOD,cAAc;EACvB,CAAC,EAAE,CAACb,QAAQ,EAAED,KAAK,CAACI,aAAa,CAAC,CAAC;EAEnChB,SAAS,CAAC,MAAM;IACd,IAAIe,aAAa,CAACI,WAAW,EAAE;MAC7BP,KAAK,CAACI,aAAa,CAACY,mBAAmB,CAACzB,kBAAkB,CAAC0B,SAAS,CAAC;MACrE;IACF;IACA,IAAId,aAAa,CAACK,cAAc,GAAG,CAAC,EAAE;MACpCR,KAAK,CAACI,aAAa,CAACY,mBAAmB,CAACzB,kBAAkB,CAAC2B,MAAM,CAAC;MAClE;IACF;IACAlB,KAAK,CAACI,aAAa,CAACY,mBAAmB,CAACzB,kBAAkB,CAAC4B,IAAI,CAAC;IAEhE,OAAO,MAAM;MACXnB,KAAK,CAACI,aAAa,CAACgB,KAAK,CAAC,CAAC;IAC7B,CAAC;EACH,CAAC,EAAE,CAACjB,aAAa,EAAEH,KAAK,CAACI,aAAa,CAAC,CAAC;EAExChB,SAAS,CAAC,MAAM;IACdY,KAAK,CAACI,aAAa,CAACH,QAAQ,GAAGA,QAAQ;EACzC,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;EAEd,OAAO;IAAEE;EAAc,CAAC;AAC1B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { VOICE_WAVEFORM } from "../../constants.js";
|
|
5
|
+
import { normalizeMetering } from "../../helpers.js";
|
|
6
|
+
const createSilentBuffer = () => new Array(VOICE_WAVEFORM.BUFFER_SIZE).fill(VOICE_WAVEFORM.MIN_LEVEL);
|
|
7
|
+
|
|
8
|
+
// Keeps a rolling buffer of normalized levels that scrolls right-to-left while
|
|
9
|
+
// recording. We sample on a fixed interval (rather than on every metering
|
|
10
|
+
// update) so the scroll speed stays constant regardless of the recorder's
|
|
11
|
+
// status cadence. The latest metering value is read from a ref to avoid
|
|
12
|
+
// resubscribing the interval on each change. Levels are low-pass filtered so
|
|
13
|
+
// neighboring bars flow into each other instead of jumping.
|
|
14
|
+
export const useVoiceWaveform = ({
|
|
15
|
+
metering,
|
|
16
|
+
isActive
|
|
17
|
+
}) => {
|
|
18
|
+
const meteringRef = useRef(metering);
|
|
19
|
+
meteringRef.current = metering;
|
|
20
|
+
const smoothedLevelRef = useRef(VOICE_WAVEFORM.MIN_LEVEL);
|
|
21
|
+
const [levels, setLevels] = useState(createSilentBuffer);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!isActive) {
|
|
24
|
+
smoothedLevelRef.current = VOICE_WAVEFORM.MIN_LEVEL;
|
|
25
|
+
setLevels(createSilentBuffer());
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const intervalId = setInterval(() => {
|
|
29
|
+
const target = normalizeMetering(meteringRef.current);
|
|
30
|
+
smoothedLevelRef.current += (target - smoothedLevelRef.current) * VOICE_WAVEFORM.LEVEL_SMOOTHING;
|
|
31
|
+
const level = Math.max(VOICE_WAVEFORM.MIN_LEVEL, smoothedLevelRef.current);
|
|
32
|
+
setLevels(prev => [...prev.slice(1), level]);
|
|
33
|
+
}, VOICE_WAVEFORM.SAMPLE_INTERVAL_MS);
|
|
34
|
+
return () => clearInterval(intervalId);
|
|
35
|
+
}, [isActive]);
|
|
36
|
+
return levels;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=useVoiceWaveform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","VOICE_WAVEFORM","normalizeMetering","createSilentBuffer","Array","BUFFER_SIZE","fill","MIN_LEVEL","useVoiceWaveform","metering","isActive","meteringRef","current","smoothedLevelRef","levels","setLevels","intervalId","setInterval","target","LEVEL_SMOOTHING","level","Math","max","prev","slice","SAMPLE_INTERVAL_MS","clearInterval"],"sourceRoot":"../../../../../../src","sources":["features/voice/recording/hooks/useVoiceWaveform.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEnD,SAASC,cAAc,QAAQ,oBAAiB;AAChD,SAASC,iBAAiB,QAAQ,kBAAe;AAOjD,MAAMC,kBAAkB,GAAGA,CAAA,KACzB,IAAIC,KAAK,CAASH,cAAc,CAACI,WAAW,CAAC,CAACC,IAAI,CAACL,cAAc,CAACM,SAAS,CAAC;;AAE9E;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAAEC,QAAQ;EAAEC;AAAiC,CAAC,KAAK;EAClF,MAAMC,WAAW,GAAGZ,MAAM,CAACU,QAAQ,CAAC;EACpCE,WAAW,CAACC,OAAO,GAAGH,QAAQ;EAE9B,MAAMI,gBAAgB,GAAGd,MAAM,CAACE,cAAc,CAACM,SAAS,CAAC;EACzD,MAAM,CAACO,MAAM,EAAEC,SAAS,CAAC,GAAGf,QAAQ,CAAWG,kBAAkB,CAAC;EAElEL,SAAS,CAAC,MAAM;IACd,IAAI,CAACY,QAAQ,EAAE;MACbG,gBAAgB,CAACD,OAAO,GAAGX,cAAc,CAACM,SAAS;MACnDQ,SAAS,CAACZ,kBAAkB,CAAC,CAAC,CAAC;MAC/B;IACF;IAEA,MAAMa,UAAU,GAAGC,WAAW,CAAC,MAAM;MACnC,MAAMC,MAAM,GAAGhB,iBAAiB,CAACS,WAAW,CAACC,OAAO,CAAC;MACrDC,gBAAgB,CAACD,OAAO,IACtB,CAACM,MAAM,GAAGL,gBAAgB,CAACD,OAAO,IAAIX,cAAc,CAACkB,eAAe;MACtE,MAAMC,KAAK,GAAGC,IAAI,CAACC,GAAG,CAACrB,cAAc,CAACM,SAAS,EAAEM,gBAAgB,CAACD,OAAO,CAAC;MAC1EG,SAAS,CA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