├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ ├── ci.yml │ └── release.yml ├── .gitignore ├── LICENSE ├── README.md ├── client ├── client.lua └── utils.lua ├── fxmanifest.lua ├── server └── server.lua └── web ├── .eslintrc.cjs ├── .gitignore ├── index.html ├── package.json ├── src ├── components │ ├── App.css │ └── App.tsx ├── hooks │ └── useNuiEvent.ts ├── index.css ├── main.tsx ├── providers │ └── VisibilityProvider.tsx ├── utils │ ├── debugData.ts │ ├── fetchNui.ts │ └── misc.ts └── vite-env.d.ts ├── tsconfig.json ├── tsconfig.node.json └── vite.config.ts /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a bug report to help solve an issue 4 | title: 'Bug: TITLE' 5 | labels: New Issue 6 | assignees: '' 7 | --- 8 | 9 | **Describe the issue** 10 | 11 | A clear and concise description of what the bug is. 12 | 13 | **Expected behavior** 14 | 15 | A clear and concise description of what you expected to happen. 16 | 17 | **To Reproduce** 18 | 19 | Steps to reproduce the behavior: 20 | 1. Go to '...' 21 | 2. Click on '....' 22 | 3. Scroll down to '....' 23 | 4. See error 24 | 25 | 26 | **Media** 27 | 28 | If applicable, add a screenshot or a video to help explain your problem. 29 | 30 | **Needed information (please complete the following information):** 31 | - **Client Version:**: [e.g. Canary or Release] 32 | - **Template Version**: [e.g. 3486] Don't know?~~Check the version in your package.json~~ 33 | 34 | **Additional context** 35 | Add any other context about the issue here. 36 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Main CI 2 | on: [push, pull_request] 3 | jobs: 4 | build: 5 | name: Build Test 6 | runs-on: ubuntu-latest 7 | defaults: 8 | run: 9 | working-directory: web 10 | 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v2 14 | - name: Setup node environment 15 | uses: actions/setup-node@v2 16 | with: 17 | node-version: 20.x 18 | - name: Get yarn cache directory path 19 | id: yarn-cache-dir-path 20 | run: echo "::set-output name=dir::$(yarn config get cacheFolder)" 21 | - uses: actions/cache@v2 22 | id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) 23 | with: 24 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 25 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 26 | restore-keys: | 27 | ${{ runner.os }}-yarn- 28 | - name: Install deps 29 | run: yarn --frozen-lockfile 30 | - name: Try build 31 | run: yarn build 32 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Tagged Release 2 | on: 3 | push: 4 | tags: 5 | - "v*" 6 | jobs: 7 | create-tagged-release: 8 | name: Create Release 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout source 12 | uses: actions/checkout@v2 13 | with: 14 | fetch-depth: 0 15 | ref: ${{ github.ref }} 16 | - name: Get tag 17 | run: echo ::set-output name=VERSION_TAG::${GITHUB_REF/refs\/tags\//} 18 | id: get_tag 19 | - name: 'Setup Node.js' 20 | uses: 'actions/setup-node@v1' 21 | with: 22 | node-version: 20.x 23 | - name: Create release 24 | uses: marvinpinto/action-automatic-releases@latest 25 | with: 26 | title: React/Lua Boilerplate - ${{ steps.get_tag.outputs.VERSION_TAG }} 27 | repo_token: ${{ secrets.GITHUB_TOKEN }} 28 | prerelease: false 29 | id: auto_release 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 Project Error 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 15 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 18 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 19 | OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
{state}
126 |
25 | {JSON.stringify(data, null)}
26 |
27 | >
28 | );
29 |
30 | interface ReturnData {
31 | x: number;
32 | y: number;
33 | z: number;
34 | }
35 |
36 | const App: React.FC = () => {
37 | const [clientData, setClientData] = useStateExit with the escape key
58 | 59 | {clientData &&(events: DebugEvent
[], timer = 1000): void => {
16 | if (import.meta.env.MODE === "development" && isEnvBrowser()) {
17 | for (const event of events) {
18 | setTimeout(() => {
19 | window.dispatchEvent(
20 | new MessageEvent("message", {
21 | data: {
22 | action: event.action,
23 | data: event.data,
24 | },
25 | }),
26 | );
27 | }, timer);
28 | }
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/web/src/utils/fetchNui.ts:
--------------------------------------------------------------------------------
1 | import { isEnvBrowser } from "./misc";
2 |
3 | /**
4 | * Simple wrapper around fetch API tailored for CEF/NUI use. This abstraction
5 | * can be extended to include AbortController if needed or if the response isn't
6 | * JSON. Tailor it to your needs.
7 | *
8 | * @param eventName - The endpoint eventname to target
9 | * @param data - Data you wish to send in the NUI Callback
10 | * @param mockData - Mock data to be returned if in the browser
11 | *
12 | * @return returnData - A promise for the data sent back by the NuiCallbacks CB argument
13 | */
14 |
15 | export async function fetchNui