@tanstack/hotkeys 0.9.0 → 0.10.1
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 +12 -14
- package/dist/format.js +17 -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/parse.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.cjs","names":["detectPlatform","splitHotkeyParts","normalizeKeyName","MODIFIER_ALIASES","resolveModifier","MODIFIER_ORDER","normalizeKeyboardEvent"],"sources":["../src/parse.ts"],"sourcesContent":["import {\n assertLogicalKey,\n normalizeKeyboardEvent,\n splitHotkeyParts,\n} from './_keyboard-event'\nimport { MODIFIER_ALIASES, MODIFIER_ORDER, normalizeKeyName } from './constants'\nimport { detectPlatform, resolveModifier } from './platform'\nimport type { CanonicalModifier, Key } from './key.types'\nimport type {\n Hotkey,\n ParsedHotkey,\n RawHotkey,\n RegisterableHotkey,\n} from './hotkey.types'\n\n/**\n * Parses a hotkey string into its component parts.\n *\n * @param hotkey - The hotkey string to parse (e.g., 'Mod+Shift+S')\n * @param platform - The target platform for resolving 'Mod' (defaults to auto-detection)\n * @returns A ParsedHotkey with either logical key or physical code and modifier flags\n *\n * @example\n * ```ts\n * parseHotkey('Mod+S') // On Mac: { key: 'S', ctrl: false, shift: false, alt: false, meta: true, modifiers: ['Meta'] }\n * parseHotkey('Mod+S') // On Windows: { key: 'S', ctrl: true, shift: false, alt: false, meta: false, modifiers: ['Control'] }\n * parseHotkey('Control+Shift+A') // { key: 'A', ctrl: true, shift: true, alt: false, meta: false, modifiers: ['Control', 'Shift'] }\n * ```\n */\nexport function parseHotkey(\n hotkey: Hotkey | (string & {}),\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): ParsedHotkey {\n const parts = splitHotkeyParts(hotkey)\n const modifiers: Set<CanonicalModifier> = new Set()\n let key = ''\n\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i]!.trim()\n\n if (i === parts.length - 1) {\n // Last part is always the key\n key = normalizeKeyName(part)\n } else {\n // All other parts are modifiers\n const alias =\n MODIFIER_ALIASES[part] ?? MODIFIER_ALIASES[part.toLowerCase()]\n\n if (alias) {\n const resolved = resolveModifier(alias, platform)\n modifiers.add(resolved)\n } else {\n // Unknown modifier, treat as part of the key if it's the only part\n // or ignore if there are more parts\n if (parts.length === 1) {\n key = normalizeKeyName(part)\n }\n }\n }\n }\n\n // If no key was found (empty string), use the last part as-is\n if (!key && parts.length > 0) {\n key = normalizeKeyName(parts[parts.length - 1]!.trim())\n }\n\n const code = /^\\[([A-Za-z][A-Za-z0-9]*)\\]$/.exec(key)?.[1]\n return {\n ...(code !== undefined ? { code } : { key }),\n ctrl: modifiers.has('Control'),\n shift: modifiers.has('Shift'),\n alt: modifiers.has('Alt'),\n meta: modifiers.has('Meta'),\n modifiers: MODIFIER_ORDER.filter((m) => modifiers.has(m)),\n }\n}\n\n/**\n * Converts a RawHotkey object to a ParsedHotkey.\n * Optional modifier booleans default to false; modifiers array is derived from them.\n * When `mod` is true, it is resolved to Control or Meta based on platform.\n *\n * @param raw - The raw hotkey object\n * @param platform - The target platform for resolving 'Mod' (defaults to auto-detection)\n * @returns A ParsedHotkey suitable for matching and formatting\n *\n * @example\n * ```ts\n * rawHotkeyToParsedHotkey({ key: 'Escape' })\n * // { key: 'Escape', ctrl: false, shift: false, alt: false, meta: false, modifiers: [] }\n *\n * rawHotkeyToParsedHotkey({ key: 'S', mod: true }, 'mac')\n * // { key: 'S', ctrl: false, shift: false, alt: false, meta: true, modifiers: ['Meta'] }\n *\n * rawHotkeyToParsedHotkey({ key: 'S', mod: true, shift: true }, 'windows')\n * // { key: 'S', ctrl: true, shift: true, alt: false, meta: false, modifiers: ['Control', 'Shift'] }\n * ```\n */\nexport function rawHotkeyToParsedHotkey(\n raw: RawHotkey,\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): ParsedHotkey {\n if (raw.code === undefined) assertLogicalKey(raw.key)\n let ctrl = raw.ctrl ?? false\n const shift = raw.shift ?? false\n const alt = raw.alt ?? false\n let meta = raw.meta ?? false\n\n if (raw.mod) {\n const resolved = resolveModifier('Mod', platform)\n if (resolved === 'Control') {\n ctrl = true\n } else {\n meta = true\n }\n }\n\n const modifiers: Array<CanonicalModifier> = MODIFIER_ORDER.filter((m) => {\n switch (m) {\n case 'Control':\n return ctrl\n case 'Shift':\n return shift\n case 'Alt':\n return alt\n case 'Meta':\n return meta\n default:\n return false\n }\n })\n return {\n ...(raw.code !== undefined\n ? { code: raw.code }\n : { key: normalizeKeyName(raw.key) }),\n ctrl,\n shift,\n alt,\n meta,\n modifiers,\n }\n}\n\n/**\n * Serializes a parsed hotkey to the canonical string form used for registration\n * and storage: `Mod` first when the platform allows, then `Alt`, then `Shift`;\n * otherwise full `Control+Alt+Shift+Meta` order.\n */\nfunction normalizedHotkeyStringFromParsed(\n parsed: ParsedHotkey,\n platform: 'mac' | 'windows' | 'linux',\n): Hotkey {\n if (parsed.code === undefined) assertLogicalKey(parsed.key)\n const canUseMod =\n platform === 'mac'\n ? parsed.meta && !parsed.ctrl\n : parsed.ctrl && !parsed.meta\n\n const parts: Array<string> = []\n\n if (canUseMod) {\n parts.push('Mod')\n if (parsed.alt) {\n parts.push('Alt')\n }\n if (parsed.shift) {\n parts.push('Shift')\n }\n } else {\n for (const modifier of MODIFIER_ORDER) {\n if (parsed.modifiers.includes(modifier)) {\n parts.push(modifier)\n }\n }\n }\n\n parts.push(\n parsed.code !== undefined\n ? `[${parsed.code}]`\n : normalizeKeyName(parsed.key),\n )\n return parts.join('+') as Hotkey\n}\n\n/**\n * Normalizes a hotkey string to its canonical form.\n *\n * - When `Mod` is allowed for the platform (Command on Mac without Control;\n * Control on Windows/Linux without Meta): emits `Mod`, then `Alt`, then `Shift`,\n * then the key (e.g. `Mod+Shift+E`, `Mod+S`).\n * - Otherwise: literal modifiers in `Control+Alt+Shift+Meta` order, then the key.\n * - Resolves aliases and normalizes key casing (e.g. `esc` → `Escape`, `a` → `A`).\n *\n * @param hotkey - The hotkey string to normalize\n * @param platform - The target platform for resolving `Mod` (defaults to auto-detection)\n * @returns The normalized hotkey string\n *\n * @example\n * ```ts\n * normalizeHotkey('shift+meta+e', 'mac') // 'Mod+Shift+E'\n * normalizeHotkey('ctrl+a', 'windows') // 'Mod+A'\n * normalizeHotkey('esc') // 'Escape'\n * ```\n */\nexport function normalizeHotkey(\n hotkey: Key | (string & {}),\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): Hotkey {\n return normalizedHotkeyStringFromParsed(\n parseHotkey(hotkey, platform),\n platform,\n )\n}\n\n/**\n * Same canonical string as {@link normalizeHotkey}, but from an already-parsed hotkey.\n */\nexport function normalizeHotkeyFromParsed(\n parsed: ParsedHotkey,\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): Hotkey {\n return normalizedHotkeyStringFromParsed(parsed, platform)\n}\n\n/**\n * Normalizes a string or {@link RawHotkey} object to the same canonical hotkey string.\n * Use this in framework adapters instead of branching on `formatHotkey(rawHotkeyToParsedHotkey(...))`.\n */\nexport function normalizeRegisterableHotkey(\n hotkey: RegisterableHotkey,\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): Hotkey {\n return typeof hotkey === 'string'\n ? normalizeHotkey(hotkey, platform)\n : normalizeHotkeyFromParsed(\n rawHotkeyToParsedHotkey(hotkey, platform),\n platform,\n )\n}\n\n/**\n * Checks if a string is a recognized modifier token (including aliases).\n *\n * For a `KeyboardEvent`, use `isModifier(normalizeKeyName(event.key))` so DOM\n * spellings like `OS` / `Win` match the same alias table.\n *\n * @param key - Key name or alias (e.g. from a hotkey string or `event.key`)\n * @returns True if the string is a recognized modifier\n */\nexport function isModifierKey(\n key: Key | (string & {}),\n): key is keyof typeof MODIFIER_ALIASES {\n return key in MODIFIER_ALIASES || key.toLowerCase() in MODIFIER_ALIASES\n}\n\n/**\n * Parses a KeyboardEvent into a ParsedHotkey object.\n *\n * This function extracts the key and modifier state from a keyboard event\n * and converts it into the same format used by `parseHotkey()`.\n *\n * @param event - The KeyboardEvent to parse\n * @param platform - The target platform for resolving modifiers (defaults to auto-detection)\n * @returns A ParsedHotkey object representing the keyboard event\n *\n * @example\n * ```ts\n * document.addEventListener('keydown', (event) => {\n * const parsed = parseKeyboardEvent(event)\n * console.log(parsed) // { key: 'S', ctrl: true, shift: false, ... }\n * })\n * ```\n */\nexport function parseKeyboardEvent(\n event: KeyboardEvent,\n platform?: 'mac' | 'windows' | 'linux',\n): ParsedHotkey {\n const normalized = normalizeKeyboardEvent(event, platform)\n // AltGraph is a character-production modifier, not an ordinary Control+Alt\n // shortcut. Record the produced glyph instead of a synthetic Ctrl+Alt chord.\n const ctrl = normalized.altGraph ? false : normalized.ctrl\n const alt = normalized.altGraph ? false : normalized.alt\n // Shift is a real modifier even during AltGraph input; preserve it for replay.\n const shift = normalized.shift\n\n // Build modifiers array in canonical order\n const modifiers: Array<CanonicalModifier> = []\n if (ctrl) modifiers.push('Control')\n if (alt) modifiers.push('Alt')\n if (shift) modifiers.push('Shift')\n if (normalized.meta) modifiers.push('Meta')\n\n return {\n key: normalized.key,\n ctrl,\n shift,\n alt,\n meta: normalized.meta,\n modifiers,\n }\n}\n\n/**\n * Normalizes a keyboard event to the same canonical hotkey string as {@link normalizeHotkey}.\n *\n * @param event - The keyboard event (typically `keydown`)\n * @param platform - Target platform for `Mod` eligibility\n */\nexport function normalizeHotkeyFromEvent(\n event: KeyboardEvent,\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): Hotkey {\n return normalizedHotkeyStringFromParsed(\n parseKeyboardEvent(event, platform),\n platform,\n )\n}\n\n/**\n * Checks if a hotkey or ParsedHotkey contains at least one non-modifier key.\n *\n * This is useful for validating that a recorded hotkey is complete and not\n * just a combination of modifiers without an action key.\n *\n * @param hotkey - The hotkey string or ParsedHotkey to check\n * @param platform - The target platform for parsing (defaults to auto-detection)\n * @returns True if the hotkey contains at least one non-modifier key\n *\n * @example\n * ```ts\n * hasNonModifierKey('Control+Shift+S') // true\n * hasNonModifierKey('Control+Shift') // false (no action key)\n * hasNonModifierKey(parseHotkey('Mod+A')) // true\n * ```\n */\nexport function hasNonModifierKey(\n hotkey: Hotkey | ParsedHotkey | (string & {}),\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): boolean {\n const parsed =\n typeof hotkey === 'string' ? parseHotkey(hotkey, platform) : hotkey\n\n if (parsed.code !== undefined) {\n // Physical modifier codes identify a side, but still are not action keys.\n return (\n parsed.code.length > 0 &&\n !/^(Control|Shift|Alt|Meta)(Left|Right)$/.test(parsed.code)\n )\n }\n\n // Check if the key part is actually a modifier\n const keyIsModifier = isModifierKey(parsed.key)\n\n // A valid hotkey must have a non-modifier key\n return !keyIsModifier && parsed.key.length > 0\n}\n\n/**\n * Parses a string or raw binding, resolving Mod for the supplied platform.\n * Physical tokens such as `[KeyQ]` retain `code`; they never become logical Q.\n */\nexport function parseRegisterableHotkey(\n hotkey: RegisterableHotkey,\n platform = detectPlatform(),\n): ParsedHotkey {\n return typeof hotkey === 'string'\n ? parseHotkey(hotkey, platform)\n : rawHotkeyToParsedHotkey(hotkey, platform)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,YACd,QACA,WAAwCA,iCAAgB,EAC1C;CACd,MAAM,QAAQC,yCAAiB,OAAO;CACtC,MAAM,4BAAoC,IAAI,KAAK;CACnD,IAAI,MAAM;AAEV,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,OAAO,MAAM,GAAI,MAAM;AAE7B,MAAI,MAAM,MAAM,SAAS,EAEvB,OAAMC,mCAAiB,KAAK;OACvB;GAEL,MAAM,QACJC,mCAAiB,SAASA,mCAAiB,KAAK,aAAa;AAE/D,OAAI,OAAO;IACT,MAAM,WAAWC,iCAAgB,OAAO,SAAS;AACjD,cAAU,IAAI,SAAS;cAInB,MAAM,WAAW,EACnB,OAAMF,mCAAiB,KAAK;;;AAOpC,KAAI,CAAC,OAAO,MAAM,SAAS,EACzB,OAAMA,mCAAiB,MAAM,MAAM,SAAS,GAAI,MAAM,CAAC;CAGzD,MAAM,OAAO,+BAA+B,KAAK,IAAI,GAAG;AACxD,QAAO;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AAwCA,iCAAgB,EAC/C;CACT,MAAM,SACJ,OAAO,WAAW,WAAW,YAAY,QAAQ,SAAS,GAAG;AAE/D,KAAI,OAAO,SAAS,OAElB,QACE,OAAO,KAAK,SAAS,KACrB,CAAC,yCAAyC,KAAK,OAAO,KAAK;AAQ/D,QAAO,CAHe,cAAc,OAAO,IAAI,IAGtB,OAAO,IAAI,SAAS;;;;;;AAO/C,SAAgB,wBACd,QACA,WAAWA,iCAAgB,EACb;AACd,QAAO,OAAO,WAAW,WACrB,YAAY,QAAQ,SAAS,GAC7B,wBAAwB,QAAQ,SAAS"}
|
package/dist/parse.d.cts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { Key } from "./key.types.cjs";
|
|
2
|
-
import { MODIFIER_ALIASES } from "./constants.cjs";
|
|
3
|
-
import { Hotkey, ParsedHotkey, RawHotkey, RegisterableHotkey } from "./hotkey.types.cjs";
|
|
4
|
-
|
|
5
|
-
//#region src/parse.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Parses a hotkey string into its component parts.
|
|
8
|
-
*
|
|
9
|
-
* @param hotkey - The hotkey string to parse (e.g., 'Mod+Shift+S')
|
|
10
|
-
* @param platform - The target platform for resolving 'Mod' (defaults to auto-detection)
|
|
11
|
-
* @returns A ParsedHotkey with either logical key or physical code and modifier flags
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* parseHotkey('Mod+S') // On Mac: { key: 'S', ctrl: false, shift: false, alt: false, meta: true, modifiers: ['Meta'] }
|
|
16
|
-
* parseHotkey('Mod+S') // On Windows: { key: 'S', ctrl: true, shift: false, alt: false, meta: false, modifiers: ['Control'] }
|
|
17
|
-
* parseHotkey('Control+Shift+A') // { key: 'A', ctrl: true, shift: true, alt: false, meta: false, modifiers: ['Control', 'Shift'] }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
declare function parseHotkey(hotkey: Hotkey | (string & {}), platform?: 'mac' | 'windows' | 'linux'): ParsedHotkey;
|
|
21
|
-
/**
|
|
22
|
-
* Converts a RawHotkey object to a ParsedHotkey.
|
|
23
|
-
* Optional modifier booleans default to false; modifiers array is derived from them.
|
|
24
|
-
* When `mod` is true, it is resolved to Control or Meta based on platform.
|
|
25
|
-
*
|
|
26
|
-
* @param raw - The raw hotkey object
|
|
27
|
-
* @param platform - The target platform for resolving 'Mod' (defaults to auto-detection)
|
|
28
|
-
* @returns A ParsedHotkey suitable for matching and formatting
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* rawHotkeyToParsedHotkey({ key: 'Escape' })
|
|
33
|
-
* // { key: 'Escape', ctrl: false, shift: false, alt: false, meta: false, modifiers: [] }
|
|
34
|
-
*
|
|
35
|
-
* rawHotkeyToParsedHotkey({ key: 'S', mod: true }, 'mac')
|
|
36
|
-
* // { key: 'S', ctrl: false, shift: false, alt: false, meta: true, modifiers: ['Meta'] }
|
|
37
|
-
*
|
|
38
|
-
* rawHotkeyToParsedHotkey({ key: 'S', mod: true, shift: true }, 'windows')
|
|
39
|
-
* // { key: 'S', ctrl: true, shift: true, alt: false, meta: false, modifiers: ['Control', 'Shift'] }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
declare function rawHotkeyToParsedHotkey(raw: RawHotkey, platform?: 'mac' | 'windows' | 'linux'): ParsedHotkey;
|
|
43
|
-
/**
|
|
44
|
-
* Normalizes a hotkey string to its canonical form.
|
|
45
|
-
*
|
|
46
|
-
* - When `Mod` is allowed for the platform (Command on Mac without Control;
|
|
47
|
-
* Control on Windows/Linux without Meta): emits `Mod`, then `Alt`, then `Shift`,
|
|
48
|
-
* then the key (e.g. `Mod+Shift+E`, `Mod+S`).
|
|
49
|
-
* - Otherwise: literal modifiers in `Control+Alt+Shift+Meta` order, then the key.
|
|
50
|
-
* - Resolves aliases and normalizes key casing (e.g. `esc` → `Escape`, `a` → `A`).
|
|
51
|
-
*
|
|
52
|
-
* @param hotkey - The hotkey string to normalize
|
|
53
|
-
* @param platform - The target platform for resolving `Mod` (defaults to auto-detection)
|
|
54
|
-
* @returns The normalized hotkey string
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts
|
|
58
|
-
* normalizeHotkey('shift+meta+e', 'mac') // 'Mod+Shift+E'
|
|
59
|
-
* normalizeHotkey('ctrl+a', 'windows') // 'Mod+A'
|
|
60
|
-
* normalizeHotkey('esc') // 'Escape'
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
declare function normalizeHotkey(hotkey: Key | (string & {}), platform?: 'mac' | 'windows' | 'linux'): Hotkey;
|
|
64
|
-
/**
|
|
65
|
-
* Same canonical string as {@link normalizeHotkey}, but from an already-parsed hotkey.
|
|
66
|
-
*/
|
|
67
|
-
declare function normalizeHotkeyFromParsed(parsed: ParsedHotkey, platform?: 'mac' | 'windows' | 'linux'): Hotkey;
|
|
68
|
-
/**
|
|
69
|
-
* Normalizes a string or {@link RawHotkey} object to the same canonical hotkey string.
|
|
70
|
-
* Use this in framework adapters instead of branching on `formatHotkey(rawHotkeyToParsedHotkey(...))`.
|
|
71
|
-
*/
|
|
72
|
-
declare function normalizeRegisterableHotkey(hotkey: RegisterableHotkey, platform?: 'mac' | 'windows' | 'linux'): Hotkey;
|
|
73
|
-
/**
|
|
74
|
-
* Checks if a string is a recognized modifier token (including aliases).
|
|
75
|
-
*
|
|
76
|
-
* For a `KeyboardEvent`, use `isModifier(normalizeKeyName(event.key))` so DOM
|
|
77
|
-
* spellings like `OS` / `Win` match the same alias table.
|
|
78
|
-
*
|
|
79
|
-
* @param key - Key name or alias (e.g. from a hotkey string or `event.key`)
|
|
80
|
-
* @returns True if the string is a recognized modifier
|
|
81
|
-
*/
|
|
82
|
-
declare function isModifierKey(key: Key | (string & {})): key is keyof typeof MODIFIER_ALIASES;
|
|
83
|
-
/**
|
|
84
|
-
* Parses a KeyboardEvent into a ParsedHotkey object.
|
|
85
|
-
*
|
|
86
|
-
* This function extracts the key and modifier state from a keyboard event
|
|
87
|
-
* and converts it into the same format used by `parseHotkey()`.
|
|
88
|
-
*
|
|
89
|
-
* @param event - The KeyboardEvent to parse
|
|
90
|
-
* @param platform - The target platform for resolving modifiers (defaults to auto-detection)
|
|
91
|
-
* @returns A ParsedHotkey object representing the keyboard event
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```ts
|
|
95
|
-
* document.addEventListener('keydown', (event) => {
|
|
96
|
-
* const parsed = parseKeyboardEvent(event)
|
|
97
|
-
* console.log(parsed) // { key: 'S', ctrl: true, shift: false, ... }
|
|
98
|
-
* })
|
|
99
|
-
* ```
|
|
100
|
-
*/
|
|
101
|
-
declare function parseKeyboardEvent(event: KeyboardEvent, platform?: 'mac' | 'windows' | 'linux'): ParsedHotkey;
|
|
102
|
-
/**
|
|
103
|
-
* Normalizes a keyboard event to the same canonical hotkey string as {@link normalizeHotkey}.
|
|
104
|
-
*
|
|
105
|
-
* @param event - The keyboard event (typically `keydown`)
|
|
106
|
-
* @param platform - Target platform for `Mod` eligibility
|
|
107
|
-
*/
|
|
108
|
-
declare function normalizeHotkeyFromEvent(event: KeyboardEvent, platform?: 'mac' | 'windows' | 'linux'): Hotkey;
|
|
109
|
-
/**
|
|
110
|
-
* Checks if a hotkey or ParsedHotkey contains at least one non-modifier key.
|
|
111
|
-
*
|
|
112
|
-
* This is useful for validating that a recorded hotkey is complete and not
|
|
113
|
-
* just a combination of modifiers without an action key.
|
|
114
|
-
*
|
|
115
|
-
* @param hotkey - The hotkey string or ParsedHotkey to check
|
|
116
|
-
* @param platform - The target platform for parsing (defaults to auto-detection)
|
|
117
|
-
* @returns True if the hotkey contains at least one non-modifier key
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* ```ts
|
|
121
|
-
* hasNonModifierKey('Control+Shift+S') // true
|
|
122
|
-
* hasNonModifierKey('Control+Shift') // false (no action key)
|
|
123
|
-
* hasNonModifierKey(parseHotkey('Mod+A')) // true
|
|
124
|
-
* ```
|
|
125
|
-
*/
|
|
126
|
-
declare function hasNonModifierKey(hotkey: Hotkey | ParsedHotkey | (string & {}), platform?: 'mac' | 'windows' | 'linux'): boolean;
|
|
127
|
-
/**
|
|
128
|
-
* Parses a string or raw binding, resolving Mod for the supplied platform.
|
|
129
|
-
* Physical tokens such as `[KeyQ]` retain `code`; they never become logical Q.
|
|
130
|
-
*/
|
|
131
|
-
declare function parseRegisterableHotkey(hotkey: RegisterableHotkey, platform?: "mac" | "windows" | "linux"): ParsedHotkey;
|
|
132
|
-
//#endregion
|
|
133
|
-
export { hasNonModifierKey, isModifierKey, normalizeHotkey, normalizeHotkeyFromEvent, normalizeHotkeyFromParsed, normalizeRegisterableHotkey, parseHotkey, parseKeyboardEvent, parseRegisterableHotkey, rawHotkeyToParsedHotkey };
|
|
134
|
-
//# sourceMappingURL=parse.d.cts.map
|
package/dist/parse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","names":[],"sources":["../src/parse.ts"],"sourcesContent":["import {\n assertLogicalKey,\n normalizeKeyboardEvent,\n splitHotkeyParts,\n} from './_keyboard-event'\nimport { MODIFIER_ALIASES, MODIFIER_ORDER, normalizeKeyName } from './constants'\nimport { detectPlatform, resolveModifier } from './platform'\nimport type { CanonicalModifier, Key } from './key.types'\nimport type {\n Hotkey,\n ParsedHotkey,\n RawHotkey,\n RegisterableHotkey,\n} from './hotkey.types'\n\n/**\n * Parses a hotkey string into its component parts.\n *\n * @param hotkey - The hotkey string to parse (e.g., 'Mod+Shift+S')\n * @param platform - The target platform for resolving 'Mod' (defaults to auto-detection)\n * @returns A ParsedHotkey with either logical key or physical code and modifier flags\n *\n * @example\n * ```ts\n * parseHotkey('Mod+S') // On Mac: { key: 'S', ctrl: false, shift: false, alt: false, meta: true, modifiers: ['Meta'] }\n * parseHotkey('Mod+S') // On Windows: { key: 'S', ctrl: true, shift: false, alt: false, meta: false, modifiers: ['Control'] }\n * parseHotkey('Control+Shift+A') // { key: 'A', ctrl: true, shift: true, alt: false, meta: false, modifiers: ['Control', 'Shift'] }\n * ```\n */\nexport function parseHotkey(\n hotkey: Hotkey | (string & {}),\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): ParsedHotkey {\n const parts = splitHotkeyParts(hotkey)\n const modifiers: Set<CanonicalModifier> = new Set()\n let key = ''\n\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i]!.trim()\n\n if (i === parts.length - 1) {\n // Last part is always the key\n key = normalizeKeyName(part)\n } else {\n // All other parts are modifiers\n const alias =\n MODIFIER_ALIASES[part] ?? MODIFIER_ALIASES[part.toLowerCase()]\n\n if (alias) {\n const resolved = resolveModifier(alias, platform)\n modifiers.add(resolved)\n } else {\n // Unknown modifier, treat as part of the key if it's the only part\n // or ignore if there are more parts\n if (parts.length === 1) {\n key = normalizeKeyName(part)\n }\n }\n }\n }\n\n // If no key was found (empty string), use the last part as-is\n if (!key && parts.length > 0) {\n key = normalizeKeyName(parts[parts.length - 1]!.trim())\n }\n\n const code = /^\\[([A-Za-z][A-Za-z0-9]*)\\]$/.exec(key)?.[1]\n return {\n ...(code !== undefined ? { code } : { key }),\n ctrl: modifiers.has('Control'),\n shift: modifiers.has('Shift'),\n alt: modifiers.has('Alt'),\n meta: modifiers.has('Meta'),\n modifiers: MODIFIER_ORDER.filter((m) => modifiers.has(m)),\n }\n}\n\n/**\n * Converts a RawHotkey object to a ParsedHotkey.\n * Optional modifier booleans default to false; modifiers array is derived from them.\n * When `mod` is true, it is resolved to Control or Meta based on platform.\n *\n * @param raw - The raw hotkey object\n * @param platform - The target platform for resolving 'Mod' (defaults to auto-detection)\n * @returns A ParsedHotkey suitable for matching and formatting\n *\n * @example\n * ```ts\n * rawHotkeyToParsedHotkey({ key: 'Escape' })\n * // { key: 'Escape', ctrl: false, shift: false, alt: false, meta: false, modifiers: [] }\n *\n * rawHotkeyToParsedHotkey({ key: 'S', mod: true }, 'mac')\n * // { key: 'S', ctrl: false, shift: false, alt: false, meta: true, modifiers: ['Meta'] }\n *\n * rawHotkeyToParsedHotkey({ key: 'S', mod: true, shift: true }, 'windows')\n * // { key: 'S', ctrl: true, shift: true, alt: false, meta: false, modifiers: ['Control', 'Shift'] }\n * ```\n */\nexport function rawHotkeyToParsedHotkey(\n raw: RawHotkey,\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): ParsedHotkey {\n if (raw.code === undefined) assertLogicalKey(raw.key)\n let ctrl = raw.ctrl ?? false\n const shift = raw.shift ?? false\n const alt = raw.alt ?? false\n let meta = raw.meta ?? false\n\n if (raw.mod) {\n const resolved = resolveModifier('Mod', platform)\n if (resolved === 'Control') {\n ctrl = true\n } else {\n meta = true\n }\n }\n\n const modifiers: Array<CanonicalModifier> = MODIFIER_ORDER.filter((m) => {\n switch (m) {\n case 'Control':\n return ctrl\n case 'Shift':\n return shift\n case 'Alt':\n return alt\n case 'Meta':\n return meta\n default:\n return false\n }\n })\n return {\n ...(raw.code !== undefined\n ? { code: raw.code }\n : { key: normalizeKeyName(raw.key) }),\n ctrl,\n shift,\n alt,\n meta,\n modifiers,\n }\n}\n\n/**\n * Serializes a parsed hotkey to the canonical string form used for registration\n * and storage: `Mod` first when the platform allows, then `Alt`, then `Shift`;\n * otherwise full `Control+Alt+Shift+Meta` order.\n */\nfunction normalizedHotkeyStringFromParsed(\n parsed: ParsedHotkey,\n platform: 'mac' | 'windows' | 'linux',\n): Hotkey {\n if (parsed.code === undefined) assertLogicalKey(parsed.key)\n const canUseMod =\n platform === 'mac'\n ? parsed.meta && !parsed.ctrl\n : parsed.ctrl && !parsed.meta\n\n const parts: Array<string> = []\n\n if (canUseMod) {\n parts.push('Mod')\n if (parsed.alt) {\n parts.push('Alt')\n }\n if (parsed.shift) {\n parts.push('Shift')\n }\n } else {\n for (const modifier of MODIFIER_ORDER) {\n if (parsed.modifiers.includes(modifier)) {\n parts.push(modifier)\n }\n }\n }\n\n parts.push(\n parsed.code !== undefined\n ? `[${parsed.code}]`\n : normalizeKeyName(parsed.key),\n )\n return parts.join('+') as Hotkey\n}\n\n/**\n * Normalizes a hotkey string to its canonical form.\n *\n * - When `Mod` is allowed for the platform (Command on Mac without Control;\n * Control on Windows/Linux without Meta): emits `Mod`, then `Alt`, then `Shift`,\n * then the key (e.g. `Mod+Shift+E`, `Mod+S`).\n * - Otherwise: literal modifiers in `Control+Alt+Shift+Meta` order, then the key.\n * - Resolves aliases and normalizes key casing (e.g. `esc` → `Escape`, `a` → `A`).\n *\n * @param hotkey - The hotkey string to normalize\n * @param platform - The target platform for resolving `Mod` (defaults to auto-detection)\n * @returns The normalized hotkey string\n *\n * @example\n * ```ts\n * normalizeHotkey('shift+meta+e', 'mac') // 'Mod+Shift+E'\n * normalizeHotkey('ctrl+a', 'windows') // 'Mod+A'\n * normalizeHotkey('esc') // 'Escape'\n * ```\n */\nexport function normalizeHotkey(\n hotkey: Key | (string & {}),\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): Hotkey {\n return normalizedHotkeyStringFromParsed(\n parseHotkey(hotkey, platform),\n platform,\n )\n}\n\n/**\n * Same canonical string as {@link normalizeHotkey}, but from an already-parsed hotkey.\n */\nexport function normalizeHotkeyFromParsed(\n parsed: ParsedHotkey,\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): Hotkey {\n return normalizedHotkeyStringFromParsed(parsed, platform)\n}\n\n/**\n * Normalizes a string or {@link RawHotkey} object to the same canonical hotkey string.\n * Use this in framework adapters instead of branching on `formatHotkey(rawHotkeyToParsedHotkey(...))`.\n */\nexport function normalizeRegisterableHotkey(\n hotkey: RegisterableHotkey,\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): Hotkey {\n return typeof hotkey === 'string'\n ? normalizeHotkey(hotkey, platform)\n : normalizeHotkeyFromParsed(\n rawHotkeyToParsedHotkey(hotkey, platform),\n platform,\n )\n}\n\n/**\n * Checks if a string is a recognized modifier token (including aliases).\n *\n * For a `KeyboardEvent`, use `isModifier(normalizeKeyName(event.key))` so DOM\n * spellings like `OS` / `Win` match the same alias table.\n *\n * @param key - Key name or alias (e.g. from a hotkey string or `event.key`)\n * @returns True if the string is a recognized modifier\n */\nexport function isModifierKey(\n key: Key | (string & {}),\n): key is keyof typeof MODIFIER_ALIASES {\n return key in MODIFIER_ALIASES || key.toLowerCase() in MODIFIER_ALIASES\n}\n\n/**\n * Parses a KeyboardEvent into a ParsedHotkey object.\n *\n * This function extracts the key and modifier state from a keyboard event\n * and converts it into the same format used by `parseHotkey()`.\n *\n * @param event - The KeyboardEvent to parse\n * @param platform - The target platform for resolving modifiers (defaults to auto-detection)\n * @returns A ParsedHotkey object representing the keyboard event\n *\n * @example\n * ```ts\n * document.addEventListener('keydown', (event) => {\n * const parsed = parseKeyboardEvent(event)\n * console.log(parsed) // { key: 'S', ctrl: true, shift: false, ... }\n * })\n * ```\n */\nexport function parseKeyboardEvent(\n event: KeyboardEvent,\n platform?: 'mac' | 'windows' | 'linux',\n): ParsedHotkey {\n const normalized = normalizeKeyboardEvent(event, platform)\n // AltGraph is a character-production modifier, not an ordinary Control+Alt\n // shortcut. Record the produced glyph instead of a synthetic Ctrl+Alt chord.\n const ctrl = normalized.altGraph ? false : normalized.ctrl\n const alt = normalized.altGraph ? false : normalized.alt\n // Shift is a real modifier even during AltGraph input; preserve it for replay.\n const shift = normalized.shift\n\n // Build modifiers array in canonical order\n const modifiers: Array<CanonicalModifier> = []\n if (ctrl) modifiers.push('Control')\n if (alt) modifiers.push('Alt')\n if (shift) modifiers.push('Shift')\n if (normalized.meta) modifiers.push('Meta')\n\n return {\n key: normalized.key,\n ctrl,\n shift,\n alt,\n meta: normalized.meta,\n modifiers,\n }\n}\n\n/**\n * Normalizes a keyboard event to the same canonical hotkey string as {@link normalizeHotkey}.\n *\n * @param event - The keyboard event (typically `keydown`)\n * @param platform - Target platform for `Mod` eligibility\n */\nexport function normalizeHotkeyFromEvent(\n event: KeyboardEvent,\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): Hotkey {\n return normalizedHotkeyStringFromParsed(\n parseKeyboardEvent(event, platform),\n platform,\n )\n}\n\n/**\n * Checks if a hotkey or ParsedHotkey contains at least one non-modifier key.\n *\n * This is useful for validating that a recorded hotkey is complete and not\n * just a combination of modifiers without an action key.\n *\n * @param hotkey - The hotkey string or ParsedHotkey to check\n * @param platform - The target platform for parsing (defaults to auto-detection)\n * @returns True if the hotkey contains at least one non-modifier key\n *\n * @example\n * ```ts\n * hasNonModifierKey('Control+Shift+S') // true\n * hasNonModifierKey('Control+Shift') // false (no action key)\n * hasNonModifierKey(parseHotkey('Mod+A')) // true\n * ```\n */\nexport function hasNonModifierKey(\n hotkey: Hotkey | ParsedHotkey | (string & {}),\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): boolean {\n const parsed =\n typeof hotkey === 'string' ? parseHotkey(hotkey, platform) : hotkey\n\n if (parsed.code !== undefined) {\n // Physical modifier codes identify a side, but still are not action keys.\n return (\n parsed.code.length > 0 &&\n !/^(Control|Shift|Alt|Meta)(Left|Right)$/.test(parsed.code)\n )\n }\n\n // Check if the key part is actually a modifier\n const keyIsModifier = isModifierKey(parsed.key)\n\n // A valid hotkey must have a non-modifier key\n return !keyIsModifier && parsed.key.length > 0\n}\n\n/**\n * Parses a string or raw binding, resolving Mod for the supplied platform.\n * Physical tokens such as `[KeyQ]` retain `code`; they never become logical Q.\n */\nexport function parseRegisterableHotkey(\n hotkey: RegisterableHotkey,\n platform = detectPlatform(),\n): ParsedHotkey {\n return typeof hotkey === 'string'\n ? parseHotkey(hotkey, platform)\n : rawHotkeyToParsedHotkey(hotkey, platform)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,YACd,QACA,WAAwC,gBAAgB,EAC1C;CACd,MAAM,QAAQ,iBAAiB,OAAO;CACtC,MAAM,4BAAoC,IAAI,KAAK;CACnD,IAAI,MAAM;AAEV,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;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Q,WAAW;CAGzB,MAAM,YAAsC,EAAE;AAC9C,KAAI,KAAM,WAAU,KAAK,UAAU;AACnC,KAAI,IAAK,WAAU,KAAK,MAAM;AAC9B,KAAI,MAAO,WAAU,KAAK,QAAQ;AAClC,KAAI,WAAW,KAAM,WAAU,KAAK,OAAO;AAE3C,QAAO;EACL,KAAK,WAAW;EAChB;EACA;EACA;EACA,MAAM,WAAW;EACjB;EACD;;;;;;;;AASH,SAAgB,yBACd,OACA,WAAwC,gBAAgB,EAChD;AACR,QAAO,iCACL,mBAAmB,OAAO,SAAS,EACnC,SACD;;;;;;;;;;;;;;;;;;;AAoBH,SAAgB,kBACd,QACA,WAAwC,gBAAgB,EAC/C;CACT,MAAM,SACJ,OAAO,WAAW,WAAW,YAAY,QAAQ,SAAS,GAAG;AAE/D,KAAI,OAAO,SAAS,OAElB,QACE,OAAO,KAAK,SAAS,KACrB,CAAC,yCAAyC,KAAK,OAAO,KAAK;AAQ/D,QAAO,CAHe,cAAc,OAAO,IAAI,IAGtB,OAAO,IAAI,SAAS;;;;;;AAO/C,SAAgB,wBACd,QACA,WAAW,gBAAgB,EACb;AACd,QAAO,OAAO,WAAW,WACrB,YAAY,QAAQ,SAAS,GAC7B,wBAAwB,QAAQ,SAAS"}
|
package/dist/platform.cjs
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/platform.ts
|
|
3
|
-
/**
|
|
4
|
-
* Detects the current platform based on browser navigator properties.
|
|
5
|
-
*
|
|
6
|
-
* Used internally to resolve platform-adaptive modifiers like 'Mod' (Command on Mac,
|
|
7
|
-
* Control elsewhere) and for platform-specific hotkey formatting.
|
|
8
|
-
*
|
|
9
|
-
* @returns The detected platform: 'mac', 'windows', or 'linux'
|
|
10
|
-
* @remarks Defaults to 'linux' in SSR environments where navigator is undefined
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* const platform = detectPlatform() // 'mac' | 'windows' | 'linux'
|
|
15
|
-
* const modifier = resolveModifier('Mod', platform) // 'Meta' on Mac, 'Control' elsewhere
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
function detectPlatform() {
|
|
19
|
-
if (typeof navigator === "undefined") return "linux";
|
|
20
|
-
const platform = navigator.platform?.toLowerCase() ?? "";
|
|
21
|
-
const userAgent = navigator.userAgent?.toLowerCase() ?? "";
|
|
22
|
-
if (platform.includes("mac") || userAgent.includes("mac")) return "mac";
|
|
23
|
-
if (platform.includes("win") || userAgent.includes("win")) return "windows";
|
|
24
|
-
return "linux";
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Resolves the platform-adaptive 'Mod' modifier to the appropriate canonical modifier.
|
|
28
|
-
*
|
|
29
|
-
* The 'Mod' token represents the "primary modifier" on each platform:
|
|
30
|
-
* - macOS: 'Meta' (Command key ⌘)
|
|
31
|
-
* - Windows/Linux: 'Control' (Ctrl key)
|
|
32
|
-
*
|
|
33
|
-
* This enables cross-platform hotkey definitions like 'Mod+S' that automatically
|
|
34
|
-
* map to Command+S on Mac and Ctrl+S on Windows/Linux.
|
|
35
|
-
*
|
|
36
|
-
* @param modifier - The modifier to resolve. If 'Mod', resolves based on platform.
|
|
37
|
-
* @param platform - The target platform. Defaults to auto-detection.
|
|
38
|
-
* @returns The canonical modifier name ('Control', 'Shift', 'Alt', or 'Meta')
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* resolveModifier('Mod', 'mac') // 'Meta'
|
|
43
|
-
* resolveModifier('Mod', 'windows') // 'Control'
|
|
44
|
-
* resolveModifier('Control', 'mac') // 'Control' (unchanged)
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
function resolveModifier(modifier, platform = detectPlatform()) {
|
|
48
|
-
if (modifier === "Mod") return platform === "mac" ? "Meta" : "Control";
|
|
49
|
-
return modifier;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
//#endregion
|
|
53
|
-
exports.detectPlatform = detectPlatform;
|
|
54
|
-
exports.resolveModifier = resolveModifier;
|
|
55
|
-
//# sourceMappingURL=platform.cjs.map
|
package/dist/platform.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platform.cjs","names":[],"sources":["../src/platform.ts"],"sourcesContent":["import type { CanonicalModifier } from './key.types'\n\n/**\n * Detects the current platform based on browser navigator properties.\n *\n * Used internally to resolve platform-adaptive modifiers like 'Mod' (Command on Mac,\n * Control elsewhere) and for platform-specific hotkey formatting.\n *\n * @returns The detected platform: 'mac', 'windows', or 'linux'\n * @remarks Defaults to 'linux' in SSR environments where navigator is undefined\n *\n * @example\n * ```ts\n * const platform = detectPlatform() // 'mac' | 'windows' | 'linux'\n * const modifier = resolveModifier('Mod', platform) // 'Meta' on Mac, 'Control' elsewhere\n * ```\n */\nexport function detectPlatform(): 'mac' | 'windows' | 'linux' {\n if (typeof navigator === 'undefined') {\n return 'linux' // Default for SSR\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const platform = navigator.platform?.toLowerCase() ?? ''\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const userAgent = navigator.userAgent?.toLowerCase() ?? ''\n\n if (platform.includes('mac') || userAgent.includes('mac')) {\n return 'mac'\n }\n if (platform.includes('win') || userAgent.includes('win')) {\n return 'windows'\n }\n return 'linux'\n}\n\n/**\n * Resolves the platform-adaptive 'Mod' modifier to the appropriate canonical modifier.\n *\n * The 'Mod' token represents the \"primary modifier\" on each platform:\n * - macOS: 'Meta' (Command key ⌘)\n * - Windows/Linux: 'Control' (Ctrl key)\n *\n * This enables cross-platform hotkey definitions like 'Mod+S' that automatically\n * map to Command+S on Mac and Ctrl+S on Windows/Linux.\n *\n * @param modifier - The modifier to resolve. If 'Mod', resolves based on platform.\n * @param platform - The target platform. Defaults to auto-detection.\n * @returns The canonical modifier name ('Control', 'Shift', 'Alt', or 'Meta')\n *\n * @example\n * ```ts\n * resolveModifier('Mod', 'mac') // 'Meta'\n * resolveModifier('Mod', 'windows') // 'Control'\n * resolveModifier('Control', 'mac') // 'Control' (unchanged)\n * ```\n */\nexport function resolveModifier(\n modifier: CanonicalModifier | 'Mod',\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): CanonicalModifier {\n if (modifier === 'Mod') {\n return platform === 'mac' ? 'Meta' : 'Control'\n }\n return modifier\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAgB,iBAA8C;AAC5D,KAAI,OAAO,cAAc,YACvB,QAAO;CAIT,MAAM,WAAW,UAAU,UAAU,aAAa,IAAI;CAEtD,MAAM,YAAY,UAAU,WAAW,aAAa,IAAI;AAExD,KAAI,SAAS,SAAS,MAAM,IAAI,UAAU,SAAS,MAAM,CACvD,QAAO;AAET,KAAI,SAAS,SAAS,MAAM,IAAI,UAAU,SAAS,MAAM,CACvD,QAAO;AAET,QAAO;;;;;;;;;;;;;;;;;;;;;;;AAwBT,SAAgB,gBACd,UACA,WAAwC,gBAAgB,EACrC;AACnB,KAAI,aAAa,MACf,QAAO,aAAa,QAAQ,SAAS;AAEvC,QAAO"}
|
package/dist/platform.d.cts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { CanonicalModifier } from "./key.types.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/platform.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Detects the current platform based on browser navigator properties.
|
|
6
|
-
*
|
|
7
|
-
* Used internally to resolve platform-adaptive modifiers like 'Mod' (Command on Mac,
|
|
8
|
-
* Control elsewhere) and for platform-specific hotkey formatting.
|
|
9
|
-
*
|
|
10
|
-
* @returns The detected platform: 'mac', 'windows', or 'linux'
|
|
11
|
-
* @remarks Defaults to 'linux' in SSR environments where navigator is undefined
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* const platform = detectPlatform() // 'mac' | 'windows' | 'linux'
|
|
16
|
-
* const modifier = resolveModifier('Mod', platform) // 'Meta' on Mac, 'Control' elsewhere
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
declare function detectPlatform(): 'mac' | 'windows' | 'linux';
|
|
20
|
-
/**
|
|
21
|
-
* Resolves the platform-adaptive 'Mod' modifier to the appropriate canonical modifier.
|
|
22
|
-
*
|
|
23
|
-
* The 'Mod' token represents the "primary modifier" on each platform:
|
|
24
|
-
* - macOS: 'Meta' (Command key ⌘)
|
|
25
|
-
* - Windows/Linux: 'Control' (Ctrl key)
|
|
26
|
-
*
|
|
27
|
-
* This enables cross-platform hotkey definitions like 'Mod+S' that automatically
|
|
28
|
-
* map to Command+S on Mac and Ctrl+S on Windows/Linux.
|
|
29
|
-
*
|
|
30
|
-
* @param modifier - The modifier to resolve. If 'Mod', resolves based on platform.
|
|
31
|
-
* @param platform - The target platform. Defaults to auto-detection.
|
|
32
|
-
* @returns The canonical modifier name ('Control', 'Shift', 'Alt', or 'Meta')
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* resolveModifier('Mod', 'mac') // 'Meta'
|
|
37
|
-
* resolveModifier('Mod', 'windows') // 'Control'
|
|
38
|
-
* resolveModifier('Control', 'mac') // 'Control' (unchanged)
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
declare function resolveModifier(modifier: CanonicalModifier | 'Mod', platform?: 'mac' | 'windows' | 'linux'): CanonicalModifier;
|
|
42
|
-
//#endregion
|
|
43
|
-
export { detectPlatform, resolveModifier };
|
|
44
|
-
//# sourceMappingURL=platform.d.cts.map
|
package/dist/platform.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","names":[],"sources":["../src/platform.ts"],"sourcesContent":["import type { CanonicalModifier } from './key.types'\n\n/**\n * Detects the current platform based on browser navigator properties.\n *\n * Used internally to resolve platform-adaptive modifiers like 'Mod' (Command on Mac,\n * Control elsewhere) and for platform-specific hotkey formatting.\n *\n * @returns The detected platform: 'mac', 'windows', or 'linux'\n * @remarks Defaults to 'linux' in SSR environments where navigator is undefined\n *\n * @example\n * ```ts\n * const platform = detectPlatform() // 'mac' | 'windows' | 'linux'\n * const modifier = resolveModifier('Mod', platform) // 'Meta' on Mac, 'Control' elsewhere\n * ```\n */\nexport function detectPlatform(): 'mac' | 'windows' | 'linux' {\n if (typeof navigator === 'undefined') {\n return 'linux' // Default for SSR\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const platform = navigator.platform?.toLowerCase() ?? ''\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const userAgent = navigator.userAgent?.toLowerCase() ?? ''\n\n if (platform.includes('mac') || userAgent.includes('mac')) {\n return 'mac'\n }\n if (platform.includes('win') || userAgent.includes('win')) {\n return 'windows'\n }\n return 'linux'\n}\n\n/**\n * Resolves the platform-adaptive 'Mod' modifier to the appropriate canonical modifier.\n *\n * The 'Mod' token represents the \"primary modifier\" on each platform:\n * - macOS: 'Meta' (Command key ⌘)\n * - Windows/Linux: 'Control' (Ctrl key)\n *\n * This enables cross-platform hotkey definitions like 'Mod+S' that automatically\n * map to Command+S on Mac and Ctrl+S on Windows/Linux.\n *\n * @param modifier - The modifier to resolve. If 'Mod', resolves based on platform.\n * @param platform - The target platform. Defaults to auto-detection.\n * @returns The canonical modifier name ('Control', 'Shift', 'Alt', or 'Meta')\n *\n * @example\n * ```ts\n * resolveModifier('Mod', 'mac') // 'Meta'\n * resolveModifier('Mod', 'windows') // 'Control'\n * resolveModifier('Control', 'mac') // 'Control' (unchanged)\n * ```\n */\nexport function resolveModifier(\n modifier: CanonicalModifier | 'Mod',\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): CanonicalModifier {\n if (modifier === 'Mod') {\n return platform === 'mac' ? 'Meta' : 'Control'\n }\n return modifier\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,iBAA8C;AAC5D,KAAI,OAAO,cAAc,YACvB,QAAO;CAIT,MAAM,WAAW,UAAU,UAAU,aAAa,IAAI;CAEtD,MAAM,YAAY,UAAU,WAAW,aAAa,IAAI;AAExD,KAAI,SAAS,SAAS,MAAM,IAAI,UAAU,SAAS,MAAM,CACvD,QAAO;AAET,KAAI,SAAS,SAAS,MAAM,IAAI,UAAU,SAAS,MAAM,CACvD,QAAO;AAET,QAAO;;;;;;;;;;;;;;;;;;;;;;;AAwBT,SAAgB,gBACd,UACA,WAAwC,gBAAgB,EACrC;AACnB,KAAI,aAAa,MACf,QAAO,aAAa,QAAQ,SAAS;AAEvC,QAAO"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Hotkey, ParsedHotkey } from "./hotkey.types.cjs";
|
|
2
|
-
import { HotkeyConflict, HotkeyConflictOptions } from "./conflicts.cjs";
|
|
3
|
-
|
|
4
|
-
//#region src/recorder-options.d.ts
|
|
5
|
-
/** Event property used to record a binding. Physical codes are the default. */
|
|
6
|
-
type RecorderKeyMode = 'code' | 'key';
|
|
7
|
-
interface RecorderRejection {
|
|
8
|
-
reason: 'missing-code' | 'alt-graph' | 'invalid' | 'conflict' | 'validation';
|
|
9
|
-
message: string;
|
|
10
|
-
hotkey?: Hotkey;
|
|
11
|
-
sequence?: Array<Hotkey>;
|
|
12
|
-
conflicts?: Array<HotkeyConflict>;
|
|
13
|
-
}
|
|
14
|
-
interface RecorderOptions {
|
|
15
|
-
/** Physical code recording is the default. Choose key to record logical characters. */
|
|
16
|
-
recordBy?: RecorderKeyMode;
|
|
17
|
-
/** Platform used for Mod and AltGraph handling. Defaults to platform detection. */
|
|
18
|
-
platform?: 'mac' | 'windows' | 'linux';
|
|
19
|
-
/** Opt in to live-registry conflicts, including sequence prefixes. Default: false. */
|
|
20
|
-
detectConflicts?: boolean | HotkeyConflictOptions;
|
|
21
|
-
/** Rejected candidates leave recording active. */
|
|
22
|
-
onReject?: (rejection: RecorderRejection) => void;
|
|
23
|
-
}
|
|
24
|
-
interface HotkeyRecorderValidationContext {
|
|
25
|
-
event: KeyboardEvent;
|
|
26
|
-
parsedHotkey: ParsedHotkey;
|
|
27
|
-
}
|
|
28
|
-
interface HotkeySequenceRecorderValidationContext {
|
|
29
|
-
events: ReadonlyArray<KeyboardEvent>;
|
|
30
|
-
parsedSequence: ReadonlyArray<ParsedHotkey>;
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { HotkeyRecorderValidationContext, HotkeySequenceRecorderValidationContext, RecorderKeyMode, RecorderOptions, RecorderRejection };
|
|
34
|
-
//# sourceMappingURL=recorder-options.d.cts.map
|