mirror of
https://github.com/rilaxik/fivem-rpc.git
synced 2026-09-28 01:29:13 +00:00
feat(rpc): rework shared-types + include as mandatory dep
This commit is contained in:
Vendored
+58
@@ -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 {}
|
||||
@@ -28,12 +28,17 @@
|
||||
"directory": "shared-types"
|
||||
},
|
||||
"files": [
|
||||
"types/**/*",
|
||||
"index.d.ts",
|
||||
"readme.md",
|
||||
"license.md"
|
||||
],
|
||||
"type": "module",
|
||||
"types": "types/types/index.d.ts",
|
||||
"types": "./index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=5"
|
||||
},
|
||||
|
||||
Vendored
-52
@@ -1,52 +0,0 @@
|
||||
declare module '@entityseven/fivem-rpc-shared-types' {
|
||||
// Client commands names
|
||||
export type RPCCommands_Client = ''
|
||||
|
||||
// Server commands names
|
||||
export type RPCCommands_Server = ''
|
||||
|
||||
// Client -> Client events
|
||||
export interface RPCEvents_Client {
|
||||
_(): void
|
||||
}
|
||||
|
||||
// Client -> Server events
|
||||
export interface RPCEvents_ClientServer {
|
||||
_(): void
|
||||
}
|
||||
|
||||
// Client -> Webview events
|
||||
export interface RPCEvents_ClientWebview {
|
||||
_(): void
|
||||
}
|
||||
|
||||
// Server -> Server events
|
||||
export interface RPCEvents_Server {
|
||||
_(): void
|
||||
}
|
||||
|
||||
// Server -> Client events
|
||||
export interface RPCEvents_ServerClient {
|
||||
_(): void
|
||||
}
|
||||
|
||||
// Server -> Server events
|
||||
export interface RPCEvents_ServerWebview {
|
||||
_(): void
|
||||
}
|
||||
|
||||
// Webview -> Webview events
|
||||
export interface RPCEvents_Webview {
|
||||
_(): void
|
||||
}
|
||||
|
||||
// Webview -> Client events
|
||||
export interface RPCEvents_WebviewClient {
|
||||
_(): void
|
||||
}
|
||||
|
||||
// Webview -> Server events
|
||||
export interface RPCEvents_WebviewServer {
|
||||
_(): void
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user