feat(V2-1a): Monorepo 구조 전환 — apps/desktop으로 V1 이동

- npm workspaces 루트 (apps/*, packages/*) 세팅
- V1 전체를 apps/desktop/으로 git mv (src, resources, tests, sidecar,
  scripts, electron.vite.config.ts, electron-builder.yml, vitest.config.ts,
  tsconfig.node.json, tsconfig.web.json)
- apps/desktop/package.json 신규 (name=@d3ro/desktop)
- productName: 'd3ro-voice' 명시 — app.getName()을 고정하여 userData 경로
  %APPDATA%\d3ro-voice\ 그대로 유지 (기존 DB/설정 연속성 보장)
- 루트 package.json을 workspace 루트로 재구성, 공통 devDep만 유지
  (typescript, eslint, prettier)
- turbo.json, tsconfig.base.json 추가 (Turborepo 자체 설치는 별도 sub-phase)
- memory/project_status.md 생성 (규칙 13)

검증:
- npm run typecheck 통과
- npm run build 통과 (electron-vite main+preload+renderer)
- npm run dev 실제 실행 → DB/핫키/Ollama 자동 실행 모두 정상
This commit is contained in:
yunchan8804 2026-04-08 14:04:41 +09:00
parent 3a160b9032
commit 45a580878a
178 changed files with 214 additions and 0 deletions

View file

@ -1,126 +0,0 @@
// src/main/services/SoundEffectService.ts
// 녹음 시작/종료/에러/취소 효과음 재생. 설계서 01 ISoundEffectService 구현.
// fire-and-forget 패턴, WAV 프리로드(메모리 캐싱).
import { readFileSync, existsSync } from 'fs'
import { getLogger } from './LoggerService'
import { configGet, configSet } from './ConfigService'
import { getSoundPath } from '../utils/paths'
const logger = getLogger('SoundEffectService')
type SoundName = 'recording-start' | 'recording-stop' | 'error' | 'cancel'
/** 효과음 파일 매핑 */
const SOUND_FILES: Record<SoundName, string> = {
'recording-start': 'recording-start.wav',
'recording-stop': 'recording-stop.wav',
'error': 'error.wav',
'cancel': 'error.wav' // cancel은 error와 동일
}
/** 프리로드된 WAV 바이너리 캐시 */
const soundCache = new Map<SoundName, Buffer>()
class SoundEffectService {
private _enabled = true
/**
* .
* bootstrap에서 .
*/
initialize(): void {
this._enabled = configGet('soundEnabled')
for (const [name, filename] of Object.entries(SOUND_FILES)) {
const filePath = getSoundPath(filename)
if (existsSync(filePath)) {
try {
const buffer = readFileSync(filePath)
soundCache.set(name as SoundName, buffer)
logger.debug(`Sound preloaded: ${name} (${buffer.length} bytes)`)
} catch (err) {
logger.warn(`Failed to preload sound ${name}: ${err instanceof Error ? err.message : String(err)}`)
}
} else {
logger.debug(`Sound file not found: ${filePath}`)
}
}
logger.info(`SoundEffectService initialized (${soundCache.size} sounds cached, enabled: ${this._enabled})`)
}
/**
* (fire-and-forget).
* . .
*/
play(sound: SoundName): void {
if (!this._enabled) return
const buffer = soundCache.get(sound)
if (!buffer) {
logger.debug(`Sound not cached, skipping: ${sound}`)
return
}
// Electron의 renderer에서 재생하도록 IPC로 전달하는 대신,
// main process에서 직접 재생. node-wav-player 또는 child_process 사용.
// 가장 간단한 방법: PowerShell로 WAV 재생 (Windows)
this._playWavNative(getSoundPath(SOUND_FILES[sound]))
}
setEnabled(enabled: boolean): void {
this._enabled = enabled
configSet('soundEnabled', enabled)
logger.info(`Sound effects ${enabled ? 'enabled' : 'disabled'}`)
}
isEnabled(): boolean {
return this._enabled
}
dispose(): void {
soundCache.clear()
logger.info('SoundEffectService disposed')
}
/**
* Windows에서 WAV .
* PowerShell의 SoundPlayer를 (fire-and-forget).
*/
private _playWavNative(filePath: string): void {
if (!existsSync(filePath)) return
try {
const { exec } = require('child_process') as typeof import('child_process')
if (process.platform === 'win32') {
// Windows: PowerShell SoundPlayer (비동기, 프로세스 분리)
const escapedPath = filePath.replace(/'/g, "''")
exec(
`powershell -NoProfile -Command "(New-Object Media.SoundPlayer '${escapedPath}').PlaySync()"`,
{ windowsHide: true },
(err: Error | null) => {
if (err) {
logger.debug(`Sound play failed: ${err.message}`)
}
}
)
}
// macOS/Linux는 추후 지원 (afplay, aplay)
} catch (err) {
logger.debug(`Sound play error: ${err instanceof Error ? err.message : String(err)}`)
}
}
}
// ── 싱글톤 ──
let instance: SoundEffectService | null = null
export function getSoundEffectService(): SoundEffectService {
if (!instance) {
instance = new SoundEffectService()
}
return instance
}