types docs

This commit is contained in:
Danya H 2024-06-12 00:03:44 +01:00
parent 234bcecc7b
commit bad4d532f6
5 changed files with 106 additions and 0 deletions

View File

@ -12,34 +12,76 @@ export type {
RageFW_ICustomClientEvent, RageFW_ICustomClientEvent,
} from 'rage-fw-shared-types' } from 'rage-fw-shared-types'
/**
* Union of all available cef event names
* These only include custom events
*/
export type RageFW_CefEvent = keyof RageFW_ICustomCefEvent export type RageFW_CefEvent = keyof RageFW_ICustomCefEvent
/**
* Union of all available server event names
* These only include custom events
*/
export type RageFW_ServerEvent = keyof RageFW_ICustomServerEvent export type RageFW_ServerEvent = keyof RageFW_ICustomServerEvent
/**
* Union of all available client event names
* These only include custom events
*/
export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent
/**
* Array of arguments of an event you pass as a generic
* These only include custom cef events
*/
export type RageFW_CefArguments<K extends RageFW_CefEvent> = Parameters< export type RageFW_CefArguments<K extends RageFW_CefEvent> = Parameters<
RageFW_ICustomCefEvent[K] RageFW_ICustomCefEvent[K]
> >
/**
* Return type of event you pass as a generic
* These only include custom cef events
*/
export type RageFW_CefReturn<K extends RageFW_CefEvent> = ReturnType< export type RageFW_CefReturn<K extends RageFW_CefEvent> = ReturnType<
RageFW_ICustomCefEvent[K] RageFW_ICustomCefEvent[K]
> >
/**
* Callback (function) of event you pass as a generic
* These only include custom cef events
*/
export type RageFW_CefCallback<K extends keyof RageFW_ICustomCefEvent> = ( export type RageFW_CefCallback<K extends keyof RageFW_ICustomCefEvent> = (
args: RageFW_CefArguments<K>, args: RageFW_CefArguments<K>,
) => RageFW_CefReturn<K> ) => RageFW_CefReturn<K>
/**
* Array of arguments of event you pass as a generic
* These only include custom server events
*/
export type RageFW_ServerArguments<K extends RageFW_ServerEvent> = Parameters< export type RageFW_ServerArguments<K extends RageFW_ServerEvent> = Parameters<
RageFW_ICustomServerEvent[K] RageFW_ICustomServerEvent[K]
> >
/**
* Return type of event you pass as a generic
* These only include custom server events
*/
export type RageFW_ServerReturn<K extends RageFW_ServerEvent> = ReturnType< export type RageFW_ServerReturn<K extends RageFW_ServerEvent> = ReturnType<
RageFW_ICustomServerEvent[K] RageFW_ICustomServerEvent[K]
> >
/**
* Array of arguments of event you pass as a generic
* These only include custom client events
*/
export type RageFW_ClientArguments<K extends RageFW_ClientEvent> = Parameters< export type RageFW_ClientArguments<K extends RageFW_ClientEvent> = Parameters<
RageFW_ICustomClientEvent[K] RageFW_ICustomClientEvent[K]
> >
/**
* Return type of event you pass as a generic
* These only include custom client events
*/
export type RageFW_ClientReturn<K extends RageFW_ClientEvent> = ReturnType< export type RageFW_ClientReturn<K extends RageFW_ClientEvent> = ReturnType<
RageFW_ICustomClientEvent[K] RageFW_ICustomClientEvent[K]
> >

View File

@ -2,15 +2,31 @@
import type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types' import type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types'
/**
* Union of all available client event names
* These only include custom events
*/
export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent
/**
* Array of arguments for an event, name of which you pass as a generic
* These only include custom events
*/
export type RageFW_ClientEventArguments<K extends RageFW_ClientEvent> = export type RageFW_ClientEventArguments<K extends RageFW_ClientEvent> =
Parameters<RageFW_ICustomClientEvent[K]> Parameters<RageFW_ICustomClientEvent[K]>
/**
* Callback (function) for an event, name of which you pass as a generic
* These only include custom events
*/
export type RageFW_ClientEventCallback<K extends RageFW_ClientEvent> = ( export type RageFW_ClientEventCallback<K extends RageFW_ClientEvent> = (
args: RageFW_ClientEventArguments<K>, args: RageFW_ClientEventArguments<K>,
) => RageFW_ClientEventReturn<K> ) => RageFW_ClientEventReturn<K>
/**
* Return type for an event, name of which you pass as a generic
* These only include custom events
*/
export type RageFW_ClientEventReturn<K extends RageFW_ClientEvent> = export type RageFW_ClientEventReturn<K extends RageFW_ClientEvent> =
K extends keyof RageFW_ICustomClientEvent K extends keyof RageFW_ICustomClientEvent
? ReturnType<RageFW_ICustomClientEvent[K]> ? ReturnType<RageFW_ICustomClientEvent[K]>

View File

@ -2,14 +2,26 @@
import type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types' import type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types'
/**
* Union of all available server event names callable from client
* These only include custom events
*/
export type RageFW_ClientServerEvent = keyof RageFW_ICustomServerEvent export type RageFW_ClientServerEvent = keyof RageFW_ICustomServerEvent
/**
* Array of arguments for an event, name of which you pass as a generic
* These only include custom events
*/
export type RageFW_ClientServerEventArguments< export type RageFW_ClientServerEventArguments<
K extends RageFW_ClientServerEvent, K extends RageFW_ClientServerEvent,
> = K extends keyof RageFW_ICustomServerEvent > = K extends keyof RageFW_ICustomServerEvent
? Parameters<RageFW_ICustomServerEvent[K]> ? Parameters<RageFW_ICustomServerEvent[K]>
: never : never
/**
* Return type for an event, name of which you pass as a generic
* These only include custom events
*/
export type RageFW_ClientServerEventReturn<K extends RageFW_ClientServerEvent> = export type RageFW_ClientServerEventReturn<K extends RageFW_ClientServerEvent> =
K extends keyof RageFW_ICustomServerEvent K extends keyof RageFW_ICustomServerEvent
? ReturnType<RageFW_ICustomServerEvent[K]> ? ReturnType<RageFW_ICustomServerEvent[K]>

View File

@ -2,13 +2,25 @@
import type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types' import type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types'
/**
* Union of all available client event names
* These only include custom events
*/
export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent
/**
* Array of arguments of an event you pass as a generic
* These only include custom events
*/
export type RageFW_ClientEventArguments<K extends RageFW_ClientEvent> = export type RageFW_ClientEventArguments<K extends RageFW_ClientEvent> =
K extends RageFW_ClientEvent K extends RageFW_ClientEvent
? Parameters<RageFW_ICustomClientEvent[K]> ? Parameters<RageFW_ICustomClientEvent[K]>
: never : never
/**
* Return type of event you pass as a generic
* These only include custom events
*/
export type RageFW_ClientEventReturn<K extends RageFW_ClientEvent> = export type RageFW_ClientEventReturn<K extends RageFW_ClientEvent> =
K extends RageFW_ClientEvent K extends RageFW_ClientEvent
? ReturnType<RageFW_ICustomClientEvent[K]> ? ReturnType<RageFW_ICustomClientEvent[K]>

View File

@ -3,10 +3,18 @@
import type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types' import type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types'
export type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types' export type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types'
/**
* Union of all available server event names
* These also include system events
*/
export type RageFW_ServerEvent = export type RageFW_ServerEvent =
| keyof RageFW_ICustomServerEvent | keyof RageFW_ICustomServerEvent
| keyof IServerEvents | keyof IServerEvents
/**
* Array of arguments for an event, name of which you pass as a generic
* These also include system events
*/
export type RageFW_ServerEventArguments<K extends RageFW_ServerEvent> = export type RageFW_ServerEventArguments<K extends RageFW_ServerEvent> =
K extends keyof RageFW_ICustomServerEvent K extends keyof RageFW_ICustomServerEvent
? Parameters<RageFW_ServerEventCallbackCustom<K>> ? Parameters<RageFW_ServerEventCallbackCustom<K>>
@ -14,6 +22,10 @@ export type RageFW_ServerEventArguments<K extends RageFW_ServerEvent> =
? Parameters<RageFW_ServerEventCallbackNative<K>> ? Parameters<RageFW_ServerEventCallbackNative<K>>
: never : never
/**
* Callback (function) for an event, name of which you pass as a generic
* These include system and custom events
*/
export type RageFW_ServerEventCallback<K extends RageFW_ServerEvent> = export type RageFW_ServerEventCallback<K extends RageFW_ServerEvent> =
K extends keyof RageFW_ICustomServerEvent K extends keyof RageFW_ICustomServerEvent
? RageFW_ServerEventCallbackCustom<K> ? RageFW_ServerEventCallbackCustom<K>
@ -21,6 +33,10 @@ export type RageFW_ServerEventCallback<K extends RageFW_ServerEvent> =
? RageFW_ServerEventCallbackNative<K> ? RageFW_ServerEventCallbackNative<K>
: never : never
/**
* Return type for an event, name of which you pass as a generic
* These include system and custom events
*/
export type RageFW_ServerEventReturn<K extends RageFW_ServerEvent> = export type RageFW_ServerEventReturn<K extends RageFW_ServerEvent> =
K extends keyof RageFW_ICustomServerEvent K extends keyof RageFW_ICustomServerEvent
? ReturnType<RageFW_ICustomServerEvent[K]> ? ReturnType<RageFW_ICustomServerEvent[K]>
@ -28,6 +44,10 @@ export type RageFW_ServerEventReturn<K extends RageFW_ServerEvent> =
? ReturnType<IServerEvents[K]> ? ReturnType<IServerEvents[K]>
: never : never
/**
* Array of arguments for an event, name of which you pass as a generic
* These only include custom events
*/
export type RageFW_ServerEventCallbackCustom< export type RageFW_ServerEventCallbackCustom<
K extends keyof RageFW_ICustomServerEvent = keyof RageFW_ICustomServerEvent, K extends keyof RageFW_ICustomServerEvent = keyof RageFW_ICustomServerEvent,
> = ( > = (
@ -35,6 +55,10 @@ export type RageFW_ServerEventCallbackCustom<
args: RageFW_ServerEventArguments<K>, args: RageFW_ServerEventArguments<K>,
) => RageFW_ServerEventReturn<K> ) => RageFW_ServerEventReturn<K>
/**
* Array of arguments for an event, name of which you pass as a generic
* These only include system events
*/
export type RageFW_ServerEventCallbackNative< export type RageFW_ServerEventCallbackNative<
K extends keyof IServerEvents = keyof IServerEvents, K extends keyof IServerEvents = keyof IServerEvents,
> = IServerEvents[K] > = IServerEvents[K]