This project is the official SDK for the Stream Board project.
The SDK is helpful to develop some plugins as easy as possible and as fast as possible.
$ npm install streamboard-sdk
OR
$ yarn add streamboard-sdk
Then you can use the sdk like this example
import StreamBoardSDK from "stremboard-sdk";
const sdk = new StreamBoardSDK();
sdk.setActionConfig('myaction', [
{ type: 'input_text', key: 'world', default: () => 'World' },
]);
sdk.onContext('myaction', context => {
context.setText("Hello");
context.setColor("#1452bc");
context.onPressDown(async () => {
const config = await context.getConfig();
context.setText(`Hello ${config.world}`);
context.setColor("#14bc30");
});
});
sdk.ready();
The plugin need a valid package.json with this minimum configuration:
{
"name": "simple-plugin",
"version": "1.0.0",
"main": "src/index.ts",
"icon": "assets/img/icon.png",
"identifier": "ch.studimax.simple-plugin",
"actions": {
"myaction": {
"name": "Test",
"icon": "assets/img/actions/test.png"
}
},
"engines": {
"node": ">=14.16.0"
}
}
The plugin is executed one time on the StreamBoard, so there is only one instance of the plugin. That's why we need to use context. Context is an instance of a plugin's action declared in package.json.
context.setText("text");
src is an absolute URL.
context.setImage("https://media.giphy.com/media/xT4uQl1oBYev1vaRos/giphy.gif");
color is a valid CSS color.
context.setColor("#ff0000");
Got this event when icon is pressed down.
context.onPressDown(() => {
console.log('press down');
})
Got this event when icon is pressed up. You can get the press duration with pressDuration
context.onPressUp(({ pressDuration }) => {
console.log('press up');
})
Got this event when the context is stopped.
context.onStop(() => {
console.log('stop');
})
Got this event when the context's config changed.
context.onSettings(config => {
console.log(config);
})
//get all contexts
const contexts = sdk.getAllContexts();
//get all contexts with action named "action"
const contexts = sdk.getAllContexts("action");
onContext is executed when a new context is added on StreamBoard, the context instance and the config are returned.
sdk.onContext((context, config) => {
console.log(context);
})
Et voilà - we created a simple plugin. Don't forget that this project is in development.