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
|
|
@ -4,7 +4,14 @@
|
|||
|
||||
import type { Key as NutKey } from '@nut-tree-fork/nut-js'
|
||||
import { getLogger } from '../LoggerService'
|
||||
import { sendWin32UnicodeReplacement, sendWin32UnicodeText } from '../../utils/win32-unicode-input'
|
||||
import {
|
||||
isWin32SendInputAvailable,
|
||||
sendWin32Backspaces,
|
||||
sendWin32PasteChord,
|
||||
sendWin32SpaceKey,
|
||||
sendWin32UnicodeReplacement,
|
||||
sendWin32UnicodeText,
|
||||
} from '../../utils/win32-unicode-input'
|
||||
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
|
||||
|
||||
const logger = getLogger('TextInsertService')
|
||||
|
|
@ -99,8 +106,15 @@ export class NutKeyboardPort implements KeyboardPort {
|
|||
private readonly _load: NutModuleLoader = loadNutModule
|
||||
) {}
|
||||
|
||||
private _useWin32NativeSendInput(): boolean {
|
||||
return this._platform === 'win32' && this._load === loadNutModule
|
||||
}
|
||||
|
||||
/** 붙여넣기 단축키를 한 번의 코드(chord)로 보내 await 사이에 modifier 가 눌린 채 남지 않게 한다. */
|
||||
async paste(): Promise<void> {
|
||||
if (this._useWin32NativeSendInput() && sendWin32PasteChord()) {
|
||||
return
|
||||
}
|
||||
const nut = await this._ensureNut()
|
||||
const pasteModKey = this._platform === 'darwin' ? nut.Key.LeftSuper : nut.Key.LeftControl
|
||||
await nut.native.click(pasteModKey, nut.Key.V)
|
||||
|
|
@ -109,7 +123,7 @@ export class NutKeyboardPort implements KeyboardPort {
|
|||
/** 텍스트 전체를 네이티브 호출 한 번으로 타이핑한다 (글자 사이 JS 대기 없음). */
|
||||
async type(text: string): Promise<void> {
|
||||
if (!text) return
|
||||
if (this._platform === 'win32' && this._load === loadNutModule && sendWin32UnicodeText(text)) {
|
||||
if (this._useWin32NativeSendInput() && sendWin32UnicodeText(text)) {
|
||||
return
|
||||
}
|
||||
const nut = await this._ensureNut()
|
||||
|
|
@ -117,6 +131,9 @@ export class NutKeyboardPort implements KeyboardPort {
|
|||
}
|
||||
|
||||
async commitComposition(): Promise<void> {
|
||||
if (this._useWin32NativeSendInput() && sendWin32SpaceKey()) {
|
||||
return
|
||||
}
|
||||
const nut = await this._ensureNut()
|
||||
await nut.native.click(nut.Key.Space)
|
||||
}
|
||||
|
|
@ -127,8 +144,7 @@ export class NutKeyboardPort implements KeyboardPort {
|
|||
options: { commitComposition?: boolean } = {}
|
||||
): Promise<boolean> {
|
||||
if (
|
||||
this._platform === 'win32' &&
|
||||
this._load === loadNutModule &&
|
||||
this._useWin32NativeSendInput() &&
|
||||
sendWin32UnicodeReplacement(deleteCount, text, options)
|
||||
) {
|
||||
return true
|
||||
|
|
@ -136,9 +152,12 @@ export class NutKeyboardPort implements KeyboardPort {
|
|||
return false
|
||||
}
|
||||
|
||||
/** 백스페이스를 count 번 — 키마다 네이티브 keyTap 한 번이다. */
|
||||
/** 백스페이스를 count 번 — Windows 는 단일 SendInput 배치로, 그 외 OS 는 네이티브 keyTap 으로 전송한다. */
|
||||
async backspace(count: number): Promise<void> {
|
||||
if (count <= 0) return
|
||||
if (this._useWin32NativeSendInput() && sendWin32Backspaces(count)) {
|
||||
return
|
||||
}
|
||||
const nut = await this._ensureNut()
|
||||
for (let index = 0; index < count; index += 1) {
|
||||
await nut.native.click(nut.Key.Backspace)
|
||||
|
|
@ -146,10 +165,13 @@ export class NutKeyboardPort implements KeyboardPort {
|
|||
}
|
||||
|
||||
/**
|
||||
* nut-js 를 미리 불러 둔다. 첫 로딩이 수 초 걸려(실측 2026-10-03: 재시작 뒤 첫 제안 수락이 4.9초,
|
||||
* 그중 nut-js 로딩 4.8초) 사용자가 수락하고 한참 기다렸다. 실패는 여기서 삼키고 실제 삽입 때 다시 알린다.
|
||||
* 키 입력 백엔드를 미리 불러 둔다.
|
||||
* Windows 에서는 이미 로드된 koffi user32 SendInput 을 그대로 쓰므로 무거운 nut-js 를 로드하지 않는다.
|
||||
*/
|
||||
async preload(): Promise<void> {
|
||||
if (this._useWin32NativeSendInput() && isWin32SendInputAvailable()) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await this._ensureNut()
|
||||
} catch {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue