refactor
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import { build } from 'esbuild'
|
||||
|
||||
build({
|
||||
entryPoints: ['./src/index.ts'],
|
||||
format: 'esm',
|
||||
platform: 'node',
|
||||
target: 'node10.4',
|
||||
outdir: './dist',
|
||||
}).then(r => console.log('Successfully build.'))
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilationOptions": {
|
||||
"followSymlinks": true,
|
||||
"preferredConfigPath": "../tsconfig.json"
|
||||
},
|
||||
"entries": [
|
||||
{
|
||||
"filePath": "./src/index.ts",
|
||||
"outFile": "./dist/index.d.ts",
|
||||
"libraries": {
|
||||
"inlinedLibraries": ["@ragempcommunity/types-client"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
+5
-1
@@ -5,7 +5,11 @@
|
||||
"type": "module",
|
||||
"files": ["dist/**/*"],
|
||||
"scripts": {
|
||||
"build": "tsup"
|
||||
"build": "node --es-module-specifier-resolution=node build.js",
|
||||
"types": "dts-bundle-generator --config dts.config.json"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rage-fw-shared-types": "workspace:shared-types:*"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "SashaGoncharov19",
|
||||
|
||||
+8
-12
@@ -1,23 +1,19 @@
|
||||
/// <reference types="../../shared/client/index.d.ts" />
|
||||
import rpc from 'rage-rpc'
|
||||
import {
|
||||
RageFW_ClientEventReturn,
|
||||
RageFW_ClientEvent,
|
||||
RageFW_ClientEventArguments,
|
||||
} from './types'
|
||||
|
||||
class Player implements RageFW_Player {
|
||||
public triggerClient<EventName extends RageFW_ClientEvent>(
|
||||
player: PlayerMp,
|
||||
class Player {
|
||||
public triggerServer<EventName extends RageFW_ClientEvent>(
|
||||
eventName: EventName,
|
||||
...args: RageFW_ClientEventArguments<EventName>
|
||||
): Promise<RageFW_ClientEventReturn<EventName>> {
|
||||
return rpc.callClient(player, eventName, ...args)
|
||||
return rpc.callServer(eventName, ...args)
|
||||
}
|
||||
}
|
||||
|
||||
export const rage = {
|
||||
player: new Player(),
|
||||
}
|
||||
|
||||
const bool = rage.player.triggerClient(
|
||||
{} as PlayerMp,
|
||||
'customClientEvent',
|
||||
'arg1',
|
||||
2,
|
||||
)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference types="@ragempcommunity/types-client" />
|
||||
|
||||
import { RageFW_ICustomClientEvent } from 'rage-fw-shared-types'
|
||||
|
||||
export type RageFW_ClientEvent =
|
||||
| keyof RageFW_ICustomClientEvent
|
||||
| keyof IClientEvents
|
||||
|
||||
export type RageFW_ClientEventArguments<K extends RageFW_ClientEvent> =
|
||||
K extends keyof RageFW_ICustomClientEvent
|
||||
? Parameters<RageFW_ICustomClientEvent[K]>
|
||||
: (K extends keyof IClientEvents ? IClientEvents[K] : never)[]
|
||||
|
||||
export type RageFW_ClientEventReturn<K extends RageFW_ClientEvent> =
|
||||
K extends keyof RageFW_ICustomClientEvent
|
||||
? ReturnType<RageFW_ICustomClientEvent[K]>
|
||||
: never
|
||||
@@ -1,13 +1,9 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"lib": ["ESNext", "ES5"],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"types": ["../node_modules/@ragempcommunity/types-server", "../../shared/client"]
|
||||
"typeRoots": [
|
||||
"@ragempcommunity/types-client"
|
||||
],
|
||||
"baseUrl": "./src"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user