lenix 1.7.11 → 1.7.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/_init.ts +0 -1
- package/client/blip.ts +0 -2
- package/client/cam.ts +0 -2
- package/client/client.ts +9 -2
- package/client/control/binds.json +87 -0
- package/client/control/disable/index.ts +12 -0
- package/client/control/index.ts +42 -0
- package/client/control/onDisabled/index.ts +15 -0
- package/client/control/onHold/index.ts +12 -0
- package/client/control/onPress/index.ts +12 -0
- package/client/control/onRelease/index.ts +12 -0
- package/client/control/onReleased/index.ts +11 -0
- package/client/nearest.ts +0 -1
- package/client/nui.ts +0 -1
- package/client/pool.ts +0 -1
- package/client/timer.ts +0 -2
- package/package.json +9 -5
- package/shared/api.ts +33 -0
- package/shared/index.ts +1 -1
- package/shared/assert.ts +0 -11
package/client/_init.ts
CHANGED
package/client/blip.ts
CHANGED
package/client/cam.ts
CHANGED
package/client/client.ts
CHANGED
|
@@ -138,8 +138,15 @@ export const client = {
|
|
|
138
138
|
},
|
|
139
139
|
|
|
140
140
|
/* */
|
|
141
|
-
coords
|
|
142
|
-
|
|
141
|
+
coords<T extends true | undefined = undefined>(
|
|
142
|
+
excludeH?: T,
|
|
143
|
+
isAlive?: boolean
|
|
144
|
+
): T extends true ? Vec3 : Vec4 {
|
|
145
|
+
return (
|
|
146
|
+
excludeH === true
|
|
147
|
+
? client.entity.coords(this.entity(), true, isAlive)
|
|
148
|
+
: client.entity.coords(this.entity(), false, isAlive)
|
|
149
|
+
) as T extends true ? Vec3 : Vec4;
|
|
143
150
|
},
|
|
144
151
|
|
|
145
152
|
/* */
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"V": [0, 236, 320, 325],
|
|
3
|
+
"MOUSE RIGHT": [1, 6, 13, 66, 98, 220, 270, 271, 282, 283, 286, 287, 290, 333],
|
|
4
|
+
"MOUSE DOWN": [2, 4, 12, 67, 95, 112, 198, 221, 273, 291, 293, 332],
|
|
5
|
+
"S": [8, 33, 60, 72, 88, 126, 139, 149, 151, 196, 219, 233, 268, 269, 302],
|
|
6
|
+
"D": [9, 30, 35, 59, 64, 90, 195, 218, 235, 267, 278, 279, 342],
|
|
7
|
+
"PAGEUP": [10],
|
|
8
|
+
"PAGEDOWN": [11],
|
|
9
|
+
"SCROLLWHEEL DOWN": [14, 16, 50, 97, 180, 198, 242, 262, 334, 336],
|
|
10
|
+
"SCROLLWHEEL UP": [17, 96, 99, 115, 181, 241, 261, 335],
|
|
11
|
+
"ENTER": [18, 176, 191, 201, 215],
|
|
12
|
+
"LEFT MOUSE BUTTON": [18, 24, 122, 135, 142, 144, 176, 223, 229, 237, 257, 329, 346],
|
|
13
|
+
"SPACEBAR": [18, 22, 55, 76, 102, 143, 179, 203, 216, 255, 298, 321, 328, 353],
|
|
14
|
+
"LEFT ALT": [19],
|
|
15
|
+
"Z": [20, 48],
|
|
16
|
+
"LEFT SHIFT": [21, 61, 131, 137, 155, 209, 254, 340, 352],
|
|
17
|
+
"F": [23, 49, 56, 75, 144, 145, 251],
|
|
18
|
+
"E": [23, 38, 46, 51, 54, 86, 103, 119, 184, 206, 350, 351, 355, 356],
|
|
19
|
+
"RIGHT MOUSE BUTTON": [25, 68, 70, 91, 114, 177, 222, 225, 238, 330, 331, 347],
|
|
20
|
+
"C": [26, 79, 253, 319, 324],
|
|
21
|
+
"ARROW UP": [27, 172, 188, 300, 303],
|
|
22
|
+
"B": [29, 170, 305],
|
|
23
|
+
"W": [32, 61, 71, 77, 87, 111, 129, 136, 150, 232],
|
|
24
|
+
"A": [34, 63, 89, 124, 133, 147, 234, 338],
|
|
25
|
+
"LEFT CTRL": [36, 60, 62, 132, 210, 224, 280, 281, 326, 341, 343],
|
|
26
|
+
"TAB": [37, 192, 204, 211, 349],
|
|
27
|
+
"[": [39, 41, 43, 100, 116, 274, 275, 276, 277, 312],
|
|
28
|
+
"]": [40, 42, 197, 313],
|
|
29
|
+
"Q": [44, 52, 85, 138, 141, 152, 205, 264],
|
|
30
|
+
"R": [45, 80, 140, 250, 263, 310],
|
|
31
|
+
"G": [47, 58, 113, 183],
|
|
32
|
+
"F9": [56],
|
|
33
|
+
"F10": [57],
|
|
34
|
+
"X": [73, 105, 120, 131, 154, 186, 203, 214, 224, 252, 256, 296, 323, 337, 345, 349, 354, 357],
|
|
35
|
+
"H": [74, 101, 104, 304],
|
|
36
|
+
".": [81],
|
|
37
|
+
",": [82],
|
|
38
|
+
"=": [83],
|
|
39
|
+
"-": [84],
|
|
40
|
+
"NUMPAD-": [96],
|
|
41
|
+
"NUMPAD+": [97, 314],
|
|
42
|
+
"NUMPAD 6": [107, 109, 123, 125],
|
|
43
|
+
"NUMPAD 4": [108, 124],
|
|
44
|
+
"NUMPAD 5": [110, 112, 126, 128],
|
|
45
|
+
"NUMPAD 8": [111, 127],
|
|
46
|
+
"NUMPAD 7": [117],
|
|
47
|
+
"NUMPAD 9": [118],
|
|
48
|
+
"INSERT": [121],
|
|
49
|
+
"1": [157],
|
|
50
|
+
"2": [158],
|
|
51
|
+
"6": [159],
|
|
52
|
+
"3": [160],
|
|
53
|
+
"7": [161],
|
|
54
|
+
"8": [162],
|
|
55
|
+
"9": [163],
|
|
56
|
+
"4": [164],
|
|
57
|
+
"5": [165],
|
|
58
|
+
"F5": [166, 318, 327],
|
|
59
|
+
"F6": [167],
|
|
60
|
+
"F7": [168],
|
|
61
|
+
"F8": [169],
|
|
62
|
+
"F3": [170],
|
|
63
|
+
"CAPSLOCK": [137, 171, 217],
|
|
64
|
+
"ARROW DOWN": [173, 187, 233, 299],
|
|
65
|
+
"ARROW LEFT": [174, 189, 308],
|
|
66
|
+
"ARROW RIGHT": [175, 190, 307],
|
|
67
|
+
"BACKSPACE": [177, 194, 202],
|
|
68
|
+
"DELETE": [178, 214, 256, 296],
|
|
69
|
+
"Y": [178, 204, 246, 348],
|
|
70
|
+
"ESC": [177, 200, 202, 322],
|
|
71
|
+
"P": [199],
|
|
72
|
+
"NUMPAD ENTER": [201],
|
|
73
|
+
"PAGE DOWN": [207, 317],
|
|
74
|
+
"PAGE UP": [208, 316],
|
|
75
|
+
"HOME": [212, 213],
|
|
76
|
+
"T": [245, 309],
|
|
77
|
+
"M": [244, 301],
|
|
78
|
+
"N": [249, 306],
|
|
79
|
+
"~": [243],
|
|
80
|
+
"`": [243],
|
|
81
|
+
"K": [311],
|
|
82
|
+
"U": [303],
|
|
83
|
+
"F1": [288],
|
|
84
|
+
"F2": [289],
|
|
85
|
+
"F11": [344],
|
|
86
|
+
"SCROLLWHEEL BUTTON (PRESS)": [27, 348]
|
|
87
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Bind, isInvalidKey, noop, onKey } from ".."
|
|
2
|
+
|
|
3
|
+
export default (key: Bind) => {
|
|
4
|
+
if (isInvalidKey(key)) return false
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
setTick(() => onKey(DisableControlAction, key, noop, true) )
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.error(error)
|
|
10
|
+
}
|
|
11
|
+
return true
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { trace } from '../../../tr_lib/package/src/shared'
|
|
2
|
+
import binds from './binds.json'
|
|
3
|
+
|
|
4
|
+
export type Bind = keyof typeof binds
|
|
5
|
+
export const noop = () => {}
|
|
6
|
+
|
|
7
|
+
export const onKey = (Function: Function, key: Bind, callback: Function, ...parameters: any) => {
|
|
8
|
+
for (const index of binds[key]) {
|
|
9
|
+
if (Function(0, index, ...parameters)) {
|
|
10
|
+
if (callback) {
|
|
11
|
+
callback()
|
|
12
|
+
}
|
|
13
|
+
break
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const isInvalidKey = (key: Bind) => {
|
|
19
|
+
if (!binds[key]) {
|
|
20
|
+
trace(`Invalid control key passed: ${key}`)
|
|
21
|
+
return true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const getKeyByIndex = (index: number) => {
|
|
26
|
+
for (const key of Object.keys(binds)) {
|
|
27
|
+
for (const value of binds[key as Bind]) {
|
|
28
|
+
if (value == index) {
|
|
29
|
+
return key
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
import disable from './disable'
|
|
36
|
+
import onDisabled from './onDisabled'
|
|
37
|
+
import onHold from './onHold'
|
|
38
|
+
import onPress from './onPress'
|
|
39
|
+
import onRelease from './onRelease'
|
|
40
|
+
import onReleased from './onReleased'
|
|
41
|
+
|
|
42
|
+
export default { disable, onDisabled, onHold, onPress, onRelease, onReleased }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Bind, isInvalidKey, noop, onKey } from ".."
|
|
2
|
+
|
|
3
|
+
export default (key: Bind, callback: Function) => {
|
|
4
|
+
if (isInvalidKey(key)) return false
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
setTick(() => {
|
|
8
|
+
onKey(DisableControlAction, key, noop, true)
|
|
9
|
+
onKey(IsDisabledControlJustPressed, key, callback)
|
|
10
|
+
})
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.error(error)
|
|
13
|
+
}
|
|
14
|
+
return true
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Bind, isInvalidKey, onKey } from ".."
|
|
2
|
+
|
|
3
|
+
export default (key: Bind, callback: Function) => {
|
|
4
|
+
if (isInvalidKey(key)) return false
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
setTick(() => onKey(IsControlPressed, key, callback))
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.error(error)
|
|
10
|
+
}
|
|
11
|
+
return true
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Bind, isInvalidKey, onKey } from ".."
|
|
2
|
+
|
|
3
|
+
export default (key: Bind, callback: Function) => {
|
|
4
|
+
if (isInvalidKey(key)) return false
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
setTick(() => onKey(IsControlJustPressed, key, callback))
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.error(error)
|
|
10
|
+
}
|
|
11
|
+
return true
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Bind, isInvalidKey, onKey } from ".."
|
|
2
|
+
|
|
3
|
+
export default (key: Bind, callback: Function) => {
|
|
4
|
+
if (isInvalidKey(key)) return false
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
setTick(() => onKey(IsControlJustReleased, key, callback))
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.error(error)
|
|
10
|
+
}
|
|
11
|
+
return true
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Bind, isInvalidKey, onKey } from ".."
|
|
2
|
+
|
|
3
|
+
export default (key: Bind, callback: Function) => {
|
|
4
|
+
if (isInvalidKey(key)) return false
|
|
5
|
+
try {
|
|
6
|
+
setTick(() => onKey(IsControlReleased, key, callback))
|
|
7
|
+
} catch (error) {
|
|
8
|
+
console.error(error)
|
|
9
|
+
}
|
|
10
|
+
return true
|
|
11
|
+
}
|
package/client/nearest.ts
CHANGED
package/client/nui.ts
CHANGED
package/client/pool.ts
CHANGED
package/client/timer.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lenix",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.13",
|
|
4
4
|
"description": "Typed FiveM utilities for client, server, shared, and NUI scripts",
|
|
5
5
|
"author": "Lenix",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"lenix",
|
|
10
10
|
"modules",
|
|
11
11
|
"typescript",
|
|
12
|
+
"fivem",
|
|
12
13
|
"lua",
|
|
13
14
|
"luarocks",
|
|
14
15
|
"oop",
|
|
15
|
-
"fivem",
|
|
16
|
-
"fxmanifest",
|
|
17
16
|
"api",
|
|
18
17
|
"class",
|
|
18
|
+
"fxmanifest",
|
|
19
19
|
"eslint",
|
|
20
20
|
"linter"
|
|
21
21
|
],
|
|
@@ -36,13 +36,17 @@
|
|
|
36
36
|
"nui"
|
|
37
37
|
],
|
|
38
38
|
"scripts": {
|
|
39
|
-
"
|
|
40
|
-
"packpreview": "rm -rf ./package-preview && mkdir -p ./package-preview && bun pm pack --destination ./package-preview && tar -xzf ./package-preview/*.tgz -C ./package-preview && find ./package-preview/package -type f | sort"
|
|
39
|
+
"packprev": "rm -rf ./package-preview && mkdir -p ./package-preview && bun pm pack --destination ./package-preview && tar -xzf ./package-preview/*.tgz -C ./package-preview && find ./package-preview/package -type f | sort"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
42
|
+
"@citizenfx/client": "^2.0.33230-1",
|
|
43
|
+
"@citizenfx/server": "^2.0.32561-1",
|
|
43
44
|
"@types/bun": "latest"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
46
47
|
"typescript": "^5"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@lenix/lenix": "npm:@jsr/lenix__lenix"
|
|
47
51
|
}
|
|
48
52
|
}
|
package/shared/api.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { asserts } from "@lenix/lenix"
|
|
2
|
+
|
|
3
|
+
interface Api {
|
|
4
|
+
[resource: number]: never
|
|
5
|
+
[resource: string]: {
|
|
6
|
+
[method: number]: never
|
|
7
|
+
[method: string]: <Return, Args extends unknown[] = []>(...args: Args) => Return
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const api: Api = new Proxy(globalThis.exports, {
|
|
12
|
+
get(target, resource: string) {
|
|
13
|
+
const value = target[resource]
|
|
14
|
+
|
|
15
|
+
asserts(
|
|
16
|
+
GetResourceState(resource) === 'started' && value,
|
|
17
|
+
`<${resource}> is not started yet to be invoked`
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
return new Proxy(value, {
|
|
21
|
+
get(target, method: string) {
|
|
22
|
+
const value = target[method]
|
|
23
|
+
|
|
24
|
+
asserts(
|
|
25
|
+
value,
|
|
26
|
+
`Could not find <${method}> export in ${resource}`
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
return value
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
}) as unknown as Api
|
package/shared/index.ts
CHANGED
package/shared/assert.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Asserts that a condition is true and narrows its type.
|
|
3
|
-
*/
|
|
4
|
-
export const asserts = <T extends boolean>(
|
|
5
|
-
condition: T,
|
|
6
|
-
errorMessage = 'assertion did not passed successfuly'
|
|
7
|
-
): asserts condition => {
|
|
8
|
-
if (condition) return
|
|
9
|
-
|
|
10
|
-
throw new Error(errorMessage)
|
|
11
|
-
}
|