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 🙏

© 2024 – Pkg Stats / Ryan Hefner

streamdeck-util

v0.4.0

Published

Node.js package to help your Node.js scripts easily interface with an official Stream Deck application plugin.

Downloads

22

Readme

node-streamdeck-util

Package still under heavy development by someone who doesn't usually make packages, use it at your own risk!

Node.js package to help your Node.js scripts easily interface with an official Stream Deck application plugin.

This package is intended to help you develop your own Node.js based applications that interact with a Stream Deck plugin while not being limited to their choice of backends. The included barebones plugin in the streamdeck-plugin folder is coded to bridge the connection between the Stream Deck software and this package.

This documentation will not teach you how to use/build upon the plugin or code for the Stream Deck SDK; see the Stream Deck SDK documentation instead.

Inside the included plugin, in the default Property Inspector for each action, you will find a "Open Settings Dialog" button, which will open a window where settings relating to the connection to the Node.js application can be changed.

Settings Dialog

At the moment, this package has only been tested to work with the regular sized Stream Deck with 15 LCD keys; any others (Stream Deck Mini, Stream Deck XL, Stream Deck Mobile, etc.) should also work, as the only difference is the amount of keys.

Technically, this package sets up a simple WebSocket server that the barebones plugin in the streamdeck-plugin folder is set up to send/receive messages from, essentially bridging the gap between to two instead of directly connecting to their own WebSocket, but being able to code as if it was the same one.

Install

$ npm install streamdeck-util

Example

JavaScript

var StreamDeck = require('streamdeck-util');

// Create new instance of the utility.
var sd = new StreamDeck();

// Start listening for connections from the Stream Deck plugin.
// key - the secret key to authenticate the connection, defaults to DEFAULT_KEY
// port - the port the connection will use, defaults to 9091
// debug - if you want to print debug messages, useful for development
sd.listen({
  key: 'DEFAULT_KEY',
  port: 9091,
  debug: true
});

// When the connection between the plugin and this instance is open.
sd.on('open', () => {
  console.log('open');
});

// If the connection between the plugin and this instance is closed.
sd.on('close', (code, reason) => {
  console.log('close: %s, %s', code, reason);
});

// If there are any errors on the connection between the plugin and this instance.
sd.on('error', (err) => {
  console.log('error:');
  console.log(err);
});

// Listens for the Stream Deck's events.
sd.on('message', (msg) => {
  console.log('message:');
  console.log(msg);

  var buttonLocations = sd.getButtonLocations(); // object, see below
  var pluginUUID = sd.getPluginUUID(); // sometimes needed as context when sending messages

  // Send a message back to the Stream Deck application; the send function stringifies it for you.
  sd.send({
    event: 'openUrl',
    payload: {
      url: 'https://www.elgato.com'
    }
  });
});

// You can directly listen for Stream Deck's events by their name if you want to.
sd.on('keyDown', (msg) => {
  console.log('keyDown:');
  console.log(msg);
});

Button Locations

Because of how you may not have a constant connection to the Stream Deck application to be able to receive all of the willAppear/willDisappear messages and so on, the barebones plugin included keeps track of the location of the buttons along with other things, for example the title. This is updated in this package's side both on initial connection and any time it changes on the plugin side.

This is an object, that stores the locations of currently visible buttons related to the connected plugin, structured like this...

{
  'DEVICE_ID': {
    'ROW_NUMBER': {
      'COLUMN_NUMBER': {
        context: 'CONTEXT_ID',
        action: 'ACTION_ID',
        title: 'BUTTON_TITLE',
        isInMultiAction: true/false, (see SDK README)
        state: 0-based value, (see SDK README)
        titleParameters: object (see SDK README)
      }
    }
  }
}

By default, every button location is defined as null.

Example in software:

Example in software

Example object:

{
  '5EC4F4448895B7B97547FDA7E8090A2D': {
    '0': {
      '0': null,
      '1': null,
      '2': null,
      '3': null,
      '4': null
    },
    '1': {
      '0': null,
      '1': null,
      '2': {
        context: '043F87C7ED1F69CE6CD660EA20773405',
        action: 'com.zoton2.example.action',
        title: 'Example',
        isInMultiAction: false,
        state: 0,
        titleParameters: {
          fontFamily: '',
          fontSize: 9,
          fontStyle: '',
          fontUnderline: false,
          showTitle: true,
          titleAlignment: 'middle',
          titleColor: '#ffffff'
        }
      },
      '3': null,
      '4': null
    },
    '2': {
      '0': {
        context: '043F87C7ED1F69CE6CD660EA20773405',
        action: 'com.zoton2.example.action',
        title: 'Example',
        isInMultiAction: false,
        state: 0,
        titleParameters: {
          fontFamily: '',
          fontSize: 9,
          fontStyle: '',
          fontUnderline: false,
          showTitle: true,
          titleAlignment: 'middle',
          titleColor: '#ffffff'
        }
      },
      '1': null,
      '2': null,
      '3': null,
      '4': null
    }
  }
}