react-better-hotkeys 0.4.0 → 0.6.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.
Files changed (58) hide show
  1. package/README.md +1 -2
  2. package/dist/HotkeyRegistry.d.ts +8 -8
  3. package/dist/HotkeyRegistry.d.ts.map +1 -1
  4. package/dist/HotkeyRegistry.js +8 -8
  5. package/dist/HotkeyTextResolver.d.ts +2 -2
  6. package/dist/HotkeyTextResolver.d.ts.map +1 -1
  7. package/dist/HotkeyTextResolver.js +11 -11
  8. package/dist/hooks/useHotkey.d.ts +14 -15
  9. package/dist/hooks/useHotkey.d.ts.map +1 -1
  10. package/dist/hooks/useHotkey.js +25 -24
  11. package/dist/hooks/useRenderedHotkey.d.ts +5 -6
  12. package/dist/hooks/useRenderedHotkey.d.ts.map +1 -1
  13. package/dist/hooks/useRenderedHotkey.js +17 -15
  14. package/dist/types/hotkey/chord/ChordNode.d.ts +2 -2
  15. package/dist/types/hotkey/chord/ChordNode.d.ts.map +1 -1
  16. package/dist/types/hotkey/chord/IncompleteChordHotkey.d.ts +2 -2
  17. package/dist/types/hotkey/chord/IncompleteChordHotkey.d.ts.map +1 -1
  18. package/dist/types/hotkey/definition/ChordHotkey.d.ts +4 -0
  19. package/dist/types/hotkey/definition/ChordHotkey.d.ts.map +1 -0
  20. package/dist/types/hotkey/definition/ChordHotkeySpec.d.ts +11 -0
  21. package/dist/types/hotkey/definition/ChordHotkeySpec.d.ts.map +1 -0
  22. package/dist/types/hotkey/definition/Hotkey.d.ts +4 -0
  23. package/dist/types/hotkey/definition/Hotkey.d.ts.map +1 -0
  24. package/dist/types/hotkey/definition/HotkeyInstanceBase.d.ts +12 -0
  25. package/dist/types/hotkey/definition/HotkeyInstanceBase.d.ts.map +1 -0
  26. package/dist/types/hotkey/definition/HotkeySpec.d.ts +4 -0
  27. package/dist/types/hotkey/definition/HotkeySpec.d.ts.map +1 -0
  28. package/dist/types/hotkey/definition/SequenceHotkey.d.ts +4 -0
  29. package/dist/types/hotkey/definition/SequenceHotkey.d.ts.map +1 -0
  30. package/dist/types/hotkey/definition/SequenceHotkeySpec.d.ts +6 -0
  31. package/dist/types/hotkey/definition/SequenceHotkeySpec.d.ts.map +1 -0
  32. package/dist/types/hotkey/renderer/RenderedHotkey.d.ts +6 -0
  33. package/dist/types/hotkey/renderer/RenderedHotkey.d.ts.map +1 -0
  34. package/dist/types/hotkey/sequence/SequenceNode.d.ts +2 -2
  35. package/dist/types/hotkey/sequence/SequenceNode.d.ts.map +1 -1
  36. package/dist/types/hotkey/sequence/SequenceTree.d.ts +2 -2
  37. package/dist/types/hotkey/sequence/SequenceTree.d.ts.map +1 -1
  38. package/dist/types/other/OS.d.ts +2 -0
  39. package/dist/types/other/OS.d.ts.map +1 -0
  40. package/dist/util/checkModifierPressed.d.ts +2 -2
  41. package/dist/util/checkModifierPressed.d.ts.map +1 -1
  42. package/dist/util/detectOS.d.ts +1 -1
  43. package/dist/util/detectOS.d.ts.map +1 -1
  44. package/dist/util/wrongModifierPressed.d.ts +2 -2
  45. package/dist/util/wrongModifierPressed.d.ts.map +1 -1
  46. package/package.json +1 -1
  47. package/dist/types/hotkey/HotKeyChordDef.d.ts +0 -4
  48. package/dist/types/hotkey/HotKeyChordDef.d.ts.map +0 -1
  49. package/dist/types/hotkey/HotKeyDef.d.ts +0 -4
  50. package/dist/types/hotkey/HotKeyDef.d.ts.map +0 -1
  51. package/dist/types/hotkey/HotKeyDefBase.d.ts +0 -11
  52. package/dist/types/hotkey/HotKeyDefBase.d.ts.map +0 -1
  53. package/dist/types/hotkey/HotKeyDefChordBase.d.ts +0 -11
  54. package/dist/types/hotkey/HotKeyDefChordBase.d.ts.map +0 -1
  55. package/dist/types/hotkey/HotKeyDefSequenceBase.d.ts +0 -6
  56. package/dist/types/hotkey/HotKeyDefSequenceBase.d.ts.map +0 -1
  57. package/dist/types/hotkey/HotKeySequenceDef.d.ts +0 -4
  58. package/dist/types/hotkey/HotKeySequenceDef.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,5 +1,4 @@
1
- React Better Hotkeys
2
- ======================
1
+ # React Better Hotkeys
3
2
 
4
3
  A tiny, typed helper for registering global hotkeys in React. It supports both **chords** (e.g. `Shift + Alt + A`) and **key sequences** (e.g. `g` then `h`), respects platform-specific modifier keys, and cleans up registrations automatically.
5
4
 
@@ -1,27 +1,27 @@
1
1
  import { HotkeyTextResolver } from './HotkeyTextResolver';
2
2
  import { IncompleteHotkey } from './types/hotkey/chord/IncompleteChordHotkey';
3
- import { HotKeyChordDef } from './types/hotkey/HotKeyChordDef';
4
- import { HotKeySequenceDef } from './types/hotkey/HotKeySequenceDef';
3
+ import { ChordHotkey } from './types/hotkey/definition/ChordHotkey';
4
+ import { SequenceHotkey } from './types/hotkey/definition/SequenceHotkey';
5
5
  import { SequenceTree } from './types/hotkey/sequence/SequenceTree';
6
6
  export declare class HotkeyRegistry {
7
7
  sequenceTimeout: number;
8
8
  chordTimeout: number;
9
- chords: Record<string, HotKeyChordDef>;
10
- chordMap: Partial<Record<string, HotKeyChordDef[]>>;
11
- sequence: Record<string, HotKeySequenceDef>;
9
+ chords: Record<string, ChordHotkey>;
10
+ chordMap: Partial<Record<string, ChordHotkey[]>>;
11
+ sequence: Record<string, SequenceHotkey>;
12
12
  sequenceTree: SequenceTree | undefined;
13
13
  incompleteChords: Record<string, IncompleteHotkey>;
14
14
  waitingSequenceNodes: Record<number, SequenceTree>;
15
15
  textResolver?: HotkeyTextResolver;
16
16
  constructor(sequenceTimeout?: number, chordTimeout?: number, textResolver?: HotkeyTextResolver);
17
- addChordHotkey(hotkey: HotKeyChordDef): void;
18
- addSequenceHotkey(hotkey: HotKeySequenceDef): void;
17
+ addChordHotkey(hotkey: ChordHotkey): void;
18
+ addSequenceHotkey(hotkey: SequenceHotkey): void;
19
19
  removeChordHotkey(id: string): void;
20
20
  removeSequenceHotkey(id: string): void;
21
21
  private resolveSequenceTreeNode;
22
22
  clearIncompleteChords(): void;
23
23
  handleModifierKeydown(event: KeyboardEvent): void;
24
- handleChordHotkeyPressSuccess(chord: HotKeyChordDef, event: KeyboardEvent): void;
24
+ handleChordHotkeyPressSuccess(chord: ChordHotkey, event: KeyboardEvent): void;
25
25
  handleKeydown(event: KeyboardEvent): void;
26
26
  handleKeyup(event: KeyboardEvent): void;
27
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HotkeyRegistry.d.ts","sourceRoot":"","sources":["../src/lib/HotkeyRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AASzE,qBAAa,cAAc;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IAGrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAM;IAE5C,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CAAM;IAEzD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAM;IACjD,YAAY,EAAE,YAAY,GAAG,SAAS,CAAC;IAGvC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAM;IAExD,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAM;IAExD,YAAY,CAAC,EAAE,kBAAkB,CAAC;gBAGhC,eAAe,CAAC,EAAE,MAAM,EACxB,YAAY,CAAC,EAAE,MAAM,EACrB,YAAY,CAAC,EAAE,kBAAkB;IAO5B,cAAc,CAAC,MAAM,EAAE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kB,CAAC;gBAGhC,eAAe,CAAC,EAAE,MAAM,EACxB,YAAY,CAAC,EAAE,MAAM,EACrB,YAAY,CAAC,EAAE,kBAAkB;IAO5B,cAAc,CAAC,MAAM,EAAE,WAAW;IAOlC,iBAAiB,CAAC,MAAM,EAAE,cAAc;IAwBxC,iBAAiB,CAAC,EAAE,EAAE,MAAM;IAQ5B,oBAAoB,CAAC,EAAE,EAAE,MAAM;IAoCtC,OAAO,CAAC,uBAAuB;IA4C/B,qBAAqB;IAOrB,qBAAqB,CAAC,KAAK,EAAE,aAAa;IAW1C,6BAA6B,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa;IAc/D,aAAa,CAAC,KAAK,EAAE,aAAa;IA2ClC,WAAW,CAAC,KAAK,EAAE,aAAa;CAGxC"}
@@ -29,12 +29,12 @@ class B {
29
29
  this.sequence[e.id] = e, this.sequenceTree == null && (this.sequenceTree = { hotkey: [], keyBased: {}, codeBased: {} });
30
30
  let s = this.sequenceTree;
31
31
  for (let t = 0; t < e.keys.length; t++) {
32
- const o = h[e.keys[t]], i = o.on === "key" ? s.keyBased : s.codeBased, c = o.value;
33
- i[c] == null && (i[c] = {
32
+ const o = h[e.keys[t]], i = o.on === "key" ? s.keyBased : s.codeBased, r = o.value;
33
+ i[r] == null && (i[r] = {
34
34
  hotkey: [],
35
35
  keyBased: {},
36
36
  codeBased: {}
37
- }), t === e.keys.length - 1 && i[c].hotkey.push(e), s = i[c];
37
+ }), t === e.keys.length - 1 && i[r].hotkey.push(e), s = i[r];
38
38
  }
39
39
  }
40
40
  removeChordHotkey(e) {
@@ -47,8 +47,8 @@ class B {
47
47
  o.hotkey = o.hotkey.filter((y) => y.id !== s.id);
48
48
  return;
49
49
  }
50
- const [c, ...u] = i, d = c.value, n = c.on === "key" ? o.keyBased : o.codeBased, r = n[d];
51
- r != null && (t(r, u), r.hotkey.length === 0 && Object.keys(r.codeBased).length == 0 && Object.keys(r.keyBased).length == 0 && Reflect.deleteProperty(n, d));
50
+ const [r, ...u] = i, d = r.value, n = r.on === "key" ? o.keyBased : o.codeBased, c = n[d];
51
+ c != null && (t(c, u), c.hotkey.length === 0 && Object.keys(c.codeBased).length == 0 && Object.keys(c.keyBased).length == 0 && Reflect.deleteProperty(n, d));
52
52
  };
53
53
  this.sequenceTree != null && t(
54
54
  this.sequenceTree,
@@ -60,7 +60,7 @@ class B {
60
60
  if (t != null)
61
61
  if (t.hotkey.length > 0 && Object.keys(t.codeBased).length === 0 && Object.keys(t.keyBased).length === 0)
62
62
  t.hotkey.forEach((i) => {
63
- i.options.disabled || i.callback(s);
63
+ i.options.disabled || i.callbackRef.current(s);
64
64
  }), this.waitingSequenceNodes = {};
65
65
  else {
66
66
  const i = setTimeout(() => {
@@ -71,7 +71,7 @@ class B {
71
71
  if (o != null)
72
72
  if (o.hotkey.length > 0 && Object.keys(o.codeBased).length === 0 && Object.keys(o.keyBased).length === 0)
73
73
  o.hotkey.forEach((i) => {
74
- i.options.disabled || i.callback(s);
74
+ i.options.disabled || i.callbackRef.current(s);
75
75
  }), this.waitingSequenceNodes = {};
76
76
  else {
77
77
  const i = setTimeout(() => {
@@ -89,7 +89,7 @@ class B {
89
89
  l(s.hotkey, e) ? (this.handleChordHotkeyPressSuccess(s.hotkey, e), this.clearIncompleteChords()) : k(s.hotkey, e) && this.clearIncompleteChords();
90
90
  }
91
91
  handleChordHotkeyPressSuccess(e, s) {
92
- p(s) && !e.options.enableOnContentEditable || (e.options.preventDefault && s.preventDefault(), e.callback(s), this.waitingSequenceNodes = {});
92
+ p(s) && !e.options.enableOnContentEditable || (e.options.preventDefault && s.preventDefault(), e.callbackRef.current(s), this.waitingSequenceNodes = {});
93
93
  }
94
94
  handleKeydown(e) {
95
95
  if (a(e)) {
@@ -1,4 +1,4 @@
1
- import { HotKeyDef } from './types/hotkey/HotKeyDef';
1
+ import { Hotkey } from './types/hotkey/definition/Hotkey';
2
2
  import { HotKeyType } from './types/hotkey/HotkeyType';
3
3
  import { ResolvedKeyStatus } from './types/hotkey/renderer/ResolvedKeyStatus';
4
4
  import { PrimaryKeyCode } from './types/key/PrimaryKeyCode';
@@ -22,6 +22,6 @@ export declare class HotkeyTextResolver {
22
22
  subscribe(code: PrimaryKeyCode, callback: (newSymbol: string) => void): () => void;
23
23
  unsubscribe(code: PrimaryKeyCode, subscriberId: number): void;
24
24
  delimiterForType(type: HotKeyType): string;
25
- toString(hotkey: HotKeyDef): string;
25
+ toString(hotkey: Hotkey): string;
26
26
  }
27
27
  //# sourceMappingURL=HotkeyTextResolver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HotkeyTextResolver.d.ts","sourceRoot":"","sources":["../src/lib/HotkeyTextResolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAcjE,qBAAa,kBAAkB;IAC7B,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAM;IACxD,gBAAgB,EAAE,GAAG,CAAC,cAAc,CAAC,CAAa;IAElD,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IAEzB,EAAE,EAAE,MAAM,CAAiB;IAE3B,OAAO,CAAC,gBAAgB,CAAK;IAE7B,OAAO,CAAC,WAAW,CAEZ;gBAGL,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,EACnD,cAAc,CAAC,EAAE,MAAM,EACvB,iBAAiB,CAAC,EAAE,MAAM;IAW5B,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,eAAe;IAwBvB,OAAO,CAA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,EAAE,MAAM,EACvB,iBAAiB,CAAC,EAAE,MAAM;IAW5B,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,eAAe;IAwBvB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,SAAS;IAUV,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAiCtC,OAAO,CACZ,IAAI,EAAE,cAAc,GACnB,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,SAAS;IAOnC,SAAS,CACd,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,GACpC,MAAM,IAAI;IAcN,WAAW,CAAC,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAW7D,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM;IAK1C,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAIxC"}
@@ -1,6 +1,6 @@
1
1
  import { KeyMap as a } from "./definitions/KeyMap.js";
2
- const o = "rbh-symbols-cache";
3
- class c {
2
+ const b = "rbh-symbols-cache";
3
+ class p {
4
4
  symbolMap = {};
5
5
  invalidSymbolMap = /* @__PURE__ */ new Set();
6
6
  chordDelimiter;
@@ -40,10 +40,10 @@ class c {
40
40
  }
41
41
  storeState(t) {
42
42
  for (const e of t) this.invalidSymbolMap.delete(e);
43
- localStorage.setItem(o, this.stringifyState());
43
+ localStorage.setItem(b, this.stringifyState());
44
44
  }
45
45
  loadState() {
46
- const t = localStorage.getItem(o);
46
+ const t = localStorage.getItem(b);
47
47
  if (t) {
48
48
  const e = JSON.parse(t);
49
49
  return this.parseState(e), !0;
@@ -56,13 +56,13 @@ class c {
56
56
  );
57
57
  if (s == null)
58
58
  return;
59
- const i = s[0];
60
- if (this.symbolMap[i] === e) return;
61
- this.symbolMap[i] = e.length === 1 ? e.toLocaleUpperCase() : e;
62
- const n = Object.entries(this.symbolMap).find(
63
- ([r, b]) => r !== i && b === this.symbolMap[i]
59
+ const i = s[0], n = e.length === 1 ? e.toLocaleUpperCase() : e;
60
+ if (this.symbolMap[i] === n) return;
61
+ this.symbolMap[i] = n;
62
+ const o = Object.entries(this.symbolMap).find(
63
+ ([r, h]) => r !== i && h === this.symbolMap[i]
64
64
  );
65
- n && this.invalidSymbolMap.add(n[0]), this.storeState([i]);
65
+ o && this.invalidSymbolMap.add(o[0]), this.storeState([i]);
66
66
  const l = this.subscribers[i];
67
67
  if (l)
68
68
  for (const r of l.values())
@@ -91,5 +91,5 @@ class c {
91
91
  }
92
92
  }
93
93
  export {
94
- c as HotkeyTextResolver
94
+ p as HotkeyTextResolver
95
95
  };
@@ -1,18 +1,17 @@
1
- import { HotKeyDefChordBase } from '../types/hotkey/HotKeyDefChordBase';
2
- import { HotKeyDefSequenceBase } from '../types/hotkey/HotKeyDefSequenceBase';
3
- import { HotKeyChordDef } from '../types/hotkey/HotKeyChordDef';
4
- import { HotKeySequenceDef } from '../types/hotkey/HotKeySequenceDef';
1
+ import { ChordHotkeySpec } from '../types/hotkey/definition/ChordHotkeySpec';
2
+ import { SequenceHotkeySpec } from '../types/hotkey/definition/SequenceHotkeySpec';
3
+ import { ChordHotkey } from '../types/hotkey/definition/ChordHotkey';
4
+ import { SequenceHotkey } from '../types/hotkey/definition/SequenceHotkey';
5
5
  import { HotkeyCallback } from '../types/hotkey/HotkeyCallback';
6
6
  import { HotkeyOptions } from '../types/hotkey/HotkeyOptions';
7
- type ChordIn = HotKeyDefChordBase;
8
- type SequenceIn = HotKeyDefSequenceBase;
9
- type ChordOut = HotKeyChordDef;
10
- type SequenceOut = HotKeySequenceDef;
11
- type HotkeyMapping<T extends readonly (ChordIn | SequenceIn)[]> = {
12
- [K in keyof T]: T[K] extends ChordIn ? ChordOut : SequenceOut;
13
- };
14
- export declare function useHotkey(hotkey: ChordIn, callback: HotkeyCallback, dependencies?: unknown[], options?: Partial<HotkeyOptions>): ChordOut;
15
- export declare function useHotkey(hotkey: SequenceIn, callback: HotkeyCallback, dependencies?: unknown[], options?: Partial<HotkeyOptions>): SequenceOut;
16
- export declare function useHotkey<const T extends readonly (ChordIn | SequenceIn)[]>(hotkey: T, callback: HotkeyCallback, dependencies?: unknown[], options?: Partial<HotkeyOptions>): HotkeyMapping<typeof hotkey>;
17
- export {};
7
+ import { HotkeySpec } from '../types/hotkey/definition/HotkeySpec';
8
+ import { Hotkey } from '../types/hotkey/definition/Hotkey';
9
+ export declare function useHotkey(hotkey: HotkeySpec[], callback: HotkeyCallback, options?: Partial<HotkeyOptions>): Hotkey[];
10
+ export declare function useHotkey(hotkey: HotkeySpec[] | undefined, callback: HotkeyCallback, options?: Partial<HotkeyOptions>): Hotkey[] | undefined;
11
+ export declare function useHotkey(hotkey: ChordHotkeySpec, callback: HotkeyCallback, options?: Partial<HotkeyOptions>): ChordHotkey;
12
+ export declare function useHotkey(hotkey: ChordHotkeySpec | undefined, callback: HotkeyCallback, options?: Partial<HotkeyOptions>): ChordHotkey | undefined;
13
+ export declare function useHotkey(hotkey: SequenceHotkeySpec, callback: HotkeyCallback, options?: Partial<HotkeyOptions>): SequenceHotkey;
14
+ export declare function useHotkey(hotkey: SequenceHotkeySpec | undefined, callback: HotkeyCallback, options?: Partial<HotkeyOptions>): SequenceHotkey | undefined;
15
+ export declare function useHotkey(hotkey: HotkeySpec, callback: HotkeyCallback, options?: Partial<HotkeyOptions>): Hotkey;
16
+ export declare function useHotkey(hotkey: HotkeySpec | undefined, callback: HotkeyCallback, options?: Partial<HotkeyOptions>): Hotkey | undefined;
18
17
  //# sourceMappingURL=useHotkey.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useHotkey.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useHotkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,qBA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EACxB,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC/B,cAAc,CAAC;AAClB,wBAAgB,SAAS,CACvB,MAAM,EAAE,kBAAkB,GAAG,SAAS,EACtC,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC/B,cAAc,GAAG,SAAS,CAAC;AAC9B,wBAAgB,SAAS,CACvB,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC/B,MAAM,CAAC;AACV,wBAAgB,SAAS,CACvB,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC/B,MAAM,GAAG,SAAS,CAAC"}
@@ -1,13 +1,14 @@
1
- import { useLayoutEffect as C, useEffect as H, useContext as g, useId as R, useMemo as m, useCallback as c } from "react";
2
- import { HotkeyContext as S } from "../context/HotkeyContext.js";
1
+ import { useLayoutEffect as H, useEffect as C, useContext as R, useId as g, useRef as S, useMemo as m, useCallback as p } from "react";
2
+ import { HotkeyContext as E } from "../context/HotkeyContext.js";
3
3
  import { KeyMap as x } from "../definitions/KeyMap.js";
4
- import { isPrimaryKeyCode as E } from "../util/isPrimaryKeyCode.js";
5
- const w = typeof window < "u" ? C : H;
6
- function A(o) {
7
- return Array.isArray(o);
8
- }
9
- function q(o, y, p, v) {
10
- const r = g(S), n = R(), a = m(
4
+ import { isPrimaryKeyCode as w } from "../util/isPrimaryKeyCode.js";
5
+ const $ = typeof window < "u" ? H : C;
6
+ function q(o, d, v) {
7
+ const r = R(E), n = g(), f = S(d);
8
+ C(() => {
9
+ f.current = d;
10
+ }, [d]);
11
+ const l = m(
11
12
  () => ({
12
13
  preventDefault: !0,
13
14
  enableOnContentEditable: !1,
@@ -15,39 +16,39 @@ function q(o, y, p, v) {
15
16
  ...v
16
17
  }),
17
18
  [v]
18
- ), d = c(
19
- (e) => E(e) ? r?.textResolver.resolve(e) ?? [
19
+ ), a = p(
20
+ (e) => w(e) ? r?.textResolver.resolve(e) ?? [
20
21
  x[`Key${e}`].value,
21
22
  "unknown"
22
23
  ] : [x[e].value, "unknown"],
23
24
  [r?.textResolver]
24
- ), l = c(
25
+ ), c = p(
25
26
  (e, t) => {
26
27
  const i = {
27
28
  ...e,
28
- options: a,
29
+ options: l,
29
30
  id: t == null ? n : `${n}-${t}`,
30
- callback: y,
31
+ callbackRef: f,
31
32
  toParts: () => [
32
- e.keys.map((u) => d(u)),
33
+ e.keys.map((u) => a(u)),
33
34
  r?.textResolver.delimiterForType(e.type) ?? ""
34
35
  ],
35
36
  toString: () => r?.textResolver.toString(i) ?? ""
36
37
  };
37
38
  return i;
38
39
  },
39
- [a, y, r?.textResolver, n, d]
40
- ), f = c(
40
+ [l, r?.textResolver, n, a]
41
+ ), y = p(
41
42
  (e, t) => {
42
43
  const i = {
43
44
  ...e,
44
- options: a,
45
+ options: l,
45
46
  id: t == null ? n : `${n}-${t}`,
46
- callback: y,
47
+ callbackRef: f,
47
48
  toParts: () => [
48
49
  [
49
50
  ...Object.entries(e.modifier).filter((u) => u[1]).map((u) => [u[0], "valid"]),
50
- d(e.keyId)
51
+ a(e.keyId)
51
52
  ],
52
53
  r?.textResolver.delimiterForType(e.type) ?? ""
53
54
  ],
@@ -55,9 +56,9 @@ function q(o, y, p, v) {
55
56
  };
56
57
  return i;
57
58
  },
58
- [a, y, r?.textResolver, n, d]
59
- ), s = m(() => A(o) ? o.map((e, t) => e.type === "chord" ? f(e, t) : l(e, t)) : o.type === "chord" ? f(o) : l(o), [f, l, o]);
60
- return w(() => {
59
+ [l, r?.textResolver, n, a]
60
+ ), s = m(() => o == null ? [] : Array.isArray(o) ? o.map((e, t) => e.type === "chord" ? y(e, t) : c(e, t)) : o.type === "chord" ? y(o) : c(o), [y, c, o]);
61
+ return $(() => {
61
62
  if (r == null) {
62
63
  console.warn(
63
64
  "No HotkeyContext provided. Use <HotkeyProvider> to provide a HotkeyContext"
@@ -72,7 +73,7 @@ function q(o, y, p, v) {
72
73
  t.type === "chord" ? r.registry.removeChordHotkey(t.id) : r.registry.removeSequenceHotkey(t.id);
73
74
  });
74
75
  };
75
- }, [s, ...p || []]), s;
76
+ }, [s]), o ? s : void 0;
76
77
  }
77
78
  export {
78
79
  q as useHotkey
@@ -1,7 +1,6 @@
1
- import { HotKeyDef } from '../types/hotkey/HotKeyDef';
2
- import { HotkeyTextParts } from '../types/hotkey/HotkeyTextParts';
3
- export declare function useRenderedHotkey(hotkey: HotKeyDef): {
4
- asString: string;
5
- asParts: HotkeyTextParts;
6
- };
1
+ import { Hotkey } from '../types/hotkey/definition/Hotkey';
2
+ import { RenderedHotkey } from '../types/hotkey/renderer/RenderedHotkey';
3
+ export declare function useRenderedHotkey(hotkey: Hotkey): RenderedHotkey;
4
+ export declare function useRenderedHotkey(hotkey: undefined): undefined;
5
+ export declare function useRenderedHotkey(hotkey: Hotkey | undefined): RenderedHotkey | undefined;
7
6
  //# sourceMappingURL=useRenderedHotkey.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRenderedHotkey.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useRenderedHotkey.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS;cAIrC,MAAM;aACP,eAAe;EAiC3B"}
1
+ {"version":3,"file":"useRenderedHotkey.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useRenderedHotkey.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAGhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAE9E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC;AAElE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;AAEhE,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,cAAc,GAAG,SAAS,CAAC"}
@@ -1,31 +1,33 @@
1
1
  import { useContext as a, useState as u, useEffect as c } from "react";
2
2
  import { HotkeyContext as d } from "../context/HotkeyContext.js";
3
- import { toPrimaryKeyCode as o } from "../util/toPrimaryKeyCode.js";
4
- function P(r) {
5
- const t = a(d), [i, n] = u({
6
- asString: r.toString(),
7
- asParts: r.toParts()
8
- });
3
+ import { toPrimaryKeyCode as i } from "../util/toPrimaryKeyCode.js";
4
+ function p(r) {
5
+ const t = a(d), [o, n] = u(
6
+ r ? {
7
+ asString: r.toString(),
8
+ asParts: r.toParts()
9
+ } : void 0
10
+ );
9
11
  return c(() => {
10
- if (t == null) return;
11
- let e;
12
- return r.type === "chord" ? e = [
13
- t.textResolver.subscribe(o(r.keyId), () => {
12
+ if (t == null || r == null) return;
13
+ let s;
14
+ return r.type === "chord" ? s = [
15
+ t.textResolver.subscribe(i(r.keyId), () => {
14
16
  n({
15
17
  asParts: r.toParts(),
16
18
  asString: r.toString()
17
19
  });
18
20
  })
19
- ] : e = r.keys.map(
20
- (s) => t.textResolver.subscribe(o(s), () => {
21
+ ] : s = r.keys.map(
22
+ (e) => t.textResolver.subscribe(i(e), () => {
21
23
  n({
22
24
  asParts: r.toParts(),
23
25
  asString: r.toString()
24
26
  });
25
27
  })
26
- ), () => e.forEach((s) => s());
27
- }, [t, r]), i;
28
+ ), () => s.forEach((e) => e());
29
+ }, [t, r]), o;
28
30
  }
29
31
  export {
30
- P as useRenderedHotkey
32
+ p as useRenderedHotkey
31
33
  };
@@ -1,6 +1,6 @@
1
- import { HotKeyDefChordBase } from '../HotKeyDefChordBase';
1
+ import { ChordHotkeySpec } from '../definition/ChordHotkeySpec';
2
2
  export type ChordNode<Modifier extends string, Keys extends string> = {
3
- readonly [K in Keys]: HotKeyDefChordBase;
3
+ readonly [K in Keys]: ChordHotkeySpec;
4
4
  } & {
5
5
  readonly [K in Modifier]: ChordNode<Exclude<Modifier, K>, Keys>;
6
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ChordNode.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/chord/ChordNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,MAAM,MAAM,SAAS,CAAC,QAAQ,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,IAAI;IACpE,QAAQ,EAAE,CAAC,IAAI,IAAI,GAAG,kBAAkB;CACzC,GAAG;IACF,QAAQ,EAAE,CAAC,IAAI,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;CAChE,CAAC"}
1
+ {"version":3,"file":"ChordNode.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/chord/ChordNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,MAAM,MAAM,SAAS,CAAC,QAAQ,SAAS,MAAM,EAAE,IAAI,SAAS,MAAM,IAAI;IACpE,QAAQ,EAAE,CAAC,IAAI,IAAI,GAAG,eAAe;CACtC,GAAG;IACF,QAAQ,EAAE,CAAC,IAAI,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;CAChE,CAAC"}
@@ -1,6 +1,6 @@
1
- import { HotKeyChordDef } from '../HotKeyChordDef';
1
+ import { ChordHotkey } from '../definition/ChordHotkey';
2
2
  export type IncompleteHotkey = {
3
- hotkey: HotKeyChordDef;
3
+ hotkey: ChordHotkey;
4
4
  timeoutId: number;
5
5
  };
6
6
  //# sourceMappingURL=IncompleteChordHotkey.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IncompleteChordHotkey.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/chord/IncompleteChordHotkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
1
+ {"version":3,"file":"IncompleteChordHotkey.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/chord/IncompleteChordHotkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { HotkeyInstanceBase } from './HotkeyInstanceBase';
2
+ import { ChordHotkeySpec } from './ChordHotkeySpec';
3
+ export type ChordHotkey = HotkeyInstanceBase & ChordHotkeySpec;
4
+ //# sourceMappingURL=ChordHotkey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChordHotkey.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/definition/ChordHotkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,WAAW,GAAG,kBAAkB,GAAG,eAAe,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { KeyValueType } from '../../key/KeyValueType';
2
+ import { ModifierKeyCode } from '../../key/ModifierKeyCode';
3
+ import { PrimaryKey } from '../../key/PrimaryKey';
4
+ export type ChordHotkeySpec = {
5
+ type: "chord";
6
+ resolve: KeyValueType;
7
+ keyId: PrimaryKey;
8
+ primaryValue: string;
9
+ modifier: Record<Exclude<ModifierKeyCode, "Mod">, boolean>;
10
+ };
11
+ //# sourceMappingURL=ChordHotkeySpec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChordHotkeySpec.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/definition/ChordHotkeySpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,EAAE,UAAU,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;CAC5D,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ChordHotkey } from './ChordHotkey';
2
+ import { SequenceHotkey } from './SequenceHotkey';
3
+ export type Hotkey = ChordHotkey | SequenceHotkey;
4
+ //# sourceMappingURL=Hotkey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hotkey.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/definition/Hotkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,MAAM,MAAM,GAAG,WAAW,GAAG,cAAc,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { RefObject } from 'react';
2
+ import { HotkeyCallback } from '../HotkeyCallback';
3
+ import { HotkeyOptions } from '../HotkeyOptions';
4
+ import { HotkeyTextParts } from '../HotkeyTextParts';
5
+ export type HotkeyInstanceBase = {
6
+ id: string;
7
+ callbackRef: RefObject<HotkeyCallback>;
8
+ options: HotkeyOptions;
9
+ toString: () => string;
10
+ toParts: () => HotkeyTextParts;
11
+ };
12
+ //# sourceMappingURL=HotkeyInstanceBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotkeyInstanceBase.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/definition/HotkeyInstanceBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACvC,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,eAAe,CAAC;CAChC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ChordHotkeySpec } from './ChordHotkeySpec';
2
+ import { SequenceHotkeySpec } from './SequenceHotkeySpec';
3
+ export type HotkeySpec = ChordHotkeySpec | SequenceHotkeySpec;
4
+ //# sourceMappingURL=HotkeySpec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HotkeySpec.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/definition/HotkeySpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,kBAAkB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { HotkeyInstanceBase } from './HotkeyInstanceBase';
2
+ import { SequenceHotkeySpec } from './SequenceHotkeySpec';
3
+ export type SequenceHotkey = HotkeyInstanceBase & SequenceHotkeySpec;
4
+ //# sourceMappingURL=SequenceHotkey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SequenceHotkey.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/definition/SequenceHotkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,kBAAkB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { PrimaryKey } from '../../key/PrimaryKey';
2
+ export type SequenceHotkeySpec = {
3
+ type: "sequence";
4
+ keys: PrimaryKey[];
5
+ };
6
+ //# sourceMappingURL=SequenceHotkeySpec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SequenceHotkeySpec.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/definition/SequenceHotkeySpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,UAAU,EAAE,CAAC;CACpB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { HotkeyTextParts } from '../HotkeyTextParts';
2
+ export type RenderedHotkey = {
3
+ asString: string;
4
+ asParts: HotkeyTextParts;
5
+ };
6
+ //# sourceMappingURL=RenderedHotkey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RenderedHotkey.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/renderer/RenderedHotkey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,eAAe,CAAC;CAC1B,CAAC"}
@@ -1,6 +1,6 @@
1
- import { HotKeyDefSequenceBase } from '../HotKeyDefSequenceBase';
1
+ import { SequenceHotkeySpec } from '../definition/SequenceHotkeySpec';
2
2
  export type SequenceNode<All extends string> = {
3
- end: HotKeyDefSequenceBase;
3
+ end: SequenceHotkeySpec;
4
4
  } & {
5
5
  readonly [K in All]: SequenceNode<All>;
6
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"SequenceNode.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/sequence/SequenceNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,MAAM,YAAY,CAAC,GAAG,SAAS,MAAM,IAAI;IAC7C,GAAG,EAAE,qBAAqB,CAAC;CAC5B,GAAG;IACF,QAAQ,EAAE,CAAC,IAAI,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC;CACvC,CAAC"}
1
+ {"version":3,"file":"SequenceNode.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/sequence/SequenceNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,MAAM,MAAM,YAAY,CAAC,GAAG,SAAS,MAAM,IAAI;IAC7C,GAAG,EAAE,kBAAkB,CAAC;CACzB,GAAG;IACF,QAAQ,EAAE,CAAC,IAAI,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC;CACvC,CAAC"}
@@ -1,6 +1,6 @@
1
- import { HotKeySequenceDef } from '../HotKeySequenceDef';
1
+ import { SequenceHotkey } from '../definition/SequenceHotkey';
2
2
  export type SequenceTree = {
3
- hotkey: HotKeySequenceDef[];
3
+ hotkey: SequenceHotkey[];
4
4
  keyBased: Partial<{
5
5
  [key in string]: SequenceTree;
6
6
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"SequenceTree.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/sequence/SequenceTree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAC;SACf,GAAG,IAAI,MAAM,GAAG,YAAY;KAC9B,CAAC,CAAC;IACH,SAAS,EAAE,OAAO,CAAC;SAChB,IAAI,IAAI,MAAM,GAAG,YAAY;KAC/B,CAAC,CAAC;CACJ,CAAC"}
1
+ {"version":3,"file":"SequenceTree.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/hotkey/sequence/SequenceTree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;SACf,GAAG,IAAI,MAAM,GAAG,YAAY;KAC9B,CAAC,CAAC;IACH,SAAS,EAAE,OAAO,CAAC;SAChB,IAAI,IAAI,MAAM,GAAG,YAAY;KAC/B,CAAC,CAAC;CACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type OS = "iOS/iPadOS" | "Android" | "Windows" | "macOS" | "Linux" | "Unknown";
2
+ //# sourceMappingURL=OS.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OS.d.ts","sourceRoot":"","sources":["../../../src/lib/types/other/OS.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,EAAE,GACV,YAAY,GACZ,SAAS,GACT,SAAS,GACT,OAAO,GACP,OAAO,GACP,SAAS,CAAC"}
@@ -1,3 +1,3 @@
1
- import { HotKeyChordDef } from '../types/hotkey/HotKeyChordDef';
2
- export declare function checkModifierPressed(chord: HotKeyChordDef, event: KeyboardEvent): boolean;
1
+ import { ChordHotkey } from '../types/hotkey/definition/ChordHotkey';
2
+ export declare function checkModifierPressed(chord: ChordHotkey, event: KeyboardEvent): boolean;
3
3
  //# sourceMappingURL=checkModifierPressed.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkModifierPressed.d.ts","sourceRoot":"","sources":["../../src/lib/util/checkModifierPressed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,aAAa,GACnB,OAAO,CAOT"}
1
+ {"version":3,"file":"checkModifierPressed.d.ts","sourceRoot":"","sources":["../../src/lib/util/checkModifierPressed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAE1E,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,aAAa,GACnB,OAAO,CAOT"}
@@ -1,3 +1,3 @@
1
- export type OS = "iOS/iPadOS" | "Android" | "Windows" | "macOS" | "Linux" | "Unknown";
1
+ import { OS } from '../types/other/OS';
2
2
  export declare function detectOS(): OS;
3
3
  //# sourceMappingURL=detectOS.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"detectOS.d.ts","sourceRoot":"","sources":["../../src/lib/util/detectOS.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,EAAE,GACV,YAAY,GACZ,SAAS,GACT,SAAS,GACT,OAAO,GACP,OAAO,GACP,SAAS,CAAC;AAId,wBAAgB,QAAQ,IAAI,EAAE,CAkB7B"}
1
+ {"version":3,"file":"detectOS.d.ts","sourceRoot":"","sources":["../../src/lib/util/detectOS.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAI5C,wBAAgB,QAAQ,IAAI,EAAE,CAkB7B"}
@@ -1,3 +1,3 @@
1
- import { HotKeyChordDef } from '../types/hotkey/HotKeyChordDef';
2
- export declare function wrongModifierPressed(chord: HotKeyChordDef, event: KeyboardEvent): boolean;
1
+ import { ChordHotkey } from '../types/hotkey/definition/ChordHotkey';
2
+ export declare function wrongModifierPressed(chord: ChordHotkey, event: KeyboardEvent): boolean;
3
3
  //# sourceMappingURL=wrongModifierPressed.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wrongModifierPressed.d.ts","sourceRoot":"","sources":["../../src/lib/util/wrongModifierPressed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,aAAa,GACnB,OAAO,CAOT"}
1
+ {"version":3,"file":"wrongModifierPressed.d.ts","sourceRoot":"","sources":["../../src/lib/util/wrongModifierPressed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAE1E,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,aAAa,GACnB,OAAO,CAOT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-better-hotkeys",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "author": "Christopher Haindl",
6
6
  "repository": {
@@ -1,4 +0,0 @@
1
- import { HotKeyDefBase } from './HotKeyDefBase';
2
- import { HotKeyDefChordBase } from './HotKeyDefChordBase';
3
- export type HotKeyChordDef = HotKeyDefBase & HotKeyDefChordBase;
4
- //# sourceMappingURL=HotKeyChordDef.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotKeyChordDef.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotKeyChordDef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,kBAAkB,CAAC"}
@@ -1,4 +0,0 @@
1
- import { HotKeyChordDef } from './HotKeyChordDef';
2
- import { HotKeySequenceDef } from './HotKeySequenceDef';
3
- export type HotKeyDef = HotKeyChordDef | HotKeySequenceDef;
4
- //# sourceMappingURL=HotKeyDef.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotKeyDef.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotKeyDef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,iBAAiB,CAAC"}
@@ -1,11 +0,0 @@
1
- import { HotkeyCallback } from './HotkeyCallback';
2
- import { HotkeyOptions } from './HotkeyOptions';
3
- import { HotkeyTextParts } from './HotkeyTextParts';
4
- export type HotKeyDefBase = {
5
- id: string;
6
- callback: HotkeyCallback;
7
- options: HotkeyOptions;
8
- toString: () => string;
9
- toParts: () => HotkeyTextParts;
10
- };
11
- //# sourceMappingURL=HotKeyDefBase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotKeyDefBase.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotKeyDefBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,eAAe,CAAC;CAChC,CAAC"}
@@ -1,11 +0,0 @@
1
- import { KeyValueType } from '../key/KeyValueType';
2
- import { ModifierKeyCode } from '../key/ModifierKeyCode';
3
- import { PrimaryKey } from '../key/PrimaryKey';
4
- export type HotKeyDefChordBase = {
5
- type: "chord";
6
- resolve: KeyValueType;
7
- keyId: PrimaryKey;
8
- primaryValue: string;
9
- modifier: Record<Exclude<ModifierKeyCode, "Mod">, boolean>;
10
- };
11
- //# sourceMappingURL=HotKeyDefChordBase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotKeyDefChordBase.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotKeyDefChordBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,EAAE,UAAU,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;CAC5D,CAAC"}
@@ -1,6 +0,0 @@
1
- import { PrimaryKey } from '../key/PrimaryKey';
2
- export type HotKeyDefSequenceBase = {
3
- type: "sequence";
4
- keys: PrimaryKey[];
5
- };
6
- //# sourceMappingURL=HotKeyDefSequenceBase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotKeyDefSequenceBase.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotKeyDefSequenceBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,UAAU,EAAE,CAAC;CACpB,CAAC"}
@@ -1,4 +0,0 @@
1
- import { HotKeyDefBase } from './HotKeyDefBase';
2
- import { HotKeyDefSequenceBase } from './HotKeyDefSequenceBase';
3
- export type HotKeySequenceDef = HotKeyDefBase & HotKeyDefSequenceBase;
4
- //# sourceMappingURL=HotKeySequenceDef.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"HotKeySequenceDef.d.ts","sourceRoot":"","sources":["../../../src/lib/types/hotkey/HotKeySequenceDef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAErE,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,qBAAqB,CAAC"}