chore(deps): upgrade to Electron 43, Vite 8, Vitest 5 and pin Node 24
Electron 33.4.11 -> 43.8.10, electron-vite 6, Vite 8.3.8, Vitest 5.1.0, Node engines 24.x. Electron 43 made clipboard text read/write asynchronous, so text insertion, selected-text capture and the popup copy channel now await it; includes the async restore regression test. Evidence: docs/evidence/2026-11-17-backlog-operations.md (GAP-SEC-01).
This commit is contained in:
parent
876e72ea2f
commit
e0b1ceaa75
16 changed files with 2755 additions and 3544 deletions
|
|
@ -248,7 +248,7 @@ export class ScreenContextService {
|
|||
// 1. 기존 클립보드 저장 + 온전히 되돌릴 수 있는지 판정 (삽입과 같은 정책)
|
||||
// 탐색기에서 복사한 파일·Excel 셀처럼 다 되돌릴 수 없으면 캡처를 건너뛴다 — 부가 문맥 하나 때문에
|
||||
// 사용자가 복사해 둔 것을 지우면 안 된다(예전엔 파일 복사본이 '비어 있음'으로 보여 clear() 됐다).
|
||||
const restore = planClipboardRestore(captureClipboard(port))
|
||||
const restore = planClipboardRestore(await captureClipboard(port))
|
||||
if (restore.kind === 'unrestorable' || (restore.kind === 'write' && restore.dropped.length > 0)) {
|
||||
logger.info('선택 텍스트 캡처 건너뜀: 클립보드를 온전히 되돌릴 수 없다')
|
||||
return null
|
||||
|
|
@ -271,7 +271,7 @@ export class ScreenContextService {
|
|||
await this._sleep(150)
|
||||
|
||||
// 5. 클립보드에서 텍스트 읽기
|
||||
const text = port.readText()
|
||||
const text = await port.readText()
|
||||
|
||||
// 6. 클립보드 복원
|
||||
this._restoreClipboard(restore)
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ export class TextInsertService extends EventEmitter {
|
|||
*/
|
||||
private async _insertViaClipboard(text: string): Promise<InsertMethod> {
|
||||
// 1. 기존 클립보드 저장 + 복원 가능성 판정
|
||||
const snapshot = this.saveClipboard()
|
||||
const snapshot = await this.saveClipboard()
|
||||
const plan = planClipboardRestore(snapshot)
|
||||
if (plan.kind === 'unrestorable') {
|
||||
logger.info(
|
||||
|
|
@ -225,7 +225,7 @@ export class TextInsertService extends EventEmitter {
|
|||
|
||||
try {
|
||||
// 2. 클립보드에 텍스트 설정
|
||||
this._clipboard.writeText(text)
|
||||
await this._clipboard.writeText(text)
|
||||
|
||||
// 짧은 지연: 일부 앱이 클립보드 변경을 받아들일 시간 필요
|
||||
await this._sleep(20)
|
||||
|
|
@ -239,14 +239,14 @@ export class TextInsertService extends EventEmitter {
|
|||
await this._sleep(250)
|
||||
|
||||
// 5. 클립보드 복원 (원래 내용으로 되돌림)
|
||||
if (this._restoreIfStillOurs(text, snapshot)) {
|
||||
if (await this._restoreIfStillOurs(text, snapshot)) {
|
||||
this.emit('clipboard-restored', {})
|
||||
}
|
||||
return 'clipboard'
|
||||
} catch (error) {
|
||||
// 실패 시에도 클립보드 복원 시도
|
||||
try {
|
||||
this._restoreIfStillOurs(text, snapshot)
|
||||
await this._restoreIfStillOurs(text, snapshot)
|
||||
} catch {
|
||||
logger.warn('Failed to restore clipboard after insert error')
|
||||
}
|
||||
|
|
@ -258,8 +258,8 @@ export class TextInsertService extends EventEmitter {
|
|||
* 클립보드가 아직 우리가 넣은 텍스트일 때만 되돌린다. 그 사이 사용자가 새로 복사했다면
|
||||
* 그 내용을 덮어쓰지 않는다 (writeText 자체가 실패한 경우도 여기서 걸러진다).
|
||||
*/
|
||||
private _restoreIfStillOurs(text: string, snapshot: ClipboardSnapshot<ClipboardImage>): boolean {
|
||||
if (this._clipboard.readText() !== text) {
|
||||
private async _restoreIfStillOurs(text: string, snapshot: ClipboardSnapshot<ClipboardImage>): Promise<boolean> {
|
||||
if (await this._clipboard.readText() !== text) {
|
||||
logger.debug('Clipboard changed during insert; skipping restore')
|
||||
return false
|
||||
}
|
||||
|
|
@ -277,7 +277,7 @@ export class TextInsertService extends EventEmitter {
|
|||
/**
|
||||
* 현재 클립보드 상태를 모든 포맷으로 캡처한다.
|
||||
*/
|
||||
saveClipboard(): ClipboardSnapshot<ClipboardImage> {
|
||||
saveClipboard(): Promise<ClipboardSnapshot<ClipboardImage>> {
|
||||
return captureClipboard(this._clipboard)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export interface ClipboardWriteData<TImage extends ClipboardImage> {
|
|||
/** 클립보드 IO 포트. 운영은 Electron clipboard, 테스트는 메모리 구현을 꽂는다. */
|
||||
export interface ClipboardPort<TImage extends ClipboardImage = ClipboardImage> {
|
||||
availableFormats(): string[]
|
||||
readText(): string
|
||||
readText(): string | Promise<string>
|
||||
readHTML(): string
|
||||
readRTF(): string
|
||||
readImage(): TImage
|
||||
|
|
@ -88,9 +88,9 @@ export function isStandardClipboardFormat(format: string): boolean {
|
|||
export const UNKNOWN_FORMATS = '<unknown>'
|
||||
|
||||
/** 현재 클립보드의 모든 포맷을 캡처한다. */
|
||||
export function captureClipboard<TImage extends ClipboardImage>(
|
||||
export async function captureClipboard<TImage extends ClipboardImage>(
|
||||
port: ClipboardPort<TImage>
|
||||
): ClipboardSnapshot<TImage> {
|
||||
): Promise<ClipboardSnapshot<TImage>> {
|
||||
const buffers: ClipboardBufferEntry[] = []
|
||||
const unreadable: string[] = []
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ export function captureClipboard<TImage extends ClipboardImage>(
|
|||
|
||||
return {
|
||||
formats,
|
||||
text: port.readText() || null,
|
||||
text: (await port.readText()) || null,
|
||||
html: port.readHTML() || null,
|
||||
rtf: port.readRTF() || null,
|
||||
image: image && !image.isEmpty() ? image : null,
|
||||
|
|
|
|||
|
|
@ -1072,5 +1072,7 @@ export function reapplyThemeToAllPopups(): void {
|
|||
// ── clipboard:copy IPC (ResultPopup에서 사용) ─────────
|
||||
|
||||
ipcMain.on(IPC_CHANNELS.CLIPBOARD.COPY, (_event, text: string) => {
|
||||
clipboard.writeText(text)
|
||||
void Promise.resolve(clipboard.writeText(text)).catch((error: unknown) => {
|
||||
logger.error('Clipboard copy failed', error)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue