playlist-data-engine 1.7.2 → 1.8.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.
Files changed (41) hide show
  1. package/README.md +20 -3
  2. package/bin/cli.cjs +85 -0
  3. package/dist/core/parser/TrackExtras.d.ts +150 -1
  4. package/dist/core/parser/TrackExtras.d.ts.map +1 -1
  5. package/dist/gateway-CDMPqFEH.js +1320 -0
  6. package/dist/gateway-DKa45Uz6.cjs +6 -0
  7. package/dist/gateway.d.ts +3 -1
  8. package/dist/gateway.d.ts.map +1 -1
  9. package/dist/gateway.js +1 -1
  10. package/dist/gateway.mjs +22 -14
  11. package/dist/index.d.ts +4 -3
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/playlist-data-engine.js +34 -34
  14. package/dist/playlist-data-engine.mjs +964 -1240
  15. package/dist/utils/engineDocs.d.ts +33 -0
  16. package/dist/utils/engineDocs.d.ts.map +1 -0
  17. package/dist/utils/playlistUtils.d.ts +37 -0
  18. package/dist/utils/playlistUtils.d.ts.map +1 -1
  19. package/dist/utils/validators.d.ts +27 -0
  20. package/dist/utils/validators.d.ts.map +1 -1
  21. package/docs/DATA_ENGINE_REFERENCE.md +6660 -0
  22. package/docs/USAGE_IN_OTHER_PROJECTS.md +587 -0
  23. package/docs/features/AUDIO_ANALYSIS.md +610 -0
  24. package/docs/features/BEAT_DETECTION.md +5250 -0
  25. package/docs/features/COMBAT_SYSTEM.md +1632 -0
  26. package/docs/features/CONTENT_PACKS.md +464 -0
  27. package/docs/features/CUSTOM_CONTENT.md +603 -0
  28. package/docs/features/ENEMY_GENERATION.md +1711 -0
  29. package/docs/features/EQUIPMENT_SYSTEM.md +2279 -0
  30. package/docs/features/EXTENSIBILITY_GUIDE.md +1106 -0
  31. package/docs/features/GATEWAY_RESOLUTION.md +725 -0
  32. package/docs/features/IRL_SENSORS.md +360 -0
  33. package/docs/features/PLAYLIST_PARSING.md +446 -0
  34. package/docs/features/PREREQUISITES.md +571 -0
  35. package/docs/features/ROLLS_AND_SEEDS.md +687 -0
  36. package/docs/features/XP_AND_STATS.md +1221 -0
  37. package/llms.txt +33 -0
  38. package/package.json +9 -2
  39. package/skills/playlist-data-engine/SKILL.md +69 -0
  40. package/dist/gateway-DUk4nCao.cjs +0 -1
  41. package/dist/gateway-DyR4M-uH.js +0 -681
@@ -0,0 +1,360 @@
1
+ # IRL Sensors Reference
2
+
3
+ Complete guide to the environmental and gaming sensors in the Playlist Data Engine.
4
+
5
+ **For API details, see [DATA_ENGINE_REFERENCE.md](../DATA_ENGINE_REFERENCE.md)**
6
+ **For other usage examples, see [USAGE_IN_OTHER_PROJECTS.md](../USAGE_IN_OTHER_PROJECTS.md)**
7
+
8
+ ---
9
+
10
+ ## Table of Contents
11
+
12
+ 1. [Environmental Sensors](#environmental-sensors)
13
+ 2. [Solar Information (No API Key Required)](#solar-information-no-api-key-required)
14
+ 3. [Gaming Sensors](#gaming-sensors)
15
+ 4. [Severe Weather Detection](#severe-weather-detection)
16
+ 5. [Sensor Dashboard](#sensor-dashboard)
17
+ 6. [Sensor Configuration](#sensor-configuration)
18
+
19
+ ---
20
+
21
+ ## Environmental Sensors
22
+
23
+
24
+ ```typescript
25
+ import { EnvironmentalSensors } from 'playlist-data-engine';
26
+
27
+ // Initialize sensors with weather API key
28
+ const sensors = new EnvironmentalSensors(process.env.WEATHER_API_KEY);
29
+
30
+ // Request permissions
31
+ const permissions = await sensors.requestPermissions(['geolocation', 'motion', 'weather']);
32
+ console.log(`Permissions granted:`, permissions);
33
+
34
+ // Get current environmental context
35
+ const context = await sensors.updateSnapshot();
36
+
37
+ // Calculate XP modifier based on environment
38
+ const xpModifier = sensors.calculateXPModifier();
39
+ console.log(`Environmental bonus: ${xpModifier.toFixed(2)}x`);
40
+ // Examples:
41
+ // - Running in rain: 1.5x
42
+ // - Stationary indoors: 1.0x
43
+ // - Walking at night: 1.25x
44
+ // - High altitude + snow: 1.4x
45
+ // - Hurricane conditions (tropical): 2.25x (severe weather bonus applied)
46
+ // - Typhoon conditions (temperate): 2.25x (severe weather bonus applied)
47
+ // - Blizzard conditions: 2.0x (severe weather bonus applied)
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Solar Information (No API Key Required)
53
+
54
+ The `getSolarInfo()` method provides astronomical calculations for sunrise, sunset, and day stage. **This method works without an API key** using pure astronomical math (NOAA algorithm).
55
+
56
+ ### Basic Usage
57
+
58
+ ```typescript
59
+ import { WeatherAPIClient } from 'playlist-data-engine';
60
+
61
+ // No API key needed for solar calculations!
62
+ const weatherClient = new WeatherAPIClient('');
63
+ const solarInfo = weatherClient.getSolarInfo(40.7128, -74.0060); // NYC coordinates
64
+
65
+ console.log(solarInfo.stage); // 'day', 'night', 'dawn', or 'dusk'
66
+ console.log(solarInfo.sunrise); // Date object
67
+ console.log(solarInfo.sunset); // Date object
68
+ console.log(solarInfo.solarNoon); // Solar noon time
69
+ console.log(solarInfo.dayLengthHours); // e.g., 14.5
70
+ console.log(solarInfo.sunAltitude); // Sun altitude in degrees
71
+ console.log(solarInfo.sunAzimuth); // Sun azimuth (0-360, North=0)
72
+ ```
73
+
74
+ ### Optional Date Parameter
75
+
76
+ You can also calculate solar info for a specific date:
77
+
78
+ ```typescript
79
+ // Get solar info for a specific date
80
+ const futureDate = new Date('2024-12-25');
81
+ const christmasSolar = weatherClient.getSolarInfo(40.7128, -74.0060, futureDate);
82
+ console.log(`Christmas day length: ${christmasSolar.dayLengthHours} hours`);
83
+ ```
84
+
85
+
86
+ ---
87
+
88
+ ## Gaming Platform Integration
89
+
90
+ ```typescript
91
+ import { GamingPlatformSensors } from 'playlist-data-engine';
92
+
93
+ // Initialize with Steam
94
+ const gamingSensors = new GamingPlatformSensors({
95
+ steam: {
96
+ apiKey: process.env.STEAM_API_KEY,
97
+ steamId: '123456789',
98
+ pollInterval: 60000 // Check every 60 seconds
99
+ }
100
+ });
101
+
102
+ // Start monitoring
103
+ gamingSensors.startMonitoring((context) => {
104
+ if (context.isActivelyGaming) {
105
+ const bonus = gamingSensors.calculateGamingBonus();
106
+ console.log(`Playing: ${context.currentGame?.name}, Bonus: ${bonus.toFixed(2)}x`);
107
+ // Examples:
108
+ // - Action game: 1.425x
109
+ // - RPG game: 1.55x
110
+ // - Multiplayer RPG: 1.8x
111
+ }
112
+ });
113
+
114
+ // Stop monitoring when done
115
+ gamingSensors.stopMonitoring();
116
+ ```
117
+
118
+ **Browser Compatibility Notes:**
119
+
120
+ - Steam game detection works in both browser AND server modes
121
+ - No configuration required - environment is detected automatically
122
+
123
+
124
+ ---
125
+
126
+ ## Severe Weather Detection
127
+
128
+ The EnvironmentalSensors can detect severe weather conditions that provide significant XP bonuses. These conditions are automatically detected based on current weather data and geographic location.
129
+
130
+ ### Severe Weather Types
131
+
132
+ **Hurricane vs. Typhoon Classification:**
133
+
134
+ The system correctly classifies tropical cyclones based on geographic location:
135
+ - **Hurricane**: Tropical cyclone detected in tropical regions (between 23.5°N and 23.5°S)
136
+ - **Typhoon**: Tropical cyclone detected outside tropical regions (temperate zones)
137
+
138
+ This classification is important for accurate weather terminology and XP bonus calculations.
139
+
140
+ **All Severe Weather Types:**
141
+
142
+ | Type | Condition | XP Bonus | Severity Levels |
143
+ |------|-----------|----------|-----------------|
144
+ | **Blizzard** | Heavy snow + high winds (>25 km/h) | +50% (0.5x) | moderate, high, extreme |
145
+ | **Hurricane** | Extreme winds (>118 km/h) in tropics | +75% (0.75x) | moderate, high, extreme |
146
+ | **Typhoon** | Extreme winds (>118 km/h) in temperate | +75% (0.75x) | moderate, high, extreme |
147
+ | **Tornado** | Tornado weather type detected | +100% (1.0x) | extreme |
148
+
149
+ **Tropical Region Definition:**
150
+
151
+ Tropical regions are defined as locations between the Tropic of Cancer (23.5°N) and the Tropic of Capricorn (23.5°S). This is where hurricanes typically form and occur.
152
+
153
+ ```typescript
154
+ // Geographic boundaries
155
+ // Northern Hemisphere:
156
+ // - Tropical: 0° to 23.5°N (e.g., Singapore, Miami, Caribbean)
157
+ // - Temperate: >23.5°N (e.g., Tokyo, New York, Southern Europe)
158
+
159
+ // Southern Hemisphere:
160
+ // - Tropical: 0° to 23.5°S (e.g., Rio de Janeiro, Northern Australia)
161
+ // - Temperate: >23.5°S (e.g., Sydney, Southern Australia)
162
+ ```
163
+
164
+ ### Usage Example
165
+
166
+ ```typescript
167
+ import { EnvironmentalSensors } from 'playlist-data-engine';
168
+
169
+ const sensors = new EnvironmentalSensors(process.env.WEATHER_API_KEY);
170
+
171
+ // Detect severe weather from current conditions
172
+ const alert = await sensors.detectSevereWeather();
173
+
174
+ if (alert) {
175
+ console.log(`🌀 ${alert.type} detected!`);
176
+ console.log(`XP Bonus: +${alert.xpBonus * 100}%`);
177
+ console.log(`Severity: ${alert.severity}`);
178
+ console.log(`Message: ${alert.message}`);
179
+
180
+ // Get safety warning
181
+ const warning = sensors.getSevereWeatherWarning();
182
+ console.log(`Safety: ${warning}`);
183
+ }
184
+
185
+ // Calculate XP modifier with severe weather
186
+ const result = await sensors.calculateXPModifierWithSevereWeather();
187
+ console.log(`Total XP modifier: ${result.modifier.toFixed(2)}x`);
188
+ if (result.severeWeatherAlert) {
189
+ console.log(`Severe weather active: ${result.severeWeatherAlert.type}`);
190
+ }
191
+ ```
192
+
193
+ ### Geographic Examples
194
+
195
+ ```typescript
196
+ // Location-specific examples:
197
+
198
+ // Singapore (1.35°N) - Tropical
199
+ // → Hurricane detection (if wind >118 km/h)
200
+ // → XP Bonus: +75%
201
+
202
+ // Tokyo (35.68°N) - Temperate
203
+ // → Typhoon detection (if wind >118 km/h)
204
+ // → XP Bonus: +75%
205
+
206
+ // Sydney (-33.87°S) - Temperate
207
+ // → Typhoon detection (if wind >118 km/h)
208
+ // → XP Bonus: +75%
209
+
210
+ // Rio de Janeiro (-22.91°S) - Tropical
211
+ // → Hurricane detection (if wind >118 km/h)
212
+ // → XP Bonus: +75%
213
+
214
+ // Boundary Cases:
215
+ // - 23.5°N exactly: Typhoon (temperate)
216
+ // - 23.49°N: Hurricane (tropical)
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Sensor Dashboard
222
+
223
+ The Sensor Dashboard provides formatted console output for sensor diagnostics during development and debugging. It displays sensor status, health indicators, cache statistics, performance metrics, and recent failures with optional ANSI color support (auto-disabled in non-TTY environments like CI).
224
+
225
+ ### Basic Usage
226
+
227
+ ```typescript
228
+ import { SensorDashboard, EnvironmentalSensors, GamingPlatformSensors } from 'playlist-data-engine';
229
+
230
+ // Initialize sensors
231
+ const sensors = new EnvironmentalSensors(process.env.WEATHER_API_KEY);
232
+ const gamingSensors = new GamingPlatformSensors({
233
+ steamApiKey: process.env.STEAM_API_KEY
234
+ });
235
+
236
+ // Get sensor data
237
+ const envDiagnostics = sensors.getDiagnostics();
238
+ const gamingDiagnostics = gamingSensors.getDiagnostics();
239
+
240
+ // Display individual dashboards
241
+ SensorDashboard.displayEnvironmentalDiagnostics(envDiagnostics);
242
+ SensorDashboard.displayGamingDiagnostics(gamingDiagnostics);
243
+
244
+ // Display combined system dashboard
245
+ SensorDashboard.displaySystemDashboard({
246
+ environmental: envDiagnostics,
247
+ gaming: gamingDiagnostics
248
+ });
249
+ ```
250
+
251
+ ### Custom Configuration
252
+
253
+ ```typescript
254
+ import { SensorDashboard, type DashboardConfig } from 'playlist-data-engine';
255
+
256
+ const config: DashboardConfig = {
257
+ useColors: false, // Disable colors (for CI/logs)
258
+ compact: true, // Compact output mode
259
+ showTimestamp: false, // Hide timestamp
260
+ maxFailures: 10 // Show up to 10 recent failures
261
+ };
262
+
263
+ SensorDashboard.displayEnvironmentalDiagnostics(diagnostics, config);
264
+ ```
265
+
266
+ ### Dashboard Sections
267
+
268
+ **Environmental Diagnostics:**
269
+ - Sensor Status - Health, permissions, availability, consecutive failures, last error
270
+ - Cache Statistics - Geolocation age/expiry, weather cache size, hit rates
271
+ - API Performance - Weather/Forecast API calls, success rate, timing metrics (P95/P99)
272
+ - Recent Failures - Error messages with retry status and time ago
273
+ - Context Data - Available context types (geolocation, motion, weather, light, biome)
274
+
275
+ **Gaming Diagnostics:**
276
+ - Platform Status - Steam authentication/API key
277
+ - Gaming Context - Active gaming status, current game with session details
278
+ - Polling Status - Active status, interval, exponential backoff multiplier
279
+ - Cache - Game metadata cache size and cached games list
280
+ - API Performance - Current Game/Metadata API metrics
281
+
282
+ **Quick Health Summary (System Dashboard):**
283
+ - Overall environmental sensor health count
284
+ - Gaming platform connection status
285
+
286
+ ### Available Exports
287
+
288
+ - `SensorDashboard` - Object containing all dashboard display functions
289
+ - `displayEnvironmentalDiagnostics()` - Display environmental sensor dashboard
290
+ - `displayGamingDiagnostics()` - Display gaming platform sensor dashboard
291
+ - `displaySystemDashboard()` - Display combined system dashboard
292
+ - `DashboardConfig` type - Configuration options for dashboard output
293
+
294
+
295
+ ---
296
+
297
+ ## Sensor Configuration
298
+
299
+ Sensor configuration controls environmental and gaming platform sensor behavior, including caching, retry logic, and XP modifier calculations.
300
+
301
+ ```typescript
302
+ import {
303
+ DEFAULT_SENSOR_CONFIG,
304
+ loadConfigFromEnv,
305
+ mergeConfig,
306
+ type SensorConfig
307
+ } from 'playlist-data-engine';
308
+
309
+ // Use default configuration
310
+ const defaultConfig = DEFAULT_SENSOR_CONFIG;
311
+ console.log(defaultConfig.xpModifier.maxModifier); // 3.0
312
+
313
+ // Load configuration from environment variables
314
+ // Reads: WEATHER_API_KEY, STEAM_API_KEY, STEAM_USER_ID, XP_MAX_MODIFIER
315
+ const envConfig = loadConfigFromEnv();
316
+
317
+ // Merge custom configuration with defaults
318
+ const customConfig = mergeConfig({
319
+ weather: {
320
+ cacheTTL: 15 * 60 * 1000, // 15 minutes (default: 12 minutes)
321
+ apiKey: 'your_api_key_here'
322
+ },
323
+ xpModifier: {
324
+ maxModifier: 2.5, // Lower cap (default: 3.0)
325
+ runningBonus: 0.6, // Higher bonus for running (default: 0.5)
326
+ nightBonus: 0.3 // Higher night bonus (default: 0.25)
327
+ },
328
+ gaming: {
329
+ steam: {
330
+ pollInterval: 30000 // Poll every 30 seconds (default: 60000)
331
+ }
332
+ }
333
+ });
334
+
335
+ // Use configuration with EnvironmentalSensors
336
+ import { EnvironmentalSensors } from 'playlist-data-engine';
337
+
338
+ const sensors = new EnvironmentalSensors(customConfig);
339
+ ```
340
+
341
+ **Available Exports:**
342
+
343
+ **Sensor Configuration:**
344
+ - `DEFAULT_SENSOR_CONFIG` - Default sensor configuration values
345
+ - `loadConfigFromEnv()` - Load config from environment variables
346
+ - `mergeConfig(userConfig?)` - Merge user config with defaults and env vars
347
+ - `type SensorConfig` - Complete sensor configuration interface
348
+ - `type GeolocationSensorConfig` - GPS sensor configuration
349
+ - `type WeatherSensorConfig` - Weather API configuration
350
+ - `type GamingSensorConfig` - Gaming platform configuration
351
+ - `type XPModifierConfig` - XP modifier calculation settings
352
+ - `type RetryConfig` - Retry behavior configuration
353
+
354
+ ---
355
+
356
+ ## See Also
357
+
358
+ - [DATA_ENGINE_REFERENCE.md](../DATA_ENGINE_REFERENCE.md) - Complete API reference
359
+ - [USAGE_IN_OTHER_PROJECTS.md](../USAGE_IN_OTHER_PROJECTS.md) - Usage examples
360
+ - [XP_AND_STATS.md](XP_AND_STATS.md) - XP calculation with sensor modifiers