fix: missing types
This commit is contained in:
parent
f08291eace
commit
1467bb65b0
@ -8,11 +8,11 @@ import {
|
||||
RageFW_CefArgs,
|
||||
RageFW_CefEvent,
|
||||
RageFW_CefReturn,
|
||||
RageFW_ClientEventArguments,
|
||||
RageFW_ClientEventReturn,
|
||||
RageFW_ClientArgs,
|
||||
RageFW_ClientReturn,
|
||||
RageFW_ClientServerEvent,
|
||||
RageFW_ClientServerEventArguments,
|
||||
RageFW_ClientServerEventReturn,
|
||||
RageFW_ClientServerArgs,
|
||||
RageFW_ClientServerReturn,
|
||||
} from '../types'
|
||||
|
||||
export class Player {
|
||||
@ -21,18 +21,18 @@ export class Player {
|
||||
public trigger<EventName extends keyof RageFW_ICustomClientEvent>(
|
||||
eventName: EventName,
|
||||
...args: _ClientEventHasArgs<EventName> extends true
|
||||
? [RageFW_ClientEventArguments<EventName>]
|
||||
? [RageFW_ClientArgs<EventName>]
|
||||
: []
|
||||
): Promise<RageFW_ClientEventReturn<EventName>> {
|
||||
return rpc.call<RageFW_ClientEventReturn<EventName>>(eventName, args)
|
||||
): Promise<RageFW_ClientReturn<EventName>> {
|
||||
return rpc.call<RageFW_ClientReturn<EventName>>(eventName, args)
|
||||
}
|
||||
|
||||
public triggerServer<EventName extends RageFW_ClientServerEvent>(
|
||||
eventName: EventName,
|
||||
...args: _ServerEventHasArgs<EventName> extends true
|
||||
? [RageFW_ClientServerEventArguments<EventName>]
|
||||
? [RageFW_ClientServerArgs<EventName>]
|
||||
: []
|
||||
): Promise<RageFW_ClientServerEventReturn<EventName>> {
|
||||
): Promise<RageFW_ClientServerReturn<EventName>> {
|
||||
return rpc.callServer(eventName, args)
|
||||
}
|
||||
|
||||
|
@ -12,38 +12,7 @@ import {
|
||||
RageFW_ServerReturn,
|
||||
} from '../types'
|
||||
|
||||
type MiddlewarePoolServer<EventName extends RageFW_ServerEvent> = Partial<{
|
||||
[K in EventName]: {
|
||||
mwName: string
|
||||
mw: MiddlewareFunction<K>
|
||||
}
|
||||
}>
|
||||
|
||||
export type MiddlewareFunction<EventName extends RageFW_ServerEvent> = (
|
||||
player: PlayerMp,
|
||||
eventName: EventName,
|
||||
...args: _ServerEventHasArgs<EventName> extends true
|
||||
? [RageFW_ServerArgs<EventName>]
|
||||
: []
|
||||
) => void
|
||||
|
||||
export class Server {
|
||||
private middlewarePool: MiddlewarePoolServer<RageFW_ServerEvent> = {}
|
||||
|
||||
public use<EventName extends RageFW_ServerEvent>(
|
||||
mwName: string,
|
||||
eventName: EventName,
|
||||
mw: MiddlewareFunction<EventName>,
|
||||
) {
|
||||
this.middlewarePool = {
|
||||
...this.middlewarePool,
|
||||
[eventName]: {
|
||||
mwName,
|
||||
mw,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
private isNativeEvent(eventName: string): eventName is keyof IServerEvents {
|
||||
return nativeEvents.includes(eventName)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user