Skip to content

Commit

Permalink
feat: character interface fix, alt.meta based api usage, doc updates (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuyk authored Jun 6, 2024
1 parent 59a17d2 commit 9c164d6
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 53 deletions.
23 changes: 23 additions & 0 deletions docs/api/client/client-api-usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Client API Usage

The client API can be accessed through a single import.

If you want more direct imports, those are also available through your intellisense.

## alt:V Based Import
```ts
import * as alt from 'alt-client';

const Rebar = alt.getMeta('RebarClient');
```

## Direct Import
```ts
import { useRebar } from '@Client/index.js';

const Rebar = useRebar();

// Example(s)
const document = Rebar.document.account.useAccount();
const audioInstance = Rebar.player.useAudio(somePlayer);
```
8 changes: 8 additions & 0 deletions docs/api/server/server-api-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ The server API can be accessed through a single import.

If you want more direct imports, those are also available through your intellisense.

## alt:V Based Import
```ts
import * as alt from 'alt-server';

const Rebar = alt.getMeta('Rebar');
```

## Direct Import
```ts
import { useRebar } from '@Server/index.js';

Expand Down
15 changes: 15 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ order: -5

# Changelog

## Version 17

### Code Changes

- Added `alt.getMeta('Rebar')` to get Server API with one-less import
- Added `alt.getMeta('RebarClient')` to get Client API with one-less import
- Fixed character interface not being extended correctly
- Added `preinstall` script to download binaries, and build codebase once

### Docs Changes

- Covered alternative API import methods in docs

---

## Version 16

### Code Changes
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "stuyk",
"type": "module",
"version": "16",
"version": "17",
"scripts": {
"dev": "nodemon -x pnpm start",
"dev:linux": "nodemon -x pnpm start:linux",
Expand All @@ -10,7 +10,8 @@
"build:docker": "node ./scripts/compile.js -- docker",
"binaries": "pnpm altv-pkg",
"rebar:upgrade": "node ./scripts/upgrade.js",
"webview:dev": "node ./scripts/buildPluginDependencies.js && node ./scripts/copyFiles.js && node ./scripts/webview.js && pnpm -C webview run dev"
"webview:dev": "node ./scripts/buildPluginDependencies.js && node ./scripts/copyFiles.js && node ./scripts/webview.js && pnpm -C webview run dev",
"preinstall": "pnpm binaries && pnpm build:docker"
},
"devDependencies": {
"@altv/types-client": "^16.2.2",
Expand All @@ -19,19 +20,19 @@
"@altv/types-shared": "^16.2.1",
"@altv/types-webview": "^16.2.1",
"@altv/types-worker": "^16.2.0",
"@types/node": "^20.14.1",
"@types/node": "^20.14.2",
"altv-pkg": "^2.7.5",
"autoprefixer": "^10.4.19",
"fast-glob": "^3.3.2",
"fkill": "^9.0.0",
"nodemon": "^3.1.3",
"postcss": "^8.4.38",
"prettier": "^3.3.0",
"prettier": "^3.3.1",
"prettier-plugin-tailwindcss": "^0.5.14",
"retypeapp": "^3.5.0",
"shx": "^0.3.4",
"sucrase": "^3.35.0",
"tailwindcss": "^3.4.3"
"tailwindcss": "^3.4.4"
},
"dependencies": {
"@vitejs/plugin-vue": "^5.0.5",
Expand Down
90 changes: 45 additions & 45 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/main/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as alt from 'alt-client';
import './startup.js';
import { useClientApi } from './api/index.js';

Expand Down Expand Up @@ -53,3 +54,12 @@ export function useRebarClient() {
},
};
}

declare module "alt-shared" {
// extending interface by interface merging
export interface ICustomGlobalMeta {
RebarClient: ReturnType<typeof useRebarClient>
}
}

alt.setMeta('RebarClient', useRebarClient());
Loading

0 comments on commit 9c164d6

Please sign in to comment.