worldstate-emitter 2.1.2 → 2.2.0

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.
@@ -30,7 +30,7 @@ export default class Worldstate {
30
30
  constructor(eventEmitter, locale) {
31
31
  this.#emitter = eventEmitter;
32
32
  this.#locale = locale;
33
- logger.silly('starting up worldstate listener...');
33
+ logger.debug('starting up worldstate listener...');
34
34
  if (locale) {
35
35
  logger.debug(`only listening for ${locale}...`);
36
36
  }
@@ -134,7 +134,7 @@ export default class Worldstate {
134
134
  emit(id, packet) {
135
135
  if (debugEvents.includes(packet.key)) logger.warn(packet.key);
136
136
 
137
- logger.silly(`ws:update:event - emitting ${packet.id}`);
137
+ logger.debug(`ws:update:event - emitting ${packet.id}`);
138
138
  delete packet.cycleStart;
139
139
  this.#emitter.emit(id, packet);
140
140
  }
@@ -146,7 +146,7 @@ export default class Worldstate {
146
146
  * @throws {Error} when the platform or locale aren't tracked and aren't updated
147
147
  */
148
148
  get(language = 'en') {
149
- logger.warn(`getting worldstate ${language}...`);
149
+ logger.debug(`getting worldstate ${language}...`);
150
150
  if (this.#worldStates?.[language]) {
151
151
  return this.#worldStates?.[language]?.data;
152
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worldstate-emitter",
3
- "version": "2.1.2",
3
+ "version": "2.2.0",
4
4
  "description": "Event emitter for worldstate & other warframe events",
5
5
  "keywords": [
6
6
  "warframe",
@@ -42,7 +42,12 @@
42
42
  "commitlint": {
43
43
  "extends": [
44
44
  "@commitlint/config-conventional"
45
- ]
45
+ ],
46
+ "rules": {
47
+ "body-max-line-length": [
48
+ 0
49
+ ]
50
+ }
46
51
  },
47
52
  "lint-staged": {
48
53
  "*.js": [
@@ -117,7 +122,7 @@
117
122
  "@commitlint/cli": "^19.2.1",
118
123
  "@commitlint/config-conventional": "^19.1.0",
119
124
  "@wfcd/eslint-config": "latest",
120
- "c8": "^9.1.0",
125
+ "c8": "^10.1.2",
121
126
  "chai": "^4.3.4",
122
127
  "coveralls": "^3.1.0",
123
128
  "husky": "^9.0.11",
@@ -129,7 +134,7 @@
129
134
  },
130
135
  "peerDependencies": {
131
136
  "warframe-worldstate-data": "^2.x",
132
- "warframe-worldstate-parser": "^3.x"
137
+ "warframe-worldstate-parser": "^4.x"
133
138
  },
134
139
  "optionalDependencies": {
135
140
  "colors": "^1.4.0",
@@ -1,4 +1,4 @@
1
- import Worldstate from 'warframe-worldstate-parser';
1
+ import WorldState from 'warframe-worldstate-parser';
2
2
 
3
3
  import { logger } from './index.js';
4
4
 
@@ -16,7 +16,7 @@ export default class WSCache {
16
16
 
17
17
  /**
18
18
  * Set up a cache checking for data and updates to a specific worldstate set
19
- * @param {string} language Langauge/translation to track
19
+ * @param {string} language Language/translation to track
20
20
  * @param {Cache} kuvaCache Cache of kuva data, provided by Semlar
21
21
  * @param {Cache} sentientCache Cache of sentient outpost data, provided by Semlar
22
22
  * @param {EventEmitter} eventEmitter Emitter to push new worldstate updates to
@@ -29,6 +29,27 @@ export default class WSCache {
29
29
  this.#emitter = eventEmitter;
30
30
  }
31
31
 
32
+ /**
33
+ * Update the current data with new data
34
+ * @param {string} newData updated worldstate data
35
+ * @returns {Promise<void>}
36
+ */
37
+ #update = async (newData) => {
38
+ const t = await WorldState.build(newData, {
39
+ locale: this.#language,
40
+ kuvaData: JSON.parse(await this.#kuvaCache.get()),
41
+ sentientData: JSON.parse(await this.#sentientCache.get()),
42
+ });
43
+ if (!t.timestamp) return;
44
+
45
+ this.#inner = t;
46
+ this.#emitter.emit('ws:update:parsed', {
47
+ language: this.#language,
48
+ platform: this.#platform,
49
+ data: t,
50
+ });
51
+ };
52
+
32
53
  /**
33
54
  * Get the latest worldstate data from this cache
34
55
  * @returns {Object} Current worldstate data
@@ -43,21 +64,7 @@ export default class WSCache {
43
64
  */
44
65
  set data(newData) {
45
66
  logger.debug(`got new data for ${this.#language}, parsing...`);
46
- setTimeout(async () => {
47
- const t = new Worldstate(newData, {
48
- locale: this.#language,
49
- kuvaData: JSON.parse(await this.#kuvaCache.get()),
50
- sentientData: JSON.parse(await this.#sentientCache.get()),
51
- });
52
- if (!t.timestamp) return;
53
-
54
- this.#inner = t;
55
- this.#emitter.emit('ws:update:parsed', {
56
- language: this.#language,
57
- platform: this.#platform,
58
- data: t,
59
- });
60
- }, 0);
67
+ this.#update(newData);
61
68
  }
62
69
 
63
70
  /**