@cybermp-community/client-types 2.4.2 → 2.5.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.
@@ -1,4 +1,5 @@
1
1
 
2
+ // biome-ignore-all lint: Precomputed
2
3
  import type { UnwrapClass } from '../../game.d.ts';
3
4
  import type { MpClasses } from '../../mp-classes.d.ts';
4
5
  import * as CyberEnums from '../../enums';
@@ -1,3 +1,5 @@
1
+ import type { MpEventsMap } from "./map";
2
+
1
3
  type Args = any[];
2
4
 
3
5
  export interface MpEvents {
@@ -6,14 +8,22 @@ export interface MpEvents {
6
8
  * @param eventName Name of the event.
7
9
  * @param callback Callback function.
8
10
  */
9
- on<T extends Array = Args>(eventName: string, callback: (...args: T) => void): void;
11
+
12
+ on<E extends keyof MpEventsMap>(eventName: E, callback: MpEventsMap[E]): void;
13
+ on<T extends unknown[] = Args>(
14
+ eventName: string,
15
+ callback: (...args: T) => void,
16
+ ): void;
10
17
 
11
18
  /**
12
19
  * UnRegister a custom event listener.
13
20
  * @param eventName Name of the event.
14
21
  * @param callback Callback function.
15
22
  */
16
- off<T extends Array = Args>(eventName: string, callback: (...args: T) => void): void;
23
+ off<T extends unknown[] = Args>(
24
+ eventName: string,
25
+ callback: (...args: T) => void,
26
+ ): void;
17
27
 
18
28
  /**
19
29
  * Emit a previously registered custom event.
@@ -21,37 +31,45 @@ export interface MpEvents {
21
31
  * @param eventName Name of the event.
22
32
  * @param args Arguments to pass.
23
33
  */
24
- emit<T extends Array = Args>(eventName: string, ...args: T): void;
34
+ emit<T extends unknown[] = Args>(eventName: string, ...args: T): void;
25
35
 
26
36
  /**
27
37
  * Register a listener for server event on client.
28
38
  */
29
- onServer<T extends Array = Args>(eventName: string, callback: (...args: T) => void): void;
39
+ onServer<T extends unknown[] = Args>(
40
+ eventName: string,
41
+ callback: (...args: T) => void,
42
+ ): void;
30
43
 
31
44
  /**
32
45
  * Emit an event to the server.
33
46
  */
34
- emitServer<T extends Array = Args>(eventName: string, ...args: T): void;
47
+ emitServer<T extends unknown[] = Args>(eventName: string, ...args: T): void;
35
48
 
36
49
  /**
37
50
  * Emit an event to the cef.
38
51
  */
39
- emitCef<T extends Array = Args>(eventName: string, ...args: T): void;
52
+ emitCef<T extends unknown[] = Args>(eventName: string, ...args: T): void;
40
53
 
41
54
  /**
42
55
  * Register a custom cef event listener.
43
56
  * @param eventName Name of the event.
44
57
  * @param callback Callback function.
45
58
  */
46
- onCef<T extends Array = Args>(eventName: string, callback: (...args: T) => void): void;
59
+ onCef<T extends unknown[] = Args>(
60
+ eventName: string,
61
+ callback: (...args: T) => void,
62
+ ): void;
47
63
 
48
64
  /**
49
65
  * Register a command in the client scope.
50
66
  * @param commandName Command name without "/".
51
67
  * @param callback Callback with id and args.
52
68
  */
53
- addCommand(
69
+ addCommand<T extends string[] = string[]>(
54
70
  commandName: string,
55
- callback: (id: number, args: string[]) => void,
71
+ callback: (id: number, args: T) => void,
56
72
  ): void;
57
73
  }
74
+
75
+ export * from "./map";
@@ -0,0 +1,19 @@
1
+ export interface MpEventsMap {
2
+ globalMetaChange<T = any, K = T>(
3
+ key: string,
4
+ newValue: T,
5
+ oldValue: K,
6
+ ): undefined | boolean;
7
+ playerMetaChange<T = any, K = T>(
8
+ netId: number,
9
+ key: string,
10
+ newValue: T,
11
+ oldValue: K,
12
+ ): undefined | boolean;
13
+ entityMetaChange<T = any, K = T>(
14
+ netId: number,
15
+ key: string,
16
+ newValue: T,
17
+ oldValue: K,
18
+ ): undefined | boolean;
19
+ }
@@ -0,0 +1,9 @@
1
+ export type * from './classes';
2
+ export type * from './cef';
3
+ export type * from './discord';
4
+ export type * from './events';
5
+ export type * from './game';
6
+ export type * from './local-storage';
7
+ export type * from './meta';
8
+ export type * from './mp';
9
+ export type * from './voice-chat';
@@ -1,6 +1,6 @@
1
1
  import type { MpCef } from './cef.d.ts';
2
2
  import type { MpDiscord } from './discord.d.ts';
3
- import type { MpEvents } from './events.d.ts';
3
+ import type { MpEvents } from './events/index.js';
4
4
  import type { MpLocalStorage } from './local-storage.d.ts';
5
5
  import type { MpMeta } from './meta.d.ts';
6
6
  import type { MpVoiceChat } from './voice-chat.d.ts';
@@ -1,3 +1,5 @@
1
+ // @ts-expect-error: Precomputed
2
+ // biome-ignore lint/style/useImportType: Precomputed
1
3
  import * as CyberEnums from '../enums';
2
4
 
3
5
  export interface MpVoiceChat {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cybermp-community/client-types",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
4
4
  "description": "TypeScript type definitions for the CyberMP client-side environment.",
5
5
  "license": "CC BY-SA 4.0",
6
6
  "author": {
@@ -1,9 +0,0 @@
1
- export type * from './classes';
2
- export type * from './cef.d.ts';
3
- export type * from './discord.d.ts';
4
- export type * from './events.d.ts';
5
- export type * from './game.d.ts';
6
- export type * from './local-storage.d.ts';
7
- export type * from './meta.d.ts';
8
- export type * from './mp.d.ts';
9
- export type * from './voice-chat.d.ts';
File without changes
File without changes
File without changes
File without changes