split types in server/client files
This commit is contained in:
parent
3f48215eb1
commit
e1450397ab
@ -1,8 +1,8 @@
|
||||
import rpc from 'rage-rpc'
|
||||
import {
|
||||
RageFW_ClientCallback,
|
||||
|
||||
import type {
|
||||
RageFW_ClientEventCallback,
|
||||
RageFW_ClientEvent,
|
||||
RageFW_ClientEventReturn,
|
||||
RageFW_ClientServerEvent,
|
||||
RageFW_ClientServerEventArguments,
|
||||
RageFW_ClientServerEventReturn,
|
||||
@ -11,7 +11,7 @@ import {
|
||||
class Client {
|
||||
public register<EventName extends RageFW_ClientEvent>(
|
||||
eventName: EventName,
|
||||
callback: RageFW_ClientCallback<EventName>,
|
||||
callback: RageFW_ClientEventCallback<EventName>,
|
||||
): void {
|
||||
rpc.register(eventName, data => {
|
||||
return callback(data)
|
||||
|
@ -1,34 +0,0 @@
|
||||
/// <reference types="@ragempcommunity/types-client" />
|
||||
|
||||
import type {
|
||||
RageFW_ICustomClientEvent,
|
||||
RageFW_ICustomServerEvent,
|
||||
} from 'rage-fw-shared-types'
|
||||
|
||||
// CLIENT
|
||||
|
||||
export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent
|
||||
|
||||
export type RageFW_ClientCallback<K extends RageFW_ClientEvent> = (
|
||||
args: Parameters<RageFW_ICustomClientEvent[K]>,
|
||||
) => RageFW_ClientEventReturn<K>
|
||||
|
||||
export type RageFW_ClientEventReturn<K extends RageFW_ClientEvent> =
|
||||
K extends keyof RageFW_ICustomClientEvent
|
||||
? ReturnType<RageFW_ICustomClientEvent[K]>
|
||||
: never
|
||||
|
||||
// SERVER
|
||||
|
||||
export type RageFW_ClientServerEvent = keyof RageFW_ICustomServerEvent
|
||||
|
||||
export type RageFW_ClientServerEventArguments<
|
||||
K extends RageFW_ClientServerEvent,
|
||||
> = K extends keyof RageFW_ICustomServerEvent
|
||||
? Parameters<RageFW_ICustomServerEvent[K]>
|
||||
: never
|
||||
|
||||
export type RageFW_ClientServerEventReturn<K extends RageFW_ClientServerEvent> =
|
||||
K extends keyof RageFW_ICustomServerEvent
|
||||
? ReturnType<RageFW_ICustomServerEvent[K]>
|
||||
: never
|
14
client/src/types/client.ts
Normal file
14
client/src/types/client.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/// <reference types="@ragempcommunity/types-client" />
|
||||
|
||||
import type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types'
|
||||
|
||||
export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent
|
||||
|
||||
export type RageFW_ClientEventCallback<K extends RageFW_ClientEvent> = (
|
||||
args: Parameters<RageFW_ICustomClientEvent[K]>,
|
||||
) => RageFW_ClientEventReturn<K>
|
||||
|
||||
export type RageFW_ClientEventReturn<K extends RageFW_ClientEvent> =
|
||||
K extends keyof RageFW_ICustomClientEvent
|
||||
? ReturnType<RageFW_ICustomClientEvent[K]>
|
||||
: never
|
2
client/src/types/index.ts
Normal file
2
client/src/types/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './client'
|
||||
export * from './server'
|
16
client/src/types/server.ts
Normal file
16
client/src/types/server.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/// <reference types="@ragempcommunity/types-client" />
|
||||
|
||||
import type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types'
|
||||
|
||||
export type RageFW_ClientServerEvent = keyof RageFW_ICustomServerEvent
|
||||
|
||||
export type RageFW_ClientServerEventArguments<
|
||||
K extends RageFW_ClientServerEvent,
|
||||
> = K extends keyof RageFW_ICustomServerEvent
|
||||
? Parameters<RageFW_ICustomServerEvent[K]>
|
||||
: never
|
||||
|
||||
export type RageFW_ClientServerEventReturn<K extends RageFW_ClientServerEvent> =
|
||||
K extends keyof RageFW_ICustomServerEvent
|
||||
? ReturnType<RageFW_ICustomServerEvent[K]>
|
||||
: never
|
@ -1,15 +1,16 @@
|
||||
import rpc from 'rage-rpc'
|
||||
import {
|
||||
|
||||
import type {
|
||||
RageFW_ClientEvent,
|
||||
RageFW_ClientEventArguments,
|
||||
RageFW_ClientEventReturn,
|
||||
RageFW_ICustomServerEvent,
|
||||
RageFW_ServerEvent,
|
||||
RageFW_ServerEventCallback,
|
||||
RageFW_ServerEventCallbackCustom,
|
||||
RageFW_ServerEventCallbackNative,
|
||||
} from './types.js'
|
||||
} from './types'
|
||||
import { nativeEvents } from './native.events'
|
||||
import type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types'
|
||||
|
||||
class Server {
|
||||
private isNativeEvent(eventName: string): eventName is keyof IServerEvents {
|
||||
|
15
server/src/types/client.ts
Normal file
15
server/src/types/client.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/// <reference types="@ragempcommunity/types-server" />
|
||||
|
||||
import type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types'
|
||||
|
||||
export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent
|
||||
|
||||
export type RageFW_ClientEventArguments<K extends RageFW_ClientEvent> =
|
||||
K extends RageFW_ClientEvent
|
||||
? Parameters<RageFW_ICustomClientEvent[K]>
|
||||
: never
|
||||
|
||||
export type RageFW_ClientEventReturn<K extends RageFW_ClientEvent> =
|
||||
K extends RageFW_ClientEvent
|
||||
? ReturnType<RageFW_ICustomClientEvent[K]>
|
||||
: never
|
2
server/src/types/index.ts
Normal file
2
server/src/types/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './client'
|
||||
export * from './server'
|
@ -1,11 +1,7 @@
|
||||
/// <reference types="@ragempcommunity/types-server" />
|
||||
|
||||
import type {
|
||||
RageFW_ICustomServerEvent,
|
||||
RageFW_ICustomClientEvent,
|
||||
} from 'rage-fw-shared-types'
|
||||
|
||||
// SERVER
|
||||
import type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types'
|
||||
export type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types'
|
||||
|
||||
export type RageFW_ServerEvent =
|
||||
| keyof RageFW_ICustomServerEvent
|
||||
@ -28,17 +24,3 @@ export type RageFW_ServerEventCallback<K extends RageFW_ServerEvent> =
|
||||
: K extends keyof IServerEvents
|
||||
? RageFW_ServerEventCallbackNative<K>
|
||||
: never
|
||||
|
||||
// CLIENT
|
||||
|
||||
export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent
|
||||
|
||||
export type RageFW_ClientEventArguments<K extends RageFW_ClientEvent> =
|
||||
K extends RageFW_ClientEvent
|
||||
? Parameters<RageFW_ICustomClientEvent[K]>
|
||||
: never
|
||||
|
||||
export type RageFW_ClientEventReturn<K extends RageFW_ClientEvent> =
|
||||
K extends RageFW_ClientEvent
|
||||
? ReturnType<RageFW_ICustomClientEvent[K]>
|
||||
: never
|
Loading…
Reference in New Issue
Block a user