@nativewrappers/redm 0.0.135 → 0.0.137
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/common/GlobalData.d.ts +9 -0
- package/common/GlobalData.js +15 -0
- package/common/collections/CircularBuffer.d.ts +18 -0
- package/common/collections/CircularBuffer.js +92 -0
- package/common/collections/Stack.d.ts +9 -0
- package/common/collections/Stack.js +0 -0
- package/common/decors/Events.js +10 -2
- package/common/decors/Exports.js +3 -1
- package/common/decors/Ticks.js +11 -2
- package/common-game/entities/CommonBaseEntityBoneCollection.d.ts +1 -0
- package/common-game/entities/CommonEntityBoneCollection.d.ts +3 -0
- package/common-game/entities/CommonEntityBoneCollection.js +6 -0
- package/common-game/entities/CommonPedBoneCollection.d.ts +4 -1
- package/common-game/entities/CommonPedBoneCollection.js +8 -2
- package/index.d.ts +3 -1
- package/index.js +3 -1
- package/package.json +1 -1
package/common/GlobalData.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export declare enum ErrorType {
|
|
2
|
+
Event = 0,
|
|
3
|
+
NetEvent = 1,
|
|
4
|
+
Export = 2,
|
|
5
|
+
Nui = 3,
|
|
6
|
+
Tick = 4,
|
|
7
|
+
Immediate = 5
|
|
8
|
+
}
|
|
1
9
|
export declare class GlobalData {
|
|
2
10
|
static CurrentResource: string;
|
|
3
11
|
static GameName: string;
|
|
@@ -9,4 +17,5 @@ export declare class GlobalData {
|
|
|
9
17
|
static NetworkTick: number | null;
|
|
10
18
|
static NetworkedTicks: any[];
|
|
11
19
|
static EnablePrettyPrint: boolean;
|
|
20
|
+
static OnError: (type: ErrorType, err: Error) => void;
|
|
12
21
|
}
|
package/common/GlobalData.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
|
|
4
|
+
ErrorType2[ErrorType2["Event"] = 0] = "Event";
|
|
5
|
+
ErrorType2[ErrorType2["NetEvent"] = 1] = "NetEvent";
|
|
6
|
+
ErrorType2[ErrorType2["Export"] = 2] = "Export";
|
|
7
|
+
ErrorType2[ErrorType2["Nui"] = 3] = "Nui";
|
|
8
|
+
ErrorType2[ErrorType2["Tick"] = 4] = "Tick";
|
|
9
|
+
ErrorType2[ErrorType2["Immediate"] = 5] = "Immediate";
|
|
10
|
+
return ErrorType2;
|
|
11
|
+
})(ErrorType || {});
|
|
3
12
|
class GlobalData {
|
|
4
13
|
static {
|
|
5
14
|
__name(this, "GlobalData");
|
|
@@ -14,7 +23,13 @@ class GlobalData {
|
|
|
14
23
|
static NetworkTick = null;
|
|
15
24
|
static NetworkedTicks = [];
|
|
16
25
|
static EnablePrettyPrint = true;
|
|
26
|
+
/*
|
|
27
|
+
* Called when one of the decors errors
|
|
28
|
+
*/
|
|
29
|
+
static OnError = /* @__PURE__ */ __name((type, err) => {
|
|
30
|
+
}, "OnError");
|
|
17
31
|
}
|
|
18
32
|
export {
|
|
33
|
+
ErrorType,
|
|
19
34
|
GlobalData
|
|
20
35
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class CircularBuffer<T> {
|
|
2
|
+
private buffer;
|
|
3
|
+
private tail;
|
|
4
|
+
private count;
|
|
5
|
+
private max_size;
|
|
6
|
+
constructor(max_size: number);
|
|
7
|
+
push(item: T): void;
|
|
8
|
+
pop(): T | undefined;
|
|
9
|
+
peek(): T | undefined;
|
|
10
|
+
[Symbol.iterator](): Iterator<T>;
|
|
11
|
+
for_each(callback: (item: T, index: number) => void): void;
|
|
12
|
+
average(this: CircularBuffer<number>): number;
|
|
13
|
+
is_empty(): boolean;
|
|
14
|
+
is_full(): boolean;
|
|
15
|
+
size(): number;
|
|
16
|
+
capacity(): number;
|
|
17
|
+
clear(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
class CircularBuffer {
|
|
4
|
+
static {
|
|
5
|
+
__name(this, "CircularBuffer");
|
|
6
|
+
}
|
|
7
|
+
buffer;
|
|
8
|
+
tail = 0;
|
|
9
|
+
count = 0;
|
|
10
|
+
max_size;
|
|
11
|
+
constructor(max_size) {
|
|
12
|
+
if (max_size <= 0) {
|
|
13
|
+
throw new Error("Buffer size must be greater than 0");
|
|
14
|
+
}
|
|
15
|
+
this.max_size = max_size;
|
|
16
|
+
this.buffer = new Array(max_size);
|
|
17
|
+
}
|
|
18
|
+
push(item) {
|
|
19
|
+
this.buffer[this.tail] = item;
|
|
20
|
+
this.tail++;
|
|
21
|
+
if (this.tail >= this.max_size) {
|
|
22
|
+
this.tail = 0;
|
|
23
|
+
}
|
|
24
|
+
if (this.count < this.max_size) {
|
|
25
|
+
this.count++;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
pop() {
|
|
29
|
+
if (this.is_empty()) {
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
this.tail--;
|
|
33
|
+
if (this.tail < 0) {
|
|
34
|
+
this.tail = this.max_size - 1;
|
|
35
|
+
}
|
|
36
|
+
const item = this.buffer[this.tail];
|
|
37
|
+
this.buffer[this.tail] = void 0;
|
|
38
|
+
this.count--;
|
|
39
|
+
return item;
|
|
40
|
+
}
|
|
41
|
+
peek() {
|
|
42
|
+
if (this.is_empty()) {
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
let peek_index = this.tail - 1;
|
|
46
|
+
if (peek_index < 0) {
|
|
47
|
+
peek_index = this.max_size - 1;
|
|
48
|
+
}
|
|
49
|
+
return this.buffer[peek_index];
|
|
50
|
+
}
|
|
51
|
+
*[Symbol.iterator]() {
|
|
52
|
+
for (let i = 0; i < this.count; i++) {
|
|
53
|
+
yield this.buffer[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for_each(callback) {
|
|
57
|
+
let i = 0;
|
|
58
|
+
for (const item of this) {
|
|
59
|
+
callback(item, i++);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
average() {
|
|
63
|
+
if (this.is_empty()) {
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
let sum = 0;
|
|
67
|
+
for (const item of this) {
|
|
68
|
+
sum += item;
|
|
69
|
+
}
|
|
70
|
+
return sum / this.count;
|
|
71
|
+
}
|
|
72
|
+
is_empty() {
|
|
73
|
+
return this.count === 0;
|
|
74
|
+
}
|
|
75
|
+
is_full() {
|
|
76
|
+
return this.count === this.max_size;
|
|
77
|
+
}
|
|
78
|
+
size() {
|
|
79
|
+
return this.count;
|
|
80
|
+
}
|
|
81
|
+
capacity() {
|
|
82
|
+
return this.max_size;
|
|
83
|
+
}
|
|
84
|
+
clear() {
|
|
85
|
+
this.buffer = new Array(this.max_size);
|
|
86
|
+
this.tail = 0;
|
|
87
|
+
this.count = 0;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
CircularBuffer
|
|
92
|
+
};
|
|
File without changes
|
package/common/decors/Events.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { GlobalData } from "../GlobalData";
|
|
3
|
+
import { ErrorType, GlobalData } from "../GlobalData";
|
|
4
4
|
const DisablePrettyPrint = /* @__PURE__ */ __name(() => GlobalData.EnablePrettyPrint = false, "DisablePrettyPrint");
|
|
5
5
|
const AsyncFunction = (async () => {
|
|
6
6
|
}).constructor;
|
|
@@ -14,6 +14,7 @@ function OnEvent(eventName) {
|
|
|
14
14
|
try {
|
|
15
15
|
return await originalMethod.call(this, ...args);
|
|
16
16
|
} catch (e) {
|
|
17
|
+
GlobalData.OnError(ErrorType.Event, e);
|
|
17
18
|
REMOVE_EVENT_LOG: {
|
|
18
19
|
if (!GlobalData.EnablePrettyPrint) return;
|
|
19
20
|
console.error("------- EVENT ERROR --------");
|
|
@@ -62,6 +63,7 @@ function OnNetEvent(eventName, remoteOnly = true) {
|
|
|
62
63
|
}
|
|
63
64
|
return await originalMethod.call(this, ...args);
|
|
64
65
|
} catch (e) {
|
|
66
|
+
GlobalData.OnError(ErrorType.NetEvent, e);
|
|
65
67
|
REMOVE_NET_EVENT_LOG: {
|
|
66
68
|
if (!GlobalData.EnablePrettyPrint) return;
|
|
67
69
|
console.error("------- NET EVENT ERROR --------");
|
|
@@ -90,7 +92,13 @@ function OnNuiEvent(eventName, dontErrorWhenCbIsntInvoked = false) {
|
|
|
90
92
|
wasInvoked = true;
|
|
91
93
|
cb(args);
|
|
92
94
|
}, "cbWrapper");
|
|
93
|
-
|
|
95
|
+
let retData;
|
|
96
|
+
try {
|
|
97
|
+
retData = await originalMethod.call(this, data, cbWrapper);
|
|
98
|
+
} catch (e) {
|
|
99
|
+
GlobalData.OnError(ErrorType.Nui, e);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
94
102
|
if (!wasInvoked && !retData) {
|
|
95
103
|
if (dontErrorWhenCbIsntInvoked) return;
|
|
96
104
|
throw new Error(
|
package/common/decors/Exports.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { GlobalData } from "../GlobalData";
|
|
3
|
+
import { ErrorType, GlobalData } from "../GlobalData";
|
|
4
4
|
const AsyncFunction = (async () => {
|
|
5
5
|
}).constructor;
|
|
6
6
|
function Exports(exportName) {
|
|
@@ -15,6 +15,7 @@ function Exports(exportName) {
|
|
|
15
15
|
try {
|
|
16
16
|
return await originalMethod.call(this, ...args);
|
|
17
17
|
} catch (err) {
|
|
18
|
+
GlobalData.OnError(ErrorType.Export, err);
|
|
18
19
|
REMOVE_EVENT_LOG: {
|
|
19
20
|
if (!GlobalData.EnablePrettyPrint) return;
|
|
20
21
|
console.error("------- EXPORT ERROR --------");
|
|
@@ -31,6 +32,7 @@ function Exports(exportName) {
|
|
|
31
32
|
try {
|
|
32
33
|
return originalMethod.call(this, ...args);
|
|
33
34
|
} catch (err) {
|
|
35
|
+
GlobalData.OnError(ErrorType.Export, err);
|
|
34
36
|
REMOVE_EVENT_LOG: {
|
|
35
37
|
if (!GlobalData.EnablePrettyPrint) return;
|
|
36
38
|
console.error("------- EXPORT ERROR --------");
|
package/common/decors/Ticks.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { ErrorType, GlobalData } from "../GlobalData";
|
|
3
4
|
function SetTick() {
|
|
4
5
|
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
5
6
|
if (context.private) {
|
|
@@ -7,7 +8,11 @@ function SetTick() {
|
|
|
7
8
|
}
|
|
8
9
|
context.addInitializer(function() {
|
|
9
10
|
setTick(async () => {
|
|
10
|
-
|
|
11
|
+
try {
|
|
12
|
+
await originalMethod.call(this);
|
|
13
|
+
} catch (e) {
|
|
14
|
+
GlobalData.OnError(ErrorType.Tick, e);
|
|
15
|
+
}
|
|
11
16
|
});
|
|
12
17
|
});
|
|
13
18
|
}, "actualDecorator");
|
|
@@ -20,7 +25,11 @@ function SetImmediate() {
|
|
|
20
25
|
}
|
|
21
26
|
context.addInitializer(function() {
|
|
22
27
|
setImmediate(async () => {
|
|
23
|
-
|
|
28
|
+
try {
|
|
29
|
+
await originalMethod.call(this);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
GlobalData.OnError(ErrorType.Immediate, e);
|
|
32
|
+
}
|
|
24
33
|
});
|
|
25
34
|
});
|
|
26
35
|
}, "actualDecorator");
|
|
@@ -5,5 +5,6 @@ export declare abstract class CommonBaseEntityBoneCollection {
|
|
|
5
5
|
constructor(owner: IHandle);
|
|
6
6
|
hasBone(name: string): boolean;
|
|
7
7
|
abstract getBone(boneIndex?: number, boneName?: string): CommonBaseEntityBone;
|
|
8
|
+
abstract getBoneFromName(boneName: string): CommonBaseEntityBone;
|
|
8
9
|
abstract get Core(): CommonBaseEntityBone;
|
|
9
10
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { CommonBaseEntityBone } from "./CommonBaseEntityBone";
|
|
1
2
|
import { CommonBaseEntityBoneCollection } from "./CommonBaseEntityBoneCollection";
|
|
2
3
|
import { CommonEntityBone } from "./CommonEntityBone";
|
|
3
4
|
import type { IHandle } from "./IHandle";
|
|
4
5
|
export declare class CommonEntityBoneCollection extends CommonBaseEntityBoneCollection {
|
|
5
6
|
constructor(owner: IHandle);
|
|
7
|
+
getBoneFromName(boneName: string): CommonBaseEntityBone;
|
|
8
|
+
getBoneFromIndex(boneIndex: number): CommonBaseEntityBone;
|
|
6
9
|
getBone(boneIndex: number): CommonEntityBone;
|
|
7
10
|
getBone(boneName: string): CommonEntityBone;
|
|
8
11
|
get Core(): CommonEntityBone;
|
|
@@ -9,6 +9,12 @@ class CommonEntityBoneCollection extends CommonBaseEntityBoneCollection {
|
|
|
9
9
|
constructor(owner) {
|
|
10
10
|
super(owner);
|
|
11
11
|
}
|
|
12
|
+
getBoneFromName(boneName) {
|
|
13
|
+
return new CommonEntityBone(this.owner, GetEntityBoneIndexByName(this.owner.Handle, boneName));
|
|
14
|
+
}
|
|
15
|
+
getBoneFromIndex(boneIndex) {
|
|
16
|
+
return new CommonEntityBone(this.owner, boneIndex);
|
|
17
|
+
}
|
|
12
18
|
getBone(bone) {
|
|
13
19
|
return new CommonEntityBone(
|
|
14
20
|
this.owner,
|
|
@@ -6,5 +6,8 @@ export declare class CommonPedBoneCollection extends CommonBaseEntityBoneCollect
|
|
|
6
6
|
get Core(): CommonPedBone;
|
|
7
7
|
get LastDamaged(): CommonPedBone;
|
|
8
8
|
clearLastDamaged(): void;
|
|
9
|
-
|
|
9
|
+
getBoneFromId(boneId: number): CommonPedBone;
|
|
10
|
+
getBoneFromName(boneName: string): CommonPedBone;
|
|
11
|
+
getBone(boneIndex: number): CommonPedBone;
|
|
12
|
+
getBone(boneName: string): CommonPedBone;
|
|
10
13
|
}
|
|
@@ -19,10 +19,16 @@ class CommonPedBoneCollection extends CommonBaseEntityBoneCollection {
|
|
|
19
19
|
clearLastDamaged() {
|
|
20
20
|
ClearPedLastDamageBone(this.owner.Handle);
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
getBoneFromId(boneId) {
|
|
23
|
+
return new CommonPedBone(this.owner, GetPedBoneIndex(this.owner.Handle, boneId));
|
|
24
|
+
}
|
|
25
|
+
getBoneFromName(boneName) {
|
|
26
|
+
return new CommonPedBone(this.owner, GetEntityBoneIndexByName(this.owner.Handle, boneName));
|
|
27
|
+
}
|
|
28
|
+
getBone(bone) {
|
|
23
29
|
return new CommonPedBone(
|
|
24
30
|
this.owner,
|
|
25
|
-
|
|
31
|
+
typeof bone === "number" ? bone : GetEntityBoneIndexByName(this.owner.Handle, bone ?? "")
|
|
26
32
|
);
|
|
27
33
|
}
|
|
28
34
|
}
|
package/index.d.ts
CHANGED
|
@@ -96,4 +96,6 @@ export * from "./common/decors/Events";
|
|
|
96
96
|
export * from "./common/decors/Exports";
|
|
97
97
|
export * from "./common/decors/Permissions";
|
|
98
98
|
export * from "./common/decors/Resources";
|
|
99
|
-
export * from "./common/decors/Ticks";
|
|
99
|
+
export * from "./common/decors/Ticks";
|
|
100
|
+
export * from "./common/collections/CircularBuffer";
|
|
101
|
+
export * from "./common/collections/Stack";
|
package/index.js
CHANGED
|
@@ -96,4 +96,6 @@ export * from "./common/decors/Events";
|
|
|
96
96
|
export * from "./common/decors/Exports";
|
|
97
97
|
export * from "./common/decors/Permissions";
|
|
98
98
|
export * from "./common/decors/Resources";
|
|
99
|
-
export * from "./common/decors/Ticks";
|
|
99
|
+
export * from "./common/decors/Ticks";
|
|
100
|
+
export * from "./common/collections/CircularBuffer";
|
|
101
|
+
export * from "./common/collections/Stack";
|