Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: vite #4

Merged
merged 10 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
capture: "junit.xml"
args: "-t --formatter JUnit"
extra_libs: ox_lib+mysql+qblocales+qbox+qbox_playerdata+qbox_utils+qbox_utils_sv+qbox_utils_cl
extra_libs: ox_lib+mysql+qblocales+qbox+qbox_playerdata+qbox_lib
- name: Generate Lint Report
if: always()
uses: mikepenz/action-junit-report@v3
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ node_modules
dist
web
release
.vscode/settings.json
.vscode/settings.json
.prettierrc
.prettierignore
Empty file added .yarn.installed
Empty file.
40 changes: 25 additions & 15 deletions client/client.lua
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
lib.locale()

RegisterNUICallback('npwd:qbx_mail:getMail', function(_, cb)
local mail = lib.callback.await('npwd:qbx_mail:getMail')
local mail = lib.callback.await('npwd:qbx_mail:getMail', false)
cb({ status = 'ok', data = mail })
end)

RegisterNUICallback('npwd:qbx_mail:updateRead', function(data, cb)
lib.callback.await('npwd:qbx_mail:updateRead', false, data)
cb({})
cb({ status = 'ok' })
end)

RegisterNUICallback('npwd:qbx_mail:deleteMail', function(data, cb)
local mailDeleted = lib.callback.await('npwd:qbx_mail:deleteMail', false, data)
cb({ status = mailDeleted and 'ok' or 'error' })
cb({ status = (not mailDeleted or mailDeleted.affectedRows == 0) and 'error' or 'ok' })
end)

RegisterNUICallback('npwd:qbx_mail:updateButton', function(data, cb)
TriggerEvent(data.button.buttonEvent, data.button.buttonData)
local buttonUpdated = lib.callback.await('npwd:qbx_mail:updateButton', false, data.mailid)
cb({ status = buttonUpdated and 'ok' or 'error' })
cb({ status = buttonUpdated == 0 and 'error' or 'ok' })
end)

RegisterNetEvent('npwd:qbx_mail:newMail', function(data)
exports.npwd:sendUIMessage({type = 'npwd:qbx_mail:newMail', payload = {data}})
SetTimeout(3500, function ()
exports['npwd']:createNotification({
notisId = 'npwd:newmail',
appId = 'mail',
content = Lang:t('newmail'),
keepOpen = false,
duration = 5000,
path = '/mail',
})
end)
exports.npwd:sendNPWDMessage('npwd_qbx_mail', 'newMail', {data})
Wait(100)
exports.npwd:createNotification({
notisId = 'npwd:newmail',
appId = 'npwd_qbx_mail',
content = locale('newmail'),
keepOpen = false,
duration = 5000,
path = '/npwd_qbx_mail',
})
end)

RegisterNetEvent('npwd_qbx_mail:testMail', function()
local email = {
sender = 'Mr. Attenborough',
subject = 'Test Email',
message = 'This is a test of our electronic mail system',
}
TriggerServerEvent('qb-phone:server:sendNewMail', email)
end)
23 changes: 11 additions & 12 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
fx_version "cerulean"
game "gta5"
fx_version 'cerulean'
game 'gta5'

shared_scripts {
'@ox_lib/init.lua',
'@qbx_core/shared/locale.lua',
'locales/en.lua',
'locales/*.lua',
}
description 'npwd_qbx_mail'
repository 'https://github.com/Qbox-project/npwd_qbx_mail'
version '0.1.0'

client_script 'client/client.lua'

shared_script '@ox_lib/init.lua'

server_script {
'server/server.lua',
'@oxmysql/lib/MySQL.lua',
'server/server.lua',
}

ui_page 'web/dist/index.html'

files {
'web/dist/index.html',
'web/dist/*.js',
'web/dist/**/*',
'locales/*.json'
}

lua54 'yes'
use_experimental_fxv2_oal 'yes'
use_experimental_fxv2_oal 'yes'
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NPWD QB Mail</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"newmail": "New mail, check your phone!"
}
8 changes: 0 additions & 8 deletions locales/en.lua

This file was deleted.

3 changes: 3 additions & 0 deletions locales/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"newmail": "Vous avez reçu un mail!"
}
11 changes: 0 additions & 11 deletions locales/fr.lua

This file was deleted.

13 changes: 5 additions & 8 deletions npwd.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import App from "./src/App";
import { MailIcon, NotificationIcon } from "./icon";
import { theme } from "./src/app.theme";

export const externalAppConfig = () => ({
id: "mail",
export const path = "/npwd_qbx_mail";
export default () => ({
id: "npwd_qbx_mail",
nameLocale: "Mail",
color: "#fff",
backgroundColor: "#333",
path: "/mail",
path,
icon: MailIcon,
app: App,
notificationIcon: NotificationIcon,
theme: theme,
notificationIcon: NotificationIcon
});

export default externalAppConfig;
80 changes: 35 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,52 @@
"version": "0.0.0",
"private": true,
"devDependencies": {
"@babel/core": "7.17.5",
"@babel/preset-react": "7.16.7",
"@citizenfx/client": "^2.0.5369-1",
"@citizenfx/server": "^2.0.5369-1",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.4",
"@types/node": "^18.6.4",
"@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11",
"@types/react-router": "^5.1.18",
"@types/react-router-dom": "^5.3.3",
"@types/styled-components": "^5.1.23",
"@types/webpack-env": "^1.16.3",
"@citizenfx/client": "^2.0.7330-1",
"@citizenfx/server": "^2.0.7330-1",
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.15.4",
"@mui/material": "^5.15.4",
"@npwd/types": "1.6.1",
"@originjs/vite-plugin-federation": "^1.3.3",
"@types/node": "^20.10.8",
"@types/react": "^18.2.47",
"@types/react-dom": "^18.2.18",
"@types/react-router": "^5.1.20",
"@types/react-router-dom": "^5.3.2",
"@vitejs/plugin-react": "^4.2.1",
"add": "^2.0.6",
"babel-loader": "8.2.3",
"concurrently": "^7.0.0",
"concurrently": "^8.2.2",
"cross-env": "^7.0.3",
"html-webpack-plugin": "5.5.0",
"react-refresh": "^0.11.0",
"react-refresh-typescript": "^2.0.3",
"serve": "13.0.2",
"ts-loader": "^9.2.6",
"typescript": "^4.5.5",
"webpack": "5.66.0",
"webpack-cli": "4.9.2",
"webpack-dev-server": "4.7.4",
"yarn": "^1.22.17"
"react-refresh": "^0.14.0",
"react-refresh-typescript": "^2.0.9",
"typescript": "^5.3.3",
"vite": "^5.0.11"
},
"scripts": {
"start": "cross-env REACT_APP_IN_GAME=1 webpack-cli serve",
"build": "cross-env REACT_APP_IN_GAME=1 webpack --mode=production",
"dev": "cross-env REACT_APP_IN_GAME=0 webpack-dev-server --mode=development",
"serve": "serve dist -p 3002",
"dev": "vite --mode dev",
"dev:browser": "concurrently \"pnpm build:watch --mode dev\" \"pnpm preview:dev\"",
"build:dev": "vite build --mode dev",
"build:watch": "vite build --watch",
"build": "vite build --mode game",
"preview:dev": "vite preview --mode dev",
"clean": "rm -rf dist",
"watch": "concurrently \"yarn watch:client\" \"yarn watch:server\" \"yarn watch:nui\"",
"watch:nui": "esbuild src/index.tsx --outdir=dist/html --watch --target=es6 --bundle --loader:.png=dataurl",
"watch:client": "esbuild client/client.ts --bundle --watch --outfile=dist/client.js",
"watch:server": "esbuild server/server.ts --bundle --sourcemap --platform=node --watch --outfile=dist/server.js"
"watch:nui": "esbuild src/index.tsx --outdir=dist/html --watch --target=es6 --bundle --loader:.png=dataurl"
},
"dependencies": {
"@emotion/react": "^11.7.0",
"@emotion/styled": "^11.6.0",
"@mui/icons-material": "^5.8.4",
"@mui/material": "^5.9.3",
"@project-error/npwd-types": "^1.3.4",
"esbuild": "^0.14.23",
"eslint": "^8.10.0",
"esbuild": "^0.19.11",
"eslint": "^8.56.0",
"file-loader": "^6.2.0",
"i18next": "^21.8.16",
"prettier": "^2.5.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-fivem-hooks": "^1.0.2-1",
"react-hot-loader": "^4.13.0",
"i18next": "^23.7.16",
"prettier": "^3.1.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hot-loader": "^4.13.1",
"react-router-dom": "^5.3.0",
"recoil": "^0.7.7",
"styled-components": "^5.3.3",
"recoil-persist": "^5.1.0",
"vite-plugin-top-level-await": "^1.4.1",
"xss": "^1.0.14"
}
}
Loading
Loading