diff --git a/client/src/core/player.ts b/client/src/core/player.ts index 3572715..e4949f0 100644 --- a/client/src/core/player.ts +++ b/client/src/core/player.ts @@ -35,19 +35,19 @@ export class Player { >(eventName, args) } - public async triggerBrowser( + public async triggerBrowser( eventName: EventName, - ...args: T._CefEventHasArgs extends true - ? [T.RageFW_CefArgs] + ...args: T._BrowserEventHasArgs extends true + ? [T.RageFW_BrowserArgs] : [] - ): Promise> { + ): Promise> { if (!this._browser) throw new Error('You need to initialize browser first') return await rpc.callBrowser< typeof args, EventName, - T.RageFW_CefReturn + T.RageFW_BrowserReturn >(eventName, args) } } diff --git a/client/src/types/browser.ts b/client/src/types/browser.ts index a4b343d..27292f7 100644 --- a/client/src/types/browser.ts +++ b/client/src/types/browser.ts @@ -6,21 +6,21 @@ import type { RageFW_ICustomBrowserEvent } from '@entityseven/rage-fw-shared-typ * Union of all available browser event names callable from client * These only include custom events */ -export type RageFW_CefEvent = keyof RageFW_ICustomBrowserEvent +export type RageFW_BrowserEvent = keyof RageFW_ICustomBrowserEvent /** * Array of arguments for an event, name of which you pass as a generic * These only include custom events */ -export type RageFW_CefArgs = Parameters< +export type RageFW_BrowserArgs = Parameters< RageFW_ICustomBrowserEvent[K] > -export type RageFW_CefReturn = ReturnType< +export type RageFW_BrowserReturn = ReturnType< RageFW_ICustomBrowserEvent[K] > -export type _CefEventHasArgs< +export type _BrowserEventHasArgs< EventName extends keyof RageFW_ICustomBrowserEvent, > = keyof RageFW_ICustomBrowserEvent extends never ? false diff --git a/server/src/core/player.ts b/server/src/core/player.ts index 2838221..571fd1f 100644 --- a/server/src/core/player.ts +++ b/server/src/core/player.ts @@ -15,7 +15,7 @@ export class Player { public async triggerBrowser( player: PlayerMp, eventName: EventName, - ...args: T._CefEventHasArgs extends true + ...args: T._BrowserEventHasArgs extends true ? [T.RageFW_BrowserArgs] : [] ): Promise> { diff --git a/server/src/types/browser.ts b/server/src/types/browser.ts index eb410a0..41c4f29 100644 --- a/server/src/types/browser.ts +++ b/server/src/types/browser.ts @@ -25,7 +25,7 @@ export type RageFW_BrowserReturn = ReturnType< /** * */ -export type _CefEventHasArgs< +export type _BrowserEventHasArgs< EventName extends keyof RageFW_ICustomBrowserEvent, > = keyof RageFW_ICustomBrowserEvent extends never ? false