npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xiboplayer/settings

v0.2.0

Published

CMS settings management and application for Xibo Player

Readme

@xiboplayer/settings

CMS display settings management and application for Xibo players.

Features

  • Parse all settings from RegisterDisplay CMS response
  • Validate and normalize setting values
  • Dynamic collection interval updates
  • Download window enforcement (same-day and overnight windows)
  • Screenshot interval tracking
  • Event emission on setting changes
  • Comprehensive error handling

Installation

npm install @xiboplayer/settings

Usage

Basic Usage

import { DisplaySettings } from '@xiboplayer/settings';

const displaySettings = new DisplaySettings();

// Apply settings from RegisterDisplay response
const result = displaySettings.applySettings(cmsSettings);

console.log('Changed settings:', result.changed);
console.log('Collection interval:', result.settings.collectInterval);

With PlayerCore

import { PlayerCore } from '@xiboplayer/core';
import { DisplaySettings } from '@xiboplayer/settings';

const displaySettings = new DisplaySettings();

const core = new PlayerCore({
  config,
  xmds,
  cache,
  schedule,
  renderer,
  xmrWrapper,
  displaySettings // Inject DisplaySettings
});

// Settings are automatically applied after RegisterDisplay
await core.collect();

Event Handling

// Listen for collection interval changes
displaySettings.on('interval-changed', (newInterval) => {
  console.log(`Collection interval changed to ${newInterval}s`);
});

// Listen for any settings changes
displaySettings.on('settings-applied', (settings, changes) => {
  console.log('Settings updated:', changes.join(', '));
});

API Reference

Constructor

const displaySettings = new DisplaySettings();

Methods

applySettings(settings)

Apply CMS settings from RegisterDisplay response.

Parameters:

  • settings (Object): Raw settings from CMS

Returns:

  • Object with changed (array) and settings (object)

Example:

const result = displaySettings.applySettings({
  collectInterval: 600,
  displayName: 'Main Display',
  statsEnabled: '1',
  xmrWebSocketAddress: 'ws://xmr.example.com:9505'
});

console.log(result.changed); // ['collectInterval']
console.log(result.settings.collectInterval); // 600

getCollectInterval()

Get current collection interval in seconds.

Returns: Number (seconds)

getDisplayName()

Get display name from CMS.

Returns: String

getDisplaySize()

Get display dimensions.

Returns: Object { width: number, height: number }

isStatsEnabled()

Check if stats/proof of play is enabled.

Returns: Boolean

getAllSettings()

Get all current settings as an object.

Returns: Object

getSetting(key, defaultValue)

Get a specific setting by key.

Parameters:

  • key (String): Setting key
  • defaultValue (Any): Default if not set

Returns: Setting value or default

isInDownloadWindow()

Check if current time is within the download window.

Returns: Boolean

Example:

// Configure download window 09:00-17:00
displaySettings.applySettings({
  downloadStartWindow: '09:00',
  downloadEndWindow: '17:00'
});

// Check if downloads are allowed now
if (displaySettings.isInDownloadWindow()) {
  await downloadFiles();
}

getNextDownloadWindow()

Get the next download window start time.

Returns: Date object or null

shouldTakeScreenshot(lastScreenshot)

Check if screenshot interval has elapsed.

Parameters:

  • lastScreenshot (Date): Last screenshot timestamp

Returns: Boolean

Supported Settings

Collection

  • collectInterval - Collection interval in seconds (60-86400, default: 300)

Display Info

  • displayName - Display name (default: 'Unknown Display')
  • sizeX - Display width in pixels (default: 1920)
  • sizeY - Display height in pixels (default: 1080)

Stats/Logging

  • statsEnabled - Enable proof of play ('1' or '0')
  • aggregationLevel - Stats aggregation ('Individual' or 'Aggregate')
  • logLevel - Log level ('error', 'audit', 'info', 'debug')

XMR

  • xmrNetworkAddress - XMR TCP address (e.g., 'tcp://xmr.example.com:9505')
  • xmrWebSocketAddress - XMR WebSocket address (e.g., 'ws://xmr.example.com:9505')
  • xmrCmsKey - XMR encryption key

Features

  • preventSleep - Prevent display sleep (boolean, default: true)
  • embeddedServerPort - Embedded server port (default: 9696)
  • screenshotInterval - Screenshot interval in seconds (default: 120)

Download Windows

  • downloadStartWindow - Download start time ('HH:MM')
  • downloadEndWindow - Download end time ('HH:MM')

Other

  • licenceCode - Commercial license code
  • isSspEnabled - Enable SSP ad space (boolean)

Setting Name Formats

Supports both lowercase and CamelCase (uppercase first letter):

// Both formats work
displaySettings.applySettings({
  collectInterval: 600,   // lowercase
  CollectInterval: 600    // CamelCase
});

displaySettings.applySettings({
  displayName: 'Test',    // lowercase
  DisplayName: 'Test'     // CamelCase
});

Download Windows

Same-Day Window

displaySettings.applySettings({
  downloadStartWindow: '09:00',
  downloadEndWindow: '17:00'
});

// Downloads allowed 09:00-17:00

Overnight Window

displaySettings.applySettings({
  downloadStartWindow: '22:00',
  downloadEndWindow: '06:00'
});

// Downloads allowed 22:00-23:59 and 00:00-06:00

Events

interval-changed

Emitted when collection interval changes.

Callback: (newInterval: number) => void

settings-applied

Emitted when settings are applied.

Callback: (settings: Object, changes: Array<string>) => void

Testing

npm test

The test suite includes:

  • 44 comprehensive test cases
  • Constructor defaults
  • Setting parsing and validation
  • Collection interval enforcement (60s-24h)
  • Boolean parsing ('1', '0', true, false)
  • Download window logic (same-day and overnight)
  • Screenshot interval tracking
  • Edge cases and error handling

Integration with Upstream

Based on upstream electron-player implementation:

  • /upstream_players/electron-player/src/main/config/config.ts
  • /upstream_players/electron-player/src/main/xmds/response/registerDisplay.ts

License

AGPL-3.0-or-later