Add a second Electron entry under src/installer-rp/ + installer-rp/ launched by `npm run installer:rp`. It is structurally separate from the music quiz installer (own tsconfig, own preload, own renderer), shares the existing styles via a relative link, and exposes a three-step UI: pick a 음악퀴즈, run the install, then a 완료 page that can open the resourcepacks folder or quit. The install IPC handler currently scaffolds the flow per docs/add.md (yt-dlp prep → music download → image normalize → zip build → place at %appdata%/.minecraft/resourcepacks/) but the actual work is still TODO. Cancel/cleanup of %appdata%/.mc_custom/.temp/ is wired up so that future iterations can plug each step in without rewiring. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import { contextBridge, ipcRenderer } from 'electron'
|
|
import type { RpFetchedPack } from './types.js'
|
|
|
|
const api = {
|
|
/** manifest 와 각 음악퀴즈의 file/list/<key>.json 까지 한 번에 로드. */
|
|
loadPacks: (manifestUrl?: string): Promise<RpFetchedPack[]> =>
|
|
ipcRenderer.invoke('rp:packs:load', manifestUrl),
|
|
/** 음악퀴즈 키를 선택. */
|
|
selectPack: (packKey: string): Promise<void> =>
|
|
ipcRenderer.invoke('rp:packs:select', packKey),
|
|
|
|
/** 리소스팩 빌드/설치 시작. 완료 또는 취소될 때까지 resolve 되지 않을 수 있음. */
|
|
startInstall: (): Promise<{ resourcepackPath: string }> =>
|
|
ipcRenderer.invoke('rp:install:start'),
|
|
/** 진행 중인 설치 취소. 임시 파일 정리 후 종료. */
|
|
cancelInstall: (): Promise<void> =>
|
|
ipcRenderer.invoke('rp:install:cancel'),
|
|
|
|
/** %appdata%/.minecraft/resourcepacks/ 폴더를 OS 파일 탐색기로 연다. */
|
|
openResourcepackFolder: (): Promise<void> =>
|
|
ipcRenderer.invoke('rp:finish:openFolder'),
|
|
/** 프로그램 종료. */
|
|
quit: (): Promise<void> => ipcRenderer.invoke('rp:quit'),
|
|
|
|
/** 로그 스트림 구독. */
|
|
onLog: (handler: (line: string) => void): (() => void) => {
|
|
const listener = (_event: unknown, line: string) => handler(line)
|
|
ipcRenderer.on('log', listener)
|
|
return () => ipcRenderer.removeListener('log', listener)
|
|
}
|
|
}
|
|
|
|
contextBridge.exposeInMainWorld('rpInstaller', api)
|
|
|
|
declare global {
|
|
interface Window {
|
|
rpInstaller: typeof api
|
|
}
|
|
}
|