@nativewrappers/common-game 0.0.126 → 0.0.127

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.
Files changed (71) hide show
  1. package/CommonModel.js +2 -2
  2. package/CommonTasks.d.ts +1 -1
  3. package/CommonTasks.js +2 -2
  4. package/common/Command.d.ts +77 -0
  5. package/common/Command.js +152 -0
  6. package/common/Convar.d.ts +13 -0
  7. package/common/Convar.js +58 -0
  8. package/common/GlobalData.d.ts +12 -0
  9. package/common/GlobalData.js +20 -0
  10. package/common/Kvp.d.ts +69 -0
  11. package/common/Kvp.js +137 -0
  12. package/common/Resource.d.ts +14 -0
  13. package/common/Resource.js +54 -0
  14. package/common/decors/ConVar.d.ts +14 -0
  15. package/common/decors/ConVar.js +70 -0
  16. package/common/decors/Events.d.ts +66 -0
  17. package/common/decors/Events.js +163 -0
  18. package/common/decors/Exports.d.ts +1 -0
  19. package/common/decors/Exports.js +53 -0
  20. package/common/decors/Permissions.d.ts +3 -0
  21. package/common/decors/Permissions.js +49 -0
  22. package/common/decors/Resources.d.ts +8 -0
  23. package/common/decors/Resources.js +94 -0
  24. package/common/decors/Ticks.d.ts +9 -0
  25. package/common/decors/Ticks.js +32 -0
  26. package/common/net/NetworkedMap.d.ts +28 -0
  27. package/common/net/NetworkedMap.js +225 -0
  28. package/common/types.d.ts +5 -0
  29. package/common/types.js +0 -0
  30. package/common/utils/ClassTypes.d.ts +11 -0
  31. package/common/utils/ClassTypes.js +15 -0
  32. package/common/utils/Color.d.ts +14 -0
  33. package/common/utils/Color.js +33 -0
  34. package/common/utils/Delay.d.ts +1 -0
  35. package/common/utils/Delay.js +6 -0
  36. package/common/utils/Maths.d.ts +4 -0
  37. package/common/utils/Maths.js +18 -0
  38. package/common/utils/Point.d.ts +9 -0
  39. package/common/utils/Point.js +36 -0
  40. package/common/utils/PointF.d.ts +7 -0
  41. package/common/utils/PointF.js +18 -0
  42. package/common/utils/Quaternion.d.ts +10 -0
  43. package/common/utils/Quaternion.js +33 -0
  44. package/common/utils/Vector.d.ts +429 -0
  45. package/common/utils/Vector.js +589 -0
  46. package/common/utils/cleanPlayerName.d.ts +6 -0
  47. package/common/utils/cleanPlayerName.js +17 -0
  48. package/common/utils/enumValues.d.ts +12 -0
  49. package/common/utils/enumValues.js +20 -0
  50. package/common/utils/getStringFromUInt8Array.d.ts +8 -0
  51. package/common/utils/getStringFromUInt8Array.js +6 -0
  52. package/common/utils/getUInt32FromUint8Array.d.ts +8 -0
  53. package/common/utils/getUInt32FromUint8Array.js +6 -0
  54. package/common/utils/randomInt.d.ts +1 -0
  55. package/common/utils/randomInt.js +9 -0
  56. package/entities/CommonBaseEntity.d.ts +3 -3
  57. package/entities/CommonBaseEntity.js +2 -2
  58. package/entities/CommonBaseEntityBone.d.ts +1 -1
  59. package/entities/CommonBaseEntityBone.js +1 -1
  60. package/entities/CommonPed.d.ts +1 -1
  61. package/entities/CommonPed.js +1 -1
  62. package/entities/CommonPlayer.js +1 -1
  63. package/entities/CommonProp.d.ts +1 -1
  64. package/entities/CommonProp.js +1 -1
  65. package/entities/CommonVehicle.d.ts +1 -1
  66. package/entities/CommonVehicle.js +1 -1
  67. package/index.d.ts +26 -0
  68. package/index.js +26 -0
  69. package/interfaces/Dimension.d.ts +1 -1
  70. package/package.json +1 -1
  71. package/utils/Animations.js +1 -1
@@ -0,0 +1,589 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { ClassTypes } from "./ClassTypes";
4
+ const EXT_VECTOR2 = 20;
5
+ const EXT_VECTOR3 = 21;
6
+ const EXT_VECTOR4 = 22;
7
+ const size = Symbol("size");
8
+ class Vector {
9
+ static {
10
+ __name(this, "Vector");
11
+ }
12
+ static create(x, y = x, z, w) {
13
+ if (typeof x === "object") ({ x, y, z, w } = x);
14
+ const size2 = this instanceof Vector && this.size || [x, y, z, w].filter((arg) => arg !== void 0).length;
15
+ switch (size2) {
16
+ case 1:
17
+ case 2:
18
+ return new Vector2(x, y);
19
+ case 3:
20
+ return new Vector3(x, y, z);
21
+ case 4:
22
+ return new Vector4(x, y, z, w);
23
+ default:
24
+ throw new Error(`Cannot instantiate Vector with size of ${size2}.`);
25
+ }
26
+ }
27
+ /**
28
+ * Creates a deep copy of the provided vector.
29
+ * @param obj The vector to clone.
30
+ * @returns A new vector instance that is a copy of the provided vector.
31
+ */
32
+ static clone(obj) {
33
+ return this.create(obj);
34
+ }
35
+ /**
36
+ * Creates a vector from binary data in a MsgpackBuffer.
37
+ * @param msgpackBuffer The buffer containing binary data.
38
+ * @returns A new vector instance.
39
+ */
40
+ static fromBuffer({ buffer, type }) {
41
+ if (type !== EXT_VECTOR2 && type !== EXT_VECTOR3 && type !== EXT_VECTOR4)
42
+ throw new Error("Buffer type is not a valid Vector.");
43
+ const arr = new Array(buffer.length / 4);
44
+ for (let i = 0; i < arr.length; i++) arr[i] = Number(buffer.readFloatLE(i * 4).toPrecision(7));
45
+ return this.fromArray(arr);
46
+ }
47
+ /**
48
+ * Performs an operation between a vector and either another vector or scalar value.
49
+ * @param a - The first vector.
50
+ * @param b - The second vector or scalar value.
51
+ * @param operator - The function defining the operation to perform.
52
+ * @returns A new vector resulting from the operation.
53
+ */
54
+ static operate(a, b, operator) {
55
+ let { x, y, z, w } = a;
56
+ const isNumber = typeof b === "number";
57
+ x = operator(x, isNumber ? b : b.x ?? 0);
58
+ y = operator(y, isNumber ? b : b.y ?? 0);
59
+ if (z !== void 0) z = operator(z, isNumber ? b : b.z ?? 0);
60
+ if (w !== void 0) w = operator(w, isNumber ? b : b.w ?? 0);
61
+ return this.create(x, y, z, w);
62
+ }
63
+ /**
64
+ * Adds two vectors or a scalar value to a vector.
65
+ * @param a - The first vector or scalar value.
66
+ * @param b - The second vector or scalar value.
67
+ * @returns A new vector with incremented components.
68
+ */
69
+ static add(a, b) {
70
+ return this.operate(a, b, (x, y) => x + y);
71
+ }
72
+ /**
73
+ * Adds a scalar value to the x-component of a vector.
74
+ * @param obj - The vector.
75
+ * @param x - The value to add to the x-component.
76
+ * @returns A new vector with the x-component incremented.
77
+ */
78
+ static addX(obj, x) {
79
+ return this.create(obj.x + x, obj.y, obj.z, obj.w);
80
+ }
81
+ /**
82
+ * Adds a scalar value to the y-component of a vector.
83
+ * @param obj - The vector.
84
+ * @param y - The value to add to the y-component.
85
+ * @returns A new vector with the y-component incremented.
86
+ */
87
+ static addY(obj, y) {
88
+ return this.create(obj.x, obj.y + y, obj.z, obj.w);
89
+ }
90
+ /**
91
+ * Adds a scalar value to the z-component of a vector.
92
+ * @param obj - The vector.
93
+ * @param z - The value to add to the z-component.
94
+ * @returns A new vector with the z-component incremented.
95
+ */
96
+ static addZ(obj, z) {
97
+ return this.create(obj.x, obj.y, obj.z + z, obj.w);
98
+ }
99
+ /**
100
+ * Adds a scalar value to the w-component of a vector.
101
+ * @param obj - The vector.
102
+ * @param w - The value to add to the w-component.
103
+ * @returns A new vector with the w-component incremented.
104
+ */
105
+ static addW(obj, w) {
106
+ return this.create(obj.x, obj.y, obj.z, obj.w + w);
107
+ }
108
+ /**
109
+ * Subtracts one vector from another or subtracts a scalar value from a vector.
110
+ * @param a - The vector.
111
+ * @param b - The second vector or scalar value.
112
+ * @returns A new vector with subtracted components.
113
+ */
114
+ static subtract(a, b) {
115
+ return this.operate(a, b, (x, y) => x - y);
116
+ }
117
+ /**
118
+ * Multiplies two vectors by their components, or multiplies a vector by a scalar value.
119
+ * @param a - The vector.
120
+ * @param b - The second vector or scalar value.
121
+ * @returns A new vector with multiplied components.
122
+ */
123
+ static multiply(a, b) {
124
+ return this.operate(a, b, (x, y) => x * y);
125
+ }
126
+ /**
127
+ * Divides two vectors by their components, or divides a vector by a scalar value.
128
+ * @param a - The vector.
129
+ * @param b - The second vector or scalar vector.
130
+ * @returns A new vector with divided components.
131
+ */
132
+ static divide(a, b) {
133
+ return this.operate(a, b, (x, y) => x / y);
134
+ }
135
+ /**
136
+ * Performs an operation between a vector and either another vector or scalar value converting the vector into absolute values.
137
+ * @param a - The first vector.
138
+ * @param b - The second vector or scalar value.
139
+ * @param operator - The function defining the operation to perform.
140
+ * @returns A new vector resulting from the operation.
141
+ */
142
+ static operateAbsolute(a, b, operator) {
143
+ let { x, y, z, w } = a;
144
+ const isNumber = typeof b === "number";
145
+ x = operator(Math.abs(x), isNumber ? b : Math.abs(b.x ?? 0));
146
+ y = operator(Math.abs(y), isNumber ? b : Math.abs(b.y ?? 0));
147
+ if (z !== void 0) z = operator(Math.abs(z), isNumber ? b : Math.abs(b.z ?? 0));
148
+ if (w !== void 0) w = operator(Math.abs(w), isNumber ? b : Math.abs(b.w ?? 0));
149
+ return this.create(x, y, z, w);
150
+ }
151
+ /**
152
+ * Adds two vectors or a scalar value to a vector.
153
+ * @param a - The first vector or scalar value.
154
+ * @param b - The second vector or scalar value.
155
+ * @returns A new vector with incremented components.
156
+ */
157
+ static addAbsolute(a, b) {
158
+ return this.operateAbsolute(a, b, (x, y) => x + y);
159
+ }
160
+ /**
161
+ * Subtracts one vector from another or subtracts a scalar value from a vector.
162
+ * @param a - The vector.
163
+ * @param b - The second vector or scalar value.
164
+ * @returns A new vector with subtracted components.
165
+ */
166
+ static subtractAbsolute(a, b) {
167
+ return this.operateAbsolute(a, b, (x, y) => x - y);
168
+ }
169
+ /**
170
+ * Multiplies two vectors by their components, or multiplies a vector by a scalar value.
171
+ * @param a - The vector.
172
+ * @param b - The second vector or scalar value.
173
+ * @returns A new vector with multiplied components.
174
+ */
175
+ static multiplyAbsolute(a, b) {
176
+ return this.operateAbsolute(a, b, (x, y) => x * y);
177
+ }
178
+ /**
179
+ * Divides two vectors by their components, or divides a vector by a scalar value
180
+ * @param a - The vector.
181
+ * @param b - The second vector or scalar vector.
182
+ * @returns A new vector with divided components.
183
+ */
184
+ static divideAbsolute(a, b) {
185
+ return this.operateAbsolute(a, b, (x, y) => x / y);
186
+ }
187
+ /**
188
+ * Calculates the dot product of two vectors.
189
+ * @param a - The first vector.
190
+ * @param b - The second vector.
191
+ * @returns A scalar value representing the degree of alignment between the input vectors.
192
+ */
193
+ static dotProduct(a, b) {
194
+ let result = 0;
195
+ for (const key of ["x", "y", "z", "w"]) {
196
+ const x = a[key];
197
+ const y = b[key];
198
+ if (!!x && !!y) result += x * y;
199
+ else if (x || y) throw new Error("Vectors must have the same dimensions.");
200
+ }
201
+ return result;
202
+ }
203
+ /**
204
+ * Calculates the cross product of two vectors in three-dimensional space.
205
+ * @param a - The first vector.
206
+ * @param b - The second vector.
207
+ * @returns A new vector perpendicular to both input vectors.
208
+ */
209
+ static crossProduct(a, b) {
210
+ const { x: ax, y: ay, z: az, w: aw } = a;
211
+ const { x: bx, y: by, z: bz } = b;
212
+ if (ax === void 0 || ay === void 0 || az === void 0 || bx === void 0 || by === void 0 || bz === void 0)
213
+ throw new Error("Vector.crossProduct requires two three-dimensional vectors.");
214
+ return this.create(ay * bz - az * by, az * bx - ax * bz, ax * by - ay * bx, aw);
215
+ }
216
+ /**
217
+ * Normalizes a vector, producing a new vector with the same direction but with a magnitude of 1.
218
+ * @param vector - The vector to be normalized.
219
+ * @returns The new normalized vector.
220
+ */
221
+ static normalize(a) {
222
+ const length = a instanceof Vector ? a.Length : this.Length(a);
223
+ return this.divide(a, length);
224
+ }
225
+ /**
226
+ * Creates a vector from an array of numbers.
227
+ * @param primitive An array of numbers (usually returned by a native).
228
+ */
229
+ static fromArray(primitive) {
230
+ const [x, y, z, w] = primitive;
231
+ return this.create(x, y, z, w);
232
+ }
233
+ /**
234
+ * Creates a vector from an array or object containing vector components.
235
+ * @param primitive The object to use as a vector.
236
+ */
237
+ static fromObject(primitive) {
238
+ if (Array.isArray(primitive)) return this.fromArray(primitive);
239
+ if ("buffer" in primitive) return this.fromBuffer(primitive);
240
+ const { x, y, z, w } = primitive;
241
+ return this.create(x, y, z, w);
242
+ }
243
+ /**
244
+ * Creates an array of vectors from an array of number arrays
245
+ * @param primitives A multi-dimensional array of number arrays
246
+ */
247
+ static fromArrays(primitives) {
248
+ return primitives.map(this.fromArray);
249
+ }
250
+ /**
251
+ * Calculates the length (magnitude) of a vector.
252
+ * @param obj - The vector for which to calculate the length.
253
+ * @returns The magnitude of the vector.
254
+ */
255
+ static Length(obj) {
256
+ let sum = 0;
257
+ for (const key of ["x", "y", "z", "w"]) {
258
+ if (key in obj) {
259
+ const value = obj[key];
260
+ sum += value * value;
261
+ }
262
+ }
263
+ return Math.sqrt(sum);
264
+ }
265
+ type;
266
+ [size] = 2;
267
+ x = 0;
268
+ y = 0;
269
+ z;
270
+ w;
271
+ /**
272
+ * Constructs a new vector.
273
+ * @param x The x-component of the vector.
274
+ * @param y The y-component of the vector (optional, defaults to x).
275
+ * @param z The z-component of the vector (optional).
276
+ * @param w The w-component of the vector (optional).
277
+ */
278
+ constructor(x, y = x, z, w) {
279
+ for (let i = 0; i < arguments.length; i++) {
280
+ if (typeof arguments[i] !== "number") {
281
+ throw new TypeError(
282
+ `${this.constructor.name} argument at index ${i} must be a number, but got ${typeof arguments[i]}`
283
+ );
284
+ }
285
+ }
286
+ this.x = x;
287
+ this.y = y;
288
+ }
289
+ *[Symbol.iterator]() {
290
+ yield this.x;
291
+ yield this.y;
292
+ if (this.z !== void 0) yield this.z;
293
+ if (this.w !== void 0) yield this.w;
294
+ }
295
+ get size() {
296
+ return this[size];
297
+ }
298
+ toString() {
299
+ return `vector${this.size}(${this.toArray().join(", ")})`;
300
+ }
301
+ /**
302
+ * @see Vector.clone
303
+ */
304
+ clone() {
305
+ return Vector.clone(this);
306
+ }
307
+ /**
308
+ * The product of the Euclidean magnitudes of this and another Vector.
309
+ *
310
+ * @param v Vector to find Euclidean magnitude between.
311
+ * @returns Euclidean magnitude with another vector.
312
+ */
313
+ distanceSquared(v) {
314
+ const w = this.subtract(v);
315
+ return Vector.dotProduct(w, w);
316
+ }
317
+ /**
318
+ * The distance between two Vectors.
319
+ *
320
+ * @param v Vector to find distance between.
321
+ * @returns Distance between this and another vector.
322
+ */
323
+ distance(v) {
324
+ return Math.sqrt(this.distanceSquared(v));
325
+ }
326
+ /**
327
+ * @see Vector.normalize
328
+ */
329
+ normalize() {
330
+ return Vector.normalize(this);
331
+ }
332
+ /**
333
+ * @see Vector.dotProduct
334
+ */
335
+ dotProduct(v) {
336
+ return Vector.dotProduct(this, v);
337
+ }
338
+ /**
339
+ * @see Vector.add
340
+ */
341
+ add(v) {
342
+ return Vector.add(this, v);
343
+ }
344
+ /**
345
+ * @see Vector.addX
346
+ */
347
+ addX(x) {
348
+ return Vector.addX(this, x);
349
+ }
350
+ /**
351
+ * @see Vector.addY
352
+ */
353
+ addY(y) {
354
+ return Vector.addY(this, y);
355
+ }
356
+ /**
357
+ * @see Vector.subtract
358
+ */
359
+ subtract(v) {
360
+ return Vector.subtract(this, v);
361
+ }
362
+ /**
363
+ * @see Vector.multiply
364
+ */
365
+ multiply(v) {
366
+ return Vector.multiply(this, v);
367
+ }
368
+ /**
369
+ * @see Vector.divide
370
+ */
371
+ divide(v) {
372
+ return Vector.divide(this, v);
373
+ }
374
+ /**
375
+ * @see Vector.addAbsolute
376
+ */
377
+ addAbsolute(v) {
378
+ return Vector.addAbsolute(this, v);
379
+ }
380
+ /**
381
+ * @see Vector.subtractAbsolute
382
+ */
383
+ subtractAbsolute(v) {
384
+ return Vector.subtractAbsolute(this, v);
385
+ }
386
+ /**
387
+ * @see Vector.multiply
388
+ */
389
+ multiplyAbsolute(v) {
390
+ return Vector.multiplyAbsolute(this, v);
391
+ }
392
+ /**
393
+ * @see Vector.divide
394
+ */
395
+ divideAbsolute(v) {
396
+ return Vector.divideAbsolute(this, v);
397
+ }
398
+ /**
399
+ * Converts the vector to an array of its components.
400
+ */
401
+ toArray() {
402
+ return [...this];
403
+ }
404
+ /**
405
+ * Replaces the components of the vector with the components of another vector object.
406
+ * @param v - The object whose components will replace the current vector's components.
407
+ */
408
+ replace(v) {
409
+ for (const key of ["x", "y", "z", "w"]) {
410
+ if (key in this && key in v) this[key] = v[key];
411
+ }
412
+ }
413
+ /**
414
+ * Calculates the length (magnitude) of a vector.
415
+ * @returns The magnitude of the vector.
416
+ */
417
+ get Length() {
418
+ let sum = 0;
419
+ for (const value of this) sum += value * value;
420
+ return Math.sqrt(sum);
421
+ }
422
+ swizzle(components) {
423
+ if (!/^[xyzw]+$/.test(components)) throw new Error(`Invalid key in swizzle components (${components}).`);
424
+ const arr = components.split("").map((char) => this[char] ?? 0);
425
+ return Vector.create(...arr);
426
+ }
427
+ }
428
+ class Vector2 extends Vector {
429
+ static {
430
+ __name(this, "Vector2");
431
+ }
432
+ // DO NOT USE, ONLY EXPOSED BECAUSE TS IS TRASH, THIS TYPE IS NOT GUARANTEED
433
+ // TO EXIST, CHANGING IT WILL BREAK STUFF
434
+ type = ClassTypes.Vector2;
435
+ [size] = 2;
436
+ static Zero = new Vector2(0, 0);
437
+ /**
438
+ * Constructs a new 2D vector.
439
+ * @param x The x-component of the vector.
440
+ * @param y The y-component of the vector (optional, defaults to x).
441
+ */
442
+ constructor(x, y = x) {
443
+ super(x, y);
444
+ }
445
+ /**
446
+ * Creates a new vector based on the provided parameters.
447
+ * @param x The x-component of the vector.
448
+ * @param y The y-component of the vector (optional, defaults to the value of x).
449
+ * @returns A new vector instance.
450
+ */
451
+ static create(x, y = x) {
452
+ if (typeof x === "object") ({ x, y } = x);
453
+ return new this(x, y);
454
+ }
455
+ }
456
+ class Vector3 extends Vector {
457
+ static {
458
+ __name(this, "Vector3");
459
+ }
460
+ // DO NOT USE, ONLY EXPOSED BECAUSE TS IS TRASH, THIS TYPE IS NOT GUARANTEED
461
+ // TO EXIST, CHANGING IT WILL BREAK STUFF
462
+ type = ClassTypes.Vector3;
463
+ [size] = 3;
464
+ z = 0;
465
+ static Zero = new Vector3(0, 0, 0);
466
+ static UnitX = new Vector3(1, 0, 0);
467
+ static UnitY = new Vector3(0, 1, 0);
468
+ static UnitZ = new Vector3(0, 0, 1);
469
+ static One = new Vector3(1, 1, 1);
470
+ static Up = new Vector3(0, 0, 1);
471
+ static Down = new Vector3(0, 0, -1);
472
+ static Left = new Vector3(-1, 0, 0);
473
+ static Right = new Vector3(1, 0, 0);
474
+ static ForwardRH = new Vector3(0, 1, 0);
475
+ static ForwardLH = new Vector3(0, -1, 0);
476
+ static BackwardRH = new Vector3(0, -1, 0);
477
+ static BackwardLH = new Vector3(0, 1, 0);
478
+ static Backward = Vector3.BackwardRH;
479
+ /**
480
+ * Constructs a new 3D vector.
481
+ * @param x The x-component of the vector.
482
+ * @param y The y-component of the vector (optional, defaults to x).
483
+ * @param z The z-component of the vector (optional, defaults to y).
484
+ */
485
+ constructor(x, y = x, z = y) {
486
+ super(x, y, z);
487
+ this.z = z;
488
+ }
489
+ /**
490
+ * Creates a new vector based on the provided parameters.
491
+ * @param x The x-component of the vector.
492
+ * @param y The y-component of the vector (optional, defaults to the value of x).
493
+ * @param z The z-component of the vector (optional, defaults to the value of y).
494
+ * @returns A new vector instance.
495
+ */
496
+ static create(x, y = x, z = y) {
497
+ if (typeof x === "object") ({ x, y, z = y } = x);
498
+ return new this(x, y, z);
499
+ }
500
+ /**
501
+ * @see Vector.addZ
502
+ */
503
+ addZ(z) {
504
+ return Vector.addZ(this, z);
505
+ }
506
+ /**
507
+ * @see Vector.crossProduct
508
+ */
509
+ crossProduct(v) {
510
+ return Vector.crossProduct(this, v);
511
+ }
512
+ /**
513
+ * @returns the x and y values as Vec2
514
+ */
515
+ toVec2() {
516
+ return new Vector2(this.x, this.y);
517
+ }
518
+ }
519
+ class Vector4 extends Vector {
520
+ static {
521
+ __name(this, "Vector4");
522
+ }
523
+ // DO NOT USE, ONLY EXPOSED BECAUSE TS IS TRASH, THIS TYPE IS NOT GUARANTEED
524
+ // TO EXIST, CHANGING IT WILL BREAK STUFF
525
+ type = ClassTypes.Vector4;
526
+ [size] = 4;
527
+ z = 0;
528
+ w = 0;
529
+ static Zero = new Vector4(0, 0, 0, 0);
530
+ /**
531
+ * Constructs a new 4D vector.
532
+ * @param x The x-component of the vector.
533
+ * @param y The y-component of the vector (optional, defaults to x).
534
+ * @param z The z-component of the vector (optional, defaults to y).
535
+ * @param w The w-component of the vector (optional, defaults to z).
536
+ */
537
+ constructor(x, y = x, z = y, w = z) {
538
+ super(x, y, z, w);
539
+ this.z = z;
540
+ this.w = w;
541
+ }
542
+ /**
543
+ * Creates a new vector based on the provided parameters.
544
+ * @param x The x-component of the vector.
545
+ * @param y The y-component of the vector (optional, defaults to the value of x).
546
+ * @param z The z-component of the vector (optional, defaults to the value of y).
547
+ * @param w The w-component of the vector (optional, defaults to the value of z).
548
+ * @returns A new vector instance.
549
+ */
550
+ static create(x, y = x, z = y, w = z) {
551
+ if (typeof x === "object") ({ x, y, z = y, w = z } = x);
552
+ return new this(x, y, z, w);
553
+ }
554
+ /**
555
+ * @see Vector.addZ
556
+ */
557
+ addZ(z) {
558
+ return Vector.addZ(this, z);
559
+ }
560
+ /**
561
+ * @see Vector.addW
562
+ */
563
+ addW(w) {
564
+ return Vector.addW(this, w);
565
+ }
566
+ /**
567
+ * @see Vector.crossProduct
568
+ */
569
+ crossProduct(v) {
570
+ return Vector.crossProduct(this, v);
571
+ }
572
+ /**
573
+ * @returns the x and y values as Vec2
574
+ */
575
+ toVec2() {
576
+ return new Vector2(this.x, this.y);
577
+ }
578
+ /**
579
+ * @returns the x and y values as Vec3
580
+ */
581
+ toVec3() {
582
+ return new Vector3(this.x, this.y, this.z);
583
+ }
584
+ }
585
+ export {
586
+ Vector2,
587
+ Vector3,
588
+ Vector4
589
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Cleans up a player name and returns one version to be displayed, and one pure version to be used for fuzzy matching.
3
+ * In case the name has no ascii characters, the pure name will be "empty name".
4
+ * NOTE: this is not perfect, but took me two hours to arrive to this point.
5
+ */
6
+ export declare const cleanPlayerName: (original: string) => string;
@@ -0,0 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ const cleanPlayerName = /* @__PURE__ */ __name((original) => {
4
+ let displayName = original.substring(0, 75).replace(
5
+ // biome-ignore lint/suspicious/noMisleadingCharacterClass: <explanation>
6
+ /[\u0000-\u001F\u007F-\u009F\u200B-\u200D\uFEFF\u200E\uA9C1-\uA9C5\u239B-\u23AD]/g,
7
+ ""
8
+ ).replace(
9
+ /~(HUD_\S+|HC_\S+|[a-z]|[a1]_\d+|bold|italic|ws|wanted_star|nrt|EX_R\*|BLIP_\S+|ACCEPT|CANCEL|PAD_\S+|INPUT_\S+|INPUTGROUP_\S+)~/gi,
10
+ ""
11
+ ).replace(/\^\d/gi, "").replace(/\p{Mark}{2,}/gu, "").replace(/\s+/g, " ").trim();
12
+ if (!displayName.length) displayName = "empty name";
13
+ return displayName;
14
+ }, "cleanPlayerName");
15
+ export {
16
+ cleanPlayerName
17
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * EnumValues - iterate over enum values
3
+ * Just copy&paste from https://github.com/microsoft/TypeScript/issues/4753#issuecomment-694557208
4
+ *
5
+ * @param enumObj
6
+ */
7
+ export declare function enumValues<T extends string>(enumObj: {
8
+ [key: string]: T;
9
+ }): IterableIterator<T>;
10
+ export declare function enumValues<T extends string | number>(enumObj: {
11
+ [key: string]: T;
12
+ }): IterableIterator<Exclude<T, string>>;
@@ -0,0 +1,20 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ function* enumValues(enumObj) {
4
+ let isStringEnum = true;
5
+ for (const property in enumObj) {
6
+ if (typeof enumObj[property] === "number") {
7
+ isStringEnum = false;
8
+ break;
9
+ }
10
+ }
11
+ for (const property in enumObj) {
12
+ if (isStringEnum || typeof enumObj[property] === "number") {
13
+ yield enumObj[property];
14
+ }
15
+ }
16
+ }
17
+ __name(enumValues, "enumValues");
18
+ export {
19
+ enumValues
20
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * get string from uint8 array
3
+ *
4
+ * @param buffer - Uint8Array
5
+ * @param start - The beginning of the specified portion of the array
6
+ * @param end - The end of the specified portion of the array
7
+ */
8
+ export declare const getStringFromUInt8Array: (buffer: Uint8Array, start: number, end: number) => string;
@@ -0,0 +1,6 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ const getStringFromUInt8Array = /* @__PURE__ */ __name((buffer, start, end) => String.fromCharCode(...buffer.slice(start, end)).replace(/\u0000/g, ""), "getStringFromUInt8Array");
4
+ export {
5
+ getStringFromUInt8Array
6
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * get uint32 from uint8 array
3
+ *
4
+ * @param buffer - Uint8Array
5
+ * @param start - The beginning of the specified portion of the array
6
+ * @param end - The end of the specified portion of the array
7
+ */
8
+ export declare const getUInt32FromUint8Array: (buffer: Uint8Array, start: number, end: number) => number;
@@ -0,0 +1,6 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ const getUInt32FromUint8Array = /* @__PURE__ */ __name((buffer, start, end) => new Uint32Array(buffer.slice(start, end).buffer)[0], "getUInt32FromUint8Array");
4
+ export {
5
+ getUInt32FromUint8Array
6
+ };
@@ -0,0 +1 @@
1
+ export declare function randomInt(min: number, max: number): number;
@@ -0,0 +1,9 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ function randomInt(min, max) {
4
+ return Math.random() * (max - min) + min;
5
+ }
6
+ __name(randomInt, "randomInt");
7
+ export {
8
+ randomInt
9
+ };