feat(plugin): ajout d'un plugin Stream Deck pour gérer les webhooks

- Création des fichiers de configuration nécessaires (.gitignore, package.json, tsconfig.json, rollup.config.mjs)
- Ajout de la structure de base du plugin avec un compteur incrémental
- Intégration des dépendances nécessaires pour le développement
- Ajout de fichiers de ressources (icônes, HTML pour l'interface utilisateur)
- Configuration de la connexion au Stream Deck et enregistrement de l'action
This commit is contained in:
Mr¤KayJayDee
2025-07-10 10:37:59 +02:00
commit 22c2a5c3a6
19 changed files with 2454 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
# Node.js
node_modules/
# Stream Deck files
*.sdPlugin/bin
*.sdPlugin/logs

20
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Plugin",
"type": "node",
"request": "attach",
"processId": "${command:PickProcess}",
"outFiles": [
"${workspaceFolder}/bin/**/*.js"
],
"resolveSourceMapLocations": [
"${workspaceFolder}/**"
]
}
]
}

17
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,17 @@
{
/* JSON schemas */
"json.schemas": [
{
"fileMatch": [
"**/manifest.json"
],
"url": "https://schemas.elgato.com/streamdeck/plugins/manifest.json"
},
{
"fileMatch": [
"**/layouts/*.json"
],
"url": "https://schemas.elgato.com/streamdeck/plugins/layout.json"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 827 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

View File

@@ -0,0 +1,47 @@
{
"Name": "Webhooks-Trigger",
"Version": "0.1.0.0",
"Author": "Mr-KayJayDee",
"Actions": [
{
"Name": "Counter",
"UUID": "com.mr-kayjaydee.webhooks-trigger.increment",
"Icon": "imgs/actions/counter/icon",
"Tooltip": "Displays a count, which increments by one on press.",
"PropertyInspectorPath": "ui/increment-counter.html",
"Controllers": [
"Keypad"
],
"States": [
{
"Image": "imgs/actions/counter/key",
"TitleAlignment": "middle"
}
]
}
],
"Category": "Webhooks-Trigger",
"CategoryIcon": "imgs/plugin/category-icon",
"CodePath": "bin/plugin.js",
"Description": "Allows you to send webhooks using your Stream Deck",
"Icon": "imgs/plugin/marketplace",
"SDKVersion": 2,
"Software": {
"MinimumVersion": "6.5"
},
"OS": [
{
"Platform": "mac",
"MinimumVersion": "12"
},
{
"Platform": "windows",
"MinimumVersion": "10"
}
],
"Nodejs": {
"Version": "20",
"Debug": "enabled"
},
"UUID": "com.mr-kayjaydee.webhooks-trigger"
}

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head lang="en">
<title>Increment Counter Settings</title>
<meta charset="utf-8" />
<script src="https://sdpi-components.dev/releases/v4/sdpi-components.js"></script>
</head>
<body>
<!--
Learn more about property inspector components at https://sdpi-components.dev/docs/components
-->
<sdpi-item label="Increment By">
<sdpi-range setting="incrementBy" min="1" max="5" step="1" default="1" showlabels></sdpi-range>
</sdpi-item>
</body>
</html>

2204
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

22
package.json Normal file
View File

@@ -0,0 +1,22 @@
{
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w --watch.onEnd=\"streamdeck restart com.mr-kayjaydee.webhooks-trigger\""
},
"type": "module",
"devDependencies": {
"@elgato/cli": "^1.4.0",
"@rollup/plugin-commonjs": "^28.0.0",
"@rollup/plugin-node-resolve": "^15.2.2",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.0",
"@tsconfig/node20": "^20.1.2",
"@types/node": "~20.15.0",
"rollup": "^4.0.2",
"tslib": "^2.6.2",
"typescript": "^5.2.2"
},
"dependencies": {
"@elgato/streamdeck": "^1.0.0"
}
}

49
rollup.config.mjs Normal file
View File

@@ -0,0 +1,49 @@
import commonjs from "@rollup/plugin-commonjs";
import nodeResolve from "@rollup/plugin-node-resolve";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";
import path from "node:path";
import url from "node:url";
const isWatching = !!process.env.ROLLUP_WATCH;
const sdPlugin = "com.mr-kayjaydee.webhooks-trigger.sdPlugin";
/**
* @type {import('rollup').RollupOptions}
*/
const config = {
input: "src/plugin.ts",
output: {
file: `${sdPlugin}/bin/plugin.js`,
sourcemap: isWatching,
sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => {
return url.pathToFileURL(path.resolve(path.dirname(sourcemapPath), relativeSourcePath)).href;
}
},
plugins: [
{
name: "watch-externals",
buildStart: function () {
this.addWatchFile(`${sdPlugin}/manifest.json`);
},
},
typescript({
mapRoot: isWatching ? "./" : undefined
}),
nodeResolve({
browser: false,
exportConditions: ["node"],
preferBuiltins: true
}),
commonjs(),
!isWatching && terser(),
{
name: "emit-module-package-file",
generateBundle() {
this.emitFile({ fileName: "package.json", source: `{ "type": "module" }`, type: "asset" });
}
}
]
};
export default config;

View File

@@ -0,0 +1,41 @@
import { action, KeyDownEvent, SingletonAction, WillAppearEvent } from "@elgato/streamdeck";
/**
* An example action class that displays a count that increments by one each time the button is pressed.
*/
@action({ UUID: "com.mr-kayjaydee.webhooks-trigger.increment" })
export class IncrementCounter extends SingletonAction<CounterSettings> {
/**
* The {@link SingletonAction.onWillAppear} event is useful for setting the visual representation of an action when it becomes visible. This could be due to the Stream Deck first
* starting up, or the user navigating between pages / folders etc.. There is also an inverse of this event in the form of {@link streamDeck.client.onWillDisappear}. In this example,
* we're setting the title to the "count" that is incremented in {@link IncrementCounter.onKeyDown}.
*/
override onWillAppear(ev: WillAppearEvent<CounterSettings>): void | Promise<void> {
return ev.action.setTitle(`${ev.payload.settings.count ?? 0}`);
}
/**
* Listens for the {@link SingletonAction.onKeyDown} event which is emitted by Stream Deck when an action is pressed. Stream Deck provides various events for tracking interaction
* with devices including key down/up, dial rotations, and device connectivity, etc. When triggered, {@link ev} object contains information about the event including any payloads
* and action information where applicable. In this example, our action will display a counter that increments by one each press. We track the current count on the action's persisted
* settings using `setSettings` and `getSettings`.
*/
override async onKeyDown(ev: KeyDownEvent<CounterSettings>): Promise<void> {
// Update the count from the settings.
const { settings } = ev.payload;
settings.incrementBy ??= 1;
settings.count = (settings.count ?? 0) + settings.incrementBy;
// Update the current count in the action's settings, and change the title.
await ev.action.setSettings(settings);
await ev.action.setTitle(`${settings.count}`);
}
}
/**
* Settings for {@link IncrementCounter}.
*/
type CounterSettings = {
count?: number;
incrementBy?: number;
};

12
src/plugin.ts Normal file
View File

@@ -0,0 +1,12 @@
import streamDeck, { LogLevel } from "@elgato/streamdeck";
import { IncrementCounter } from "./actions/increment-counter";
// We can enable "trace" logging so that all messages between the Stream Deck, and the plugin are recorded. When storing sensitive information
streamDeck.logger.setLevel(LogLevel.TRACE);
// Register the increment action.
streamDeck.actions.registerAction(new IncrementCounter());
// Finally, connect to the Stream Deck.
streamDeck.connect();

17
tsconfig.json Normal file
View File

@@ -0,0 +1,17 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
"customConditions": [
"node"
],
"module": "ES2022",
"moduleResolution": "Bundler",
"noImplicitOverride": true
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
]
}