Skip to content

Commit 8a024b3

Browse files
Initialized first release
0 parents  commit 8a024b3

7 files changed

Lines changed: 1249 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release version
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
name: Create Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
- name: Install Node v12
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: '12.x'
19+
- name: Install NPM Packages
20+
run: npm install
21+
- name: Build
22+
run: npm run build --if-present
23+
- name: Create Release
24+
id: create_release
25+
uses: actions/create-release@v1
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
with:
29+
tag_name: ${{ github.ref }}
30+
release_name: Release ${{ github.ref }}
31+
body: |
32+
Changes in this Release
33+
- First version
34+
draft: false
35+
prerelease: false
36+
- name: Upload Release Asset
37+
id: upload-release-asset
38+
uses: actions/upload-release-asset@v1
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
with:
42+
upload_url: ${{ steps.create_release.outputs.upload_url }}
43+
asset_path: ./dist/StreamDeckSDK.js
44+
asset_name: StreamDeckSDK.js
45+
asset_content_type: text/javascript
46+
- name: Publish NPM
47+
uses: pascalgn/npm-publish-action@4f4bf159e299f65d21cd1cbd96fc5d53228036df
48+
with:
49+
tag_name: "v%s"
50+
tag_message: "v%s"
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.idea
2+
/dist
3+
/node_modules/

README.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Stream Deck SDK
2+
3+
This project is a **not official** SDK for Elgato's Stream Deck.
4+
5+
The idea behind was that there are few "files" or projects which want providing an layer for the Stream Deck.
6+
But I want to develop some plugins as easy as possible and as fast as possible.
7+
8+
## Features
9+
10+
- Automatic setting management (Loading & Saving values in Property Inspector with 2 lines of code)
11+
- Setting image easily via URL
12+
- Drawing management (Canvas)
13+
- HTTP Module (http.get/http.post/... easily instead of fetch)
14+
15+
# Installation
16+
17+
$ npm install streamdeck-sdk
18+
19+
After that add the script to header of your html files. (i.e. `plugin.html`/`index.html` and `property-inspector.html`)
20+
21+
<script src="node_modules/streamdeck-sdk/dist/StreamDeckSDK.js"></script>
22+
23+
When you downloaded only the `StreamDeckSDK.js` you can easily add them, too.
24+
25+
<script src="StreamDeckSDK.js"></script>
26+
27+
# Registration Procedure
28+
29+
Read the steps for the plugin and for the property inspector.
30+
31+
## Plugin
32+
33+
The plugin is easily load via:
34+
35+
<script>
36+
var plugin = new StreamDeckPlugin();
37+
</script>
38+
39+
## Property Inspector
40+
41+
The property inspector is easily load via:
42+
43+
<script>
44+
var propertyInspector = new StreamDeckPropertyInspector();
45+
</script>
46+
47+
### Automatic setting management
48+
49+
For enabling the property inspector setting management you must add this line to your `<script>`:
50+
51+
propertyInspector.enableSettingManager();
52+
53+
Behind the scene it loops all your `input`, `textarea` and `select` elements.
54+
Then it checks for the `name` or `id` attribute and if it's already set in the `settings` of your Stream Deck.
55+
56+
If yes, it automatically set's the `value` of your element to the stored value.
57+
On change event it will automatically store the value.
58+
And in case of closing the property inspector there is a listener for the `beforeunload` event.
59+
(which sends the settings to the plugin which stores it then automatically)
60+
61+
You can disable the automatic loading and saving for single elements by adding the `sdk-ignore` class.
62+
63+
This logic supports also `file` inputs.
64+
You can show the `file` then in the plugin via `instance.setImageURL(instance.settings.myname)`.
65+
66+
### Example: Simple counter (with stored and changable value)
67+
68+
This demonstrates how easy you can develop a plugin with property inspector view.
69+
70+
_Do not forget to add the StreamDeckSDK.js in plugin and property inspector files as described in Installation!_
71+
72+
#### Plugin
73+
74+
The plugin shows a number (counter) and on each key press (keyUp) it will count the number plus one.
75+
But when we got a new value from property inspector we also want to use this number.
76+
77+
// First we initialize the Stream Deck Plugin
78+
var plugin = new StreamDeckPlugin();
79+
// Then we listen to the initialization process
80+
plugin.on('init', function(event) {
81+
// Each init gives one instance (instance = 1 button on the Stream Deck)
82+
// Instances having an `action` which you can check when you have multiple actions!
83+
// i.e. if (instance.action === 'org.examle.firstaction') { }
84+
var instance = event.detail.instance;
85+
// Then we setting the title of the instance to the counter - else 1
86+
instance.setTitle((+instance.settings.counter) || 1);
87+
// Now we're going to listen for keyUp, so whenever we press the button and release this is called
88+
instance.on('keyUp', function() {
89+
// Lets get the current value and count + 1
90+
var count = ((+instance.settings.counter) || 1) + 1;
91+
// Now lets set the title of our instance to the number
92+
instance.setTitle(count);
93+
// And then lets save the new number
94+
instance.setSetting('counter', count);
95+
});
96+
// We want also to listen for changed settings from the property inspector
97+
instance.on('didReceiveSettings', function() {
98+
// So when property inspector changes the counter value set the title to it
99+
instance.setTitle(instance.settings.counter || 1);
100+
});
101+
});
102+
103+
#### Property Inspector
104+
105+
In the property inspector we add the element with the input to the `<body>`.
106+
107+
<div class="sdpi-item">
108+
<div class="sdpi-item-label">Counter Value</div>
109+
<input class="sdpi-item-value" name="counter" />
110+
</div>
111+
112+
And in the `<script>` (maybe before closing `</body>`) we add our logic.
113+
114+
<script>
115+
var plugin = new StreamDeckPropertyInspector();
116+
plugin.enableSettingManager();
117+
</script>
118+
119+
#### Done
120+
121+
Et voilà - we created a simple logic which sends the counter value to the plugin which shows it.
122+
And the plugin count it up on each keypress.
123+
The property inspector will also be updated on each `keyUp` because it's listening to the setting change event.
124+
125+
# Build
126+
127+
Run `npm run build` to build the project. The build artifacts will be stored in the `dist/` directory.
128+
129+
# Sample plugins
130+
131+
* Coming May 2020: Toggl
132+
* Coming May 2020: INSTAR Camera Viewer
133+
134+
# Contributing
135+
136+
Feel free to open issues, pull requests or something else.
137+
138+
When you need a plugin feel free to request it via the issues.

0 commit comments

Comments
 (0)