@nativewrappers/common 0.0.130 → 0.0.132
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/index.d.ts +1 -52
- package/index.js +1 -52
- package/package.json +1 -1
- package/common-game/CommonGameConstants.d.ts +0 -7
- package/common-game/CommonGameConstants.js +0 -24
- package/common-game/CommonModel.d.ts +0 -99
- package/common-game/CommonModel.js +0 -172
- package/common-game/CommonTasks.d.ts +0 -44
- package/common-game/CommonTasks.js +0 -233
- package/common-game/cfx/StateBagChangeHandler.d.ts +0 -1
- package/common-game/cfx/StateBagChangeHandler.js +0 -0
- package/common-game/cfx/cfx.d.ts +0 -6
- package/common-game/cfx/cfx.js +0 -4
- package/common-game/common/Command.d.ts +0 -77
- package/common-game/common/Command.js +0 -152
- package/common-game/common/Convar.d.ts +0 -13
- package/common-game/common/Convar.js +0 -58
- package/common-game/common/GlobalData.d.ts +0 -12
- package/common-game/common/GlobalData.js +0 -20
- package/common-game/common/Kvp.d.ts +0 -69
- package/common-game/common/Kvp.js +0 -137
- package/common-game/common/Resource.d.ts +0 -14
- package/common-game/common/Resource.js +0 -54
- package/common-game/common/decors/ConVar.d.ts +0 -14
- package/common-game/common/decors/ConVar.js +0 -70
- package/common-game/common/decors/Events.d.ts +0 -66
- package/common-game/common/decors/Events.js +0 -163
- package/common-game/common/decors/Exports.d.ts +0 -1
- package/common-game/common/decors/Exports.js +0 -53
- package/common-game/common/decors/Permissions.d.ts +0 -3
- package/common-game/common/decors/Permissions.js +0 -49
- package/common-game/common/decors/Resources.d.ts +0 -8
- package/common-game/common/decors/Resources.js +0 -94
- package/common-game/common/decors/Ticks.d.ts +0 -9
- package/common-game/common/decors/Ticks.js +0 -32
- package/common-game/common/net/NetworkedMap.d.ts +0 -28
- package/common-game/common/net/NetworkedMap.js +0 -262
- package/common-game/common/types.d.ts +0 -5
- package/common-game/common/types.js +0 -0
- package/common-game/common/utils/ClassTypes.d.ts +0 -11
- package/common-game/common/utils/ClassTypes.js +0 -15
- package/common-game/common/utils/Color.d.ts +0 -14
- package/common-game/common/utils/Color.js +0 -33
- package/common-game/common/utils/Delay.d.ts +0 -1
- package/common-game/common/utils/Delay.js +0 -6
- package/common-game/common/utils/Maths.d.ts +0 -4
- package/common-game/common/utils/Maths.js +0 -18
- package/common-game/common/utils/Point.d.ts +0 -9
- package/common-game/common/utils/Point.js +0 -36
- package/common-game/common/utils/PointF.d.ts +0 -7
- package/common-game/common/utils/PointF.js +0 -18
- package/common-game/common/utils/Quaternion.d.ts +0 -10
- package/common-game/common/utils/Quaternion.js +0 -33
- package/common-game/common/utils/Vector.d.ts +0 -429
- package/common-game/common/utils/Vector.js +0 -589
- package/common-game/common/utils/cleanPlayerName.d.ts +0 -6
- package/common-game/common/utils/cleanPlayerName.js +0 -17
- package/common-game/common/utils/enumValues.d.ts +0 -12
- package/common-game/common/utils/enumValues.js +0 -20
- package/common-game/common/utils/getStringFromUInt8Array.d.ts +0 -8
- package/common-game/common/utils/getStringFromUInt8Array.js +0 -6
- package/common-game/common/utils/getUInt32FromUint8Array.d.ts +0 -8
- package/common-game/common/utils/getUInt32FromUint8Array.js +0 -6
- package/common-game/common/utils/randomInt.d.ts +0 -1
- package/common-game/common/utils/randomInt.js +0 -9
- package/common-game/definitions/index.d.js +0 -0
- package/common-game/definitions/redm.d.js +0 -0
- package/common-game/entities/CommonBaseEntity.d.ts +0 -116
- package/common-game/entities/CommonBaseEntity.js +0 -266
- package/common-game/entities/CommonBaseEntityBone.d.ts +0 -11
- package/common-game/entities/CommonBaseEntityBone.js +0 -32
- package/common-game/entities/CommonBaseEntityBoneCollection.d.ts +0 -9
- package/common-game/entities/CommonBaseEntityBoneCollection.js +0 -17
- package/common-game/entities/CommonEntityBone.d.ts +0 -5
- package/common-game/entities/CommonEntityBone.js +0 -14
- package/common-game/entities/CommonEntityBoneCollection.d.ts +0 -9
- package/common-game/entities/CommonEntityBoneCollection.js +0 -24
- package/common-game/entities/CommonEntityType.d.ts +0 -4
- package/common-game/entities/CommonEntityType.js +0 -0
- package/common-game/entities/CommonPed.d.ts +0 -16
- package/common-game/entities/CommonPed.js +0 -52
- package/common-game/entities/CommonPedBone.d.ts +0 -6
- package/common-game/entities/CommonPedBone.js +0 -17
- package/common-game/entities/CommonPedBoneCollection.d.ts +0 -10
- package/common-game/entities/CommonPedBoneCollection.js +0 -31
- package/common-game/entities/CommonPlayer.d.ts +0 -61
- package/common-game/entities/CommonPlayer.js +0 -156
- package/common-game/entities/CommonProp.d.ts +0 -15
- package/common-game/entities/CommonProp.js +0 -43
- package/common-game/entities/CommonVehicle.d.ts +0 -11
- package/common-game/entities/CommonVehicle.js +0 -36
- package/common-game/entities/GetEntityClassIdFromHandle.d.ts +0 -2
- package/common-game/entities/GetEntityClassIdFromHandle.js +0 -23
- package/common-game/entities/IHandle.d.ts +0 -6
- package/common-game/entities/IHandle.js +0 -20
- package/common-game/enums/VehicleSeat.d.ts +0 -13
- package/common-game/enums/VehicleSeat.js +0 -17
- package/common-game/index.d.ts +0 -50
- package/common-game/index.js +0 -50
- package/common-game/interfaces/Dimension.d.ts +0 -5
- package/common-game/interfaces/Dimension.js +0 -0
- package/common-game/utils/Animations.d.ts +0 -19
- package/common-game/utils/Animations.js +0 -43
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
class Kvp {
|
|
4
|
-
static {
|
|
5
|
-
__name(this, "Kvp");
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Returns the value associated with a key as a number.
|
|
9
|
-
*/
|
|
10
|
-
getNumber(key) {
|
|
11
|
-
return GetResourceKvpInt(key);
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Returns the value associated with a key as a float.
|
|
15
|
-
*/
|
|
16
|
-
getFloat(key) {
|
|
17
|
-
return GetResourceKvpFloat(key);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Returns the value associated with a key as a string.
|
|
21
|
-
*/
|
|
22
|
-
getString(key) {
|
|
23
|
-
return GetResourceKvpString(key);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Returns the value associated with a key as a parsed JSON string.
|
|
27
|
-
*/
|
|
28
|
-
getJson(key) {
|
|
29
|
-
const str = GetResourceKvpString(key);
|
|
30
|
-
return str ? JSON.parse(str) : null;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Sets the value associated with a key as a number.
|
|
34
|
-
* @param async set the value using an async operation.
|
|
35
|
-
*/
|
|
36
|
-
setNumber(key, value, async = false) {
|
|
37
|
-
return async ? SetResourceKvpIntNoSync(key, value) : SetResourceKvpInt(key, value);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Sets the value associated with a key as a float.
|
|
41
|
-
* @param async set the value using an async operation.
|
|
42
|
-
*/
|
|
43
|
-
setFloat(key, value, async = false) {
|
|
44
|
-
return async ? SetResourceKvpFloatNoSync(key, value) : SetResourceKvpFloat(key, value);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Sets the value associated with a key as a string.
|
|
48
|
-
* @param async set the value using an async operation.
|
|
49
|
-
*/
|
|
50
|
-
setString(key, value, async = false) {
|
|
51
|
-
return async ? SetResourceKvpNoSync(key, value) : SetResourceKvp(key, value);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Sets the value associated with a key as a JSON string.
|
|
55
|
-
* @param async set the value using an async operation.
|
|
56
|
-
*/
|
|
57
|
-
setJson(key, value, async = false) {
|
|
58
|
-
const str = JSON.stringify(value);
|
|
59
|
-
return async ? SetResourceKvpNoSync(key, str) : SetResourceKvp(key, str);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Sets the value associated with a key as a JSON string.
|
|
63
|
-
* @param async set the value using an async operation.
|
|
64
|
-
*/
|
|
65
|
-
set(key, value, async = false) {
|
|
66
|
-
switch (typeof value) {
|
|
67
|
-
case "function":
|
|
68
|
-
case "symbol":
|
|
69
|
-
throw new Error(`Failed to set Kvp for invalid type '${typeof value}'`);
|
|
70
|
-
case "undefined":
|
|
71
|
-
return this.delete(key, async);
|
|
72
|
-
case "object":
|
|
73
|
-
return this.setJson(key, value, async);
|
|
74
|
-
case "boolean":
|
|
75
|
-
value = value ? 1 : 0;
|
|
76
|
-
case "number":
|
|
77
|
-
return Number.isInteger(value) ? this.setNumber(key, value, async) : this.setFloat(key, value, async);
|
|
78
|
-
default:
|
|
79
|
-
value = String(value);
|
|
80
|
-
return this.setString(key, value, async);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Deletes the specified value for key.
|
|
85
|
-
* @param async remove the value using an async operation
|
|
86
|
-
*/
|
|
87
|
-
delete(key, async = false) {
|
|
88
|
-
return async ? DeleteResourceKvpNoSync(key) : DeleteResourceKvp(key);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Commits pending asynchronous operations to disk, ensuring data consistency.
|
|
92
|
-
*
|
|
93
|
-
* Should be called after calling set methods using the async flag.
|
|
94
|
-
*/
|
|
95
|
-
flush() {
|
|
96
|
-
FlushResourceKvp();
|
|
97
|
-
}
|
|
98
|
-
getAllKeys(prefix) {
|
|
99
|
-
const keys = [];
|
|
100
|
-
const handle = StartFindKvp(prefix);
|
|
101
|
-
if (handle === -1) return keys;
|
|
102
|
-
let key;
|
|
103
|
-
do {
|
|
104
|
-
key = FindKvp(handle);
|
|
105
|
-
if (key) keys.push(key);
|
|
106
|
-
} while (key);
|
|
107
|
-
EndFindKvp(handle);
|
|
108
|
-
return keys;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Returns an array of keys which match or contain the given keys.
|
|
112
|
-
*/
|
|
113
|
-
getKeys(prefix) {
|
|
114
|
-
return typeof prefix === "string" ? this.getAllKeys(prefix) : prefix.flatMap((key) => this.getAllKeys(key));
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Get all values from keys in an array as the specified type.
|
|
118
|
-
*/
|
|
119
|
-
getValuesAsType(prefix, type) {
|
|
120
|
-
const values = this.getKeys(prefix);
|
|
121
|
-
return values.map((key) => {
|
|
122
|
-
switch (type) {
|
|
123
|
-
case "number":
|
|
124
|
-
return this.getNumber(key);
|
|
125
|
-
case "float":
|
|
126
|
-
return this.getFloat(key);
|
|
127
|
-
case "string":
|
|
128
|
-
return this.getString(key);
|
|
129
|
-
default:
|
|
130
|
-
return this.getJson(key);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
export {
|
|
136
|
-
Kvp
|
|
137
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare class Resource {
|
|
2
|
-
name: string;
|
|
3
|
-
constructor(name: string);
|
|
4
|
-
getMetadata(metadataKey: string, index: number): string;
|
|
5
|
-
getPath(): string;
|
|
6
|
-
loadFile(fileName: string): string;
|
|
7
|
-
saveFile(fileName: string, data: string, length: number): boolean;
|
|
8
|
-
scheduleTick(): void;
|
|
9
|
-
start(): void;
|
|
10
|
-
stop(): void;
|
|
11
|
-
static startResource(name: string): void;
|
|
12
|
-
static stopResource(name: string): void;
|
|
13
|
-
static resourceCount(): number;
|
|
14
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { GlobalData } from "./GlobalData";
|
|
4
|
-
class Resource {
|
|
5
|
-
constructor(name) {
|
|
6
|
-
this.name = name;
|
|
7
|
-
}
|
|
8
|
-
static {
|
|
9
|
-
__name(this, "Resource");
|
|
10
|
-
}
|
|
11
|
-
getMetadata(metadataKey, index) {
|
|
12
|
-
return GetResourceMetadata(this.name, metadataKey, index);
|
|
13
|
-
}
|
|
14
|
-
getPath() {
|
|
15
|
-
return GetResourcePath(this.name);
|
|
16
|
-
}
|
|
17
|
-
loadFile(fileName) {
|
|
18
|
-
return LoadResourceFile(this.name, fileName);
|
|
19
|
-
}
|
|
20
|
-
saveFile(fileName, data, length) {
|
|
21
|
-
$CLIENT: {
|
|
22
|
-
if (GlobalData.IS_CLIENT) {
|
|
23
|
-
throw new Error("This function isn't available on the client");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return SaveResourceFile(this.name, fileName, data, length);
|
|
27
|
-
}
|
|
28
|
-
scheduleTick() {
|
|
29
|
-
$CLIENT: {
|
|
30
|
-
if (GlobalData.IS_CLIENT) {
|
|
31
|
-
throw new Error("This function isn't available on the client");
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return ScheduleResourceTick(this.name);
|
|
35
|
-
}
|
|
36
|
-
start() {
|
|
37
|
-
StartResource(this.name);
|
|
38
|
-
}
|
|
39
|
-
stop() {
|
|
40
|
-
StopResource(this.name);
|
|
41
|
-
}
|
|
42
|
-
static startResource(name) {
|
|
43
|
-
StartResource(name);
|
|
44
|
-
}
|
|
45
|
-
static stopResource(name) {
|
|
46
|
-
StopResource(name);
|
|
47
|
-
}
|
|
48
|
-
static resourceCount() {
|
|
49
|
-
return GetNumResources();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
export {
|
|
53
|
-
Resource
|
|
54
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare enum ConVarType {
|
|
2
|
-
String = 0,
|
|
3
|
-
Integer = 1,
|
|
4
|
-
Float = 2,
|
|
5
|
-
Boolean = 3
|
|
6
|
-
}
|
|
7
|
-
type DeserializeFn<T> = (data: T) => unknown;
|
|
8
|
-
/**
|
|
9
|
-
* Gets the specified `ConVar`s value, this will bind to the param.
|
|
10
|
-
* @param name the convar name
|
|
11
|
-
* @param is_floating_point if the convar is floating point, this should be explicitly set to true if your convar will be a float
|
|
12
|
-
*/
|
|
13
|
-
export declare function ConVar<T>(name: string, is_floating_point?: boolean, deserialize?: DeserializeFn<T>): (_initialValue: any, context: ClassFieldDecoratorContext, ..._args: any[]) => void;
|
|
14
|
-
export {};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
var ConVarType = /* @__PURE__ */ ((ConVarType2) => {
|
|
4
|
-
ConVarType2[ConVarType2["String"] = 0] = "String";
|
|
5
|
-
ConVarType2[ConVarType2["Integer"] = 1] = "Integer";
|
|
6
|
-
ConVarType2[ConVarType2["Float"] = 2] = "Float";
|
|
7
|
-
ConVarType2[ConVarType2["Boolean"] = 3] = "Boolean";
|
|
8
|
-
return ConVarType2;
|
|
9
|
-
})(ConVarType || {});
|
|
10
|
-
const get_convar_fn = /* @__PURE__ */ __name((con_var_type) => {
|
|
11
|
-
switch (con_var_type) {
|
|
12
|
-
case 0 /* String */:
|
|
13
|
-
return GetConvar;
|
|
14
|
-
case 1 /* Integer */:
|
|
15
|
-
return GetConvarInt;
|
|
16
|
-
case 2 /* Float */:
|
|
17
|
-
return GetConvarFloat;
|
|
18
|
-
case 3 /* Boolean */:
|
|
19
|
-
return GetConvarBool;
|
|
20
|
-
// needed so typescript wont complain about "unreachable code" for the error below
|
|
21
|
-
default:
|
|
22
|
-
}
|
|
23
|
-
throw new Error("Got invalid ConVarType");
|
|
24
|
-
}, "get_convar_fn");
|
|
25
|
-
function ConVar(name, is_floating_point, deserialize) {
|
|
26
|
-
return /* @__PURE__ */ __name(function actualDecorator(_initialValue, context, ..._args) {
|
|
27
|
-
if (context.private) {
|
|
28
|
-
throw new Error("ConVar does not work on private types, please mark the field as public");
|
|
29
|
-
}
|
|
30
|
-
context.addInitializer(function() {
|
|
31
|
-
const t = this;
|
|
32
|
-
const default_value = Reflect.get(t, context.name);
|
|
33
|
-
const default_type = typeof default_value;
|
|
34
|
-
let con_var_type = null;
|
|
35
|
-
if (default_type === "number") {
|
|
36
|
-
if (is_floating_point || !Number.isInteger(default_value)) {
|
|
37
|
-
con_var_type = 2 /* Float */;
|
|
38
|
-
} else {
|
|
39
|
-
con_var_type = 1 /* Integer */;
|
|
40
|
-
}
|
|
41
|
-
} else if (default_type === "boolean") {
|
|
42
|
-
con_var_type = 3 /* Boolean */;
|
|
43
|
-
} else if (default_type === "string") {
|
|
44
|
-
con_var_type = 0 /* String */;
|
|
45
|
-
}
|
|
46
|
-
if (!deserialize && con_var_type === null) {
|
|
47
|
-
throw new Error(
|
|
48
|
-
`Failed to determine what to use to deserialize '${name}' was for var had type '${default_type}' which can't be deserialized without providing your own deserialize function.`
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
if (con_var_type === null) {
|
|
52
|
-
con_var_type = 0 /* String */;
|
|
53
|
-
}
|
|
54
|
-
const con_var_fn = get_convar_fn(con_var_type);
|
|
55
|
-
const get_convar_value = /* @__PURE__ */ __name(() => {
|
|
56
|
-
const data = con_var_fn(name, default_value);
|
|
57
|
-
return deserialize ? deserialize(data) : data;
|
|
58
|
-
}, "get_convar_value");
|
|
59
|
-
Reflect.set(t, context.name, get_convar_value());
|
|
60
|
-
AddConvarChangeListener(name, () => {
|
|
61
|
-
Reflect.set(t, context.name, get_convar_value());
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
}, "actualDecorator");
|
|
65
|
-
}
|
|
66
|
-
__name(ConVar, "ConVar");
|
|
67
|
-
export {
|
|
68
|
-
ConVar,
|
|
69
|
-
ConVarType
|
|
70
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Disables pretty printing in error messages
|
|
3
|
-
*/
|
|
4
|
-
export declare const DisablePrettyPrint: () => boolean;
|
|
5
|
-
export declare enum Binding {
|
|
6
|
-
/**
|
|
7
|
-
* No one can call this
|
|
8
|
-
*/
|
|
9
|
-
None = 0,
|
|
10
|
-
/**
|
|
11
|
-
* Server only accepts server calls, client only client calls
|
|
12
|
-
*/
|
|
13
|
-
Local = 1,
|
|
14
|
-
/**
|
|
15
|
-
* Server only accepts client calls, client only server calls
|
|
16
|
-
*/
|
|
17
|
-
Remote = 2,
|
|
18
|
-
/**
|
|
19
|
-
* Accept all incoming calls
|
|
20
|
-
* Server only accepts client calls, client only server calls
|
|
21
|
-
*/
|
|
22
|
-
All = 3
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Registers the Event call for {@link eventName} to this method.
|
|
26
|
-
*
|
|
27
|
-
* This has internal pretty-printing to make errors easier to track, if
|
|
28
|
-
* you want to disable this you will need to call {@link DisablePrettyPrint}, or if you're
|
|
29
|
-
* using esbuild you can add `REMOVE_EVENT_LOG` to your drop label {@link https://esbuild.github.io/api/#drop-labels}
|
|
30
|
-
* @param eventName the event to bind to
|
|
31
|
-
*/
|
|
32
|
-
export declare function CfxEvent(eventName: string, binding?: Binding): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
33
|
-
/**
|
|
34
|
-
* Registers the Event call for {@link eventName} to this method.
|
|
35
|
-
*
|
|
36
|
-
* This has internal pretty-printing to make errors easier to track, if
|
|
37
|
-
* you want to disable this you will need to call {@link DisablePrettyPrint}, or if you're
|
|
38
|
-
* using esbuild you can add `REMOVE_EVENT_LOG` to your drop label {@link https://esbuild.github.io/api/#drop-labels}
|
|
39
|
-
*
|
|
40
|
-
* @param eventName the event to bind to
|
|
41
|
-
*/
|
|
42
|
-
export declare function Event(eventName: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
43
|
-
/**
|
|
44
|
-
* Registers the Net Event call for {@link eventName} to this method
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* This has internal pretty-printing to make errors easier to track, if
|
|
48
|
-
* you want to disable this you will need to call {@link DisablePrettyPrint}, or if you're
|
|
49
|
-
* using esbuild you can add `REMOVE_EVENT_LOG` to your drop label {@link https://esbuild.github.io/api/#drop-labels}
|
|
50
|
-
*
|
|
51
|
-
* @param eventName the event to bind this net event to
|
|
52
|
-
* @param remoteOnly if the event should only accept remote calls, if set to true it will ignore any local call via `emit`, defaults to true
|
|
53
|
-
*/
|
|
54
|
-
export declare function NetEvent(eventName: string, remoteOnly?: boolean): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
55
|
-
export type NuiCallback = (data: string) => void;
|
|
56
|
-
/**
|
|
57
|
-
* Registers the NUI Event call for {eventName} to this method, the function signature
|
|
58
|
-
* will always be (data: unknown, cb: (data?: any) => void) => void
|
|
59
|
-
*
|
|
60
|
-
* There's two valid ways to return data into a callback, returning in the method
|
|
61
|
-
* you're currently using will automatically call the callback, or you can manually call the callback yourself
|
|
62
|
-
*
|
|
63
|
-
* @param eventName the event this will listen for
|
|
64
|
-
* @param dontErrorWhenCbIsntInvoked this will just block the event fro merroring when the callback is never invoked.
|
|
65
|
-
*/
|
|
66
|
-
export declare function NuiEvent(eventName: string, dontErrorWhenCbIsntInvoked?: boolean): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { GlobalData } from "../GlobalData";
|
|
4
|
-
const DisablePrettyPrint = /* @__PURE__ */ __name(() => GlobalData.EnablePrettyPrint = false, "DisablePrettyPrint");
|
|
5
|
-
const AsyncFunction = (async () => {
|
|
6
|
-
}).constructor;
|
|
7
|
-
var Binding = /* @__PURE__ */ ((Binding2) => {
|
|
8
|
-
Binding2[Binding2["None"] = 0] = "None";
|
|
9
|
-
Binding2[Binding2["Local"] = 1] = "Local";
|
|
10
|
-
Binding2[Binding2["Remote"] = 2] = "Remote";
|
|
11
|
-
Binding2[Binding2["All"] = 3] = "All";
|
|
12
|
-
return Binding2;
|
|
13
|
-
})(Binding || {});
|
|
14
|
-
function CfxEvent(eventName, binding = 1 /* Local */) {
|
|
15
|
-
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
16
|
-
if (context.private) {
|
|
17
|
-
throw new Error("Event does not work on private methods, please mark the method as public");
|
|
18
|
-
}
|
|
19
|
-
context.addInitializer(function() {
|
|
20
|
-
const fn = (binding & 2 /* Remote */) !== 0 ? onNet : on;
|
|
21
|
-
const _t = this;
|
|
22
|
-
fn(eventName, async (...args) => {
|
|
23
|
-
const src = source;
|
|
24
|
-
if (_t.__permissionMap && binding & 2 /* Remote */) {
|
|
25
|
-
const permissions = _t.__permissionMap.get(context.name);
|
|
26
|
-
if (permissions) {
|
|
27
|
-
let hasPermission = false;
|
|
28
|
-
for (const perm of permissions) {
|
|
29
|
-
if (IsPlayerAceAllowed(src, perm)) {
|
|
30
|
-
hasPermission = true;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (!hasPermission) {
|
|
35
|
-
emit("@nativewrappers:no_permission", { eventName, method: context.name });
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
return await originalMethod.call(this, ...args);
|
|
42
|
-
} catch (e) {
|
|
43
|
-
REMOVE_EVENT_LOG: {
|
|
44
|
-
if (!GlobalData.EnablePrettyPrint) return;
|
|
45
|
-
console.error("------- EVENT ERROR --------");
|
|
46
|
-
console.error(`Call to ${eventName} errored`);
|
|
47
|
-
console.error(`Data: ${JSON.stringify(args)}`);
|
|
48
|
-
console.error(`Error: ${e}`);
|
|
49
|
-
console.error("------- END EVENT ERROR --------");
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
}, "actualDecorator");
|
|
55
|
-
}
|
|
56
|
-
__name(CfxEvent, "CfxEvent");
|
|
57
|
-
function Event(eventName) {
|
|
58
|
-
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
59
|
-
if (context.private) {
|
|
60
|
-
throw new Error("Event does not work on private methods, please mark the method as public");
|
|
61
|
-
}
|
|
62
|
-
context.addInitializer(function() {
|
|
63
|
-
on(eventName, async (...args) => {
|
|
64
|
-
try {
|
|
65
|
-
return await originalMethod.call(this, ...args);
|
|
66
|
-
} catch (e) {
|
|
67
|
-
REMOVE_EVENT_LOG: {
|
|
68
|
-
if (!GlobalData.EnablePrettyPrint) return;
|
|
69
|
-
console.error("------- EVENT ERROR --------");
|
|
70
|
-
console.error(`Call to ${eventName} errored`);
|
|
71
|
-
console.error(`Data: ${JSON.stringify(args)}`);
|
|
72
|
-
console.error(`Error: ${e}`);
|
|
73
|
-
console.error("------- END EVENT ERROR --------");
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}, "actualDecorator");
|
|
79
|
-
}
|
|
80
|
-
__name(Event, "Event");
|
|
81
|
-
function NetEvent(eventName, remoteOnly = true) {
|
|
82
|
-
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
83
|
-
if (context.private) {
|
|
84
|
-
throw new Error("NetEvent does not work on private methods, please mark the method as public");
|
|
85
|
-
}
|
|
86
|
-
context.addInitializer(function() {
|
|
87
|
-
const _t = this;
|
|
88
|
-
onNet(eventName, async (...args) => {
|
|
89
|
-
const src = source;
|
|
90
|
-
if (_t.__permissionMap) {
|
|
91
|
-
const permissions = _t.__permissionMap.get(context.name);
|
|
92
|
-
if (permissions) {
|
|
93
|
-
let hasPermission = false;
|
|
94
|
-
for (const perm of permissions) {
|
|
95
|
-
if (IsPlayerAceAllowed(src, perm)) {
|
|
96
|
-
hasPermission = true;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (!hasPermission) {
|
|
101
|
-
emit("@nativewrappers:no_permission", { eventName, method: context.name });
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
try {
|
|
107
|
-
$CLIENT: {
|
|
108
|
-
if (GlobalData.IS_CLIENT && remoteOnly && source !== 65535) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return await originalMethod.call(this, ...args);
|
|
113
|
-
} catch (e) {
|
|
114
|
-
REMOVE_NET_EVENT_LOG: {
|
|
115
|
-
if (!GlobalData.EnablePrettyPrint) return;
|
|
116
|
-
console.error("------- NET EVENT ERROR --------");
|
|
117
|
-
console.error(`Call to ${eventName} errored`);
|
|
118
|
-
console.error(`Caller: ${src}`);
|
|
119
|
-
console.error(`Data: ${JSON.stringify(args)}`);
|
|
120
|
-
console.error(`Error: ${e}`);
|
|
121
|
-
console.error("------- END NET EVENT ERROR --------");
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
}, "actualDecorator");
|
|
127
|
-
}
|
|
128
|
-
__name(NetEvent, "NetEvent");
|
|
129
|
-
function NuiEvent(eventName, dontErrorWhenCbIsntInvoked = false) {
|
|
130
|
-
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
131
|
-
if (context.private) {
|
|
132
|
-
throw new Error("NuiEvent does not work on private methods, please mark the method as public");
|
|
133
|
-
}
|
|
134
|
-
context.addInitializer(function() {
|
|
135
|
-
RegisterNuiCallback(eventName, async (data, cb) => {
|
|
136
|
-
let wasInvoked = false;
|
|
137
|
-
const cbWrapper = /* @__PURE__ */ __name((args) => {
|
|
138
|
-
wasInvoked = true;
|
|
139
|
-
cb(args);
|
|
140
|
-
}, "cbWrapper");
|
|
141
|
-
const retData = await originalMethod.call(this, data, cbWrapper);
|
|
142
|
-
if (!wasInvoked && !retData) {
|
|
143
|
-
if (dontErrorWhenCbIsntInvoked) return;
|
|
144
|
-
throw new Error(
|
|
145
|
-
`Error in NuiEvent ${eventName} '@NuiEvent' expects you to return data in your callback, or to return from the function call`
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
if (!wasInvoked) {
|
|
149
|
-
cb(retData);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
}, "actualDecorator");
|
|
154
|
-
}
|
|
155
|
-
__name(NuiEvent, "NuiEvent");
|
|
156
|
-
export {
|
|
157
|
-
Binding,
|
|
158
|
-
CfxEvent,
|
|
159
|
-
DisablePrettyPrint,
|
|
160
|
-
Event,
|
|
161
|
-
NetEvent,
|
|
162
|
-
NuiEvent
|
|
163
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function Exports(exportName: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { GlobalData } from "../GlobalData";
|
|
4
|
-
const AsyncFunction = (async () => {
|
|
5
|
-
}).constructor;
|
|
6
|
-
function Exports(exportName) {
|
|
7
|
-
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
8
|
-
if (context.private) {
|
|
9
|
-
throw new Error("Exports does not work on private methods, please mark the method as public");
|
|
10
|
-
}
|
|
11
|
-
context.addInitializer(function() {
|
|
12
|
-
let exportCb;
|
|
13
|
-
if (originalMethod instanceof AsyncFunction) {
|
|
14
|
-
exportCb = /* @__PURE__ */ __name(async (...args) => {
|
|
15
|
-
try {
|
|
16
|
-
return await originalMethod.call(this, ...args);
|
|
17
|
-
} catch (err) {
|
|
18
|
-
REMOVE_EVENT_LOG: {
|
|
19
|
-
if (!GlobalData.EnablePrettyPrint) return;
|
|
20
|
-
console.error("------- EXPORT ERROR --------");
|
|
21
|
-
console.error(`Call to ${exportName} errored`);
|
|
22
|
-
console.error(`Data: ${JSON.stringify(args)}`);
|
|
23
|
-
console.error(`Error: ${err}`);
|
|
24
|
-
console.error("------- END EXPORT ERROR --------");
|
|
25
|
-
}
|
|
26
|
-
throw err;
|
|
27
|
-
}
|
|
28
|
-
}, "exportCb");
|
|
29
|
-
} else {
|
|
30
|
-
exportCb = /* @__PURE__ */ __name((...args) => {
|
|
31
|
-
try {
|
|
32
|
-
return originalMethod.call(this, ...args);
|
|
33
|
-
} catch (err) {
|
|
34
|
-
REMOVE_EVENT_LOG: {
|
|
35
|
-
if (!GlobalData.EnablePrettyPrint) return;
|
|
36
|
-
console.error("------- EXPORT ERROR --------");
|
|
37
|
-
console.error(`Call to ${exportName} errored`);
|
|
38
|
-
console.error(`Data: ${JSON.stringify(args)}`);
|
|
39
|
-
console.error(`Error: ${err}`);
|
|
40
|
-
console.error("------- END EXPORT ERROR --------");
|
|
41
|
-
}
|
|
42
|
-
throw err;
|
|
43
|
-
}
|
|
44
|
-
}, "exportCb");
|
|
45
|
-
}
|
|
46
|
-
exports(exportName, exportCb);
|
|
47
|
-
});
|
|
48
|
-
}, "actualDecorator");
|
|
49
|
-
}
|
|
50
|
-
__name(Exports, "Exports");
|
|
51
|
-
export {
|
|
52
|
-
Exports
|
|
53
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare function RestrictToGroupAce(groupAceName: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
2
|
-
export declare function RestrictToJobAce(jobAce: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
3
|
-
export declare function RestrictToAce(aceName: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
import { GlobalData } from "../GlobalData";
|
|
4
|
-
const addAcePermission = /* @__PURE__ */ __name((aceName, context) => {
|
|
5
|
-
context.addInitializer(function() {
|
|
6
|
-
const _t = this;
|
|
7
|
-
_t.__permissionMap = _t.__permissionMap ?? /* @__PURE__ */ new Map();
|
|
8
|
-
const ace_list = _t.__permissionMap.get(context.name);
|
|
9
|
-
if (ace_list) {
|
|
10
|
-
ace_list.add(aceName);
|
|
11
|
-
} else {
|
|
12
|
-
_t.__permissionMap.set(context.name, /* @__PURE__ */ new Set([aceName]));
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}, "addAcePermission");
|
|
16
|
-
function RestrictToGroupAce(groupAceName) {
|
|
17
|
-
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
18
|
-
if (context.private) {
|
|
19
|
-
throw new Error("Exports does not work on private methods, please mark the method as public");
|
|
20
|
-
}
|
|
21
|
-
const groupAce = `group.${groupAceName}`;
|
|
22
|
-
addAcePermission(groupAce, context);
|
|
23
|
-
}, "actualDecorator");
|
|
24
|
-
}
|
|
25
|
-
__name(RestrictToGroupAce, "RestrictToGroupAce");
|
|
26
|
-
function RestrictToJobAce(jobAce) {
|
|
27
|
-
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
28
|
-
if (context.private) {
|
|
29
|
-
throw new Error("Exports does not work on private methods, please mark the method as public");
|
|
30
|
-
}
|
|
31
|
-
const groupAce = `job.${jobAce}`;
|
|
32
|
-
addAcePermission(groupAce, context);
|
|
33
|
-
}, "actualDecorator");
|
|
34
|
-
}
|
|
35
|
-
__name(RestrictToJobAce, "RestrictToJobAce");
|
|
36
|
-
function RestrictToAce(aceName) {
|
|
37
|
-
return /* @__PURE__ */ __name(function actualDecorator(originalMethod, context) {
|
|
38
|
-
if (context.private) {
|
|
39
|
-
throw new Error("Exports does not work on private methods, please mark the method as public");
|
|
40
|
-
}
|
|
41
|
-
addAcePermission(aceName, context);
|
|
42
|
-
}, "actualDecorator");
|
|
43
|
-
}
|
|
44
|
-
__name(RestrictToAce, "RestrictToAce");
|
|
45
|
-
export {
|
|
46
|
-
RestrictToAce,
|
|
47
|
-
RestrictToGroupAce,
|
|
48
|
-
RestrictToJobAce
|
|
49
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Called whenever the specified resource is started, this will be called once on once on resource start if the resource is started.
|
|
3
|
-
*/
|
|
4
|
-
export declare function OnResourceStart(resource?: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|
|
5
|
-
/**
|
|
6
|
-
* Called whenever the specified resource is stopped.
|
|
7
|
-
*/
|
|
8
|
-
export declare function OnResourceStop(resource?: string): (originalMethod: any, context: ClassMethodDecoratorContext) => void;
|