- renaming done
This commit is contained in:
Danya H 2024-10-28 17:40:25 +00:00
parent d9b917c024
commit d8df9fa7ef
4 changed files with 11 additions and 11 deletions

View File

@ -35,19 +35,19 @@ export class Player {
>(eventName, args)
}
public async triggerBrowser<EventName extends T.RageFW_CefEvent>(
public async triggerBrowser<EventName extends T.RageFW_BrowserEvent>(
eventName: EventName,
...args: T._CefEventHasArgs<EventName> extends true
? [T.RageFW_CefArgs<EventName>]
...args: T._BrowserEventHasArgs<EventName> extends true
? [T.RageFW_BrowserArgs<EventName>]
: []
): Promise<T.RageFW_CefReturn<EventName>> {
): Promise<T.RageFW_BrowserReturn<EventName>> {
if (!this._browser)
throw new Error('You need to initialize browser first')
return await rpc.callBrowser<
typeof args,
EventName,
T.RageFW_CefReturn<EventName>
T.RageFW_BrowserReturn<EventName>
>(eventName, args)
}
}

View File

@ -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<K extends RageFW_CefEvent> = Parameters<
export type RageFW_BrowserArgs<K extends RageFW_BrowserEvent> = Parameters<
RageFW_ICustomBrowserEvent[K]
>
export type RageFW_CefReturn<K extends RageFW_CefEvent> = ReturnType<
export type RageFW_BrowserReturn<K extends RageFW_BrowserEvent> = ReturnType<
RageFW_ICustomBrowserEvent[K]
>
export type _CefEventHasArgs<
export type _BrowserEventHasArgs<
EventName extends keyof RageFW_ICustomBrowserEvent,
> = keyof RageFW_ICustomBrowserEvent extends never
? false

View File

@ -15,7 +15,7 @@ export class Player {
public async triggerBrowser<EventName extends T.RageFW_BrowserEvent>(
player: PlayerMp,
eventName: EventName,
...args: T._CefEventHasArgs<EventName> extends true
...args: T._BrowserEventHasArgs<EventName> extends true
? [T.RageFW_BrowserArgs<EventName>]
: []
): Promise<T.RageFW_BrowserReturn<EventName>> {

View File

@ -25,7 +25,7 @@ export type RageFW_BrowserReturn<K extends RageFW_BrowserEvent> = ReturnType<
/**
*
*/
export type _CefEventHasArgs<
export type _BrowserEventHasArgs<
EventName extends keyof RageFW_ICustomBrowserEvent,
> = keyof RageFW_ICustomBrowserEvent extends never
? false