@tanstack/angular-hotkeys 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hotkeys-provider.cjs.map +1 -1
- package/dist/hotkeys-provider.d.cts +2 -1
- package/dist/hotkeys-provider.d.ts +2 -1
- package/dist/hotkeys-provider.js.map +1 -1
- package/dist/index.cjs +4 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/injectHotkey.cjs +36 -6
- package/dist/injectHotkey.cjs.map +1 -1
- package/dist/injectHotkey.d.cts +2 -0
- package/dist/injectHotkey.d.ts +2 -0
- package/dist/injectHotkey.js +37 -7
- package/dist/injectHotkey.js.map +1 -1
- package/dist/injectHotkeySequence.cjs +43 -11
- package/dist/injectHotkeySequence.cjs.map +1 -1
- package/dist/injectHotkeySequence.d.cts +9 -2
- package/dist/injectHotkeySequence.d.ts +9 -2
- package/dist/injectHotkeySequence.js +45 -13
- package/dist/injectHotkeySequence.js.map +1 -1
- package/dist/injectHotkeySequenceRecorder.cjs +58 -0
- package/dist/injectHotkeySequenceRecorder.cjs.map +1 -0
- package/dist/injectHotkeySequenceRecorder.d.cts +19 -0
- package/dist/injectHotkeySequenceRecorder.d.ts +19 -0
- package/dist/injectHotkeySequenceRecorder.js +58 -0
- package/dist/injectHotkeySequenceRecorder.js.map +1 -0
- package/dist/injectHotkeySequences.cjs +105 -0
- package/dist/injectHotkeySequences.cjs.map +1 -0
- package/dist/injectHotkeySequences.d.cts +47 -0
- package/dist/injectHotkeySequences.d.ts +47 -0
- package/dist/injectHotkeySequences.js +105 -0
- package/dist/injectHotkeySequences.js.map +1 -0
- package/package.json +2 -2
- package/src/hotkeys-provider.ts +5 -1
- package/src/index.ts +2 -0
- package/src/injectHotkey.ts +43 -11
- package/src/injectHotkeySequence.ts +66 -19
- package/src/injectHotkeySequenceRecorder.ts +103 -0
- package/src/injectHotkeySequences.ts +176 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hotkeys-provider.cjs","names":["InjectionToken"],"sources":["../src/hotkeys-provider.ts"],"sourcesContent":["import { InjectionToken, inject } from '@angular/core'\nimport type {
|
|
1
|
+
{"version":3,"file":"hotkeys-provider.cjs","names":["InjectionToken"],"sources":["../src/hotkeys-provider.ts"],"sourcesContent":["import { InjectionToken, inject } from '@angular/core'\nimport type {\n HotkeyRecorderOptions,\n HotkeySequenceRecorderOptions,\n} from '@tanstack/hotkeys'\nimport type { InjectHotkeyOptions } from './injectHotkey'\nimport type { InjectHotkeySequenceOptions } from './injectHotkeySequence'\nimport type { StaticProvider } from '@angular/core'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<InjectHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>\n hotkeySequence?: Partial<InjectHotkeySequenceOptions>\n}\n\nexport interface HotkeysContextValue {\n readonly defaultOptions: HotkeysProviderOptions\n}\n\nexport const HOTKEYS_INJECTION_TOKEN = new InjectionToken<HotkeysContextValue>(\n 'HOTKEYS_INJECTION_TOKEN',\n {\n providedIn: 'root',\n factory: () => ({ defaultOptions: {} }),\n },\n)\n\nexport function provideHotkeys(\n defaultOptions: HotkeysProviderOptions,\n): StaticProvider {\n return {\n provide: HOTKEYS_INJECTION_TOKEN,\n useValue: { defaultOptions },\n }\n}\n\nexport function injectHotkeysContext(): HotkeysContextValue {\n return inject(HOTKEYS_INJECTION_TOKEN)\n}\n\nexport function injectDefaultHotkeysOptions(): HotkeysProviderOptions {\n return injectHotkeysContext().defaultOptions\n}\n"],"mappings":";;;AAoBA,MAAa,0BAA0B,IAAIA,6BACzC,2BACA;CACE,YAAY;CACZ,gBAAgB,EAAE,gBAAgB,EAAE,EAAE;CACvC,CACF;AAED,SAAgB,eACd,gBACgB;AAChB,QAAO;EACL,SAAS;EACT,UAAU,EAAE,gBAAgB;EAC7B;;AAGH,SAAgB,uBAA4C;AAC1D,kCAAc,wBAAwB;;AAGxC,SAAgB,8BAAsD;AACpE,QAAO,sBAAsB,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { InjectHotkeyOptions } from "./injectHotkey.cjs";
|
|
2
2
|
import { InjectHotkeySequenceOptions } from "./injectHotkeySequence.cjs";
|
|
3
|
-
import { HotkeyRecorderOptions } from "@tanstack/hotkeys";
|
|
3
|
+
import { HotkeyRecorderOptions, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
|
|
4
4
|
import { InjectionToken, StaticProvider } from "@angular/core";
|
|
5
5
|
|
|
6
6
|
//#region src/hotkeys-provider.d.ts
|
|
7
7
|
interface HotkeysProviderOptions {
|
|
8
8
|
hotkey?: Partial<InjectHotkeyOptions>;
|
|
9
9
|
hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
|
|
10
|
+
hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>;
|
|
10
11
|
hotkeySequence?: Partial<InjectHotkeySequenceOptions>;
|
|
11
12
|
}
|
|
12
13
|
interface HotkeysContextValue {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { InjectHotkeyOptions } from "./injectHotkey.js";
|
|
2
2
|
import { InjectHotkeySequenceOptions } from "./injectHotkeySequence.js";
|
|
3
|
-
import { HotkeyRecorderOptions } from "@tanstack/hotkeys";
|
|
3
|
+
import { HotkeyRecorderOptions, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
|
|
4
4
|
import { InjectionToken, StaticProvider } from "@angular/core";
|
|
5
5
|
|
|
6
6
|
//#region src/hotkeys-provider.d.ts
|
|
7
7
|
interface HotkeysProviderOptions {
|
|
8
8
|
hotkey?: Partial<InjectHotkeyOptions>;
|
|
9
9
|
hotkeyRecorder?: Partial<HotkeyRecorderOptions>;
|
|
10
|
+
hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>;
|
|
10
11
|
hotkeySequence?: Partial<InjectHotkeySequenceOptions>;
|
|
11
12
|
}
|
|
12
13
|
interface HotkeysContextValue {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hotkeys-provider.js","names":[],"sources":["../src/hotkeys-provider.ts"],"sourcesContent":["import { InjectionToken, inject } from '@angular/core'\nimport type {
|
|
1
|
+
{"version":3,"file":"hotkeys-provider.js","names":[],"sources":["../src/hotkeys-provider.ts"],"sourcesContent":["import { InjectionToken, inject } from '@angular/core'\nimport type {\n HotkeyRecorderOptions,\n HotkeySequenceRecorderOptions,\n} from '@tanstack/hotkeys'\nimport type { InjectHotkeyOptions } from './injectHotkey'\nimport type { InjectHotkeySequenceOptions } from './injectHotkeySequence'\nimport type { StaticProvider } from '@angular/core'\n\nexport interface HotkeysProviderOptions {\n hotkey?: Partial<InjectHotkeyOptions>\n hotkeyRecorder?: Partial<HotkeyRecorderOptions>\n hotkeySequenceRecorder?: Partial<HotkeySequenceRecorderOptions>\n hotkeySequence?: Partial<InjectHotkeySequenceOptions>\n}\n\nexport interface HotkeysContextValue {\n readonly defaultOptions: HotkeysProviderOptions\n}\n\nexport const HOTKEYS_INJECTION_TOKEN = new InjectionToken<HotkeysContextValue>(\n 'HOTKEYS_INJECTION_TOKEN',\n {\n providedIn: 'root',\n factory: () => ({ defaultOptions: {} }),\n },\n)\n\nexport function provideHotkeys(\n defaultOptions: HotkeysProviderOptions,\n): StaticProvider {\n return {\n provide: HOTKEYS_INJECTION_TOKEN,\n useValue: { defaultOptions },\n }\n}\n\nexport function injectHotkeysContext(): HotkeysContextValue {\n return inject(HOTKEYS_INJECTION_TOKEN)\n}\n\nexport function injectDefaultHotkeysOptions(): HotkeysProviderOptions {\n return injectHotkeysContext().defaultOptions\n}\n"],"mappings":";;;AAoBA,MAAa,0BAA0B,IAAI,eACzC,2BACA;CACE,YAAY;CACZ,gBAAgB,EAAE,gBAAgB,EAAE,EAAE;CACvC,CACF;AAED,SAAgB,eACd,gBACgB;AAChB,QAAO;EACL,SAAS;EACT,UAAU,EAAE,gBAAgB;EAC7B;;AAGH,SAAgB,uBAA4C;AAC1D,QAAO,OAAO,wBAAwB;;AAGxC,SAAgB,8BAAsD;AACpE,QAAO,sBAAsB,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -3,10 +3,12 @@ const require_hotkeys_provider = require('./hotkeys-provider.cjs');
|
|
|
3
3
|
const require_injectHotkey = require('./injectHotkey.cjs');
|
|
4
4
|
const require_injectHotkeys = require('./injectHotkeys.cjs');
|
|
5
5
|
const require_injectHotkeySequence = require('./injectHotkeySequence.cjs');
|
|
6
|
+
const require_injectHotkeySequences = require('./injectHotkeySequences.cjs');
|
|
6
7
|
const require_injectHeldKeys = require('./injectHeldKeys.cjs');
|
|
7
8
|
const require_injectHeldKeyCodes = require('./injectHeldKeyCodes.cjs');
|
|
8
9
|
const require_injectKeyHold = require('./injectKeyHold.cjs');
|
|
9
10
|
const require_injectHotkeyRecorder = require('./injectHotkeyRecorder.cjs');
|
|
11
|
+
const require_injectHotkeySequenceRecorder = require('./injectHotkeySequenceRecorder.cjs');
|
|
10
12
|
|
|
11
13
|
exports.HOTKEYS_INJECTION_TOKEN = require_hotkeys_provider.HOTKEYS_INJECTION_TOKEN;
|
|
12
14
|
exports.injectDefaultHotkeysOptions = require_hotkeys_provider.injectDefaultHotkeysOptions;
|
|
@@ -15,6 +17,8 @@ exports.injectHeldKeys = require_injectHeldKeys.injectHeldKeys;
|
|
|
15
17
|
exports.injectHotkey = require_injectHotkey.injectHotkey;
|
|
16
18
|
exports.injectHotkeyRecorder = require_injectHotkeyRecorder.injectHotkeyRecorder;
|
|
17
19
|
exports.injectHotkeySequence = require_injectHotkeySequence.injectHotkeySequence;
|
|
20
|
+
exports.injectHotkeySequenceRecorder = require_injectHotkeySequenceRecorder.injectHotkeySequenceRecorder;
|
|
21
|
+
exports.injectHotkeySequences = require_injectHotkeySequences.injectHotkeySequences;
|
|
18
22
|
exports.injectHotkeys = require_injectHotkeys.injectHotkeys;
|
|
19
23
|
exports.injectHotkeysContext = require_hotkeys_provider.injectHotkeysContext;
|
|
20
24
|
exports.injectKeyHold = require_injectKeyHold.injectKeyHold;
|
package/dist/index.d.cts
CHANGED
|
@@ -2,9 +2,11 @@ import { InjectHotkeyOptions, injectHotkey } from "./injectHotkey.cjs";
|
|
|
2
2
|
import { InjectHotkeySequenceOptions, injectHotkeySequence } from "./injectHotkeySequence.cjs";
|
|
3
3
|
import { HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, injectDefaultHotkeysOptions, injectHotkeysContext, provideHotkeys } from "./hotkeys-provider.cjs";
|
|
4
4
|
import { InjectHotkeyDefinition, injectHotkeys } from "./injectHotkeys.cjs";
|
|
5
|
+
import { InjectHotkeySequenceDefinition, injectHotkeySequences } from "./injectHotkeySequences.cjs";
|
|
5
6
|
import { injectHeldKeys } from "./injectHeldKeys.cjs";
|
|
6
7
|
import { injectHeldKeyCodes } from "./injectHeldKeyCodes.cjs";
|
|
7
8
|
import { injectKeyHold } from "./injectKeyHold.cjs";
|
|
8
9
|
import { AngularHotkeyRecorder, injectHotkeyRecorder } from "./injectHotkeyRecorder.cjs";
|
|
10
|
+
import { AngularHotkeySequenceRecorder, injectHotkeySequenceRecorder } from "./injectHotkeySequenceRecorder.cjs";
|
|
9
11
|
export * from "@tanstack/hotkeys";
|
|
10
|
-
export { AngularHotkeyRecorder, HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, InjectHotkeyDefinition, InjectHotkeyOptions, InjectHotkeySequenceOptions, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyRecorder, injectHotkeySequence, injectHotkeys, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
|
12
|
+
export { AngularHotkeyRecorder, AngularHotkeySequenceRecorder, HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, InjectHotkeyDefinition, InjectHotkeyOptions, InjectHotkeySequenceDefinition, InjectHotkeySequenceOptions, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyRecorder, injectHotkeySequence, injectHotkeySequenceRecorder, injectHotkeySequences, injectHotkeys, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,11 @@ import { InjectHotkeyOptions, injectHotkey } from "./injectHotkey.js";
|
|
|
2
2
|
import { InjectHotkeySequenceOptions, injectHotkeySequence } from "./injectHotkeySequence.js";
|
|
3
3
|
import { HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, injectDefaultHotkeysOptions, injectHotkeysContext, provideHotkeys } from "./hotkeys-provider.js";
|
|
4
4
|
import { InjectHotkeyDefinition, injectHotkeys } from "./injectHotkeys.js";
|
|
5
|
+
import { InjectHotkeySequenceDefinition, injectHotkeySequences } from "./injectHotkeySequences.js";
|
|
5
6
|
import { injectHeldKeys } from "./injectHeldKeys.js";
|
|
6
7
|
import { injectHeldKeyCodes } from "./injectHeldKeyCodes.js";
|
|
7
8
|
import { injectKeyHold } from "./injectKeyHold.js";
|
|
8
9
|
import { AngularHotkeyRecorder, injectHotkeyRecorder } from "./injectHotkeyRecorder.js";
|
|
10
|
+
import { AngularHotkeySequenceRecorder, injectHotkeySequenceRecorder } from "./injectHotkeySequenceRecorder.js";
|
|
9
11
|
export * from "@tanstack/hotkeys";
|
|
10
|
-
export { AngularHotkeyRecorder, HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, InjectHotkeyDefinition, InjectHotkeyOptions, InjectHotkeySequenceOptions, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyRecorder, injectHotkeySequence, injectHotkeys, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
|
12
|
+
export { AngularHotkeyRecorder, AngularHotkeySequenceRecorder, HOTKEYS_INJECTION_TOKEN, HotkeysContextValue, HotkeysProviderOptions, InjectHotkeyDefinition, InjectHotkeyOptions, InjectHotkeySequenceDefinition, InjectHotkeySequenceOptions, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyRecorder, injectHotkeySequence, injectHotkeySequenceRecorder, injectHotkeySequences, injectHotkeys, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,13 @@ import { HOTKEYS_INJECTION_TOKEN, injectDefaultHotkeysOptions, injectHotkeysCont
|
|
|
2
2
|
import { injectHotkey } from "./injectHotkey.js";
|
|
3
3
|
import { injectHotkeys } from "./injectHotkeys.js";
|
|
4
4
|
import { injectHotkeySequence } from "./injectHotkeySequence.js";
|
|
5
|
+
import { injectHotkeySequences } from "./injectHotkeySequences.js";
|
|
5
6
|
import { injectHeldKeys } from "./injectHeldKeys.js";
|
|
6
7
|
import { injectHeldKeyCodes } from "./injectHeldKeyCodes.js";
|
|
7
8
|
import { injectKeyHold } from "./injectKeyHold.js";
|
|
8
9
|
import { injectHotkeyRecorder } from "./injectHotkeyRecorder.js";
|
|
10
|
+
import { injectHotkeySequenceRecorder } from "./injectHotkeySequenceRecorder.js";
|
|
9
11
|
|
|
10
12
|
export * from "@tanstack/hotkeys"
|
|
11
13
|
|
|
12
|
-
export { HOTKEYS_INJECTION_TOKEN, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyRecorder, injectHotkeySequence, injectHotkeys, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
|
14
|
+
export { HOTKEYS_INJECTION_TOKEN, injectDefaultHotkeysOptions, injectHeldKeyCodes, injectHeldKeys, injectHotkey, injectHotkeyRecorder, injectHotkeySequence, injectHotkeySequenceRecorder, injectHotkeySequences, injectHotkeys, injectHotkeysContext, injectKeyHold, provideHotkeys };
|
package/dist/injectHotkey.cjs
CHANGED
|
@@ -13,6 +13,8 @@ let _angular_core = require("@angular/core");
|
|
|
13
13
|
* Call in an injection context (e.g. constructor or field initializer).
|
|
14
14
|
* Uses effect() to track reactive dependencies and update registration
|
|
15
15
|
* when options or the callback change.
|
|
16
|
+
* `enabled: false` keeps the registration (visible in devtools) and only suppresses firing; the same
|
|
17
|
+
* handle is updated instead of unregistering and re-registering when identity is unchanged.
|
|
16
18
|
*
|
|
17
19
|
* @param hotkey - The hotkey string (e.g. 'Mod+S', 'Escape') or getter function
|
|
18
20
|
* @param callback - The function to call when the hotkey is pressed
|
|
@@ -62,7 +64,19 @@ let _angular_core = require("@angular/core");
|
|
|
62
64
|
function injectHotkey(hotkey, callback, options = {}) {
|
|
63
65
|
const defaultOptions = require_hotkeys_provider.injectDefaultHotkeysOptions();
|
|
64
66
|
const manager = (0, _tanstack_hotkeys.getHotkeyManager)();
|
|
65
|
-
(0, _angular_core.
|
|
67
|
+
const destroyRef = (0, _angular_core.inject)(_angular_core.DestroyRef);
|
|
68
|
+
let registration = null;
|
|
69
|
+
let lastHotkeyString = null;
|
|
70
|
+
let lastTarget = null;
|
|
71
|
+
destroyRef.onDestroy(() => {
|
|
72
|
+
if (registration?.isActive) {
|
|
73
|
+
registration.unregister();
|
|
74
|
+
registration = null;
|
|
75
|
+
}
|
|
76
|
+
lastHotkeyString = null;
|
|
77
|
+
lastTarget = null;
|
|
78
|
+
});
|
|
79
|
+
(0, _angular_core.effect)(() => {
|
|
66
80
|
const resolvedHotkey = typeof hotkey === "function" ? hotkey() : hotkey;
|
|
67
81
|
const resolvedOptions = typeof options === "function" ? options() : options;
|
|
68
82
|
const mergedOptions = {
|
|
@@ -72,9 +86,26 @@ function injectHotkey(hotkey, callback, options = {}) {
|
|
|
72
86
|
const platform = mergedOptions.platform ?? (0, _tanstack_hotkeys.detectPlatform)();
|
|
73
87
|
const hotkeyString = typeof resolvedHotkey === "string" ? resolvedHotkey : (0, _tanstack_hotkeys.formatHotkey)((0, _tanstack_hotkeys.rawHotkeyToParsedHotkey)(resolvedHotkey, platform));
|
|
74
88
|
const resolvedTarget = "target" in mergedOptions ? mergedOptions.target ?? null : typeof document !== "undefined" ? document : null;
|
|
75
|
-
if (!resolvedTarget)
|
|
89
|
+
if (!resolvedTarget) {
|
|
90
|
+
if (registration?.isActive) {
|
|
91
|
+
registration.unregister();
|
|
92
|
+
registration = null;
|
|
93
|
+
}
|
|
94
|
+
lastHotkeyString = null;
|
|
95
|
+
lastTarget = null;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
76
98
|
const { target: _target, ...optionsWithoutTarget } = mergedOptions;
|
|
77
|
-
|
|
99
|
+
if (registration?.isActive && lastHotkeyString === hotkeyString && lastTarget === resolvedTarget) {
|
|
100
|
+
registration.callback = callback;
|
|
101
|
+
registration.setOptions(optionsWithoutTarget);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (registration?.isActive) {
|
|
105
|
+
registration.unregister();
|
|
106
|
+
registration = null;
|
|
107
|
+
}
|
|
108
|
+
registration = manager.register(hotkeyString, callback, {
|
|
78
109
|
...optionsWithoutTarget,
|
|
79
110
|
target: resolvedTarget
|
|
80
111
|
});
|
|
@@ -82,9 +113,8 @@ function injectHotkey(hotkey, callback, options = {}) {
|
|
|
82
113
|
registration.callback = callback;
|
|
83
114
|
registration.setOptions(optionsWithoutTarget);
|
|
84
115
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
116
|
+
lastHotkeyString = hotkeyString;
|
|
117
|
+
lastTarget = resolvedTarget;
|
|
88
118
|
});
|
|
89
119
|
}
|
|
90
120
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectHotkey.cjs","names":["injectDefaultHotkeysOptions"],"sources":["../src/injectHotkey.ts"],"sourcesContent":["import { effect } from '@angular/core'\nimport {\n detectPlatform,\n formatHotkey,\n getHotkeyManager,\n rawHotkeyToParsedHotkey,\n} from '@tanstack/hotkeys'\nimport { injectDefaultHotkeysOptions } from './hotkeys-provider'\nimport type {\n Hotkey,\n HotkeyCallback,\n HotkeyOptions,\n RegisterableHotkey,\n} from '@tanstack/hotkeys'\n\nexport interface InjectHotkeyOptions extends Omit<HotkeyOptions, 'target'> {\n /**\n * The DOM element to attach the event listener to.\n * Can be a direct DOM element, an accessor (for reactive targets that become\n * available after mount), or null. Defaults to document.\n * When using scoped targets, pass an accessor: () => ({ target: elementSignal() })\n * so the hotkey waits for the element to be attached before registering.\n */\n target?: HTMLElement | Document | Window | null\n}\n\n/**\n * Angular inject-based API for registering a keyboard hotkey.\n *\n * Uses the singleton HotkeyManager for efficient event handling.\n * The callback receives both the keyboard event and a context object\n * containing the hotkey string and parsed hotkey.\n *\n * Call in an injection context (e.g. constructor or field initializer).\n * Uses effect() to track reactive dependencies and update registration\n * when options or the callback change.\n *\n * @param hotkey - The hotkey string (e.g. 'Mod+S', 'Escape') or getter function\n * @param callback - The function to call when the hotkey is pressed\n * @param options - Options for the hotkey behavior, or getter for reactive options\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class SaveButtonComponent {\n * private readonly saveCount = signal(0)\n *\n * constructor() {\n * injectHotkey('Mod+S', (event, { hotkey }) => {\n * event.preventDefault()\n * this.saveCount.update(c => c + 1)\n * })\n * }\n * }\n * ```\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class ModalComponent {\n * isOpen = signal(true)\n *\n * constructor() {\n * injectHotkey('Escape', () => this.close(), () => ({ enabled: this.isOpen() }))\n * }\n * }\n * ```\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class EditorComponent {\n * private readonly editorRef = viewChild<ElementRef<HTMLDivElement>>('editorRef')\n *\n * constructor() {\n * injectHotkey('Mod+B', () => this.toggleBold(), () => ({\n * target: this.editorRef()?.nativeElement ?? null,\n * }))\n * }\n * }\n * ```\n */\nexport function injectHotkey(\n hotkey: RegisterableHotkey | (() => RegisterableHotkey),\n callback: HotkeyCallback,\n options: InjectHotkeyOptions | (() => InjectHotkeyOptions) = {},\n): void {\n const defaultOptions = injectDefaultHotkeysOptions()\n const manager = getHotkeyManager()\n\n effect((
|
|
1
|
+
{"version":3,"file":"injectHotkey.cjs","names":["injectDefaultHotkeysOptions","DestroyRef"],"sources":["../src/injectHotkey.ts"],"sourcesContent":["import { DestroyRef, effect, inject } from '@angular/core'\nimport {\n detectPlatform,\n formatHotkey,\n getHotkeyManager,\n rawHotkeyToParsedHotkey,\n} from '@tanstack/hotkeys'\nimport { injectDefaultHotkeysOptions } from './hotkeys-provider'\nimport type {\n Hotkey,\n HotkeyCallback,\n HotkeyOptions,\n HotkeyRegistrationHandle,\n RegisterableHotkey,\n} from '@tanstack/hotkeys'\n\nexport interface InjectHotkeyOptions extends Omit<HotkeyOptions, 'target'> {\n /**\n * The DOM element to attach the event listener to.\n * Can be a direct DOM element, an accessor (for reactive targets that become\n * available after mount), or null. Defaults to document.\n * When using scoped targets, pass an accessor: () => ({ target: elementSignal() })\n * so the hotkey waits for the element to be attached before registering.\n */\n target?: HTMLElement | Document | Window | null\n}\n\n/**\n * Angular inject-based API for registering a keyboard hotkey.\n *\n * Uses the singleton HotkeyManager for efficient event handling.\n * The callback receives both the keyboard event and a context object\n * containing the hotkey string and parsed hotkey.\n *\n * Call in an injection context (e.g. constructor or field initializer).\n * Uses effect() to track reactive dependencies and update registration\n * when options or the callback change.\n * `enabled: false` keeps the registration (visible in devtools) and only suppresses firing; the same\n * handle is updated instead of unregistering and re-registering when identity is unchanged.\n *\n * @param hotkey - The hotkey string (e.g. 'Mod+S', 'Escape') or getter function\n * @param callback - The function to call when the hotkey is pressed\n * @param options - Options for the hotkey behavior, or getter for reactive options\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class SaveButtonComponent {\n * private readonly saveCount = signal(0)\n *\n * constructor() {\n * injectHotkey('Mod+S', (event, { hotkey }) => {\n * event.preventDefault()\n * this.saveCount.update(c => c + 1)\n * })\n * }\n * }\n * ```\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class ModalComponent {\n * isOpen = signal(true)\n *\n * constructor() {\n * injectHotkey('Escape', () => this.close(), () => ({ enabled: this.isOpen() }))\n * }\n * }\n * ```\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class EditorComponent {\n * private readonly editorRef = viewChild<ElementRef<HTMLDivElement>>('editorRef')\n *\n * constructor() {\n * injectHotkey('Mod+B', () => this.toggleBold(), () => ({\n * target: this.editorRef()?.nativeElement ?? null,\n * }))\n * }\n * }\n * ```\n */\nexport function injectHotkey(\n hotkey: RegisterableHotkey | (() => RegisterableHotkey),\n callback: HotkeyCallback,\n options: InjectHotkeyOptions | (() => InjectHotkeyOptions) = {},\n): void {\n const defaultOptions = injectDefaultHotkeysOptions()\n const manager = getHotkeyManager()\n const destroyRef = inject(DestroyRef)\n\n let registration: HotkeyRegistrationHandle | null = null\n let lastHotkeyString: Hotkey | null = null\n let lastTarget: HTMLElement | Document | Window | null = null\n\n destroyRef.onDestroy(() => {\n if (registration?.isActive) {\n registration.unregister()\n registration = null\n }\n lastHotkeyString = null\n lastTarget = null\n })\n\n effect(() => {\n // Resolve reactive values\n const resolvedHotkey = typeof hotkey === 'function' ? hotkey() : hotkey\n const resolvedOptions = typeof options === 'function' ? options() : options\n\n const mergedOptions = {\n ...defaultOptions.hotkey,\n ...resolvedOptions,\n } as InjectHotkeyOptions\n\n // Normalize to hotkey string\n const platform = mergedOptions.platform ?? detectPlatform()\n const hotkeyString: Hotkey =\n typeof resolvedHotkey === 'string'\n ? resolvedHotkey\n : (formatHotkey(\n rawHotkeyToParsedHotkey(resolvedHotkey, platform),\n ) as Hotkey)\n\n // Resolve target: when explicitly provided (even as null), use it and skip if null.\n // When not provided, default to document. Matches React's ref handling.\n const resolvedTarget =\n 'target' in mergedOptions\n ? (mergedOptions.target ?? null)\n : typeof document !== 'undefined'\n ? document\n : null\n\n if (!resolvedTarget) {\n if (registration?.isActive) {\n registration.unregister()\n registration = null\n }\n lastHotkeyString = null\n lastTarget = null\n return\n }\n\n // Extract options without target (target is handled separately)\n const { target: _target, ...optionsWithoutTarget } = mergedOptions\n\n if (\n registration?.isActive &&\n lastHotkeyString === hotkeyString &&\n lastTarget === resolvedTarget\n ) {\n registration.callback = callback\n registration.setOptions(optionsWithoutTarget)\n return\n }\n\n if (registration?.isActive) {\n registration.unregister()\n registration = null\n }\n\n registration = manager.register(hotkeyString, callback, {\n ...optionsWithoutTarget,\n target: resolvedTarget,\n })\n\n if (registration.isActive) {\n registration.callback = callback\n registration.setOptions(optionsWithoutTarget)\n }\n\n lastHotkeyString = hotkeyString\n lastTarget = resolvedTarget\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,SAAgB,aACd,QACA,UACA,UAA6D,EAAE,EACzD;CACN,MAAM,iBAAiBA,sDAA6B;CACpD,MAAM,mDAA4B;CAClC,MAAM,uCAAoBC,yBAAW;CAErC,IAAI,eAAgD;CACpD,IAAI,mBAAkC;CACtC,IAAI,aAAqD;AAEzD,YAAW,gBAAgB;AACzB,MAAI,cAAc,UAAU;AAC1B,gBAAa,YAAY;AACzB,kBAAe;;AAEjB,qBAAmB;AACnB,eAAa;GACb;AAEF,iCAAa;EAEX,MAAM,iBAAiB,OAAO,WAAW,aAAa,QAAQ,GAAG;EACjE,MAAM,kBAAkB,OAAO,YAAY,aAAa,SAAS,GAAG;EAEpE,MAAM,gBAAgB;GACpB,GAAG,eAAe;GAClB,GAAG;GACJ;EAGD,MAAM,WAAW,cAAc,mDAA4B;EAC3D,MAAM,eACJ,OAAO,mBAAmB,WACtB,oGAE0B,gBAAgB,SAAS,CAClD;EAIP,MAAM,iBACJ,YAAY,gBACP,cAAc,UAAU,OACzB,OAAO,aAAa,cAClB,WACA;AAER,MAAI,CAAC,gBAAgB;AACnB,OAAI,cAAc,UAAU;AAC1B,iBAAa,YAAY;AACzB,mBAAe;;AAEjB,sBAAmB;AACnB,gBAAa;AACb;;EAIF,MAAM,EAAE,QAAQ,SAAS,GAAG,yBAAyB;AAErD,MACE,cAAc,YACd,qBAAqB,gBACrB,eAAe,gBACf;AACA,gBAAa,WAAW;AACxB,gBAAa,WAAW,qBAAqB;AAC7C;;AAGF,MAAI,cAAc,UAAU;AAC1B,gBAAa,YAAY;AACzB,kBAAe;;AAGjB,iBAAe,QAAQ,SAAS,cAAc,UAAU;GACtD,GAAG;GACH,QAAQ;GACT,CAAC;AAEF,MAAI,aAAa,UAAU;AACzB,gBAAa,WAAW;AACxB,gBAAa,WAAW,qBAAqB;;AAG/C,qBAAmB;AACnB,eAAa;GACb"}
|
package/dist/injectHotkey.d.cts
CHANGED
|
@@ -21,6 +21,8 @@ interface InjectHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
|
|
|
21
21
|
* Call in an injection context (e.g. constructor or field initializer).
|
|
22
22
|
* Uses effect() to track reactive dependencies and update registration
|
|
23
23
|
* when options or the callback change.
|
|
24
|
+
* `enabled: false` keeps the registration (visible in devtools) and only suppresses firing; the same
|
|
25
|
+
* handle is updated instead of unregistering and re-registering when identity is unchanged.
|
|
24
26
|
*
|
|
25
27
|
* @param hotkey - The hotkey string (e.g. 'Mod+S', 'Escape') or getter function
|
|
26
28
|
* @param callback - The function to call when the hotkey is pressed
|
package/dist/injectHotkey.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ interface InjectHotkeyOptions extends Omit<HotkeyOptions, 'target'> {
|
|
|
21
21
|
* Call in an injection context (e.g. constructor or field initializer).
|
|
22
22
|
* Uses effect() to track reactive dependencies and update registration
|
|
23
23
|
* when options or the callback change.
|
|
24
|
+
* `enabled: false` keeps the registration (visible in devtools) and only suppresses firing; the same
|
|
25
|
+
* handle is updated instead of unregistering and re-registering when identity is unchanged.
|
|
24
26
|
*
|
|
25
27
|
* @param hotkey - The hotkey string (e.g. 'Mod+S', 'Escape') or getter function
|
|
26
28
|
* @param callback - The function to call when the hotkey is pressed
|
package/dist/injectHotkey.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { injectDefaultHotkeysOptions } from "./hotkeys-provider.js";
|
|
2
2
|
import { detectPlatform, formatHotkey, getHotkeyManager, rawHotkeyToParsedHotkey } from "@tanstack/hotkeys";
|
|
3
|
-
import { effect } from "@angular/core";
|
|
3
|
+
import { DestroyRef, effect, inject } from "@angular/core";
|
|
4
4
|
|
|
5
5
|
//#region src/injectHotkey.ts
|
|
6
6
|
/**
|
|
@@ -13,6 +13,8 @@ import { effect } from "@angular/core";
|
|
|
13
13
|
* Call in an injection context (e.g. constructor or field initializer).
|
|
14
14
|
* Uses effect() to track reactive dependencies and update registration
|
|
15
15
|
* when options or the callback change.
|
|
16
|
+
* `enabled: false` keeps the registration (visible in devtools) and only suppresses firing; the same
|
|
17
|
+
* handle is updated instead of unregistering and re-registering when identity is unchanged.
|
|
16
18
|
*
|
|
17
19
|
* @param hotkey - The hotkey string (e.g. 'Mod+S', 'Escape') or getter function
|
|
18
20
|
* @param callback - The function to call when the hotkey is pressed
|
|
@@ -62,7 +64,19 @@ import { effect } from "@angular/core";
|
|
|
62
64
|
function injectHotkey(hotkey, callback, options = {}) {
|
|
63
65
|
const defaultOptions = injectDefaultHotkeysOptions();
|
|
64
66
|
const manager = getHotkeyManager();
|
|
65
|
-
|
|
67
|
+
const destroyRef = inject(DestroyRef);
|
|
68
|
+
let registration = null;
|
|
69
|
+
let lastHotkeyString = null;
|
|
70
|
+
let lastTarget = null;
|
|
71
|
+
destroyRef.onDestroy(() => {
|
|
72
|
+
if (registration?.isActive) {
|
|
73
|
+
registration.unregister();
|
|
74
|
+
registration = null;
|
|
75
|
+
}
|
|
76
|
+
lastHotkeyString = null;
|
|
77
|
+
lastTarget = null;
|
|
78
|
+
});
|
|
79
|
+
effect(() => {
|
|
66
80
|
const resolvedHotkey = typeof hotkey === "function" ? hotkey() : hotkey;
|
|
67
81
|
const resolvedOptions = typeof options === "function" ? options() : options;
|
|
68
82
|
const mergedOptions = {
|
|
@@ -72,9 +86,26 @@ function injectHotkey(hotkey, callback, options = {}) {
|
|
|
72
86
|
const platform = mergedOptions.platform ?? detectPlatform();
|
|
73
87
|
const hotkeyString = typeof resolvedHotkey === "string" ? resolvedHotkey : formatHotkey(rawHotkeyToParsedHotkey(resolvedHotkey, platform));
|
|
74
88
|
const resolvedTarget = "target" in mergedOptions ? mergedOptions.target ?? null : typeof document !== "undefined" ? document : null;
|
|
75
|
-
if (!resolvedTarget)
|
|
89
|
+
if (!resolvedTarget) {
|
|
90
|
+
if (registration?.isActive) {
|
|
91
|
+
registration.unregister();
|
|
92
|
+
registration = null;
|
|
93
|
+
}
|
|
94
|
+
lastHotkeyString = null;
|
|
95
|
+
lastTarget = null;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
76
98
|
const { target: _target, ...optionsWithoutTarget } = mergedOptions;
|
|
77
|
-
|
|
99
|
+
if (registration?.isActive && lastHotkeyString === hotkeyString && lastTarget === resolvedTarget) {
|
|
100
|
+
registration.callback = callback;
|
|
101
|
+
registration.setOptions(optionsWithoutTarget);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (registration?.isActive) {
|
|
105
|
+
registration.unregister();
|
|
106
|
+
registration = null;
|
|
107
|
+
}
|
|
108
|
+
registration = manager.register(hotkeyString, callback, {
|
|
78
109
|
...optionsWithoutTarget,
|
|
79
110
|
target: resolvedTarget
|
|
80
111
|
});
|
|
@@ -82,9 +113,8 @@ function injectHotkey(hotkey, callback, options = {}) {
|
|
|
82
113
|
registration.callback = callback;
|
|
83
114
|
registration.setOptions(optionsWithoutTarget);
|
|
84
115
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
116
|
+
lastHotkeyString = hotkeyString;
|
|
117
|
+
lastTarget = resolvedTarget;
|
|
88
118
|
});
|
|
89
119
|
}
|
|
90
120
|
|
package/dist/injectHotkey.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectHotkey.js","names":[],"sources":["../src/injectHotkey.ts"],"sourcesContent":["import { effect } from '@angular/core'\nimport {\n detectPlatform,\n formatHotkey,\n getHotkeyManager,\n rawHotkeyToParsedHotkey,\n} from '@tanstack/hotkeys'\nimport { injectDefaultHotkeysOptions } from './hotkeys-provider'\nimport type {\n Hotkey,\n HotkeyCallback,\n HotkeyOptions,\n RegisterableHotkey,\n} from '@tanstack/hotkeys'\n\nexport interface InjectHotkeyOptions extends Omit<HotkeyOptions, 'target'> {\n /**\n * The DOM element to attach the event listener to.\n * Can be a direct DOM element, an accessor (for reactive targets that become\n * available after mount), or null. Defaults to document.\n * When using scoped targets, pass an accessor: () => ({ target: elementSignal() })\n * so the hotkey waits for the element to be attached before registering.\n */\n target?: HTMLElement | Document | Window | null\n}\n\n/**\n * Angular inject-based API for registering a keyboard hotkey.\n *\n * Uses the singleton HotkeyManager for efficient event handling.\n * The callback receives both the keyboard event and a context object\n * containing the hotkey string and parsed hotkey.\n *\n * Call in an injection context (e.g. constructor or field initializer).\n * Uses effect() to track reactive dependencies and update registration\n * when options or the callback change.\n *\n * @param hotkey - The hotkey string (e.g. 'Mod+S', 'Escape') or getter function\n * @param callback - The function to call when the hotkey is pressed\n * @param options - Options for the hotkey behavior, or getter for reactive options\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class SaveButtonComponent {\n * private readonly saveCount = signal(0)\n *\n * constructor() {\n * injectHotkey('Mod+S', (event, { hotkey }) => {\n * event.preventDefault()\n * this.saveCount.update(c => c + 1)\n * })\n * }\n * }\n * ```\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class ModalComponent {\n * isOpen = signal(true)\n *\n * constructor() {\n * injectHotkey('Escape', () => this.close(), () => ({ enabled: this.isOpen() }))\n * }\n * }\n * ```\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class EditorComponent {\n * private readonly editorRef = viewChild<ElementRef<HTMLDivElement>>('editorRef')\n *\n * constructor() {\n * injectHotkey('Mod+B', () => this.toggleBold(), () => ({\n * target: this.editorRef()?.nativeElement ?? null,\n * }))\n * }\n * }\n * ```\n */\nexport function injectHotkey(\n hotkey: RegisterableHotkey | (() => RegisterableHotkey),\n callback: HotkeyCallback,\n options: InjectHotkeyOptions | (() => InjectHotkeyOptions) = {},\n): void {\n const defaultOptions = injectDefaultHotkeysOptions()\n const manager = getHotkeyManager()\n\n effect((
|
|
1
|
+
{"version":3,"file":"injectHotkey.js","names":[],"sources":["../src/injectHotkey.ts"],"sourcesContent":["import { DestroyRef, effect, inject } from '@angular/core'\nimport {\n detectPlatform,\n formatHotkey,\n getHotkeyManager,\n rawHotkeyToParsedHotkey,\n} from '@tanstack/hotkeys'\nimport { injectDefaultHotkeysOptions } from './hotkeys-provider'\nimport type {\n Hotkey,\n HotkeyCallback,\n HotkeyOptions,\n HotkeyRegistrationHandle,\n RegisterableHotkey,\n} from '@tanstack/hotkeys'\n\nexport interface InjectHotkeyOptions extends Omit<HotkeyOptions, 'target'> {\n /**\n * The DOM element to attach the event listener to.\n * Can be a direct DOM element, an accessor (for reactive targets that become\n * available after mount), or null. Defaults to document.\n * When using scoped targets, pass an accessor: () => ({ target: elementSignal() })\n * so the hotkey waits for the element to be attached before registering.\n */\n target?: HTMLElement | Document | Window | null\n}\n\n/**\n * Angular inject-based API for registering a keyboard hotkey.\n *\n * Uses the singleton HotkeyManager for efficient event handling.\n * The callback receives both the keyboard event and a context object\n * containing the hotkey string and parsed hotkey.\n *\n * Call in an injection context (e.g. constructor or field initializer).\n * Uses effect() to track reactive dependencies and update registration\n * when options or the callback change.\n * `enabled: false` keeps the registration (visible in devtools) and only suppresses firing; the same\n * handle is updated instead of unregistering and re-registering when identity is unchanged.\n *\n * @param hotkey - The hotkey string (e.g. 'Mod+S', 'Escape') or getter function\n * @param callback - The function to call when the hotkey is pressed\n * @param options - Options for the hotkey behavior, or getter for reactive options\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class SaveButtonComponent {\n * private readonly saveCount = signal(0)\n *\n * constructor() {\n * injectHotkey('Mod+S', (event, { hotkey }) => {\n * event.preventDefault()\n * this.saveCount.update(c => c + 1)\n * })\n * }\n * }\n * ```\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class ModalComponent {\n * isOpen = signal(true)\n *\n * constructor() {\n * injectHotkey('Escape', () => this.close(), () => ({ enabled: this.isOpen() }))\n * }\n * }\n * ```\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class EditorComponent {\n * private readonly editorRef = viewChild<ElementRef<HTMLDivElement>>('editorRef')\n *\n * constructor() {\n * injectHotkey('Mod+B', () => this.toggleBold(), () => ({\n * target: this.editorRef()?.nativeElement ?? null,\n * }))\n * }\n * }\n * ```\n */\nexport function injectHotkey(\n hotkey: RegisterableHotkey | (() => RegisterableHotkey),\n callback: HotkeyCallback,\n options: InjectHotkeyOptions | (() => InjectHotkeyOptions) = {},\n): void {\n const defaultOptions = injectDefaultHotkeysOptions()\n const manager = getHotkeyManager()\n const destroyRef = inject(DestroyRef)\n\n let registration: HotkeyRegistrationHandle | null = null\n let lastHotkeyString: Hotkey | null = null\n let lastTarget: HTMLElement | Document | Window | null = null\n\n destroyRef.onDestroy(() => {\n if (registration?.isActive) {\n registration.unregister()\n registration = null\n }\n lastHotkeyString = null\n lastTarget = null\n })\n\n effect(() => {\n // Resolve reactive values\n const resolvedHotkey = typeof hotkey === 'function' ? hotkey() : hotkey\n const resolvedOptions = typeof options === 'function' ? options() : options\n\n const mergedOptions = {\n ...defaultOptions.hotkey,\n ...resolvedOptions,\n } as InjectHotkeyOptions\n\n // Normalize to hotkey string\n const platform = mergedOptions.platform ?? detectPlatform()\n const hotkeyString: Hotkey =\n typeof resolvedHotkey === 'string'\n ? resolvedHotkey\n : (formatHotkey(\n rawHotkeyToParsedHotkey(resolvedHotkey, platform),\n ) as Hotkey)\n\n // Resolve target: when explicitly provided (even as null), use it and skip if null.\n // When not provided, default to document. Matches React's ref handling.\n const resolvedTarget =\n 'target' in mergedOptions\n ? (mergedOptions.target ?? null)\n : typeof document !== 'undefined'\n ? document\n : null\n\n if (!resolvedTarget) {\n if (registration?.isActive) {\n registration.unregister()\n registration = null\n }\n lastHotkeyString = null\n lastTarget = null\n return\n }\n\n // Extract options without target (target is handled separately)\n const { target: _target, ...optionsWithoutTarget } = mergedOptions\n\n if (\n registration?.isActive &&\n lastHotkeyString === hotkeyString &&\n lastTarget === resolvedTarget\n ) {\n registration.callback = callback\n registration.setOptions(optionsWithoutTarget)\n return\n }\n\n if (registration?.isActive) {\n registration.unregister()\n registration = null\n }\n\n registration = manager.register(hotkeyString, callback, {\n ...optionsWithoutTarget,\n target: resolvedTarget,\n })\n\n if (registration.isActive) {\n registration.callback = callback\n registration.setOptions(optionsWithoutTarget)\n }\n\n lastHotkeyString = hotkeyString\n lastTarget = resolvedTarget\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,SAAgB,aACd,QACA,UACA,UAA6D,EAAE,EACzD;CACN,MAAM,iBAAiB,6BAA6B;CACpD,MAAM,UAAU,kBAAkB;CAClC,MAAM,aAAa,OAAO,WAAW;CAErC,IAAI,eAAgD;CACpD,IAAI,mBAAkC;CACtC,IAAI,aAAqD;AAEzD,YAAW,gBAAgB;AACzB,MAAI,cAAc,UAAU;AAC1B,gBAAa,YAAY;AACzB,kBAAe;;AAEjB,qBAAmB;AACnB,eAAa;GACb;AAEF,cAAa;EAEX,MAAM,iBAAiB,OAAO,WAAW,aAAa,QAAQ,GAAG;EACjE,MAAM,kBAAkB,OAAO,YAAY,aAAa,SAAS,GAAG;EAEpE,MAAM,gBAAgB;GACpB,GAAG,eAAe;GAClB,GAAG;GACJ;EAGD,MAAM,WAAW,cAAc,YAAY,gBAAgB;EAC3D,MAAM,eACJ,OAAO,mBAAmB,WACtB,iBACC,aACC,wBAAwB,gBAAgB,SAAS,CAClD;EAIP,MAAM,iBACJ,YAAY,gBACP,cAAc,UAAU,OACzB,OAAO,aAAa,cAClB,WACA;AAER,MAAI,CAAC,gBAAgB;AACnB,OAAI,cAAc,UAAU;AAC1B,iBAAa,YAAY;AACzB,mBAAe;;AAEjB,sBAAmB;AACnB,gBAAa;AACb;;EAIF,MAAM,EAAE,QAAQ,SAAS,GAAG,yBAAyB;AAErD,MACE,cAAc,YACd,qBAAqB,gBACrB,eAAe,gBACf;AACA,gBAAa,WAAW;AACxB,gBAAa,WAAW,qBAAqB;AAC7C;;AAGF,MAAI,cAAc,UAAU;AAC1B,gBAAa,YAAY;AACzB,kBAAe;;AAGjB,iBAAe,QAAQ,SAAS,cAAc,UAAU;GACtD,GAAG;GACH,QAAQ;GACT,CAAC;AAEF,MAAI,aAAa,UAAU;AACzB,gBAAa,WAAW;AACxB,gBAAa,WAAW,qBAAqB;;AAG/C,qBAAmB;AACnB,eAAa;GACb"}
|
|
@@ -16,7 +16,8 @@ let _angular_core = require("@angular/core");
|
|
|
16
16
|
*
|
|
17
17
|
* @param sequence - Array of hotkey strings that form the sequence (or getter function)
|
|
18
18
|
* @param callback - Function to call when the sequence is completed
|
|
19
|
-
* @param options - Options for the sequence behavior (or getter function)
|
|
19
|
+
* @param options - Options for the sequence behavior (or getter function). `enabled: false` still registers
|
|
20
|
+
* the sequence (visible in devtools); only execution is suppressed.
|
|
20
21
|
*
|
|
21
22
|
* @example
|
|
22
23
|
* ```ts
|
|
@@ -35,24 +36,55 @@ let _angular_core = require("@angular/core");
|
|
|
35
36
|
*/
|
|
36
37
|
function injectHotkeySequence(sequence, callback, options = {}) {
|
|
37
38
|
const defaultOptions = require_hotkeys_provider.injectDefaultHotkeysOptions();
|
|
38
|
-
(0,
|
|
39
|
+
const manager = (0, _tanstack_hotkeys.getSequenceManager)();
|
|
40
|
+
const destroyRef = (0, _angular_core.inject)(_angular_core.DestroyRef);
|
|
41
|
+
let handle = null;
|
|
42
|
+
let lastSequenceKey = null;
|
|
43
|
+
let lastTarget = null;
|
|
44
|
+
destroyRef.onDestroy(() => {
|
|
45
|
+
if (handle?.isActive) {
|
|
46
|
+
handle.unregister();
|
|
47
|
+
handle = null;
|
|
48
|
+
}
|
|
49
|
+
lastSequenceKey = null;
|
|
50
|
+
lastTarget = null;
|
|
51
|
+
});
|
|
52
|
+
(0, _angular_core.effect)(() => {
|
|
39
53
|
const resolvedSequence = typeof sequence === "function" ? sequence() : sequence;
|
|
40
54
|
const resolvedOptions = typeof options === "function" ? options() : options;
|
|
41
55
|
const { enabled = true, ...sequenceOptions } = {
|
|
42
56
|
...defaultOptions.hotkeySequence,
|
|
43
57
|
...resolvedOptions
|
|
44
58
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
59
|
+
const resolvedTarget = "target" in sequenceOptions ? sequenceOptions.target ?? null : typeof document !== "undefined" ? document : null;
|
|
60
|
+
if (resolvedSequence.length === 0 || !resolvedTarget) {
|
|
61
|
+
if (handle?.isActive) {
|
|
62
|
+
handle.unregister();
|
|
63
|
+
handle = null;
|
|
64
|
+
}
|
|
65
|
+
lastSequenceKey = null;
|
|
66
|
+
lastTarget = null;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const sequenceKey = (0, _tanstack_hotkeys.formatHotkeySequence)(resolvedSequence);
|
|
70
|
+
const registerPayload = {
|
|
48
71
|
...sequenceOptions,
|
|
49
|
-
enabled
|
|
50
|
-
target:
|
|
72
|
+
enabled,
|
|
73
|
+
target: resolvedTarget
|
|
51
74
|
};
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
75
|
+
const { target: _t, ...optionsWithoutTarget } = registerPayload;
|
|
76
|
+
if (handle?.isActive && lastSequenceKey === sequenceKey && lastTarget === resolvedTarget) {
|
|
77
|
+
handle.callback = callback;
|
|
78
|
+
handle.setOptions(optionsWithoutTarget);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (handle?.isActive) {
|
|
82
|
+
handle.unregister();
|
|
83
|
+
handle = null;
|
|
84
|
+
}
|
|
85
|
+
handle = manager.register(resolvedSequence, callback, registerPayload);
|
|
86
|
+
lastSequenceKey = sequenceKey;
|
|
87
|
+
lastTarget = resolvedTarget;
|
|
56
88
|
});
|
|
57
89
|
}
|
|
58
90
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectHotkeySequence.cjs","names":["injectDefaultHotkeysOptions"],"sources":["../src/injectHotkeySequence.ts"],"sourcesContent":["import { effect } from '@angular/core'\nimport { getSequenceManager } from '@tanstack/hotkeys'\nimport { injectDefaultHotkeysOptions } from './hotkeys-provider'\nimport type {\n HotkeyCallback,\n HotkeySequence,\n SequenceOptions,\n} from '@tanstack/hotkeys'\n\nexport interface InjectHotkeySequenceOptions extends Omit<\n SequenceOptions,\n 'enabled'\n> {\n /** Whether the sequence is enabled. Defaults to true. */\n enabled?: boolean\n}\n\n/**\n * Angular inject-based API for registering a keyboard shortcut sequence (Vim-style).\n *\n * Allows you to register multi-key sequences like 'g g' or 'd d' that trigger\n * when the full sequence is pressed within a timeout.\n *\n * Each step may include modifiers. You can chain the same modifier across\n * steps (e.g. `Shift+R` then `Shift+T`). Modifier-only keydown events (Shift,\n * Control, Alt, or Meta pressed alone) are ignored while matching—they do not\n * advance the sequence or reset progress.\n *\n * @param sequence - Array of hotkey strings that form the sequence (or getter function)\n * @param callback - Function to call when the sequence is completed\n * @param options - Options for the sequence behavior (or getter function)\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class VimEditorComponent {\n * lastSequence = signal<string | null>(null)\n *\n * constructor() {\n * injectHotkeySequence(['G', 'G'], () => this.lastSequence.set('gg → Go to top'))\n * injectHotkeySequence(['D', 'D'], () => this.lastSequence.set('dd → Delete line'))\n * injectHotkeySequence(['C', 'I', 'W'], () => this.lastSequence.set('ciw'), { timeout: 500 })\n * injectHotkeySequence(['Shift+R', 'Shift+T'], () => this.lastSequence.set('⇧R⇧T'))\n * }\n * }\n * ```\n */\nexport function injectHotkeySequence(\n sequence: HotkeySequence | (() => HotkeySequence),\n callback: HotkeyCallback,\n options:\n | InjectHotkeySequenceOptions\n | (() => InjectHotkeySequenceOptions) = {},\n): void {\n const defaultOptions = injectDefaultHotkeysOptions()\n\n effect((
|
|
1
|
+
{"version":3,"file":"injectHotkeySequence.cjs","names":["injectDefaultHotkeysOptions","DestroyRef"],"sources":["../src/injectHotkeySequence.ts"],"sourcesContent":["import { DestroyRef, effect, inject } from '@angular/core'\nimport { formatHotkeySequence, getSequenceManager } from '@tanstack/hotkeys'\nimport { injectDefaultHotkeysOptions } from './hotkeys-provider'\nimport type {\n HotkeyCallback,\n HotkeySequence,\n SequenceOptions,\n SequenceRegistrationHandle,\n} from '@tanstack/hotkeys'\n\ntype SequenceTarget = Document | HTMLElement | Window\n\nexport interface InjectHotkeySequenceOptions extends Omit<\n SequenceOptions,\n 'enabled' | 'target'\n> {\n /** Whether the sequence is enabled. Defaults to true. */\n enabled?: boolean\n /**\n * The DOM element to attach the event listener to.\n * Can be a direct DOM element, an accessor target, or null.\n * Defaults to document when omitted.\n */\n target?: HTMLElement | Document | Window | null\n}\n\n/**\n * Angular inject-based API for registering a keyboard shortcut sequence (Vim-style).\n *\n * Allows you to register multi-key sequences like 'g g' or 'd d' that trigger\n * when the full sequence is pressed within a timeout.\n *\n * Each step may include modifiers. You can chain the same modifier across\n * steps (e.g. `Shift+R` then `Shift+T`). Modifier-only keydown events (Shift,\n * Control, Alt, or Meta pressed alone) are ignored while matching—they do not\n * advance the sequence or reset progress.\n *\n * @param sequence - Array of hotkey strings that form the sequence (or getter function)\n * @param callback - Function to call when the sequence is completed\n * @param options - Options for the sequence behavior (or getter function). `enabled: false` still registers\n * the sequence (visible in devtools); only execution is suppressed.\n *\n * @example\n * ```ts\n * @Component({ ... })\n * export class VimEditorComponent {\n * lastSequence = signal<string | null>(null)\n *\n * constructor() {\n * injectHotkeySequence(['G', 'G'], () => this.lastSequence.set('gg → Go to top'))\n * injectHotkeySequence(['D', 'D'], () => this.lastSequence.set('dd → Delete line'))\n * injectHotkeySequence(['C', 'I', 'W'], () => this.lastSequence.set('ciw'), { timeout: 500 })\n * injectHotkeySequence(['Shift+R', 'Shift+T'], () => this.lastSequence.set('⇧R⇧T'))\n * }\n * }\n * ```\n */\nexport function injectHotkeySequence(\n sequence: HotkeySequence | (() => HotkeySequence),\n callback: HotkeyCallback,\n options:\n | InjectHotkeySequenceOptions\n | (() => InjectHotkeySequenceOptions) = {},\n): void {\n const defaultOptions = injectDefaultHotkeysOptions()\n const manager = getSequenceManager()\n const destroyRef = inject(DestroyRef)\n\n let handle: SequenceRegistrationHandle | null = null\n let lastSequenceKey: string | null = null\n let lastTarget: SequenceTarget | null = null\n\n destroyRef.onDestroy(() => {\n if (handle?.isActive) {\n handle.unregister()\n handle = null\n }\n lastSequenceKey = null\n lastTarget = null\n })\n\n effect(() => {\n // Resolve reactive values\n const resolvedSequence =\n typeof sequence === 'function' ? sequence() : sequence\n const resolvedOptions = typeof options === 'function' ? options() : options\n\n const mergedOptions = {\n ...defaultOptions.hotkeySequence,\n ...resolvedOptions,\n } as InjectHotkeySequenceOptions\n\n const { enabled = true, ...sequenceOptions } = mergedOptions\n\n const resolvedTarget =\n 'target' in sequenceOptions\n ? (sequenceOptions.target ?? null)\n : typeof document !== 'undefined'\n ? document\n : null\n\n if (resolvedSequence.length === 0 || !resolvedTarget) {\n if (handle?.isActive) {\n handle.unregister()\n handle = null\n }\n lastSequenceKey = null\n lastTarget = null\n return\n }\n\n const sequenceKey = formatHotkeySequence(resolvedSequence)\n\n const registerPayload: SequenceOptions = {\n ...sequenceOptions,\n enabled,\n target: resolvedTarget,\n }\n const { target: _t, ...optionsWithoutTarget } = registerPayload\n\n if (\n handle?.isActive &&\n lastSequenceKey === sequenceKey &&\n lastTarget === resolvedTarget\n ) {\n handle.callback = callback\n handle.setOptions(optionsWithoutTarget)\n return\n }\n\n if (handle?.isActive) {\n handle.unregister()\n handle = null\n }\n\n handle = manager.register(resolvedSequence, callback, registerPayload)\n lastSequenceKey = sequenceKey\n lastTarget = resolvedTarget\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,SAAgB,qBACd,UACA,UACA,UAE0C,EAAE,EACtC;CACN,MAAM,iBAAiBA,sDAA6B;CACpD,MAAM,qDAA8B;CACpC,MAAM,uCAAoBC,yBAAW;CAErC,IAAI,SAA4C;CAChD,IAAI,kBAAiC;CACrC,IAAI,aAAoC;AAExC,YAAW,gBAAgB;AACzB,MAAI,QAAQ,UAAU;AACpB,UAAO,YAAY;AACnB,YAAS;;AAEX,oBAAkB;AAClB,eAAa;GACb;AAEF,iCAAa;EAEX,MAAM,mBACJ,OAAO,aAAa,aAAa,UAAU,GAAG;EAChD,MAAM,kBAAkB,OAAO,YAAY,aAAa,SAAS,GAAG;EAOpE,MAAM,EAAE,UAAU,MAAM,GAAG,oBALL;GACpB,GAAG,eAAe;GAClB,GAAG;GACJ;EAID,MAAM,iBACJ,YAAY,kBACP,gBAAgB,UAAU,OAC3B,OAAO,aAAa,cAClB,WACA;AAER,MAAI,iBAAiB,WAAW,KAAK,CAAC,gBAAgB;AACpD,OAAI,QAAQ,UAAU;AACpB,WAAO,YAAY;AACnB,aAAS;;AAEX,qBAAkB;AAClB,gBAAa;AACb;;EAGF,MAAM,0DAAmC,iBAAiB;EAE1D,MAAM,kBAAmC;GACvC,GAAG;GACH;GACA,QAAQ;GACT;EACD,MAAM,EAAE,QAAQ,IAAI,GAAG,yBAAyB;AAEhD,MACE,QAAQ,YACR,oBAAoB,eACpB,eAAe,gBACf;AACA,UAAO,WAAW;AAClB,UAAO,WAAW,qBAAqB;AACvC;;AAGF,MAAI,QAAQ,UAAU;AACpB,UAAO,YAAY;AACnB,YAAS;;AAGX,WAAS,QAAQ,SAAS,kBAAkB,UAAU,gBAAgB;AACtE,oBAAkB;AAClB,eAAa;GACb"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { HotkeyCallback, HotkeySequence, SequenceOptions } from "@tanstack/hotkeys";
|
|
2
2
|
|
|
3
3
|
//#region src/injectHotkeySequence.d.ts
|
|
4
|
-
interface InjectHotkeySequenceOptions extends Omit<SequenceOptions, 'enabled'> {
|
|
4
|
+
interface InjectHotkeySequenceOptions extends Omit<SequenceOptions, 'enabled' | 'target'> {
|
|
5
5
|
/** Whether the sequence is enabled. Defaults to true. */
|
|
6
6
|
enabled?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The DOM element to attach the event listener to.
|
|
9
|
+
* Can be a direct DOM element, an accessor target, or null.
|
|
10
|
+
* Defaults to document when omitted.
|
|
11
|
+
*/
|
|
12
|
+
target?: HTMLElement | Document | Window | null;
|
|
7
13
|
}
|
|
8
14
|
/**
|
|
9
15
|
* Angular inject-based API for registering a keyboard shortcut sequence (Vim-style).
|
|
@@ -18,7 +24,8 @@ interface InjectHotkeySequenceOptions extends Omit<SequenceOptions, 'enabled'> {
|
|
|
18
24
|
*
|
|
19
25
|
* @param sequence - Array of hotkey strings that form the sequence (or getter function)
|
|
20
26
|
* @param callback - Function to call when the sequence is completed
|
|
21
|
-
* @param options - Options for the sequence behavior (or getter function)
|
|
27
|
+
* @param options - Options for the sequence behavior (or getter function). `enabled: false` still registers
|
|
28
|
+
* the sequence (visible in devtools); only execution is suppressed.
|
|
22
29
|
*
|
|
23
30
|
* @example
|
|
24
31
|
* ```ts
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { HotkeyCallback, HotkeySequence, SequenceOptions } from "@tanstack/hotkeys";
|
|
2
2
|
|
|
3
3
|
//#region src/injectHotkeySequence.d.ts
|
|
4
|
-
interface InjectHotkeySequenceOptions extends Omit<SequenceOptions, 'enabled'> {
|
|
4
|
+
interface InjectHotkeySequenceOptions extends Omit<SequenceOptions, 'enabled' | 'target'> {
|
|
5
5
|
/** Whether the sequence is enabled. Defaults to true. */
|
|
6
6
|
enabled?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The DOM element to attach the event listener to.
|
|
9
|
+
* Can be a direct DOM element, an accessor target, or null.
|
|
10
|
+
* Defaults to document when omitted.
|
|
11
|
+
*/
|
|
12
|
+
target?: HTMLElement | Document | Window | null;
|
|
7
13
|
}
|
|
8
14
|
/**
|
|
9
15
|
* Angular inject-based API for registering a keyboard shortcut sequence (Vim-style).
|
|
@@ -18,7 +24,8 @@ interface InjectHotkeySequenceOptions extends Omit<SequenceOptions, 'enabled'> {
|
|
|
18
24
|
*
|
|
19
25
|
* @param sequence - Array of hotkey strings that form the sequence (or getter function)
|
|
20
26
|
* @param callback - Function to call when the sequence is completed
|
|
21
|
-
* @param options - Options for the sequence behavior (or getter function)
|
|
27
|
+
* @param options - Options for the sequence behavior (or getter function). `enabled: false` still registers
|
|
28
|
+
* the sequence (visible in devtools); only execution is suppressed.
|
|
22
29
|
*
|
|
23
30
|
* @example
|
|
24
31
|
* ```ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { injectDefaultHotkeysOptions } from "./hotkeys-provider.js";
|
|
2
|
-
import { getSequenceManager } from "@tanstack/hotkeys";
|
|
3
|
-
import { effect } from "@angular/core";
|
|
2
|
+
import { formatHotkeySequence, getSequenceManager } from "@tanstack/hotkeys";
|
|
3
|
+
import { DestroyRef, effect, inject } from "@angular/core";
|
|
4
4
|
|
|
5
5
|
//#region src/injectHotkeySequence.ts
|
|
6
6
|
/**
|
|
@@ -16,7 +16,8 @@ import { effect } from "@angular/core";
|
|
|
16
16
|
*
|
|
17
17
|
* @param sequence - Array of hotkey strings that form the sequence (or getter function)
|
|
18
18
|
* @param callback - Function to call when the sequence is completed
|
|
19
|
-
* @param options - Options for the sequence behavior (or getter function)
|
|
19
|
+
* @param options - Options for the sequence behavior (or getter function). `enabled: false` still registers
|
|
20
|
+
* the sequence (visible in devtools); only execution is suppressed.
|
|
20
21
|
*
|
|
21
22
|
* @example
|
|
22
23
|
* ```ts
|
|
@@ -35,24 +36,55 @@ import { effect } from "@angular/core";
|
|
|
35
36
|
*/
|
|
36
37
|
function injectHotkeySequence(sequence, callback, options = {}) {
|
|
37
38
|
const defaultOptions = injectDefaultHotkeysOptions();
|
|
38
|
-
|
|
39
|
+
const manager = getSequenceManager();
|
|
40
|
+
const destroyRef = inject(DestroyRef);
|
|
41
|
+
let handle = null;
|
|
42
|
+
let lastSequenceKey = null;
|
|
43
|
+
let lastTarget = null;
|
|
44
|
+
destroyRef.onDestroy(() => {
|
|
45
|
+
if (handle?.isActive) {
|
|
46
|
+
handle.unregister();
|
|
47
|
+
handle = null;
|
|
48
|
+
}
|
|
49
|
+
lastSequenceKey = null;
|
|
50
|
+
lastTarget = null;
|
|
51
|
+
});
|
|
52
|
+
effect(() => {
|
|
39
53
|
const resolvedSequence = typeof sequence === "function" ? sequence() : sequence;
|
|
40
54
|
const resolvedOptions = typeof options === "function" ? options() : options;
|
|
41
55
|
const { enabled = true, ...sequenceOptions } = {
|
|
42
56
|
...defaultOptions.hotkeySequence,
|
|
43
57
|
...resolvedOptions
|
|
44
58
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
59
|
+
const resolvedTarget = "target" in sequenceOptions ? sequenceOptions.target ?? null : typeof document !== "undefined" ? document : null;
|
|
60
|
+
if (resolvedSequence.length === 0 || !resolvedTarget) {
|
|
61
|
+
if (handle?.isActive) {
|
|
62
|
+
handle.unregister();
|
|
63
|
+
handle = null;
|
|
64
|
+
}
|
|
65
|
+
lastSequenceKey = null;
|
|
66
|
+
lastTarget = null;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const sequenceKey = formatHotkeySequence(resolvedSequence);
|
|
70
|
+
const registerPayload = {
|
|
48
71
|
...sequenceOptions,
|
|
49
|
-
enabled
|
|
50
|
-
target:
|
|
72
|
+
enabled,
|
|
73
|
+
target: resolvedTarget
|
|
51
74
|
};
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
75
|
+
const { target: _t, ...optionsWithoutTarget } = registerPayload;
|
|
76
|
+
if (handle?.isActive && lastSequenceKey === sequenceKey && lastTarget === resolvedTarget) {
|
|
77
|
+
handle.callback = callback;
|
|
78
|
+
handle.setOptions(optionsWithoutTarget);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (handle?.isActive) {
|
|
82
|
+
handle.unregister();
|
|
83
|
+
handle = null;
|
|
84
|
+
}
|
|
85
|
+
handle = manager.register(resolvedSequence, callback, registerPayload);
|
|
86
|
+
lastSequenceKey = sequenceKey;
|
|
87
|
+
lastTarget = resolvedTarget;
|
|
56
88
|
});
|
|
57
89
|
}
|
|
58
90
|
|