r/StreamDeckSDK • Elgato Staff • Feb 07 '22

Javascript JavaScript Stream Deck Plugin Template

Hi Devs,

I'm working on a new JavaScript Stream Deck plugin template... If anyone has some time I would love it if you could take a peek at this and let me know if it could use anything:

https://github.com/ChekTek/streamdeck-plugin-template

GOALS:

* Use modern javascript

* Remove all the unnecessary utils

* Add documentation inside the code (possibly a jsdoc)

* Make it easier to get started, and more approachable for new devs

* Make IntelliSense actually help you

* Make minimal changes that require updating the documentation site

* Separate what is the plugin and what is a library used for connecting (if you feel the need to make changes to anything inside of the "libs" folder please let me know. The end game will be to publish the "libs" folder as a node package, so we don't want to have to make changes in there.)

TODO

*Property Inspector still needs a bit of work

*Remove all classes from CSS so styles apply directly to elements easily

*Gather form data from ALL controls using name (the proper HTML way, not using sketchy classes), not just the easy ones

I don't think it's ready for prime time yet (and I still have talk to the team about getting it on the main github), but I think it is in a good place that people could try it out.

Any feedback is welcome!

10 Upvotes

13 comments sorted by

View all comments

3

u/JPhando Feb 08 '22 edited Feb 08 '22

The Elgato template left a lot to be desired. The new codebase is WAY cleaner, thank you! I am just getting into it, but is there a mechanism to deal with multiple instances of the same plugin on the same profile as well as supporting multiple actions within the same plugin? Those were two items that required some heavy lifting with the older template.

My plugin Stonks uses an updated version of their code. It supports radios and checkboxes among other improvements.

1

u/elgato_zack Elgato Staff Feb 08 '22

Nice. The property inspector/form still needs some work in this iteration, but I'm working on it!

1

u/elgato_zack Elgato Staff Feb 08 '22 edited Feb 08 '22

I'm sorry I missed your question the first time around. I'm not sure that I fully follow exactly what you are asking. You do still need to manage the context to reference the specific key. I've added destructuring to the parameters in the little example, so it is easier to find the context when creating the action instead of just the "jsn". Creating multiple actions should be easier now you can just use the constructor with your action uuid from the manifest. `new Action('com.elgato.supercool.action')`

StreamDeck.registerConnected(({ actionInfo, appInfo, connection, messageType, port, uuid }) => {  
	const templateAction = new Action('com.elgato.template.action');  
	templateAction.registerKeyUp(({ action, context, device, event, payload }) => {  
		StreamDeck.openUrl('https://developer.elgato.com/documentation/stream-deck/sdk/overview/');  
		console.log('Your code goes here!');  
		StreamDeck.showOk(context);  
	});  
});

There is always just one "plugin" in this case "app.js" is what I would consider the plugin (maybe I should name it plugin.js). Then you can have multiple actions, but in order to find the specific key that action lives on, you need to use that context parameter.

1

u/JPhando Feb 08 '22

I am extending your example to be a multi action template. Hopefully it will help. The new code is super clean and way less bloated than the previous release. Thank you for all the cleanup and reworking.