@tanstack/hotkeys 0.9.0 → 0.10.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/dist/_event-target.js +1 -2
- package/dist/_keyboard-event.js +1 -2
- package/dist/_match.js +1 -2
- package/dist/_named-keys.d.ts +3 -5
- package/dist/_named-keys.js +1 -2
- package/dist/_recorder-chord.js +1 -2
- package/dist/_recording-guard.js +1 -2
- package/dist/_registration.js +1 -2
- package/dist/conflicts.d.ts +4 -7
- package/dist/conflicts.js +1 -2
- package/dist/constants.d.ts +14 -17
- package/dist/constants.js +8 -9
- package/dist/display-labels.d.ts +7 -10
- package/dist/display-labels.js +1 -2
- package/dist/format.d.ts +9 -12
- package/dist/format.js +9 -7
- package/dist/hint.d.ts +3 -6
- package/dist/hint.js +1 -2
- package/dist/hotkey-manager.d.ts +8 -10
- package/dist/hotkey-manager.js +21 -3
- package/dist/hotkey-recorder.d.ts +4 -7
- package/dist/hotkey-recorder.js +9 -6
- package/dist/hotkey-sequence-recorder.d.ts +5 -8
- package/dist/hotkey-sequence-recorder.js +6 -7
- package/dist/hotkey.types.d.ts +15 -18
- package/dist/key-state-tracker.d.ts +4 -7
- package/dist/key-state-tracker.js +6 -3
- package/dist/key.types.d.ts +17 -20
- package/dist/match.d.ts +8 -11
- package/dist/match.js +1 -2
- package/dist/parse.d.ts +11 -14
- package/dist/parse.js +5 -4
- package/dist/platform.d.ts +3 -6
- package/dist/platform.js +1 -2
- package/dist/recorder-options.d.ts +6 -9
- package/dist/sequence-manager.d.ts +11 -14
- package/dist/sequence-manager.js +12 -7
- package/dist/validate.d.ts +5 -8
- package/dist/validate.js +1 -2
- package/package.json +8 -13
- package/dist/_event-target.cjs +0 -73
- package/dist/_event-target.cjs.map +0 -1
- package/dist/_event-target.js.map +0 -1
- package/dist/_keyboard-event.cjs +0 -83
- package/dist/_keyboard-event.cjs.map +0 -1
- package/dist/_keyboard-event.js.map +0 -1
- package/dist/_match.cjs +0 -49
- package/dist/_match.cjs.map +0 -1
- package/dist/_match.js.map +0 -1
- package/dist/_named-keys.cjs +0 -68
- package/dist/_named-keys.cjs.map +0 -1
- package/dist/_named-keys.d.cts +0 -8
- package/dist/_named-keys.js.map +0 -1
- package/dist/_recorder-chord.cjs +0 -44
- package/dist/_recorder-chord.cjs.map +0 -1
- package/dist/_recorder-chord.js.map +0 -1
- package/dist/_recording-guard.cjs +0 -59
- package/dist/_recording-guard.cjs.map +0 -1
- package/dist/_recording-guard.js.map +0 -1
- package/dist/_registration.cjs +0 -54
- package/dist/_registration.cjs.map +0 -1
- package/dist/_registration.js.map +0 -1
- package/dist/conflicts.cjs +0 -55
- package/dist/conflicts.cjs.map +0 -1
- package/dist/conflicts.d.cts +0 -39
- package/dist/conflicts.js.map +0 -1
- package/dist/constants.cjs +0 -410
- package/dist/constants.cjs.map +0 -1
- package/dist/constants.d.cts +0 -165
- package/dist/constants.js.map +0 -1
- package/dist/display-labels.cjs +0 -119
- package/dist/display-labels.cjs.map +0 -1
- package/dist/display-labels.d.cts +0 -93
- package/dist/display-labels.js.map +0 -1
- package/dist/format.cjs +0 -85
- package/dist/format.cjs.map +0 -1
- package/dist/format.d.cts +0 -99
- package/dist/format.js.map +0 -1
- package/dist/hint.cjs +0 -24
- package/dist/hint.cjs.map +0 -1
- package/dist/hint.d.cts +0 -23
- package/dist/hint.js.map +0 -1
- package/dist/hotkey-manager.cjs +0 -414
- package/dist/hotkey-manager.cjs.map +0 -1
- package/dist/hotkey-manager.d.cts +0 -234
- package/dist/hotkey-manager.js.map +0 -1
- package/dist/hotkey-recorder.cjs +0 -235
- package/dist/hotkey-recorder.cjs.map +0 -1
- package/dist/hotkey-recorder.d.cts +0 -119
- package/dist/hotkey-recorder.js.map +0 -1
- package/dist/hotkey-sequence-recorder.cjs +0 -255
- package/dist/hotkey-sequence-recorder.cjs.map +0 -1
- package/dist/hotkey-sequence-recorder.d.cts +0 -86
- package/dist/hotkey-sequence-recorder.js.map +0 -1
- package/dist/hotkey.types.d.cts +0 -236
- package/dist/index.cjs +0 -71
- package/dist/index.d.cts +0 -18
- package/dist/key-state-tracker.cjs +0 -197
- package/dist/key-state-tracker.cjs.map +0 -1
- package/dist/key-state-tracker.d.cts +0 -107
- package/dist/key-state-tracker.js.map +0 -1
- package/dist/key.types.d.cts +0 -82
- package/dist/match.cjs +0 -144
- package/dist/match.cjs.map +0 -1
- package/dist/match.d.cts +0 -101
- package/dist/match.js.map +0 -1
- package/dist/parse.cjs +0 -245
- package/dist/parse.cjs.map +0 -1
- package/dist/parse.d.cts +0 -134
- package/dist/parse.js.map +0 -1
- package/dist/platform.cjs +0 -55
- package/dist/platform.cjs.map +0 -1
- package/dist/platform.d.cts +0 -44
- package/dist/platform.js.map +0 -1
- package/dist/recorder-options.d.cts +0 -34
- package/dist/sequence-manager.cjs +0 -441
- package/dist/sequence-manager.cjs.map +0 -1
- package/dist/sequence-manager.d.cts +0 -172
- package/dist/sequence-manager.js.map +0 -1
- package/dist/validate.cjs +0 -112
- package/dist/validate.cjs.map +0 -1
- package/dist/validate.d.cts +0 -67
- package/dist/validate.js.map +0 -1
- package/src/_event-target.ts +0 -157
- package/src/_keyboard-event.ts +0 -101
- package/src/_match.ts +0 -96
- package/src/_named-keys.ts +0 -62
- package/src/_recorder-chord.ts +0 -76
- package/src/_recording-guard.ts +0 -63
- package/src/_registration.ts +0 -79
- package/src/conflicts.ts +0 -125
- package/src/constants.ts +0 -455
- package/src/display-labels.ts +0 -123
- package/src/format.ts +0 -201
- package/src/hint.ts +0 -42
- package/src/hotkey-manager.ts +0 -814
- package/src/hotkey-recorder.ts +0 -348
- package/src/hotkey-sequence-recorder.ts +0 -410
- package/src/hotkey.types.ts +0 -269
- package/src/index.ts +0 -17
- package/src/key-state-tracker.ts +0 -261
- package/src/key.types.ts +0 -268
- package/src/match.ts +0 -210
- package/src/parse.ts +0 -369
- package/src/platform.ts +0 -66
- package/src/recorder-options.ts +0 -34
- package/src/sequence-manager.ts +0 -769
- package/src/validate.ts +0 -179
package/dist/_event-target.js
CHANGED
|
@@ -67,5 +67,4 @@ function isEventForTarget(event, target) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
//#endregion
|
|
70
|
-
export { isEventForTarget, shouldIgnoreInputEvent };
|
|
71
|
-
//# sourceMappingURL=_event-target.js.map
|
|
70
|
+
export { getActiveElementForListenerTarget, isEventForTarget, isInputElement, shouldIgnoreInputEvent };
|
package/dist/_keyboard-event.js
CHANGED
|
@@ -72,5 +72,4 @@ function assertLogicalKey(key) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
//#endregion
|
|
75
|
-
export { assertLogicalKey, codeToLogicalKey, isAsciiLetter, isLatinLetter, isPrintableKey, keysEqual, normalizeKeyboardEvent, splitHotkeyParts };
|
|
76
|
-
//# sourceMappingURL=_keyboard-event.js.map
|
|
75
|
+
export { assertLogicalKey, codeToLogicalKey, isAsciiLetter, isLatinLetter, isPrintableKey, keysEqual, normalizeKeyboardEvent, splitHotkeyParts };
|
package/dist/_match.js
CHANGED
package/dist/_named-keys.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
//#region src/_named-keys.d.ts
|
|
2
2
|
/** Names defined for both KeyboardEvent.key and KeyboardEvent.code, beyond the basic key groups. */
|
|
3
|
-
declare const SHARED_NAMED_KEYS: readonly ["CapsLock", "ContextMenu", "Convert", "KanaMode", "NonConvert", "Help", "Insert", "NumLock", "Fn", "FnLock", "PrintScreen", "ScrollLock", "Pause", "BrowserBack", "BrowserFavorites", "BrowserForward", "BrowserHome", "BrowserRefresh", "BrowserSearch", "BrowserStop", "Eject", "LaunchMail", "MediaPlayPause", "MediaStop", "MediaTrackNext", "MediaTrackPrevious", "Power", "AudioVolumeDown", "AudioVolumeMute", "AudioVolumeUp", "WakeUp", "Hyper", "Super", "Again", "Copy", "Cut", "Find", "Open", "Paste", "Props", "Select", "Undo", "Hiragana", "Katakana"];
|
|
3
|
+
export declare const SHARED_NAMED_KEYS: readonly ["CapsLock", "ContextMenu", "Convert", "KanaMode", "NonConvert", "Help", "Insert", "NumLock", "Fn", "FnLock", "PrintScreen", "ScrollLock", "Pause", "BrowserBack", "BrowserFavorites", "BrowserForward", "BrowserHome", "BrowserRefresh", "BrowserSearch", "BrowserStop", "Eject", "LaunchMail", "MediaPlayPause", "MediaStop", "MediaTrackNext", "MediaTrackPrevious", "Power", "AudioVolumeDown", "AudioVolumeMute", "AudioVolumeUp", "WakeUp", "Hyper", "Super", "Again", "Copy", "Cut", "Find", "Open", "Paste", "Props", "Select", "Undo", "Hiragana", "Katakana"];
|
|
4
4
|
/** Logical counterparts whose physical positions use different names (for example Sleep and Lang1). */
|
|
5
|
-
declare const LOGICAL_ONLY_NAMED_KEYS: readonly ["Clear", "Cancel", "Standby", "LaunchApplication1", "LaunchApplication2", "LaunchMediaPlayer", "HangulMode", "HanjaMode", "Zenkaku", "Hankaku", "ZenkakuHankaku"];
|
|
6
|
-
//#endregion
|
|
7
|
-
export { LOGICAL_ONLY_NAMED_KEYS, SHARED_NAMED_KEYS };
|
|
8
|
-
//# sourceMappingURL=_named-keys.d.ts.map
|
|
5
|
+
export declare const LOGICAL_ONLY_NAMED_KEYS: readonly ["Clear", "Cancel", "Standby", "LaunchApplication1", "LaunchApplication2", "LaunchMediaPlayer", "HangulMode", "HanjaMode", "Zenkaku", "Hankaku", "ZenkakuHankaku"];
|
|
6
|
+
//#endregion
|
package/dist/_named-keys.js
CHANGED
package/dist/_recorder-chord.js
CHANGED
package/dist/_recording-guard.js
CHANGED
|
@@ -52,5 +52,4 @@ function isRecordingEvent(event) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
//#endregion
|
|
55
|
-
export { beginRecording, captureRecordingEvent, endRecording, isRecordingEvent };
|
|
56
|
-
//# sourceMappingURL=_recording-guard.js.map
|
|
55
|
+
export { beginRecording, captureRecordingEvent, endRecording, isRecordingEvent };
|
package/dist/_registration.js
CHANGED
|
@@ -46,5 +46,4 @@ function optionsEqual(left, right) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
|
-
export { defaultHotkeyOptions, getDefaultIgnoreInputs, handleConflict, optionsEqual };
|
|
50
|
-
//# sourceMappingURL=_registration.js.map
|
|
49
|
+
export { defaultHotkeyOptions, getDefaultIgnoreInputs, handleConflict, optionsEqual };
|
package/dist/conflicts.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { RegisterableHotkey } from "./hotkey.types.js";
|
|
2
2
|
import { HotkeyRegistrationView } from "./hotkey-manager.js";
|
|
3
3
|
import { SequenceRegistrationView } from "./sequence-manager.js";
|
|
4
|
-
|
|
5
4
|
//#region src/conflicts.d.ts
|
|
6
|
-
type HotkeyConflict = {
|
|
5
|
+
export type HotkeyConflict = {
|
|
7
6
|
type: 'hotkey';
|
|
8
7
|
registration: HotkeyRegistrationView;
|
|
9
8
|
} | {
|
|
10
9
|
type: 'sequence';
|
|
11
10
|
registration: SequenceRegistrationView;
|
|
12
11
|
};
|
|
13
|
-
interface HotkeyConflictOptions {
|
|
12
|
+
export interface HotkeyConflictOptions {
|
|
14
13
|
/** Intended registration target. Defaults to document; disjoint targets are excluded. */
|
|
15
14
|
target?: HTMLElement | Document | Window;
|
|
16
15
|
/** Check all targets instead of overlapping targets. Default: overlapping. */
|
|
@@ -33,7 +32,5 @@ interface HotkeyConflictOptions {
|
|
|
33
32
|
* With source events, also checks observed logical/physical overlap. Does not
|
|
34
33
|
* discover unmounted handlers, external listeners, or other keyboard layouts.
|
|
35
34
|
*/
|
|
36
|
-
declare function findHotkeyConflicts(candidate: RegisterableHotkey | ReadonlyArray<RegisterableHotkey>, options?: HotkeyConflictOptions): Array<HotkeyConflict>;
|
|
37
|
-
//#endregion
|
|
38
|
-
export { HotkeyConflict, HotkeyConflictOptions, findHotkeyConflicts };
|
|
39
|
-
//# sourceMappingURL=conflicts.d.ts.map
|
|
35
|
+
export declare function findHotkeyConflicts(candidate: RegisterableHotkey | ReadonlyArray<RegisterableHotkey>, options?: HotkeyConflictOptions): Array<HotkeyConflict>;
|
|
36
|
+
//#endregion
|
package/dist/conflicts.js
CHANGED
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CanonicalModifier, EditingKey, FunctionKey, LetterKey, NavigationKey, NumberKey, PunctuationKey } from "./key.types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/constants.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Canonical order for modifiers in normalized hotkey strings.
|
|
@@ -15,7 +14,7 @@ import { CanonicalModifier, EditingKey, FunctionKey, LetterKey, NavigationKey, N
|
|
|
15
14
|
* // Normalized: 'Control+Alt+Shift+Meta+S' (following MODIFIER_ORDER)
|
|
16
15
|
* ```
|
|
17
16
|
*/
|
|
18
|
-
declare const MODIFIER_ORDER: Array<CanonicalModifier>;
|
|
17
|
+
export declare const MODIFIER_ORDER: Array<CanonicalModifier>;
|
|
19
18
|
/**
|
|
20
19
|
* Set of canonical modifier key names for fast lookup.
|
|
21
20
|
*
|
|
@@ -23,7 +22,7 @@ declare const MODIFIER_ORDER: Array<CanonicalModifier>;
|
|
|
23
22
|
* a modifier is released so we can clear non-modifier keys whose keyup events
|
|
24
23
|
* may have been swallowed by the OS (e.g. macOS Cmd+key combos).
|
|
25
24
|
*/
|
|
26
|
-
declare const MODIFIER_KEYS: Set<string>;
|
|
25
|
+
export declare const MODIFIER_KEYS: Set<string>;
|
|
27
26
|
/**
|
|
28
27
|
* Maps modifier key aliases to their canonical form or platform-adaptive 'Mod'.
|
|
29
28
|
*
|
|
@@ -43,14 +42,14 @@ declare const MODIFIER_KEYS: Set<string>;
|
|
|
43
42
|
* MODIFIER_ALIASES['Mod'] // 'Mod' (resolved at runtime)
|
|
44
43
|
* ```
|
|
45
44
|
*/
|
|
46
|
-
declare const MODIFIER_ALIASES: Record<string, CanonicalModifier | 'Mod'>;
|
|
45
|
+
export declare const MODIFIER_ALIASES: Record<string, CanonicalModifier | 'Mod'>;
|
|
47
46
|
/**
|
|
48
47
|
* Set of all valid letter keys (A-Z).
|
|
49
48
|
*
|
|
50
49
|
* Used for validation and type checking. Letter keys are matched case-insensitively
|
|
51
50
|
* in hotkey matching, but normalized to uppercase in canonical form.
|
|
52
51
|
*/
|
|
53
|
-
declare const LETTER_KEYS: Set<LetterKey>;
|
|
52
|
+
export declare const LETTER_KEYS: Set<LetterKey>;
|
|
54
53
|
/**
|
|
55
54
|
* Set of all valid number keys (0-9).
|
|
56
55
|
*
|
|
@@ -58,14 +57,14 @@ declare const LETTER_KEYS: Set<LetterKey>;
|
|
|
58
57
|
* so they're excluded from Shift-based hotkey combinations to avoid
|
|
59
58
|
* layout-dependent behavior.
|
|
60
59
|
*/
|
|
61
|
-
declare const NUMBER_KEYS: Set<NumberKey>;
|
|
60
|
+
export declare const NUMBER_KEYS: Set<NumberKey>;
|
|
62
61
|
/**
|
|
63
62
|
* Set of all valid function keys (F1-F24).
|
|
64
63
|
*
|
|
65
64
|
* Function keys are commonly used for system shortcuts (e.g., F12 for DevTools,
|
|
66
65
|
* Alt+F4 to close windows) and application-specific commands.
|
|
67
66
|
*/
|
|
68
|
-
declare const FUNCTION_KEYS: Set<FunctionKey>;
|
|
67
|
+
export declare const FUNCTION_KEYS: Set<FunctionKey>;
|
|
69
68
|
/**
|
|
70
69
|
* Set of all valid navigation keys for cursor movement and document navigation.
|
|
71
70
|
*
|
|
@@ -73,7 +72,7 @@ declare const FUNCTION_KEYS: Set<FunctionKey>;
|
|
|
73
72
|
* These keys are commonly combined with modifiers for selection (Shift+ArrowUp) or
|
|
74
73
|
* navigation shortcuts (Alt+ArrowLeft for back).
|
|
75
74
|
*/
|
|
76
|
-
declare const NAVIGATION_KEYS: Set<NavigationKey>;
|
|
75
|
+
export declare const NAVIGATION_KEYS: Set<NavigationKey>;
|
|
77
76
|
/**
|
|
78
77
|
* Set of all valid editing and special keys.
|
|
79
78
|
*
|
|
@@ -81,7 +80,7 @@ declare const NAVIGATION_KEYS: Set<NavigationKey>;
|
|
|
81
80
|
* special actions (Escape, Space). These keys are frequently combined with modifiers
|
|
82
81
|
* for editor shortcuts (Mod+Enter to submit, Shift+Tab to go back).
|
|
83
82
|
*/
|
|
84
|
-
declare const EDITING_KEYS: Set<EditingKey>;
|
|
83
|
+
export declare const EDITING_KEYS: Set<EditingKey>;
|
|
85
84
|
/**
|
|
86
85
|
* Set of all valid punctuation keys commonly used in keyboard shortcuts.
|
|
87
86
|
*
|
|
@@ -94,7 +93,7 @@ declare const EDITING_KEYS: Set<EditingKey>;
|
|
|
94
93
|
* Note: Punctuation keys are affected by Shift (Shift+',' → '<' on US layout),
|
|
95
94
|
* so they're excluded from Shift-based hotkey combinations to avoid layout-dependent behavior.
|
|
96
95
|
*/
|
|
97
|
-
declare const PUNCTUATION_KEYS: Set<PunctuationKey>;
|
|
96
|
+
export declare const PUNCTUATION_KEYS: Set<PunctuationKey>;
|
|
98
97
|
/**
|
|
99
98
|
* Maps `KeyboardEvent.code` values for punctuation keys to their canonical characters.
|
|
100
99
|
*
|
|
@@ -104,7 +103,7 @@ declare const PUNCTUATION_KEYS: Set<PunctuationKey>;
|
|
|
104
103
|
* falling back to `event.code` for punctuation keys, similar to the existing `Key*`/`Digit*`
|
|
105
104
|
* fallbacks for letters and digits.
|
|
106
105
|
*/
|
|
107
|
-
declare const PUNCTUATION_CODE_MAP: Record<string, string>;
|
|
106
|
+
export declare const PUNCTUATION_CODE_MAP: Record<string, string>;
|
|
108
107
|
/**
|
|
109
108
|
* Set of all valid non-modifier keys.
|
|
110
109
|
*
|
|
@@ -119,7 +118,7 @@ declare const PUNCTUATION_CODE_MAP: Record<string, string>;
|
|
|
119
118
|
* @see {@link EDITING_KEYS}
|
|
120
119
|
* @see {@link PUNCTUATION_KEYS}
|
|
121
120
|
*/
|
|
122
|
-
declare const ALL_KEYS: Set<LetterKey | NumberKey | FunctionKey | NavigationKey | EditingKey | PunctuationKey | "CapsLock" | "ContextMenu" | "Convert" | "KanaMode" | "NonConvert" | "Help" | "Insert" | "NumLock" | "Fn" | "FnLock" | "PrintScreen" | "ScrollLock" | "Pause" | "BrowserBack" | "BrowserFavorites" | "BrowserForward" | "BrowserHome" | "BrowserRefresh" | "BrowserSearch" | "BrowserStop" | "Eject" | "LaunchMail" | "MediaPlayPause" | "MediaStop" | "MediaTrackNext" | "MediaTrackPrevious" | "Power" | "AudioVolumeDown" | "AudioVolumeMute" | "AudioVolumeUp" | "WakeUp" | "Hyper" | "Super" | "Again" | "Copy" | "Cut" | "Find" | "Open" | "Paste" | "Props" | "Select" | "Undo" | "Hiragana" | "Katakana" | "Clear" | "Cancel" | "Standby" | "LaunchApplication1" | "LaunchApplication2" | "LaunchMediaPlayer" | "HangulMode" | "HanjaMode" | "Zenkaku" | "Hankaku" | "ZenkakuHankaku">;
|
|
121
|
+
export declare const ALL_KEYS: Set<LetterKey | NumberKey | FunctionKey | NavigationKey | EditingKey | PunctuationKey | "CapsLock" | "ContextMenu" | "Convert" | "KanaMode" | "NonConvert" | "Help" | "Insert" | "NumLock" | "Fn" | "FnLock" | "PrintScreen" | "ScrollLock" | "Pause" | "BrowserBack" | "BrowserFavorites" | "BrowserForward" | "BrowserHome" | "BrowserRefresh" | "BrowserSearch" | "BrowserStop" | "Eject" | "LaunchMail" | "MediaPlayPause" | "MediaStop" | "MediaTrackNext" | "MediaTrackPrevious" | "Power" | "AudioVolumeDown" | "AudioVolumeMute" | "AudioVolumeUp" | "WakeUp" | "Hyper" | "Super" | "Again" | "Copy" | "Cut" | "Find" | "Open" | "Paste" | "Props" | "Select" | "Undo" | "Hiragana" | "Katakana" | "Clear" | "Cancel" | "Standby" | "LaunchApplication1" | "LaunchApplication2" | "LaunchMediaPlayer" | "HangulMode" | "HanjaMode" | "Zenkaku" | "Hankaku" | "ZenkakuHankaku">;
|
|
123
122
|
/**
|
|
124
123
|
* Normalizes a key name to its canonical form.
|
|
125
124
|
*
|
|
@@ -144,7 +143,7 @@ declare const ALL_KEYS: Set<LetterKey | NumberKey | FunctionKey | NavigationKey
|
|
|
144
143
|
* normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)
|
|
145
144
|
* ```
|
|
146
145
|
*/
|
|
147
|
-
declare function isSingleLetterKey(key: string): boolean;
|
|
146
|
+
export declare function isSingleLetterKey(key: string): boolean;
|
|
148
147
|
/**
|
|
149
148
|
* Normalizes a key name to its canonical form.
|
|
150
149
|
*
|
|
@@ -159,7 +158,5 @@ declare function isSingleLetterKey(key: string): boolean;
|
|
|
159
158
|
* normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)
|
|
160
159
|
* ```
|
|
161
160
|
*/
|
|
162
|
-
declare function normalizeKeyName(key: string): string;
|
|
163
|
-
//#endregion
|
|
164
|
-
export { ALL_KEYS, EDITING_KEYS, FUNCTION_KEYS, LETTER_KEYS, MODIFIER_ALIASES, MODIFIER_KEYS, MODIFIER_ORDER, NAVIGATION_KEYS, NUMBER_KEYS, PUNCTUATION_CODE_MAP, PUNCTUATION_KEYS, isSingleLetterKey, normalizeKeyName };
|
|
165
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
161
|
+
export declare function normalizeKeyName(key: string): string;
|
|
162
|
+
//#endregion
|
package/dist/constants.js
CHANGED
|
@@ -80,7 +80,7 @@ const MODIFIER_ALIASES = {
|
|
|
80
80
|
* Used for validation and type checking. Letter keys are matched case-insensitively
|
|
81
81
|
* in hotkey matching, but normalized to uppercase in canonical form.
|
|
82
82
|
*/
|
|
83
|
-
const LETTER_KEYS = new Set([
|
|
83
|
+
const LETTER_KEYS = /* @__PURE__ */ new Set([
|
|
84
84
|
"A",
|
|
85
85
|
"B",
|
|
86
86
|
"C",
|
|
@@ -115,7 +115,7 @@ const LETTER_KEYS = new Set([
|
|
|
115
115
|
* so they're excluded from Shift-based hotkey combinations to avoid
|
|
116
116
|
* layout-dependent behavior.
|
|
117
117
|
*/
|
|
118
|
-
const NUMBER_KEYS = new Set([
|
|
118
|
+
const NUMBER_KEYS = /* @__PURE__ */ new Set([
|
|
119
119
|
"0",
|
|
120
120
|
"1",
|
|
121
121
|
"2",
|
|
@@ -133,7 +133,7 @@ const NUMBER_KEYS = new Set([
|
|
|
133
133
|
* Function keys are commonly used for system shortcuts (e.g., F12 for DevTools,
|
|
134
134
|
* Alt+F4 to close windows) and application-specific commands.
|
|
135
135
|
*/
|
|
136
|
-
const FUNCTION_KEYS = new Set([
|
|
136
|
+
const FUNCTION_KEYS = /* @__PURE__ */ new Set([
|
|
137
137
|
"F1",
|
|
138
138
|
"F2",
|
|
139
139
|
"F3",
|
|
@@ -166,7 +166,7 @@ const FUNCTION_KEYS = new Set([
|
|
|
166
166
|
* These keys are commonly combined with modifiers for selection (Shift+ArrowUp) or
|
|
167
167
|
* navigation shortcuts (Alt+ArrowLeft for back).
|
|
168
168
|
*/
|
|
169
|
-
const NAVIGATION_KEYS = new Set([
|
|
169
|
+
const NAVIGATION_KEYS = /* @__PURE__ */ new Set([
|
|
170
170
|
"ArrowUp",
|
|
171
171
|
"ArrowDown",
|
|
172
172
|
"ArrowLeft",
|
|
@@ -183,7 +183,7 @@ const NAVIGATION_KEYS = new Set([
|
|
|
183
183
|
* special actions (Escape, Space). These keys are frequently combined with modifiers
|
|
184
184
|
* for editor shortcuts (Mod+Enter to submit, Shift+Tab to go back).
|
|
185
185
|
*/
|
|
186
|
-
const EDITING_KEYS = new Set([
|
|
186
|
+
const EDITING_KEYS = /* @__PURE__ */ new Set([
|
|
187
187
|
"Enter",
|
|
188
188
|
"Escape",
|
|
189
189
|
"Space",
|
|
@@ -203,7 +203,7 @@ const EDITING_KEYS = new Set([
|
|
|
203
203
|
* Note: Punctuation keys are affected by Shift (Shift+',' → '<' on US layout),
|
|
204
204
|
* so they're excluded from Shift-based hotkey combinations to avoid layout-dependent behavior.
|
|
205
205
|
*/
|
|
206
|
-
const PUNCTUATION_KEYS = new Set([
|
|
206
|
+
const PUNCTUATION_KEYS = /* @__PURE__ */ new Set([
|
|
207
207
|
"/",
|
|
208
208
|
"[",
|
|
209
209
|
"]",
|
|
@@ -273,7 +273,7 @@ const PUNCTUATION_CODE_MAP = {
|
|
|
273
273
|
* @see {@link EDITING_KEYS}
|
|
274
274
|
* @see {@link PUNCTUATION_KEYS}
|
|
275
275
|
*/
|
|
276
|
-
const ALL_KEYS = new Set([
|
|
276
|
+
const ALL_KEYS = /* @__PURE__ */ new Set([
|
|
277
277
|
...LETTER_KEYS,
|
|
278
278
|
...NUMBER_KEYS,
|
|
279
279
|
...FUNCTION_KEYS,
|
|
@@ -394,5 +394,4 @@ function normalizeKeyName(key) {
|
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
//#endregion
|
|
397
|
-
export { ALL_KEYS, EDITING_KEYS, FUNCTION_KEYS, LETTER_KEYS, MODIFIER_ALIASES, MODIFIER_KEYS, MODIFIER_ORDER, NAVIGATION_KEYS, NUMBER_KEYS, PUNCTUATION_CODE_MAP, PUNCTUATION_KEYS, isSingleLetterKey, normalizeKeyName };
|
|
398
|
-
//# sourceMappingURL=constants.js.map
|
|
397
|
+
export { ALL_KEYS, EDITING_KEYS, FUNCTION_KEYS, LETTER_KEYS, MODIFIER_ALIASES, MODIFIER_KEYS, MODIFIER_ORDER, NAVIGATION_KEYS, NUMBER_KEYS, PUNCTUATION_CODE_MAP, PUNCTUATION_KEYS, isSingleLetterKey, normalizeKeyName };
|
package/dist/display-labels.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CanonicalModifier } from "./key.types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/display-labels.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Modifier key symbols for macOS display.
|
|
@@ -16,7 +15,7 @@ import { CanonicalModifier } from "./key.types.js";
|
|
|
16
15
|
* MAC_MODIFIER_SYMBOLS['Shift'] // '⇧'
|
|
17
16
|
* ```
|
|
18
17
|
*/
|
|
19
|
-
declare const MAC_MODIFIER_SYMBOLS: Record<CanonicalModifier | 'Mod', string>;
|
|
18
|
+
export declare const MAC_MODIFIER_SYMBOLS: Record<CanonicalModifier | 'Mod', string>;
|
|
20
19
|
/**
|
|
21
20
|
* Modifier key labels for macOS display.
|
|
22
21
|
*
|
|
@@ -32,7 +31,7 @@ declare const MAC_MODIFIER_SYMBOLS: Record<CanonicalModifier | 'Mod', string>;
|
|
|
32
31
|
* MAC_MODIFIER_LABELS['Meta'] // 'cmd'
|
|
33
32
|
* ```
|
|
34
33
|
*/
|
|
35
|
-
declare const MAC_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string>;
|
|
34
|
+
export declare const MAC_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string>;
|
|
36
35
|
/**
|
|
37
36
|
* Modifier key labels for Windows/Linux display.
|
|
38
37
|
*
|
|
@@ -48,9 +47,9 @@ declare const MAC_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string>;
|
|
|
48
47
|
* STANDARD_MODIFIER_LABELS['Shift'] // 'Shift'
|
|
49
48
|
* ```
|
|
50
49
|
*/
|
|
51
|
-
declare const WINDOWS_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string>;
|
|
52
|
-
declare const LINUX_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string>;
|
|
53
|
-
declare const PUNCTUATION_KEY_DISPLAY_LABELS: {
|
|
50
|
+
export declare const WINDOWS_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string>;
|
|
51
|
+
export declare const LINUX_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string>;
|
|
52
|
+
export declare const PUNCTUATION_KEY_DISPLAY_LABELS: {
|
|
54
53
|
readonly '`': "Backquote";
|
|
55
54
|
readonly '\\': "Backslash";
|
|
56
55
|
readonly '[': "Left Bracket";
|
|
@@ -76,7 +75,7 @@ declare const PUNCTUATION_KEY_DISPLAY_LABELS: {
|
|
|
76
75
|
* KEY_DISPLAY_SYMBOLS['Space'] // '␣'
|
|
77
76
|
* ```
|
|
78
77
|
*/
|
|
79
|
-
declare const KEY_DISPLAY_SYMBOLS: {
|
|
78
|
+
export declare const KEY_DISPLAY_SYMBOLS: {
|
|
80
79
|
readonly ArrowUp: "↑";
|
|
81
80
|
readonly ArrowDown: "↓";
|
|
82
81
|
readonly ArrowLeft: "←";
|
|
@@ -88,6 +87,4 @@ declare const KEY_DISPLAY_SYMBOLS: {
|
|
|
88
87
|
readonly Tab: "⇥";
|
|
89
88
|
readonly Space: "␣";
|
|
90
89
|
};
|
|
91
|
-
//#endregion
|
|
92
|
-
export { KEY_DISPLAY_SYMBOLS, LINUX_MODIFIER_LABELS, MAC_MODIFIER_LABELS, MAC_MODIFIER_SYMBOLS, PUNCTUATION_KEY_DISPLAY_LABELS, WINDOWS_MODIFIER_LABELS };
|
|
93
|
-
//# sourceMappingURL=display-labels.d.ts.map
|
|
90
|
+
//#endregion
|
package/dist/display-labels.js
CHANGED
|
@@ -109,5 +109,4 @@ const KEY_DISPLAY_SYMBOLS = {
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
//#endregion
|
|
112
|
-
export { KEY_DISPLAY_SYMBOLS, LINUX_MODIFIER_LABELS, MAC_MODIFIER_LABELS, MAC_MODIFIER_SYMBOLS, PUNCTUATION_KEY_DISPLAY_LABELS, WINDOWS_MODIFIER_LABELS };
|
|
113
|
-
//# sourceMappingURL=display-labels.js.map
|
|
112
|
+
export { KEY_DISPLAY_SYMBOLS, LINUX_MODIFIER_LABELS, MAC_MODIFIER_LABELS, MAC_MODIFIER_SYMBOLS, PUNCTUATION_KEY_DISPLAY_LABELS, WINDOWS_MODIFIER_LABELS };
|
package/dist/format.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Hotkey, ParsedHotkey, RegisterableHotkey } from "./hotkey.types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/format.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Joins stored sequence steps with spaces, preserving physical code tokens.
|
|
@@ -14,7 +13,7 @@ import { Hotkey, ParsedHotkey, RegisterableHotkey } from "./hotkey.types.js";
|
|
|
14
13
|
* formatHotkeySequence(['D', 'I', 'W']) // 'D I W'
|
|
15
14
|
* ```
|
|
16
15
|
*/
|
|
17
|
-
declare function formatHotkeySequence(sequence: Array<Hotkey>): string;
|
|
16
|
+
export declare function formatHotkeySequence(sequence: Array<Hotkey>): string;
|
|
18
17
|
/**
|
|
19
18
|
* Converts a ParsedHotkey back to a hotkey string.
|
|
20
19
|
*
|
|
@@ -27,8 +26,8 @@ declare function formatHotkeySequence(sequence: Array<Hotkey>): string;
|
|
|
27
26
|
* // Returns: 'Control+Shift+S'
|
|
28
27
|
* ```
|
|
29
28
|
*/
|
|
30
|
-
declare function formatHotkey(parsed: ParsedHotkey): string;
|
|
31
|
-
type DisplayHotkey = RegisterableHotkey | ParsedHotkey | (string & {});
|
|
29
|
+
export declare function formatHotkey(parsed: ParsedHotkey): string;
|
|
30
|
+
export type DisplayHotkey = RegisterableHotkey | ParsedHotkey | (string & {});
|
|
32
31
|
/**
|
|
33
32
|
* Formats a hotkey for display in a user interface.
|
|
34
33
|
*
|
|
@@ -56,21 +55,21 @@ type DisplayHotkey = RegisterableHotkey | ParsedHotkey | (string & {});
|
|
|
56
55
|
* // Returns: 'Esc' (on all platforms)
|
|
57
56
|
* ```
|
|
58
57
|
*/
|
|
59
|
-
declare function formatForDisplay(hotkey: DisplayHotkey, options: FormatDisplayOptions & {
|
|
58
|
+
export declare function formatForDisplay(hotkey: DisplayHotkey, options: FormatDisplayOptions & {
|
|
60
59
|
parts: true;
|
|
61
60
|
}): Array<string>;
|
|
62
|
-
declare function formatForDisplay(hotkey: DisplayHotkey, options?: FormatDisplayOptions & {
|
|
61
|
+
export declare function formatForDisplay(hotkey: DisplayHotkey, options?: FormatDisplayOptions & {
|
|
63
62
|
parts?: false;
|
|
64
63
|
}): string;
|
|
65
|
-
declare function formatForDisplay(hotkey: DisplayHotkey, options: FormatDisplayOptions): string | Array<string>;
|
|
64
|
+
export declare function formatForDisplay(hotkey: DisplayHotkey, options: FormatDisplayOptions): string | Array<string>;
|
|
66
65
|
/**
|
|
67
66
|
* @deprecated Use {@link formatForDisplay} instead with `useSymbols: false` option.
|
|
68
67
|
*/
|
|
69
|
-
declare function formatWithLabels(hotkey: RegisterableHotkey, options?: Omit<FormatDisplayOptions, 'useSymbols' | 'parts'>): string;
|
|
68
|
+
export declare function formatWithLabels(hotkey: RegisterableHotkey, options?: Omit<FormatDisplayOptions, 'useSymbols' | 'parts'>): string;
|
|
70
69
|
/**
|
|
71
70
|
* Options for formatting hotkeys for display.
|
|
72
71
|
*/
|
|
73
|
-
interface FormatDisplayOptions {
|
|
72
|
+
export interface FormatDisplayOptions {
|
|
74
73
|
/** The target platform. Defaults to auto-detection. */
|
|
75
74
|
platform?: 'mac' | 'windows' | 'linux';
|
|
76
75
|
/** Whether to use symbols for the display. Defaults to true. */
|
|
@@ -94,6 +93,4 @@ interface FormatDisplayOptions {
|
|
|
94
93
|
/** Override the separator between display tokens. Defaults to platform-specific formatting when null/undefined. */
|
|
95
94
|
separatorToken?: string | null;
|
|
96
95
|
}
|
|
97
|
-
//#endregion
|
|
98
|
-
export { DisplayHotkey, FormatDisplayOptions, formatForDisplay, formatHotkey, formatHotkeySequence, formatWithLabels };
|
|
99
|
-
//# sourceMappingURL=format.d.ts.map
|
|
96
|
+
//#endregion
|
package/dist/format.js
CHANGED
|
@@ -46,7 +46,8 @@ function formatForDisplay(hotkey, options = {}) {
|
|
|
46
46
|
const modifierSymbols = typeof symbols === "boolean" ? symbols : symbols.modifiers ?? true;
|
|
47
47
|
const keySymbols = typeof symbols === "boolean" ? symbols : symbols.keys ?? true;
|
|
48
48
|
const separator = options.separatorToken ?? (platform === "mac" && modifierSymbols ? " " : "+");
|
|
49
|
-
const
|
|
49
|
+
const normalized = typeof hotkey === "object" && "modifiers" in hotkey ? normalizeHotkeyFromParsed(hotkey, platform) : normalizeRegisterableHotkey(hotkey, platform);
|
|
50
|
+
const parts = splitHotkeyParts(normalized).map((segment) => {
|
|
50
51
|
if (isModifierKey(segment)) {
|
|
51
52
|
const modifier = MODIFIER_ALIASES[segment] ?? MODIFIER_ALIASES[segment.toLowerCase()];
|
|
52
53
|
return platform === "mac" ? modifierSymbols ? MAC_MODIFIER_SYMBOLS[modifier] : MAC_MODIFIER_LABELS[modifier] : platform === "windows" ? WINDOWS_MODIFIER_LABELS[modifier] : LINUX_MODIFIER_LABELS[modifier];
|
|
@@ -58,10 +59,12 @@ function formatForDisplay(hotkey, options = {}) {
|
|
|
58
59
|
let displayKey = code ?? segment;
|
|
59
60
|
const mappedKey = code ? options.layoutMap?.get(code) : void 0;
|
|
60
61
|
if (mappedKey) displayKey = normalizeKeyName(mappedKey);
|
|
61
|
-
else if (code)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
else if (code) {
|
|
63
|
+
if (/^Key[A-Z]$/.test(code)) displayKey = code.slice(3);
|
|
64
|
+
else if (/^Digit[0-9]$/.test(code)) displayKey = code.slice(5);
|
|
65
|
+
else if (numpad) displayKey = code.slice(6);
|
|
66
|
+
else displayKey = PUNCTUATION_CODE_MAP[code] ?? code;
|
|
67
|
+
}
|
|
65
68
|
const display = (keySymbols ? KEY_DISPLAY_SYMBOLS : PUNCTUATION_KEY_DISPLAY_LABELS)[displayKey] ?? displayKey;
|
|
66
69
|
return numpad ? `Numpad ${display.replace(/([a-z])([A-Z])/g, "$1 $2")}` : display;
|
|
67
70
|
});
|
|
@@ -78,5 +81,4 @@ function formatWithLabels(hotkey, options = {}) {
|
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
//#endregion
|
|
81
|
-
export { formatForDisplay, formatHotkey, formatHotkeySequence, formatWithLabels };
|
|
82
|
-
//# sourceMappingURL=format.js.map
|
|
84
|
+
export { formatForDisplay, formatHotkey, formatHotkeySequence, formatWithLabels };
|
package/dist/hint.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RegisterableHotkey } from "./hotkey.types.js";
|
|
2
|
-
|
|
3
2
|
//#region src/hint.d.ts
|
|
4
|
-
interface HeldModifierOptions {
|
|
3
|
+
export interface HeldModifierOptions {
|
|
5
4
|
/** Resolve Mod for this platform. Defaults to platform detection. */
|
|
6
5
|
platform?: 'mac' | 'windows' | 'linux';
|
|
7
6
|
/** Require every binding modifier to be held. Default: false (nonempty subset). */
|
|
@@ -17,7 +16,5 @@ interface HeldModifierOptions {
|
|
|
17
16
|
* matchesHeldModifiers('Alt+Shift+[KeyK]', ['Alt']) // true
|
|
18
17
|
* matchesHeldModifiers('Alt+Shift+[KeyK]', ['Alt', 'Control']) // false
|
|
19
18
|
*/
|
|
20
|
-
declare function matchesHeldModifiers(hotkey: RegisterableHotkey, heldKeys: ReadonlyArray<string>, options?: HeldModifierOptions): boolean;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { HeldModifierOptions, matchesHeldModifiers };
|
|
23
|
-
//# sourceMappingURL=hint.d.ts.map
|
|
19
|
+
export declare function matchesHeldModifiers(hotkey: RegisterableHotkey, heldKeys: ReadonlyArray<string>, options?: HeldModifierOptions): boolean;
|
|
20
|
+
//#endregion
|
package/dist/hint.js
CHANGED
package/dist/hotkey-manager.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { ConflictBehavior, Hotkey, HotkeyCallback, HotkeyMeta, ParsedHotkey, RegisterableHotkey } from "./hotkey.types.js";
|
|
2
2
|
import { Store } from "@tanstack/store";
|
|
3
|
-
|
|
4
3
|
//#region src/hotkey-manager.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Options for registering a hotkey.
|
|
7
6
|
*/
|
|
8
|
-
interface HotkeyOptions {
|
|
7
|
+
export interface HotkeyOptions {
|
|
9
8
|
/** Behavior when this hotkey conflicts with an existing registration on the same target. Defaults to 'warn' */
|
|
10
9
|
conflictBehavior?: ConflictBehavior;
|
|
11
10
|
/**
|
|
@@ -34,7 +33,7 @@ interface HotkeyOptions {
|
|
|
34
33
|
/**
|
|
35
34
|
* A registered hotkey handler in the HotkeyManager.
|
|
36
35
|
*/
|
|
37
|
-
interface HotkeyRegistration {
|
|
36
|
+
export interface HotkeyRegistration {
|
|
38
37
|
/** The callback to invoke */
|
|
39
38
|
callback: HotkeyCallback;
|
|
40
39
|
/** Whether this registration has fired and needs reset (for requireReset) */
|
|
@@ -61,7 +60,7 @@ interface HotkeyRegistration {
|
|
|
61
60
|
* Public view of a hotkey registration for display and introspection.
|
|
62
61
|
* Omits the callback function which is an internal implementation detail.
|
|
63
62
|
*/
|
|
64
|
-
interface HotkeyRegistrationView {
|
|
63
|
+
export interface HotkeyRegistrationView {
|
|
65
64
|
/** The original hotkey string */
|
|
66
65
|
hotkey: Hotkey;
|
|
67
66
|
/** Unique identifier for this registration */
|
|
@@ -81,7 +80,7 @@ interface HotkeyRegistrationView {
|
|
|
81
80
|
* Creates a public view from an internal registration,
|
|
82
81
|
* stripping the callback function.
|
|
83
82
|
*/
|
|
84
|
-
declare function toHotkeyRegistrationView(reg: HotkeyRegistration): HotkeyRegistrationView;
|
|
83
|
+
export declare function toHotkeyRegistrationView(reg: HotkeyRegistration): HotkeyRegistrationView;
|
|
85
84
|
/**
|
|
86
85
|
* A handle returned from HotkeyManager.register() that allows updating
|
|
87
86
|
* the callback and options without re-registering the hotkey.
|
|
@@ -105,7 +104,7 @@ declare function toHotkeyRegistrationView(reg: HotkeyRegistration): HotkeyRegist
|
|
|
105
104
|
* handle.unregister()
|
|
106
105
|
* ```
|
|
107
106
|
*/
|
|
108
|
-
interface HotkeyRegistrationHandle {
|
|
107
|
+
export interface HotkeyRegistrationHandle {
|
|
109
108
|
/**
|
|
110
109
|
* The callback function. Can be set directly to update without re-registering.
|
|
111
110
|
* This avoids stale closures when the callback references React state.
|
|
@@ -142,7 +141,7 @@ interface HotkeyRegistrationHandle {
|
|
|
142
141
|
* unregister()
|
|
143
142
|
* ```
|
|
144
143
|
*/
|
|
145
|
-
declare class HotkeyManager {
|
|
144
|
+
export declare class HotkeyManager {
|
|
146
145
|
#private;
|
|
147
146
|
/**
|
|
148
147
|
* The TanStack Store containing all hotkey registrations.
|
|
@@ -228,7 +227,6 @@ declare class HotkeyManager {
|
|
|
228
227
|
* Gets the singleton HotkeyManager instance.
|
|
229
228
|
* Convenience function for accessing the manager.
|
|
230
229
|
*/
|
|
231
|
-
declare function getHotkeyManager(): HotkeyManager;
|
|
230
|
+
export declare function getHotkeyManager(): HotkeyManager;
|
|
232
231
|
//#endregion
|
|
233
|
-
export {
|
|
234
|
-
//# sourceMappingURL=hotkey-manager.d.ts.map
|
|
232
|
+
export type { ConflictBehavior };
|
package/dist/hotkey-manager.js
CHANGED
|
@@ -53,11 +53,30 @@ function generateId() {
|
|
|
53
53
|
*/
|
|
54
54
|
var HotkeyManager = class HotkeyManager {
|
|
55
55
|
static #instance = null;
|
|
56
|
+
/**
|
|
57
|
+
* The TanStack Store containing all hotkey registrations.
|
|
58
|
+
* Use this to subscribe to registration changes or access current registrations.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const manager = HotkeyManager.getInstance()
|
|
63
|
+
*
|
|
64
|
+
* // Subscribe to registration changes
|
|
65
|
+
* const unsubscribe = manager.registrations.subscribe(() => {
|
|
66
|
+
* console.log('Registrations changed:', manager.registrations.state.size)
|
|
67
|
+
* })
|
|
68
|
+
*
|
|
69
|
+
* // Access current registrations
|
|
70
|
+
* for (const [id, reg] of manager.registrations.state) {
|
|
71
|
+
* console.log(reg.hotkey, reg.options.enabled)
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
registrations = new Store(/* @__PURE__ */ new Map());
|
|
56
76
|
#platform;
|
|
57
77
|
#targetListeners = /* @__PURE__ */ new Map();
|
|
58
78
|
#targetRegistrations = /* @__PURE__ */ new Map();
|
|
59
79
|
constructor() {
|
|
60
|
-
this.registrations = new Store(/* @__PURE__ */ new Map());
|
|
61
80
|
this.#platform = detectPlatform();
|
|
62
81
|
}
|
|
63
82
|
/**
|
|
@@ -408,5 +427,4 @@ function getHotkeyManager() {
|
|
|
408
427
|
}
|
|
409
428
|
|
|
410
429
|
//#endregion
|
|
411
|
-
export { HotkeyManager, getHotkeyManager, toHotkeyRegistrationView };
|
|
412
|
-
//# sourceMappingURL=hotkey-manager.js.map
|
|
430
|
+
export { HotkeyManager, getHotkeyManager, toHotkeyRegistrationView };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Hotkey } from "./hotkey.types.js";
|
|
2
2
|
import { HotkeyRecorderValidationContext, RecorderOptions } from "./recorder-options.js";
|
|
3
3
|
import { Store } from "@tanstack/store";
|
|
4
|
-
|
|
5
4
|
//#region src/hotkey-recorder.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* State interface for the HotkeyRecorder.
|
|
8
7
|
*/
|
|
9
|
-
interface HotkeyRecorderState {
|
|
8
|
+
export interface HotkeyRecorderState {
|
|
10
9
|
/** Whether recording is currently active */
|
|
11
10
|
isRecording: boolean;
|
|
12
11
|
/** The currently recorded hotkey (for live preview) */
|
|
@@ -15,7 +14,7 @@ interface HotkeyRecorderState {
|
|
|
15
14
|
/**
|
|
16
15
|
* Options for configuring a HotkeyRecorder instance.
|
|
17
16
|
*/
|
|
18
|
-
interface HotkeyRecorderOptions extends RecorderOptions {
|
|
17
|
+
export interface HotkeyRecorderOptions extends RecorderOptions {
|
|
19
18
|
/** Return true to accept, or false/a message to reject while staying in recording mode. */
|
|
20
19
|
validate?: (hotkey: Hotkey, context: HotkeyRecorderValidationContext) => boolean | string;
|
|
21
20
|
/** Callback when a hotkey is successfully recorded */
|
|
@@ -72,7 +71,7 @@ interface HotkeyRecorderOptions extends RecorderOptions {
|
|
|
72
71
|
* unsubscribe()
|
|
73
72
|
* ```
|
|
74
73
|
*/
|
|
75
|
-
declare class HotkeyRecorder {
|
|
74
|
+
export declare class HotkeyRecorder {
|
|
76
75
|
#private;
|
|
77
76
|
/**
|
|
78
77
|
* The TanStack Store instance containing the recorder state.
|
|
@@ -114,6 +113,4 @@ declare class HotkeyRecorder {
|
|
|
114
113
|
*/
|
|
115
114
|
destroy(): void;
|
|
116
115
|
}
|
|
117
|
-
//#endregion
|
|
118
|
-
export { HotkeyRecorder, HotkeyRecorderOptions, HotkeyRecorderState };
|
|
119
|
-
//# sourceMappingURL=hotkey-recorder.d.ts.map
|
|
116
|
+
//#endregion
|