diff --git a/rpc/src/core/client.ts b/rpc/src/core/client.ts index 09b00ff..12d5a55 100644 --- a/rpc/src/core/client.ts +++ b/rpc/src/core/client.ts @@ -18,20 +18,6 @@ import { } from '../utils/types' import { Wrapper } from './wrapper' -declare function onNet(eventName: string, callback: Function): void -declare function emitNet(eventName: string, ...args: unknown[]): void -declare function on(eventName: string, callback: Function): void -declare function RegisterNuiCallbackType(callbackType: string): void -declare function GetPlayerServerId(player: number): number -declare function PlayerId(): number -declare function SetNuiFocus(hasFocus: boolean, hasCursor: boolean): void -declare function RegisterCommand( - commandName: string, - handler: Function, - restricted: boolean, -): void -declare function SendNuiMessage(jsonString: string): boolean - export class RPCInstanceClient extends Wrapper { private readonly _emitterServer: Emitter private readonly _pendingServer: Emitter diff --git a/rpc/src/core/server.ts b/rpc/src/core/server.ts index 26407f0..8cb72fc 100644 --- a/rpc/src/core/server.ts +++ b/rpc/src/core/server.ts @@ -13,15 +13,6 @@ import { } from '../utils/types' import { Wrapper } from './wrapper' -declare function onNet(eventName: string, callback: Function): void -declare function emitNet(eventName: string, ...args: unknown[]): void -declare function on(eventName: string, callback: Function): void -declare function RegisterCommand( - commandName: string, - handler: Function, - restricted: boolean, -): void - export class RPCInstanceServer extends Wrapper { private readonly _emitterClient: Emitter private readonly _pendingClient: Emitter diff --git a/rpc/src/core/webview.ts b/rpc/src/core/webview.ts index 837fadb..4f0a1d5 100644 --- a/rpc/src/core/webview.ts +++ b/rpc/src/core/webview.ts @@ -11,12 +11,6 @@ import { } from '../utils/types' import { Wrapper } from './wrapper' -declare global { - interface Window { - GetParentResourceName?: () => string - } -} - export class RPCInstanceWebview extends Wrapper { private readonly _emitterClient: Emitter private readonly _emitterServer: Emitter diff --git a/rpc/src/fivem.d.ts b/rpc/src/fivem.d.ts new file mode 100644 index 0000000..3d9a00a --- /dev/null +++ b/rpc/src/fivem.d.ts @@ -0,0 +1,36 @@ +/* +FiveM runtime globals used by this library. Internal: not part of the published types, so consumers are free to use @citizenfx/*. +See https://docs.fivem.net/docs/scripting-reference/runtimes/javascript/ +*/ + +// ===== SHARED (client + server) ===== + +declare function on( + eventName: string, + callback: (...args: A) => unknown, +): void +declare function onNet( + eventName: string, + callback: (...args: A) => unknown, +): void +/** Server: `emitNet(eventName, target, ...args)` */ +declare function emitNet(eventName: string, ...args: unknown[]): void +declare function RegisterCommand( + commandName: string, + handler: (source: number, args: A, rawCommand: string) => unknown, + restricted: boolean, +): void + +// ===== CLIENT ===== + +declare function RegisterNuiCallbackType(callbackType: string): void +declare function GetPlayerServerId(player: number): number +declare function PlayerId(): number +declare function SetNuiFocus(hasFocus: boolean, hasCursor: boolean): void +declare function SendNuiMessage(jsonString: string): boolean + +// ===== WEBVIEW (NUI) ===== + +interface Window { + GetParentResourceName?: () => string +}