hotkey-router 0.3.0 → 0.3.2

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/auto.js CHANGED
@@ -1,21 +1,39 @@
1
- // hotkey-router v0.3.0 | SEE LICENSE IN LICENSE
1
+ // hotkey-router v0.3.2 | SEE LICENSE IN LICENSE
2
2
 
3
3
 
4
- // hotkey-router.js
5
- function on(target, type, fn, options) {
6
- target.addEventListener(type, fn, options);
7
- return () => target.removeEventListener(type, fn, options);
4
+ // platform.js
5
+ function fromPlatformString(s) {
6
+ if (!s) return null;
7
+ if (/Chrome ?OS|CrOS/i.test(s)) return "chromeos";
8
+ if (/Mac|iPhone|iPad|iPod/i.test(s)) return "mac";
9
+ if (/Win/i.test(s)) return "windows";
10
+ if (/Linux|X11/i.test(s)) return "linux";
11
+ return null;
8
12
  }
9
- var isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/.test(navigator.platform);
10
- var modifierTokens = /* @__PURE__ */ new Set(["ctrl", "shift", "alt", "meta"]);
11
- var MODIFIER_KEY_TOKEN = Object.freeze({
12
- Alt: "alt",
13
- AltGraph: "alt",
14
- Control: "ctrl",
15
- Shift: "shift",
16
- Meta: "meta",
17
- OS: "meta"
18
- });
13
+ function detectPlatform(nav = typeof navigator !== "undefined" ? navigator : null, { chromeos = false } = {}) {
14
+ if (!nav) return null;
15
+ const ua = nav.userAgent || "";
16
+ const found = (/\bCrOS\b/.test(ua) ? "chromeos" : null) || fromPlatformString(nav.userAgentData?.platform) || fromPlatformString(nav.platform) || (/Mac OS X/i.test(ua) ? "mac" : /Windows/i.test(ua) ? "windows" : /Linux|X11/i.test(ua) ? "linux" : null);
17
+ if (found === "chromeos" && !chromeos) return "linux";
18
+ return found;
19
+ }
20
+ function detectBrowser(nav = typeof navigator !== "undefined" ? navigator : null) {
21
+ if (!nav) return null;
22
+ const ua = nav.userAgent || "";
23
+ if (/Edg\//.test(ua)) return "edge";
24
+ if (/Firefox/.test(ua)) return "firefox";
25
+ if (/Chrome/.test(ua)) return "chrome";
26
+ if (/Safari/.test(ua)) return "safari";
27
+ return null;
28
+ }
29
+ var PLATFORM_LABELS = { mac: "macOS", windows: "Windows", linux: "Linux", chromeos: "ChromeOS" };
30
+ function platformLabel(platform) {
31
+ return PLATFORM_LABELS[platform] || platform;
32
+ }
33
+
34
+ // parse.js
35
+ var DEFAULT_PLATFORM = detectPlatform();
36
+ var modifierTokens = /* @__PURE__ */ new Set(["ctrl", "shift", "alt", "meta", "mod"]);
19
37
  var ahkPrefixMap = /* @__PURE__ */ new Map([
20
38
  ["^", "ctrl"],
21
39
  // Ctrl
@@ -58,6 +76,7 @@ var keyAliases = Object.freeze({
58
76
  control: "ctrl",
59
77
  ctrl: "ctrl",
60
78
  option: "alt",
79
+ opt: "alt",
61
80
  alt: "alt",
62
81
  shift: "shift",
63
82
  // modifiers (symbols)
@@ -65,19 +84,11 @@ var keyAliases = Object.freeze({
65
84
  "\u2303": "ctrl",
66
85
  "\u2325": "alt",
67
86
  "\u21E7": "shift",
68
- // cross-platform "mod"
69
- mod: isMac ? "meta" : "ctrl",
87
+ // cross-platform "mod", resolved per platform while parsing
88
+ mod: "mod",
70
89
  // plus key ergonomics
71
90
  plus: "+"
72
91
  });
73
- var ignoreEditable = true;
74
- var defaultTarget = typeof window !== "undefined" ? window : null;
75
- var bindHooks = [];
76
- var registry = /* @__PURE__ */ new Map();
77
- var plugins = /* @__PURE__ */ new Map();
78
- var bindingIndex = /* @__PURE__ */ new Map();
79
- var paused = false;
80
- var nextId = 1;
81
92
  function normalizeKey(key) {
82
93
  const original = String(key ?? "");
83
94
  if (original === " ") return " ";
@@ -85,43 +96,16 @@ function normalizeKey(key) {
85
96
  const k = trimmed.toLowerCase();
86
97
  return keyAliases[k] ?? k;
87
98
  }
88
- function comboKeyFromParts({ ctrl, shift, alt, meta, key, code, bareModifier }) {
89
- if (bareModifier) return `__bare__:${bareModifier}`;
90
- let s = "";
91
- if (ctrl) s += "ctrl+";
92
- if (shift) s += "shift+";
93
- if (alt) s += "alt+";
94
- if (meta) s += "meta+";
95
- if (code) return s + "code:" + code;
96
- return s ? s + key : key;
97
- }
98
- function comboKeyFromEvent(e) {
99
- const bareMod = MODIFIER_KEY_TOKEN[e.key];
100
- if (bareMod) return `__bare__:${bareMod}`;
101
- return comboKeyFromParts({
102
- ctrl: e.ctrlKey,
103
- shift: e.shiftKey,
104
- alt: e.altKey,
105
- meta: e.metaKey,
106
- key: normalizeKey(e.key)
107
- });
108
- }
109
- function codeKeyFromEvent(e) {
110
- if (!e.code) return null;
111
- let s = "";
112
- if (e.ctrlKey) s += "ctrl+";
113
- if (e.shiftKey) s += "shift+";
114
- if (e.altKey) s += "alt+";
115
- if (e.metaKey) s += "meta+";
116
- return s + "code:" + e.code;
117
- }
118
99
  function isModifierToken(token) {
119
- const t = normalizeKey(token);
120
- return modifierTokens.has(t);
100
+ return modifierTokens.has(normalizeKey(token));
121
101
  }
122
102
  var CODE_TOKEN_RE = /(^|\+)code:([A-Za-z][A-Za-z0-9_]*)/;
123
- function parseHotkey(hotkeyStr) {
103
+ function readHotkey(hotkeyStr, { platform = DEFAULT_PLATFORM } = {}) {
124
104
  const raw = String(hotkeyStr || "").trim();
105
+ let error = null;
106
+ const fail = (msg) => {
107
+ error = error || `Invalid hotkey "${hotkeyStr}": ${msg}`;
108
+ };
125
109
  const isUp = /\s+up$/i.test(raw);
126
110
  const baseRaw = isUp ? raw.replace(/\s+up$/i, "").trim() : raw;
127
111
  const combo = {
@@ -133,25 +117,27 @@ function parseHotkey(hotkeyStr) {
133
117
  code: null,
134
118
  bareModifier: null
135
119
  };
120
+ const setMod = (mod) => {
121
+ if (mod === "mod") combo[platform === "mac" ? "meta" : "ctrl"] = true;
122
+ else combo[mod] = true;
123
+ };
136
124
  let stripped = baseRaw;
137
125
  while (stripped.length) {
138
126
  const mod = ahkPrefixMap.get(stripped[0]) ?? null;
139
127
  if (!mod) break;
140
- combo[mod] = true;
128
+ setMod(mod);
141
129
  stripped = stripped.slice(1).trimStart();
142
130
  }
143
131
  const codeMatches = stripped.match(/code:[A-Za-z][A-Za-z0-9_]*/g);
144
132
  if (codeMatches && codeMatches.length > 1) {
145
- throw new Error(
146
- `Invalid hotkey "${hotkeyStr}": multiple code: tokens not supported (got ${codeMatches.length}).`
147
- );
133
+ fail(`multiple code: tokens not supported (got ${codeMatches.length}).`);
148
134
  }
149
135
  let codeValue = null;
150
136
  const scrubbed = stripped.replace(CODE_TOKEN_RE, (_, sep, val) => {
151
137
  codeValue = val;
152
138
  return sep + "__code__";
153
139
  });
154
- let cleanStr = scrubbed.toLowerCase();
140
+ const cleanStr = scrubbed.toLowerCase();
155
141
  const rawParts = cleanStr.split("+").map((p) => p.trim());
156
142
  const parts = rawParts.filter(Boolean);
157
143
  const impliedPlusKey = rawParts.some((p) => p === "") && cleanStr.includes("++");
@@ -159,13 +145,9 @@ function parseHotkey(hotkeyStr) {
159
145
  let seenBase = false;
160
146
  for (const part of parts) {
161
147
  if (isModifierToken(part)) {
162
- if (seenBase) {
163
- throw new Error(
164
- `Invalid hotkey "${hotkeyStr}": modifiers must come before the base key (e.g. "ctrl+k", not "k+ctrl")`
165
- );
166
- }
148
+ if (seenBase) fail('modifiers must come before the base key (e.g. "ctrl+k", not "k+ctrl")');
167
149
  } else {
168
- if (!seenBase) seenBase = true;
150
+ seenBase = true;
169
151
  }
170
152
  }
171
153
  }
@@ -175,10 +157,7 @@ function parseHotkey(hotkeyStr) {
175
157
  continue;
176
158
  }
177
159
  const actual = keyAliases[part] ?? part;
178
- if (actual === "ctrl") combo.ctrl = true;
179
- else if (actual === "shift") combo.shift = true;
180
- else if (actual === "alt") combo.alt = true;
181
- else if (actual === "meta") combo.meta = true;
160
+ if (modifierTokens.has(actual)) setMod(actual);
182
161
  else combo.key = normalizeKey(actual);
183
162
  }
184
163
  if (!combo.key && !combo.code && impliedPlusKey) combo.key = "+";
@@ -187,14 +166,111 @@ function parseHotkey(hotkeyStr) {
187
166
  if (modCount === 1) {
188
167
  combo.bareModifier = combo.ctrl ? "ctrl" : combo.shift ? "shift" : combo.alt ? "alt" : "meta";
189
168
  } else if (modCount > 1) {
190
- throw new Error(
191
- `Invalid hotkey "${hotkeyStr}": multi-modifier bare bindings not supported. Add a base key (e.g. "ctrl+alt+x").`
192
- );
169
+ fail('multi-modifier bare bindings not supported. Add a base key (e.g. "ctrl+alt+x").');
193
170
  } else {
194
- throw new Error(`Invalid hotkey "${hotkeyStr}" (missing base key)`);
171
+ error = error || `Invalid hotkey "${hotkeyStr}" (missing base key)`;
195
172
  }
196
173
  }
197
- return { combo, type: isUp ? "keyup" : "keydown", raw: hotkeyStr };
174
+ return { combo, type: isUp ? "keyup" : "keydown", raw: hotkeyStr, error };
175
+ }
176
+ function parseHotkey(hotkeyStr, opts) {
177
+ const { combo, type, raw, error } = readHotkey(hotkeyStr, opts);
178
+ if (error) throw new Error(error);
179
+ return { combo, type, raw };
180
+ }
181
+ var PUNCT_NAMES = {
182
+ ".": "period",
183
+ ",": "comma",
184
+ ";": "semicolon",
185
+ "'": "quote",
186
+ "/": "slash",
187
+ "\\": "backslash",
188
+ "[": "bracketleft",
189
+ "]": "bracketright",
190
+ "-": "minus",
191
+ "=": "equal",
192
+ "`": "backquote",
193
+ " ": "space",
194
+ "+": "equal"
195
+ };
196
+ function codeToBase(code) {
197
+ if (!code) return null;
198
+ const letter = /^Key([A-Za-z])$/.exec(code);
199
+ if (letter) return letter[1].toLowerCase();
200
+ const digit = /^(?:Digit|Numpad)(\d)$/.exec(code);
201
+ if (digit) return digit[1];
202
+ return code.toLowerCase();
203
+ }
204
+ function keyToBase(key) {
205
+ if (key == null || key === "") return null;
206
+ if (PUNCT_NAMES[key]) return PUNCT_NAMES[key];
207
+ const k = normalizeKey(key);
208
+ return PUNCT_NAMES[k] || k || null;
209
+ }
210
+ function lookupKey(combo) {
211
+ if (!combo || combo.bareModifier) return null;
212
+ const base = combo.code ? codeToBase(combo.code) : keyToBase(combo.key);
213
+ if (!base) return null;
214
+ const parts = [];
215
+ if (combo.ctrl) parts.push("ctrl");
216
+ if (combo.meta) parts.push("meta");
217
+ if (combo.alt) parts.push("alt");
218
+ if (combo.shift) parts.push("shift");
219
+ parts.push(base);
220
+ return parts.join("+");
221
+ }
222
+
223
+ // hotkey-router.js
224
+ function on(target, type, fn, options) {
225
+ target.addEventListener(type, fn, options);
226
+ return () => target.removeEventListener(type, fn, options);
227
+ }
228
+ var PLATFORM = detectPlatform();
229
+ var MODIFIER_KEY_TOKEN = Object.freeze({
230
+ Alt: "alt",
231
+ AltGraph: "alt",
232
+ Control: "ctrl",
233
+ Shift: "shift",
234
+ Meta: "meta",
235
+ OS: "meta"
236
+ });
237
+ var ignoreEditable = true;
238
+ var defaultTarget = typeof window !== "undefined" ? window : null;
239
+ var bindHooks = [];
240
+ var registry = /* @__PURE__ */ new Map();
241
+ var plugins = /* @__PURE__ */ new Map();
242
+ var bindingIndex = /* @__PURE__ */ new Map();
243
+ var paused = false;
244
+ var nextId = 1;
245
+ function comboKeyFromParts({ ctrl, shift, alt, meta, key, code, bareModifier }) {
246
+ if (bareModifier) return `__bare__:${bareModifier}`;
247
+ let s = "";
248
+ if (ctrl) s += "ctrl+";
249
+ if (shift) s += "shift+";
250
+ if (alt) s += "alt+";
251
+ if (meta) s += "meta+";
252
+ if (code) return s + "code:" + code;
253
+ return s ? s + key : key;
254
+ }
255
+ function comboKeyFromEvent(e) {
256
+ const bareMod = MODIFIER_KEY_TOKEN[e.key];
257
+ if (bareMod) return `__bare__:${bareMod}`;
258
+ return comboKeyFromParts({
259
+ ctrl: e.ctrlKey,
260
+ shift: e.shiftKey,
261
+ alt: e.altKey,
262
+ meta: e.metaKey,
263
+ key: normalizeKey(e.key)
264
+ });
265
+ }
266
+ function codeKeyFromEvent(e) {
267
+ if (!e.code) return null;
268
+ let s = "";
269
+ if (e.ctrlKey) s += "ctrl+";
270
+ if (e.shiftKey) s += "shift+";
271
+ if (e.altKey) s += "alt+";
272
+ if (e.metaKey) s += "meta+";
273
+ return s + "code:" + e.code;
198
274
  }
199
275
  function isFromInputTarget(e) {
200
276
  const t = e?.target;
@@ -344,41 +420,44 @@ function isAltGraphCharacter(e) {
344
420
  function isComposingEvent(e) {
345
421
  return Boolean(e.isComposing || e.keyCode === 229);
346
422
  }
423
+ function eligibleBindings(e, type, phase) {
424
+ const altGraphChar = isAltGraphCharacter(e);
425
+ const composing = isComposingEvent(e);
426
+ const fromInput = ignoreEditable && isFromInputTarget(e);
427
+ const seen = /* @__PURE__ */ new Set();
428
+ const candidates = [];
429
+ for (const lookupKey2 of [comboKeyFromEvent(e), codeKeyFromEvent(e)]) {
430
+ if (!lookupKey2 || seen.has(lookupKey2)) continue;
431
+ seen.add(lookupKey2);
432
+ const bindings = registry.get(lookupKey2)?.get(type);
433
+ if (!bindings?.length) continue;
434
+ for (const b of bindings) {
435
+ const o = b.options;
436
+ if (phase === "capture" && !o.capture) continue;
437
+ if (phase === "bubble" && o.capture) continue;
438
+ if (altGraphChar && !o.altGraph) continue;
439
+ if (composing && !o.composing) continue;
440
+ if (fromInput && !o.allowIn?.(e)) continue;
441
+ if (type === "keydown" && o.repeat === false && e.repeat) continue;
442
+ if (o.when && o.when(e) === false) continue;
443
+ candidates.push(b);
444
+ }
445
+ }
446
+ return candidates;
447
+ }
448
+ function fire(winner, e) {
449
+ const o = winner.options;
450
+ if (o.preventDefault) e.preventDefault();
451
+ if (o.stopImmediatePropagation) e.stopImmediatePropagation();
452
+ else if (o.stopPropagation) e.stopPropagation();
453
+ winner.handler(e);
454
+ if (o.once) removeById(winner.id);
455
+ }
347
456
  function handleEvent(type, phase = "all") {
348
457
  return (e) => {
349
458
  if (paused) return;
350
- const altGraphChar = isAltGraphCharacter(e);
351
- const composing = isComposingEvent(e);
352
- const fromInput = ignoreEditable && isFromInputTarget(e);
353
- const comboStr = comboKeyFromEvent(e);
354
- const codeStr = codeKeyFromEvent(e);
355
- const seen = /* @__PURE__ */ new Set();
356
- const candidates = [];
357
- for (const lookupKey of [comboStr, codeStr]) {
358
- if (!lookupKey || seen.has(lookupKey)) continue;
359
- seen.add(lookupKey);
360
- const bindings = registry.get(lookupKey)?.get(type);
361
- if (!bindings?.length) continue;
362
- for (const b of bindings) {
363
- const o2 = b.options;
364
- if (phase === "capture" && !o2.capture) continue;
365
- if (phase === "bubble" && o2.capture) continue;
366
- if (altGraphChar && !o2.altGraph) continue;
367
- if (composing && !o2.composing) continue;
368
- if (fromInput && !o2.allowIn?.(e)) continue;
369
- if (type === "keydown" && o2.repeat === false && e.repeat) continue;
370
- if (o2.when && o2.when(e) === false) continue;
371
- candidates.push(b);
372
- }
373
- }
374
- if (!candidates.length) return;
375
- const winner = pickWinner(candidates);
376
- const o = winner.options;
377
- if (o.preventDefault) e.preventDefault();
378
- if (o.stopImmediatePropagation) e.stopImmediatePropagation();
379
- else if (o.stopPropagation) e.stopPropagation();
380
- winner.handler(e);
381
- if (o.once) removeById(winner.id);
459
+ const candidates = eligibleBindings(e, type, phase);
460
+ if (candidates.length) fire(pickWinner(candidates), e);
382
461
  };
383
462
  }
384
463
  var stopDown = null;
@@ -417,13 +496,62 @@ var BARE_MOD_TO_KEY = {
417
496
  alt: "Alt",
418
497
  meta: "Meta"
419
498
  };
420
- function trigger(hotkeyStr, { type: forcedType } = {}) {
499
+ var CODE_TO_KEY = {
500
+ Period: ".",
501
+ Comma: ",",
502
+ Semicolon: ";",
503
+ Quote: "'",
504
+ Slash: "/",
505
+ Backslash: "\\",
506
+ BracketLeft: "[",
507
+ BracketRight: "]",
508
+ Minus: "-",
509
+ Equal: "=",
510
+ Backquote: "`",
511
+ Space: " ",
512
+ Enter: "Enter",
513
+ NumpadEnter: "Enter",
514
+ Tab: "Tab",
515
+ Escape: "Escape",
516
+ Backspace: "Backspace",
517
+ Delete: "Delete",
518
+ Insert: "Insert",
519
+ Home: "Home",
520
+ End: "End",
521
+ PageUp: "PageUp",
522
+ PageDown: "PageDown",
523
+ ArrowUp: "ArrowUp",
524
+ ArrowDown: "ArrowDown",
525
+ ArrowLeft: "ArrowLeft",
526
+ ArrowRight: "ArrowRight"
527
+ };
528
+ var KEY_TO_CODE = {};
529
+ var _a;
530
+ for (const [code, key] of Object.entries(CODE_TO_KEY)) {
531
+ KEY_TO_CODE[_a = normalizeKey(key)] ?? (KEY_TO_CODE[_a] = code);
532
+ }
533
+ function keyForCode(code) {
534
+ if (!code) return null;
535
+ const letter = /^Key([A-Z])$/.exec(code);
536
+ if (letter) return letter[1].toLowerCase();
537
+ const digit = /^(?:Digit|Numpad)(\d)$/.exec(code);
538
+ if (digit) return digit[1];
539
+ if (/^F\d{1,2}$/.test(code)) return code;
540
+ return CODE_TO_KEY[code] ?? null;
541
+ }
542
+ function codeForKey(key) {
543
+ if (!key) return null;
544
+ if (/^[a-z]$/.test(key)) return "Key" + key.toUpperCase();
545
+ if (/^\d$/.test(key)) return "Digit" + key;
546
+ if (/^f\d{1,2}$/.test(key)) return key.toUpperCase();
547
+ return KEY_TO_CODE[key] ?? null;
548
+ }
549
+ function trigger(hotkeyStr, { type: forcedType, target = null } = {}) {
421
550
  const { combo, type } = parseHotkey(hotkeyStr);
422
- const comboStr = comboKeyFromParts(combo);
423
551
  const actualType = forcedType || type;
424
- const bindings = registry.get(comboStr)?.get(actualType);
425
- if (!bindings?.length) return false;
426
- const eventKey = combo.bareModifier ? BARE_MOD_TO_KEY[combo.bareModifier] : combo.key;
552
+ if (paused) return false;
553
+ const eventKey = combo.bareModifier ? BARE_MOD_TO_KEY[combo.bareModifier] : combo.key ?? keyForCode(combo.code);
554
+ const eventCode = combo.bareModifier ? null : combo.code ?? codeForKey(combo.key);
427
555
  let altKey = !!combo.alt;
428
556
  let ctrlKey = !!combo.ctrl;
429
557
  let shiftKey = !!combo.shift;
@@ -437,32 +565,33 @@ function trigger(hotkeyStr, { type: forcedType } = {}) {
437
565
  const e = {
438
566
  type: actualType,
439
567
  key: eventKey,
440
- code: combo.code || null,
568
+ code: eventCode,
441
569
  ctrlKey,
442
570
  shiftKey,
443
571
  altKey,
444
572
  metaKey,
445
573
  repeat: false,
574
+ isComposing: false,
575
+ getModifierState() {
576
+ return false;
577
+ },
446
578
  preventDefault() {
447
579
  },
448
580
  stopPropagation() {
449
581
  },
450
582
  stopImmediatePropagation() {
451
583
  },
452
- target: null
584
+ target
453
585
  };
454
- const winner = pickWinner(
455
- bindings.filter((b) => b.options.when ? b.options.when(e) !== false : true)
456
- );
457
- if (!winner) return false;
458
- winner.handler(e);
459
- if (winner.options.once) removeById(winner.id);
586
+ const candidates = eligibleBindings(e, actualType, "all");
587
+ if (!candidates.length) return false;
588
+ fire(pickWinner(candidates), e);
460
589
  return true;
461
590
  }
462
- function comboFromEvent(e, { physical = true, useMod = false } = {}) {
591
+ function comboFromEvent(e, { physical = true, useMod = false, platform = PLATFORM } = {}) {
463
592
  if (!e || MODIFIER_KEY_TOKEN[e.key]) return null;
464
593
  const parts = [];
465
- const primaryIsMeta = isMac;
594
+ const primaryIsMeta = platform === "mac";
466
595
  if (useMod && (primaryIsMeta ? e.metaKey : e.ctrlKey)) parts.push("mod");
467
596
  if (e.ctrlKey && !(useMod && !primaryIsMeta)) parts.push("ctrl");
468
597
  if (e.metaKey && !(useMod && primaryIsMeta)) parts.push("meta");
@@ -497,14 +626,15 @@ var hotkey_router_default = {
497
626
  trigger,
498
627
  // helpers
499
628
  parseHotkey,
500
- comboFromEvent
629
+ comboFromEvent,
630
+ detectPlatform
501
631
  };
502
632
 
503
633
  // data/browser-hotkeys.json
504
634
  var browser_hotkeys_default = {
505
635
  $comment: "Machine-readable companion to docs/browser-hotkeys.md. Each combo entry describes who claims the binding and how strongly. Intended for runtime conflict warnings in keyboard-routing libraries (e.g. hotkey-router) and dev-time validation in apps like WebRadar. Update both this file and the markdown together \u2014 the markdown is the human source of truth, this file is the machine projection.",
506
636
  version: {
507
- generated: "2026-05-17",
637
+ generated: "2026-10-15",
508
638
  schema: "1.0",
509
639
  sources: [
510
640
  "https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly",
@@ -657,7 +787,11 @@ var browser_hotkeys_default = {
657
787
  "meta+shift+q": { action: "Log out", severity: "os" },
658
788
  "meta+ctrl+q": { action: "Lock screen", severity: "os" },
659
789
  "meta+ctrl+space": { action: "Character Viewer", severity: "os" },
660
- "meta+alt+esc": { action: "Force-quit dialog", severity: "os" }
790
+ "meta+alt+esc": { action: "Force-quit dialog", severity: "os" },
791
+ "meta+shift+slash": { action: "Help menu search (Cmd+?)", severity: "os" },
792
+ "meta+alt+h": { action: "Hide other apps", severity: "os" },
793
+ "meta+alt+d": { action: "Show or hide the Dock", severity: "os" },
794
+ "meta+backquote": { action: "Switch windows of the front app", severity: "os" }
661
795
  },
662
796
  noteForLetterCombos: {
663
797
  "alt+a..z": { behavior: "compose", note: "Option+letter types special characters in text inputs (Option+E\u2192\xB4, Option+A\u2192\xE5, Option+F\u2192\u0192). Outside inputs, free for page world." },
@@ -854,27 +988,6 @@ var browser_hotkeys_default = {
854
988
  // reservations.js
855
989
  var SUPPORTED_SCHEMA = "1.0";
856
990
  var HARD_SEVERITIES = /* @__PURE__ */ new Set(["hard", "os", "menu-activation"]);
857
- function detectPlatform(nav = typeof navigator !== "undefined" ? navigator : null) {
858
- if (!nav) return null;
859
- const platform = nav.platform || "";
860
- if (/Mac|iPhone|iPad|iPod/.test(platform)) return "mac";
861
- if (/Win/i.test(platform)) return "windows";
862
- if (/Linux|X11/i.test(platform)) return "linux";
863
- const ua = nav.userAgent || "";
864
- if (/Mac OS X/i.test(ua)) return "mac";
865
- if (/Windows/i.test(ua)) return "windows";
866
- if (/Linux|X11/i.test(ua)) return "linux";
867
- return null;
868
- }
869
- function detectBrowser(nav = typeof navigator !== "undefined" ? navigator : null) {
870
- if (!nav) return null;
871
- const ua = nav.userAgent || "";
872
- if (/Edg\//.test(ua)) return "edge";
873
- if (/Firefox/.test(ua)) return "firefox";
874
- if (/Chrome/.test(ua)) return "chrome";
875
- if (/Safari/.test(ua)) return "safari";
876
- return null;
877
- }
878
991
  function canonicalize(rawKey) {
879
992
  const parts = String(rawKey).toLowerCase().split("+").map((p) => p.trim()).filter(Boolean);
880
993
  if (!parts.length) return "";
@@ -921,65 +1034,44 @@ function buildIndex(data) {
921
1034
  }
922
1035
  var SCHEMA_OK = browser_hotkeys_default?.version?.schema === SUPPORTED_SCHEMA;
923
1036
  var INDEX = SCHEMA_OK ? buildIndex(browser_hotkeys_default) : { platforms: {} };
924
- function codeToKey(code) {
925
- if (!code) return null;
926
- const letter = /^Key([A-Za-z])$/.exec(code);
927
- if (letter) return letter[1].toLowerCase();
928
- const digit = /^Digit(\d)$/.exec(code);
929
- if (digit) return digit[1];
930
- return code.toLowerCase();
931
- }
932
- function lookupKeyFromCombo(combo) {
933
- if (!combo) return null;
934
- if (combo.bareModifier) return null;
935
- const base = combo.code ? codeToKey(combo.code) : combo.key;
936
- if (!base) return null;
937
- const parts = [];
938
- if (combo.ctrl) parts.push("ctrl");
939
- if (combo.meta) parts.push("meta");
940
- if (combo.alt) parts.push("alt");
941
- if (combo.shift) parts.push("shift");
942
- parts.push(base);
943
- return parts.join("+");
944
- }
1037
+ var lookupKeyFromCombo = lookupKey;
945
1038
  function lookupReservation(combo, { platform, browser } = {}) {
946
1039
  if (!SCHEMA_OK) return null;
947
- const lookupKey = lookupKeyFromCombo(combo);
948
- if (!lookupKey) return null;
1040
+ const lookupKey2 = lookupKeyFromCombo(combo);
1041
+ if (!lookupKey2) return null;
949
1042
  const pdata = platform && INDEX.platforms[platform];
950
1043
  if (!pdata) return null;
951
1044
  const btable = browser ? pdata.browsers?.[browser] : null;
952
- const bclaim = btable?.[lookupKey];
1045
+ const bclaim = btable?.[lookupKey2];
953
1046
  if (bclaim) {
954
1047
  return {
955
1048
  source: "browser",
956
1049
  platform,
957
1050
  browser,
958
- lookupKey,
1051
+ lookupKey: lookupKey2,
959
1052
  action: bclaim.action,
960
1053
  severity: bclaim.severity
961
1054
  };
962
1055
  }
963
- const sclaim = pdata.system?.[lookupKey];
1056
+ const sclaim = pdata.system?.[lookupKey2];
964
1057
  if (sclaim) {
965
1058
  return {
966
1059
  source: "system",
967
1060
  platform,
968
1061
  browser,
969
- lookupKey,
1062
+ lookupKey: lookupKey2,
970
1063
  action: sclaim.action,
971
1064
  severity: sclaim.severity
972
1065
  };
973
1066
  }
974
1067
  return null;
975
1068
  }
976
- var PLATFORM_LABEL = { mac: "macOS", windows: "Windows", linux: "Linux" };
977
1069
  function severityIsHard(severity) {
978
1070
  return HARD_SEVERITIES.has(severity);
979
1071
  }
980
1072
  function formatReservationWarning(reservation, rawHotkey) {
981
- const platformLabel = PLATFORM_LABEL[reservation.platform] || reservation.platform;
982
- const sourceLabel = reservation.source === "browser" ? `${reservation.browser} on ${platformLabel}` : `${platformLabel}`;
1073
+ const where = platformLabel(reservation.platform);
1074
+ const sourceLabel = reservation.source === "browser" ? `${reservation.browser} on ${where}` : where;
983
1075
  const tag = severityIsHard(reservation.severity) ? "will not fire" : "fires in normal browsing";
984
1076
  return `[hotkey-router] "${rawHotkey}" (${reservation.lookupKey}) reserved by ${sourceLabel}: "${reservation.action}" [${reservation.severity}] \u2014 ${tag}.`;
985
1077
  }