@mafiahub/types 0.1.0 → 0.1.3
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/framework/key.d.ts +57 -0
- package/index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
declare namespace Framework {
|
|
2
|
+
/**
|
|
3
|
+
* Client-side keybinding API. **Client only** — not available on the server.
|
|
4
|
+
*
|
|
5
|
+
* Binds a physical key to a handler that fires on key-down, key-up, or both
|
|
6
|
+
* edges. Binds are resource-owned: they are cleared automatically when the
|
|
7
|
+
* resource stops. Handlers only fire while the game is in the foreground and
|
|
8
|
+
* no UI (chat box, menu, focused web view) is capturing input.
|
|
9
|
+
*
|
|
10
|
+
* Key names are case-insensitive. Recognised names:
|
|
11
|
+
* - Letters `a`–`z`, digits `0`–`9`
|
|
12
|
+
* - Function keys `f1`–`f12`
|
|
13
|
+
* - Arrows `up` `down` `left` `right`
|
|
14
|
+
* - Modifiers `shift` `lshift` `rshift`, `ctrl`/`control` `lctrl` `rctrl`,
|
|
15
|
+
* `alt` `lalt` `ralt`
|
|
16
|
+
* - Editing `space` `enter`/`return` `escape`/`esc` `tab` `backspace`
|
|
17
|
+
* `insert` `delete` `home` `end` `pageup` `pagedown` `capslock`
|
|
18
|
+
* - Numpad `numpad0`–`numpad9` (aliases `num0`–`num9`)
|
|
19
|
+
* - Mouse `mouse1` (left) `mouse2` (right) `mouse3` (middle) `mouse4` `mouse5`
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Toggle a HUD on key-down:
|
|
23
|
+
* Framework.Key.bind("f6", "down", () => toggleHud());
|
|
24
|
+
*
|
|
25
|
+
* // Hold-to-act (fires on both edges); state is "down" then "up":
|
|
26
|
+
* Framework.Key.bind("b", "both", (key, state) => setAiming(state === "down"));
|
|
27
|
+
*
|
|
28
|
+
* // State omitted defaults to "down":
|
|
29
|
+
* Framework.Key.bind("h", () => honk());
|
|
30
|
+
*/
|
|
31
|
+
const Key: {
|
|
32
|
+
/**
|
|
33
|
+
* Bind a handler to a key.
|
|
34
|
+
* @param key Case-insensitive key name (see the {@link Key} table).
|
|
35
|
+
* @param state `"down"`, `"up"`, or `"both"`. If omitted, defaults to `"down"`.
|
|
36
|
+
* @param handler Called as `handler(key, state)` where `state` is the actual
|
|
37
|
+
* edge that fired (`"down"` or `"up"`).
|
|
38
|
+
* @returns `true` once bound. Throws on an unknown key name or bad state.
|
|
39
|
+
*/
|
|
40
|
+
bind(key: string, state: "down" | "up" | "both", handler: (key: string, state: "down" | "up") => void): boolean;
|
|
41
|
+
bind(key: string, handler: (key: string, state: "down" | "up") => void): boolean;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Remove binds for a key. With no filters, removes every handler on that key.
|
|
45
|
+
* @param state Optional: only remove binds registered with this state.
|
|
46
|
+
* @param handler Optional: only remove this exact handler function.
|
|
47
|
+
* @returns `true` if at least one bind was removed.
|
|
48
|
+
*/
|
|
49
|
+
unbind(key: string, state?: "down" | "up" | "both", handler?: (key: string, state: "down" | "up") => void): boolean;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Live physical state of a key. Returns `false` while UI owns input or the
|
|
53
|
+
* game window is in the background (same gate as bind dispatch).
|
|
54
|
+
*/
|
|
55
|
+
isDown(key: string): boolean;
|
|
56
|
+
};
|
|
57
|
+
}
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mafiahub/types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "TypeScript type definitions for the MafiaHub Framework scripting API",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/MafiaHub/Framework.git",
|
|
13
|
+
"url": "git+https://github.com/MafiaHub/Framework.git",
|
|
14
14
|
"directory": "types"
|
|
15
15
|
},
|
|
16
16
|
"license": "SEE LICENSE IN ../LICENSE",
|