🕐 커밋 시간: 2025. 11. 24. 12:43:58 📊 변경 통계: • 총 파일: 40개 • 추가: +774줄 • 삭제: -581줄 📝 수정된 파일: ~ com.twin.app.shoptime/src/actions/appDataActions.js ~ com.twin.app.shoptime/src/actions/billingActions.js ~ com.twin.app.shoptime/src/actions/brandActions.js ~ com.twin.app.shoptime/src/actions/cancelActions.js ~ com.twin.app.shoptime/src/actions/cardActions.js ~ com.twin.app.shoptime/src/actions/cartActions.js ~ com.twin.app.shoptime/src/actions/checkoutActions.js ~ com.twin.app.shoptime/src/actions/commonActions.js ~ com.twin.app.shoptime/src/actions/convertActions.js ~ com.twin.app.shoptime/src/actions/couponActions.js ~ com.twin.app.shoptime/src/actions/deviceActions.js ~ com.twin.app.shoptime/src/actions/empActions.js ~ com.twin.app.shoptime/src/actions/eventActions.js ~ com.twin.app.shoptime/src/actions/forYouActions.js ~ com.twin.app.shoptime/src/actions/homeActions.js ~ com.twin.app.shoptime/src/actions/logActions.js ~ com.twin.app.shoptime/src/actions/mediaActions.js ~ com.twin.app.shoptime/src/actions/mockCartActions.js ~ com.twin.app.shoptime/src/actions/myPageActions.js ~ com.twin.app.shoptime/src/actions/onSaleActions.js ~ com.twin.app.shoptime/src/actions/orderActions.js ~ com.twin.app.shoptime/src/actions/panelActions.js ~ com.twin.app.shoptime/src/actions/panelNavigationActions.js ~ com.twin.app.shoptime/src/actions/pinCodeActions.js ~ com.twin.app.shoptime/src/actions/productActions.js ~ com.twin.app.shoptime/src/actions/queuedPanelActions.js ~ com.twin.app.shoptime/src/actions/searchActions.js ~ com.twin.app.shoptime/src/actions/shippingActions.js ~ com.twin.app.shoptime/src/actions/voiceActions.js ~ com.twin.app.shoptime/src/actions/webSpeechActions.js ~ com.twin.app.shoptime/src/reducers/localSettingsReducer.js ~ com.twin.app.shoptime/src/reducers/mediaOverlayReducer.js ~ com.twin.app.shoptime/src/reducers/mockCartReducer.js ~ com.twin.app.shoptime/src/reducers/playReducer.js ~ com.twin.app.shoptime/src/reducers/productReducer.js ~ com.twin.app.shoptime/src/reducers/videoOverlayReducer.js ~ com.twin.app.shoptime/src/views/UserReview/ShowUserReviews.jsx ~ com.twin.app.shoptime/src/views/UserReview/UserReviewPanel.jsx ~ com.twin.app.shoptime/src/views/UserReview/components/UserReviewsList.jsx ~ com.twin.app.shoptime/src/views/UserReview/components/VirtualScrollBar.jsx 🔧 함수 변경 내용: 📊 Function-level changes summary across 40 files: • Functions added: 14 • Functions modified: 34 • Functions deleted: 18 📋 By language: • javascript: 40 files, 66 function changes 🔧 주요 변경 내용: • 핵심 비즈니스 로직 개선 • 로깅 시스템 개선 • 설정 관리 시스템 개선 • UI 컴포넌트 아키텍처 개선
162 lines
4.7 KiB
JavaScript
162 lines
4.7 KiB
JavaScript
// src/actions/webSpeechActions.js
|
|
|
|
import { types } from './actionTypes';
|
|
import webSpeechService from '../services/webSpeech/WebSpeechService';
|
|
import { createDebugHelpers } from '../utils/debug';
|
|
|
|
// 디버그 헬퍼 설정
|
|
const DEBUG_MODE = false;
|
|
const { dlog, dwarn, derror } = createDebugHelpers(DEBUG_MODE);
|
|
|
|
/**
|
|
* Web Speech 초기화 및 시작
|
|
* @param {Object} config - 언어 및 설정
|
|
*/
|
|
export const initializeWebSpeech =
|
|
(config = {}) =>
|
|
(dispatch) => {
|
|
dlog('[VoiceInput]-[WebSpeech] ACTION-INIT: 초기화 시작');
|
|
|
|
// 지원 여부 확인
|
|
if (!webSpeechService.isSupported) {
|
|
const error = 'Web Speech API is not supported in this browser';
|
|
derror('[VoiceInput]-[WebSpeech] ACTION-INIT: ❌ Web Speech API 미지원');
|
|
dispatch({
|
|
type: types.WEB_SPEECH_ERROR,
|
|
payload: { error, message: error },
|
|
});
|
|
return false;
|
|
}
|
|
|
|
// 초기화
|
|
const initialized = webSpeechService.initialize({
|
|
lang: config.lang || 'ko-KR',
|
|
continuous: config.continuous || false,
|
|
interimResults: config.interimResults !== false,
|
|
maxAlternatives: config.maxAlternatives || 1,
|
|
});
|
|
|
|
if (!initialized) {
|
|
derror('[VoiceInput]-[WebSpeech] ACTION-INIT: ❌ 초기화 실패');
|
|
dispatch({
|
|
type: types.WEB_SPEECH_ERROR,
|
|
payload: { error: 'Failed to initialize', message: 'Failed to initialize Web Speech' },
|
|
});
|
|
return false;
|
|
}
|
|
|
|
// 이벤트 핸들러 등록
|
|
webSpeechService.on('start', () => {
|
|
dlog('[VoiceInput]-[WebSpeech] ACTION-EVENT: WEB_SPEECH_START 디스패치');
|
|
dispatch({
|
|
type: types.WEB_SPEECH_START,
|
|
});
|
|
});
|
|
|
|
webSpeechService.on('result', (result) => {
|
|
dlog(
|
|
`[VoiceInput]-[WebSpeech] ACTION-EVENT: result 수신 - isFinal=${result.isFinal}, text="${result.transcript}"`
|
|
);
|
|
|
|
// Interim 결과 (중간 결과) - 항상 디스패치하여 실시간 표시
|
|
dispatch({
|
|
type: types.WEB_SPEECH_INTERIM_RESULT,
|
|
payload: result.transcript, // 전체 연결된 텍스트 (final + interim)
|
|
});
|
|
|
|
// ✅ Final 결과 처리 추가 (TV 환경 대응)
|
|
// TV에서는 final result가 와야 API 호출이 가능할 수 있음
|
|
if (result.isFinal) {
|
|
dlog(
|
|
`[VoiceInput]-[WebSpeech] ACTION-EVENT: WEB_SPEECH_FINAL_RESULT 디스패치 - finalText="${result.transcript}"`
|
|
);
|
|
dispatch({
|
|
type: types.WEB_SPEECH_FINAL_RESULT,
|
|
payload: {
|
|
finalText: result.transcript,
|
|
confidence: result.confidence,
|
|
},
|
|
});
|
|
}
|
|
});
|
|
|
|
webSpeechService.on('error', (errorInfo) => {
|
|
derror(
|
|
`[VoiceInput]-[WebSpeech] ACTION-EVENT: WEB_SPEECH_ERROR 디스패치 - error="${errorInfo.error}"`
|
|
);
|
|
dispatch({
|
|
type: types.WEB_SPEECH_ERROR,
|
|
payload: errorInfo,
|
|
});
|
|
});
|
|
|
|
webSpeechService.on('end', () => {
|
|
dlog('[VoiceInput]-[WebSpeech] ACTION-EVENT: WEB_SPEECH_END 디스패치');
|
|
dispatch({
|
|
type: types.WEB_SPEECH_END,
|
|
});
|
|
});
|
|
|
|
dlog('[VoiceInput]-[WebSpeech] ACTION-INIT: ✅ WEB_SPEECH_INITIALIZED 디스패치');
|
|
dispatch({
|
|
type: types.WEB_SPEECH_INITIALIZED,
|
|
});
|
|
|
|
return true;
|
|
};
|
|
|
|
/**
|
|
* 음성 인식 시작
|
|
*/
|
|
export const startWebSpeech = () => (dispatch) => {
|
|
dlog('[VoiceInput]-[WebSpeech] ACTION-START: 음성 인식 시작 요청');
|
|
const started = webSpeechService.start();
|
|
|
|
if (!started) {
|
|
derror('[VoiceInput]-[WebSpeech] ACTION-START: ❌ 음성 인식 시작 실패');
|
|
dispatch({
|
|
type: types.WEB_SPEECH_ERROR,
|
|
payload: { error: 'Failed to start', message: 'Failed to start recognition' },
|
|
});
|
|
}
|
|
};
|
|
|
|
/**
|
|
* 음성 인식 중지
|
|
*/
|
|
export const stopWebSpeech = () => (dispatch) => {
|
|
dlog('[VoiceInput]-[WebSpeech] ACTION-STOP: 음성 인식 중지 요청');
|
|
webSpeechService.stop();
|
|
};
|
|
|
|
/**
|
|
* 음성 인식 중단
|
|
*/
|
|
export const abortWebSpeech = () => (dispatch) => {
|
|
dlog('[VoiceInput]-[WebSpeech] ACTION-ABORT: 음성 인식 중단 (즉시) 요청');
|
|
webSpeechService.abort();
|
|
};
|
|
|
|
/**
|
|
* 리소스 정리
|
|
*/
|
|
export const cleanupWebSpeech = () => (dispatch) => {
|
|
dlog('[VoiceInput]-[WebSpeech] ACTION-CLEANUP: 리소스 정리 요청');
|
|
webSpeechService.cleanup();
|
|
dispatch({
|
|
type: types.WEB_SPEECH_CLEANUP,
|
|
});
|
|
dlog('[VoiceInput]-[WebSpeech] ACTION-CLEANUP: ✅ WEB_SPEECH_CLEANUP 디스패치');
|
|
};
|
|
|
|
/**
|
|
* STT 텍스트 초기화 (이전 음성 인식 결과 제거)
|
|
*/
|
|
export const clearSTTText = () => (dispatch) => {
|
|
dlog('[VoiceInput]-[WebSpeech] ACTION-CLEAR: STT 텍스트 초기화 요청');
|
|
dispatch({
|
|
type: types.VOICE_CLEAR_STATE,
|
|
});
|
|
dlog('[VoiceInput]-[WebSpeech] ACTION-CLEAR: ✅ VOICE_CLEAR_STATE 디스패치');
|
|
};
|