ngx-keys 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +361 -7
- package/fesm2022/ngx-keys.mjs +324 -72
- package/fesm2022/ngx-keys.mjs.map +1 -1
- package/index.d.ts +193 -14
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-keys.mjs","sources":["../../../projects/ngx-keys/src/lib/keyboard-shortcuts.errors.ts","../../../projects/ngx-keys/src/lib/keyboard-shortcuts.ts","../../../projects/ngx-keys/src/public-api.ts","../../../projects/ngx-keys/src/ngx-keys.ts"],"sourcesContent":["/**\n * Centralized error messages for keyboard shortcuts service\n * This ensures consistency across the application and makes testing easier\n */\nexport const KeyboardShortcutsErrors = {\n // Registration errors\n SHORTCUT_ALREADY_REGISTERED: (id: string) => `Shortcut \"${id}\" already registered`,\n GROUP_ALREADY_REGISTERED: (id: string) => `Group \"${id}\" already registered`,\n KEY_CONFLICT: (conflictId: string) => `Key conflict with \"${conflictId}\"`,\n SHORTCUT_IDS_ALREADY_REGISTERED: (ids: string[]) => `Shortcut IDs already registered: ${ids.join(', ')}`,\n DUPLICATE_SHORTCUTS_IN_GROUP: (ids: string[]) => `Duplicate shortcuts in group: ${ids.join(', ')}`,\n KEY_CONFLICTS_IN_GROUP: (conflicts: string[]) => `Key conflicts: ${conflicts.join(', ')}`,\n \n // Operation errors\n SHORTCUT_NOT_REGISTERED: (id: string) => `Shortcut \"${id}\" not registered`,\n GROUP_NOT_REGISTERED: (id: string) => `Group \"${id}\" not registered`,\n \n // Activation/Deactivation errors\n CANNOT_ACTIVATE_SHORTCUT: (id: string) => `Cannot activate shortcut \"${id}\": not registered`,\n CANNOT_DEACTIVATE_SHORTCUT: (id: string) => `Cannot deactivate shortcut \"${id}\": not registered`,\n CANNOT_ACTIVATE_GROUP: (id: string) => `Cannot activate group \"${id}\": not registered`,\n CANNOT_DEACTIVATE_GROUP: (id: string) => `Cannot deactivate group \"${id}\": not registered`,\n \n // Unregistration errors\n CANNOT_UNREGISTER_SHORTCUT: (id: string) => `Cannot unregister shortcut \"${id}\": not registered`,\n CANNOT_UNREGISTER_GROUP: (id: string) => `Cannot unregister group \"${id}\": not registered`,\n} as const;\n\n/**\n * Error types for type safety\n */\nexport type KeyboardShortcutsErrorType = keyof typeof KeyboardShortcutsErrors;\n\n/**\n * Custom error class for keyboard shortcuts\n */\nexport class KeyboardShortcutError extends Error {\n constructor(\n public readonly errorType: KeyboardShortcutsErrorType,\n message: string,\n public readonly context?: Record<string, any>\n ) {\n super(message);\n this.name = 'KeyboardShortcutError';\n }\n}\n\n/**\n * Error factory for creating consistent errors\n */\nexport class KeyboardShortcutsErrorFactory {\n static shortcutAlreadyRegistered(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'SHORTCUT_ALREADY_REGISTERED',\n KeyboardShortcutsErrors.SHORTCUT_ALREADY_REGISTERED(id),\n { shortcutId: id }\n );\n }\n\n static groupAlreadyRegistered(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'GROUP_ALREADY_REGISTERED',\n KeyboardShortcutsErrors.GROUP_ALREADY_REGISTERED(id),\n { groupId: id }\n );\n }\n\n static keyConflict(conflictId: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'KEY_CONFLICT',\n KeyboardShortcutsErrors.KEY_CONFLICT(conflictId),\n { conflictId }\n );\n }\n\n static shortcutIdsAlreadyRegistered(ids: string[]): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'SHORTCUT_IDS_ALREADY_REGISTERED',\n KeyboardShortcutsErrors.SHORTCUT_IDS_ALREADY_REGISTERED(ids),\n { duplicateIds: ids }\n );\n }\n\n static duplicateShortcutsInGroup(ids: string[]): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'DUPLICATE_SHORTCUTS_IN_GROUP',\n KeyboardShortcutsErrors.DUPLICATE_SHORTCUTS_IN_GROUP(ids),\n { duplicateIds: ids }\n );\n }\n\n static keyConflictsInGroup(conflicts: string[]): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'KEY_CONFLICTS_IN_GROUP',\n KeyboardShortcutsErrors.KEY_CONFLICTS_IN_GROUP(conflicts),\n { conflicts }\n );\n }\n\n static shortcutNotRegistered(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'SHORTCUT_NOT_REGISTERED',\n KeyboardShortcutsErrors.SHORTCUT_NOT_REGISTERED(id),\n { shortcutId: id }\n );\n }\n\n static groupNotRegistered(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'GROUP_NOT_REGISTERED',\n KeyboardShortcutsErrors.GROUP_NOT_REGISTERED(id),\n { groupId: id }\n );\n }\n\n static cannotActivateShortcut(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'CANNOT_ACTIVATE_SHORTCUT',\n KeyboardShortcutsErrors.CANNOT_ACTIVATE_SHORTCUT(id),\n { shortcutId: id }\n );\n }\n\n static cannotDeactivateShortcut(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'CANNOT_DEACTIVATE_SHORTCUT',\n KeyboardShortcutsErrors.CANNOT_DEACTIVATE_SHORTCUT(id),\n { shortcutId: id }\n );\n }\n\n static cannotActivateGroup(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'CANNOT_ACTIVATE_GROUP',\n KeyboardShortcutsErrors.CANNOT_ACTIVATE_GROUP(id),\n { groupId: id }\n );\n }\n\n static cannotDeactivateGroup(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'CANNOT_DEACTIVATE_GROUP',\n KeyboardShortcutsErrors.CANNOT_DEACTIVATE_GROUP(id),\n { groupId: id }\n );\n }\n\n static cannotUnregisterShortcut(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'CANNOT_UNREGISTER_SHORTCUT',\n KeyboardShortcutsErrors.CANNOT_UNREGISTER_SHORTCUT(id),\n { shortcutId: id }\n );\n }\n\n static cannotUnregisterGroup(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'CANNOT_UNREGISTER_GROUP',\n KeyboardShortcutsErrors.CANNOT_UNREGISTER_GROUP(id),\n { groupId: id }\n );\n }\n}\n","import { DestroyRef, Injectable, OnDestroy, PLATFORM_ID, inject, signal, computed } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\nimport { KeyboardShortcut, KeyboardShortcutActiveUntil, KeyboardShortcutGroup, KeyboardShortcutUI, KeyStep } from './keyboard-shortcut.interface'\nimport { KeyboardShortcutsErrorFactory } from './keyboard-shortcuts.errors';\nimport { Observable, take } from 'rxjs';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class KeyboardShortcuts implements OnDestroy {\n private readonly shortcuts = new Map<string, KeyboardShortcut>();\n private readonly groups = new Map<string, KeyboardShortcutGroup>();\n private readonly activeShortcuts = new Set<string>();\n private readonly activeGroups = new Set<string>();\n private readonly currentlyDownKeys = new Set<string>();\n \n // Single consolidated state signal - reduces memory overhead\n private readonly state = signal({\n shortcuts: new Map<string, KeyboardShortcut>(),\n groups: new Map<string, KeyboardShortcutGroup>(),\n activeShortcuts: new Set<string>(),\n activeGroups: new Set<string>(),\n version: 0 // for change detection optimization\n });\n \n // Primary computed signal - consumers derive what they need from this\n readonly shortcuts$ = computed(() => {\n const state = this.state();\n const activeShortcuts = Array.from(state.activeShortcuts)\n .map(id => state.shortcuts.get(id))\n .filter((s): s is KeyboardShortcut => s !== undefined);\n \n const inactiveShortcuts = Array.from(state.shortcuts.values())\n .filter(s => !state.activeShortcuts.has(s.id));\n \n return {\n active: activeShortcuts,\n inactive: inactiveShortcuts,\n all: Array.from(state.shortcuts.values()),\n groups: {\n active: Array.from(state.activeGroups),\n inactive: Array.from(state.groups.keys())\n .filter(id => !state.activeGroups.has(id))\n }\n };\n });\n\n // Optional: Pre-formatted UI signal for components that need it\n readonly shortcutsUI$ = computed(() => {\n const shortcuts = this.shortcuts$();\n return {\n active: shortcuts.active.map(s => this.formatShortcutForUI(s)),\n inactive: shortcuts.inactive.map(s => this.formatShortcutForUI(s)),\n all: shortcuts.all.map(s => this.formatShortcutForUI(s))\n };\n });\n \n private readonly keydownListener = this.handleKeydown.bind(this);\n private readonly keyupListener = this.handleKeyup.bind(this);\n private readonly blurListener = this.handleWindowBlur.bind(this);\n private readonly visibilityListener = this.handleVisibilityChange.bind(this);\n private isListening = false;\n protected isBrowser: boolean;\n /** Default timeout (ms) for completing a multi-step sequence */\n protected sequenceTimeout = 2000;\n\n /** Runtime state for multi-step sequences */\n private pendingSequence: {\n shortcutId: string;\n stepIndex: number;\n timerId: any;\n } | null = null;\n\n constructor() {\n // Use try-catch to handle injection context for better testability\n try {\n const platformId = inject(PLATFORM_ID);\n this.isBrowser = isPlatformBrowser(platformId);\n } catch {\n // Fallback for testing - assume browser environment\n this.isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';\n }\n\n if (this.isBrowser) {\n this.startListening();\n }\n }\n\n ngOnDestroy(): void {\n this.stopListening();\n }\n\n /**\n * Batch updates and increment version for change detection\n */\n private updateState(): void {\n this.state.update(current => ({\n shortcuts: new Map(this.shortcuts),\n groups: new Map(this.groups),\n activeShortcuts: new Set(this.activeShortcuts),\n activeGroups: new Set(this.activeGroups),\n version: current.version + 1\n }));\n }\n\n /**\n * Utility method for UI formatting\n */\n formatShortcutForUI(shortcut: KeyboardShortcut): KeyboardShortcutUI {\n return {\n id: shortcut.id,\n keys: this.formatStepsForDisplay(shortcut.keys ?? shortcut.steps ?? [], false),\n macKeys: this.formatStepsForDisplay(shortcut.macKeys ?? shortcut.macSteps ?? [], true),\n description: shortcut.description\n };\n }\n\n /**\n * Utility method for batch operations - reduces signal updates\n */\n batchUpdate(operations: () => void): void {\n operations();\n this.updateState();\n }\n\n /**\n * Format keys for display with proper Unicode symbols\n */\n private formatKeysForDisplay(keys: string[], isMac = false): string {\n const keyMap: Record<string, string> = isMac ? {\n 'ctrl': '⌃',\n 'alt': '⌥', \n 'shift': '⇧',\n 'meta': '⌘',\n 'cmd': '⌘',\n 'command': '⌘'\n } : {\n 'ctrl': 'Ctrl',\n 'alt': 'Alt',\n 'shift': 'Shift', \n 'meta': 'Win'\n };\n\n return keys\n .map(key => keyMap[key.toLowerCase()] || key.toUpperCase())\n .join('+');\n }\n\n private formatStepsForDisplay(steps: string[] | string[][], isMac = false): string {\n if (!steps) return '';\n\n // If the first element is an array, assume steps is string[][]\n const normalized = this.normalizeToSteps(steps as KeyStep[] | string[]);\n if (normalized.length === 0) return '';\n if (normalized.length === 1) return this.formatKeysForDisplay(normalized[0], isMac);\n return normalized.map(step => this.formatKeysForDisplay(step, isMac)).join(', ');\n }\n\n private normalizeToSteps(input: KeyStep[] | string[]): KeyStep[] {\n if (!input) return [];\n // If first element is an array, assume already KeyStep[]\n if (Array.isArray(input[0])) {\n return input as KeyStep[];\n }\n // Single step array\n return [input as string[]];\n }\n\n /**\n * Check if a key combination is already registered\n * @returns The ID of the conflicting shortcut, or null if no conflict\n */\n private findConflict(newShortcut: KeyboardShortcut): string | null {\n for (const existing of this.shortcuts.values()) {\n // Compare single-step shapes if provided\n if (newShortcut.keys && existing.keys && this.keysMatch(newShortcut.keys, existing.keys)) {\n return existing.id;\n }\n if (newShortcut.macKeys && existing.macKeys && this.keysMatch(newShortcut.macKeys, existing.macKeys)) {\n return existing.id;\n }\n\n // Compare multi-step shapes\n if (newShortcut.steps && existing.steps && this.stepsMatch(newShortcut.steps, existing.steps)) {\n return existing.id;\n }\n if (newShortcut.macSteps && existing.macSteps && this.stepsMatch(newShortcut.macSteps, existing.macSteps)) {\n return existing.id;\n }\n }\n return null;\n }\n\n /**\n * Register a single keyboard shortcut\n * @throws KeyboardShortcutError if shortcut ID is already registered or key combination is in use\n */\n register(shortcut: KeyboardShortcut): void {\n if (this.shortcuts.has(shortcut.id)) {\n throw KeyboardShortcutsErrorFactory.shortcutAlreadyRegistered(shortcut.id);\n }\n\n const conflictId = this.findConflict(shortcut);\n if (conflictId) {\n throw KeyboardShortcutsErrorFactory.keyConflict(conflictId);\n }\n \n this.shortcuts.set(shortcut.id, shortcut);\n this.activeShortcuts.add(shortcut.id);\n this.updateState();\n\n this.setupActiveUntil(\n shortcut.activeUntil,\n this.unregister.bind(this, shortcut.id),\n );\n }\n\n /**\n * Register multiple keyboard shortcuts as a group\n * @throws KeyboardShortcutError if group ID is already registered or if any shortcut ID or key combination conflicts\n */\n registerGroup(groupId: string, shortcuts: KeyboardShortcut[], activeUntil?: KeyboardShortcutActiveUntil): void {\n // Check if group ID already exists\n if (this.groups.has(groupId)) {\n throw KeyboardShortcutsErrorFactory.groupAlreadyRegistered(groupId);\n }\n \n // Check for duplicate shortcut IDs and key combination conflicts\n const duplicateIds: string[] = [];\n const keyConflicts: string[] = [];\n shortcuts.forEach(shortcut => {\n if (this.shortcuts.has(shortcut.id)) {\n duplicateIds.push(shortcut.id);\n }\n const conflictId = this.findConflict(shortcut);\n if (conflictId) {\n keyConflicts.push(`\"${shortcut.id}\" conflicts with \"${conflictId}\"`);\n }\n });\n \n if (duplicateIds.length > 0) {\n throw KeyboardShortcutsErrorFactory.shortcutIdsAlreadyRegistered(duplicateIds);\n }\n\n if (keyConflicts.length > 0) {\n throw KeyboardShortcutsErrorFactory.keyConflictsInGroup(keyConflicts);\n }\n \n // Validate that all shortcuts have unique IDs within the group\n const groupIds = new Set<string>();\n const duplicatesInGroup: string[] = [];\n shortcuts.forEach(shortcut => {\n if (groupIds.has(shortcut.id)) {\n duplicatesInGroup.push(shortcut.id);\n } else {\n groupIds.add(shortcut.id);\n }\n });\n \n if (duplicatesInGroup.length > 0) {\n throw KeyboardShortcutsErrorFactory.duplicateShortcutsInGroup(duplicatesInGroup);\n }\n \n // Use batch update to reduce signal updates\n this.batchUpdate(() => {\n const group: KeyboardShortcutGroup = {\n id: groupId,\n shortcuts,\n active: true\n };\n \n this.groups.set(groupId, group);\n this.activeGroups.add(groupId);\n \n // Register individual shortcuts\n shortcuts.forEach(shortcut => {\n this.shortcuts.set(shortcut.id, shortcut);\n this.activeShortcuts.add(shortcut.id);\n });\n });\n\n this.setupActiveUntil(\n activeUntil,\n this.unregisterGroup.bind(this, groupId),\n );\n }\n\n /**\n * Unregister a single keyboard shortcut\n * @throws KeyboardShortcutError if shortcut ID doesn't exist\n */\n unregister(shortcutId: string): void {\n if (!this.shortcuts.has(shortcutId)) {\n throw KeyboardShortcutsErrorFactory.cannotUnregisterShortcut(shortcutId);\n }\n \n this.shortcuts.delete(shortcutId);\n this.activeShortcuts.delete(shortcutId);\n this.updateState();\n }\n\n /**\n * Unregister a group of keyboard shortcuts\n * @throws KeyboardShortcutError if group ID doesn't exist\n */\n unregisterGroup(groupId: string): void {\n const group = this.groups.get(groupId);\n if (!group) {\n throw KeyboardShortcutsErrorFactory.cannotUnregisterGroup(groupId);\n }\n \n this.batchUpdate(() => {\n group.shortcuts.forEach(shortcut => {\n this.shortcuts.delete(shortcut.id);\n this.activeShortcuts.delete(shortcut.id);\n });\n this.groups.delete(groupId);\n this.activeGroups.delete(groupId);\n });\n }\n\n /**\n * Activate a single keyboard shortcut\n * @throws KeyboardShortcutError if shortcut ID doesn't exist\n */\n activate(shortcutId: string): void {\n if (!this.shortcuts.has(shortcutId)) {\n throw KeyboardShortcutsErrorFactory.cannotActivateShortcut(shortcutId);\n }\n \n this.activeShortcuts.add(shortcutId);\n this.updateState();\n }\n\n /**\n * Deactivate a single keyboard shortcut\n * @throws KeyboardShortcutError if shortcut ID doesn't exist\n */\n deactivate(shortcutId: string): void {\n if (!this.shortcuts.has(shortcutId)) {\n throw KeyboardShortcutsErrorFactory.cannotDeactivateShortcut(shortcutId);\n }\n \n this.activeShortcuts.delete(shortcutId);\n this.updateState();\n }\n\n /**\n * Activate a group of keyboard shortcuts\n * @throws KeyboardShortcutError if group ID doesn't exist\n */\n activateGroup(groupId: string): void {\n const group = this.groups.get(groupId);\n if (!group) {\n throw KeyboardShortcutsErrorFactory.cannotActivateGroup(groupId);\n }\n \n this.batchUpdate(() => {\n group.active = true;\n this.activeGroups.add(groupId);\n group.shortcuts.forEach(shortcut => {\n this.activeShortcuts.add(shortcut.id);\n });\n });\n }\n\n /**\n * Deactivate a group of keyboard shortcuts\n * @throws KeyboardShortcutError if group ID doesn't exist\n */\n deactivateGroup(groupId: string): void {\n const group = this.groups.get(groupId);\n if (!group) {\n throw KeyboardShortcutsErrorFactory.cannotDeactivateGroup(groupId);\n }\n \n this.batchUpdate(() => {\n group.active = false;\n this.activeGroups.delete(groupId);\n group.shortcuts.forEach(shortcut => {\n this.activeShortcuts.delete(shortcut.id);\n });\n });\n }\n\n /**\n * Check if a shortcut is active\n */\n isActive(shortcutId: string): boolean {\n return this.activeShortcuts.has(shortcutId);\n }\n\n /**\n * Check if a shortcut is registered\n */\n isRegistered(shortcutId: string): boolean {\n return this.shortcuts.has(shortcutId);\n }\n\n /**\n * Check if a group is active\n */\n isGroupActive(groupId: string): boolean {\n return this.activeGroups.has(groupId);\n }\n\n /**\n * Check if a group is registered\n */\n isGroupRegistered(groupId: string): boolean {\n return this.groups.has(groupId);\n }\n\n /**\n * Get all registered shortcuts\n */\n getShortcuts(): ReadonlyMap<string, KeyboardShortcut> {\n return this.shortcuts;\n }\n\n /**\n * Get all registered groups\n */\n getGroups(): ReadonlyMap<string, KeyboardShortcutGroup> {\n return this.groups;\n }\n\n private startListening(): void {\n if (!this.isBrowser || this.isListening) {\n return;\n }\n \n // Listen to both keydown and keyup so we can maintain a Set of currently\n // pressed physical keys. We avoid passive:true because we may call\n // preventDefault() when matching shortcuts.\n document.addEventListener('keydown', this.keydownListener, { passive: false });\n document.addEventListener('keyup', this.keyupListener, { passive: false });\n // Listen for blur/visibility changes so we can clear the currently-down keys\n // and avoid stale state when the browser or tab loses focus.\n window.addEventListener('blur', this.blurListener);\n document.addEventListener('visibilitychange', this.visibilityListener);\n this.isListening = true;\n }\n\n private stopListening(): void {\n if (!this.isBrowser || !this.isListening) {\n return;\n }\n \n document.removeEventListener('keydown', this.keydownListener);\n document.removeEventListener('keyup', this.keyupListener);\n window.removeEventListener('blur', this.blurListener);\n document.removeEventListener('visibilitychange', this.visibilityListener);\n this.isListening = false;\n }\n\n protected handleKeydown(event: KeyboardEvent): void {\n // Update the currently down keys with this event's key\n this.updateCurrentlyDownKeysOnKeydown(event);\n\n // Build the pressed keys set used for matching. Prefer the currentlyDownKeys\n // if it contains more than one non-modifier key; otherwise fall back to the\n // traditional per-event pressed keys calculation for compatibility.\n // Use a Set for matching to avoid allocations and sorting on every event\n const pressedKeys = this.buildPressedKeysForMatch(event);\n const isMac = this.isMacPlatform();\n\n // If there is a pending multi-step sequence, try to advance it first\n if (this.pendingSequence) {\n const pending = this.pendingSequence;\n const shortcut = this.shortcuts.get(pending.shortcutId);\n if (shortcut) {\n const steps = isMac\n ? (shortcut.macSteps ?? shortcut.macKeys ?? shortcut.steps ?? shortcut.keys ?? [])\n : (shortcut.steps ?? shortcut.keys ?? shortcut.macSteps ?? shortcut.macKeys ?? []);\n const normalizedSteps = this.normalizeToSteps(steps as KeyStep[] | string[]);\n const expected = normalizedSteps[pending.stepIndex];\n\n // Use per-event pressed keys for advancing sequence steps. Relying on\n // the accumulated `currentlyDownKeys` can accidentally include keys\n // from previous steps (if tests or callers don't emit keyup), which\n // would prevent matching a simple single-key step like ['s'] after\n // a prior ['k'] step. Use getPressedKeys(event) which reflects the\n // actual modifier/main-key state for this event.\n const stepPressed = this.getPressedKeys(event);\n\n if (expected && this.keysMatch(stepPressed, expected)) {\n // Advance sequence\n clearTimeout(pending.timerId);\n pending.stepIndex += 1;\n\n if (pending.stepIndex >= normalizedSteps.length) {\n // Completed\n event.preventDefault();\n event.stopPropagation();\n try {\n shortcut.action();\n } catch (error) {\n console.error(`Error executing keyboard shortcut \"${shortcut.id}\":`, error);\n }\n this.pendingSequence = null;\n return;\n }\n\n // Reset timer for next step\n pending.timerId = setTimeout(() => { this.pendingSequence = null; }, this.sequenceTimeout);\n return;\n } else {\n // Cancel pending if doesn't match\n this.clearPendingSequence();\n }\n } else {\n // pending exists but shortcut not found\n this.clearPendingSequence();\n }\n }\n\n // No pending sequence - check active shortcuts for a match or sequence start\n for (const shortcutId of this.activeShortcuts) {\n const shortcut = this.shortcuts.get(shortcutId);\n if (!shortcut) continue;\n\n const steps = isMac\n ? (shortcut.macSteps ?? shortcut.macKeys ?? shortcut.steps ?? shortcut.keys ?? [])\n : (shortcut.steps ?? shortcut.keys ?? shortcut.macSteps ?? shortcut.macKeys ?? []);\n const normalizedSteps = this.normalizeToSteps(steps as KeyStep[] | string[]);\n\n const firstStep = normalizedSteps[0];\n if (this.keysMatch(pressedKeys, firstStep)) {\n if (normalizedSteps.length === 1) {\n // single-step\n event.preventDefault();\n event.stopPropagation();\n try {\n shortcut.action();\n } catch (error) {\n console.error(`Error executing keyboard shortcut \"${shortcut.id}\":`, error);\n }\n break;\n } else {\n // start pending sequence\n if (this.pendingSequence) {\n this.clearPendingSequence();\n }\n this.pendingSequence = {\n shortcutId: shortcut.id,\n stepIndex: 1,\n timerId: setTimeout(() => { this.pendingSequence = null; }, this.sequenceTimeout)\n };\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n }\n }\n }\n\n protected handleKeyup(event: KeyboardEvent): void {\n // Remove the key from currentlyDownKeys on keyup\n const key = event.key ? event.key.toLowerCase() : '';\n if (key && !['control', 'alt', 'shift', 'meta'].includes(key)) {\n this.currentlyDownKeys.delete(key);\n }\n }\n\n /**\n * Clear the currently-down keys. Exposed for testing and for use by\n * blur/visibilitychange handlers to avoid stale state when the page loses focus.\n */\n clearCurrentlyDownKeys(): void {\n this.currentlyDownKeys.clear();\n }\n\n protected handleWindowBlur(): void {\n this.clearCurrentlyDownKeys();\n // Clear any pressed keys and any pending multi-step sequence to avoid\n // stale state when the window loses focus.\n this.clearPendingSequence();\n }\n\n protected handleVisibilityChange(): void {\n if (document.visibilityState === 'hidden') {\n // When the document becomes hidden, clear both pressed keys and any\n // pending multi-step sequence. This prevents sequences from remaining\n // active when the user switches tabs or minimizes the window.\n this.clearCurrentlyDownKeys();\n this.clearPendingSequence();\n }\n }\n\n /**\n * Update the currentlyDownKeys set when keydown events happen.\n * Normalizes common keys (function keys, space, etc.) to the same values\n * used by getPressedKeys/keysMatch.\n */\n protected updateCurrentlyDownKeysOnKeydown(event: KeyboardEvent): void {\n const key = event.key ? event.key.toLowerCase() : '';\n\n // Ignore modifier-only keydown entries\n if (['control', 'alt', 'shift', 'meta'].includes(key)) {\n return;\n }\n\n // Normalize some special cases similar to the demo component's recording logic\n if (event.code && event.code.startsWith('F') && /^F\\d+$/.test(event.code)) {\n this.currentlyDownKeys.add(event.code.toLowerCase());\n return;\n }\n\n if (key === ' ') {\n this.currentlyDownKeys.add('space');\n return;\n }\n\n if (key === 'escape') {\n this.currentlyDownKeys.add('escape');\n return;\n }\n\n if (key === 'enter') {\n this.currentlyDownKeys.add('enter');\n return;\n }\n\n if (key && key.length > 0) {\n this.currentlyDownKeys.add(key);\n }\n }\n\n /**\n * Build the pressed keys array used for matching against registered shortcuts.\n * If multiple non-modifier keys are currently down, include them (chord support).\n * Otherwise fall back to single main-key detection from the event for compatibility.\n */\n /**\n * Build the pressed keys set used for matching against registered shortcuts.\n * If multiple non-modifier keys are currently down, include them (chord support).\n * Otherwise fall back to single main-key detection from the event for compatibility.\n *\n * Returns a Set<string> (lowercased) to allow O(1) lookups and O(n) comparisons\n * without sorting or allocating sorted arrays on every event.\n */\n protected buildPressedKeysForMatch(event: KeyboardEvent): Set<string> {\n const modifiers = new Set<string>();\n if (event.ctrlKey) modifiers.add('ctrl');\n if (event.altKey) modifiers.add('alt');\n if (event.shiftKey) modifiers.add('shift');\n if (event.metaKey) modifiers.add('meta');\n\n // Collect non-modifier keys from currentlyDownKeys (excluding modifiers)\n const nonModifierKeys = Array.from(this.currentlyDownKeys).filter(k => !['control', 'alt', 'shift', 'meta'].includes(k));\n\n const result = new Set<string>();\n // Add modifiers first\n modifiers.forEach(m => result.add(m));\n\n if (nonModifierKeys.length > 0) {\n nonModifierKeys.forEach(k => result.add(k.toLowerCase()));\n return result;\n }\n\n // Fallback: single main key from the event (existing behavior)\n const key = event.key.toLowerCase();\n if (!['control', 'alt', 'shift', 'meta'].includes(key)) {\n result.add(key);\n }\n return result;\n }\n\n protected getPressedKeys(event: KeyboardEvent): string[] {\n const keys: string[] = [];\n \n if (event.ctrlKey) keys.push('ctrl');\n if (event.altKey) keys.push('alt');\n if (event.shiftKey) keys.push('shift');\n if (event.metaKey) keys.push('meta');\n \n // Add the main key (normalize to lowercase)\n const key = event.key.toLowerCase();\n if (!['control', 'alt', 'shift', 'meta'].includes(key)) {\n keys.push(key);\n }\n \n return keys;\n }\n\n /**\n * Compare pressed keys against a target key combination.\n * Accepts either a Set<string> (preferred) or an array for backwards compatibility.\n * Uses Set-based comparison: sizes must match and every element in target must exist in pressed.\n */\n protected keysMatch(pressedKeys: Set<string> | string[], targetKeys: string[]): boolean {\n // Normalize targetKeys into a Set<string> (lowercased)\n const normalizedTarget = new Set<string>(targetKeys.map(k => k.toLowerCase()));\n\n // Normalize pressedKeys into a Set<string> if it's an array\n const pressedSet: Set<string> = Array.isArray(pressedKeys)\n ? new Set<string>(pressedKeys.map(k => k.toLowerCase()))\n : new Set<string>(Array.from(pressedKeys).map(k => k.toLowerCase()));\n\n if (pressedSet.size !== normalizedTarget.size) {\n return false;\n }\n \n // Check if every element in normalizedTarget exists in pressedSet\n for (const key of normalizedTarget) {\n if (!pressedSet.has(key)) {\n return false;\n }\n }\n \n return true;\n }\n\n /** Compare two multi-step sequences for equality */\n protected stepsMatch(a: string[][], b: string[][]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!this.keysMatch(a[i], b[i])) return false;\n }\n return true;\n }\n\n /** Safely clear any pending multi-step sequence */\n private clearPendingSequence(): void {\n if (!this.pendingSequence) return;\n try {\n clearTimeout(this.pendingSequence.timerId);\n } catch { /* ignore */ }\n this.pendingSequence = null;\n }\n\n protected isMacPlatform(): boolean {\n return this.isBrowser && /Mac|iPod|iPhone|iPad/.test(navigator.platform);\n }\n \n protected setupActiveUntil (activeUntil: KeyboardShortcutActiveUntil|undefined, unregister: () => void) {\n if (!activeUntil) {\n return\n }\n\n if (activeUntil === 'destruct') {\n inject(DestroyRef).onDestroy(unregister);\n return\n } \n \n if (activeUntil instanceof DestroyRef) {\n activeUntil.onDestroy(unregister);\n return\n } \n \n if (activeUntil instanceof Observable) {\n activeUntil.pipe(take(1)).subscribe(unregister);\n return\n }\n }\n}\n","/*\n * Public API Surface of ngx-keys\n */\n\nexport * from './lib/keyboard-shortcuts';\nexport * from './lib/keyboard-shortcut.interface';\nexport * from './lib/keyboard-shortcuts.errors';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAA;;;AAGG;AACI,MAAM,uBAAuB,GAAG;;IAErC,2BAA2B,EAAE,CAAC,EAAU,KAAK,CAAA,UAAA,EAAa,EAAE,CAAA,oBAAA,CAAsB;IAClF,wBAAwB,EAAE,CAAC,EAAU,KAAK,CAAA,OAAA,EAAU,EAAE,CAAA,oBAAA,CAAsB;IAC5E,YAAY,EAAE,CAAC,UAAkB,KAAK,CAAA,mBAAA,EAAsB,UAAU,CAAA,CAAA,CAAG;AACzE,IAAA,+BAA+B,EAAE,CAAC,GAAa,KAAK,CAAA,iCAAA,EAAoC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE;AACxG,IAAA,4BAA4B,EAAE,CAAC,GAAa,KAAK,CAAA,8BAAA,EAAiC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE;AAClG,IAAA,sBAAsB,EAAE,CAAC,SAAmB,KAAK,CAAA,eAAA,EAAkB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE;;IAGzF,uBAAuB,EAAE,CAAC,EAAU,KAAK,CAAA,UAAA,EAAa,EAAE,CAAA,gBAAA,CAAkB;IAC1E,oBAAoB,EAAE,CAAC,EAAU,KAAK,CAAA,OAAA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,CAAC,UAAU,CAAC;YACxC;QACF;AAEA,QAAA,IAAI,WAAW,YAAY,UAAU,EAAE;AACrC,YAAA,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC;YACjC;QACF;AAEA,QAAA,IAAI,WAAW,YAAY,UAAU,EAAE;AACrC,YAAA,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC;YAC/C;QACF;IACF;uGA1uBW,iBAAiB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAjB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,iBAAiB,cAFhB,MAAM,EAAA,CAAA;;2FAEP,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAH7B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;ACRD;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngx-keys.mjs","sources":["../../../projects/ngx-keys/src/lib/keyboard-shortcuts.errors.ts","../../../projects/ngx-keys/src/lib/keyboard-shortcuts.ts","../../../projects/ngx-keys/src/public-api.ts","../../../projects/ngx-keys/src/ngx-keys.ts"],"sourcesContent":["/**\n * Centralized error messages for keyboard shortcuts service\n * This ensures consistency across the application and makes testing easier\n */\nexport const KeyboardShortcutsErrors = {\n // Registration errors\n SHORTCUT_ALREADY_REGISTERED: (id: string) => `Shortcut \"${id}\" already registered`,\n GROUP_ALREADY_REGISTERED: (id: string) => `Group \"${id}\" already registered`,\n KEY_CONFLICT: (conflictId: string) => `Key conflict with \"${conflictId}\"`,\n ACTIVE_KEY_CONFLICT: (conflictId: string) => `Key conflict with active shortcut \"${conflictId}\"`,\n ACTIVATION_KEY_CONFLICT: (shortcutId: string, conflictIds: string[]) => `Cannot activate \"${shortcutId}\": would conflict with active shortcuts: ${conflictIds.join(', ')}`,\n GROUP_ACTIVATION_KEY_CONFLICT: (groupId: string, conflictIds: string[]) => `Cannot activate group \"${groupId}\": would conflict with active shortcuts: ${conflictIds.join(', ')}`,\n SHORTCUT_IDS_ALREADY_REGISTERED: (ids: string[]) => `Shortcut IDs already registered: ${ids.join(', ')}`,\n DUPLICATE_SHORTCUTS_IN_GROUP: (ids: string[]) => `Duplicate shortcuts in group: ${ids.join(', ')}`,\n KEY_CONFLICTS_IN_GROUP: (conflicts: string[]) => `Key conflicts: ${conflicts.join(', ')}`,\n \n // Operation errors\n SHORTCUT_NOT_REGISTERED: (id: string) => `Shortcut \"${id}\" not registered`,\n GROUP_NOT_REGISTERED: (id: string) => `Group \"${id}\" not registered`,\n \n // Activation/Deactivation errors\n CANNOT_ACTIVATE_SHORTCUT: (id: string) => `Cannot activate shortcut \"${id}\": not registered`,\n CANNOT_DEACTIVATE_SHORTCUT: (id: string) => `Cannot deactivate shortcut \"${id}\": not registered`,\n CANNOT_ACTIVATE_GROUP: (id: string) => `Cannot activate group \"${id}\": not registered`,\n CANNOT_DEACTIVATE_GROUP: (id: string) => `Cannot deactivate group \"${id}\": not registered`,\n \n // Unregistration errors\n CANNOT_UNREGISTER_SHORTCUT: (id: string) => `Cannot unregister shortcut \"${id}\": not registered`,\n CANNOT_UNREGISTER_GROUP: (id: string) => `Cannot unregister group \"${id}\": not registered`,\n} as const;\n\n/**\n * Error types for type safety\n */\nexport type KeyboardShortcutsErrorType = keyof typeof KeyboardShortcutsErrors;\n\n/**\n * Custom error class for keyboard shortcuts\n */\nexport class KeyboardShortcutError extends Error {\n constructor(\n public readonly errorType: KeyboardShortcutsErrorType,\n message: string,\n public readonly context?: Record<string, any>\n ) {\n super(message);\n this.name = 'KeyboardShortcutError';\n }\n}\n\n/**\n * Error factory for creating consistent errors\n */\nexport class KeyboardShortcutsErrorFactory {\n static shortcutAlreadyRegistered(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'SHORTCUT_ALREADY_REGISTERED',\n KeyboardShortcutsErrors.SHORTCUT_ALREADY_REGISTERED(id),\n { shortcutId: id }\n );\n }\n\n static groupAlreadyRegistered(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'GROUP_ALREADY_REGISTERED',\n KeyboardShortcutsErrors.GROUP_ALREADY_REGISTERED(id),\n { groupId: id }\n );\n }\n\n static keyConflict(conflictId: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'KEY_CONFLICT',\n KeyboardShortcutsErrors.KEY_CONFLICT(conflictId),\n { conflictId }\n );\n }\n\n static activeKeyConflict(conflictId: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'ACTIVE_KEY_CONFLICT',\n KeyboardShortcutsErrors.ACTIVE_KEY_CONFLICT(conflictId),\n { conflictId }\n );\n }\n\n static activationKeyConflict(shortcutId: string, conflictIds: string[]): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'ACTIVATION_KEY_CONFLICT',\n KeyboardShortcutsErrors.ACTIVATION_KEY_CONFLICT(shortcutId, conflictIds),\n { shortcutId, conflictIds }\n );\n }\n\n static groupActivationKeyConflict(groupId: string, conflictIds: string[]): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'GROUP_ACTIVATION_KEY_CONFLICT',\n KeyboardShortcutsErrors.GROUP_ACTIVATION_KEY_CONFLICT(groupId, conflictIds),\n { groupId, conflictIds }\n );\n }\n\n static shortcutIdsAlreadyRegistered(ids: string[]): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'SHORTCUT_IDS_ALREADY_REGISTERED',\n KeyboardShortcutsErrors.SHORTCUT_IDS_ALREADY_REGISTERED(ids),\n { duplicateIds: ids }\n );\n }\n\n static duplicateShortcutsInGroup(ids: string[]): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'DUPLICATE_SHORTCUTS_IN_GROUP',\n KeyboardShortcutsErrors.DUPLICATE_SHORTCUTS_IN_GROUP(ids),\n { duplicateIds: ids }\n );\n }\n\n static keyConflictsInGroup(conflicts: string[]): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'KEY_CONFLICTS_IN_GROUP',\n KeyboardShortcutsErrors.KEY_CONFLICTS_IN_GROUP(conflicts),\n { conflicts }\n );\n }\n\n static shortcutNotRegistered(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'SHORTCUT_NOT_REGISTERED',\n KeyboardShortcutsErrors.SHORTCUT_NOT_REGISTERED(id),\n { shortcutId: id }\n );\n }\n\n static groupNotRegistered(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'GROUP_NOT_REGISTERED',\n KeyboardShortcutsErrors.GROUP_NOT_REGISTERED(id),\n { groupId: id }\n );\n }\n\n static cannotActivateShortcut(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'CANNOT_ACTIVATE_SHORTCUT',\n KeyboardShortcutsErrors.CANNOT_ACTIVATE_SHORTCUT(id),\n { shortcutId: id }\n );\n }\n\n static cannotDeactivateShortcut(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'CANNOT_DEACTIVATE_SHORTCUT',\n KeyboardShortcutsErrors.CANNOT_DEACTIVATE_SHORTCUT(id),\n { shortcutId: id }\n );\n }\n\n static cannotActivateGroup(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'CANNOT_ACTIVATE_GROUP',\n KeyboardShortcutsErrors.CANNOT_ACTIVATE_GROUP(id),\n { groupId: id }\n );\n }\n\n static cannotDeactivateGroup(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'CANNOT_DEACTIVATE_GROUP',\n KeyboardShortcutsErrors.CANNOT_DEACTIVATE_GROUP(id),\n { groupId: id }\n );\n }\n\n static cannotUnregisterShortcut(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'CANNOT_UNREGISTER_SHORTCUT',\n KeyboardShortcutsErrors.CANNOT_UNREGISTER_SHORTCUT(id),\n { shortcutId: id }\n );\n }\n\n static cannotUnregisterGroup(id: string): KeyboardShortcutError {\n return new KeyboardShortcutError(\n 'CANNOT_UNREGISTER_GROUP',\n KeyboardShortcutsErrors.CANNOT_UNREGISTER_GROUP(id),\n { groupId: id }\n );\n }\n}\n","import {\n afterNextRender,\n computed,\n DestroyRef,\n DOCUMENT,\n inject,\n Injectable,\n OnDestroy,\n signal,\n} from '@angular/core';\nimport { KeyboardShortcut, KeyboardShortcutActiveUntil, KeyboardShortcutFilter, KeyboardShortcutGroup, KeyboardShortcutGroupOptions, KeyboardShortcutUI, KeyStep } from './keyboard-shortcut.interface'\nimport { KeyboardShortcutsErrorFactory } from './keyboard-shortcuts.errors';\nimport { Observable, take } from 'rxjs';\n\n/**\n * Type guard to detect KeyboardShortcutGroupOptions at runtime.\n * Centralising this logic keeps registerGroup simpler and less fragile.\n */\nfunction isGroupOptions(param: unknown): param is KeyboardShortcutGroupOptions {\n if (!param || typeof param !== 'object') return false;\n // Narrow to object for property checks\n const obj = param as Record<string, unknown>;\n return ('filter' in obj) || ('activeUntil' in obj);\n}\n\n/**\n * Detect real DestroyRef instances or duck-typed objects exposing onDestroy(fn).\n * Returns true for either an actual DestroyRef or an object with an onDestroy method.\n */\nfunction isDestroyRefLike(obj: unknown): obj is DestroyRef & { onDestroy: (fn: () => void) => void } {\n if (!obj || typeof obj !== 'object') return false;\n try {\n // Prefer instanceof when available (real DestroyRef)\n if (obj instanceof DestroyRef) return true;\n } catch {\n // instanceof may throw if DestroyRef is not constructable in certain runtimes/tests\n }\n\n const o = obj as Record<string, unknown>;\n return typeof o['onDestroy'] === 'function';\n}\n\n@Injectable({\n providedIn: 'root'\n})\nexport class KeyboardShortcuts implements OnDestroy {\n private static readonly MODIFIER_KEYS = new Set(['control', 'alt', 'shift', 'meta']);\n private readonly document = inject(DOCUMENT);\n private readonly window = this.document.defaultView!;\n\n private readonly shortcuts = new Map<string, KeyboardShortcut>();\n private readonly groups = new Map<string, KeyboardShortcutGroup>();\n private readonly activeShortcuts = new Set<string>();\n private readonly activeGroups = new Set<string>();\n private readonly currentlyDownKeys = new Set<string>();\n // O(1) lookup from shortcutId to its groupId to avoid scanning all groups per event\n private readonly shortcutToGroup = new Map<string, string>();\n\n /**\n * Named global filters that apply to all shortcuts.\n * All global filters must return `true` for a shortcut to be processed.\n */\n private readonly globalFilters = new Map<string, KeyboardShortcutFilter>();\n\n // Single consolidated state signal - reduces memory overhead\n private readonly state = signal({\n shortcuts: new Map<string, KeyboardShortcut>(),\n groups: new Map<string, KeyboardShortcutGroup>(),\n activeShortcuts: new Set<string>(),\n activeGroups: new Set<string>(),\n version: 0 // for change detection optimization\n });\n\n // Primary computed signal - consumers derive what they need from this\n readonly shortcuts$ = computed(() => {\n const state = this.state();\n const activeShortcuts = Array.from(state.activeShortcuts)\n .map(id => state.shortcuts.get(id))\n .filter((s): s is KeyboardShortcut => s !== undefined);\n\n const inactiveShortcuts = Array.from(state.shortcuts.values())\n .filter(s => !state.activeShortcuts.has(s.id));\n\n return {\n active: activeShortcuts,\n inactive: inactiveShortcuts,\n all: Array.from(state.shortcuts.values()),\n groups: {\n active: Array.from(state.activeGroups),\n inactive: Array.from(state.groups.keys())\n .filter(id => !state.activeGroups.has(id))\n }\n };\n });\n\n // Optional: Pre-formatted UI signal for components that need it\n readonly shortcutsUI$ = computed(() => {\n const shortcuts = this.shortcuts$();\n return {\n active: shortcuts.active.map(s => this.formatShortcutForUI(s)),\n inactive: shortcuts.inactive.map(s => this.formatShortcutForUI(s)),\n all: shortcuts.all.map(s => this.formatShortcutForUI(s))\n };\n });\n\n private readonly keydownListener = this.handleKeydown.bind(this);\n private readonly keyupListener = this.handleKeyup.bind(this);\n private readonly blurListener = this.handleWindowBlur.bind(this);\n private readonly visibilityListener = this.handleVisibilityChange.bind(this);\n private isListening = false;\n /** Default timeout (ms) for completing a multi-step sequence */\n protected sequenceTimeout = 2000;\n\n /** Runtime state for multi-step sequences */\n private pendingSequence: {\n shortcutId: string;\n stepIndex: number;\n timerId: any;\n } | null = null;\n\n constructor() {\n afterNextRender(() => {\n this.startListening();\n });\n }\n\n ngOnDestroy(): void {\n this.stopListening();\n }\n\n /**\n * Batch updates and increment version for change detection\n */\n private updateState(): void {\n this.state.update(current => ({\n shortcuts: new Map(this.shortcuts),\n groups: new Map(this.groups),\n activeShortcuts: new Set(this.activeShortcuts),\n activeGroups: new Set(this.activeGroups),\n version: current.version + 1\n }));\n }\n\n /**\n * Utility method for UI formatting\n */\n formatShortcutForUI(shortcut: KeyboardShortcut): KeyboardShortcutUI {\n return {\n id: shortcut.id,\n keys: this.formatStepsForDisplay(shortcut.keys ?? shortcut.steps ?? [], false),\n macKeys: this.formatStepsForDisplay(shortcut.macKeys ?? shortcut.macSteps ?? [], true),\n description: shortcut.description\n };\n }\n\n /**\n * Utility method for batch operations - reduces signal updates\n */\n batchUpdate(operations: () => void): void {\n operations();\n this.updateState();\n }\n\n /**\n * Format keys for display with proper Unicode symbols\n */\n private formatKeysForDisplay(keys: string[], isMac = false): string {\n const keyMap: Record<string, string> = isMac ? {\n 'ctrl': '⌃',\n 'alt': '⌥',\n 'shift': '⇧',\n 'meta': '⌘',\n 'cmd': '⌘',\n 'command': '⌘'\n } : {\n 'ctrl': 'Ctrl',\n 'alt': 'Alt',\n 'shift': 'Shift',\n 'meta': 'Win'\n };\n\n return keys\n .map(key => keyMap[key.toLowerCase()] || key.toUpperCase())\n .join('+');\n }\n\n private formatStepsForDisplay(steps: string[] | string[][], isMac = false): string {\n if (!steps) return '';\n\n // If the first element is an array, assume steps is string[][]\n const normalized = this.normalizeToSteps(steps as KeyStep[] | string[]);\n if (normalized.length === 0) return '';\n if (normalized.length === 1) return this.formatKeysForDisplay(normalized[0], isMac);\n return normalized.map(step => this.formatKeysForDisplay(step, isMac)).join(', ');\n }\n\n private normalizeToSteps(input: KeyStep[] | string[]): KeyStep[] {\n if (!input) return [];\n // If first element is an array, assume already KeyStep[]\n if (Array.isArray(input[0])) {\n return input as KeyStep[];\n }\n // Single step array\n return [input as string[]];\n }\n\n /**\n * Check if a key combination is already registered by an active shortcut\n * @returns The ID of the conflicting active shortcut, or null if no active conflict\n */\n private findActiveConflict(newShortcut: KeyboardShortcut): string | null {\n for (const existing of this.shortcuts.values()) {\n // Only check conflicts with active shortcuts\n if (!this.activeShortcuts.has(existing.id)) {\n continue;\n }\n\n // Compare single-step shapes if provided\n if (newShortcut.keys && existing.keys && this.keysMatch(newShortcut.keys, existing.keys)) {\n return existing.id;\n }\n if (newShortcut.macKeys && existing.macKeys && this.keysMatch(newShortcut.macKeys, existing.macKeys)) {\n return existing.id;\n }\n\n // Compare multi-step shapes\n if (newShortcut.steps && existing.steps && this.stepsMatch(newShortcut.steps, existing.steps)) {\n return existing.id;\n }\n if (newShortcut.macSteps && existing.macSteps && this.stepsMatch(newShortcut.macSteps, existing.macSteps)) {\n return existing.id;\n }\n }\n return null;\n }\n\n /**\n * Check if activating a shortcut would create key conflicts with other active shortcuts\n * @returns Array of conflicting shortcut IDs that would be created by activation\n */\n private findActivationConflicts(shortcutId: string): string[] {\n const shortcut = this.shortcuts.get(shortcutId);\n if (!shortcut) return [];\n\n const conflicts: string[] = [];\n for (const existing of this.shortcuts.values()) {\n // Skip self and inactive shortcuts\n if (existing.id === shortcutId || !this.activeShortcuts.has(existing.id)) {\n continue;\n }\n\n // Check for key conflicts\n if ((shortcut.keys && existing.keys && this.keysMatch(shortcut.keys, existing.keys)) ||\n (shortcut.macKeys && existing.macKeys && this.keysMatch(shortcut.macKeys, existing.macKeys)) ||\n (shortcut.steps && existing.steps && this.stepsMatch(shortcut.steps, existing.steps)) ||\n (shortcut.macSteps && existing.macSteps && this.stepsMatch(shortcut.macSteps, existing.macSteps))) {\n conflicts.push(existing.id);\n }\n }\n return conflicts;\n }\n\n /**\n * Register a single keyboard shortcut\n * @throws KeyboardShortcutError if shortcut ID is already registered or if the shortcut would conflict with currently active shortcuts\n */\n register(shortcut: KeyboardShortcut): void {\n if (this.shortcuts.has(shortcut.id)) {\n throw KeyboardShortcutsErrorFactory.shortcutAlreadyRegistered(shortcut.id);\n }\n\n // Check for conflicts only with currently active shortcuts\n const conflictId = this.findActiveConflict(shortcut);\n if (conflictId) {\n throw KeyboardShortcutsErrorFactory.activeKeyConflict(conflictId);\n }\n\n this.shortcuts.set(shortcut.id, shortcut);\n this.activeShortcuts.add(shortcut.id);\n this.updateState();\n\n this.setupActiveUntil(\n shortcut.activeUntil,\n this.unregister.bind(this, shortcut.id),\n );\n }\n\n /**\n * Register multiple keyboard shortcuts as a group\n * @param groupId - Unique identifier for the group\n * @param shortcuts - Array of shortcuts to register as a group\n * @param options - Optional configuration including filter and activeUntil\n * @throws KeyboardShortcutError if group ID is already registered or if any shortcut ID or key combination conflicts\n */\n registerGroup(groupId: string, shortcuts: KeyboardShortcut[], options?: KeyboardShortcutGroupOptions): void;\n /**\n * @deprecated Use registerGroup(groupId, shortcuts, { activeUntil }) instead\n */\n registerGroup(groupId: string, shortcuts: KeyboardShortcut[], activeUntil?: KeyboardShortcutActiveUntil): void;\n registerGroup(groupId: string, shortcuts: KeyboardShortcut[], optionsOrActiveUntil?: KeyboardShortcutGroupOptions | KeyboardShortcutActiveUntil): void {\n // Parse parameters - support both old (activeUntil) and new (options) formats\n let options: KeyboardShortcutGroupOptions;\n if (isGroupOptions(optionsOrActiveUntil)) {\n // New format with options object\n options = optionsOrActiveUntil;\n } else {\n // Old format with just activeUntil parameter\n options = { activeUntil: optionsOrActiveUntil as KeyboardShortcutActiveUntil };\n }\n\n // Check if group ID already exists\n if (this.groups.has(groupId)) {\n throw KeyboardShortcutsErrorFactory.groupAlreadyRegistered(groupId);\n }\n \n // Check for duplicate shortcut IDs and key combination conflicts with active shortcuts\n const duplicateIds: string[] = [];\n const keyConflicts: string[] = [];\n shortcuts.forEach(shortcut => {\n if (this.shortcuts.has(shortcut.id)) {\n duplicateIds.push(shortcut.id);\n }\n const conflictId = this.findActiveConflict(shortcut);\n if (conflictId) {\n keyConflicts.push(`\"${shortcut.id}\" conflicts with active shortcut \"${conflictId}\"`);\n }\n });\n\n if (duplicateIds.length > 0) {\n throw KeyboardShortcutsErrorFactory.shortcutIdsAlreadyRegistered(duplicateIds);\n }\n\n if (keyConflicts.length > 0) {\n throw KeyboardShortcutsErrorFactory.keyConflictsInGroup(keyConflicts);\n }\n\n // Validate that all shortcuts have unique IDs within the group\n const groupIds = new Set<string>();\n const duplicatesInGroup: string[] = [];\n shortcuts.forEach(shortcut => {\n if (groupIds.has(shortcut.id)) {\n duplicatesInGroup.push(shortcut.id);\n } else {\n groupIds.add(shortcut.id);\n }\n });\n\n if (duplicatesInGroup.length > 0) {\n throw KeyboardShortcutsErrorFactory.duplicateShortcutsInGroup(duplicatesInGroup);\n }\n\n // Use batch update to reduce signal updates\n this.batchUpdate(() => {\n const group: KeyboardShortcutGroup = {\n id: groupId,\n shortcuts,\n active: true,\n filter: options.filter\n };\n\n this.groups.set(groupId, group);\n this.activeGroups.add(groupId);\n\n // Register individual shortcuts\n shortcuts.forEach(shortcut => {\n this.shortcuts.set(shortcut.id, shortcut);\n this.activeShortcuts.add(shortcut.id);\n this.shortcutToGroup.set(shortcut.id, groupId);\n });\n });\n\n this.setupActiveUntil(\n options.activeUntil,\n this.unregisterGroup.bind(this, groupId),\n );\n }\n\n /**\n * Unregister a single keyboard shortcut\n * @throws KeyboardShortcutError if shortcut ID doesn't exist\n */\n unregister(shortcutId: string): void {\n if (!this.shortcuts.has(shortcutId)) {\n throw KeyboardShortcutsErrorFactory.cannotUnregisterShortcut(shortcutId);\n }\n\n this.shortcuts.delete(shortcutId);\n this.activeShortcuts.delete(shortcutId);\n this.shortcutToGroup.delete(shortcutId);\n this.updateState();\n }\n\n /**\n * Unregister a group of keyboard shortcuts\n * @throws KeyboardShortcutError if group ID doesn't exist\n */\n unregisterGroup(groupId: string): void {\n const group = this.groups.get(groupId);\n if (!group) {\n throw KeyboardShortcutsErrorFactory.cannotUnregisterGroup(groupId);\n }\n\n this.batchUpdate(() => {\n group.shortcuts.forEach(shortcut => {\n this.shortcuts.delete(shortcut.id);\n this.activeShortcuts.delete(shortcut.id);\n this.shortcutToGroup.delete(shortcut.id);\n });\n this.groups.delete(groupId);\n this.activeGroups.delete(groupId);\n });\n }\n\n /**\n * Activate a single keyboard shortcut\n * @throws KeyboardShortcutError if shortcut ID doesn't exist or if activation would create key conflicts\n */\n activate(shortcutId: string): void {\n if (!this.shortcuts.has(shortcutId)) {\n throw KeyboardShortcutsErrorFactory.cannotActivateShortcut(shortcutId);\n }\n\n // Check for conflicts that would be created by activation\n const conflicts = this.findActivationConflicts(shortcutId);\n if (conflicts.length > 0) {\n throw KeyboardShortcutsErrorFactory.activationKeyConflict(shortcutId, conflicts);\n }\n\n this.activeShortcuts.add(shortcutId);\n this.updateState();\n }\n\n /**\n * Deactivate a single keyboard shortcut\n * @throws KeyboardShortcutError if shortcut ID doesn't exist\n */\n deactivate(shortcutId: string): void {\n if (!this.shortcuts.has(shortcutId)) {\n throw KeyboardShortcutsErrorFactory.cannotDeactivateShortcut(shortcutId);\n }\n\n this.activeShortcuts.delete(shortcutId);\n this.updateState();\n }\n\n /**\n * Activate a group of keyboard shortcuts\n * @throws KeyboardShortcutError if group ID doesn't exist or if activation would create key conflicts\n */\n activateGroup(groupId: string): void {\n const group = this.groups.get(groupId);\n if (!group) {\n throw KeyboardShortcutsErrorFactory.cannotActivateGroup(groupId);\n }\n\n // Check for conflicts that would be created by activating all shortcuts in the group\n const allConflicts: string[] = [];\n group.shortcuts.forEach(shortcut => {\n const conflicts = this.findActivationConflicts(shortcut.id);\n allConflicts.push(...conflicts);\n });\n\n if (allConflicts.length > 0) {\n throw KeyboardShortcutsErrorFactory.groupActivationKeyConflict(groupId, allConflicts);\n }\n\n this.batchUpdate(() => {\n group.active = true;\n this.activeGroups.add(groupId);\n group.shortcuts.forEach(shortcut => {\n this.activeShortcuts.add(shortcut.id);\n });\n });\n }\n\n /**\n * Deactivate a group of keyboard shortcuts\n * @throws KeyboardShortcutError if group ID doesn't exist\n */\n deactivateGroup(groupId: string): void {\n const group = this.groups.get(groupId);\n if (!group) {\n throw KeyboardShortcutsErrorFactory.cannotDeactivateGroup(groupId);\n }\n\n this.batchUpdate(() => {\n group.active = false;\n this.activeGroups.delete(groupId);\n group.shortcuts.forEach(shortcut => {\n this.activeShortcuts.delete(shortcut.id);\n });\n });\n }\n\n /**\n * Check if a shortcut is active\n */\n isActive(shortcutId: string): boolean {\n return this.activeShortcuts.has(shortcutId);\n }\n\n /**\n * Check if a shortcut is registered\n */\n isRegistered(shortcutId: string): boolean {\n return this.shortcuts.has(shortcutId);\n }\n\n /**\n * Check if a group is active\n */\n isGroupActive(groupId: string): boolean {\n return this.activeGroups.has(groupId);\n }\n\n /**\n * Check if a group is registered\n */\n isGroupRegistered(groupId: string): boolean {\n return this.groups.has(groupId);\n }\n\n /**\n * Get all registered shortcuts\n */\n getShortcuts(): ReadonlyMap<string, KeyboardShortcut> {\n return this.shortcuts;\n }\n\n /**\n * Get all registered groups\n */\n getGroups(): ReadonlyMap<string, KeyboardShortcutGroup> {\n return this.groups;\n }\n\n /**\n * Add a named global filter that applies to all shortcuts.\n * All global filters must return `true` for a shortcut to execute.\n * \n * @param name - Unique name for this filter\n * @param filter - Function that returns `true` to allow shortcuts, `false` to block them\n * \n * @example\n * ```typescript\n * // Block shortcuts in form elements\n * keyboardService.addFilter('forms', (event) => {\n * const target = event.target as HTMLElement;\n * const tagName = target?.tagName?.toLowerCase();\n * return !['input', 'textarea', 'select'].includes(tagName) && !target?.isContentEditable;\n * });\n * \n * // Block shortcuts when modal is open\n * keyboardService.addFilter('modal', (event) => {\n * return !document.querySelector('.modal.active');\n * });\n * ```\n */\n addFilter(name: string, filter: KeyboardShortcutFilter): void {\n this.globalFilters.set(name, filter);\n }\n\n /**\n * Remove a named global filter.\n * \n * @param name - Name of the filter to remove\n * @returns `true` if filter was removed, `false` if it didn't exist\n */\n removeFilter(name: string): boolean {\n return this.globalFilters.delete(name);\n }\n\n /**\n * Get a named global filter.\n * \n * @param name - Name of the filter to retrieve\n * @returns The filter function, or undefined if not found\n */\n getFilter(name: string): KeyboardShortcutFilter | undefined {\n return this.globalFilters.get(name);\n }\n\n /**\n * Get all global filter names.\n * \n * @returns Array of filter names\n */\n getFilterNames(): string[] {\n return Array.from(this.globalFilters.keys());\n }\n\n /**\n * Remove all global filters.\n */\n clearFilters(): void {\n this.globalFilters.clear();\n }\n\n /**\n * Check if a named filter exists.\n * \n * @param name - Name of the filter to check\n * @returns `true` if filter exists, `false` otherwise\n */\n hasFilter(name: string): boolean {\n return this.globalFilters.has(name);\n }\n\n /**\n * Find the group that contains a specific shortcut.\n * \n * @param shortcutId - The ID of the shortcut to find\n * @returns The group containing the shortcut, or undefined if not found in any group\n */\n private findGroupForShortcut(shortcutId: string): KeyboardShortcutGroup | undefined {\n const groupId = this.shortcutToGroup.get(shortcutId);\n return groupId ? this.groups.get(groupId) : undefined;\n }\n\n /**\n * Check if a keyboard event should be processed based on global, group, and per-shortcut filters.\n * Filter hierarchy: Global filters → Group filter → Individual shortcut filter\n * \n * @param event - The keyboard event to evaluate\n * @param shortcut - The shortcut being evaluated (for per-shortcut filter)\n * @returns `true` if event should be processed, `false` if it should be ignored\n */\n private shouldProcessEvent(event: KeyboardEvent, shortcut: KeyboardShortcut): boolean {\n // First, check all global filters - ALL must return true\n // Note: handleKeydown pre-checks these once per event for early exit,\n // but we keep this for direct calls and completeness.\n for (const globalFilter of this.globalFilters.values()) {\n if (!globalFilter(event)) {\n return false;\n }\n }\n\n // Then check group filter if shortcut belongs to a group\n const group = this.findGroupForShortcut(shortcut.id);\n if (group?.filter && !group.filter(event)) {\n return false;\n }\n\n // Finally check per-shortcut filter if it exists\n if (shortcut.filter && !shortcut.filter(event)) {\n return false;\n }\n\n return true;\n }\n\n private startListening(): void {\n if (this.isListening) {\n return;\n }\n\n // Listen to both keydown and keyup so we can maintain a Set of currently\n // pressed physical keys. We avoid passive:true because we may call\n // preventDefault() when matching shortcuts.\n this.document.addEventListener('keydown', this.keydownListener, { passive: false });\n this.document.addEventListener('keyup', this.keyupListener, { passive: false });\n // Listen for blur/visibility changes so we can clear the currently-down keys\n // and avoid stale state when the browser or tab loses focus.\n this.window.addEventListener('blur', this.blurListener);\n this.document.addEventListener('visibilitychange', this.visibilityListener);\n this.isListening = true;\n }\n\n private stopListening(): void {\n if (!this.isListening) {\n return;\n }\n\n this.document.removeEventListener('keydown', this.keydownListener);\n this.document.removeEventListener('keyup', this.keyupListener);\n this.window.removeEventListener('blur', this.blurListener);\n this.document.removeEventListener('visibilitychange', this.visibilityListener);\n this.isListening = false;\n }\n\n protected handleKeydown(event: KeyboardEvent): void {\n // Update the currently down keys with this event's key\n this.updateCurrentlyDownKeysOnKeydown(event);\n\n // Fast path: if any global filter blocks this event, bail out before\n // scanning all active shortcuts. This drastically reduces per-event work\n // when filters are commonly blocking (e.g., while typing in inputs).\n if (this.globalFilters.size > 0) {\n for (const f of this.globalFilters.values()) {\n if (!f(event)) {\n // Also clear any pending multi-step sequence – entering a globally\n // filtered context should not allow sequences to continue.\n this.clearPendingSequence();\n return;\n }\n }\n }\n\n const isMac = this.isMacPlatform();\n\n // Evaluate active group-level filters once per event and cache blocked groups\n const blockedGroups = this.precomputeBlockedGroups(event);\n\n // If there is a pending multi-step sequence, try to advance it first\n if (this.pendingSequence) {\n const pending = this.pendingSequence;\n const shortcut = this.shortcuts.get(pending.shortcutId);\n if (shortcut) {\n // If the pending shortcut belongs to a blocked group, cancel sequence\n const g = this.findGroupForShortcut(shortcut.id);\n if (g && blockedGroups.has(g.id)) {\n this.clearPendingSequence();\n return;\n }\n const steps = isMac\n ? (shortcut.macSteps ?? shortcut.macKeys ?? shortcut.steps ?? shortcut.keys ?? [])\n : (shortcut.steps ?? shortcut.keys ?? shortcut.macSteps ?? shortcut.macKeys ?? []);\n const normalizedSteps = this.normalizeToSteps(steps as KeyStep[] | string[]);\n const expected = normalizedSteps[pending.stepIndex];\n\n // Use per-event pressed keys for advancing sequence steps. Relying on\n // the accumulated `currentlyDownKeys` can accidentally include keys\n // from previous steps (if tests or callers don't emit keyup), which\n // would prevent matching a simple single-key step like ['s'] after\n // a prior ['k'] step. Use getPressedKeys(event) which reflects the\n // actual modifier/main-key state for this event as a Set<string>.\n const stepPressed = this.getPressedKeys(event);\n\n if (expected && this.keysMatch(stepPressed, expected)) {\n // Advance sequence\n clearTimeout(pending.timerId);\n pending.stepIndex += 1;\n\n if (pending.stepIndex >= normalizedSteps.length) {\n // Completed - check filters before executing\n if (!this.shouldProcessEvent(event, shortcut)) {\n this.pendingSequence = null;\n return; // Skip execution due to filters\n }\n\n event.preventDefault();\n event.stopPropagation();\n try {\n shortcut.action();\n } catch (error) {\n console.error(`Error executing keyboard shortcut \"${shortcut.id}\":`, error);\n }\n this.pendingSequence = null;\n return;\n }\n\n // Reset timer for next step\n pending.timerId = setTimeout(() => { this.pendingSequence = null; }, this.sequenceTimeout);\n return;\n } else {\n // Cancel pending if doesn't match\n this.clearPendingSequence();\n }\n } else {\n // pending exists but shortcut not found\n this.clearPendingSequence();\n }\n }\n\n // No pending sequence - check active shortcuts for a match or sequence start\n for (const shortcutId of this.activeShortcuts) {\n const shortcut = this.shortcuts.get(shortcutId);\n if (!shortcut) continue;\n\n // Skip expensive matching entirely when the shortcut's group is blocked\n const g = this.findGroupForShortcut(shortcut.id);\n if (g && blockedGroups.has(g.id)) {\n continue;\n }\n\n const steps = isMac\n ? (shortcut.macSteps ?? shortcut.macKeys ?? shortcut.steps ?? shortcut.keys ?? [])\n : (shortcut.steps ?? shortcut.keys ?? shortcut.macSteps ?? shortcut.macKeys ?? []);\n const normalizedSteps = this.normalizeToSteps(steps as KeyStep[] | string[]);\n\n const firstStep = normalizedSteps[0];\n\n // Decide which pressed-keys representation to use for this shortcut's\n // expected step: if it requires multiple non-modifier keys, treat it as\n // a chord and use accumulated keys; otherwise use per-event keys to avoid\n // interference from previously pressed non-modifier keys.\n const nonModifierCount = firstStep.filter(k => !KeyboardShortcuts.MODIFIER_KEYS.has(k.toLowerCase())).length;\n // Normalize pressed keys to a Set<string> for consistent typing\n const pressedForStep: Set<string> = nonModifierCount > 1\n ? this.buildPressedKeysForMatch(event)\n : this.getPressedKeys(event);\n\n if (this.keysMatch(pressedForStep, firstStep)) {\n // Check if this event should be processed based on filters\n if (!this.shouldProcessEvent(event, shortcut)) {\n continue; // Skip this shortcut due to filters\n }\n\n if (normalizedSteps.length === 1) {\n // single-step\n event.preventDefault();\n event.stopPropagation();\n try {\n shortcut.action();\n } catch (error) {\n console.error(`Error executing keyboard shortcut \"${shortcut.id}\":`, error);\n }\n break;\n } else {\n // start pending sequence\n if (this.pendingSequence) {\n this.clearPendingSequence();\n }\n this.pendingSequence = {\n shortcutId: shortcut.id,\n stepIndex: 1,\n timerId: setTimeout(() => { this.pendingSequence = null; }, this.sequenceTimeout)\n };\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n }\n }\n }\n\n protected handleKeyup(event: KeyboardEvent): void {\n // Remove the key from currentlyDownKeys on keyup\n const key = event.key ? event.key.toLowerCase() : '';\n if (key && !KeyboardShortcuts.MODIFIER_KEYS.has(key)) {\n this.currentlyDownKeys.delete(key);\n }\n }\n\n /**\n * Clear the currently-down keys. Exposed for testing and for use by\n * blur/visibilitychange handlers to avoid stale state when the page loses focus.\n */\n clearCurrentlyDownKeys(): void {\n this.currentlyDownKeys.clear();\n }\n\n protected handleWindowBlur(): void {\n this.clearCurrentlyDownKeys();\n // Clear any pressed keys and any pending multi-step sequence to avoid\n // stale state when the window loses focus.\n this.clearPendingSequence();\n }\n\n protected handleVisibilityChange(): void {\n if (this.document.visibilityState === 'hidden') {\n // When the document becomes hidden, clear both pressed keys and any\n // pending multi-step sequence. This prevents sequences from remaining\n // active when the user switches tabs or minimizes the window.\n this.clearCurrentlyDownKeys();\n this.clearPendingSequence();\n }\n }\n\n /**\n * Update the currentlyDownKeys set when keydown events happen.\n * Normalizes common keys (function keys, space, etc.) to the same values\n * used by getPressedKeys/keysMatch.\n */\n protected updateCurrentlyDownKeysOnKeydown(event: KeyboardEvent): void {\n const key = event.key ? event.key.toLowerCase() : '';\n\n // Ignore modifier-only keydown entries\n if (KeyboardShortcuts.MODIFIER_KEYS.has(key)) {\n return;\n }\n\n // Normalize some special cases similar to the demo component's recording logic\n if (event.code && event.code.startsWith('F') && /^F\\d+$/.test(event.code)) {\n this.currentlyDownKeys.add(event.code.toLowerCase());\n return;\n }\n\n if (key === ' ') {\n this.currentlyDownKeys.add('space');\n return;\n }\n\n if (key === 'escape') {\n this.currentlyDownKeys.add('escape');\n return;\n }\n\n if (key === 'enter') {\n this.currentlyDownKeys.add('enter');\n return;\n }\n\n if (key && key.length > 0) {\n this.currentlyDownKeys.add(key);\n }\n }\n\n /**\n * Build the pressed keys set used for matching against registered shortcuts.\n * If multiple non-modifier keys are currently down, include them (chord support).\n * Otherwise fall back to single main-key detection from the event for compatibility.\n *\n * Returns a Set<string> (lowercased) to allow O(1) lookups and O(n) comparisons\n * without sorting or allocating sorted arrays on every event.\n */\n protected buildPressedKeysForMatch(event: KeyboardEvent): Set<string> {\n const modifiers = new Set<string>();\n if (event.ctrlKey) modifiers.add('ctrl');\n if (event.altKey) modifiers.add('alt');\n if (event.shiftKey) modifiers.add('shift');\n if (event.metaKey) modifiers.add('meta');\n\n // Collect non-modifier keys from currentlyDownKeys (excluding modifiers)\n const nonModifierKeys = Array.from(this.currentlyDownKeys).filter(k => !KeyboardShortcuts.MODIFIER_KEYS.has(k));\n\n const result = new Set<string>();\n // Add modifiers first\n modifiers.forEach(m => result.add(m));\n\n if (nonModifierKeys.length > 0) {\n nonModifierKeys.forEach(k => result.add(k.toLowerCase()));\n return result;\n }\n\n // Fallback: single main key from the event (existing behavior)\n const key = event.key.toLowerCase();\n if (!KeyboardShortcuts.MODIFIER_KEYS.has(key)) {\n result.add(key);\n }\n return result;\n }\n\n /**\n * Return the pressed keys for this event as a Set<string>.\n * This is the canonical internal API used for matching.\n */\n protected getPressedKeys(event: KeyboardEvent): Set<string> {\n const result = new Set<string>();\n\n if (event.ctrlKey) result.add('ctrl');\n if (event.altKey) result.add('alt');\n if (event.shiftKey) result.add('shift');\n if (event.metaKey) result.add('meta');\n\n // Add the main key (normalize to lowercase) if it's not a modifier\n const key = (event.key ?? '').toLowerCase();\n if (key && !KeyboardShortcuts.MODIFIER_KEYS.has(key)) {\n result.add(key);\n }\n\n return result;\n }\n\n /**\n * Compare pressed keys against a target key combination.\n * Accepts either a Set<string> (preferred) or an array for backwards compatibility.\n * Uses Set-based comparison: sizes must match and every element in target must exist in pressed.\n */\n protected keysMatch(pressedKeys: Set<string> | string[], targetKeys: string[]): boolean {\n // Normalize targetKeys into a Set<string> (lowercased)\n const normalizedTarget = new Set<string>(targetKeys.map(k => k.toLowerCase()));\n\n // Normalize pressedKeys into a Set<string> if it's an array\n const pressedSet: Set<string> = Array.isArray(pressedKeys)\n ? new Set<string>(pressedKeys.map(k => k.toLowerCase()))\n : new Set<string>(Array.from(pressedKeys).map(k => k.toLowerCase()));\n\n if (pressedSet.size !== normalizedTarget.size) {\n return false;\n }\n\n // Check if every element in normalizedTarget exists in pressedSet\n for (const key of normalizedTarget) {\n if (!pressedSet.has(key)) {\n return false;\n }\n }\n\n return true;\n }\n\n /** Compare two multi-step sequences for equality */\n protected stepsMatch(a: string[][], b: string[][]): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!this.keysMatch(a[i], b[i])) return false;\n }\n return true;\n }\n\n /** Safely clear any pending multi-step sequence */\n private clearPendingSequence(): void {\n if (!this.pendingSequence) return;\n try {\n clearTimeout(this.pendingSequence.timerId);\n } catch { /* ignore */ }\n this.pendingSequence = null;\n }\n\n protected isMacPlatform(): boolean {\n return /Mac|iPod|iPhone|iPad/.test(this.window.navigator.platform ?? '');\n }\n\n protected setupActiveUntil(activeUntil: KeyboardShortcutActiveUntil | undefined, unregister: () => void) {\n if (!activeUntil) {\n return\n }\n\n if (activeUntil === 'destruct') {\n inject(DestroyRef).onDestroy(unregister);\n return\n }\n\n // Support both real DestroyRef instances and duck-typed objects (e.g.,\n // Jasmine spies) that expose an onDestroy(fn) method for backwards\n // compatibility with earlier APIs and tests.\n if (isDestroyRefLike(activeUntil)) {\n activeUntil.onDestroy(unregister);\n return;\n }\n\n if (activeUntil instanceof Observable) {\n activeUntil.pipe(take(1)).subscribe(unregister);\n return\n }\n }\n\n /**\n * Evaluate group filters once per event and return the set of blocked group IDs.\n */\n protected precomputeBlockedGroups(event: KeyboardEvent): Set<string> {\n const blocked = new Set<string>();\n if (this.activeGroups.size === 0) return blocked;\n for (const groupId of this.activeGroups) {\n const group = this.groups.get(groupId);\n if (group && group.filter && !group.filter(event)) {\n blocked.add(groupId);\n }\n }\n return blocked;\n }\n}","/*\n * Public API Surface of ngx-keys\n */\n\nexport * from './lib/keyboard-shortcuts';\nexport * from './lib/keyboard-shortcut.interface';\nexport * from './lib/keyboard-shortcuts.errors';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;AACI,MAAM,uBAAuB,GAAG;;IAErC,2BAA2B,EAAE,CAAC,EAAU,KAAK,CAAA,UAAA,EAAa,EAAE,CAAA,oBAAA,CAAsB;IAClF,wBAAwB,EAAE,CAAC,EAAU,KAAK,CAAA,OAAA,EAAU,EAAE,CAAA,oBAAA,CAAsB;IAC5E,YAAY,EAAE,CAAC,UAAkB,KAAK,CAAA,mBAAA,EAAsB,UAAU,CAAA,CAAA,CAAG;IACzE,mBAAmB,EAAE,CAAC,UAAkB,KAAK,CAAA,mCAAA,EAAsC,UAAU,CAAA,CAAA,CAAG;AAChG,IAAA,uBAAuB,EAAE,CAAC,UAAkB,EAAE,WAAqB,KAAK,CAAA,iBAAA,EAAoB,UAAU,4CAA4C,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAE;AAC1K,IAAA,6BAA6B,EAAE,CAAC,OAAe,EAAE,WAAqB,KAA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F;AACA,QAAA,OAAO,OAAO;IAChB;uGAp+BW,iBAAiB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAjB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,iBAAiB,cAFhB,MAAM,EAAA,CAAA;;2FAEP,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAH7B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;AC5CD;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -9,6 +9,14 @@ interface KeyboardShortcut {
|
|
|
9
9
|
/**
|
|
10
10
|
* Single-step shortcuts keep the existing shape using `keys`/`macKeys`.
|
|
11
11
|
* For multi-step shortcuts, use `steps` (array of steps), where each step is an array of keys.
|
|
12
|
+
*
|
|
13
|
+
* The library allows registering multiple shortcuts with the same
|
|
14
|
+
* key combination as long as they are not simultaneously active. This enables:
|
|
15
|
+
* - Context-specific shortcuts (e.g., same key in different UI contexts)
|
|
16
|
+
* - Alternative shortcuts for the same action
|
|
17
|
+
* - Feature toggles with same keys for different modes
|
|
18
|
+
*
|
|
19
|
+
* Conflicts are only checked among active shortcuts, not all registered shortcuts.
|
|
12
20
|
*/
|
|
13
21
|
keys?: string[];
|
|
14
22
|
macKeys?: string[];
|
|
@@ -17,11 +25,83 @@ interface KeyboardShortcut {
|
|
|
17
25
|
action: () => void;
|
|
18
26
|
description: string;
|
|
19
27
|
activeUntil?: KeyboardShortcutActiveUntil;
|
|
28
|
+
/**
|
|
29
|
+
* Optional filter function for this specific shortcut.
|
|
30
|
+
* If provided, this filter is evaluated AFTER global filters.
|
|
31
|
+
* Both global filters AND this filter must return true for the shortcut to execute.
|
|
32
|
+
*
|
|
33
|
+
* @param event - The keyboard event to evaluate
|
|
34
|
+
* @returns `true` to allow this shortcut, `false` to ignore the event
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* // This shortcut works everywhere, even bypassing global input filters
|
|
39
|
+
* {
|
|
40
|
+
* id: 'emergency-save',
|
|
41
|
+
* keys: ['ctrl', 'shift', 's'],
|
|
42
|
+
* action: () => this.emergencySave(),
|
|
43
|
+
* filter: () => true, // Always allow
|
|
44
|
+
* description: 'Emergency save (works in inputs)'
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
filter?: KeyboardShortcutFilter;
|
|
20
49
|
}
|
|
21
50
|
interface KeyboardShortcutGroup {
|
|
22
51
|
id: string;
|
|
23
52
|
shortcuts: KeyboardShortcut[];
|
|
24
53
|
active: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Optional filter function for this entire group.
|
|
56
|
+
* If provided, this filter is evaluated AFTER global filters but BEFORE individual shortcut filters.
|
|
57
|
+
* The filter hierarchy is: Global filters → Group filter → Individual shortcut filter.
|
|
58
|
+
* All applicable filters must return true for a shortcut to execute.
|
|
59
|
+
*
|
|
60
|
+
* @param event - The keyboard event to evaluate
|
|
61
|
+
* @returns `true` to allow shortcuts in this group, `false` to ignore the event
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* // Modal shortcuts group that only works when modal is active
|
|
66
|
+
* keyboardService.registerGroup('modal-shortcuts', shortcuts, {
|
|
67
|
+
* filter: (event) => !!document.querySelector('.modal.active')
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
filter?: KeyboardShortcutFilter;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Filter function type for determining whether a keyboard event should be processed.
|
|
75
|
+
* Return `true` to process the event (allow shortcuts), `false` to ignore it.
|
|
76
|
+
*
|
|
77
|
+
* @param event - The keyboard event to evaluate
|
|
78
|
+
* @returns `true` to allow shortcuts, `false` to ignore the event
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* // Ignore shortcuts when typing in form elements
|
|
83
|
+
* const inputFilter: KeyboardShortcutFilter = (event) => {
|
|
84
|
+
* const target = event.target as HTMLElement;
|
|
85
|
+
* const tagName = target?.tagName?.toLowerCase();
|
|
86
|
+
* return !['input', 'textarea', 'select'].includes(tagName) && !target?.isContentEditable;
|
|
87
|
+
* };
|
|
88
|
+
* // keyboardService.addFilter('forms', inputFilter);
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
type KeyboardShortcutFilter = (event: KeyboardEvent) => boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Options for registering a group of keyboard shortcuts
|
|
94
|
+
*/
|
|
95
|
+
interface KeyboardShortcutGroupOptions {
|
|
96
|
+
/**
|
|
97
|
+
* Optional filter function for the entire group.
|
|
98
|
+
* This filter is evaluated after global filters but before individual shortcut filters.
|
|
99
|
+
*/
|
|
100
|
+
filter?: KeyboardShortcutFilter;
|
|
101
|
+
/**
|
|
102
|
+
* Optional lifecycle management for automatic cleanup
|
|
103
|
+
*/
|
|
104
|
+
activeUntil?: KeyboardShortcutActiveUntil;
|
|
25
105
|
}
|
|
26
106
|
/**
|
|
27
107
|
* Interface for keyboard shortcut data optimized for UI display
|
|
@@ -34,11 +114,20 @@ interface KeyboardShortcutUI {
|
|
|
34
114
|
}
|
|
35
115
|
|
|
36
116
|
declare class KeyboardShortcuts implements OnDestroy {
|
|
117
|
+
private static readonly MODIFIER_KEYS;
|
|
118
|
+
private readonly document;
|
|
119
|
+
private readonly window;
|
|
37
120
|
private readonly shortcuts;
|
|
38
121
|
private readonly groups;
|
|
39
122
|
private readonly activeShortcuts;
|
|
40
123
|
private readonly activeGroups;
|
|
41
124
|
private readonly currentlyDownKeys;
|
|
125
|
+
private readonly shortcutToGroup;
|
|
126
|
+
/**
|
|
127
|
+
* Named global filters that apply to all shortcuts.
|
|
128
|
+
* All global filters must return `true` for a shortcut to be processed.
|
|
129
|
+
*/
|
|
130
|
+
private readonly globalFilters;
|
|
42
131
|
private readonly state;
|
|
43
132
|
readonly shortcuts$: _angular_core.Signal<{
|
|
44
133
|
active: KeyboardShortcut[];
|
|
@@ -59,7 +148,6 @@ declare class KeyboardShortcuts implements OnDestroy {
|
|
|
59
148
|
private readonly blurListener;
|
|
60
149
|
private readonly visibilityListener;
|
|
61
150
|
private isListening;
|
|
62
|
-
protected isBrowser: boolean;
|
|
63
151
|
/** Default timeout (ms) for completing a multi-step sequence */
|
|
64
152
|
protected sequenceTimeout: number;
|
|
65
153
|
/** Runtime state for multi-step sequences */
|
|
@@ -85,19 +173,31 @@ declare class KeyboardShortcuts implements OnDestroy {
|
|
|
85
173
|
private formatStepsForDisplay;
|
|
86
174
|
private normalizeToSteps;
|
|
87
175
|
/**
|
|
88
|
-
* Check if a key combination is already registered
|
|
89
|
-
* @returns The ID of the conflicting shortcut, or null if no conflict
|
|
176
|
+
* Check if a key combination is already registered by an active shortcut
|
|
177
|
+
* @returns The ID of the conflicting active shortcut, or null if no active conflict
|
|
178
|
+
*/
|
|
179
|
+
private findActiveConflict;
|
|
180
|
+
/**
|
|
181
|
+
* Check if activating a shortcut would create key conflicts with other active shortcuts
|
|
182
|
+
* @returns Array of conflicting shortcut IDs that would be created by activation
|
|
90
183
|
*/
|
|
91
|
-
private
|
|
184
|
+
private findActivationConflicts;
|
|
92
185
|
/**
|
|
93
186
|
* Register a single keyboard shortcut
|
|
94
|
-
* @throws KeyboardShortcutError if shortcut ID is already registered or
|
|
187
|
+
* @throws KeyboardShortcutError if shortcut ID is already registered or if the shortcut would conflict with currently active shortcuts
|
|
95
188
|
*/
|
|
96
189
|
register(shortcut: KeyboardShortcut): void;
|
|
97
190
|
/**
|
|
98
191
|
* Register multiple keyboard shortcuts as a group
|
|
192
|
+
* @param groupId - Unique identifier for the group
|
|
193
|
+
* @param shortcuts - Array of shortcuts to register as a group
|
|
194
|
+
* @param options - Optional configuration including filter and activeUntil
|
|
99
195
|
* @throws KeyboardShortcutError if group ID is already registered or if any shortcut ID or key combination conflicts
|
|
100
196
|
*/
|
|
197
|
+
registerGroup(groupId: string, shortcuts: KeyboardShortcut[], options?: KeyboardShortcutGroupOptions): void;
|
|
198
|
+
/**
|
|
199
|
+
* @deprecated Use registerGroup(groupId, shortcuts, { activeUntil }) instead
|
|
200
|
+
*/
|
|
101
201
|
registerGroup(groupId: string, shortcuts: KeyboardShortcut[], activeUntil?: KeyboardShortcutActiveUntil): void;
|
|
102
202
|
/**
|
|
103
203
|
* Unregister a single keyboard shortcut
|
|
@@ -111,7 +211,7 @@ declare class KeyboardShortcuts implements OnDestroy {
|
|
|
111
211
|
unregisterGroup(groupId: string): void;
|
|
112
212
|
/**
|
|
113
213
|
* Activate a single keyboard shortcut
|
|
114
|
-
* @throws KeyboardShortcutError if shortcut ID doesn't exist
|
|
214
|
+
* @throws KeyboardShortcutError if shortcut ID doesn't exist or if activation would create key conflicts
|
|
115
215
|
*/
|
|
116
216
|
activate(shortcutId: string): void;
|
|
117
217
|
/**
|
|
@@ -121,7 +221,7 @@ declare class KeyboardShortcuts implements OnDestroy {
|
|
|
121
221
|
deactivate(shortcutId: string): void;
|
|
122
222
|
/**
|
|
123
223
|
* Activate a group of keyboard shortcuts
|
|
124
|
-
* @throws KeyboardShortcutError if group ID doesn't exist
|
|
224
|
+
* @throws KeyboardShortcutError if group ID doesn't exist or if activation would create key conflicts
|
|
125
225
|
*/
|
|
126
226
|
activateGroup(groupId: string): void;
|
|
127
227
|
/**
|
|
@@ -153,6 +253,76 @@ declare class KeyboardShortcuts implements OnDestroy {
|
|
|
153
253
|
* Get all registered groups
|
|
154
254
|
*/
|
|
155
255
|
getGroups(): ReadonlyMap<string, KeyboardShortcutGroup>;
|
|
256
|
+
/**
|
|
257
|
+
* Add a named global filter that applies to all shortcuts.
|
|
258
|
+
* All global filters must return `true` for a shortcut to execute.
|
|
259
|
+
*
|
|
260
|
+
* @param name - Unique name for this filter
|
|
261
|
+
* @param filter - Function that returns `true` to allow shortcuts, `false` to block them
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* // Block shortcuts in form elements
|
|
266
|
+
* keyboardService.addFilter('forms', (event) => {
|
|
267
|
+
* const target = event.target as HTMLElement;
|
|
268
|
+
* const tagName = target?.tagName?.toLowerCase();
|
|
269
|
+
* return !['input', 'textarea', 'select'].includes(tagName) && !target?.isContentEditable;
|
|
270
|
+
* });
|
|
271
|
+
*
|
|
272
|
+
* // Block shortcuts when modal is open
|
|
273
|
+
* keyboardService.addFilter('modal', (event) => {
|
|
274
|
+
* return !document.querySelector('.modal.active');
|
|
275
|
+
* });
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
addFilter(name: string, filter: KeyboardShortcutFilter): void;
|
|
279
|
+
/**
|
|
280
|
+
* Remove a named global filter.
|
|
281
|
+
*
|
|
282
|
+
* @param name - Name of the filter to remove
|
|
283
|
+
* @returns `true` if filter was removed, `false` if it didn't exist
|
|
284
|
+
*/
|
|
285
|
+
removeFilter(name: string): boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Get a named global filter.
|
|
288
|
+
*
|
|
289
|
+
* @param name - Name of the filter to retrieve
|
|
290
|
+
* @returns The filter function, or undefined if not found
|
|
291
|
+
*/
|
|
292
|
+
getFilter(name: string): KeyboardShortcutFilter | undefined;
|
|
293
|
+
/**
|
|
294
|
+
* Get all global filter names.
|
|
295
|
+
*
|
|
296
|
+
* @returns Array of filter names
|
|
297
|
+
*/
|
|
298
|
+
getFilterNames(): string[];
|
|
299
|
+
/**
|
|
300
|
+
* Remove all global filters.
|
|
301
|
+
*/
|
|
302
|
+
clearFilters(): void;
|
|
303
|
+
/**
|
|
304
|
+
* Check if a named filter exists.
|
|
305
|
+
*
|
|
306
|
+
* @param name - Name of the filter to check
|
|
307
|
+
* @returns `true` if filter exists, `false` otherwise
|
|
308
|
+
*/
|
|
309
|
+
hasFilter(name: string): boolean;
|
|
310
|
+
/**
|
|
311
|
+
* Find the group that contains a specific shortcut.
|
|
312
|
+
*
|
|
313
|
+
* @param shortcutId - The ID of the shortcut to find
|
|
314
|
+
* @returns The group containing the shortcut, or undefined if not found in any group
|
|
315
|
+
*/
|
|
316
|
+
private findGroupForShortcut;
|
|
317
|
+
/**
|
|
318
|
+
* Check if a keyboard event should be processed based on global, group, and per-shortcut filters.
|
|
319
|
+
* Filter hierarchy: Global filters → Group filter → Individual shortcut filter
|
|
320
|
+
*
|
|
321
|
+
* @param event - The keyboard event to evaluate
|
|
322
|
+
* @param shortcut - The shortcut being evaluated (for per-shortcut filter)
|
|
323
|
+
* @returns `true` if event should be processed, `false` if it should be ignored
|
|
324
|
+
*/
|
|
325
|
+
private shouldProcessEvent;
|
|
156
326
|
private startListening;
|
|
157
327
|
private stopListening;
|
|
158
328
|
protected handleKeydown(event: KeyboardEvent): void;
|
|
@@ -170,11 +340,6 @@ declare class KeyboardShortcuts implements OnDestroy {
|
|
|
170
340
|
* used by getPressedKeys/keysMatch.
|
|
171
341
|
*/
|
|
172
342
|
protected updateCurrentlyDownKeysOnKeydown(event: KeyboardEvent): void;
|
|
173
|
-
/**
|
|
174
|
-
* Build the pressed keys array used for matching against registered shortcuts.
|
|
175
|
-
* If multiple non-modifier keys are currently down, include them (chord support).
|
|
176
|
-
* Otherwise fall back to single main-key detection from the event for compatibility.
|
|
177
|
-
*/
|
|
178
343
|
/**
|
|
179
344
|
* Build the pressed keys set used for matching against registered shortcuts.
|
|
180
345
|
* If multiple non-modifier keys are currently down, include them (chord support).
|
|
@@ -184,7 +349,11 @@ declare class KeyboardShortcuts implements OnDestroy {
|
|
|
184
349
|
* without sorting or allocating sorted arrays on every event.
|
|
185
350
|
*/
|
|
186
351
|
protected buildPressedKeysForMatch(event: KeyboardEvent): Set<string>;
|
|
187
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Return the pressed keys for this event as a Set<string>.
|
|
354
|
+
* This is the canonical internal API used for matching.
|
|
355
|
+
*/
|
|
356
|
+
protected getPressedKeys(event: KeyboardEvent): Set<string>;
|
|
188
357
|
/**
|
|
189
358
|
* Compare pressed keys against a target key combination.
|
|
190
359
|
* Accepts either a Set<string> (preferred) or an array for backwards compatibility.
|
|
@@ -197,6 +366,10 @@ declare class KeyboardShortcuts implements OnDestroy {
|
|
|
197
366
|
private clearPendingSequence;
|
|
198
367
|
protected isMacPlatform(): boolean;
|
|
199
368
|
protected setupActiveUntil(activeUntil: KeyboardShortcutActiveUntil | undefined, unregister: () => void): void;
|
|
369
|
+
/**
|
|
370
|
+
* Evaluate group filters once per event and return the set of blocked group IDs.
|
|
371
|
+
*/
|
|
372
|
+
protected precomputeBlockedGroups(event: KeyboardEvent): Set<string>;
|
|
200
373
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<KeyboardShortcuts, never>;
|
|
201
374
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<KeyboardShortcuts>;
|
|
202
375
|
}
|
|
@@ -209,6 +382,9 @@ declare const KeyboardShortcutsErrors: {
|
|
|
209
382
|
readonly SHORTCUT_ALREADY_REGISTERED: (id: string) => string;
|
|
210
383
|
readonly GROUP_ALREADY_REGISTERED: (id: string) => string;
|
|
211
384
|
readonly KEY_CONFLICT: (conflictId: string) => string;
|
|
385
|
+
readonly ACTIVE_KEY_CONFLICT: (conflictId: string) => string;
|
|
386
|
+
readonly ACTIVATION_KEY_CONFLICT: (shortcutId: string, conflictIds: string[]) => string;
|
|
387
|
+
readonly GROUP_ACTIVATION_KEY_CONFLICT: (groupId: string, conflictIds: string[]) => string;
|
|
212
388
|
readonly SHORTCUT_IDS_ALREADY_REGISTERED: (ids: string[]) => string;
|
|
213
389
|
readonly DUPLICATE_SHORTCUTS_IN_GROUP: (ids: string[]) => string;
|
|
214
390
|
readonly KEY_CONFLICTS_IN_GROUP: (conflicts: string[]) => string;
|
|
@@ -240,6 +416,9 @@ declare class KeyboardShortcutsErrorFactory {
|
|
|
240
416
|
static shortcutAlreadyRegistered(id: string): KeyboardShortcutError;
|
|
241
417
|
static groupAlreadyRegistered(id: string): KeyboardShortcutError;
|
|
242
418
|
static keyConflict(conflictId: string): KeyboardShortcutError;
|
|
419
|
+
static activeKeyConflict(conflictId: string): KeyboardShortcutError;
|
|
420
|
+
static activationKeyConflict(shortcutId: string, conflictIds: string[]): KeyboardShortcutError;
|
|
421
|
+
static groupActivationKeyConflict(groupId: string, conflictIds: string[]): KeyboardShortcutError;
|
|
243
422
|
static shortcutIdsAlreadyRegistered(ids: string[]): KeyboardShortcutError;
|
|
244
423
|
static duplicateShortcutsInGroup(ids: string[]): KeyboardShortcutError;
|
|
245
424
|
static keyConflictsInGroup(conflicts: string[]): KeyboardShortcutError;
|
|
@@ -254,4 +433,4 @@ declare class KeyboardShortcutsErrorFactory {
|
|
|
254
433
|
}
|
|
255
434
|
|
|
256
435
|
export { KeyboardShortcutError, KeyboardShortcuts, KeyboardShortcutsErrorFactory, KeyboardShortcutsErrors };
|
|
257
|
-
export type { KeyStep, KeyboardShortcut, KeyboardShortcutActiveUntil, KeyboardShortcutGroup, KeyboardShortcutUI, KeyboardShortcutsErrorType };
|
|
436
|
+
export type { KeyStep, KeyboardShortcut, KeyboardShortcutActiveUntil, KeyboardShortcutFilter, KeyboardShortcutGroup, KeyboardShortcutGroupOptions, KeyboardShortcutUI, KeyboardShortcutsErrorType };
|