Compare commits
1 Commits
rpc-react-
...
react-18
Author | SHA1 | Date | |
---|---|---|---|
81639386e5 |
11
.gitignore
vendored
11
.gitignore
vendored
@ -1,8 +1,8 @@
|
|||||||
# Editor
|
# Editor
|
||||||
.vscode/
|
.vscode
|
||||||
.idea/
|
.idea
|
||||||
|
|
||||||
.git/
|
.git
|
||||||
|
|
||||||
# Server Files
|
# Server Files
|
||||||
server/bin
|
server/bin
|
||||||
@ -18,8 +18,3 @@ server/ragemp-server.exe
|
|||||||
# Development
|
# Development
|
||||||
node_modules
|
node_modules
|
||||||
pnpm-lock.yaml
|
pnpm-lock.yaml
|
||||||
|
|
||||||
# Build
|
|
||||||
build/
|
|
||||||
dist/
|
|
||||||
out/
|
|
@ -1,6 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "rage-fw-example-browser",
|
"name": "rage-fw-example-cef",
|
||||||
"description": "Browser side of Rage-FW example",
|
"version": "0.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"author": "Entity Seven Group",
|
||||||
|
"license": "CC BY-ND",
|
||||||
|
"description": "CEF side of rage-fw example",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
@ -8,10 +12,9 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@entityseven/rage-fw-rpc": "0.2.5",
|
|
||||||
"@rage-fw/shared": "workspace:^",
|
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0"
|
"react-dom": "^18.2.0",
|
||||||
|
"rage-fw-cef": "latest"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/react": "^18.2.66",
|
"@types/react": "^18.2.66",
|
||||||
@ -22,11 +25,7 @@
|
|||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.6",
|
"eslint-plugin-react-refresh": "^0.4.6",
|
||||||
"typescript": "^5.6.3",
|
"typescript": "^5.2.2",
|
||||||
"vite": "^5.4.10"
|
"vite": "^5.2.0"
|
||||||
},
|
}
|
||||||
"type": "module",
|
|
||||||
"license": "CC BY-ND",
|
|
||||||
"author": "Entity Seven Group",
|
|
||||||
"version": "0.1.0"
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
|
import { fw } from 'rage-fw-cef'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { events } from '@rage-fw/shared'
|
|
||||||
import { rpc } from '@/lib'
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [data, setData] = useState<string>('')
|
const [data, setData] = useState('')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
rpc.register(events.browser.customBrowserEvent, (args: string) => {
|
fw.event.register('customCefEvent', async ([test]) => {
|
||||||
setData(prev => prev + ' | ' + args)
|
setData(p => p + ' ' + test)
|
||||||
return 'response from cef'
|
return 'from cef'
|
||||||
})
|
})
|
||||||
rpc.callClient(events.client.cefReady, ['hello from cef'])
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
import { Rpc } from '@entityseven/rage-fw-rpc'
|
|
||||||
|
|
||||||
export const rpc = new Rpc({
|
|
||||||
debugLogs: true,
|
|
||||||
})
|
|
@ -22,11 +22,7 @@
|
|||||||
"types": [
|
"types": [
|
||||||
"../../node_modules/@ragempcommunity/types-cef",
|
"../../node_modules/@ragempcommunity/types-cef",
|
||||||
"../shared/declarations/rage-fw-shared-types/"
|
"../shared/declarations/rage-fw-shared-types/"
|
||||||
],
|
]
|
||||||
"paths": {
|
|
||||||
"@": ["./src"],
|
|
||||||
"@/*": ["./src/*"],
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": ["src"],
|
||||||
"references": [{ "path": "./tsconfig.node.json" }]
|
"references": [{ "path": "./tsconfig.node.json" }]
|
||||||
|
@ -6,12 +6,6 @@ export default defineConfig({
|
|||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
build: {
|
build: {
|
||||||
outDir: '../../server/client_packages/cef',
|
outDir: '../../server/client_packages/cef',
|
||||||
emptyOutDir: true,
|
emptyOutDir: true
|
||||||
},
|
}
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
'@': './src',
|
|
||||||
'@/*': './src/*',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "rage-fw-example-client",
|
"name": "rage-fw-example-client",
|
||||||
"description": "Client side of Rage-FW example",
|
"version": "0.1.0",
|
||||||
|
"author": "Entity Seven Group",
|
||||||
|
"license": "CC BY-ND",
|
||||||
|
"description": "Client side of rage-fw example",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "esbuild src/index.ts --bundle --platform=node --outfile=../../server/client_packages/index.js --format=esm"
|
"build": "esbuild src/index.ts --bundle --platform=node --outfile=../../server/client_packages/index.js --format=esm"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@entityseven/rage-fw-rpc": "0.2.5",
|
"rage-fw-client": "latest"
|
||||||
"@rage-fw/shared": "workspace:^"
|
}
|
||||||
},
|
|
||||||
"license": "CC BY-ND",
|
|
||||||
"author": "Entity Seven Group",
|
|
||||||
"version": "0.1.0"
|
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,14 @@
|
|||||||
import { events } from '@rage-fw/shared'
|
import { fw } from 'rage-fw-client'
|
||||||
import { rpc } from './lib'
|
|
||||||
|
|
||||||
rpc.browser = mp.browsers.new('package://cef/index.html')
|
fw.player.browser = mp.browsers.new('package://cef/index.html')
|
||||||
|
|
||||||
rpc.register(events.client.cefReady, async (args: string) => {
|
fw.event.register('cefReady', async () => {
|
||||||
mp.console.logInfo(args)
|
fw.system.log.info('cefReady')
|
||||||
const res = (await rpc.callServer(events.server.customServerEvent, [
|
|
||||||
'hello from client',
|
const responseCef = await fw.player.triggerBrowser('customCefEvent', [
|
||||||
])) as string
|
'from client',
|
||||||
mp.console.logInfo(res)
|
])
|
||||||
return 'response from client'
|
fw.system.log.info(responseCef)
|
||||||
})
|
|
||||||
|
await fw.player.triggerServer('customServerEvent', ['from client'])
|
||||||
rpc.register(events.client.cefReady, async (args: string) => {
|
|
||||||
mp.console.logInfo(args)
|
|
||||||
const res = (await rpc.callBrowser(events.browser.customBrowserEvent, [
|
|
||||||
'hello from client',
|
|
||||||
])) as string
|
|
||||||
mp.console.logInfo(res)
|
|
||||||
return 'response from client'
|
|
||||||
})
|
})
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
import { Rpc } from '@entityseven/rage-fw-rpc'
|
|
||||||
|
|
||||||
export const rpc = new Rpc({
|
|
||||||
debugLogs: true,
|
|
||||||
})
|
|
@ -1,14 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "rage-fw-example-server",
|
"name": "rage-fw-example-server",
|
||||||
"description": "Server side of Rage-FW example",
|
"version": "0.1.0",
|
||||||
|
"author": "Entity Seven Group",
|
||||||
|
"license": "CC BY-ND",
|
||||||
|
"description": "Server side of rage-fw example",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "esbuild src/index.ts --bundle --platform=node --target=node10.4 --outfile=../../server/packages/server/index.js"
|
"build": "esbuild src/index.ts --bundle --platform=node --target=node10.4 --outfile=../../server/packages/server/index.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@entityseven/rage-fw-rpc": "0.2.5",
|
"rage-fw-server": "latest"
|
||||||
"@rage-fw/shared": "workspace:^"
|
}
|
||||||
},
|
|
||||||
"license": "CC BY-ND",
|
|
||||||
"author": "Entity Seven Group",
|
|
||||||
"version": "0.1.0"
|
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
import { events } from '@rage-fw/shared'
|
import { fw } from 'rage-fw-server'
|
||||||
import { rpc } from './lib'
|
|
||||||
|
|
||||||
rpc.register('playerJoin', async (player: PlayerMp) => {
|
fw.event.register('playerJoin', async ([player]) => {
|
||||||
console.log(`[Server] ${player.socialClub} connected`)
|
fw.system.log.info(`Connected: ${player.socialClub}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
rpc.register(
|
fw.event.register('customServerEvent', async ([player, msg]) => {
|
||||||
events.server.customServerEvent,
|
fw.system.log.info(player.socialClub + ' ' + msg)
|
||||||
async (player: PlayerMp, args: string) => {
|
|
||||||
console.log(args)
|
const resFromCef = await fw.player.triggerBrowser(
|
||||||
const res = await rpc.callClient(
|
|
||||||
player,
|
player,
|
||||||
events.client.customClientEvent,
|
'customCefEvent',
|
||||||
['hello from server'],
|
['from server'],
|
||||||
)
|
)
|
||||||
console.log(res)
|
fw.system.log.info(player.socialClub + ' ' + resFromCef)
|
||||||
return 'response from server'
|
|
||||||
},
|
return 'from server'
|
||||||
)
|
})
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
import { Rpc } from '@entityseven/rage-fw-rpc'
|
|
||||||
|
|
||||||
export const rpc = new Rpc({
|
|
||||||
debugLogs: true,
|
|
||||||
})
|
|
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"extends": "../../tsconfig.json",
|
"extends": "../../tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["DOM", "ESNext"],
|
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"baseUrl": "./src",
|
"baseUrl": "./src",
|
||||||
"types": [
|
"types": [
|
||||||
|
11
apps/shared/declarations/rage-fw-shared-types/index.d.ts
vendored
Normal file
11
apps/shared/declarations/rage-fw-shared-types/index.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
declare module 'rage-fw-shared-types' {
|
||||||
|
export interface RageFW_ICustomClientEvent {}
|
||||||
|
|
||||||
|
export interface RageFW_ICustomServerEvent {
|
||||||
|
customServerEvent(greetings: string): string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RageFW_ICustomCefEvent {
|
||||||
|
customCefEvent(greetings: string): string
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +0,0 @@
|
|||||||
export const events = {
|
|
||||||
server: {
|
|
||||||
customServerEvent: 'customServerEvent',
|
|
||||||
},
|
|
||||||
client: {
|
|
||||||
cefReady: 'cefReady',
|
|
||||||
customClientEvent: 'customClientEvent',
|
|
||||||
},
|
|
||||||
browser: {
|
|
||||||
customBrowserEvent: 'customBrowserEvent',
|
|
||||||
},
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@rage-fw/shared",
|
|
||||||
"description": "Shared data for Rage-FW example",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"main": "index.ts"
|
|
||||||
}
|
|
19
package.json
19
package.json
@ -1,30 +1,25 @@
|
|||||||
{
|
{
|
||||||
"name": "framework-example",
|
"name": "framework-example",
|
||||||
"description": "This project is an example of RAGE FW usage",
|
"description": "This project is example of RAGE FW usage.",
|
||||||
"workspaces": [
|
"workspaces": ["apps/*"],
|
||||||
"apps/*"
|
|
||||||
],
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"server:update": "cd server && rage-win64.exe",
|
"server:update": "cd server && rage-win64.exe",
|
||||||
"server:run": "cd server && ragemp-server.exe",
|
|
||||||
"i:client": "cd apps/client && pnpm i",
|
|
||||||
"i:server": "cd apps/server && pnpm i",
|
|
||||||
"i:browser": "cd apps/browser && pnpm i",
|
|
||||||
"build:client": "cd apps/client && pnpm build",
|
"build:client": "cd apps/client && pnpm build",
|
||||||
"build:server": "cd apps/server && pnpm build",
|
"build:server": "cd apps/server && pnpm build",
|
||||||
"build:browser": "cd apps/cef && pnpm build",
|
"build:cef": "cd apps/cef && pnpm build",
|
||||||
"build:all": "pnpm build:client && pnpm build:server && pnpm build:browser",
|
"build:all": "pnpm build:client && pnpm build:server && pnpm build:cef"
|
||||||
"build": "pnpm build:all"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ragempcommunity/types-client": "^2.1.8",
|
"@ragempcommunity/types-client": "^2.1.8",
|
||||||
"@ragempcommunity/types-server": "^2.1.8",
|
"@ragempcommunity/types-server": "^2.1.8",
|
||||||
"@ragempcommunity/types-cef": "^2.1.8",
|
"@ragempcommunity/types-cef": "^2.1.8",
|
||||||
|
"rage-fw-shared-types": "latest",
|
||||||
"esbuild": "^0.21.5",
|
"esbuild": "^0.21.5",
|
||||||
"typescript": "^5.4.5",
|
"typescript": "^5.4.5",
|
||||||
"prettier": "^3.3.2"
|
"prettier": "^3.3.2"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
|
||||||
"author": "Entity Seven Group",
|
"author": "Entity Seven Group",
|
||||||
|
"license": "CC BY-ND",
|
||||||
"version": "0.1.0"
|
"version": "0.1.0"
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,5 @@
|
|||||||
packages:
|
packages:
|
||||||
- "apps/*"
|
- "apps/browser"
|
||||||
|
- "apps/client"
|
||||||
|
- "apps/server"
|
||||||
|
- "apps/shared"
|
Loading…
Reference in New Issue
Block a user