This commit is contained in:
Danya H 2025-01-26 22:30:10 +00:00
parent 037a7af2da
commit ce52e6469a
20 changed files with 197 additions and 225 deletions

View File

@ -5,10 +5,13 @@ jsxSingleQuote: false
semi: false
arrowParens: avoid
endOfLine: auto
overrides:
- files: "*.{css,sass,scss}"
options:
tabWidth: 2
plugins:
- prettier-plugin-tailwindcss
parser: typescript
- prettier-plugin-svelte
overrides:
- files: '*.{css,sass,scss}'
options:
tabWidth: 2
parser: scss
- files: '*.svelte'
options:
parser: 'svelte'

View File

@ -14,8 +14,8 @@ Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also pow
**Why use this over SvelteKit?**
- It brings its own routing solution which might not be preferable for some users.
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
- It brings its own routing solution which might not be preferable for some users.
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
This template contains as little as possible to get started with Vite + TypeScript + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.

View File

@ -1,12 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Svelte 5 Demo</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.ts"></script>
</body>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Svelte 5 Demo</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

View File

@ -1,53 +1,53 @@
{
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "eslint --c .eslintrc.yaml src",
"check": "svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json"
},
"dependencies": {
"@rage-fw/shared": "workspace:^",
"@entityseven/rage-fw-rpc": "0.2.5"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.6",
"@tsconfig/svelte": "^5.0.4",
"@types/node": "^22.5.0",
"@typescript-eslint/eslint-plugin": "^8.2.0",
"@typescript-eslint/parser": "^8.2.0",
"autoprefixer": "^10.4.20",
"eslint": "^9.3.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.9.0",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.6",
"svelte": "5.1.3",
"svelte-check": "^3.8.5",
"tslib": "^2.6.3",
"typescript": "^5.5.3",
"typescript-eslint": "^8.2.0",
"vite": "^5.4.1"
},
"name": "src-web",
"private": true,
"homepage": ".",
"version": "0.0.0",
"type": "module",
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "eslint --c .eslintrc.yaml src",
"check": "svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json"
},
"dependencies": {
"@entityseven/rage-fw-browser": "0.2.0",
"@rage-fw/shared": "workspace:^"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.6",
"@tsconfig/svelte": "^5.0.4",
"@types/node": "^22.5.0",
"@typescript-eslint/eslint-plugin": "^8.2.0",
"@typescript-eslint/parser": "^8.2.0",
"autoprefixer": "^10.4.20",
"eslint": "^9.3.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.9.0",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.3.3",
"svelte": "5.1.3",
"svelte-check": "^3.8.5",
"tslib": "^2.6.3",
"typescript": "^5.5.3",
"typescript-eslint": "^8.2.0",
"vite": "^5.4.1"
},
"name": "src-web",
"private": true,
"homepage": ".",
"version": "0.0.0",
"type": "module",
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"trustedDependencies": [
"svelte-preprocess"
]
},
"trustedDependencies": [
"svelte-preprocess"
]
}

View File

@ -1,16 +1,20 @@
<script lang="ts">
import { fw } from '@entityseven/rage-fw-browser'
import type { RageFW_ICustomBrowserEvent } from '@entityseven/rage-fw-shared-types'
import { onMount } from 'svelte'
import { events } from '@rage-fw/shared'
import { rpc } from '@/lib'
let data = $state<string>('')
let data =
$state<ReturnType<RageFW_ICustomBrowserEvent['customBrowserEvent']>>()
onMount(() => {
rpc.register(events.browser.customBrowserEvent, (args: string) => {
data = data + ' | ' + args
return 'response from cef'
})
rpc.callClient(events.client.cefReady, ['hello from cef'])
try {
fw.event.register('customBrowserEvent', async greeting => {
data += greeting
return 'from cef'
})
} catch (e) {
console.error(e)
}
})
</script>

View File

@ -1,5 +0,0 @@
import { Rpc } from '@entityseven/rage-fw-rpc'
export const rpc = new Rpc({
debugLogs: true,
})

View File

@ -1,32 +1,33 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"types": [
"../../node_modules/@ragempcommunity/types-cef",
],
"paths": {
"@": ["./src"],
"@/*": ["./src/*"],
}
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"types": [
"../../node_modules/@ragempcommunity/types-cef",
"../shared/declarations/rage-fw-shared-types/"
],
"paths": {
"@": ["./src"],
"@/*": ["./src/*"]
}
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}

View File

@ -1,12 +1,11 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"strict": true,
// "noEmit": true,
"module": "ESNext",
"moduleResolution": "bundler",
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo"
},
"include": ["vite.config.ts"]
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"strict": true,
"module": "ESNext",
"moduleResolution": "bundler",
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo"
},
"include": ["vite.config.ts"]
}

View File

@ -1,14 +1,14 @@
{
"name": "rage-fw-example-client",
"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/shared": "workspace:^",
"@entityseven/rage-fw-rpc": "0.2.5"
},
"license": "MIT",
"author": "Entity Seven Group",
"version": "0.1.0"
"name": "rage-fw-example-client",
"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/shared": "workspace:^",
"@entityseven/rage-fw-client": "0.2.0"
},
"license": "MIT",
"author": "Entity Seven Group",
"version": "0.1.0"
}

View File

@ -1,22 +1,15 @@
import { events } from '@rage-fw/shared'
import { rpc } from './lib'
import { fw } from '@entityseven/rage-fw-client'
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) => {
mp.console.logInfo(args)
const res = (await rpc.callServer(events.server.customServerEvent, [
'hello from client',
])) as string
mp.console.logInfo(res)
return 'response 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'
fw.event.register('cefReady', async () => {
fw.system.log.info('cefReady')
const responseBrowser = await fw.player.triggerBrowser(
'customBrowserEvent',
['from client'],
)
fw.system.log.info(responseBrowser)
await fw.player.triggerServer('customServerEvent', ['from client'])
})

View File

@ -1,5 +0,0 @@
import { Rpc } from '@entityseven/rage-fw-rpc'
export const rpc = new Rpc({
debugLogs: true,
})

View File

@ -1,11 +1,11 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"resolveJsonModule": true,
"baseUrl": "./src",
"types": [
"../../node_modules/@ragempcommunity/types-client",
"../shared/declarations/rage-fw-shared-types/"
]
}
"extends": "../../tsconfig.json",
"compilerOptions": {
"resolveJsonModule": true,
"baseUrl": "./src",
"types": [
"../../node_modules/@ragempcommunity/types-client",
"../shared/declarations/rage-fw-shared-types/"
]
}
}

View File

@ -1,14 +1,14 @@
{
"name": "rage-fw-example-server",
"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/shared": "workspace:^",
"@entityseven/rage-fw-rpc": "0.2.5"
},
"license": "MIT",
"author": "Entity Seven Group",
"version": "0.1.0"
"name": "rage-fw-example-server",
"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/shared": "workspace:^",
"@entityseven/rage-fw-server": "0.2.0"
},
"license": "MIT",
"author": "Entity Seven Group",
"version": "0.1.0"
}

View File

@ -1,20 +1,18 @@
import { events } from '@rage-fw/shared'
import { rpc } from './lib'
import { fw } from '@entityseven/rage-fw-server'
rpc.register('playerJoin', async (player: PlayerMp) => {
console.log(`[Server] ${player.socialClub} connected`)
fw.event.register('playerJoin', async player => {
fw.system.log.info(`Connected: ${player.socialClub}`)
})
rpc.register(
events.server.customServerEvent,
async (player: PlayerMp, args: string) => {
console.log(args)
const res = await rpc.callClient(
player,
events.client.customClientEvent,
['hello from server'],
)
console.log(res)
return 'response from server'
},
)
fw.event.register('customServerEvent', async (player, greeting) => {
fw.system.log.info(player.socialClub + ' ' + greeting)
const resFromBrowser = await fw.player.triggerBrowser(
player,
'customBrowserEvent',
['from server'],
)
fw.system.log.info(player.socialClub + ' ' + resFromBrowser)
return 'from server'
})

View File

@ -1,5 +0,0 @@
import { Rpc } from '@entityseven/rage-fw-rpc'
export const rpc = new Rpc({
debugLogs: true,
})

View File

@ -1,12 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"lib": ["DOM", "ESNext"],
"resolveJsonModule": true,
"baseUrl": "./src",
"types": [
"../../node_modules/@ragempcommunity/types-server",
"../shared/declarations/rage-fw-shared-types/"
]
}
"extends": "../../tsconfig.json",
"compilerOptions": {
"lib": ["DOM", "ESNext"],
"resolveJsonModule": true,
"baseUrl": "./src",
"types": [
"../../node_modules/@ragempcommunity/types-server",
"../shared/declarations/rage-fw-shared-types/"
]
}
}

View File

@ -1,12 +0,0 @@
export const events = {
server: {
customServerEvent: 'customServerEvent',
},
client: {
cefReady: 'cefReady',
customClientEvent: 'customClientEvent',
},
browser: {
customBrowserEvent: 'customBrowserEvent',
},
}

View File

@ -1,6 +1,6 @@
{
"name": "@rage-fw/shared",
"description": "Shared data for Rage-FW example",
"version": "0.1.0",
"main": "index.ts"
"name": "@rage-fw/shared",
"description": "Shared data for Rage-FW example",
"version": "0.1.0",
"main": "index.ts"
}

View File

@ -18,6 +18,7 @@
"@ragempcommunity/types-client": "^2.1.8",
"@ragempcommunity/types-server": "^2.1.8",
"@ragempcommunity/types-cef": "^2.1.8",
"@entityseven/rage-fw-shared-types": "0.2.0",
"esbuild": "^0.21.5",
"typescript": "^5.4.5",
"prettier": "^3.3.2"