@xiboplayer/settings 0.6.2 → 0.6.4
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 +112 -14
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
# @xiboplayer/settings
|
|
2
2
|
|
|
3
|
-
**CMS display settings management for Xibo
|
|
3
|
+
**CMS display settings management for Xibo players.**
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Parses and applies display configuration received from the CMS RegisterDisplay response:
|
|
8
8
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
9
|
+
- **Collection interval** -- how often to poll the CMS (60s-86400s, default 300s)
|
|
10
|
+
- **Display info** -- name, resolution (sizeX/sizeY)
|
|
11
|
+
- **Stats config** -- enable/disable, aggregation mode (Individual/Aggregate)
|
|
12
|
+
- **Log level** -- remote log verbosity (error, audit, info, debug)
|
|
13
|
+
- **XMR config** -- WebSocket address and CMS key for real-time commands
|
|
14
|
+
- **Download windows** -- time-of-day restrictions with overnight crossing support
|
|
15
|
+
- **Screenshot config** -- interval and quality settings
|
|
16
|
+
- **Event-driven** -- emits `interval-changed` and `settings-applied` on updates
|
|
17
|
+
|
|
18
|
+
## Architecture
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
CMS RegisterDisplay response
|
|
22
|
+
|
|
|
23
|
+
v
|
|
24
|
+
DisplaySettings.applySettings(raw)
|
|
25
|
+
+- Parse all settings (handles both camelCase and PascalCase)
|
|
26
|
+
+- Validate and normalize values
|
|
27
|
+
+- Detect changes (collectInterval)
|
|
28
|
+
+- Emit events
|
|
29
|
+
|
|
|
30
|
+
v
|
|
31
|
+
Platform Layer listens to events
|
|
32
|
+
+- 'interval-changed' -> update collection timer
|
|
33
|
+
+- 'settings-applied' -> update UI, screenshot config, etc.
|
|
34
|
+
```
|
|
15
35
|
|
|
16
36
|
## Installation
|
|
17
37
|
|
|
@@ -22,18 +42,96 @@ npm install @xiboplayer/settings
|
|
|
22
42
|
## Usage
|
|
23
43
|
|
|
24
44
|
```javascript
|
|
25
|
-
import {
|
|
45
|
+
import { DisplaySettings } from '@xiboplayer/settings';
|
|
46
|
+
|
|
47
|
+
const settings = new DisplaySettings();
|
|
48
|
+
|
|
49
|
+
// Apply settings from CMS (RegisterDisplay response)
|
|
50
|
+
const { changed, settings: applied } = settings.applySettings(regResult.settings);
|
|
51
|
+
console.log('Changed:', changed); // e.g., ['collectInterval']
|
|
26
52
|
|
|
27
|
-
|
|
28
|
-
settings.
|
|
53
|
+
// Read settings
|
|
54
|
+
const interval = settings.getCollectInterval(); // 300 (seconds)
|
|
55
|
+
const displayName = settings.getDisplayName(); // 'Lobby Display'
|
|
56
|
+
const { width, height } = settings.getDisplaySize(); // { width: 1920, height: 1080 }
|
|
57
|
+
const statsOn = settings.isStatsEnabled(); // true/false
|
|
29
58
|
|
|
30
|
-
|
|
31
|
-
|
|
59
|
+
// Check download window
|
|
60
|
+
if (settings.isInDownloadWindow()) {
|
|
61
|
+
startDownloads();
|
|
62
|
+
} else {
|
|
63
|
+
const next = settings.getNextDownloadWindow();
|
|
64
|
+
console.log(`Downloads paused, next window at ${next}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Check screenshot timing
|
|
68
|
+
if (settings.shouldTakeScreenshot(lastScreenshotDate)) {
|
|
69
|
+
captureScreenshot();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Listen for changes
|
|
73
|
+
settings.on('interval-changed', (newInterval) => {
|
|
74
|
+
updateCollectionTimer(newInterval);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
settings.on('settings-applied', (allSettings, changedKeys) => {
|
|
78
|
+
console.log('Settings updated:', changedKeys);
|
|
79
|
+
});
|
|
32
80
|
```
|
|
33
81
|
|
|
82
|
+
## Settings
|
|
83
|
+
|
|
84
|
+
| Key | Type | Default | Description |
|
|
85
|
+
|-----|------|---------|-------------|
|
|
86
|
+
| `collectInterval` | number | 300 | CMS polling interval (seconds, min 60, max 86400) |
|
|
87
|
+
| `displayName` | string | 'Unknown Display' | Human-readable display name |
|
|
88
|
+
| `sizeX` / `sizeY` | number | 1920 / 1080 | Display resolution |
|
|
89
|
+
| `statsEnabled` | boolean | false | Enable proof-of-play tracking |
|
|
90
|
+
| `aggregationLevel` | string | 'Individual' | Stats mode: 'Individual' or 'Aggregate' |
|
|
91
|
+
| `logLevel` | string | 'error' | Remote log level |
|
|
92
|
+
| `xmrNetworkAddress` | string | null | XMR network address |
|
|
93
|
+
| `xmrWebSocketAddress` | string | null | XMR WebSocket URL |
|
|
94
|
+
| `xmrCmsKey` | string | null | XMR authentication key |
|
|
95
|
+
| `preventSleep` | boolean | true | Keep screen awake |
|
|
96
|
+
| `screenshotInterval` | number | 120 | Seconds between screenshots |
|
|
97
|
+
| `downloadStartWindow` | string | null | Download window start (HH:MM) |
|
|
98
|
+
| `downloadEndWindow` | string | null | Download window end (HH:MM) |
|
|
99
|
+
|
|
100
|
+
## API Reference
|
|
101
|
+
|
|
102
|
+
### Constructor
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
new DisplaySettings()
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Extends EventEmitter -- supports `on()`, `off()`, `emit()`.
|
|
109
|
+
|
|
110
|
+
### Methods
|
|
111
|
+
|
|
112
|
+
| Method | Returns | Description |
|
|
113
|
+
|--------|---------|-------------|
|
|
114
|
+
| `applySettings(raw)` | `{ changed, settings }` | Parse and apply CMS settings |
|
|
115
|
+
| `getCollectInterval()` | `number` | Collection interval in seconds |
|
|
116
|
+
| `getDisplayName()` | `string` | Display name |
|
|
117
|
+
| `getDisplaySize()` | `{ width, height }` | Display resolution |
|
|
118
|
+
| `isStatsEnabled()` | `boolean` | Stats enabled flag |
|
|
119
|
+
| `getAllSettings()` | `Object` | All settings (copy) |
|
|
120
|
+
| `getSetting(key, default?)` | `any` | Get specific setting |
|
|
121
|
+
| `isInDownloadWindow()` | `boolean` | Check if downloads are allowed now |
|
|
122
|
+
| `getNextDownloadWindow()` | `Date \| null` | Next download window start |
|
|
123
|
+
| `shouldTakeScreenshot(last)` | `boolean` | Check if screenshot interval elapsed |
|
|
124
|
+
|
|
125
|
+
### Events
|
|
126
|
+
|
|
127
|
+
| Event | Payload | Description |
|
|
128
|
+
|-------|---------|-------------|
|
|
129
|
+
| `interval-changed` | `(seconds)` | Collection interval changed |
|
|
130
|
+
| `settings-applied` | `(settings, changedKeys)` | Settings applied from CMS |
|
|
131
|
+
|
|
34
132
|
## Dependencies
|
|
35
133
|
|
|
36
|
-
- `@xiboplayer/utils`
|
|
134
|
+
- `@xiboplayer/utils` -- EventEmitter, logger
|
|
37
135
|
|
|
38
136
|
---
|
|
39
137
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiboplayer/settings",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "CMS settings management and application for Xibo Player",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"./manager": "./src/settings.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xiboplayer/utils": "0.6.
|
|
13
|
+
"@xiboplayer/utils": "0.6.4"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"jsdom": "^25.0.1",
|