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

@morten-olsen/deck

v1.2.4

Published

`deck` is a full featured framework for building multi app clients for your stream deck

Downloads

20

Readme

Deck

deck is a full featured framework for building multi app clients for your stream deck

Getting started

Installation

yarn add @morten-olsen/deck

If you are running on linux you also need to take the platform specific step described in @elgato-stream-deck/node

Writing your first app

A deck client consist of one or more apps, so to get started you will need to create an app. This is pretty simple; create a new instance of App

import { App } from '@morten-olsen/deck';

const myApp = new App();

That's it, you have your first app!

Putting the app on the deck

To actually render our app unto a Stream Deck you need a runtime to serve your app, again this is pretty simple, just create a new instance of Runtime and pass it your new app.

import { Runtime } from '@morten-olsen/deck';

const runtime = new Runtime(myApp);

Run your code and you should see... well nothing yet as our app doesn't contain any buttons

Adding buttons

To add a button to our app call addButton on your app with an instance of a button. Buttons consist of image which is what should be rendered on the button and an action which is what should happen when that button is pressed.

import { Button, createText } from '@morten-olsen/deck';

const myButton = new Button({
  image: createText('My button!'),
  action: () => console.log('The button was pressed'),
});

myApp.addButton(myButton);

Now you chould see a button with the text "My button!" on your Stream Deck, and when you press it, you should see "The button was pressed" being printed in the console.

You can remove buttons using the removeButton method on your app

myApp.removeButton(myButton);

Buttons are automatically updated once their properties change, so let's create a button which shows the current time.

const clock = new Button({});

const updateClock = () => {
  clock.image = createText(new Date().toISOString());
  setTimeout(updateClock, 1000);
}
updateClock();
myApp.addButton(clock);

You should now have a button which shows the current time.

Navigating

deck is intended for multiple apps, where apps can open other apps or go back to the previous one. Button action receive an api which can be used for this navigation.

const appA = new App();
const backButton = new Button({
  image: createText('Go back'),
  action: (api) => api.back(),
});

const rootApp = new App();
const openButton = new Button({
  image: createText('Open appA'),
  action: (api) => api.open(appA),
});

const runtime = new Runtime(rootApp);

Now you will have one button called "Open appA", which when clicked will navigate to appA, which will have two back buttons (one with a back arrow and one with the text "Go back). The reason that you have two is that apps uses a BasicLayout which will automatically render a back button if there are any apps to go back to.

There are a few navigation method available on the api

  • back(): Goes back to the previous app
  • open(app): Opens the given app. If the app is already in the navigation stack it will be moved to the top.
  • popTo(app): If the app exists in the navigation stack it will pop down to that instance. If it doesn't exist it will be added to the top.
  • updateStack(updateFunction): Allows you to manipulate the navigation stack by providing a function which gets an app array and returns an app array ((apps) => apps.reverse() would inverse the navigation stack). NOTE: you always have to return an array with at least one app in it

Layouts

Apps can have different layouts, which are responsible for deciding where the buttons are place on the deck.

These layouts has to take make a layout of the current apps buttons, the runtimes sticky buttons as well as any additional buttons that may be required (back, next, prev, etc.).

At the moment only the BasicLayout is supported, but more will come in the future, as well as a guide on how to write your own layouts.

Examples

You can see a fully working example of an app inside packages/example which is also using a pre built OBS app which can be found at apps/obs