feat(rpc): rework shared-types + include as mandatory dep

This commit is contained in:
2026-09-28 02:05:40 +01:00
parent 3e3548a9cc
commit 8029f24e9d
9 changed files with 235 additions and 222 deletions
+58
View File
@@ -0,0 +1,58 @@
/**
* Event and command declarations for `@entityseven/fivem-rpc`.
*
* Every interface starts empty: until you declare something in it, the matching
* rpc methods accept any name and any arguments. Declare your own by augmenting
* this module from any `.d.ts` (or `.ts`) file included in your project:
*
* @example
* // shared/rpc.d.ts
* import '@entityseven/fivem-rpc-shared-types'
*
* declare module '@entityseven/fivem-rpc-shared-types' {
* interface RPCEvents_ClientServer {
* // name(arguments): value returned by the listener
* buyItem(item: string, amount: number): boolean
* }
* interface RPCCommands_Server {
* ban: true
* }
* }
*/
// ===== COMMANDS (names are the keys, values are not used) =====
/** Commands registered with `rpc.onCommand` on the client */
export interface RPCCommands_Client {}
/** Commands registered with `rpc.onCommand` on the server */
export interface RPCCommands_Server {}
// ===== EVENTS (caller -> receiver) =====
/** Client -> client: `emitSelf` / `onSelf` on the client */
export interface RPCEvents_Client {}
/** Client -> server: `emitServer` on the client, `onClient` on the server */
export interface RPCEvents_ClientServer {}
/** Client -> webview: `emitWebview` on the client, `onClient` on the webview */
export interface RPCEvents_ClientWebview {}
/** Server -> server: `emitSelf` / `onSelf` on the server */
export interface RPCEvents_Server {}
/** Server -> client: `emitClient` on the server, `onServer` on the client */
export interface RPCEvents_ServerClient {}
/** Server -> webview: `emitWebview` on the server, `onServer` on the webview */
export interface RPCEvents_ServerWebview {}
/** Webview -> webview: `emitSelf` / `onSelf` on the webview */
export interface RPCEvents_Webview {}
/** Webview -> client: `emitClient` on the webview, `onWebview` on the client */
export interface RPCEvents_WebviewClient {}
/** Webview -> server: `emitServer` on the webview, `onWebview` on the server */
export interface RPCEvents_WebviewServer {}