@tanstack/hotkeys-devtools 1.6.0 → 1.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/_trigger.js +41 -0
- package/dist/components/ActionButtons.js +2 -2
- package/dist/components/HeldKeysTopbar.js +1 -1
- package/dist/core.d.ts +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/production.d.ts +2 -1
- package/dist/types.d.ts +21 -0
- package/package.json +4 -4
package/dist/_trigger.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { HotkeyManager } from "@tanstack/hotkeys";
|
|
2
|
+
|
|
3
|
+
//#region src/_trigger.ts
|
|
4
|
+
/**
|
|
5
|
+
* Runs a registration's callback as if its hotkey, or a sequence's last step,
|
|
6
|
+
* was pressed, and counts it like a real press. The event names the physical
|
|
7
|
+
* code for physical bindings and the key otherwise.
|
|
8
|
+
*
|
|
9
|
+
* @returns False when no registration has the id
|
|
10
|
+
*/
|
|
11
|
+
function triggerRegistration(id, manager = HotkeyManager.getInstance()) {
|
|
12
|
+
const registration = manager.registrations.state.get(id);
|
|
13
|
+
if (!registration) return false;
|
|
14
|
+
const context = registration.kind === "chord" ? {
|
|
15
|
+
kind: "chord",
|
|
16
|
+
hotkey: registration.hotkey,
|
|
17
|
+
parsedChord: registration.parsedChord
|
|
18
|
+
} : {
|
|
19
|
+
kind: "sequence",
|
|
20
|
+
hotkey: registration.hotkey,
|
|
21
|
+
parsedSequence: registration.parsedSequence
|
|
22
|
+
};
|
|
23
|
+
const parsed = registration.kind === "chord" ? registration.parsedChord : registration.parsedSequence[registration.parsedSequence.length - 1];
|
|
24
|
+
const event = new KeyboardEvent(registration.options.eventType ?? "keydown", {
|
|
25
|
+
...parsed.code !== void 0 ? { code: parsed.code } : { key: parsed.key },
|
|
26
|
+
ctrlKey: parsed.ctrl,
|
|
27
|
+
shiftKey: parsed.shift,
|
|
28
|
+
altKey: parsed.alt,
|
|
29
|
+
metaKey: parsed.meta,
|
|
30
|
+
bubbles: true,
|
|
31
|
+
cancelable: true
|
|
32
|
+
});
|
|
33
|
+
registration.triggerCount++;
|
|
34
|
+
if (registration.kind === "sequence") registration.hasFired = true;
|
|
35
|
+
manager.registrations.setState((prev) => new Map(prev));
|
|
36
|
+
registration.callback(event, context);
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { triggerRegistration };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useStyles } from "../styles/use-styles.js";
|
|
2
|
+
import { triggerRegistration } from "../_trigger.js";
|
|
2
3
|
import { className, delegateEvents, effect, template } from "solid-js/web";
|
|
3
|
-
import { HotkeyManager } from "@tanstack/hotkeys";
|
|
4
4
|
|
|
5
5
|
//#region src/components/ActionButtons.tsx
|
|
6
6
|
var _tmpl$ = /*#__PURE__*/ template(`<div><button><span></span>Trigger`);
|
|
7
7
|
function ActionButtons(props) {
|
|
8
8
|
const styles = useStyles();
|
|
9
9
|
const handleTrigger = () => {
|
|
10
|
-
|
|
10
|
+
triggerRegistration(props.registration.id);
|
|
11
11
|
};
|
|
12
12
|
return (() => {
|
|
13
13
|
var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HotkeysDevtoolsCoreClass } from "./types.js";
|
|
2
2
|
//#region src/core.d.ts
|
|
3
3
|
export interface HotkeysDevtoolsInit {}
|
|
4
|
-
export declare const HotkeysDevtoolsCore:
|
|
4
|
+
export declare const HotkeysDevtoolsCore: HotkeysDevtoolsCoreClass;
|
|
5
5
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { HotkeysDevtoolsCoreClass, HotkeysDevtoolsPanelProps, HotkeysDevtoolsTheme } from "./types.js";
|
|
1
2
|
import { HotkeysDevtoolsInit } from "./core.js";
|
|
2
|
-
import { ClassType } from "@tanstack/devtools-utils/solid";
|
|
3
3
|
//#region src/index.d.ts
|
|
4
|
-
export declare const HotkeysDevtoolsCore:
|
|
4
|
+
export declare const HotkeysDevtoolsCore: HotkeysDevtoolsCoreClass;
|
|
5
5
|
//#endregion
|
|
6
|
-
export type { HotkeysDevtoolsInit };
|
|
6
|
+
export type { HotkeysDevtoolsCoreClass, HotkeysDevtoolsInit, HotkeysDevtoolsPanelProps, HotkeysDevtoolsTheme };
|
package/dist/production.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { HotkeysDevtoolsCoreClass, HotkeysDevtoolsPanelProps, HotkeysDevtoolsTheme } from "./types.js";
|
|
1
2
|
import { HotkeysDevtoolsCore, HotkeysDevtoolsInit } from "./core.js";
|
|
2
|
-
export { HotkeysDevtoolsCore, type HotkeysDevtoolsInit };
|
|
3
|
+
export { HotkeysDevtoolsCore, type HotkeysDevtoolsCoreClass, type HotkeysDevtoolsInit, type HotkeysDevtoolsPanelProps, type HotkeysDevtoolsTheme };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
/** The devtools color theme. */
|
|
3
|
+
export type HotkeysDevtoolsTheme = 'light' | 'dark';
|
|
4
|
+
/**
|
|
5
|
+
* Props a devtools host passes to the Hotkeys panel.
|
|
6
|
+
*
|
|
7
|
+
* These match `TanStackDevtoolsPluginProps` from `@tanstack/devtools`. They
|
|
8
|
+
* are declared here because the `@tanstack/devtools-utils` types import
|
|
9
|
+
* `@tanstack/devtools` without depending on it, so published types that use
|
|
10
|
+
* them fail to resolve.
|
|
11
|
+
*/
|
|
12
|
+
export interface HotkeysDevtoolsPanelProps {
|
|
13
|
+
theme: HotkeysDevtoolsTheme;
|
|
14
|
+
devtoolsOpen: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** The class each framework panel creates and mounts the devtools with. */
|
|
17
|
+
export type HotkeysDevtoolsCoreClass = new () => {
|
|
18
|
+
mount: (el: HTMLElement, props: HotkeysDevtoolsPanelProps) => Promise<void>;
|
|
19
|
+
unmount: () => void;
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/hotkeys-devtools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Devtools for TanStack Hotkeys",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@tanstack/hotkeys": "0.
|
|
39
|
+
"@tanstack/hotkeys": "0.20.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@tanstack/devtools-ui": "^0.7.
|
|
43
|
-
"@tanstack/devtools-utils": "^0.7.
|
|
42
|
+
"@tanstack/devtools-ui": "^0.7.2",
|
|
43
|
+
"@tanstack/devtools-utils": "^0.7.2",
|
|
44
44
|
"clsx": "^2.1.1",
|
|
45
45
|
"goober": "^2.1.19",
|
|
46
46
|
"match-sorter": "^8.3.0",
|