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

@gamesdonequick/typed-obs-scenes

v1.1.2

Published

Generate a d.ts file full of enums describing an OBS Scene Collection.

Downloads

4

Readme

typed-obs-scenes npm Build Status

Generate a d.ts file full of enums describing an OBS Scene Collection.

Table of Contents

Motivation

We often need to write code which remotely controls one or more OBS Studio instances via obs-websocket. When doing this, it is common to need to reference specific Scene and Source names. This can be really dangerous, as it's easy to typo and these typos might go unnoticed until it is too late.

That's where this CLI tool comes in. It takes an OBS Scene Collection JSON file as input, and outputs a TypeScript d.ts typedef file with enums describing the Scenes, Sources, Groups, and Transitions present in that Collection. It looks like this (don't worry, you can use UpperCamelCase if you don't like snake_case):

export const enum Group {
	'camera_interview' = 'Camera (Interview)',
	'camera_widescreen_2' = 'Camera (Widescreen 2)',
	'camera_widescreen_1' = 'Camera (Widescreen 1)',
}

export const enum Source {
	'layout_widescreen_3' = 'Layout Widescreen 3',
	'layout_standard_4_ff_4_fe' = 'Layout Standard 4 FF4FE',
	'layout_standard_2_sms' = 'Layout Standard 2 SMS',
	'countdown_anim' = 'Countdown Anim',
	'layout_ds_vertical' = 'Layout DS Vertical',
	'closing_slate' = 'Closing Slate',
}

export const enum Scene {
	'main_stage_full_camera' = 'Main Stage Full Camera',
	'widescreen_3' = 'Widescreen 3',
	'standard_4_ff_4_fe' = 'Standard 4 FF4FE',
	'standard_2_sms' = 'Standard 2 SMS',
}

export const enum Transition {
	'fade_to_color' = 'Fade to Color',
	'blank_stinger' = 'Blank Stinger',
}

Installation

This is a CLI program, so you don't need to write any code to use it. Just install and run.

npm i -g @gamesdonequick/typed-obs-scenes

Usage

  1. Export your Scene Collection from OBS (this is done via the Scene Collection > Export dropdown menu).

  2. Run typed-obs-scenes on it:

    typed-obs-scenes --input path/to/your/scene/collection.json
  3. Import the resulting d.ts file in your TypeScript project and start using it!

    import * as SceneCollection from 'path/to/your/scene/collection.d.ts';
    import * as ObsWebsocketJs from 'obs-websocket-js';
    
    const obs = new OBSWebSocket();
    obs.connect({ address: 'localhost:4444', password: '$up3rSecretP@ssw0rd' }).then(() => {
    	obs.send('SetCurrentScene', {
    		'scene-name': SceneCollection.Scene.main_stage_full_camera,
    	});
    });

You can also run typed-obs-scenes (with no arguments) at any time, and it will print a list of its options and how to use them:

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --input    the OBS Scene Collection to generate typedefs from
                                                             [string] [required]
  --output   the location to write the generated typedefs to            [string]
  --case     the casing to use in the enum key names
                                  [choices: "camel", "snake"] [default: "snake"]

Missing required argument: input

License

MIT