mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-16 22:46:03 +01:00
feat(package): interface definitions
This commit is contained in:
6
package/.gitignore
vendored
Normal file
6
package/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
node_modules
|
||||
pnpm-debug.log*
|
||||
|
||||
*.js
|
||||
*.js.map
|
||||
*.d.ts
|
||||
1
package/.npmignore
Normal file
1
package/.npmignore
Normal file
@@ -0,0 +1 @@
|
||||
.prettierrc
|
||||
9
package/.prettierrc
Normal file
9
package/.prettierrc
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"printWidth": 120,
|
||||
"singleQuote": true,
|
||||
"useTabs": false,
|
||||
"tabWidth": 2,
|
||||
"semi": true,
|
||||
"bracketSpacing": true,
|
||||
"trailingComma": "es5"
|
||||
}
|
||||
4
package/client/index.ts
Normal file
4
package/client/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import * as lib from './resource';
|
||||
export * from './resource';
|
||||
|
||||
export default lib;
|
||||
8
package/client/resource/index.ts
Normal file
8
package/client/resource/index.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export * from './interface/alert';
|
||||
export * from './interface/clipboard';
|
||||
export * from './interface/context';
|
||||
export * from './interface/input';
|
||||
export * from './interface/menu';
|
||||
export * from './interface/notify';
|
||||
export * from './interface/progress';
|
||||
export * from './interface/textui';
|
||||
10
package/client/resource/interface/alert.ts
Normal file
10
package/client/resource/interface/alert.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
interface AlertDialogProps {
|
||||
header: string;
|
||||
content: string;
|
||||
centered?: boolean;
|
||||
cancel?: boolean;
|
||||
}
|
||||
|
||||
type alertDialog = (data: AlertDialogProps) => Promise<'cancel' | 'confirm'>;
|
||||
|
||||
export const alertDialog: alertDialog = async (data) => await exports.ox_lib.alertDialog(data);
|
||||
1
package/client/resource/interface/clipboard.ts
Normal file
1
package/client/resource/interface/clipboard.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const setClipboard = (value: string) => exports.ox_lib.setClipboard(value);
|
||||
36
package/client/resource/interface/context.ts
Normal file
36
package/client/resource/interface/context.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
|
||||
|
||||
interface ContextMenuItem {
|
||||
menu?: string;
|
||||
icon?: IconName | [IconPrefix, IconName];
|
||||
iconColor?: string;
|
||||
onSelect?: () => void;
|
||||
arrow?: boolean;
|
||||
description?: boolean;
|
||||
metadata?: string | { [key: string]: any } | string[];
|
||||
event?: string;
|
||||
serverEvent?: string;
|
||||
args?: any;
|
||||
}
|
||||
|
||||
interface ContextMenuArrayItem extends ContextMenuItem {
|
||||
title: string;
|
||||
}
|
||||
|
||||
interface ContextMenuProps {
|
||||
id: string;
|
||||
title: string;
|
||||
menu?: string;
|
||||
onExit?: () => void;
|
||||
canClose?: boolean;
|
||||
options: { [key: string]: ContextMenuItem } | ContextMenuArrayItem[];
|
||||
}
|
||||
|
||||
type registerContext = (context: ContextMenuProps) => void;
|
||||
export const registerContext: registerContext = (context) => exports.ox_lib.registerContext(context);
|
||||
|
||||
export const showContext = (id: string): void => exports.ox_lib.showContext(id);
|
||||
|
||||
export const hideContext = (onExit: boolean): void => exports.ox_lib.hideContext(onExit);
|
||||
|
||||
export const getOpenContextMenu = (): string | null => exports.ox_lib.getOpenContextMenu();
|
||||
22
package/client/resource/interface/input.ts
Normal file
22
package/client/resource/interface/input.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
|
||||
|
||||
interface InputDialogRowProps {
|
||||
type: 'input' | 'number' | 'checkbox' | 'select' | 'slider';
|
||||
label: string;
|
||||
options?: { value: string; label: string; default?: string }[];
|
||||
password?: boolean;
|
||||
icon?: IconName | [IconPrefix, IconName];
|
||||
iconColor?: string;
|
||||
placeholder?: string;
|
||||
default?: string | number;
|
||||
checked?: boolean;
|
||||
min?: number;
|
||||
max?: number;
|
||||
step?: number;
|
||||
}
|
||||
|
||||
type inputDialog = (
|
||||
heading: string,
|
||||
rows: string[] | InputDialogRowProps[]
|
||||
) => Promise<Array<string | number | boolean> | undefined>;
|
||||
export const inputDialog: inputDialog = async (heading, rows) => await exports.ox_lib.inputDialog(heading, rows);
|
||||
36
package/client/resource/interface/menu.ts
Normal file
36
package/client/resource/interface/menu.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
|
||||
|
||||
type MenuPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
||||
type ChangeFunction = (selected: number, scrollIndex: number | null, args: any | null) => void;
|
||||
|
||||
interface MenuOptions {
|
||||
label: string;
|
||||
icon?: IconName | [IconPrefix, IconName];
|
||||
values?: string[];
|
||||
description?: string;
|
||||
defaultIndex?: number;
|
||||
args?: any;
|
||||
}
|
||||
|
||||
interface MenuProps {
|
||||
id: string;
|
||||
title: string;
|
||||
options: MenuOptions[];
|
||||
position?: MenuPosition;
|
||||
disableInput?: boolean;
|
||||
onClose?: () => void;
|
||||
onSelected?: ChangeFunction;
|
||||
onSideScroll?: ChangeFunction;
|
||||
}
|
||||
|
||||
type registerMenu = (data: MenuProps, cb: ChangeFunction) => void;
|
||||
export const registerMenu: registerMenu = (data, cb) => exports.ox_lib.registerMenu(data, cb);
|
||||
|
||||
export const showMenu = (id: string): string => exports.ox_lib.showMenu(id);
|
||||
|
||||
export const hideMenu = (onExit: boolean): void => exports.ox_lib.hideMenu(onExit);
|
||||
|
||||
export const getOpenMenu = (): string | null => exports.ox_lib.getOpenMenu();
|
||||
|
||||
type setMenuOptions = (id: string, options: MenuOptions | MenuOptions[], index?: number) => void;
|
||||
export const setMenuOptions: setMenuOptions = (id, options, index) => exports.ox_lib.setMenuOptions(id, options, index);
|
||||
30
package/client/resource/interface/notify.ts
Normal file
30
package/client/resource/interface/notify.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { CSSProperties } from 'react';
|
||||
import { IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
|
||||
|
||||
type NotificationPosition = 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left';
|
||||
type NotificationType = 'inform' | 'error' | 'success';
|
||||
|
||||
interface NotifyProps {
|
||||
id?: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
duration?: number;
|
||||
position?: NotificationPosition;
|
||||
type: NotificationType;
|
||||
style?: CSSProperties;
|
||||
icon?: IconName | [IconPrefix, IconName];
|
||||
iconColor?: string;
|
||||
}
|
||||
|
||||
export const notify = (data: NotifyProps): void => exports.ox_lib.notify(data);
|
||||
|
||||
interface DefaultNotifyProps {
|
||||
title?: string;
|
||||
description?: string;
|
||||
duration?: number;
|
||||
position?: NotificationPosition;
|
||||
status: 'info' | 'warning' | 'success' | 'error';
|
||||
id?: number;
|
||||
}
|
||||
|
||||
export const defaultNotify = (data: DefaultNotifyProps): void => exports.ox_lib.defaultNotify(data);
|
||||
54
package/client/resource/interface/progress.ts
Normal file
54
package/client/resource/interface/progress.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
type Position = {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
};
|
||||
|
||||
interface PropProps {
|
||||
model: string;
|
||||
bone?: number;
|
||||
pos: Position;
|
||||
rot: Position;
|
||||
}
|
||||
|
||||
interface ProgressProps {
|
||||
duration: number;
|
||||
useWhileDead?: boolean;
|
||||
allowRagdoll?: boolean;
|
||||
allowCuffed?: boolean;
|
||||
allowFalling?: boolean;
|
||||
canCancel?: boolean;
|
||||
anim?: {
|
||||
dict?: string;
|
||||
clip: string;
|
||||
flag?: number;
|
||||
blendIn?: number;
|
||||
blendOut?: number;
|
||||
duration?: number;
|
||||
playbackRate?: number;
|
||||
lockX?: boolean;
|
||||
lockY?: boolean;
|
||||
lockZ?: boolean;
|
||||
scenario?: string;
|
||||
playEnter?: boolean;
|
||||
};
|
||||
prop?: PropProps | PropProps[];
|
||||
disable?: {
|
||||
move?: boolean;
|
||||
car?: boolean;
|
||||
combat?: boolean;
|
||||
mouse?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
interface ProgressbarProps extends ProgressProps {
|
||||
label: string;
|
||||
}
|
||||
|
||||
export const progressBar = async (data: ProgressbarProps): Promise<boolean> => exports.ox_lib.progressBar(data);
|
||||
|
||||
export const progressCircle = async (data: ProgressProps): Promise<boolean> => exports.ox_lib.progressCircle(data);
|
||||
|
||||
export const progressActive = (): boolean => exports.ox_lib.progressActive();
|
||||
|
||||
export const cancelProgress = (): void => exports.ox_lib.cancelProgress();
|
||||
12
package/client/resource/interface/textui.ts
Normal file
12
package/client/resource/interface/textui.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { IconLookup, IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
|
||||
import { CSSProperties } from 'react';
|
||||
|
||||
interface OptionsProps {
|
||||
position?: 'right-center' | 'left-center' | 'top-center';
|
||||
icon?: IconName | [IconPrefix, IconName];
|
||||
iconColor?: string;
|
||||
style?: CSSProperties;
|
||||
}
|
||||
export const showTextUI = (text: string, options?: OptionsProps): void => exports.ox_lib.showTextUI(text, options);
|
||||
|
||||
export const hideTextUI = (): void => exports.ox_lib.hideTextUI();
|
||||
8
package/client/tsconfig.json
Normal file
8
package/client/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": ".",
|
||||
},
|
||||
"include": ["./**/*"],
|
||||
"exclude": ["**/node_modules"]
|
||||
}
|
||||
34
package/package.json
Normal file
34
package/package.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "@overextended/ox_lib",
|
||||
"author": "Overextended",
|
||||
"version": "1.0.0",
|
||||
"description": "JS/TS wrapper for ox_lib exports",
|
||||
"types": "./client/index.d.ts",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"prepublish": "tsc"
|
||||
},
|
||||
"keywords": [
|
||||
"fivem",
|
||||
"ox_lib",
|
||||
"ox",
|
||||
"overextended"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/overextended/ox_lib.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/overextended/ox_lib/issues"
|
||||
},
|
||||
"license": "LGPL-3.0",
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-common-types": "6.1.1",
|
||||
"@types/node": "16.9.1",
|
||||
"@types/react": "^18.0.20",
|
||||
"typescript": "^4.8.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^2.7.1"
|
||||
}
|
||||
}
|
||||
61
package/pnpm-lock.yaml
generated
Normal file
61
package/pnpm-lock.yaml
generated
Normal file
@@ -0,0 +1,61 @@
|
||||
lockfileVersion: 5.4
|
||||
|
||||
specifiers:
|
||||
'@fortawesome/fontawesome-common-types': 6.1.1
|
||||
'@types/node': 16.9.1
|
||||
'@types/react': ^18.0.20
|
||||
prettier: ^2.7.1
|
||||
typescript: ^4.8.3
|
||||
|
||||
dependencies:
|
||||
'@fortawesome/fontawesome-common-types': 6.1.1
|
||||
'@types/node': 16.9.1
|
||||
'@types/react': 18.0.20
|
||||
typescript: 4.8.3
|
||||
|
||||
devDependencies:
|
||||
prettier: 2.7.1
|
||||
|
||||
packages:
|
||||
|
||||
/@fortawesome/fontawesome-common-types/6.1.1:
|
||||
resolution: {integrity: sha512-wVn5WJPirFTnzN6tR95abCx+ocH+3IFLXAgyavnf9hUmN0CfWoDjPT/BAWsUVwSlYYVBeCLJxaqi7ZGe4uSjBA==}
|
||||
engines: {node: '>=6'}
|
||||
requiresBuild: true
|
||||
dev: false
|
||||
|
||||
/@types/node/16.9.1:
|
||||
resolution: {integrity: sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==}
|
||||
dev: false
|
||||
|
||||
/@types/prop-types/15.7.5:
|
||||
resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==}
|
||||
dev: false
|
||||
|
||||
/@types/react/18.0.20:
|
||||
resolution: {integrity: sha512-MWul1teSPxujEHVwZl4a5HxQ9vVNsjTchVA+xRqv/VYGCuKGAU6UhfrTdF5aBefwD1BHUD8i/zq+O/vyCm/FrA==}
|
||||
dependencies:
|
||||
'@types/prop-types': 15.7.5
|
||||
'@types/scheduler': 0.16.2
|
||||
csstype: 3.1.1
|
||||
dev: false
|
||||
|
||||
/@types/scheduler/0.16.2:
|
||||
resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==}
|
||||
dev: false
|
||||
|
||||
/csstype/3.1.1:
|
||||
resolution: {integrity: sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==}
|
||||
dev: false
|
||||
|
||||
/prettier/2.7.1:
|
||||
resolution: {integrity: sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/typescript/4.8.3:
|
||||
resolution: {integrity: sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==}
|
||||
engines: {node: '>=4.2.0'}
|
||||
hasBin: true
|
||||
dev: false
|
||||
23
package/tsconfig.json
Normal file
23
package/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"strict": true,
|
||||
"module": "CommonJS",
|
||||
"types": ["@types/node"],
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"target": "ESNext",
|
||||
"allowJs": false,
|
||||
"lib": ["ESNext"],
|
||||
"noEmitOnError": false,
|
||||
"resolveJsonModule": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "node",
|
||||
"experimentalDecorators": true,
|
||||
"noImplicitAny": false,
|
||||
"noEmit": false
|
||||
},
|
||||
"include": ["client"],
|
||||
"exclude": ["**/node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user