mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-16 13:03:31 +08:00
- Restore full Ink TUI startup chain (cli.tsx entry point) - Create stub .md files for verify skill (Bun text loader hang fix) - Create stub types for filePersistence and SDK modules - Fix Enter key not working (modifiers-napi missing, added try-catch) - Remove overly conservative LOCAL_RECOVERY early return - Add README with setup instructions - Add .env.example template - Add bin/claude-haha entry script and preload.ts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
export type ModifierKey = 'shift' | 'command' | 'control' | 'option'
|
|
|
|
let prewarmed = false
|
|
|
|
/**
|
|
* Pre-warm the native module by loading it in advance.
|
|
* Call this early to avoid delay on first use.
|
|
*/
|
|
export function prewarmModifiers(): void {
|
|
if (prewarmed || process.platform !== 'darwin') {
|
|
return
|
|
}
|
|
prewarmed = true
|
|
// Load module in background
|
|
try {
|
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
const { prewarm } = require('modifiers-napi') as { prewarm: () => void }
|
|
prewarm()
|
|
} catch {
|
|
// Ignore errors during prewarm
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Check if a specific modifier key is currently pressed (synchronous).
|
|
*/
|
|
export function isModifierPressed(modifier: ModifierKey): boolean {
|
|
if (process.platform !== 'darwin') {
|
|
return false
|
|
}
|
|
try {
|
|
// Dynamic import to avoid loading native module at top level
|
|
const { isModifierPressed: nativeIsModifierPressed } =
|
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
require('modifiers-napi') as { isModifierPressed: (m: string) => boolean }
|
|
return nativeIsModifierPressed(modifier)
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|