asdf
Squash the current repository state back into one baseline commit while preserving the README reframing and repository contents. Constraint: User explicitly requested a single squashed commit with subject "asdf" Confidence: high Scope-risk: broad Reversibility: clean Directive: This commit intentionally rewrites published history; coordinate before future force-pushes Tested: git status clean; local history rewritten to one commit; force-pushed main to origin and instructkr Not-tested: Fresh clone verification after push
This commit is contained in:
commit
d2542c9a62
36
src/utils/modifiers.ts
Normal file
36
src/utils/modifiers.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
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
|
||||
}
|
||||
// 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)
|
||||
}
|
||||
Reference in New Issue
Block a user