@nativewrappers/server 0.0.72 → 0.0.74

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/README.md CHANGED
@@ -1,45 +1,45 @@
1
- <h1 align="center">Monorepo for a FiveM server/client wrapper</h1>
2
-
3
- <p align="center">
4
- <i>🔥 A Javascript/Typescript package for FiveM resource development 🎮</i>
5
- <br>
6
- <small>This project is in no way affiliated with FiveM or the Cfx.re Collective.</small>
7
- </br></br>
8
- <a href="https://github.com/nativewrappers/nativewrappers/blob/master/LICENSE">
9
- <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat" alt="License: MIT">
10
- </a>
11
- <a href="https://www.npmjs.com/package/@nativewrappers/fivem">
12
- <img src="https://img.shields.io/npm/v/@nativewrappers/fivem?style=flat" alt="npm version">
13
- </a>
14
- <a href="https://www.npmjs.com/package/@nativewrappers/fivem">
15
- <img src="https://img.shields.io/npm/dm/@nativewrappers/fivem?style=flat">
16
- </a>
17
- <a href="https://github.com/nativewrappers/nativewrappers/actions/workflows/config.yml">
18
- <img src="https://github.com/nativewrappers/nativewrappers/actions/workflows/config.yml/badge.svg" alt="Workflow Status">
19
- </a>
20
- <a href="https://github.com/nativewrappers/nativewrappers/commits/master">
21
- <img src="https://img.shields.io/github/last-commit/nativewrappers/fivem.svg?style=flat" alt="Last commit">
22
- </a>
23
- </p>
24
-
25
- <h3 align="center">This project is currently iterating rapidly, there will be breaking changes.</h3>
26
-
27
- <p align="center">
28
- <h2 align="center"><a href="https://github.com/nativewrappers/nativewrappers/tree/main/docs">Documentation</a></h2>
29
- <!-- <a href="https://forum.fivem.net/t/fivem-js-v1-3-2-javascript-typescript-wrapper-now-with-menu-class-nativeui/268640">Forum</a> -->
30
- </p>
31
-
32
- ## Features
33
-
34
- - No runtime dependencies
35
- - Entity management through class objects (i.e. `Vehicle` and `Ped` entities)
36
- - Server and Client side variants on wrapper
37
-
38
-
39
- ## Download & Install
40
- ```
41
- pnpm add @nativewrappers/redm # for redm,
42
- pnpm add @nativewrappers/fivem # for fivem
43
- pnpm add @nativewrappers/common # for any, should be game agnostic, provides Vector3, decors, kvps, helper functions, etc
44
- pnpm add @nativewrappers/server # for server
45
- ```
1
+ <h1 align="center">Monorepo for a FiveM server/client wrapper</h1>
2
+
3
+ <p align="center">
4
+ <i>🔥 A Javascript/Typescript package for FiveM resource development 🎮</i>
5
+ <br>
6
+ <small>This project is in no way affiliated with FiveM or the Cfx.re Collective.</small>
7
+ </br></br>
8
+ <a href="https://github.com/nativewrappers/nativewrappers/blob/master/LICENSE">
9
+ <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat" alt="License: MIT">
10
+ </a>
11
+ <a href="https://www.npmjs.com/package/@nativewrappers/fivem">
12
+ <img src="https://img.shields.io/npm/v/@nativewrappers/fivem?style=flat" alt="npm version">
13
+ </a>
14
+ <a href="https://www.npmjs.com/package/@nativewrappers/fivem">
15
+ <img src="https://img.shields.io/npm/dm/@nativewrappers/fivem?style=flat">
16
+ </a>
17
+ <a href="https://github.com/nativewrappers/nativewrappers/actions/workflows/config.yml">
18
+ <img src="https://github.com/nativewrappers/nativewrappers/actions/workflows/config.yml/badge.svg" alt="Workflow Status">
19
+ </a>
20
+ <a href="https://github.com/nativewrappers/nativewrappers/commits/master">
21
+ <img src="https://img.shields.io/github/last-commit/nativewrappers/fivem.svg?style=flat" alt="Last commit">
22
+ </a>
23
+ </p>
24
+
25
+ <h3 align="center">This project is currently iterating rapidly, there will be breaking changes.</h3>
26
+
27
+ <p align="center">
28
+ <h2 align="center"><a href="https://github.com/nativewrappers/nativewrappers/tree/main/docs">Documentation</a></h2>
29
+ <!-- <a href="https://forum.fivem.net/t/fivem-js-v1-3-2-javascript-typescript-wrapper-now-with-menu-class-nativeui/268640">Forum</a> -->
30
+ </p>
31
+
32
+ ## Features
33
+
34
+ - No runtime dependencies
35
+ - Entity management through class objects (i.e. `Vehicle` and `Ped` entities)
36
+ - Server and Client side variants on wrapper
37
+
38
+
39
+ ## Download & Install
40
+ ```
41
+ pnpm add @nativewrappers/redm # for redm,
42
+ pnpm add @nativewrappers/fivem # for fivem
43
+ pnpm add @nativewrappers/common # for any, should be game agnostic, provides Vector3, decors, kvps, helper functions, etc
44
+ pnpm add @nativewrappers/server # for server
45
+ ```
@@ -1,8 +1,3 @@
1
- export interface PointF {
2
- x: number;
3
- y: number;
4
- z: number;
5
- }
6
1
  export declare class PointF implements PointF {
7
2
  x: number;
8
3
  y: number;
package/index.js CHANGED
@@ -42,8 +42,7 @@ var Vector = class _Vector {
42
42
  if (type !== EXT_VECTOR2 && type !== EXT_VECTOR3 && type !== EXT_VECTOR4)
43
43
  throw new Error("Buffer type is not a valid Vector.");
44
44
  const arr = new Array(buffer.length / 4);
45
- for (let i = 0; i < arr.length; i++)
46
- arr[i] = Number(buffer.readFloatLE(i * 4).toPrecision(7));
45
+ for (let i = 0; i < arr.length; i++) arr[i] = Number(buffer.readFloatLE(i * 4).toPrecision(7));
47
46
  return this.fromArray(arr);
48
47
  }
49
48
  /**
@@ -96,12 +95,7 @@ var Vector = class _Vector {
96
95
  * @returns A new vector with the z-component incremented.
97
96
  */
98
97
  static addZ(obj, z) {
99
- return this.create(
100
- obj.x,
101
- obj.y,
102
- obj.z + z,
103
- obj.w
104
- );
98
+ return this.create(obj.x, obj.y, obj.z + z, obj.w);
105
99
  }
106
100
  /**
107
101
  * Adds a scalar value to the w-component of a vector.
@@ -151,10 +145,8 @@ var Vector = class _Vector {
151
145
  const isNumber = typeof b === "number";
152
146
  x = operator(Math.abs(x), isNumber ? b : Math.abs(b.x ?? 0));
153
147
  y = operator(Math.abs(y), isNumber ? b : Math.abs(b.y ?? 0));
154
- if (z !== void 0)
155
- z = operator(Math.abs(z), isNumber ? b : Math.abs(b.z ?? 0));
156
- if (w !== void 0)
157
- w = operator(Math.abs(w), isNumber ? b : Math.abs(b.w ?? 0));
148
+ if (z !== void 0) z = operator(Math.abs(z), isNumber ? b : Math.abs(b.z ?? 0));
149
+ if (w !== void 0) w = operator(Math.abs(w), isNumber ? b : Math.abs(b.w ?? 0));
158
150
  return this.create(x, y, z, w);
159
151
  }
160
152
  /**
@@ -205,8 +197,7 @@ var Vector = class _Vector {
205
197
  const x = a[key];
206
198
  const y = b[key];
207
199
  if (!!x && !!y) result += x * y;
208
- else if (x || y)
209
- throw new Error("Vectors must have the same dimensions.");
200
+ else if (x || y) throw new Error("Vectors must have the same dimensions.");
210
201
  }
211
202
  return result;
212
203
  }
@@ -220,15 +211,8 @@ var Vector = class _Vector {
220
211
  const { x: ax, y: ay, z: az, w: aw } = a;
221
212
  const { x: bx, y: by, z: bz } = b;
222
213
  if (ax === void 0 || ay === void 0 || az === void 0 || bx === void 0 || by === void 0 || bz === void 0)
223
- throw new Error(
224
- "Vector.crossProduct requires two three-dimensional vectors."
225
- );
226
- return this.create(
227
- ay * bz - az * by,
228
- az * bx - ax * bz,
229
- ax * by - ay * bx,
230
- aw
231
- );
214
+ throw new Error("Vector.crossProduct requires two three-dimensional vectors.");
215
+ return this.create(ay * bz - az * by, az * bx - ax * bz, ax * by - ay * bx, aw);
232
216
  }
233
217
  /**
234
218
  * Normalizes a vector, producing a new vector with the same direction but with a magnitude of 1.
@@ -252,8 +236,7 @@ var Vector = class _Vector {
252
236
  * @param primitive The object to use as a vector.
253
237
  */
254
238
  static fromObject(primitive) {
255
- if (Array.isArray(primitive))
256
- return this.fromArray(primitive);
239
+ if (Array.isArray(primitive)) return this.fromArray(primitive);
257
240
  if ("buffer" in primitive) return this.fromBuffer(primitive);
258
241
  const { x, y, z, w } = primitive;
259
242
  return this.create(x, y, z, w);
@@ -438,8 +421,7 @@ var Vector = class _Vector {
438
421
  return Math.sqrt(sum);
439
422
  }
440
423
  swizzle(components) {
441
- if (!/^[xyzw]+$/.test(components))
442
- throw new Error(`Invalid key in swizzle components (${components}).`);
424
+ if (!/^[xyzw]+$/.test(components)) throw new Error(`Invalid key in swizzle components (${components}).`);
443
425
  const arr = components.split("").map((char) => this[char] ?? 0);
444
426
  return _Vector.create(...arr);
445
427
  }
@@ -679,6 +661,7 @@ var Color = class _Color {
679
661
  // src/common/utils/cleanPlayerName.ts
680
662
  var cleanPlayerName = /* @__PURE__ */ __name((original) => {
681
663
  let displayName = original.substring(0, 75).replace(
664
+ // biome-ignore lint/suspicious/noMisleadingCharacterClass: <explanation>
682
665
  /[\u0000-\u001F\u007F-\u009F\u200B-\u200D\uFEFF\u200E\uA9C1-\uA9C5\u239B-\u23AD]/g,
683
666
  ""
684
667
  ).replace(
@@ -790,10 +773,7 @@ var BaseEntity = class _BaseEntity {
790
773
  return GetEntityHeading(this.handle);
791
774
  }
792
775
  get PositionAndHeading() {
793
- return Vector4.fromArray([
794
- ...GetEntityCoords(this.handle),
795
- GetEntityHeading(this.handle)
796
- ]);
776
+ return Vector4.fromArray([...GetEntityCoords(this.handle), GetEntityHeading(this.handle)]);
797
777
  }
798
778
  get Health() {
799
779
  return GetEntityHealth(this.handle);
@@ -1405,7 +1385,6 @@ var Game = class {
1405
1385
  static registerCommand(name, handler, restricted = false) {
1406
1386
  RegisterCommand(
1407
1387
  name,
1408
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1409
1388
  (source2, args) => {
1410
1389
  const player = new Player2(Number.parseInt(source2));
1411
1390
  handler(player, args);
@@ -1521,8 +1500,7 @@ function registerCommand(name, commandHandler, restricted) {
1521
1500
  }
1522
1501
  if (Array.isArray(restricted)) {
1523
1502
  for (const principal of restricted) {
1524
- if (!IsPrincipalAceAllowed(principal, ace))
1525
- ExecuteCommand(`add_ace ${restricted} ${ace} allow`);
1503
+ if (!IsPrincipalAceAllowed(principal, ace)) ExecuteCommand(`add_ace ${restricted} ${ace} allow`);
1526
1504
  }
1527
1505
  }
1528
1506
  }
@@ -1535,11 +1513,7 @@ var Command = class {
1535
1513
  this.params = params;
1536
1514
  this.#handler = handler;
1537
1515
  this.name = `/${name}`;
1538
- registerCommand(
1539
- name,
1540
- (source2, args, raw) => this.call(source2, args, raw),
1541
- restricted
1542
- );
1516
+ registerCommand(name, (source2, args, raw) => this.call(source2, args, raw), restricted);
1543
1517
  if (params) {
1544
1518
  for (const parameter of params) {
1545
1519
  if (parameter.type) {
@@ -1600,10 +1574,8 @@ var Command = class {
1600
1574
  try {
1601
1575
  await this.#handler(parsed);
1602
1576
  } catch (err) {
1603
- Citizen.trace(
1604
- `^1command '${raw.split(" ")[0] || raw}' failed to execute!^0
1605
- ${err.message}`
1606
- );
1577
+ Citizen.trace(`^1command '${raw.split(" ")[0] || raw}' failed to execute!^0
1578
+ ${err.message}`);
1607
1579
  }
1608
1580
  }
1609
1581
  };
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "type": "module",
11
- "version": "0.0.72",
11
+ "version": "0.0.74",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/nativewrappers/nativewrappers.git"