@xiboplayer/settings 0.2.0 → 0.3.1
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 +19 -272
- package/package.json +2 -2
- package/src/index.js +2 -0
package/README.md
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
# @xiboplayer/settings
|
|
2
2
|
|
|
3
|
-
CMS display settings management
|
|
3
|
+
**CMS display settings management for Xibo Player.**
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
7
|
+
Manages display configuration received from the CMS:
|
|
8
|
+
|
|
9
|
+
- **Resolution** — screen dimensions and orientation
|
|
10
|
+
- **Collection interval** — how often to poll the CMS
|
|
11
|
+
- **Download windows** — time-of-day restrictions for media downloads
|
|
12
|
+
- **Screenshot config** — screenshot dimensions, quality, and interval
|
|
13
|
+
- **Log level** — remote log verbosity control
|
|
14
|
+
- **Stats config** — proof of play aggregation mode and submission interval
|
|
14
15
|
|
|
15
16
|
## Installation
|
|
16
17
|
|
|
@@ -20,274 +21,20 @@ npm install @xiboplayer/settings
|
|
|
20
21
|
|
|
21
22
|
## Usage
|
|
22
23
|
|
|
23
|
-
### Basic Usage
|
|
24
|
-
|
|
25
24
|
```javascript
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
const displaySettings = new DisplaySettings();
|
|
29
|
-
|
|
30
|
-
// Apply settings from RegisterDisplay response
|
|
31
|
-
const result = displaySettings.applySettings(cmsSettings);
|
|
32
|
-
|
|
33
|
-
console.log('Changed settings:', result.changed);
|
|
34
|
-
console.log('Collection interval:', result.settings.collectInterval);
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### With PlayerCore
|
|
38
|
-
|
|
39
|
-
```javascript
|
|
40
|
-
import { PlayerCore } from '@xiboplayer/core';
|
|
41
|
-
import { DisplaySettings } from '@xiboplayer/settings';
|
|
42
|
-
|
|
43
|
-
const displaySettings = new DisplaySettings();
|
|
44
|
-
|
|
45
|
-
const core = new PlayerCore({
|
|
46
|
-
config,
|
|
47
|
-
xmds,
|
|
48
|
-
cache,
|
|
49
|
-
schedule,
|
|
50
|
-
renderer,
|
|
51
|
-
xmrWrapper,
|
|
52
|
-
displaySettings // Inject DisplaySettings
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Settings are automatically applied after RegisterDisplay
|
|
56
|
-
await core.collect();
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Event Handling
|
|
60
|
-
|
|
61
|
-
```javascript
|
|
62
|
-
// Listen for collection interval changes
|
|
63
|
-
displaySettings.on('interval-changed', (newInterval) => {
|
|
64
|
-
console.log(`Collection interval changed to ${newInterval}s`);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// Listen for any settings changes
|
|
68
|
-
displaySettings.on('settings-applied', (settings, changes) => {
|
|
69
|
-
console.log('Settings updated:', changes.join(', '));
|
|
70
|
-
});
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## API Reference
|
|
74
|
-
|
|
75
|
-
### Constructor
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
const displaySettings = new DisplaySettings();
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Methods
|
|
82
|
-
|
|
83
|
-
#### `applySettings(settings)`
|
|
25
|
+
import { SettingsManager } from '@xiboplayer/settings';
|
|
84
26
|
|
|
85
|
-
|
|
27
|
+
const settings = new SettingsManager();
|
|
28
|
+
settings.apply(cmsSettings);
|
|
86
29
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
**Returns:**
|
|
91
|
-
- Object with `changed` (array) and `settings` (object)
|
|
92
|
-
|
|
93
|
-
**Example:**
|
|
94
|
-
```javascript
|
|
95
|
-
const result = displaySettings.applySettings({
|
|
96
|
-
collectInterval: 600,
|
|
97
|
-
displayName: 'Main Display',
|
|
98
|
-
statsEnabled: '1',
|
|
99
|
-
xmrWebSocketAddress: 'ws://xmr.example.com:9505'
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
console.log(result.changed); // ['collectInterval']
|
|
103
|
-
console.log(result.settings.collectInterval); // 600
|
|
30
|
+
const interval = settings.get('collectInterval');
|
|
31
|
+
const screenshotEnabled = settings.get('screenshotRequested');
|
|
104
32
|
```
|
|
105
33
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
Get current collection interval in seconds.
|
|
109
|
-
|
|
110
|
-
**Returns:** Number (seconds)
|
|
111
|
-
|
|
112
|
-
#### `getDisplayName()`
|
|
113
|
-
|
|
114
|
-
Get display name from CMS.
|
|
115
|
-
|
|
116
|
-
**Returns:** String
|
|
117
|
-
|
|
118
|
-
#### `getDisplaySize()`
|
|
119
|
-
|
|
120
|
-
Get display dimensions.
|
|
121
|
-
|
|
122
|
-
**Returns:** Object `{ width: number, height: number }`
|
|
123
|
-
|
|
124
|
-
#### `isStatsEnabled()`
|
|
125
|
-
|
|
126
|
-
Check if stats/proof of play is enabled.
|
|
127
|
-
|
|
128
|
-
**Returns:** Boolean
|
|
129
|
-
|
|
130
|
-
#### `getAllSettings()`
|
|
131
|
-
|
|
132
|
-
Get all current settings as an object.
|
|
133
|
-
|
|
134
|
-
**Returns:** Object
|
|
135
|
-
|
|
136
|
-
#### `getSetting(key, defaultValue)`
|
|
137
|
-
|
|
138
|
-
Get a specific setting by key.
|
|
139
|
-
|
|
140
|
-
**Parameters:**
|
|
141
|
-
- `key` (String): Setting key
|
|
142
|
-
- `defaultValue` (Any): Default if not set
|
|
143
|
-
|
|
144
|
-
**Returns:** Setting value or default
|
|
145
|
-
|
|
146
|
-
#### `isInDownloadWindow()`
|
|
147
|
-
|
|
148
|
-
Check if current time is within the download window.
|
|
149
|
-
|
|
150
|
-
**Returns:** Boolean
|
|
151
|
-
|
|
152
|
-
**Example:**
|
|
153
|
-
```javascript
|
|
154
|
-
// Configure download window 09:00-17:00
|
|
155
|
-
displaySettings.applySettings({
|
|
156
|
-
downloadStartWindow: '09:00',
|
|
157
|
-
downloadEndWindow: '17:00'
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
// Check if downloads are allowed now
|
|
161
|
-
if (displaySettings.isInDownloadWindow()) {
|
|
162
|
-
await downloadFiles();
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
#### `getNextDownloadWindow()`
|
|
167
|
-
|
|
168
|
-
Get the next download window start time.
|
|
169
|
-
|
|
170
|
-
**Returns:** Date object or null
|
|
171
|
-
|
|
172
|
-
#### `shouldTakeScreenshot(lastScreenshot)`
|
|
173
|
-
|
|
174
|
-
Check if screenshot interval has elapsed.
|
|
175
|
-
|
|
176
|
-
**Parameters:**
|
|
177
|
-
- `lastScreenshot` (Date): Last screenshot timestamp
|
|
178
|
-
|
|
179
|
-
**Returns:** Boolean
|
|
180
|
-
|
|
181
|
-
## Supported Settings
|
|
182
|
-
|
|
183
|
-
### Collection
|
|
184
|
-
- `collectInterval` - Collection interval in seconds (60-86400, default: 300)
|
|
185
|
-
|
|
186
|
-
### Display Info
|
|
187
|
-
- `displayName` - Display name (default: 'Unknown Display')
|
|
188
|
-
- `sizeX` - Display width in pixels (default: 1920)
|
|
189
|
-
- `sizeY` - Display height in pixels (default: 1080)
|
|
190
|
-
|
|
191
|
-
### Stats/Logging
|
|
192
|
-
- `statsEnabled` - Enable proof of play ('1' or '0')
|
|
193
|
-
- `aggregationLevel` - Stats aggregation ('Individual' or 'Aggregate')
|
|
194
|
-
- `logLevel` - Log level ('error', 'audit', 'info', 'debug')
|
|
195
|
-
|
|
196
|
-
### XMR
|
|
197
|
-
- `xmrNetworkAddress` - XMR TCP address (e.g., 'tcp://xmr.example.com:9505')
|
|
198
|
-
- `xmrWebSocketAddress` - XMR WebSocket address (e.g., 'ws://xmr.example.com:9505')
|
|
199
|
-
- `xmrCmsKey` - XMR encryption key
|
|
200
|
-
|
|
201
|
-
### Features
|
|
202
|
-
- `preventSleep` - Prevent display sleep (boolean, default: true)
|
|
203
|
-
- `embeddedServerPort` - Embedded server port (default: 9696)
|
|
204
|
-
- `screenshotInterval` - Screenshot interval in seconds (default: 120)
|
|
205
|
-
|
|
206
|
-
### Download Windows
|
|
207
|
-
- `downloadStartWindow` - Download start time ('HH:MM')
|
|
208
|
-
- `downloadEndWindow` - Download end time ('HH:MM')
|
|
209
|
-
|
|
210
|
-
### Other
|
|
211
|
-
- `licenceCode` - Commercial license code
|
|
212
|
-
- `isSspEnabled` - Enable SSP ad space (boolean)
|
|
213
|
-
|
|
214
|
-
## Setting Name Formats
|
|
215
|
-
|
|
216
|
-
Supports both lowercase and CamelCase (uppercase first letter):
|
|
217
|
-
|
|
218
|
-
```javascript
|
|
219
|
-
// Both formats work
|
|
220
|
-
displaySettings.applySettings({
|
|
221
|
-
collectInterval: 600, // lowercase
|
|
222
|
-
CollectInterval: 600 // CamelCase
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
displaySettings.applySettings({
|
|
226
|
-
displayName: 'Test', // lowercase
|
|
227
|
-
DisplayName: 'Test' // CamelCase
|
|
228
|
-
});
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
## Download Windows
|
|
232
|
-
|
|
233
|
-
### Same-Day Window
|
|
234
|
-
|
|
235
|
-
```javascript
|
|
236
|
-
displaySettings.applySettings({
|
|
237
|
-
downloadStartWindow: '09:00',
|
|
238
|
-
downloadEndWindow: '17:00'
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
// Downloads allowed 09:00-17:00
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
### Overnight Window
|
|
245
|
-
|
|
246
|
-
```javascript
|
|
247
|
-
displaySettings.applySettings({
|
|
248
|
-
downloadStartWindow: '22:00',
|
|
249
|
-
downloadEndWindow: '06:00'
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
// Downloads allowed 22:00-23:59 and 00:00-06:00
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
## Events
|
|
256
|
-
|
|
257
|
-
### `interval-changed`
|
|
258
|
-
|
|
259
|
-
Emitted when collection interval changes.
|
|
260
|
-
|
|
261
|
-
**Callback:** `(newInterval: number) => void`
|
|
262
|
-
|
|
263
|
-
### `settings-applied`
|
|
264
|
-
|
|
265
|
-
Emitted when settings are applied.
|
|
266
|
-
|
|
267
|
-
**Callback:** `(settings: Object, changes: Array<string>) => void`
|
|
268
|
-
|
|
269
|
-
## Testing
|
|
270
|
-
|
|
271
|
-
```bash
|
|
272
|
-
npm test
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
The test suite includes:
|
|
276
|
-
- 44 comprehensive test cases
|
|
277
|
-
- Constructor defaults
|
|
278
|
-
- Setting parsing and validation
|
|
279
|
-
- Collection interval enforcement (60s-24h)
|
|
280
|
-
- Boolean parsing ('1', '0', true, false)
|
|
281
|
-
- Download window logic (same-day and overnight)
|
|
282
|
-
- Screenshot interval tracking
|
|
283
|
-
- Edge cases and error handling
|
|
284
|
-
|
|
285
|
-
## Integration with Upstream
|
|
34
|
+
## Dependencies
|
|
286
35
|
|
|
287
|
-
|
|
288
|
-
- `/upstream_players/electron-player/src/main/config/config.ts`
|
|
289
|
-
- `/upstream_players/electron-player/src/main/xmds/response/registerDisplay.ts`
|
|
36
|
+
- `@xiboplayer/utils` — logger, events
|
|
290
37
|
|
|
291
|
-
|
|
38
|
+
---
|
|
292
39
|
|
|
293
|
-
|
|
40
|
+
**Part of the [XiboPlayer SDK](https://github.com/xibo-players/xiboplayer)** | [MCP Server](https://github.com/xibo-players/xiboplayer/tree/main/mcp-server) for AI-assisted development
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiboplayer/settings",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "CMS settings management and application for Xibo Player",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"./manager": "./src/settings.js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@xiboplayer/utils": "0.
|
|
12
|
+
"@xiboplayer/utils": "0.3.1"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"jsdom": "^25.0.1",
|