@mafiahub/types 0.1.2 → 0.1.4

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.
@@ -14,6 +14,7 @@ declare namespace Core {
14
14
  inverse(): Quaternion;
15
15
  dot(other: Quaternion): number;
16
16
  rotateVector(v: Vector3): Vector3;
17
+ /** Euler angles in radians (x=pitch, y=yaw, z=roll). */
17
18
  toEuler(): Vector3;
18
19
  set(w: number, x: number, y: number, z: number): this;
19
20
  clone(): Quaternion;
@@ -21,6 +22,7 @@ declare namespace Core {
21
22
  toJSON(): { w: number; x: number; y: number; z: number };
22
23
 
23
24
  static identity(): Quaternion;
25
+ /** From euler angles in radians. */
24
26
  static fromEuler(pitch: number, yaw: number, roll: number): Quaternion;
25
27
  static fromAxisAngle(axis: Vector3, angle: number): Quaternion;
26
28
  }
@@ -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
@@ -7,3 +7,4 @@
7
7
  /// <reference path="framework/messages.d.ts" />
8
8
  /// <reference path="framework/imports.d.ts" />
9
9
  /// <reference path="framework/exports.d.ts" />
10
+ /// <reference path="framework/key.d.ts" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mafiahub/types",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "TypeScript type definitions for the MafiaHub Framework scripting API",
5
5
  "types": "index.d.ts",
6
6
  "files": [