From fcb83f66367e23f9f66f66c96de72a80f4d8621f Mon Sep 17 00:00:00 2001 From: Danya H Date: Wed, 30 Oct 2024 20:17:26 +0000 Subject: [PATCH] upd deps --- apps/browser/package.json | 10 +++--- apps/browser/src/App.tsx | 16 ++++++--- apps/client/package.json | 6 ++-- apps/client/src/index.ts | 14 ++++---- apps/server/package.json | 6 ++-- apps/server/src/index.ts | 33 +++++++++++-------- .../rage-fw-shared-types/index.d.ts | 10 +++--- package.json | 4 +-- 8 files changed, 57 insertions(+), 42 deletions(-) diff --git a/apps/browser/package.json b/apps/browser/package.json index e16d3d4..63b2b89 100644 --- a/apps/browser/package.json +++ b/apps/browser/package.json @@ -1,10 +1,10 @@ { - "name": "rage-fw-example-cef", + "name": "rage-fw-example-browser", "version": "0.0.0", "type": "module", "author": "Entity Seven Group", - "license": "CC BY-ND", - "description": "CEF side of rage-fw example", + "license": "MIT", + "description": "Browser side of rage-fw-example", "scripts": { "dev": "vite", "build": "tsc && vite build", @@ -12,9 +12,9 @@ "preview": "vite preview" }, "dependencies": { + "@entityseven/rage-fw-browser": "0.2.0", "react": "^18.2.0", - "react-dom": "^18.2.0", - "rage-fw-cef": "latest" + "react-dom": "^18.2.0" }, "devDependencies": { "@types/react": "^18.2.66", diff --git a/apps/browser/src/App.tsx b/apps/browser/src/App.tsx index 8d962b7..0d9e5de 100644 --- a/apps/browser/src/App.tsx +++ b/apps/browser/src/App.tsx @@ -1,13 +1,19 @@ -import { fw } from 'rage-fw-cef' +import { fw } from '@entityseven/rage-fw-browser' import { useEffect, useState } from 'react' function App() { - const [data, setData] = useState('') + const [data, setData] = useState('initial') useEffect(() => { - fw.event.register('customCefEvent', async ([test]) => { - setData(p => p + ' ' + test) - return 'from cef' + fw.event.register('customBrowserEvent', async message => { + setData(p => p + ' | ' + message) + + const response = await fw.event.triggerServer('customServerEvent', [ + 'hello from browser', + ]) + setData(p => p + ' | ' + response) + + return 'response from browser' }) }, []) diff --git a/apps/client/package.json b/apps/client/package.json index 0dada23..ccbc27f 100644 --- a/apps/client/package.json +++ b/apps/client/package.json @@ -2,12 +2,12 @@ "name": "rage-fw-example-client", "version": "0.1.0", "author": "Entity Seven Group", - "license": "CC BY-ND", - "description": "Client side of rage-fw example", + "license": "MIT", + "description": "Client side of rage-fw-example", "scripts": { "build": "esbuild src/index.ts --bundle --platform=node --outfile=../../server/client_packages/index.js --format=esm" }, "dependencies": { - "rage-fw-client": "latest" + "@entityseven/rage-fw-client": "0.2.0" } } diff --git a/apps/client/src/index.ts b/apps/client/src/index.ts index bc23c27..652815c 100644 --- a/apps/client/src/index.ts +++ b/apps/client/src/index.ts @@ -1,14 +1,14 @@ -import { fw } from 'rage-fw-client' +import { fw } from '@entityseven/rage-fw-client' fw.player.browser = mp.browsers.new('package://cef/index.html') -fw.event.register('cefReady', async () => { - fw.system.log.info('cefReady') +fw.event.register('customClientEvent', async msg => { + fw.system.log.info(msg) - const responseCef = await fw.player.triggerBrowser('customCefEvent', [ - 'from client', + const response = await fw.player.triggerBrowser('customBrowserEvent', [ + 'hello from client', ]) - fw.system.log.info(responseCef) + fw.system.log.info(response) - await fw.player.triggerServer('customServerEvent', ['from client']) + return 'response from client' }) diff --git a/apps/server/package.json b/apps/server/package.json index 5c2b8b6..e966619 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -2,12 +2,12 @@ "name": "rage-fw-example-server", "version": "0.1.0", "author": "Entity Seven Group", - "license": "CC BY-ND", - "description": "Server side of rage-fw example", + "license": "MIT", + "description": "Server side of rage-fw-example", "scripts": { "build": "esbuild src/index.ts --bundle --platform=node --target=node10.4 --outfile=../../server/packages/server/index.js" }, "dependencies": { - "rage-fw-server": "latest" + "@entityseven/rage-fw-server": "0.2.0" } } diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index 63e964c..a14cefa 100644 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -1,18 +1,25 @@ -import { fw } from 'rage-fw-server' +import { fw } from '@entityseven/rage-fw-server' -fw.event.register('playerJoin', async ([player]) => { - fw.system.log.info(`Connected: ${player.socialClub}`) -}) +fw.event.register('playerJoin', async player => { + fw.system.log.info('Connected:', player.socialClub) -fw.event.register('customServerEvent', async ([player, msg]) => { - fw.system.log.info(player.socialClub + ' ' + msg) - - const resFromCef = await fw.player.triggerBrowser( + const response = await fw.player.triggerClient( player, - 'customCefEvent', - ['from server'], + 'customClientEvent', + ['hello from server'], ) - fw.system.log.info(player.socialClub + ' ' + resFromCef) - - return 'from server' + fw.system.log.info(response) +}) + +fw.event.register('customServerEvent', async (player, msg) => { + fw.system.log.info(player.socialClub, msg) + + const response = await fw.player.triggerBrowser( + player, + 'customBrowserEvent', + ['hello from server'], + ) + fw.system.log.info(player.socialClub, response) + + return 'response from server' }) diff --git a/apps/shared/declarations/rage-fw-shared-types/index.d.ts b/apps/shared/declarations/rage-fw-shared-types/index.d.ts index 5156884..71c52e1 100644 --- a/apps/shared/declarations/rage-fw-shared-types/index.d.ts +++ b/apps/shared/declarations/rage-fw-shared-types/index.d.ts @@ -1,11 +1,13 @@ -declare module 'rage-fw-shared-types' { - export interface RageFW_ICustomClientEvent {} +declare module '@entityseven/rage-fw-shared-types' { + export interface RageFW_ICustomClientEvent { + customClientEvent(greetings: string): string + } export interface RageFW_ICustomServerEvent { customServerEvent(greetings: string): string } - export interface RageFW_ICustomCefEvent { - customCefEvent(greetings: string): string + export interface RageFW_ICustomBrowserEvent { + customBrowserEvent(greetings: string): string } } diff --git a/package.json b/package.json index 137f10c..9f4a955 100644 --- a/package.json +++ b/package.json @@ -11,15 +11,15 @@ "build:all": "pnpm build:client && pnpm build:server && pnpm build:cef" }, "devDependencies": { + "@entityseven/rage-fw-shared-types": "0.2.0", "@ragempcommunity/types-client": "^2.1.8", "@ragempcommunity/types-server": "^2.1.8", "@ragempcommunity/types-cef": "^2.1.8", - "rage-fw-shared-types": "latest", "esbuild": "^0.21.5", "typescript": "^5.4.5", "prettier": "^3.3.2" }, "author": "Entity Seven Group", - "license": "CC BY-ND", + "license": "MIT", "version": "0.1.0" }