worldstate-emitter 2.2.12 → 2.3.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.
- package/README.md +252 -60
- package/dist/index.d.mts +56 -0
- package/dist/index.mjs +14645 -0
- package/package.json +43 -18
- package/.babelrc.json +0 -4
- package/.commitlintrc.yml +0 -5
- package/.eslintignore +0 -5
- package/.eslintrc.yml +0 -9
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.lintstagedrc.yml +0 -9
- package/.mocharc.yml +0 -3
- package/.nvmrc +0 -1
- package/.nycrc.yml +0 -4
- package/.prettierrc +0 -1
- package/.releaserc.yml +0 -1
- package/SECURITY.md +0 -17
- package/handlers/RSS.js +0 -66
- package/handlers/Twitter.js +0 -169
- package/handlers/Worldstate.js +0 -154
- package/handlers/events/arrayLike.js +0 -27
- package/handlers/events/checkOverrides.js +0 -17
- package/handlers/events/cycleLike.js +0 -38
- package/handlers/events/eKeyOverrides.js +0 -40
- package/handlers/events/kuva.js +0 -31
- package/handlers/events/nightwave.js +0 -35
- package/handlers/events/objectLike.js +0 -17
- package/handlers/events/parse.js +0 -82
- package/index.js +0 -96
- package/nodemon.json +0 -9
- package/resources/config.js +0 -8
- package/resources/rssFeeds.json +0 -129
- package/resources/tweeters.json +0 -17
- package/utilities/Cache.js +0 -61
- package/utilities/WSCache.js +0 -96
- package/utilities/env.js +0 -10
- package/utilities/index.js +0 -79
package/README.md
CHANGED
|
@@ -5,93 +5,285 @@ Suuuper simple emitter for worldstate events.
|
|
|
5
5
|
Very opinionated decisions on what events and event names, as well as.... everything else
|
|
6
6
|
|
|
7
7
|
[](https://github.com/semantic-release/semantic-release)
|
|
8
|
+
[](https://www.npmjs.com/package/worldstate-emitter)
|
|
9
|
+
[](https://www.npmjs.com/package/worldstate-emitter)
|
|
10
|
+
[](https://www.typescriptlang.org/)
|
|
11
|
+
[](https://discord.gg/jGZxH9f)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install worldstate-emitter
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This package requires Node.js 20.10.0 or higher and is an ES Module.
|
|
20
|
+
|
|
21
|
+
### Peer Dependencies
|
|
22
|
+
|
|
23
|
+
You'll also need to install the following peer dependencies:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install warframe-worldstate-parser@^5 warframe-worldstate-data@^3
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Optional Dependencies
|
|
30
|
+
|
|
31
|
+
For better logging support:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install winston@^3
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### Basic Example
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import WorldstateEmitter from "worldstate-emitter";
|
|
43
|
+
|
|
44
|
+
// Create emitter instance
|
|
45
|
+
const emitter = await WorldstateEmitter.make({
|
|
46
|
+
locale: "en",
|
|
47
|
+
features: ["worldstate", "rss", "twitter"],
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Listen for worldstate events
|
|
51
|
+
emitter.on("ws:update:event", (event) => {
|
|
52
|
+
console.log("New worldstate event:", event.id);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Listen for RSS posts
|
|
56
|
+
emitter.on("rss", (post) => {
|
|
57
|
+
console.log("New forum post:", post.title);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Listen for tweets
|
|
61
|
+
emitter.on("tweet", (tweet) => {
|
|
62
|
+
console.log("New tweet:", tweet.text);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Get current worldstate
|
|
66
|
+
const worldstate = emitter.getWorldstate("en");
|
|
67
|
+
console.log("Current worldstate:", worldstate);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### TypeScript Support
|
|
71
|
+
|
|
72
|
+
This package is written in TypeScript and includes full type definitions. All types are automatically available when using TypeScript:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import WorldstateEmitter from "worldstate-emitter";
|
|
76
|
+
import type WorldState from "warframe-worldstate-parser";
|
|
77
|
+
|
|
78
|
+
const emitter = await WorldstateEmitter.make({ locale: "en" });
|
|
79
|
+
|
|
80
|
+
// TypeScript will infer the correct types
|
|
81
|
+
const ws: WorldState | undefined = emitter.getWorldstate("en");
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Configuration Options
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
interface WorldstateEmitterOptions {
|
|
88
|
+
locale?: string; // Language to filter events (e.g., 'en', 'es', 'de')
|
|
89
|
+
features?: string[]; // Features to enable: 'worldstate', 'rss', 'twitter'
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const emitter = await WorldstateEmitter.make({
|
|
93
|
+
locale: "en", // Optional: filter to English only
|
|
94
|
+
features: ["worldstate", "rss"], // Optional: only enable these features
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Environment Variables
|
|
99
|
+
|
|
100
|
+
Configure the emitter with environment variables:
|
|
101
|
+
|
|
102
|
+
- `LOG_LEVEL` - Logging level (default: `error`)
|
|
103
|
+
- `WORLDSTATE_URL` - Custom worldstate API URL
|
|
104
|
+
- `KUVA_URL` - Custom Kuva/Arbitration data URL
|
|
105
|
+
- `SENTIENT_URL` - Custom Sentient Anomaly data URL
|
|
106
|
+
- `WORLDSTATE_CRON` - Cron pattern for worldstate updates (default: `25 */5 * * * *`)
|
|
107
|
+
- `WS_EXTERNAL_CRON` - Cron pattern for external data (default: `0 */10 * * * *`)
|
|
108
|
+
- `WS_EMITTER_FEATURES` - Comma-separated list of features to enable
|
|
109
|
+
- `TWITTER_KEY` - Twitter API consumer key
|
|
110
|
+
- `TWITTER_SECRET` - Twitter API consumer secret
|
|
111
|
+
- `TWITTER_BEARER_TOKEN` - Twitter API bearer token
|
|
112
|
+
- `TWITTER_TIMEOUT` - Twitter update interval in ms (default: `60000`)
|
|
8
113
|
|
|
9
114
|
## Emitter Events
|
|
10
115
|
|
|
11
|
-
|
|
12
|
-
|:--------------|-------------|---------------------------------------------|
|
|
13
|
-
| RSS | `rss` | New forum post from DE |
|
|
14
|
-
| Worldstate | `ws:update` | New Worldstate event |
|
|
15
|
-
| Tweet | `tweet` | New tweet from one of the selected accounts |
|
|
116
|
+
### Main Events
|
|
16
117
|
|
|
118
|
+
| Emitter Event | Emit key | Description |
|
|
119
|
+
| :---------------- | ------------------ | ------------------------------------------- |
|
|
120
|
+
| RSS | `rss` | New forum post from DE |
|
|
121
|
+
| Raw Worldstate | `ws:update:raw` | Raw worldstate data updated |
|
|
122
|
+
| Parsed Worldstate | `ws:update:parsed` | Parsed worldstate data available |
|
|
123
|
+
| Worldstate Event | `ws:update:event` | Individual worldstate event |
|
|
124
|
+
| Tweet | `tweet` | New tweet from one of the selected accounts |
|
|
125
|
+
|
|
126
|
+
### API Methods
|
|
127
|
+
|
|
128
|
+
| Method | Parameters | Returns | Description |
|
|
129
|
+
| :---------------- | :------------------ | :------------------------ | :---------------------------- |
|
|
130
|
+
| `getRss()` | - | `RssFeedItem[]` | Get current RSS feed items |
|
|
131
|
+
| `getWorldstate()` | `language?: string` | `WorldState \| undefined` | Get worldstate for a language |
|
|
132
|
+
| `getTwitter()` | - | `Promise<any>` | Get Twitter data |
|
|
133
|
+
| `debug` | - | `DebugInfo` | Get debug information |
|
|
134
|
+
|
|
135
|
+
**Parameters:**
|
|
136
|
+
|
|
137
|
+
- `language` - Defaults to `en`. Any locale from [`warframe-worldstate-data`](https://github.com/WFCD/warframe-worldstate-data)
|
|
17
138
|
|
|
18
139
|
<details>
|
|
19
140
|
<summary>Twitter Accounts</summary>
|
|
20
141
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
142
|
+
- [Warframe](https://twitter.com/playwarframe) (warframe)
|
|
143
|
+
- [Digital Extremes](https://twitter.com/digitalextremes) (digitalextremes)
|
|
144
|
+
- [[DE]Pablo](https://twitter.com/PabloPoon) (pablo)
|
|
145
|
+
- [Cameron Rogers](https://twitter.com/cam_rogers) (cameron)
|
|
146
|
+
- [[DE]Rebecca](https://twitter.com/rebbford) (rebecca)
|
|
147
|
+
- [[DE]Steve](https://twitter.com/sj_sinclair) (steve)
|
|
148
|
+
- [[DE]Danielle](https://twitter.com/soelloo) (danielle)
|
|
149
|
+
- [[DE]Megan](https://twitter.com/moitoi) (megan)
|
|
150
|
+
- [[DE]George](https://twitter.com/GameSoundDesign) (george)
|
|
151
|
+
- [[DE]Maciej](https://twitter.com/msinilo) (maciej)
|
|
152
|
+
- [[DE]Sheldon](https://twitter.com/sheldoncarter) (sheldon)
|
|
153
|
+
- [[DE]Marcus](https://twitter.com/narcbag) (narc)
|
|
154
|
+
- [[DE]Helen](https://twitter.com/helen_heikkila) (helen)
|
|
155
|
+
- [Tobiah (me)](https://twitter.com/tobitenno) (tobiah)
|
|
156
|
+
- [WF Discord](https://twitter.com/wfdiscord) (wfdiscord)
|
|
36
157
|
</details>
|
|
37
158
|
|
|
38
159
|
<br />
|
|
39
160
|
<details> <summary>Twitter Events</summary>
|
|
40
161
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
162
|
+
- `tweet`
|
|
163
|
+
- `retweet`
|
|
164
|
+
- `reply`
|
|
165
|
+
- `quote`
|
|
45
166
|
</details>
|
|
46
167
|
|
|
47
168
|
<br />
|
|
48
169
|
<details><summary>RSS Feeds</summary>
|
|
49
170
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
171
|
+
- [Players helping Players](https://forums.warframe.com/forum/38-players-helping-players)
|
|
172
|
+
- [PC Updates](https://forums.warframe.com/forum/3-pc-update-notes)
|
|
173
|
+
- [PC Announcements](https://forums.warframe.com/forum/2-pc-announcements)
|
|
174
|
+
- [PS4 Updates](https://forums.warframe.com/forum/152-ps4-update-notes)
|
|
175
|
+
- [PS4 Announcements](https://forums.warframe.com/forum/151-ps4-announcements)
|
|
176
|
+
- [XB1 Updates](https://forums.warframe.com/forum/253-xbox-one-update-notes)
|
|
177
|
+
- [XB1 Announcements](https://forums.warframe.com/forum/252-xbox-one-announcements)
|
|
178
|
+
- [Switch Updates](https://forums.warframe.com/forum/1196-nintendo-switch-update-notes)
|
|
179
|
+
- [Switch Announcements](https://forums.warframe.com/forum/1198-nintendo-switch-announcements)
|
|
180
|
+
- [News](https://forums.warframe.com/forum/170-announcements-events)
|
|
181
|
+
- [Developers Workshop](https://forums.warframe.com/forum/123-developer-workshop-update-notes)
|
|
182
|
+
|
|
62
183
|
<details><summary>Staff Replies</summary>
|
|
63
184
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
185
|
+
- [[DE]Rebecca](https://forums.warframe.com/discover/839)
|
|
186
|
+
- [[DE]Danielle](https://forums.warframe.com/discover/840)
|
|
187
|
+
- [[DE]Drew](https://forums.warframe.com/discover/841)
|
|
188
|
+
- [[DE]Glen](https://forums.warframe.com/discover/842)
|
|
189
|
+
- [[DE]Taylor](https://forums.warframe.com/discover/1171)
|
|
190
|
+
- [[DE]Steve](https://forums.warframe.com/discover/1777)
|
|
191
|
+
- [[DE]Helen](https://forums.warframe.com/discover/1291)
|
|
192
|
+
- [[DE]Saske](https://forums.warframe.com/discover/1294)
|
|
193
|
+
- [[DE]Kaz](https://forums.warframe.com/discover/1295)
|
|
194
|
+
- [[DE]Pablo](https://forums.warframe.com/discover/1299)
|
|
195
|
+
- [[DE]Connor](https://forums.warframe.com/discover/1778)
|
|
196
|
+
- [[DE]Marcus](https://forums.warframe.com/discover/1779)
|
|
197
|
+
- [[DE]George](https://forums.warframe.com/discover/1780)
|
|
198
|
+
- [[DE]Bear](https://forums.warframe.com/discover/1781)
|
|
78
199
|
</details>
|
|
79
200
|
</details>
|
|
80
201
|
|
|
81
202
|
<br />
|
|
82
|
-
<details><summary>Other Methods</summary>
|
|
83
203
|
|
|
84
|
-
|
|
85
|
-
:-- | -- | --
|
|
86
|
-
`getRss` | -- | Map of RSS feeds with `url` and `items`
|
|
87
|
-
`getWorldstate` | `platform`, `locale` | Worldstate objects
|
|
88
|
-
-- | `platform` | Defaults to `pc`. One of `pc`, `ps4`, `xb1`, `swi`.
|
|
89
|
-
-- | `locale` | Defaults to `en`. Any of the locales included in [`worldstate-data`](https://github.com/WFCD/warframe-worldstate-data)
|
|
204
|
+
## Development
|
|
90
205
|
|
|
91
|
-
|
|
206
|
+
### Building
|
|
92
207
|
|
|
93
|
-
|
|
94
|
-
|
|
208
|
+
This project is written in TypeScript and uses `tsdown` for building:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
npm run build
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
This generates:
|
|
215
|
+
|
|
216
|
+
- `dist/index.mjs` - Compiled JavaScript module
|
|
217
|
+
- `dist/index.d.mts` - TypeScript type definitions
|
|
218
|
+
|
|
219
|
+
### Testing
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
npm test
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Tests use Mocha with `tsx` for TypeScript support.
|
|
226
|
+
|
|
227
|
+
### Linting
|
|
228
|
+
|
|
229
|
+
This project uses Biome for linting and formatting:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
npm run lint # Check for issues
|
|
233
|
+
npm run lint:fix # Auto-fix issues
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Documentation
|
|
237
|
+
|
|
238
|
+
Generate TypeDoc documentation:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
npm run build:docs
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Project Structure
|
|
245
|
+
|
|
246
|
+
```haskell
|
|
247
|
+
worldstate-emitter/
|
|
248
|
+
├── handlers/ # Event handlers
|
|
249
|
+
│ ├── events/ # Event processors
|
|
250
|
+
│ ├── RSS.ts # RSS feed handler
|
|
251
|
+
│ ├── Twitter.ts # Twitter API handler
|
|
252
|
+
│ └── Worldstate.ts # Worldstate handler
|
|
253
|
+
├── utilities/ # Utility classes and functions
|
|
254
|
+
│ ├── Cache.ts # Cron-based cache
|
|
255
|
+
│ ├── WSCache.ts # Worldstate cache wrapper
|
|
256
|
+
│ ├── env.ts # Environment configuration
|
|
257
|
+
│ └── index.ts # Shared utilities
|
|
258
|
+
├── resources/ # Configuration files
|
|
259
|
+
│ ├── config.ts # URL and cron patterns
|
|
260
|
+
│ ├── rssFeeds.json # RSS feed definitions
|
|
261
|
+
│ └── tweeters.json # Twitter accounts to watch
|
|
262
|
+
├── types/ # TypeScript type definitions
|
|
263
|
+
├── test/ # Test files
|
|
264
|
+
└── dist/ # Build output (generated)
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Contributing
|
|
268
|
+
|
|
269
|
+
This project uses:
|
|
270
|
+
|
|
271
|
+
- **TypeScript** with strict mode
|
|
272
|
+
- **Biome** for linting and formatting
|
|
273
|
+
- **Conventional Commits** for commit messages
|
|
274
|
+
- **Semantic Release** for automated versioning
|
|
275
|
+
|
|
276
|
+
Before submitting a PR:
|
|
277
|
+
|
|
278
|
+
1. Run `npm run lint:fix` to format code
|
|
279
|
+
2. Run `npm test` to ensure tests pass
|
|
280
|
+
3. Run `npm run build` to verify the build
|
|
281
|
+
4. Use conventional commit messages
|
|
282
|
+
|
|
283
|
+
## License
|
|
284
|
+
|
|
285
|
+
Apache-2.0
|
|
95
286
|
|
|
96
287
|
## Help & Contact
|
|
288
|
+
|
|
97
289
|
[](https://discord.gg/jGZxH9f)
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import EventEmitter from "node:events";
|
|
2
|
+
import { RSSItem } from "rss-feed-emitter";
|
|
3
|
+
import WorldState from "warframe-worldstate-parser";
|
|
4
|
+
|
|
5
|
+
//#region index.d.ts
|
|
6
|
+
interface WorldstateEmitterOptions {
|
|
7
|
+
locale?: string;
|
|
8
|
+
features?: string[];
|
|
9
|
+
}
|
|
10
|
+
interface RssFeedItem {
|
|
11
|
+
url: string;
|
|
12
|
+
items: RSSItem[];
|
|
13
|
+
}
|
|
14
|
+
interface DebugInfo {
|
|
15
|
+
rss?: RssFeedItem[];
|
|
16
|
+
worldstate?: WorldState;
|
|
17
|
+
twitter?: unknown;
|
|
18
|
+
}
|
|
19
|
+
declare class WorldstateEmitter extends EventEmitter {
|
|
20
|
+
#private;
|
|
21
|
+
static make({
|
|
22
|
+
locale,
|
|
23
|
+
features
|
|
24
|
+
}?: WorldstateEmitterOptions): Promise<WorldstateEmitter>;
|
|
25
|
+
/**
|
|
26
|
+
* Pull in and instantiate emitters
|
|
27
|
+
* @param options - Configuration options
|
|
28
|
+
*/
|
|
29
|
+
constructor({
|
|
30
|
+
locale
|
|
31
|
+
}?: WorldstateEmitterOptions);
|
|
32
|
+
/**
|
|
33
|
+
* Set up internal logging
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
private setupLogging;
|
|
37
|
+
/**
|
|
38
|
+
* Get current rss feed items
|
|
39
|
+
* @returns RSS feed items
|
|
40
|
+
*/
|
|
41
|
+
getRss(): RssFeedItem[] | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Get a specific worldstate, defaulting to 'pc' for the platform and 'en' for the language
|
|
44
|
+
* @param language - locale/language to fetch
|
|
45
|
+
* @returns Requested worldstate
|
|
46
|
+
*/
|
|
47
|
+
getWorldstate(language?: string): WorldState | undefined;
|
|
48
|
+
get debug(): DebugInfo;
|
|
49
|
+
/**
|
|
50
|
+
* Get Twitter data
|
|
51
|
+
* @returns Promised twitter data
|
|
52
|
+
*/
|
|
53
|
+
getTwitter(): Promise<unknown>;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { WorldstateEmitter as default };
|