@armoury/fivem-framework-server 1.0.54 → 1.0.61

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.
@@ -47,7 +47,7 @@ let ServerDBDependentController = class ServerDBDependentController extends serv
47
47
  entityValues = [forceId.toString(), ...entityValues];
48
48
  }
49
49
  const id = await Cfx.exports['oxmysql'].insert_async(`INSERT INTO \`${this.dbTableName}\` (${entityProperties.join(', ')}) VALUES (${Array(entityProperties.length).fill('?').join(', ')})`, entityValues);
50
- const createdEntity = Object.assign(Object.assign({}, entity), { id: forceId || id });
50
+ const createdEntity = { ...entity, id: forceId || id };
51
51
  this._entities.push(createdEntity);
52
52
  this.syncWithClients();
53
53
  return createdEntity;
@@ -105,7 +105,7 @@ let ServerDBDependentController = class ServerDBDependentController extends serv
105
105
  });
106
106
  return resultItem;
107
107
  });
108
- if (result === null || result === void 0 ? void 0 : result.length) {
108
+ if (result?.length) {
109
109
  result.forEach((entity) => {
110
110
  this._entities.push(entity);
111
111
  if (bindTo) {
@@ -113,7 +113,7 @@ let ServerDBDependentController = class ServerDBDependentController extends serv
113
113
  }
114
114
  });
115
115
  setTimeout(() => { this.syncWithClients(); }, 2000);
116
- return ((result === null || result === void 0 ? void 0 : result.length) > 1 ? result : result[0]);
116
+ return (result?.length > 1 ? result : result[0]);
117
117
  }
118
118
  return null;
119
119
  }
@@ -126,7 +126,7 @@ let ServerDBDependentController = class ServerDBDependentController extends serv
126
126
  });
127
127
  return resultItem;
128
128
  });
129
- if (result === null || result === void 0 ? void 0 : result.length) {
129
+ if (result?.length) {
130
130
  this._entities = result;
131
131
  setTimeout(() => { this.syncWithClients(); }, 2000);
132
132
  }
@@ -10,20 +10,26 @@ exports.Blip = void 0;
10
10
  const injection_js_1 = require("injection-js");
11
11
  let Blip = class Blip {
12
12
  static createLocalized(x, y, z, localizationKey, options) {
13
- var _a;
14
- const newOptions = Object.assign(Object.assign({}, (options ? options : {})), { localizationKey, localizationParameters: (_a = options === null || options === void 0 ? void 0 : options.localizationParameters) !== null && _a !== void 0 ? _a : {} });
13
+ const newOptions = {
14
+ ...(options ? options : {}),
15
+ localizationKey,
16
+ localizationParameters: options?.localizationParameters ?? {},
17
+ };
15
18
  return this.create(x, y, z, newOptions);
16
19
  }
17
20
  static create(x, y, z, options) {
18
- var _a, _b, _c, _d;
19
- options = Object.assign(Object.assign({}, options), { toPlayerId: (_a = options === null || options === void 0 ? void 0 : options.toPlayerId) !== null && _a !== void 0 ? _a : -1, localizationParameters: (_b = options === null || options === void 0 ? void 0 : options.localizationParameters) !== null && _b !== void 0 ? _b : {} });
21
+ options = {
22
+ ...options,
23
+ toPlayerId: options?.toPlayerId ?? -1,
24
+ localizationParameters: options?.localizationParameters ?? {},
25
+ };
20
26
  const lastBlipId = !this._blipIds.length ? -1 : this._blipIds[this._blipIds.length - 1];
21
27
  const blipId = lastBlipId + 1;
22
28
  this._blipIds.push(blipId);
23
29
  const newLocalizationKey = options.localizationKey
24
30
  ? `${Cfx.Server.GetCurrentResourceName()}.${options.localizationKey}`
25
31
  : undefined;
26
- Cfx.emitNet('armoury:safe:blip:create', options.toPlayerId, Cfx.Server.GetCurrentResourceName(), blipId, x, y, z, (_c = options.spriteId) !== null && _c !== void 0 ? _c : undefined, newLocalizationKey, (_d = options.localizationParameters) !== null && _d !== void 0 ? _d : undefined);
32
+ Cfx.emitNet('armoury:safe:blip:create', options.toPlayerId, Cfx.Server.GetCurrentResourceName(), blipId, x, y, z, options.spriteId ?? undefined, newLocalizationKey, options.localizationParameters ?? undefined);
27
33
  Cfx.emit('armoury:safe:blip:created', blipId, x, y, z, options);
28
34
  return blipId;
29
35
  }
@@ -45,9 +45,8 @@ let ServerResourceDatabase = class ServerResourceDatabase {
45
45
  this.loadDBEntities();
46
46
  }
47
47
  this.onSync$.subscribe((data) => {
48
- var _a;
49
48
  // TODO: Probable performance issue cause. Entity updates should be sent to clients only for a specific property, so they don't need to wipe ALL data and rewrite it back.
50
- Cfx.Server.TriggerClientEvent(`${Cfx.Server.GetCurrentResourceName()}:db-send-entities`, (_a = data === null || data === void 0 ? void 0 : data.player) !== null && _a !== void 0 ? _a : -1, this.entities);
49
+ Cfx.Server.TriggerClientEvent(`${Cfx.Server.GetCurrentResourceName()}:db-send-entities`, data?.player ?? -1, this.entities);
51
50
  });
52
51
  }
53
52
  create(entity, forceId) {
@@ -60,7 +59,7 @@ let ServerResourceDatabase = class ServerResourceDatabase {
60
59
  entityValues = [forceId.toString(), ...entityValues];
61
60
  }
62
61
  const id = await Cfx.exports['oxmysql'].insert_async(`INSERT INTO \`${this._tableName}\` (${entityProperties.join(', ')}) VALUES (${Array(entityProperties.length).fill('?').join(', ')})`, entityValues);
63
- const createdEntity = Object.assign(Object.assign({}, entity), { id: forceId || id });
62
+ const createdEntity = { ...entity, id: forceId || id };
64
63
  this._entities.push(createdEntity);
65
64
  this._onSync$.next();
66
65
  return createdEntity;
@@ -115,7 +114,7 @@ let ServerResourceDatabase = class ServerResourceDatabase {
115
114
  });
116
115
  return resultItem;
117
116
  });
118
- if (result === null || result === void 0 ? void 0 : result.length) {
117
+ if (result?.length) {
119
118
  result.forEach((entity) => {
120
119
  this._entities.push(entity);
121
120
  if (bindTo) {
@@ -123,7 +122,7 @@ let ServerResourceDatabase = class ServerResourceDatabase {
123
122
  }
124
123
  });
125
124
  setTimeout(() => { this._onSync$.next(); }, 2000);
126
- return ((result === null || result === void 0 ? void 0 : result.length) > 1 ? result : result[0]);
125
+ return (result?.length > 1 ? result : result[0]);
127
126
  }
128
127
  return null;
129
128
  }
@@ -136,7 +135,7 @@ let ServerResourceDatabase = class ServerResourceDatabase {
136
135
  });
137
136
  return resultItem;
138
137
  });
139
- if (result === null || result === void 0 ? void 0 : result.length) {
138
+ if (result?.length) {
140
139
  this._entities = result;
141
140
  setTimeout(() => { this._onSync$.next(); }, 2000);
142
141
  }
@@ -21,9 +21,8 @@ let ServerTranslateService = class ServerTranslateService {
21
21
  this.playersMappedToLanguages = new Map();
22
22
  }
23
23
  instant(forPlayer, key) {
24
- var _a;
25
24
  const language = this.getLanguage(forPlayer);
26
- return ((_a = this._translations[language]) === null || _a === void 0 ? void 0 : _a[key]) || key;
25
+ return this._translations[language]?.[key] || key;
27
26
  }
28
27
  onPlayerDisconnect() {
29
28
  const player = Cfx.source;
@@ -44,7 +44,7 @@ let ServerDBDependentController = class ServerDBDependentController extends Serv
44
44
  entityValues = [forceId.toString(), ...entityValues];
45
45
  }
46
46
  const id = await Cfx.exports['oxmysql'].insert_async(`INSERT INTO \`${this.dbTableName}\` (${entityProperties.join(', ')}) VALUES (${Array(entityProperties.length).fill('?').join(', ')})`, entityValues);
47
- const createdEntity = Object.assign(Object.assign({}, entity), { id: forceId || id });
47
+ const createdEntity = { ...entity, id: forceId || id };
48
48
  this._entities.push(createdEntity);
49
49
  this.syncWithClients();
50
50
  return createdEntity;
@@ -102,7 +102,7 @@ let ServerDBDependentController = class ServerDBDependentController extends Serv
102
102
  });
103
103
  return resultItem;
104
104
  });
105
- if (result === null || result === void 0 ? void 0 : result.length) {
105
+ if (result?.length) {
106
106
  result.forEach((entity) => {
107
107
  this._entities.push(entity);
108
108
  if (bindTo) {
@@ -110,7 +110,7 @@ let ServerDBDependentController = class ServerDBDependentController extends Serv
110
110
  }
111
111
  });
112
112
  setTimeout(() => { this.syncWithClients(); }, 2000);
113
- return ((result === null || result === void 0 ? void 0 : result.length) > 1 ? result : result[0]);
113
+ return (result?.length > 1 ? result : result[0]);
114
114
  }
115
115
  return null;
116
116
  }
@@ -123,7 +123,7 @@ let ServerDBDependentController = class ServerDBDependentController extends Serv
123
123
  });
124
124
  return resultItem;
125
125
  });
126
- if (result === null || result === void 0 ? void 0 : result.length) {
126
+ if (result?.length) {
127
127
  this._entities = result;
128
128
  setTimeout(() => { this.syncWithClients(); }, 2000);
129
129
  }
@@ -7,20 +7,26 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { Injectable } from 'injection-js';
8
8
  let Blip = class Blip {
9
9
  static createLocalized(x, y, z, localizationKey, options) {
10
- var _a;
11
- const newOptions = Object.assign(Object.assign({}, (options ? options : {})), { localizationKey, localizationParameters: (_a = options === null || options === void 0 ? void 0 : options.localizationParameters) !== null && _a !== void 0 ? _a : {} });
10
+ const newOptions = {
11
+ ...(options ? options : {}),
12
+ localizationKey,
13
+ localizationParameters: options?.localizationParameters ?? {},
14
+ };
12
15
  return this.create(x, y, z, newOptions);
13
16
  }
14
17
  static create(x, y, z, options) {
15
- var _a, _b, _c, _d;
16
- options = Object.assign(Object.assign({}, options), { toPlayerId: (_a = options === null || options === void 0 ? void 0 : options.toPlayerId) !== null && _a !== void 0 ? _a : -1, localizationParameters: (_b = options === null || options === void 0 ? void 0 : options.localizationParameters) !== null && _b !== void 0 ? _b : {} });
18
+ options = {
19
+ ...options,
20
+ toPlayerId: options?.toPlayerId ?? -1,
21
+ localizationParameters: options?.localizationParameters ?? {},
22
+ };
17
23
  const lastBlipId = !this._blipIds.length ? -1 : this._blipIds[this._blipIds.length - 1];
18
24
  const blipId = lastBlipId + 1;
19
25
  this._blipIds.push(blipId);
20
26
  const newLocalizationKey = options.localizationKey
21
27
  ? `${Cfx.Server.GetCurrentResourceName()}.${options.localizationKey}`
22
28
  : undefined;
23
- Cfx.emitNet('armoury:safe:blip:create', options.toPlayerId, Cfx.Server.GetCurrentResourceName(), blipId, x, y, z, (_c = options.spriteId) !== null && _c !== void 0 ? _c : undefined, newLocalizationKey, (_d = options.localizationParameters) !== null && _d !== void 0 ? _d : undefined);
29
+ Cfx.emitNet('armoury:safe:blip:create', options.toPlayerId, Cfx.Server.GetCurrentResourceName(), blipId, x, y, z, options.spriteId ?? undefined, newLocalizationKey, options.localizationParameters ?? undefined);
24
30
  Cfx.emit('armoury:safe:blip:created', blipId, x, y, z, options);
25
31
  return blipId;
26
32
  }
@@ -42,9 +42,8 @@ let ServerResourceDatabase = class ServerResourceDatabase {
42
42
  this.loadDBEntities();
43
43
  }
44
44
  this.onSync$.subscribe((data) => {
45
- var _a;
46
45
  // TODO: Probable performance issue cause. Entity updates should be sent to clients only for a specific property, so they don't need to wipe ALL data and rewrite it back.
47
- Cfx.Server.TriggerClientEvent(`${Cfx.Server.GetCurrentResourceName()}:db-send-entities`, (_a = data === null || data === void 0 ? void 0 : data.player) !== null && _a !== void 0 ? _a : -1, this.entities);
46
+ Cfx.Server.TriggerClientEvent(`${Cfx.Server.GetCurrentResourceName()}:db-send-entities`, data?.player ?? -1, this.entities);
48
47
  });
49
48
  }
50
49
  create(entity, forceId) {
@@ -57,7 +56,7 @@ let ServerResourceDatabase = class ServerResourceDatabase {
57
56
  entityValues = [forceId.toString(), ...entityValues];
58
57
  }
59
58
  const id = await Cfx.exports['oxmysql'].insert_async(`INSERT INTO \`${this._tableName}\` (${entityProperties.join(', ')}) VALUES (${Array(entityProperties.length).fill('?').join(', ')})`, entityValues);
60
- const createdEntity = Object.assign(Object.assign({}, entity), { id: forceId || id });
59
+ const createdEntity = { ...entity, id: forceId || id };
61
60
  this._entities.push(createdEntity);
62
61
  this._onSync$.next();
63
62
  return createdEntity;
@@ -112,7 +111,7 @@ let ServerResourceDatabase = class ServerResourceDatabase {
112
111
  });
113
112
  return resultItem;
114
113
  });
115
- if (result === null || result === void 0 ? void 0 : result.length) {
114
+ if (result?.length) {
116
115
  result.forEach((entity) => {
117
116
  this._entities.push(entity);
118
117
  if (bindTo) {
@@ -120,7 +119,7 @@ let ServerResourceDatabase = class ServerResourceDatabase {
120
119
  }
121
120
  });
122
121
  setTimeout(() => { this._onSync$.next(); }, 2000);
123
- return ((result === null || result === void 0 ? void 0 : result.length) > 1 ? result : result[0]);
122
+ return (result?.length > 1 ? result : result[0]);
124
123
  }
125
124
  return null;
126
125
  }
@@ -133,7 +132,7 @@ let ServerResourceDatabase = class ServerResourceDatabase {
133
132
  });
134
133
  return resultItem;
135
134
  });
136
- if (result === null || result === void 0 ? void 0 : result.length) {
135
+ if (result?.length) {
137
136
  this._entities = result;
138
137
  setTimeout(() => { this._onSync$.next(); }, 2000);
139
138
  }
@@ -18,9 +18,8 @@ let ServerTranslateService = class ServerTranslateService {
18
18
  this.playersMappedToLanguages = new Map();
19
19
  }
20
20
  instant(forPlayer, key) {
21
- var _a;
22
21
  const language = this.getLanguage(forPlayer);
23
- return ((_a = this._translations[language]) === null || _a === void 0 ? void 0 : _a[key]) || key;
22
+ return this._translations[language]?.[key] || key;
24
23
  }
25
24
  onPlayerDisconnect() {
26
25
  const player = Cfx.source;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@armoury/fivem-framework-server",
3
- "version": "1.0.54",
3
+ "version": "1.0.61",
4
4
  "description": "Server APIs for the Armoury FiveM framework",
5
5
  "main": "dist/cjs/server/index.js",
6
6
  "module": "dist/esm/server/index.js",
@@ -27,7 +27,7 @@
27
27
  "rxjs": "^7.8.1"
28
28
  },
29
29
  "peerDependencies": {
30
- "@armoury/fivem-framework-common": "1.0.54"
30
+ "@armoury/fivem-framework-common": "1.0.61"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"