feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
29
apps/desktop/src/main/ipc/renderer-broadcast.ts
Normal file
29
apps/desktop/src/main/ipc/renderer-broadcast.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// src/main/ipc/renderer-broadcast.ts
|
||||
// 메인/전체 렌더러 창으로 안전하게 IPC 이벤트를 송신하는 공용 헬퍼.
|
||||
|
||||
import { BrowserWindow } from 'electron'
|
||||
import { getMainWindow } from '../windows/WindowManager'
|
||||
|
||||
function canSendToWindow(win: BrowserWindow | null | undefined): win is BrowserWindow {
|
||||
if (!win || win.isDestroyed()) return false
|
||||
const contents = win.webContents as { isDestroyed?: () => boolean } | undefined
|
||||
if (!contents) return false
|
||||
return typeof contents.isDestroyed === 'function' ? !contents.isDestroyed() : true
|
||||
}
|
||||
|
||||
/** 메인 창이 살아 있을 때만 IPC 채널로 데이터를 전송한다. */
|
||||
export function safeSendToRenderer(channel: string, data: unknown): void {
|
||||
const win = getMainWindow()
|
||||
if (canSendToWindow(win)) {
|
||||
win.webContents.send(channel, data)
|
||||
}
|
||||
}
|
||||
|
||||
/** 파괴되지 않은 모든 BrowserWindow 렌더러에 IPC 이벤트를 브로드캐스트한다. */
|
||||
export function broadcastToAllWindows(channel: string, payload: unknown): void {
|
||||
for (const win of BrowserWindow.getAllWindows()) {
|
||||
if (canSendToWindow(win)) {
|
||||
win.webContents.send(channel, payload)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue