cef functionality implementation

This commit is contained in:
Oleksandr Honcharov 2024-06-11 23:11:52 +03:00
parent fa3b1b1b0b
commit 88e40a4635
3 changed files with 83 additions and 5 deletions

View File

@ -1,13 +1,46 @@
import rpc from 'rage-rpc' import rpc from 'rage-rpc'
import {
RageFW_CefArguments,
RageFW_CefCallback,
RageFW_CefReturn,
RageFW_ClientArguments,
RageFW_ClientReturn,
RageFW_ServerArguments,
RageFW_ServerReturn,
RageFW_ICustomCefEvent,
RageFW_ICustomClientEvent,
RageFW_ICustomServerEvent,
} from './types'
class Cef { class Cef {
public register() {} public register<EventName extends keyof RageFW_ICustomCefEvent>(
eventName: EventName,
callback: RageFW_CefCallback<EventName>,
): void {
rpc.register(eventName, callback)
}
public trigger() {} public trigger<EventName extends keyof RageFW_ICustomCefEvent>(
eventName: EventName,
args: RageFW_CefArguments<EventName>,
): Promise<RageFW_CefReturn<EventName>> {
return rpc.call(eventName, args)
}
public triggerServer() {} public triggerServer<EventName extends keyof RageFW_ICustomServerEvent>(
eventName: EventName,
args: RageFW_ServerArguments<EventName>,
): Promise<RageFW_ServerReturn<EventName>> {
return rpc.callServer(eventName, args)
}
public triggerClient() {} public triggerClient<EventName extends keyof RageFW_ICustomClientEvent>(
eventName: EventName,
args: RageFW_ClientArguments<EventName>,
): Promise<RageFW_ClientReturn<EventName>> {
return rpc.callClient(eventName, args)
}
} }
export const fw = { export const fw = {

View File

@ -0,0 +1,45 @@
/// <reference types="@ragempcommunity/types-cef" />
import type {
RageFW_ICustomCefEvent,
RageFW_ICustomClientEvent,
RageFW_ICustomServerEvent,
} from 'rage-fw-shared-types'
export type {
RageFW_ICustomCefEvent,
RageFW_ICustomServerEvent,
RageFW_ICustomClientEvent,
} from 'rage-fw-shared-types'
export type RageFW_CefEvent = keyof RageFW_ICustomCefEvent
export type RageFW_ServerEvent = keyof RageFW_ICustomServerEvent
export type RageFW_ClientEvent = keyof RageFW_ICustomClientEvent
export type RageFW_CefArguments<K extends RageFW_CefEvent> = Parameters<
RageFW_ICustomCefEvent[K]
>
export type RageFW_CefReturn<K extends RageFW_CefEvent> = ReturnType<
RageFW_ICustomCefEvent[K]
>
export type RageFW_CefCallback<K extends keyof RageFW_ICustomCefEvent> = (
args: RageFW_CefArguments<K>,
) => RageFW_CefReturn<K>
export type RageFW_ServerArguments<K extends RageFW_ServerEvent> = Parameters<
RageFW_ICustomServerEvent[K]
>
export type RageFW_ServerReturn<K extends RageFW_ServerEvent> = ReturnType<
RageFW_ICustomServerEvent[K]
>
export type RageFW_ClientArguments<K extends RageFW_ClientEvent> = Parameters<
RageFW_ICustomClientEvent[K]
>
export type RageFW_ClientReturn<K extends RageFW_ClientEvent> = ReturnType<
RageFW_ICustomClientEvent[K]
>

View File

@ -12,7 +12,7 @@
"moduleDetection": "auto", "moduleDetection": "auto",
"module": "CommonJS", "module": "CommonJS",
"resolveJsonModule": true, "resolveJsonModule": true,
"declaration": true, "declaration": false,
"declarationMap": false, "declarationMap": false,
"sourceMap": false, "sourceMap": false,
"downlevelIteration": false, "downlevelIteration": false,