Compare commits

..
Author SHA1 Message Date
Oleksandr Honcharov 57b4f236ac v0.0.18-alpha.0 2024-06-12 04:11:34 +03:00
Oleksandr Honcharov 558005d7b0 update peerDependencies 2024-06-12 04:09:14 +03:00
rilaxik a03cc01aa0 readme 2024-06-12 01:15:17 +01:00
rilaxik bad4d532f6 types docs 2024-06-12 00:03:44 +01:00
Oleksandr Honcharov 234bcecc7b v0.0.17-alpha.0 2024-06-11 23:14:22 +03:00
Oleksandr Honcharov 2b26dbffc0 client tsconfig.json changes 2024-06-11 23:12:06 +03:00
Oleksandr Honcharov 88e40a4635 cef functionality implementation 2024-06-11 23:11:52 +03:00
rilaxik fa3b1b1b0b Merge remote-tracking branch 'origin/master' 2024-06-11 19:52:07 +01:00
rilaxik 1880f28eb7 unregister + trigger 2024-06-11 19:52:00 +01:00
Oleksandr Honcharov c021ef3c59 remove shared 2024-06-11 21:35:57 +03:00
Oleksandr Honcharov 22945357fd cef pnpm workspace 2024-06-11 21:34:47 +03:00
Oleksandr Honcharov 17ef98cbd2 cef implementation 2024-06-11 21:34:35 +03:00
Oleksandr Honcharov 39ab22f9aa client logger 2024-06-11 21:30:39 +03:00
Oleksandr Honcharov 97b094c3d4 v0.0.16-alpha.0 2024-06-11 20:29:42 +03:00
Oleksandr Honcharov acd7ad3406 client / server ragempcommunity types peerDependency 2024-06-11 20:29:07 +03:00
Oleksandr Honcharov 0a81acf49e logger functionality 2024-06-11 20:28:57 +03:00
Oleksandr Honcharov 1b2f0d02ef server logger 2024-06-11 20:27:54 +03:00
Oleksandr Honcharov 3bb9256eb8 v0.0.15-alpha.0 2024-06-11 19:12:23 +03:00
Oleksandr Honcharov 23c1e6080a fixes types 2024-06-11 19:12:03 +03:00
Oleksandr Honcharov 33ebdaac84 clear usages 2024-06-11 19:09:19 +03:00
25 changed files with 786 additions and 144 deletions
+23
View File
@@ -0,0 +1,23 @@
{
"name": "rage-fw-cef",
"version": "0.0.18-alpha.0",
"main": "dist/index.js",
"types": "dist/src/index.d.ts",
"files": [
"dist/**/*"
],
"scripts": {
"build": "tsup"
},
"dependencies": {
"rage-rpc": "^0.4.0"
},
"peerDependencies": {
"@ragempcommunity/types-cef": "^2.1.8",
"rage-fw-shared-types": "workspace:^"
},
"keywords": [],
"author": "SashaGoncharov19",
"license": "MIT",
"description": "CEF side for rage-fw"
}
+48
View File
@@ -0,0 +1,48 @@
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 {
public register<EventName extends keyof RageFW_ICustomCefEvent>(
eventName: EventName,
callback: RageFW_CefCallback<EventName>,
): void {
rpc.register(eventName, callback)
}
public trigger<EventName extends keyof RageFW_ICustomCefEvent>(
eventName: EventName,
args: RageFW_CefArguments<EventName>,
): Promise<RageFW_CefReturn<EventName>> {
return rpc.call(eventName, args)
}
public triggerServer<EventName extends keyof RageFW_ICustomServerEvent>(
eventName: EventName,
args: RageFW_ServerArguments<EventName>,
): Promise<RageFW_ServerReturn<EventName>> {
return rpc.callServer(eventName, args)
}
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 = {
event: new Cef(),
}
+87
View File
@@ -0,0 +1,87 @@
/// <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'
/**
* Union of all available cef event names
* These only include custom events
*/
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
/**
* Union of all available client event names
* These only include custom events
*/
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<
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<
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> = (
args: RageFW_CefArguments<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<
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<
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<
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<
RageFW_ICustomClientEvent[K]
>
+25
View File
@@ -0,0 +1,25 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Base",
"exclude": [
"node_modules"
],
"compilerOptions": {
"incremental": false,
"composite": false,
"target": "ES2022",
"experimentalDecorators": true,
"moduleDetection": "auto",
"module": "CommonJS",
"resolveJsonModule": true,
"declaration": false,
"declarationMap": false,
"sourceMap": false,
"downlevelIteration": false,
"inlineSourceMap": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
+12
View File
@@ -0,0 +1,12 @@
import { defineConfig } from 'tsup'
export default defineConfig({
entry: ['src/index.ts'],
outDir: './dist',
format: ['cjs'],
noExternal: ['rage-rpc'],
experimentalDts: true,
splitting: false,
sourcemap: false,
clean: true,
})
+6 -4
View File
@@ -1,8 +1,8 @@
{
"name": "rage-fw-client",
"version": "0.0.14-alpha.0",
"version": "0.0.18-alpha.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"types": "dist/src/index.d.ts",
"files": [
"dist/**/*"
],
@@ -10,10 +10,12 @@
"build": "tsup"
},
"dependencies": {
"@ragempcommunity/types-client": "^2.1.8",
"rage-fw-shared-types": "workspace:^",
"rage-rpc": "^0.4.0"
},
"peerDependencies": {
"@ragempcommunity/types-client": "^2.1.8",
"rage-fw-shared-types": "workspace:^"
},
"keywords": [],
"author": "SashaGoncharov19",
"license": "MIT",
+22 -4
View File
@@ -1,12 +1,17 @@
import rpc from 'rage-rpc'
import type {
import Logger from './logger'
import {
RageFW_ClientEventCallback,
RageFW_ClientEvent,
RageFW_ClientServerEvent,
RageFW_ClientServerEventArguments,
RageFW_ClientServerEventReturn,
RageFW_ClientEventArguments,
RageFW_ClientEventReturn,
} from './types'
import type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types'
class Client {
public register<EventName extends RageFW_ClientEvent>(
@@ -17,6 +22,19 @@ class Client {
return callback(data)
})
}
public unregister<EventName extends RageFW_ClientEvent>(
eventName: EventName,
): void {
rpc.unregister(eventName)
}
public trigger<EventName extends keyof RageFW_ICustomClientEvent>(
eventName: EventName,
args: RageFW_ClientEventArguments<EventName>,
): Promise<RageFW_ClientEventReturn<EventName>> {
return rpc.call<RageFW_ClientEventReturn<EventName>>(eventName, args)
}
}
class Player {
@@ -31,7 +49,7 @@ class Player {
export const fw = {
event: new Client(),
player: new Player(),
system: {
log: new Logger(),
},
}
fw.player.triggerServer('customServerEvent', ['wer'])
fw.event.register('customClientEvent', ([arg1]) => true)
+19
View File
@@ -0,0 +1,19 @@
export default class Logger {
public error(message: unknown) {
mp.console.logError(
`[${new Date().toLocaleTimeString()}] [ERROR] ${message}`,
)
}
public warn(message: unknown) {
mp.console.logWarning(
`[${new Date().toLocaleTimeString()}] [WARN] ${message}`,
)
}
public info(message: unknown) {
mp.console.logInfo(
`[${new Date().toLocaleTimeString()}] [INFO] ${message}`,
)
}
}
+20 -1
View File
@@ -2,12 +2,31 @@
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
/**
* 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> =
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> = (
args: Parameters<RageFW_ICustomClientEvent[K]>,
args: RageFW_ClientEventArguments<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> =
K extends keyof RageFW_ICustomClientEvent
? ReturnType<RageFW_ICustomClientEvent[K]>
+12
View File
@@ -2,14 +2,26 @@
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
/**
* Array of arguments for an event, name of which you pass as a generic
* These only include custom events
*/
export type RageFW_ClientServerEventArguments<
K extends RageFW_ClientServerEvent,
> = K extends keyof RageFW_ICustomServerEvent
? Parameters<RageFW_ICustomServerEvent[K]>
: 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> =
K extends keyof RageFW_ICustomServerEvent
? ReturnType<RageFW_ICustomServerEvent[K]>
-1
View File
@@ -9,7 +9,6 @@
"composite": false,
"target": "ES2022",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleDetection": "auto",
"module": "CommonJS",
"resolveJsonModule": true,
+1 -1
View File
@@ -5,7 +5,7 @@ export default defineConfig({
outDir: './dist',
format: ['cjs'],
noExternal: ['rage-rpc'],
dts: true,
experimentalDts: true,
splitting: false,
sourcemap: false,
clean: true,
+1 -1
View File
@@ -1,5 +1,5 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "0.0.14-alpha.0",
"version": "0.0.18-alpha.0",
"npmClient": "pnpm"
}
+3 -5
View File
@@ -17,10 +17,8 @@
"prettier": "^3.3.1",
"rage-rpc": "^0.4.0",
"tsup": "^8.1.0",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"winston": "^3.13.0"
},
"type": "module",
"devDependencies": {
}
"type": "module"
}
+340 -74
View File
@@ -33,7 +33,7 @@ importers:
version: 8.1.3([email protected])
prettier:
specifier: ^3.3.1
version: 3.3.1
version: 3.3.2
rage-rpc:
specifier: ^0.4.0
version: 0.4.0
@@ -43,6 +43,21 @@ importers:
typescript:
specifier: ^5.4.5
version: 5.4.5
winston:
specifier: ^3.13.0
version: 3.13.0
cef:
dependencies:
'@ragempcommunity/types-cef':
specifier: ^2.1.8
version: 2.1.8
rage-fw-shared-types:
specifier: workspace:^
version: link:../shared-types
rage-rpc:
specifier: ^0.4.0
version: 0.4.0
client:
dependencies:
@@ -68,8 +83,6 @@ importers:
specifier: ^0.4.0
version: 0.4.0
shared: {}
shared-types: {}
packages:
@@ -94,6 +107,19 @@ packages:
}
engines: { node: '>=6.9.0' }
'@colors/[email protected]':
resolution:
{
integrity: sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==,
}
engines: { node: '>=0.1.90' }
'@dabh/[email protected]':
resolution:
{
integrity: sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA==,
}
'@esbuild/[email protected]':
resolution:
{
@@ -517,112 +543,112 @@ packages:
}
engines: { node: ^16.14.0 || >=18.0.0 }
'@nrwl/[email protected].2':
'@nrwl/[email protected].3':
resolution:
{
integrity: sha512-NWB3OAm6/oHaF2h7isUXpK9J2XF097mfaiENHj1GzH9JwjB2YoFaD7v033er6+Hb6FEZtOPZpVH1kEQjVaYJLA==,
integrity: sha512-OL6sc70gR/USasvbYzyYY44Hd5ZCde2UfiA5h8VeAYAJbq+JmtscpvjcnZ7OIsXyYEOxe1rypULElqu/8qpKzQ==,
}
'@nrwl/[email protected].2':
'@nrwl/[email protected].3':
resolution:
{
integrity: sha512-G/m3EGXf3m9rM2sQQGpRPD40gfaWR6jFVCsZW66/6FXDo1dMUH5/U5JOBnD6vBdug8txKA1ceWHM74NkAB1QEg==,
integrity: sha512-vwo6ogcy6A9vJggDOsHGi1F0cTRqSqRypbgq/EdNuZqL7rGyZB/ctId69/i8dV6cLkl8BJG/4WpEe5BIrMTsjA==,
}
hasBin: true
'@nx/[email protected].2':
'@nx/[email protected].3':
resolution:
{
integrity: sha512-6y+th5m1qVc+B0lXmKb3WRcfwNYD2B/bqGn1HiKLu8g6DDVJFn0mT+a872e4OtvgHyubZQm3HnPfjXobChpRuw==,
integrity: sha512-if1WwRVexrQBBADObEcxVIivq4QRZWY/nYRhCQy/qfFI6Cu2jBSI6ZQ1uy7to2L2sQPLgn8v2beQZiAeZdIktg==,
}
peerDependencies:
nx: '>= 17 <= 20'
'@nx/[email protected].2':
'@nx/[email protected].3':
resolution:
{
integrity: sha512-AgvsZ0iDA0rklH0TqOIiTrbJysn7WfFFzhLYd1JnxS2Z3GAFPRoE6TxRSSqpTBmFqskrZhZyrjHllOoBD5odFQ==,
integrity: sha512-1beJscdMraGgLHpvjyC5FXUzpdQYW8JwnPK0Yj9iti9Vnahtx3PLQHCFOFwoE0KZF9VEL1KsZSSVPljMgW/j+g==,
}
engines: { node: '>= 10' }
cpu: [arm64]
os: [darwin]
'@nx/[email protected].2':
'@nx/[email protected].3':
resolution:
{
integrity: sha512-YPd9Kmn5/YPYolBVYoficQmp8LFTe/PAI3dQ3NebOGFYw49PFmV0cdB8+4m0q70WCBMwyqo1x6a6MO9CvENkTg==,
integrity: sha512-wCpIRThGKL/FebPe+WaFk/V6nk31mMc83APoEyhyS5kAodqeKjb6iPud+QNydtUJ/jsF9aQ/DaHIioKC9wbg8A==,
}
engines: { node: '>= 10' }
cpu: [x64]
os: [darwin]
'@nx/[email protected].2':
'@nx/[email protected].3':
resolution:
{
integrity: sha512-43hMzFmYyi0aEiGa/VNXChzotL6nFG9hLSZhtpXAO6qyibSqKwlU5PjNyly/7y5gUGl7YfmdpwWwlOIYPSQoVw==,
integrity: sha512-ytY18USCyf83wqyUgFaeRO/3zvysJXPJf1Di8czBhiUSroSMB6088OaeqW7SnzdcYNdACZUv0Q6PupXpx3w2Ng==,
}
engines: { node: '>= 10' }
cpu: [x64]
os: [freebsd]
'@nx/[email protected].2':
'@nx/[email protected].3':
resolution:
{
integrity: sha512-locP8QQWI4NFb7kVe8Fflkpdnf9kw5o/WMROILJLFWlTy59K+NBQkpxRIhoUghJ6yckDxk1Kf2kmvV+xuX4f8Q==,
integrity: sha512-FPtqIMzdOzYSSDnLXUpcrflqEsNe6UgpAgYoHLVbWiR47O3qJnpQRDfYUsP7Lv+2C0CBKNXgwPEvmDLXKHcfYg==,
}
engines: { node: '>= 10' }
cpu: [arm]
os: [linux]
'@nx/[email protected].2':
'@nx/[email protected].3':
resolution:
{
integrity: sha512-uQUZs+56yplEjokgCC3Pv/nUr4v+/bCurc1v/juUH4byqCdvi+Cny7jqws49UELS+QkcTkWGBtajvf8U3JZEbQ==,
integrity: sha512-VOuzPD5FBPZmctvXqdB9K1MYVzkV8TgOZFS7Md6ClH7UwJTEOjnMoomYCMM1VlOZV4P0S5E0u/Zere5YWh+ZWw==,
}
engines: { node: '>= 10' }
cpu: [arm64]
os: [linux]
'@nx/[email protected].2':
'@nx/[email protected].3':
resolution:
{
integrity: sha512-rU6l18ubh0Chv7lkxshgm6o4IKduB+jztUBRR4SuOuTOLJ6okm51AqzdY+vy7esicEL3HnHWSJP/U5PwoAaNsA==,
integrity: sha512-qd6QZysktt0D7rNCOlBaV3ME0/J0VwvC1cmdjtZoljwtsX6Zc56AEdfwsgGzsZNU4w+N+BtXxowan3D44iiSzQ==,
}
engines: { node: '>= 10' }
cpu: [arm64]
os: [linux]
'@nx/[email protected].2':
'@nx/[email protected].3':
resolution:
{
integrity: sha512-rvGP3p0qmzHJu8cUcYnRDyJ1BkVExgmsWmtzyQrHl48+hvNrq805NrP3gTreOxqymRlBEXg7c22fRECI1CV1lA==,
integrity: sha512-wE08BstTD65dt6c+9L9bEp98PxFwc7CuaUVX2cZTDFAERBXCMhu7y6Gb1JbiAvfVci4+yLrm+h0E1ieY1wMTXw==,
}
engines: { node: '>= 10' }
cpu: [x64]
os: [linux]
'@nx/[email protected].2':
'@nx/[email protected].3':
resolution:
{
integrity: sha512-86pfT+z6SWKlJUoRy7MOMjRhrCPgSnAxbcH7jYCkqhokbCIDIv2IFWqMf0zdUqa8HqjRo13X6Jd6PhNYzWwJzw==,
integrity: sha512-IA09+NZ0kKPSfK/dXsyjZ8TN+hN/1PcnbdNuUCn1Opmbrdda9GBfzHSDFKXxoA6TVB/j/qnXHKgKxhhVH05TGg==,
}
engines: { node: '>= 10' }
cpu: [x64]
os: [linux]
'@nx/[email protected].2':
'@nx/[email protected].3':
resolution:
{
integrity: sha512-kJ3G0+nyAgBr5RTkNceC9zl2pekFEu0ec6ceLJ0tfcTwil76Ce3Xnlr0CFFNsre4T1v2RfFIDJL3EaRUXYep0w==,
integrity: sha512-fkbcTp+XuxGaL5e4Ve8AjxNEim5Ifdn61ofaxEDMoGjauKvKZBejbLhBFOonCKDqntXsY8D2nDXjhcsdNYxzMg==,
}
engines: { node: '>= 10' }
cpu: [arm64]
os: [win32]
'@nx/[email protected].2':
'@nx/[email protected].3':
resolution:
{
integrity: sha512-9KKGYFgWfc4jHzHjnIp+DJt750NyG1kA4Q+DWf/UcFA5917UWuAw9rribFPRsqYkcwbu++Uajw5bI5yMLP7ThA==,
integrity: sha512-E2q3c504xjFXTY+/iq57DOZmS6CPA8RbFwLf6bCG5wo2BDajxmvU3VCeCSkxqXEwCY7NJSI3PT1V/3vRDzJ3lQ==,
}
engines: { node: '>= 10' }
cpu: [x64]
@@ -1061,6 +1087,12 @@ packages:
integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==,
}
'@types/[email protected]':
resolution:
{
integrity: sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==,
}
'@typescript-eslint/[email protected]':
resolution:
{
@@ -1694,6 +1726,12 @@ packages:
integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==,
}
[email protected]:
resolution:
{
integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==,
}
[email protected]:
resolution:
{
@@ -1701,6 +1739,18 @@ packages:
}
hasBin: true
[email protected]:
resolution:
{
integrity: sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==,
}
[email protected]:
resolution:
{
integrity: sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w==,
}
[email protected]:
resolution:
{
@@ -1988,6 +2038,12 @@ packages:
integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==,
}
[email protected]:
resolution:
{
integrity: sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ==,
}
[email protected]:
resolution:
{
@@ -2141,6 +2197,13 @@ packages:
}
engines: { node: '>=10' }
[email protected]:
resolution:
{
integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==,
}
engines: { node: '>=10' }
[email protected]:
resolution:
{
@@ -2185,6 +2248,12 @@ packages:
integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==,
}
[email protected]:
resolution:
{
integrity: sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==,
}
[email protected]:
resolution:
{
@@ -2253,6 +2322,12 @@ packages:
integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==,
}
[email protected]:
resolution:
{
integrity: sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==,
}
[email protected]:
resolution:
{
@@ -2376,6 +2451,13 @@ packages:
}
engines: { node: '>=10' }
[email protected]:
resolution:
{
integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==,
}
engines: { node: '>=10' }
[email protected]:
resolution:
{
@@ -2733,6 +2815,12 @@ packages:
integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==,
}
[email protected]:
resolution:
{
integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==,
}
[email protected]:
resolution:
{
@@ -2850,6 +2938,13 @@ packages:
}
engines: { node: '>=8' }
[email protected]:
resolution:
{
integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==,
}
engines: { node: '>=8' }
[email protected]:
resolution:
{
@@ -3060,6 +3155,12 @@ packages:
}
engines: { node: '>=0.10.0' }
[email protected]:
resolution:
{
integrity: sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==,
}
[email protected]:
resolution:
{
@@ -3182,6 +3283,13 @@ packages:
}
engines: { node: '>=10' }
[email protected]:
resolution:
{
integrity: sha512-1ulHeNPp6k/LD8H91o7VYFBng5i1BDE7HoKxVbZiGFidS1Rj65qcywLxX+pVfAPoQJEjRdvKcusKwOupHCVOVQ==,
}
engines: { node: '>= 12.0.0' }
[email protected]:
resolution:
{
@@ -3306,6 +3414,12 @@ packages:
integrity: sha512-tUpxzX0VAzJHjLu0xUfFv1gwVp9ba3IOuRAVH2EGuRW8a5emA2FlACLqiT/lDVtS1W+TGNwqz3sWaNyLgDJWuw==,
}
[email protected]:
resolution:
{
integrity: sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==,
}
[email protected]:
resolution:
{
@@ -3681,10 +3795,10 @@ packages:
engines: { node: ^12.13.0 || ^14.15.0 || >=16.0.0 }
deprecated: This package is no longer supported.
[email protected].2:
[email protected].3:
resolution:
{
integrity: sha512-Tg3REVykwKmVBCsroeCE/KhHAJx3e/m0FgNZWXJhn3EEh01qhdsVfWpM/ecawin73or7YcvB/99S8vVPU1nczg==,
integrity: sha512-SvxFgk9PD2m6tXEaqB6DENOpe4jhov/Ili/2JmOnPAAIGUR6H9WajCzVuHfq3bvQxmGRvkQQRv/rfvAuLTme3g==,
}
hasBin: true
peerDependencies:
@@ -3709,6 +3823,12 @@ packages:
integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==,
}
[email protected]:
resolution:
{
integrity: sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g==,
}
[email protected]:
resolution:
{
@@ -4036,10 +4156,10 @@ packages:
}
engines: { node: '>= 0.8.0' }
[email protected].1:
[email protected].2:
resolution:
{
integrity: sha512-7CAwy5dRsxs8PHXT3twixW9/OEll8MLE0VRPCJyl7CkS6VHGPSlsVaWTiASPTyGyYRyApxlaWTzwUxVNrhcwDg==,
integrity: sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==,
}
engines: { node: '>=14' }
hasBin: true
@@ -4357,6 +4477,13 @@ packages:
integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==,
}
[email protected]:
resolution:
{
integrity: sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g==,
}
engines: { node: '>=10' }
[email protected]:
resolution:
{
@@ -4441,6 +4568,12 @@ packages:
}
engines: { node: ^16.14.0 || >=18.0.0 }
[email protected]:
resolution:
{
integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==,
}
[email protected]:
resolution:
{
@@ -4559,6 +4692,12 @@ packages:
}
engines: { node: ^12.13.0 || ^14.15.0 || >=16.0.0 }
[email protected]:
resolution:
{
integrity: sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==,
}
[email protected]:
resolution:
{
@@ -4713,6 +4852,12 @@ packages:
}
engines: { node: '>=0.10' }
[email protected]:
resolution:
{
integrity: sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==,
}
[email protected]:
resolution:
{
@@ -4791,6 +4936,13 @@ packages:
}
engines: { node: '>=8' }
[email protected]:
resolution:
{
integrity: sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==,
}
engines: { node: '>= 14.0.0' }
[email protected]:
resolution:
{
@@ -5065,6 +5217,20 @@ packages:
integrity: sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==,
}
[email protected]:
resolution:
{
integrity: sha512-ajBj65K5I7denzer2IYW6+2bNIVqLGDHqDw3Ow8Ohh+vdW+rv4MZ6eiDvHoKhfJFZ2auyN8byXieDDJ96ViONg==,
}
engines: { node: '>= 12.0.0' }
[email protected]:
resolution:
{
integrity: sha512-rwidmA1w3SE4j0E5MuIufFhyJPBDG7Nu71RkZor1p2+qHvJSZ9GYDA81AyleQcZbh/+V6HjeBdfnTZJm9rSeQQ==,
}
engines: { node: '>= 12.0.0' }
[email protected]:
resolution:
{
@@ -5210,6 +5376,14 @@ snapshots:
js-tokens: 4.0.0
picocolors: 1.0.1
'@colors/[email protected]': {}
'@dabh/[email protected]':
dependencies:
colorspace: 1.1.4
enabled: 2.0.0
kuler: 2.0.0
'@esbuild/[email protected]':
optional: true
@@ -5349,7 +5523,7 @@ snapshots:
'@lerna/[email protected]([email protected])([email protected])':
dependencies:
'@npmcli/run-script': 7.0.2
'@nx/devkit': 19.2.2([email protected].2)
'@nx/devkit': 19.2.3([email protected].3)
'@octokit/plugin-enterprise-rest': 6.0.1
'@octokit/rest': 19.0.11([email protected])
byte-size: 8.1.1
@@ -5386,7 +5560,7 @@ snapshots:
npm-packlist: 5.1.1
npm-registry-fetch: 14.0.5
npmlog: 6.0.2
nx: 19.2.2
nx: 19.2.3
p-map: 4.0.0
p-map-series: 2.1.0
p-queue: 6.6.2
@@ -5439,7 +5613,7 @@ snapshots:
'@rushstack/terminal': 0.13.0
'@rushstack/ts-command-line': 4.22.0
lodash: 4.17.21
minimatch: 3.0.5
minimatch: 3.0.8
resolve: 1.22.8
semver: 7.5.4
source-map: 0.6.1
@@ -5518,62 +5692,62 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@nrwl/[email protected].2([email protected].2)':
'@nrwl/[email protected].3([email protected].3)':
dependencies:
'@nx/devkit': 19.2.2([email protected].2)
'@nx/devkit': 19.2.3([email protected].3)
transitivePeerDependencies:
- nx
'@nrwl/[email protected].2':
'@nrwl/[email protected].3':
dependencies:
nx: 19.2.2
nx: 19.2.3
tslib: 2.6.3
transitivePeerDependencies:
- '@swc-node/register'
- '@swc/core'
- debug
'@nx/[email protected].2([email protected].2)':
'@nx/[email protected].3([email protected].3)':
dependencies:
'@nrwl/devkit': 19.2.2([email protected].2)
'@nrwl/devkit': 19.2.3([email protected].3)
ejs: 3.1.10
enquirer: 2.3.6
ignore: 5.3.1
minimatch: 9.0.3
nx: 19.2.2
nx: 19.2.3
semver: 7.6.2
tmp: 0.2.3
tslib: 2.6.3
yargs-parser: 21.1.1
'@nx/[email protected].2':
'@nx/[email protected].3':
optional: true
'@nx/[email protected].2':
'@nx/[email protected].3':
optional: true
'@nx/[email protected].2':
'@nx/[email protected].3':
optional: true
'@nx/[email protected].2':
'@nx/[email protected].3':
optional: true
'@nx/[email protected].2':
'@nx/[email protected].3':
optional: true
'@nx/[email protected].2':
'@nx/[email protected].3':
optional: true
'@nx/[email protected].2':
'@nx/[email protected].3':
optional: true
'@nx/[email protected].2':
'@nx/[email protected].3':
optional: true
'@nx/[email protected].2':
'@nx/[email protected].3':
optional: true
'@nx/[email protected].2':
'@nx/[email protected].3':
optional: true
'@octokit/[email protected]': {}
@@ -5827,6 +6001,8 @@ snapshots:
'@types/[email protected]': {}
'@types/[email protected]': {}
'@typescript-eslint/[email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])':
dependencies:
'@eslint-community/regexpp': 4.10.1
@@ -6219,8 +6395,23 @@ snapshots:
[email protected]: {}
[email protected]:
dependencies:
color-name: 1.1.4
simple-swizzle: 0.2.2
[email protected]: {}
[email protected]:
dependencies:
color-convert: 1.9.3
color-string: 1.9.1
[email protected]:
dependencies:
color: 3.2.1
text-hex: 1.0.0
[email protected]:
dependencies:
strip-ansi: 6.0.1
@@ -6380,6 +6571,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]:
dependencies:
iconv-lite: 0.6.3
@@ -6519,6 +6712,18 @@ snapshots:
signal-exit: 3.0.7
strip-final-newline: 2.0.0
[email protected]:
dependencies:
cross-spawn: 7.0.3
get-stream: 6.0.1
human-signals: 2.1.0
is-stream: 2.0.1
merge-stream: 2.0.0
npm-run-path: 4.0.1
onetime: 5.1.2
signal-exit: 3.0.7
strip-final-newline: 2.0.0
[email protected]: {}
[email protected]:
@@ -6545,6 +6750,8 @@ snapshots:
dependencies:
reusify: 1.0.4
[email protected]: {}
[email protected]:
dependencies:
escape-string-regexp: 1.0.5
@@ -6585,6 +6792,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]:
@@ -6655,6 +6864,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]:
dependencies:
dargs: 7.0.0
@@ -6898,6 +7109,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]:
dependencies:
binary-extensions: 2.3.0
@@ -6944,6 +7157,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]:
dependencies:
text-extensions: 1.9.0
@@ -6971,13 +7186,13 @@ snapshots:
[email protected]:
dependencies:
async: 3.2.5
chalk: 4.1.2
chalk: 4.1.0
filelist: 1.0.4
minimatch: 3.1.2
[email protected]:
dependencies:
chalk: 4.1.2
chalk: 4.1.0
diff-sequences: 29.6.3
jest-get-type: 29.6.3
pretty-format: 29.7.0
@@ -7039,11 +7254,13 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]([email protected]):
dependencies:
'@lerna/create': 8.1.3([email protected])([email protected])
'@npmcli/run-script': 7.0.2
'@nx/devkit': 19.2.2([email protected].2)
'@nx/devkit': 19.2.3([email protected].3)
'@octokit/plugin-enterprise-rest': 6.0.1
'@octokit/rest': 19.0.11([email protected])
byte-size: 8.1.1
@@ -7086,7 +7303,7 @@ snapshots:
npm-packlist: 5.1.1
npm-registry-fetch: 14.0.5
npmlog: 6.0.2
nx: 19.2.2
nx: 19.2.3
p-map: 4.0.0
p-map-series: 2.1.0
p-pipe: 3.1.0
@@ -7196,6 +7413,15 @@ snapshots:
chalk: 4.1.2
is-unicode-supported: 0.1.0
[email protected]:
dependencies:
'@colors/colors': 1.6.0
'@types/triple-beam': 1.3.5
fecha: 4.2.3
ms: 2.1.3
safe-stable-stringify: 2.4.3
triple-beam: 1.4.1
[email protected]: {}
[email protected]:
@@ -7291,6 +7517,10 @@ snapshots:
dependencies:
brace-expansion: 1.1.11
[email protected]:
dependencies:
brace-expansion: 1.1.11
[email protected]:
dependencies:
brace-expansion: 1.1.11
@@ -7381,7 +7611,7 @@ snapshots:
array-differ: 3.0.0
array-union: 2.1.0
arrify: 2.0.1
minimatch: 3.1.2
minimatch: 3.0.5
[email protected]: {}
@@ -7546,14 +7776,14 @@ snapshots:
gauge: 4.0.4
set-blocking: 2.0.0
[email protected].2:
[email protected].3:
dependencies:
'@nrwl/tao': 19.2.2
'@nrwl/tao': 19.2.3
'@yarnpkg/lockfile': 1.1.0
'@yarnpkg/parsers': 3.0.0-rc.46
'@zkochan/js-yaml': 0.0.7
axios: 1.7.2
chalk: 4.1.2
chalk: 4.1.0
cli-cursor: 3.1.0
cli-spinners: 2.6.1
cliui: 8.0.1
@@ -7583,16 +7813,16 @@ snapshots:
yargs: 17.7.2
yargs-parser: 21.1.1
optionalDependencies:
'@nx/nx-darwin-arm64': 19.2.2
'@nx/nx-darwin-x64': 19.2.2
'@nx/nx-freebsd-x64': 19.2.2
'@nx/nx-linux-arm-gnueabihf': 19.2.2
'@nx/nx-linux-arm64-gnu': 19.2.2
'@nx/nx-linux-arm64-musl': 19.2.2
'@nx/nx-linux-x64-gnu': 19.2.2
'@nx/nx-linux-x64-musl': 19.2.2
'@nx/nx-win32-arm64-msvc': 19.2.2
'@nx/nx-win32-x64-msvc': 19.2.2
'@nx/nx-darwin-arm64': 19.2.3
'@nx/nx-darwin-x64': 19.2.3
'@nx/nx-freebsd-x64': 19.2.3
'@nx/nx-linux-arm-gnueabihf': 19.2.3
'@nx/nx-linux-arm64-gnu': 19.2.3
'@nx/nx-linux-arm64-musl': 19.2.3
'@nx/nx-linux-x64-gnu': 19.2.3
'@nx/nx-linux-x64-musl': 19.2.3
'@nx/nx-win32-arm64-msvc': 19.2.3
'@nx/nx-win32-x64-msvc': 19.2.3
transitivePeerDependencies:
- debug
@@ -7602,6 +7832,10 @@ snapshots:
dependencies:
wrappy: 1.0.2
[email protected]:
dependencies:
fn.name: 1.1.0
[email protected]:
dependencies:
mimic-fn: 2.1.0
@@ -7624,7 +7858,7 @@ snapshots:
[email protected]:
dependencies:
bl: 4.1.0
chalk: 4.1.2
chalk: 4.1.0
cli-cursor: 3.1.0
cli-spinners: 2.6.1
is-interactive: 1.0.0
@@ -7793,7 +8027,7 @@ snapshots:
[email protected]: {}
[email protected].1: {}
[email protected].2: {}
[email protected]:
dependencies:
@@ -7981,6 +8215,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]: {}
@@ -8028,6 +8264,10 @@ snapshots:
transitivePeerDependencies:
- supports-color
[email protected]:
dependencies:
is-arrayish: 0.3.2
[email protected]: {}
[email protected]: {}
@@ -8097,6 +8337,8 @@ snapshots:
dependencies:
minipass: 3.3.6
[email protected]: {}
[email protected]: {}
[email protected]:
@@ -8190,6 +8432,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]:
@@ -8227,6 +8471,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]([email protected]):
dependencies:
typescript: 5.4.5
@@ -8248,7 +8494,7 @@ snapshots:
chokidar: 3.6.0
debug: 4.3.5
esbuild: 0.21.5
execa: 5.0.0
execa: 5.1.1
globby: 11.1.0
joycon: 3.1.1
postcss-load-config: 4.0.2
@@ -8373,6 +8619,26 @@ snapshots:
dependencies:
string-width: 4.2.3
[email protected]:
dependencies:
logform: 2.6.0
readable-stream: 3.6.2
triple-beam: 1.4.1
[email protected]:
dependencies:
'@colors/colors': 1.6.0
'@dabh/diagnostics': 2.0.3
async: 3.2.5
is-stream: 2.0.1
logform: 2.6.0
one-time: 1.0.0
readable-stream: 3.6.2
safe-stable-stringify: 2.4.3
stack-trace: 0.0.10
triple-beam: 1.4.1
winston-transport: 4.7.0
[email protected]: {}
[email protected]: {}
+1 -1
View File
@@ -1,5 +1,5 @@
packages:
- "server"
- "client"
- "shared"
- "cef"
- "shared-types"
+20
View File
@@ -0,0 +1,20 @@
# Rage Framework (RageFW)
RageFW is a type-safe framework for developing Rage:MP servers. Designed with developers in mind, RageFW brings structure and efficiency to your Rage:MP servers, ensuring robust and maintainable code
## Features
- **Type-Safe Development:** Eliminate runtime errors and enhance code reliability with RageFW comprehensive type safety, making your RP server's development smoother than a Sunday drive through Los Santos
- **Wrapped RPC client:** Communicate effortlessly between server, client and cef with RPC system, wrapped in a cozy custom-typed blanket for your peace of mind
- **Logging System:** Keep track of server activities and debug like a pro with our built-in, feature-rich logging system. After all, even virtual cops need evidence
## Getting Started
*soon*
## Contributing
Join our community of developers and contribute to the ongoing development of RageFW. At the moment the only way to contribute is opening issues
## Support
Need help? Reach out via our community forums or contact us directly through our support channels. We're committed to help you as we can
> *RageFW - because in the world of GTA:RP, nobody has time for type errors*
+5 -3
View File
@@ -1,6 +1,6 @@
{
"name": "rage-fw-server",
"version": "0.0.14-alpha.0",
"version": "0.0.18-alpha.0",
"main": "dist/index.js",
"types": "dist/src/index.d.ts",
"files": [
@@ -10,10 +10,12 @@
"build": "tsup"
},
"dependencies": {
"@ragempcommunity/types-server": "^2.1.8",
"rage-fw-shared-types": "workspace:^",
"rage-rpc": "^0.4.0"
},
"peerDependencies": {
"@ragempcommunity/types-server": "^2.1.8",
"rage-fw-shared-types": "workspace:^"
},
"keywords": [],
"author": "SashaGoncharov19",
"license": "MIT",
+40 -14
View File
@@ -1,14 +1,18 @@
import rpc from 'rage-rpc'
import type {
import Logger from './logger'
import {
RageFW_ClientEvent,
RageFW_ClientEventArguments,
RageFW_ClientEventReturn,
RageFW_ICustomServerEvent,
RageFW_ServerEvent,
RageFW_ServerEventArguments,
RageFW_ServerEventCallback,
RageFW_ServerEventCallbackCustom,
RageFW_ServerEventCallbackNative,
RageFW_ServerEventReturn,
} from './types'
import { nativeEvents } from './native.events'
@@ -23,10 +27,7 @@ class Server {
): void {
rpc.register(
eventName,
async (
args: Parameters<RageFW_ICustomServerEvent[EventName]>,
info,
) => {
async (args: RageFW_ServerEventArguments<EventName>, info) => {
callback(info.player as PlayerMp, args)
},
)
@@ -51,7 +52,7 @@ class Server {
} else {
this.registerCustom(
eventName,
callback as RageFW_ServerEventCallbackCustom,
callback as unknown as RageFW_ServerEventCallbackCustom,
)
}
}
@@ -69,12 +70,41 @@ class Server {
} else {
this.registerCustom(
eventName as keyof RageFW_ICustomServerEvent,
callback as RageFW_ServerEventCallbackCustom,
callback as unknown as RageFW_ServerEventCallbackCustom,
)
}
},
)
}
private unregisterCustom<EventName extends keyof RageFW_ICustomServerEvent>(
eventName: EventName,
): void {
rpc.unregister(eventName)
}
private unregisterNative<EventName extends keyof IServerEvents>(
eventName: EventName,
): void {
mp.events.remove(eventName)
}
public unregister<EventName extends RageFW_ServerEvent>(
eventName: EventName,
): void {
if (this.isNativeEvent(eventName)) {
this.unregisterNative(eventName)
} else {
this.unregisterCustom(eventName)
}
}
private trigger<EventName extends keyof RageFW_ICustomServerEvent>(
eventName: EventName,
args: RageFW_ServerEventArguments<EventName>,
): Promise<RageFW_ServerEventReturn<EventName>> {
return rpc.call<RageFW_ServerEventReturn<EventName>>(eventName, args)
}
}
class Player {
@@ -90,11 +120,7 @@ class Player {
export const fw = {
event: new Server(),
player: new Player(),
system: {
log: new Logger(),
},
}
fw.event.register('customServerEvent', (player, args) => true)
fw.event.register('playerDeath', (player, args, killer) => {})
fw.event.registerMany({
trailerAttached: (vehicle, trailer) => undefined,
})
+36
View File
@@ -0,0 +1,36 @@
import winston, { format } from 'winston'
const { timestamp, printf, colorize } = format
export default class Logger {
private format = printf(({ message, level, timestamp }) => {
return `[${new Date(timestamp).toLocaleTimeString()}] [${level}]: ${message}`
})
private systemLogger = winston.createLogger({
transports: [new winston.transports.Console()],
format: format.combine(
colorize({
level: true,
colors: {
error: 'red',
warn: 'yellow',
info: 'white',
},
}),
timestamp(),
this.format,
),
})
public info(message: unknown) {
this.systemLogger.info(message)
}
public warn(message: unknown) {
this.systemLogger.warn(message)
}
public error(message: unknown) {
this.systemLogger.error(message)
}
}
+12
View File
@@ -2,13 +2,25 @@
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
/**
* Array of arguments of an event you pass as a generic
* These only include custom events
*/
export type RageFW_ClientEventArguments<K extends RageFW_ClientEvent> =
K extends RageFW_ClientEvent
? Parameters<RageFW_ICustomClientEvent[K]>
: never
/**
* Return type of event you pass as a generic
* These only include custom events
*/
export type RageFW_ClientEventReturn<K extends RageFW_ClientEvent> =
K extends RageFW_ClientEvent
? ReturnType<RageFW_ICustomClientEvent[K]>
+48 -10
View File
@@ -3,24 +3,62 @@
import 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 =
| keyof RageFW_ICustomServerEvent
| keyof IServerEvents
export type RageFW_ServerEventCallbackCustom<
K extends keyof RageFW_ICustomServerEvent = keyof RageFW_ICustomServerEvent,
> = (
player: PlayerMp,
args: Parameters<RageFW_ICustomServerEvent[K]>,
) => ReturnType<RageFW_ICustomServerEvent[K]>
export type RageFW_ServerEventCallbackNative<
K extends keyof IServerEvents = keyof IServerEvents,
> = IServerEvents[K]
/**
* 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> =
K extends keyof RageFW_ICustomServerEvent
? Parameters<RageFW_ServerEventCallbackCustom<K>>
: K extends keyof IServerEvents
? Parameters<RageFW_ServerEventCallbackNative<K>>
: 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> =
K extends keyof RageFW_ICustomServerEvent
? RageFW_ServerEventCallbackCustom<K>
: K extends keyof IServerEvents
? RageFW_ServerEventCallbackNative<K>
: 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> =
K extends keyof RageFW_ICustomServerEvent
? ReturnType<RageFW_ICustomServerEvent[K]>
: K extends keyof IServerEvents
? ReturnType<IServerEvents[K]>
: never
/**
* Array of arguments for an event, name of which you pass as a generic
* These only include custom events
*/
export type RageFW_ServerEventCallbackCustom<
K extends keyof RageFW_ICustomServerEvent = keyof RageFW_ICustomServerEvent,
> = (
player: PlayerMp,
args: RageFW_ServerEventArguments<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<
K extends keyof IServerEvents = keyof IServerEvents,
> = IServerEvents[K]
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "rage-fw-shared-types",
"version": "0.0.14-alpha.0",
"version": "0.0.18-alpha.0",
"types": "types/types/index.d.ts",
"files": [
"types/**/*"
+4 -7
View File
@@ -1,10 +1,7 @@
declare module 'rage-fw-shared-types' {
export interface RageFW_ICustomServerEvent {
customServerEvent(customArgs: string): boolean
customServerEvent2(...customArgs2: number[]): void
}
export interface RageFW_ICustomServerEvent {}
export interface RageFW_ICustomClientEvent {
customClientEvent(clientArgs: string): boolean
}
export interface RageFW_ICustomClientEvent {}
export interface RageFW_ICustomCefEvent {}
}
-17
View File
@@ -1,17 +0,0 @@
{
"name": "rage-fw-shared",
"version": "0.0.14-alpha.0",
"type": "module",
"main": "index.d.ts",
"files": [
"index.d.ts"
],
"scripts": {
"test": "tsup"
},
"keywords": [],
"author": "SashaGoncharov19",
"license": "MIT",
"description": "Shared client types for rage-fw",
"gitHead": "053e4fd12aa120d53e11e0d2009c0df78c1a2ad0"
}