@tanstack/alpine-hotkeys 0.11.0 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  import { createHotkeyRegistrations } from "./createHotkeyRegistrations.js";
2
2
 
3
- //#region src/createAppHotkeys.ts
3
+ // src/createAppHotkeys.ts
4
4
  function requireStore(scope) {
5
5
  const store = scope.appHotkeys();
6
- if (!store) throw new Error("App hotkeys require provideAppHotkeys()");
6
+ if (!store) throw new Error("[hotkeys] App hotkeys require provideAppHotkeys()");
7
7
  return store;
8
8
  }
9
9
  function createAppHotkeys(scope) {
@@ -29,5 +29,4 @@ function createCustomHotkeys(scope) {
29
29
  };
30
30
  }
31
31
 
32
- //#endregion
33
32
  export { createAppHotkeyList, createAppHotkeys, createCustomHotkeys };
@@ -1,9 +1,8 @@
1
1
  import { getKeyStateTracker } from "@tanstack/hotkeys";
2
2
 
3
- //#region src/createHeldKeyCodes.ts
3
+ // src/createHeldKeyCodes.ts
4
4
  function createHeldKeyCodes(scope) {
5
5
  return scope.select(getKeyStateTracker().store, (state) => state.heldCodes);
6
6
  }
7
7
 
8
- //#endregion
9
8
  export { createHeldKeyCodes };
@@ -1,9 +1,8 @@
1
1
  import { getKeyStateTracker } from "@tanstack/hotkeys";
2
2
 
3
- //#region src/createHeldKeys.ts
3
+ // src/createHeldKeys.ts
4
4
  function createHeldKeys(scope) {
5
5
  return scope.select(getKeyStateTracker().store, (state) => state.heldKeys);
6
6
  }
7
7
 
8
- //#endregion
9
8
  export { createHeldKeys };
@@ -1,7 +1,7 @@
1
- import { read } from "./scope.js";
2
1
  import { createHotkeys } from "./createHotkeys.js";
2
+ import { read } from "./scope.js";
3
3
 
4
- //#region src/createHotkey.ts
4
+ // src/createHotkey.ts
5
5
  function createHotkey(scope, hotkey, callback, options = {}) {
6
6
  createHotkeys(scope, () => [{
7
7
  hotkey: read(hotkey),
@@ -10,5 +10,4 @@ function createHotkey(scope, hotkey, callback, options = {}) {
10
10
  }]);
11
11
  }
12
12
 
13
- //#endregion
14
13
  export { createHotkey };
@@ -1,7 +1,7 @@
1
1
  import { read } from "./scope.js";
2
2
  import { getHotkeyManager, getKeyStateTracker, isAppHotkey, matchesHeldModifiers, resolveAppHotkey } from "@tanstack/hotkeys";
3
3
 
4
- //#region src/createHotkeyHint.ts
4
+ // src/createHotkeyHint.ts
5
5
  function createHotkeyHint(scope, hotkey, options = {}) {
6
6
  const manager = getHotkeyManager();
7
7
  const registrations = scope.select(manager.registrations, (state) => state);
@@ -12,5 +12,4 @@ function createHotkeyHint(scope, hotkey, options = {}) {
12
12
  });
13
13
  }
14
14
 
15
- //#endregion
16
15
  export { createHotkeyHint };
@@ -1,7 +1,6 @@
1
- import { AlpineHotkeyRecorder, AlpineHotkeys } from "./types.js";
2
1
  import "./scope.js";
2
+ import { AlpineHotkeyRecorder, AlpineHotkeys } from "./types.js";
3
3
  import { HotkeyChord, HotkeyChordRecorderOptions, HotkeyRecorderOptions, HotkeySequenceRecorderOptions } from "@tanstack/hotkeys";
4
- //#region src/createHotkeyRecorder.d.ts
5
4
  /**
6
5
  * Creates a recorder owned by a `createHotkeysScope` owner. It uses the
7
6
  * owner's `hotkeyRecorder` defaults, and options can follow Alpine state.
@@ -11,5 +10,4 @@ export declare function createHotkeyRecorder(owner: AlpineHotkeys, options: Hotk
11
10
  export declare function createHotkeyRecorder(owner: AlpineHotkeys, options: HotkeySequenceRecorderOptions): AlpineHotkeyRecorder;
12
11
  export declare function createHotkeyRecorder(owner: AlpineHotkeys, options: () => HotkeySequenceRecorderOptions): AlpineHotkeyRecorder;
13
12
  export declare function createHotkeyRecorder(owner: AlpineHotkeys, options: () => HotkeyChordRecorderOptions): AlpineHotkeyRecorder<HotkeyChord>;
14
- export declare function createHotkeyRecorder(owner: AlpineHotkeys, options: () => HotkeyRecorderOptions): AlpineHotkeyRecorder;
15
- //#endregion
13
+ export declare function createHotkeyRecorder(owner: AlpineHotkeys, options: () => HotkeyRecorderOptions): AlpineHotkeyRecorder;
@@ -2,7 +2,7 @@ import { read, scopeOf } from "./scope.js";
2
2
  import { HotkeyRecorder } from "@tanstack/hotkeys";
3
3
  import { withDefaults } from "@tanstack/hotkeys/adapter";
4
4
 
5
- //#region src/createHotkeyRecorder.ts
5
+ // src/createHotkeyRecorder.ts
6
6
  function createHotkeyRecorder(owner, options) {
7
7
  return createRecorder(scopeOf(owner), options);
8
8
  }
@@ -30,5 +30,4 @@ function createRecorder(scope, options) {
30
30
  };
31
31
  }
32
32
 
33
- //#endregion
34
33
  export { createHotkeyRecorder, createRecorder };
@@ -1,6 +1,6 @@
1
1
  import { getHotkeyManager, toHotkeyRegistrationView } from "@tanstack/hotkeys";
2
2
 
3
- //#region src/createHotkeyRegistrations.ts
3
+ // src/createHotkeyRegistrations.ts
4
4
  function createHotkeyRegistrations(scope) {
5
5
  const state = scope.select(getHotkeyManager().registrations, (value) => Array.from(value.values()).map(toHotkeyRegistrationView));
6
6
  return { get hotkeys() {
@@ -8,5 +8,4 @@ function createHotkeyRegistrations(scope) {
8
8
  } };
9
9
  }
10
10
 
11
- //#endregion
12
11
  export { createHotkeyRegistrations };
@@ -1,9 +1,8 @@
1
1
  import { getHotkeyManager } from "@tanstack/hotkeys";
2
2
 
3
- //#region src/createHotkeyScopesState.ts
3
+ // src/createHotkeyScopesState.ts
4
4
  function createHotkeyScopesState(scope) {
5
5
  return scope.select(getHotkeyManager().scopes, (state) => state);
6
6
  }
7
7
 
8
- //#endregion
9
8
  export { createHotkeyScopesState };
@@ -1,7 +1,7 @@
1
1
  import { read } from "./scope.js";
2
2
  import { createHotkeyBindings, prepareHotkeyDefinitions } from "@tanstack/hotkeys/adapter";
3
3
 
4
- //#region src/createHotkeys.ts
4
+ // src/createHotkeys.ts
5
5
  function createHotkeys(scope, definitions, options = {}) {
6
6
  scope.assertActive();
7
7
  const bindings = createHotkeyBindings();
@@ -19,5 +19,4 @@ function createHotkeys(scope, definitions, options = {}) {
19
19
  }
20
20
  }
21
21
 
22
- //#endregion
23
22
  export { createHotkeys };
@@ -1,10 +1,8 @@
1
1
  import { AlpineHotkeys, DefaultHotkeysOptions, MaybeGetter } from "./types.js";
2
- //#region src/createHotkeysScope.d.ts
3
2
  /**
4
3
  * Owns Alpine effects and Store subscriptions, with optional shared defaults.
5
4
  * App hotkeys come from `provideAppHotkeys`. Call destroy from x-data's
6
5
  * destroy hook.
7
6
  */
8
7
  export declare function createHotkeysScope(defaultOptions?: MaybeGetter<DefaultHotkeysOptions>): AlpineHotkeys;
9
- //#endregion
10
8
  export type { AlpineHotkeys, DefaultHotkeysOptions, MaybeGetter };
@@ -1,15 +1,15 @@
1
- import { createScope, ownerScopes } from "./scope.js";
2
- import { createHotkeys } from "./createHotkeys.js";
3
- import { createHotkey } from "./createHotkey.js";
4
- import { createHeldKeys } from "./createHeldKeys.js";
1
+ import { createAppHotkeyList, createAppHotkeys, createCustomHotkeys } from "./createAppHotkeys.js";
5
2
  import { createHeldKeyCodes } from "./createHeldKeyCodes.js";
6
- import { createKeyHold } from "./createKeyHold.js";
3
+ import { createHeldKeys } from "./createHeldKeys.js";
4
+ import { createHotkey } from "./createHotkey.js";
7
5
  import { createHotkeyHint } from "./createHotkeyHint.js";
8
6
  import { createHotkeyRegistrations } from "./createHotkeyRegistrations.js";
9
7
  import { createHotkeyScopesState } from "./createHotkeyScopesState.js";
10
- import { createAppHotkeyList, createAppHotkeys, createCustomHotkeys } from "./createAppHotkeys.js";
8
+ import { createHotkeys } from "./createHotkeys.js";
9
+ import { createKeyHold } from "./createKeyHold.js";
10
+ import { createScope, ownerScopes } from "./scope.js";
11
11
 
12
- //#region src/createHotkeysScope.ts
12
+ // src/createHotkeysScope.ts
13
13
  /**
14
14
  * Owns Alpine effects and Store subscriptions, with optional shared defaults.
15
15
  * App hotkeys come from `provideAppHotkeys`. Call destroy from x-data's
@@ -35,5 +35,4 @@ function createHotkeysScope(defaultOptions = {}) {
35
35
  return owner;
36
36
  }
37
37
 
38
- //#endregion
39
38
  export { createHotkeysScope };
@@ -1,10 +1,9 @@
1
1
  import { read } from "./scope.js";
2
2
  import { getKeyStateTracker } from "@tanstack/hotkeys";
3
3
 
4
- //#region src/createKeyHold.ts
4
+ // src/createKeyHold.ts
5
5
  function createKeyHold(scope, key) {
6
6
  return scope.select(getKeyStateTracker().store, (state) => state.heldKeys.includes(read(key)));
7
7
  }
8
8
 
9
- //#endregion
10
9
  export { createKeyHold };
@@ -1,9 +1,7 @@
1
1
  import Alpine from "alpinejs";
2
- //#region src/hotkeyRecorderPlugin.d.ts
3
2
  /**
4
3
  * Installs $hotkeyRecorder, a function that creates recorders owned by its
5
4
  * element. It is separate from `hotkeysPlugin`, so apps that don't record
6
5
  * hotkeys don't ship the recorder.
7
6
  */
8
- export declare function hotkeyRecorderPlugin(alpine: typeof Alpine): void;
9
- //#endregion
7
+ export declare function hotkeyRecorderPlugin(alpine: typeof Alpine): void;
@@ -1,7 +1,7 @@
1
- import { createScope, setAlpine } from "./scope.js";
2
1
  import { createRecorder } from "./createHotkeyRecorder.js";
2
+ import { createScope, setAlpine } from "./scope.js";
3
3
 
4
- //#region src/hotkeyRecorderPlugin.ts
4
+ // src/hotkeyRecorderPlugin.ts
5
5
  /**
6
6
  * Installs $hotkeyRecorder, a function that creates recorders owned by its
7
7
  * element. It is separate from `hotkeysPlugin`, so apps that don't record
@@ -25,5 +25,4 @@ function hotkeyRecorderPlugin(alpine) {
25
25
  });
26
26
  }
27
27
 
28
- //#endregion
29
28
  export { hotkeyRecorderPlugin };
@@ -1,9 +1,7 @@
1
1
  import Alpine from "alpinejs";
2
- //#region src/hotkeysPlugin.d.ts
3
2
  /**
4
3
  * Installs $hotkeys, whose registrations and subscriptions belong to its
5
4
  * element. Every hotkeys scope, including ones from `createHotkeysScope`, uses
6
5
  * the Alpine instance passed here.
7
6
  */
8
- export declare function hotkeysPlugin(alpine: typeof Alpine): void;
9
- //#endregion
7
+ export declare function hotkeysPlugin(alpine: typeof Alpine): void;
@@ -1,7 +1,7 @@
1
- import { setAlpine } from "./scope.js";
2
1
  import { createHotkeysScope } from "./createHotkeysScope.js";
2
+ import { setAlpine } from "./scope.js";
3
3
 
4
- //#region src/hotkeysPlugin.ts
4
+ // src/hotkeysPlugin.ts
5
5
  /**
6
6
  * Installs $hotkeys, whose registrations and subscriptions belong to its
7
7
  * element. Every hotkeys scope, including ones from `createHotkeysScope`, uses
@@ -25,5 +25,4 @@ function hotkeysPlugin(alpine) {
25
25
  });
26
26
  }
27
27
 
28
- //#endregion
29
28
  export { hotkeysPlugin };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { AlpineAppHotkeyOptions, AlpineCreateHotkey, AlpineCreateHotkeyRecorder, AlpineCustomHotkeys, AlpineHotkeyCommonOptions, AlpineHotkeyDefinition, AlpineHotkeyOptionsFor, AlpineHotkeyRecorder, AlpineHotkeyState, AlpineHotkeyTarget, AlpineHotkeys, DefaultHotkeysOptions, HotkeyRegistrationsResult, MaybeGetter } from "./types.js";
2
1
  import { createHotkeysScope } from "./createHotkeysScope.js";
3
2
  import { hotkeysPlugin } from "./hotkeysPlugin.js";
4
3
  import { createHotkeyRecorder } from "./createHotkeyRecorder.js";
5
4
  import { hotkeyRecorderPlugin } from "./hotkeyRecorderPlugin.js";
5
+ import { AlpineAppHotkeyOptions, AlpineCreateHotkey, AlpineCreateHotkeyRecorder, AlpineCustomHotkeys, AlpineHotkeyCommonOptions, AlpineHotkeyDefinition, AlpineHotkeyOptionsFor, AlpineHotkeyRecorder, AlpineHotkeyState, AlpineHotkeyTarget, AlpineHotkeys, DefaultHotkeysOptions, HotkeyRegistrationsResult, MaybeGetter } from "./types.js";
6
6
  export * from "@tanstack/hotkeys";
7
7
  export { AlpineAppHotkeyOptions, AlpineCreateHotkey, AlpineCreateHotkeyRecorder, AlpineCustomHotkeys, AlpineHotkeyCommonOptions, AlpineHotkeyDefinition, AlpineHotkeyOptionsFor, AlpineHotkeyRecorder, AlpineHotkeyState, AlpineHotkeyTarget, AlpineHotkeys, DefaultHotkeysOptions, HotkeyRegistrationsResult, MaybeGetter, createHotkeyRecorder, createHotkeysScope, hotkeyRecorderPlugin, hotkeysPlugin };
package/dist/scope.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import "./types.js";
2
2
  import "@tanstack/hotkeys";
3
3
  import "@tanstack/hotkeys/adapter";
4
- import Alpine from "alpinejs";
4
+ import "alpinejs";
package/dist/scope.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getHotkeyManager } from "@tanstack/hotkeys";
2
2
  import { subscribePublishedAppHotkeys } from "@tanstack/hotkeys/adapter";
3
3
 
4
- //#region src/scope.ts
4
+ // src/scope.ts
5
5
  let pluginAlpine;
6
6
  /** Records the Alpine instance passed to `hotkeysPlugin`. */
7
7
  function setAlpine(alpine) {
@@ -9,7 +9,7 @@ function setAlpine(alpine) {
9
9
  }
10
10
  function getAlpine() {
11
11
  const alpine = pluginAlpine ?? globalThis.Alpine;
12
- if (!alpine) throw new Error("[TanStack Hotkeys] Alpine was not found. Call Alpine.plugin(hotkeysPlugin) before Alpine.start(), or set window.Alpine.");
12
+ if (!alpine) throw new Error("[hotkeys] Alpine not found. Call Alpine.plugin(hotkeysPlugin) before Alpine.start(), or set window.Alpine");
13
13
  return alpine;
14
14
  }
15
15
  /** The internal scope behind each `createHotkeysScope` owner. */
@@ -28,7 +28,7 @@ function createScope(defaultOptions) {
28
28
  const cleanups = /* @__PURE__ */ new Set();
29
29
  let destroyed = false;
30
30
  function assertActive() {
31
- if (destroyed) throw new Error("Cannot use a destroyed hotkeys scope");
31
+ if (destroyed) throw new Error("[hotkeys] Cannot use a destroyed hotkeys scope");
32
32
  }
33
33
  function effect(callback) {
34
34
  assertActive();
@@ -95,5 +95,4 @@ function createScope(defaultOptions) {
95
95
  };
96
96
  }
97
97
 
98
- //#endregion
99
98
  export { createScope, ownerScopes, read, scopeOf, setAlpine };
package/dist/types.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { AppHotkey, AppHotkeyListItem, CustomHotkeys, HeldModifierOptions, Hotkey, HotkeyCallback, HotkeyCallbackContextFor, HotkeyChord, HotkeyChordRecorderOptions, HotkeyRecorderOptions, HotkeyRegistrationView, HotkeyScopesState, HotkeySequence, HotkeySequenceRecorderOptions, IndividualKey, RegisterableHotkey, RegisteredAppHotkeys, Target } from "@tanstack/hotkeys";
2
2
  import { AdapterAppHotkeyOptions, AdapterCommonOptions, AdapterHotkeyDefinition, AdapterOptionsFor } from "@tanstack/hotkeys/adapter";
3
- //#region src/types.d.ts
4
3
  /** A reactive value. Read `.value` where the framework tracks dependencies. */
5
4
  export interface AlpineHotkeyState<T> {
6
5
  readonly value: T;
@@ -108,5 +107,4 @@ export interface DefaultHotkeysOptions {
108
107
  hotkey?: AlpineHotkeyCommonOptions;
109
108
  /** Defaults for every recorder. */
110
109
  hotkeyRecorder?: Partial<Omit<HotkeyChordRecorderOptions & HotkeySequenceRecorderOptions, 'maxSteps' | 'onRecord' | 'validate'>>;
111
- }
112
- //#endregion
110
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/alpine-hotkeys",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "description": "Alpine adapter for TanStack Hotkeys",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -35,20 +35,20 @@
35
35
  "skills"
36
36
  ],
37
37
  "dependencies": {
38
- "@tanstack/hotkeys": "0.23.0"
38
+ "@tanstack/hotkeys": "0.25.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/alpinejs": "^3.17.0",
42
- "alpinejs": "^3.17.4"
42
+ "alpinejs": "^3.17.5"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "alpinejs": "^3.13.0"
46
46
  },
47
47
  "scripts": {
48
48
  "clean": "premove ./build ./dist",
49
- "lint": "eslint ./src",
50
- "lint:fix": "eslint ./src --fix",
51
- "test:eslint": "eslint ./src",
49
+ "lint": "oxlint ./src",
50
+ "lint:fix": "oxlint ./src --fix",
51
+ "test:oxlint": "oxlint ./src",
52
52
  "test:lib": "vitest --passWithNoTests",
53
53
  "test:lib:dev": "pnpm test:lib --watch",
54
54
  "test:types": "tsc",
@@ -34,8 +34,8 @@ requires:
34
34
  Before starting, load the `@tanstack/hotkeys#hotkeys-core` skill (`npx @tanstack/intent@latest load @tanstack/hotkeys#hotkeys-core`).
35
35
 
36
36
  ```ts no-check
37
- import Alpine from 'alpinejs'
38
37
  import { createHotkeysScope, hotkeysPlugin } from '@tanstack/alpine-hotkeys'
38
+ import Alpine from 'alpinejs'
39
39
 
40
40
  Alpine.plugin(hotkeysPlugin) // before Alpine.start()
41
41
 
@@ -35,12 +35,12 @@ The app hotkey methods throw until `provideAppHotkeys` has run. When saved short
35
35
  A settings row records with `createHotkeyRecorder` on its owner:
36
36
 
37
37
  ```ts
38
- import Alpine from 'alpinejs'
39
38
  import {
40
39
  createHotkeyRecorder,
41
40
  createHotkeysScope,
42
41
  formatForDisplay,
43
42
  } from '@tanstack/alpine-hotkeys'
43
+ import Alpine from 'alpinejs'
44
44
  import type { AppHotkeyId } from '@tanstack/alpine-hotkeys'
45
45
 
46
46
  Alpine.data('shortcutRow', (id: AppHotkeyId) => {