Compare commits
23
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2113b5ae29 | ||
|
|
ff37d353bd | ||
|
|
3958fd458a | ||
|
|
44602be670 | ||
|
|
aed9bf2091 | ||
|
|
512b37cdbd | ||
|
|
c163ef6585 | ||
|
|
2775b42f59 | ||
|
|
19fdebd986 | ||
|
|
1923cb7a04 | ||
|
|
b336f1e1fe | ||
|
|
e649b46351 | ||
|
|
6d0ae3191f | ||
|
|
47ce0a6b16 | ||
|
|
77d667ce67 | ||
|
|
5064fb6347 | ||
|
|
bea9d570ad | ||
|
|
3b20276486 | ||
|
|
39dfe4c71d | ||
|
|
318c6b2387 | ||
|
|
e408a599a5 | ||
|
|
3ce49e85a9 | ||
|
|
b3e152c4f0 |
@@ -1,9 +0,0 @@
|
||||
import { build } from 'esbuild'
|
||||
|
||||
build({
|
||||
entryPoints: ['./src/index.ts'],
|
||||
format: 'esm',
|
||||
platform: 'node',
|
||||
target: 'node10.4',
|
||||
outdir: './dist',
|
||||
}).then(r => console.log('Successfully build.'))
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"compilationOptions": {
|
||||
"followSymlinks": true,
|
||||
"preferredConfigPath": "../tsconfig.json"
|
||||
},
|
||||
"entries": [
|
||||
{
|
||||
"filePath": "./src/index.ts",
|
||||
"outFile": "./dist/index.d.ts"
|
||||
}
|
||||
]
|
||||
}
|
||||
+8
-7
@@ -1,21 +1,22 @@
|
||||
{
|
||||
"name": "rage-fw-client",
|
||||
"version": "0.0.2-alpha.0",
|
||||
"version": "0.0.13-alpha.0",
|
||||
"main": "dist/index.js",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/**/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "node --es-module-specifier-resolution=node build.js",
|
||||
"types": "dts-bundle-generator --config dts.config.json"
|
||||
"build": "tsup"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"dependencies": {
|
||||
"@ragempcommunity/types-client": "^2.1.8",
|
||||
"rage-fw-shared-types": "workspace:^"
|
||||
"rage-fw-shared-types": "workspace:^",
|
||||
"rage-rpc": "^0.4.0"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "SashaGoncharov19",
|
||||
"license": "MIT",
|
||||
"description": "Client side of rage-fw"
|
||||
"description": "Client side of rage-fw",
|
||||
"gitHead": "053e4fd12aa120d53e11e0d2009c0df78c1a2ad0"
|
||||
}
|
||||
|
||||
+16
-2
@@ -1,10 +1,23 @@
|
||||
import rpc from 'rage-rpc'
|
||||
import type {
|
||||
import {
|
||||
RageFW_ClientEventReturn,
|
||||
RageFW_ClientEvent,
|
||||
RageFW_ClientEventArguments,
|
||||
RageFW_ClientServerCallback,
|
||||
RageFW_ClientServerEvent,
|
||||
} from './types'
|
||||
|
||||
class Client {
|
||||
public register<EventName extends RageFW_ClientServerEvent>(
|
||||
eventName: EventName,
|
||||
callback: RageFW_ClientServerCallback<EventName>,
|
||||
): void {
|
||||
rpc.register(eventName, data => {
|
||||
return callback(...data)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
class Player {
|
||||
public triggerServer<EventName extends RageFW_ClientEvent>(
|
||||
eventName: EventName,
|
||||
@@ -14,6 +27,7 @@ class Player {
|
||||
}
|
||||
}
|
||||
|
||||
export const rage = {
|
||||
export const fw = {
|
||||
event: new Client(),
|
||||
player: new Player(),
|
||||
}
|
||||
|
||||
+14
-7
@@ -1,17 +1,24 @@
|
||||
/// <reference types="@ragempcommunity/types-client" />
|
||||
|
||||
import type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types'
|
||||
import type {
|
||||
RageFW_ICustomClientEvent,
|
||||
RageFW_ICustomServerEvent,
|
||||
} from 'rage-fw-shared-types'
|
||||
|
||||
export type RageFW_ClientEvent =
|
||||
| keyof RageFW_ICustomClientEvent
|
||||
| keyof IClientEvents
|
||||
export type RageFW_ClientEvent = keyof RageFW_ICustomServerEvent
|
||||
|
||||
export type RageFW_ClientEventArguments<K extends RageFW_ClientEvent> =
|
||||
K extends keyof RageFW_ICustomClientEvent
|
||||
? Parameters<RageFW_ICustomClientEvent[K]>
|
||||
: (K extends keyof IClientEvents ? IClientEvents[K] : never)[]
|
||||
K extends keyof RageFW_ICustomServerEvent
|
||||
? Parameters<RageFW_ICustomServerEvent[K]>
|
||||
: never
|
||||
|
||||
export type RageFW_ClientEventReturn<K extends RageFW_ClientEvent> =
|
||||
K extends keyof RageFW_ICustomClientEvent
|
||||
? ReturnType<RageFW_ICustomClientEvent[K]>
|
||||
: never
|
||||
|
||||
export type RageFW_ClientServerEvent = keyof RageFW_ICustomClientEvent
|
||||
|
||||
export type RageFW_ClientServerCallback<K extends RageFW_ClientServerEvent> = (
|
||||
...args: Parameters<RageFW_ICustomClientEvent[K]>
|
||||
) => ReturnType<RageFW_ICustomClientEvent[K]>
|
||||
|
||||
+22
-5
@@ -1,9 +1,26 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"typeRoots": [
|
||||
"@ragempcommunity/types-client"
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"display": "Base",
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
],
|
||||
"baseUrl": "./src"
|
||||
"compilerOptions": {
|
||||
"incremental": false,
|
||||
"composite": false,
|
||||
"target": "ES2022",
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { defineConfig } from 'tsup'
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/index.ts'],
|
||||
outDir: './dist',
|
||||
format: ['cjs'],
|
||||
noExternal: ['rage-rpc'],
|
||||
dts: true,
|
||||
splitting: false,
|
||||
sourcemap: false,
|
||||
clean: true,
|
||||
})
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
||||
"version": "0.0.2-alpha.0",
|
||||
"version": "0.0.13-alpha.0",
|
||||
"npmClient": "pnpm"
|
||||
}
|
||||
|
||||
+8
-4
@@ -1,15 +1,19 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"publish": "pnpm build && lerna publish --force-publish",
|
||||
"build": "lerna run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ragempcommunity/types-cef": "^2.1.8",
|
||||
"@ragempcommunity/types-client": "^2.1.8",
|
||||
"@ragempcommunity/types-server": "^2.1.8",
|
||||
"dts-bundle-generator": "^9.5.1",
|
||||
"esbuild": "^0.21.5",
|
||||
"@microsoft/api-extractor": "^7.47.0",
|
||||
"tsup": "^8.1.0",
|
||||
"lerna": "^8.1.3",
|
||||
"prettier": "^3.3.1",
|
||||
"rage-rpc": "^0.4.0",
|
||||
"typescript": "^5.4.5",
|
||||
"lerna": "^8.1.3"
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
Generated
+985
-44
File diff suppressed because it is too large
Load Diff
@@ -1,9 +0,0 @@
|
||||
import { build } from 'esbuild'
|
||||
|
||||
build({
|
||||
entryPoints: ['./src/index.ts'],
|
||||
format: 'esm',
|
||||
platform: 'node',
|
||||
target: 'node10.4',
|
||||
outdir: './dist',
|
||||
}).then(r => console.log('Successfully build.'))
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"compilationOptions": {
|
||||
"followSymlinks": true,
|
||||
"preferredConfigPath": "../tsconfig.json"
|
||||
},
|
||||
"entries": [
|
||||
{
|
||||
"filePath": "./src/index.ts",
|
||||
"outFile": "./dist/index.d.ts",
|
||||
"libraries": {
|
||||
"inlinedLibraries": ["@ragempcommunity/types-server"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
+9
-8
@@ -1,21 +1,22 @@
|
||||
{
|
||||
"name": "rage-fw-server",
|
||||
"version": "0.0.2-alpha.0",
|
||||
"version": "0.0.13-alpha.0",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"type": "module",
|
||||
"types": "dist/src/index.d.ts",
|
||||
"files": [
|
||||
"dist/**/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "node --es-module-specifier-resolution=node build.js",
|
||||
"types": "dts-bundle-generator --config dts.config.json"
|
||||
"build": "tsup"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"rage-fw-shared-types": "workspace:^"
|
||||
"dependencies": {
|
||||
"@ragempcommunity/types-server": "^2.1.8",
|
||||
"rage-fw-shared-types": "workspace:^",
|
||||
"rage-rpc": "^0.4.0"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "SashaGoncharov19",
|
||||
"license": "MIT",
|
||||
"description": "Server side for rage-fw"
|
||||
"description": "Server side for rage-fw",
|
||||
"gitHead": "053e4fd12aa120d53e11e0d2009c0df78c1a2ad0"
|
||||
}
|
||||
|
||||
+34
-5
@@ -1,27 +1,56 @@
|
||||
import rpc from 'rage-rpc'
|
||||
import type { RageFW_ServerEvent, RageFW_ServerEventCallback } from './types.js'
|
||||
import {
|
||||
RageFW_ClientEvent,
|
||||
RageFW_ClientEventArguments,
|
||||
RageFW_ClientEventReturn,
|
||||
RageFW_ServerEvent,
|
||||
RageFW_ServerEventCallback,
|
||||
} from './types.js'
|
||||
import { nativeEvents } from './native.events'
|
||||
|
||||
class Server {
|
||||
public register<EventName extends RageFW_ServerEvent>(
|
||||
eventName: EventName,
|
||||
callback: RageFW_ServerEventCallback<EventName>,
|
||||
): void {
|
||||
if (nativeEvents.includes(eventName)) {
|
||||
mp.events.add(eventName, callback)
|
||||
} else {
|
||||
rpc.register(eventName, callback as rpc.ProcedureListener)
|
||||
}
|
||||
}
|
||||
|
||||
public registerMany<EventName extends RageFW_ServerEvent>(events: {
|
||||
[event in EventName]: RageFW_ServerEventCallback<event>
|
||||
}): void {
|
||||
Object.entries(events).map(([eventName, callback]) =>
|
||||
Object.entries(events).map(([eventName, callback]) => {
|
||||
if (nativeEvents.includes(eventName)) {
|
||||
mp.events.add(
|
||||
eventName as keyof IServerEvents,
|
||||
callback as (...arg: unknown[]) => void,
|
||||
)
|
||||
} else {
|
||||
rpc.register(eventName, (args: unknown[]) => {
|
||||
return Array.isArray(args)
|
||||
? (callback as (...arg: typeof args) => void)(...args)
|
||||
: (callback as (arg: typeof args) => void)(args)
|
||||
}),
|
||||
)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const rage = {
|
||||
class Player {
|
||||
public triggerClient<EventName extends RageFW_ClientEvent>(
|
||||
player: PlayerMp,
|
||||
eventName: EventName,
|
||||
...args: RageFW_ClientEventArguments<EventName>
|
||||
): Promise<RageFW_ClientEventReturn<EventName>> {
|
||||
return rpc.callClient(player, eventName, args)
|
||||
}
|
||||
}
|
||||
|
||||
export const fw = {
|
||||
event: new Server(),
|
||||
player: new Player(),
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
export const nativeEvents = [
|
||||
'entityCreated',
|
||||
'entityDestroyed',
|
||||
'entityModelChange',
|
||||
'incomingConnection',
|
||||
'packagesLoaded',
|
||||
'playerChat',
|
||||
'playerCommand',
|
||||
'playerDamage',
|
||||
'playerDeath',
|
||||
'playerEnterCheckpoint',
|
||||
'playerEnterColshape',
|
||||
'playerEnterVehicle',
|
||||
'playerExitCheckpoint',
|
||||
'playerExitColshape',
|
||||
'playerExitVehicle',
|
||||
'playerJoin',
|
||||
'playerQuit',
|
||||
'playerReachWaypoint',
|
||||
'playerReady',
|
||||
'playerSpawn',
|
||||
'playerStartEnterVehicle',
|
||||
'playerStartExitVehicle',
|
||||
'playerStreamIn',
|
||||
'playerStreamOut',
|
||||
'playerWeaponChange',
|
||||
'serverShutdown',
|
||||
'trailerAttached',
|
||||
'vehicleDamage',
|
||||
'vehicleDeath',
|
||||
'vehicleHornToggle',
|
||||
'vehicleSirenToggle',
|
||||
]
|
||||
+16
-1
@@ -1,6 +1,9 @@
|
||||
/// <reference types="@ragempcommunity/types-server" />
|
||||
|
||||
import type { RageFW_ICustomServerEvent } from 'rage-fw-shared-types'
|
||||
import type {
|
||||
RageFW_ICustomServerEvent,
|
||||
RageFW_ICustomClientEvent,
|
||||
} from 'rage-fw-shared-types'
|
||||
|
||||
export type RageFW_ServerEvent =
|
||||
| keyof RageFW_ICustomServerEvent
|
||||
@@ -16,3 +19,15 @@ export type RageFW_ServerEventCallback<
|
||||
: K extends keyof IServerEvents
|
||||
? ThisifyServerEvents[K]
|
||||
: never
|
||||
|
||||
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
|
||||
|
||||
+21
-5
@@ -1,9 +1,25 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"typeRoots": [
|
||||
"@ragempcommunity/types-server"
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"display": "Base",
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
],
|
||||
"baseUrl": "./src"
|
||||
"compilerOptions": {
|
||||
"incremental": false,
|
||||
"composite": false,
|
||||
"target": "ES2022",
|
||||
"experimentalDecorators": true,
|
||||
"moduleDetection": "auto",
|
||||
"module": "CommonJS",
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"declarationMap": false,
|
||||
"sourceMap": false,
|
||||
"downlevelIteration": false,
|
||||
"inlineSourceMap": false,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "rage-fw-shared-types",
|
||||
"version": "0.0.2-alpha.0",
|
||||
"version": "0.0.13-alpha.0",
|
||||
"types": "types/types/index.d.ts",
|
||||
"files": [
|
||||
"types/**/*"
|
||||
],
|
||||
"author": "SashaGoncharov19",
|
||||
"license": "MIT",
|
||||
"type": "module"
|
||||
"type": "module",
|
||||
"gitHead": "053e4fd12aa120d53e11e0d2009c0df78c1a2ad0"
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rage-fw-shared",
|
||||
"version": "0.0.2-alpha.0",
|
||||
"version": "0.0.13-alpha.0",
|
||||
"type": "module",
|
||||
"main": "index.d.ts",
|
||||
"files": [
|
||||
@@ -12,5 +12,6 @@
|
||||
"keywords": [],
|
||||
"author": "SashaGoncharov19",
|
||||
"license": "MIT",
|
||||
"description": "Shared client types for rage-fw"
|
||||
"description": "Shared client types for rage-fw",
|
||||
"gitHead": "053e4fd12aa120d53e11e0d2009c0df78c1a2ad0"
|
||||
}
|
||||
|
||||
+3
-5
@@ -1,16 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"lib": ["ESNext","ES2019"],
|
||||
"moduleResolution": "node",
|
||||
"module": "ESNext",
|
||||
"strict": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"strict": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"declaration": true,
|
||||
"useUnknownInCatchVariables": false,
|
||||
"exactOptionalPropertyTypes": true,
|
||||
"typeRoots": [
|
||||
|
||||
Reference in New Issue
Block a user