@tanstack/octane-hotkeys 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/HotkeysProvider.d.ts +3 -4
- package/dist/HotkeysProvider.js +2 -3
- package/dist/index.d.ts +2 -2
- package/dist/internal.js +2 -3
- package/dist/types.d.ts +1 -3
- package/dist/useAppHotkeys.d.ts +1 -3
- package/dist/useAppHotkeys.js +3 -4
- package/dist/useFormatForDisplay.d.ts +1 -3
- package/dist/useFormatForDisplay.js +3 -4
- package/dist/useHeldKeyCodes.d.ts +1 -3
- package/dist/useHeldKeyCodes.js +1 -2
- package/dist/useHeldKeys.d.ts +1 -3
- package/dist/useHeldKeys.js +1 -2
- package/dist/useHotkey.d.ts +1 -3
- package/dist/useHotkey.js +1 -2
- package/dist/useHotkeyHint.d.ts +1 -3
- package/dist/useHotkeyHint.js +2 -3
- package/dist/useHotkeyRecorder.d.ts +1 -3
- package/dist/useHotkeyRecorder.js +3 -4
- package/dist/useHotkeyRegistrations.d.ts +1 -3
- package/dist/useHotkeyRegistrations.js +1 -2
- package/dist/useHotkeyScopesState.d.ts +1 -3
- package/dist/useHotkeyScopesState.js +1 -2
- package/dist/useHotkeys.d.ts +1 -3
- package/dist/useHotkeys.js +3 -4
- package/dist/useKeyHold.d.ts +1 -3
- package/dist/useKeyHold.js +1 -2
- package/package.json +9 -9
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { UseHotkeyCommonOptions } from "./useHotkey.js";
|
|
2
2
|
import { AppHotkeys, AppHotkeysStore, CustomHotkeys, HotkeyChordRecorderOptions, HotkeyPlatform, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
|
|
3
3
|
import { HotkeysProviderScopeProps } from "@tanstack/hotkeys/adapter";
|
|
4
|
-
//#region src/HotkeysProvider.d.ts
|
|
5
4
|
export interface DefaultHotkeysOptions {
|
|
6
5
|
/**
|
|
7
6
|
* The user's platform, for labels from `useFormatForDisplay`, hotkeys, and
|
|
@@ -37,8 +36,8 @@ export interface HotkeysProviderProps extends HotkeysProviderScopeProps {
|
|
|
37
36
|
/**
|
|
38
37
|
* The user's saved custom hotkeys. When the value changes, such as after
|
|
39
38
|
* saved data loads or the user signs in, it replaces the current custom
|
|
40
|
-
* hotkeys. `undefined` leaves them unchanged; `null` clears them.
|
|
41
|
-
* entries are ignored
|
|
39
|
+
* hotkeys. `undefined` leaves them unchanged; `null` clears them. Unknown
|
|
40
|
+
* ids and invalid entries are ignored.
|
|
42
41
|
*/
|
|
43
42
|
customHotkeys?: CustomHotkeys | null;
|
|
44
43
|
/** Called with the custom hotkeys after every change, ready to save. */
|
|
@@ -63,4 +62,4 @@ export declare function HotkeysProvider({ children, defaultOptions, appHotkeys,
|
|
|
63
62
|
};
|
|
64
63
|
children: unknown;
|
|
65
64
|
}>;
|
|
66
|
-
|
|
65
|
+
export {};
|
package/dist/HotkeysProvider.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { subSlot } from "./internal.js";
|
|
2
2
|
import { publishAppHotkeysStore } from "@tanstack/hotkeys";
|
|
3
|
-
import { createContext, createElement, useContext, useLayoutEffect, useRef } from "octane";
|
|
4
3
|
import { activateHotkeysProviderScope, createAppHotkeysStore, getHotkeysProviderScopeKey, mergeHotkeysProviderDefaults } from "@tanstack/hotkeys/adapter";
|
|
4
|
+
import { createContext, createElement, useContext, useLayoutEffect, useRef } from "octane";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/HotkeysProvider.ts
|
|
7
7
|
const HotkeysContext = createContext(null);
|
|
8
8
|
/** Reads the nearest provider, or null outside a provider. */
|
|
9
9
|
function useHotkeysContext() {
|
|
@@ -55,5 +55,4 @@ function HotkeysProvider({ children, defaultOptions, appHotkeys, customHotkeys,
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
//#endregion
|
|
59
58
|
export { HotkeysProvider, useDefaultHotkeysOptions, useHotkeysContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { UseAppHotkeyOptions, UseHotkeyChordOptions, UseHotkeyCommonOptions, UseHotkeyOptions, UseHotkeyOptionsFor, UseHotkeySequenceOptions, UseHotkeyTarget, useHotkey } from "./useHotkey.js";
|
|
2
1
|
import { DefaultHotkeysOptions, HotkeysProvider, HotkeysProviderOptions, HotkeysProviderProps, useDefaultHotkeysOptions, useHotkeysContext } from "./HotkeysProvider.js";
|
|
3
2
|
import { UseHotkeyDefinition, useHotkeys } from "./useHotkeys.js";
|
|
3
|
+
import { UseAppHotkeyOptions, UseHotkeyChordOptions, UseHotkeyCommonOptions, UseHotkeyOptions, UseHotkeyOptionsFor, UseHotkeySequenceOptions, UseHotkeyTarget, useHotkey } from "./useHotkey.js";
|
|
4
4
|
import { useHeldKeys } from "./useHeldKeys.js";
|
|
5
5
|
import { useHeldKeyCodes } from "./useHeldKeyCodes.js";
|
|
6
6
|
import { useKeyHold } from "./useKeyHold.js";
|
|
7
7
|
import { useHotkeyHint } from "./useHotkeyHint.js";
|
|
8
8
|
import { useFormatForDisplay } from "./useFormatForDisplay.js";
|
|
9
|
-
import { HotkeyRegistrationsResult, OctaneHotkeyRecorder, UseCustomHotkeysResult } from "./types.js";
|
|
10
9
|
import { useHotkeyRegistrations } from "./useHotkeyRegistrations.js";
|
|
11
10
|
import { useHotkeyScopesState } from "./useHotkeyScopesState.js";
|
|
12
11
|
import { useHotkeyRecorder } from "./useHotkeyRecorder.js";
|
|
13
12
|
import { useAppHotkeyList, useAppHotkeys, useCustomHotkeys } from "./useAppHotkeys.js";
|
|
13
|
+
import { HotkeyRegistrationsResult, OctaneHotkeyRecorder, UseCustomHotkeysResult } from "./types.js";
|
|
14
14
|
export * from "@tanstack/hotkeys";
|
|
15
15
|
export { type DefaultHotkeysOptions, HotkeyRegistrationsResult, HotkeysProvider, type HotkeysProviderOptions, type HotkeysProviderProps, OctaneHotkeyRecorder, UseAppHotkeyOptions, UseCustomHotkeysResult, UseHotkeyChordOptions, UseHotkeyCommonOptions, UseHotkeyDefinition, UseHotkeyOptions, UseHotkeyOptionsFor, UseHotkeySequenceOptions, UseHotkeyTarget, useAppHotkeyList, useAppHotkeys, useCustomHotkeys, useDefaultHotkeysOptions, useFormatForDisplay, useHeldKeyCodes, useHeldKeys, useHotkey, useHotkeyHint, useHotkeyRecorder, useHotkeyRegistrations, useHotkeyScopesState, useHotkeys, useHotkeysContext, useKeyHold };
|
package/dist/internal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useCallback, useRef, useSyncExternalStore } from "octane";
|
|
2
1
|
import { createStore } from "@tanstack/hotkeys/adapter";
|
|
2
|
+
import { useCallback, useRef, useSyncExternalStore } from "octane";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/internal.ts
|
|
5
5
|
const subSlotCache = /* @__PURE__ */ new Map();
|
|
6
6
|
const bareTagCache = /* @__PURE__ */ new Map();
|
|
7
7
|
function subSlot(slot, tag) {
|
|
@@ -61,5 +61,4 @@ function useAppHotkeysStore(store, slot) {
|
|
|
61
61
|
return store;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
//#endregion
|
|
65
64
|
export { select, splitSlot, subSlot, useAppHotkeysStore };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AppHotkey, CustomHotkeys, Hotkey, HotkeyRegistrationView, HotkeySequence, RegisteredAppHotkeys } from "@tanstack/hotkeys";
|
|
2
|
-
//#region src/types.d.ts
|
|
3
2
|
/** Recording state and controls owned by the containing component. */
|
|
4
3
|
export interface OctaneHotkeyRecorder<THotkey extends Hotkey = Hotkey> {
|
|
5
4
|
/** Whether the recorder is listening for a shortcut. */
|
|
@@ -37,5 +36,4 @@ export interface UseCustomHotkeysResult {
|
|
|
37
36
|
resetCustomHotkeys: () => void;
|
|
38
37
|
/** Other app hotkeys that would collide if `id` used `hotkey`. */
|
|
39
38
|
findConflicts: (id: keyof RegisteredAppHotkeys & string, hotkey: Hotkey) => Array<AppHotkey>;
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
39
|
+
}
|
package/dist/useAppHotkeys.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { UseCustomHotkeysResult } from "./types.js";
|
|
2
2
|
import { AppHotkeyListItem, RegisteredAppHotkeys } from "@tanstack/hotkeys";
|
|
3
|
-
//#region src/useAppHotkeys.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Returns the effective app hotkeys from `HotkeysProvider`, typed by
|
|
6
5
|
* `Register`: each declaration with the user's custom hotkey applied.
|
|
@@ -17,5 +16,4 @@ export declare function useAppHotkeyList(): Array<AppHotkeyListItem<RegisteredAp
|
|
|
17
16
|
* registered app hotkey immediately and are passed to the provider's
|
|
18
17
|
* `onCustomHotkeysChange`, ready to save.
|
|
19
18
|
*/
|
|
20
|
-
export declare function useCustomHotkeys(): UseCustomHotkeysResult;
|
|
21
|
-
//#endregion
|
|
19
|
+
export declare function useCustomHotkeys(): UseCustomHotkeysResult;
|
package/dist/useAppHotkeys.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { subSlot, useAppHotkeysStore } from "./internal.js";
|
|
2
1
|
import { useHotkeysContext } from "./HotkeysProvider.js";
|
|
2
|
+
import { subSlot, useAppHotkeysStore } from "./internal.js";
|
|
3
3
|
import { useHotkeyRegistrations } from "./useHotkeyRegistrations.js";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/useAppHotkeys.ts
|
|
6
6
|
function useRequiredStore(name, slot) {
|
|
7
7
|
const store = useAppHotkeysStore(useHotkeysContext()?.appHotkeysStore ?? null, subSlot(slot, `${name}-store`));
|
|
8
|
-
if (!store) throw new Error(
|
|
8
|
+
if (!store) throw new Error(`[hotkeys] ${name} requires a HotkeysProvider with appHotkeys`);
|
|
9
9
|
return store;
|
|
10
10
|
}
|
|
11
11
|
function useAppHotkeys(slot) {
|
|
@@ -27,5 +27,4 @@ function useCustomHotkeys(slot) {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
//#endregion
|
|
31
30
|
export { useAppHotkeyList, useAppHotkeys, useCustomHotkeys };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { formatForDisplay } from "@tanstack/hotkeys";
|
|
2
|
-
//#region src/useFormatForDisplay.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Returns `formatForDisplay` with the platform from `HotkeysProvider`, or the
|
|
5
4
|
* detected platform without one. A `platform` passed to the returned function
|
|
@@ -22,5 +21,4 @@ import { formatForDisplay } from "@tanstack/hotkeys";
|
|
|
22
21
|
* }
|
|
23
22
|
* ```
|
|
24
23
|
*/
|
|
25
|
-
export declare function useFormatForDisplay(): typeof formatForDisplay;
|
|
26
|
-
//#endregion
|
|
24
|
+
export declare function useFormatForDisplay(): typeof formatForDisplay;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { subSlot } from "./internal.js";
|
|
2
1
|
import { useDefaultHotkeysOptions } from "./HotkeysProvider.js";
|
|
2
|
+
import { subSlot } from "./internal.js";
|
|
3
3
|
import { detectPlatform, formatForDisplay } from "@tanstack/hotkeys";
|
|
4
|
-
import { useCallback, useSyncExternalStore } from "octane";
|
|
5
4
|
import { getServerPlatformSnapshot } from "@tanstack/hotkeys/adapter";
|
|
5
|
+
import { useCallback, useSyncExternalStore } from "octane";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/useFormatForDisplay.ts
|
|
8
8
|
const subscribe = () => () => {};
|
|
9
9
|
function useFormatForDisplay(slot) {
|
|
10
10
|
const provided = useDefaultHotkeysOptions().platform;
|
|
@@ -15,5 +15,4 @@ function useFormatForDisplay(slot) {
|
|
|
15
15
|
}), [platform], subSlot(slot, "format"));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
//#endregion
|
|
19
18
|
export { useFormatForDisplay };
|
package/dist/useHeldKeyCodes.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { select, subSlot } from "./internal.js";
|
|
2
2
|
import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/useHeldKeyCodes.ts
|
|
5
5
|
function useHeldKeyCodes(slot) {
|
|
6
6
|
return select(getKeyStateTracker().store, (state) => state.heldCodes, subSlot(slot, "held-codes"));
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
//#endregion
|
|
10
9
|
export { useHeldKeyCodes };
|
package/dist/useHeldKeys.d.ts
CHANGED
package/dist/useHeldKeys.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { select, subSlot } from "./internal.js";
|
|
2
2
|
import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/useHeldKeys.ts
|
|
5
5
|
function useHeldKeys(slot) {
|
|
6
6
|
return select(getKeyStateTracker().store, (state) => state.heldKeys, subSlot(slot, "held-keys"));
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
//#endregion
|
|
10
9
|
export { useHeldKeys };
|
package/dist/useHotkey.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AppHotkey, HotkeyCallback, HotkeyCallbackContextFor, RegisterableHotkey, Target } from "@tanstack/hotkeys";
|
|
2
2
|
import { AdapterAppHotkeyOptions, AdapterChordOptions, AdapterCommonOptions, AdapterHotkeyOptions, AdapterOptionsFor, AdapterSequenceOptions } from "@tanstack/hotkeys/adapter";
|
|
3
|
-
//#region src/useHotkey.d.ts
|
|
4
3
|
/** The element to listen on. A `null` target skips registration until it is set. */
|
|
5
4
|
export type UseHotkeyTarget = Target | null;
|
|
6
5
|
/** Options shared by chords and sequences. */
|
|
@@ -22,5 +21,4 @@ export type UseAppHotkeyOptions<T extends AppHotkey = AppHotkey> = AdapterAppHot
|
|
|
22
21
|
* registers nothing, for an optional shortcut.
|
|
23
22
|
*/
|
|
24
23
|
export declare function useHotkey<T extends AppHotkey>(hotkey: T | null | undefined, callback: HotkeyCallback, options?: UseAppHotkeyOptions<T>): void;
|
|
25
|
-
export declare function useHotkey<const T extends RegisterableHotkey>(hotkey: T | null | undefined, callback: HotkeyCallback<HotkeyCallbackContextFor<T>>, options?: UseHotkeyOptionsFor<T>): void;
|
|
26
|
-
//#endregion
|
|
24
|
+
export declare function useHotkey<const T extends RegisterableHotkey>(hotkey: T | null | undefined, callback: HotkeyCallback<HotkeyCallbackContextFor<T>>, options?: UseHotkeyOptionsFor<T>): void;
|
package/dist/useHotkey.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { splitSlot, subSlot } from "./internal.js";
|
|
2
2
|
import { useHotkeys } from "./useHotkeys.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/useHotkey.ts
|
|
5
5
|
function useHotkey(hotkey, callback, ...rest) {
|
|
6
6
|
const [args, slot] = splitSlot(rest);
|
|
7
7
|
useHotkeys([{
|
|
@@ -11,5 +11,4 @@ function useHotkey(hotkey, callback, ...rest) {
|
|
|
11
11
|
}], void 0, subSlot(slot, "hotkey"));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
//#endregion
|
|
15
14
|
export { useHotkey };
|
package/dist/useHotkeyHint.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AppHotkey, HeldModifierOptions, RegisterableHotkey } from "@tanstack/hotkeys";
|
|
2
|
-
//#region src/useHotkeyHint.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Reports whether held modifiers reveal a shortcut hint. The hint shows only
|
|
5
4
|
* while the hotkey can fire: some registration of it is enabled and in an
|
|
@@ -8,5 +7,4 @@ import { AppHotkey, HeldModifierOptions, RegisterableHotkey } from "@tanstack/ho
|
|
|
8
7
|
* while unbound). No hotkey (`undefined`, `null`, or `''`) returns false. A
|
|
9
8
|
* hotkey on an element counts only while focus is inside it.
|
|
10
9
|
*/
|
|
11
|
-
export declare function useHotkeyHint(hotkey: RegisterableHotkey | AppHotkey | null | undefined, options?: HeldModifierOptions): boolean;
|
|
12
|
-
//#endregion
|
|
10
|
+
export declare function useHotkeyHint(hotkey: RegisterableHotkey | AppHotkey | null | undefined, options?: HeldModifierOptions): boolean;
|
package/dist/useHotkeyHint.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { select, splitSlot, subSlot, useAppHotkeysStore } from "./internal.js";
|
|
2
1
|
import { useHotkeysContext } from "./HotkeysProvider.js";
|
|
2
|
+
import { select, splitSlot, subSlot, useAppHotkeysStore } from "./internal.js";
|
|
3
3
|
import { getHotkeyManager, getKeyStateTracker, isAppHotkey, matchesHeldModifiers, resolveAppHotkey } from "@tanstack/hotkeys";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/useHotkeyHint.ts
|
|
6
6
|
function useHotkeyHint(hotkey, ...rest) {
|
|
7
7
|
const [args, slot] = splitSlot(rest);
|
|
8
8
|
const store = useAppHotkeysStore(useHotkeysContext()?.appHotkeysStore ?? null, subSlot(slot, "app-hotkeys"));
|
|
@@ -13,5 +13,4 @@ function useHotkeyHint(hotkey, ...rest) {
|
|
|
13
13
|
return active && held;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
//#endregion
|
|
17
16
|
export { useHotkeyHint };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { OctaneHotkeyRecorder } from "./types.js";
|
|
2
2
|
import { HotkeyChord, HotkeyChordRecorderOptions, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
|
|
3
|
-
//#region src/useHotkeyRecorder.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Records a shortcut and destroys the recorder on unmount. With the default
|
|
6
5
|
* `maxSteps: 1`, the first valid chord is recorded. With a larger `maxSteps`,
|
|
@@ -9,5 +8,4 @@ import { HotkeyChord, HotkeyChordRecorderOptions, HotkeySequenceRecorderOptions
|
|
|
9
8
|
* `onRecord` receives a chord (one step) or a sequence.
|
|
10
9
|
*/
|
|
11
10
|
export declare function useHotkeyRecorder(options: HotkeyChordRecorderOptions): OctaneHotkeyRecorder<HotkeyChord>;
|
|
12
|
-
export declare function useHotkeyRecorder(options: HotkeySequenceRecorderOptions): OctaneHotkeyRecorder;
|
|
13
|
-
//#endregion
|
|
11
|
+
export declare function useHotkeyRecorder(options: HotkeySequenceRecorderOptions): OctaneHotkeyRecorder;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { select, subSlot } from "./internal.js";
|
|
2
1
|
import { useDefaultHotkeysOptions } from "./HotkeysProvider.js";
|
|
2
|
+
import { select, subSlot } from "./internal.js";
|
|
3
3
|
import { HotkeyRecorder } from "@tanstack/hotkeys";
|
|
4
|
-
import { useLayoutEffect, useRef } from "octane";
|
|
5
4
|
import { withDefaults } from "@tanstack/hotkeys/adapter";
|
|
5
|
+
import { useLayoutEffect, useRef } from "octane";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/useHotkeyRecorder.ts
|
|
8
8
|
function useHotkeyRecorder(options, slot) {
|
|
9
9
|
const defaults = useDefaultHotkeysOptions();
|
|
10
10
|
const merged = withDefaults(defaults.hotkeyRecorder, options);
|
|
@@ -29,5 +29,4 @@ function useHotkeyRecorder(options, slot) {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
//#endregion
|
|
33
32
|
export { useHotkeyRecorder };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { HotkeyRegistrationsResult } from "./types.js";
|
|
2
|
-
//#region src/useHotkeyRegistrations.d.ts
|
|
3
2
|
/** Reads public snapshots of every registration, chords and sequences. */
|
|
4
|
-
export declare function useHotkeyRegistrations(): HotkeyRegistrationsResult;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare function useHotkeyRegistrations(): HotkeyRegistrationsResult;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { select, subSlot } from "./internal.js";
|
|
2
2
|
import { getHotkeyManager, toHotkeyRegistrationView } from "@tanstack/hotkeys";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/useHotkeyRegistrations.ts
|
|
5
5
|
function useHotkeyRegistrations(slot) {
|
|
6
6
|
return { hotkeys: select(getHotkeyManager().registrations, (state) => Array.from(state.values()).map(toHotkeyRegistrationView), subSlot(slot, "hotkeys")) };
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
//#endregion
|
|
10
9
|
export { useHotkeyRegistrations };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { HotkeyScopesState } from "@tanstack/hotkeys";
|
|
2
|
-
//#region src/useHotkeyScopesState.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Reads the hotkey manager's scope state: the active scopes, the exclusive
|
|
5
4
|
* scope that owns the keyboard, and the scopes it allows or suspends.
|
|
6
5
|
*/
|
|
7
|
-
export declare function useHotkeyScopesState(): HotkeyScopesState;
|
|
8
|
-
//#endregion
|
|
6
|
+
export declare function useHotkeyScopesState(): HotkeyScopesState;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { select, subSlot } from "./internal.js";
|
|
2
2
|
import { getHotkeyManager } from "@tanstack/hotkeys";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/useHotkeyScopesState.ts
|
|
5
5
|
function useHotkeyScopesState(slot) {
|
|
6
6
|
return select(getHotkeyManager().scopes, (state) => state, subSlot(slot, "hotkey-scopes-state"));
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
//#endregion
|
|
10
9
|
export { useHotkeyScopesState };
|
package/dist/useHotkeys.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { UseHotkeyCommonOptions, UseHotkeyTarget } from "./useHotkey.js";
|
|
2
2
|
import { AdapterHotkeyDefinition } from "@tanstack/hotkeys/adapter";
|
|
3
|
-
//#region src/useHotkeys.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* One hotkey for `useHotkeys`. Chords accept `requireReset`; sequences accept
|
|
6
5
|
* `timeout`; hotkeys of unknown kind accept only shared options.
|
|
@@ -12,5 +11,4 @@ export type UseHotkeyDefinition = AdapterHotkeyDefinition<UseHotkeyTarget>;
|
|
|
12
11
|
* provider defaults, app hotkey declaration, common options, per-hotkey
|
|
13
12
|
* options. Unbound app hotkeys and empty sequences register nothing.
|
|
14
13
|
*/
|
|
15
|
-
export declare function useHotkeys(definitions: ReadonlyArray<UseHotkeyDefinition>, options?: UseHotkeyCommonOptions): void;
|
|
16
|
-
//#endregion
|
|
14
|
+
export declare function useHotkeys(definitions: ReadonlyArray<UseHotkeyDefinition>, options?: UseHotkeyCommonOptions): void;
|
package/dist/useHotkeys.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { splitSlot, subSlot, useAppHotkeysStore } from "./internal.js";
|
|
2
1
|
import { useHotkeysContext } from "./HotkeysProvider.js";
|
|
3
|
-
import {
|
|
2
|
+
import { splitSlot, subSlot, useAppHotkeysStore } from "./internal.js";
|
|
4
3
|
import { createHotkeyBindings, prepareHotkeyDefinitions } from "@tanstack/hotkeys/adapter";
|
|
4
|
+
import { useLayoutEffect, useRef } from "octane";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/useHotkeys.ts
|
|
7
7
|
function useHotkeys(definitions, ...rest) {
|
|
8
8
|
const [args, slot] = splitSlot(rest);
|
|
9
9
|
const context = useHotkeysContext();
|
|
@@ -23,5 +23,4 @@ function useHotkeys(definitions, ...rest) {
|
|
|
23
23
|
useLayoutEffect(() => () => bindings.destroy(), [], subSlot(slot, "cleanup"));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
//#endregion
|
|
27
26
|
export { useHotkeys };
|
package/dist/useKeyHold.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { IndividualKey } from "@tanstack/hotkeys";
|
|
2
|
-
//#region src/useKeyHold.d.ts
|
|
3
2
|
/** Reports whether a logical key is held. */
|
|
4
|
-
export declare function useKeyHold(key: IndividualKey): boolean;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare function useKeyHold(key: IndividualKey): boolean;
|
package/dist/useKeyHold.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { select, subSlot } from "./internal.js";
|
|
2
2
|
import { getKeyStateTracker } from "@tanstack/hotkeys";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/useKeyHold.ts
|
|
5
5
|
function useKeyHold(key, slot) {
|
|
6
6
|
return select(getKeyStateTracker().store, (state) => state.heldKeys.includes(key), subSlot(slot, "key-hold"));
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
//#endregion
|
|
10
9
|
export { useKeyHold };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/octane-hotkeys",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Octane adapter for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"skills"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@tanstack/hotkeys": "0.
|
|
38
|
+
"@tanstack/hotkeys": "0.25.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@tsrx/oxc": "0.
|
|
42
|
-
"@tsrx/typescript-plugin": "^0.3
|
|
43
|
-
"octane": "0.
|
|
44
|
-
"vite": "^8.3.
|
|
41
|
+
"@tsrx/oxc": "0.23.0",
|
|
42
|
+
"@tsrx/typescript-plugin": "^0.6.3",
|
|
43
|
+
"octane": "0.16.7",
|
|
44
|
+
"vite": "^8.3.6"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"octane": ">=0.12.0"
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"clean": "premove ./build ./dist",
|
|
58
|
-
"lint": "
|
|
59
|
-
"lint:fix": "
|
|
60
|
-
"test:
|
|
58
|
+
"lint": "oxlint ./src",
|
|
59
|
+
"lint:fix": "oxlint ./src --fix",
|
|
60
|
+
"test:oxlint": "oxlint ./src",
|
|
61
61
|
"test:lib": "vitest run && vitest run --config vitest.ssr.config.ts",
|
|
62
62
|
"test:lib:dev": "vitest --watch",
|
|
63
63
|
"test:types": "tsrx-tsc --noEmit",
|