Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): bump path-parse from 1.0.6 to 1.0.7 #7

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
16 changes: 16 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
push:
branches:
- "main"

jobs:
build:
name: Build and pack
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm ci
- run: npm run build
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@ typings/

# TernJS port file
.tern-port

# Build output
dist/
55 changes: 55 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"branches": [
"main"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"releaseRules": [
{
"type": "breaking",
"release": "major"
},
{
"type": "feat",
"release": "minor"
},
{
"message": "*",
"release": "patch"
},
{
"scope": "no-release",
"release": false
}
]
}
],
"@semantic-release/release-notes-generator",
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
[
"@semantic-release/github",
{
"assets": [
"*.midiMixerPlugin"
]
}
],
[
"@semantic-release/git",
{
"assets": [
"package.json",
"package-lock.json",
"plugin.json"
]
}
]
]
}
2 changes: 0 additions & 2 deletions dist/index.html

This file was deleted.

62 changes: 0 additions & 62 deletions dist/src.8d0d3182.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/src.8d0d3182.js.map

This file was deleted.

109 changes: 109 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const midi_mixer_plugin_1 = require("midi-mixer-plugin");
const obs_websocket_js_1 = __importDefault(require("obs-websocket-js"));
const obs = new obs_websocket_js_1.default();
let sources = {};
let scenes = {};
const settingsP = $MM.getSettings();
let currentScene = "";
const connect = async () => {
const settings = await settingsP;
return obs.connect({
address: settings.address ?? "localhost:4444",
password: settings.password ?? "",
});
};
const registerListeners = () => {
obs.on("SourceVolumeChanged", (data) => {
const source = sources[data.sourceName];
if (!source)
return;
source.volume = data.volume;
});
obs.on("SourceMuteStateChanged", (data) => {
const source = sources[data.sourceName];
if (!source)
return;
source.muted = data.muted;
});
obs.on("SwitchScenes", (data) => {
currentScene = data["scene-name"];
Object.values(scenes).forEach((button) => {
button.active = data["scene-name"] === button.id;
});
});
};
const mapSources = async () => {
const data = await obs.send("GetSourcesList");
data.sources?.forEach(async (source) => {
const [volume, muted] = await Promise.all([
obs
.send("GetVolume", {
source: source.name,
})
.then((res) => res.volume),
obs
.send("GetMute", {
source: source.name,
})
.then((res) => res.muted),
]);
const assignment = new midi_mixer_plugin_1.Assignment(source.name, {
name: source.name,
muted,
volume,
});
assignment.on("volumeChanged", (level) => {
obs.send("SetVolume", {
source: source.name,
volume: level,
});
});
assignment.on("mutePressed", () => {
obs.send("SetMute", {
source: source.name,
mute: !assignment.muted,
});
});
sources[source.name] = assignment;
});
};
const mapScenes = async () => {
const data = await obs.send("GetSceneList");
currentScene = data["current-scene"];
data.scenes.forEach((scene) => {
const button = new midi_mixer_plugin_1.ButtonType(scene.name, {
name: `OBS: Switch to "${scene.name}" scene`,
active: scene.name === currentScene,
});
button.on("pressed", () => {
obs.send("SetCurrentScene", {
"scene-name": scene.name,
});
button.active = true;
});
scenes[scene.name] = button;
});
};
const init = async () => {
obs.disconnect();
sources = {};
scenes = {};
try {
$MM.setSettingsStatus("status", "Connecting...");
await connect();
registerListeners();
await Promise.all([mapSources(), mapScenes()]);
$MM.setSettingsStatus("status", "Connected");
}
catch (err) {
console.warn("OBS error:", err);
$MM.setSettingsStatus("status", err.description || err.message || err);
}
};
$MM.onSettingsButtonPress("reconnect", init);
init();
Loading