├── .npmrc ├── src ├── resources │ ├── icons │ │ ├── app.ico │ │ ├── app.png │ │ ├── app.icns │ │ ├── icon.ico │ │ ├── icon.png │ │ ├── icon@2x.png │ │ └── icon@3x.png │ └── json │ │ └── config.json ├── render │ ├── src │ │ ├── assets │ │ │ ├── icons │ │ │ │ └── icon.ico │ │ │ ├── pictures │ │ │ │ ├── deco.png │ │ │ │ ├── gabin.png │ │ │ │ ├── noise.png │ │ │ │ ├── loading.gif │ │ │ │ ├── boot-200.gif │ │ │ │ ├── boot-500.gif │ │ │ │ ├── obs │ │ │ │ │ ├── obs-scenes.png │ │ │ │ │ ├── obs-add-scene.png │ │ │ │ │ ├── obs-container.png │ │ │ │ │ ├── obs-new-scene.png │ │ │ │ │ └── obs-containers.png │ │ │ │ └── vmix │ │ │ │ │ ├── vmix-add-container.png │ │ │ │ │ ├── vmix-overlay-sources.png │ │ │ │ │ └── vmix-create-container.png │ │ │ └── fonts │ │ │ │ ├── SpaceGrotesk-Bold.ttf │ │ │ │ ├── SpaceGrotesk-Light.ttf │ │ │ │ ├── SpaceGrotesk-Medium.ttf │ │ │ │ ├── SpaceGrotesk-Regular.ttf │ │ │ │ └── SpaceGrotesk-SemiBold.ttf │ │ ├── components │ │ │ ├── basics │ │ │ │ ├── PopUp │ │ │ │ │ ├── PopUp.vue │ │ │ │ │ ├── PopUpContainer.vue │ │ │ │ │ └── PopUpBackground.vue │ │ │ │ ├── ButtonUi.vue │ │ │ │ ├── TooltipUi.vue │ │ │ │ ├── ButtonContainerUi.vue │ │ │ │ ├── ModalUi.vue │ │ │ │ ├── TagUi.vue │ │ │ │ ├── ToggleUi.vue │ │ │ │ ├── ToastUi.vue │ │ │ │ ├── GabinFace.vue │ │ │ │ └── InputUi.vue │ │ │ ├── icons │ │ │ │ ├── PlayIcon.vue │ │ │ │ ├── ChevronLeftIcon.vue │ │ │ │ ├── ChevronRightIcon.vue │ │ │ │ ├── PlusIcon.vue │ │ │ │ ├── StopIcon.vue │ │ │ │ ├── ChevronBottomIcon.vue │ │ │ │ ├── ArrowRightIcon.vue │ │ │ │ ├── ArrowLeftIcon.vue │ │ │ │ ├── PlayCircleIcon.vue │ │ │ │ ├── CheckIcon.vue │ │ │ │ ├── ReturnIcon.vue │ │ │ │ ├── PenIcon.vue │ │ │ │ ├── MinCircleIcon.vue │ │ │ │ ├── ProfileIcons.vue │ │ │ │ ├── CrossIcon.vue │ │ │ │ ├── BurgerMenuIcon.vue │ │ │ │ ├── DotsIcon.vue │ │ │ │ ├── FolderIcon.vue │ │ │ │ ├── UserIcon.vue │ │ │ │ ├── PlusCircleIcon.vue │ │ │ │ ├── BinIcon.vue │ │ │ │ ├── PauseCircleIcon.vue │ │ │ │ ├── EyeIcon.vue │ │ │ │ ├── InfoIcon.vue │ │ │ │ ├── SmileIcon.vue │ │ │ │ ├── QuestionMarkIcon.vue │ │ │ │ ├── CamIcon.vue │ │ │ │ ├── PaperClipIcon.vue │ │ │ │ ├── PizzaIcon.vue │ │ │ │ ├── DownloadIcon.vue │ │ │ │ ├── RocketIcon.vue │ │ │ │ ├── UploadIcon.vue │ │ │ │ ├── SandwichIcon.vue │ │ │ │ └── SettingsIcon.vue │ │ │ ├── home │ │ │ │ ├── MainProfile.vue │ │ │ │ ├── Audio.vue │ │ │ │ ├── EditIcon.vue │ │ │ │ └── Connections.vue │ │ │ ├── setup │ │ │ │ ├── FetchProfile.vue │ │ │ │ ├── TimelineSteps.vue │ │ │ │ ├── SourcesTree.vue │ │ │ │ ├── OscTuto.vue │ │ │ │ └── VmixTuto.vue │ │ │ ├── loading │ │ │ │ └── LoadingGabin.vue │ │ │ ├── settings │ │ │ │ └── EditConnection.vue │ │ │ └── utils │ │ │ │ ├── KeyPress.vue │ │ │ │ └── UtilsTools.vue │ │ ├── env.d.ts │ │ ├── views │ │ │ ├── SplashView.vue │ │ │ ├── DisconnectView.vue │ │ │ ├── setup │ │ │ │ ├── SummaryView.vue │ │ │ │ ├── SettingsView.vue │ │ │ │ ├── IndexView.vue │ │ │ │ ├── VideoMixerView.vue │ │ │ │ ├── ProfileView.vue │ │ │ │ ├── LandingView.vue │ │ │ │ ├── ObsView.vue │ │ │ │ ├── VmixView.vue │ │ │ │ └── OscView.vue │ │ │ ├── LoadingView.vue │ │ │ └── RunningView.vue │ │ ├── layout │ │ │ ├── BackgroundLayout.vue │ │ │ ├── FooterLayout.vue │ │ │ ├── TimelineLayout.vue │ │ │ ├── HeaderLayout.vue │ │ │ └── GlobalLayout.vue │ │ └── App.vue │ ├── index.html │ ├── vite.config.ts │ ├── .gitignore │ ├── tsconfig.json │ ├── package.json │ ├── uno.config.ts │ └── README.md └── main │ ├── servers │ ├── Connections.ts │ └── Server.ts │ ├── clients │ ├── Client.ts │ ├── OBSClient.ts │ └── OSCClient.ts │ ├── index.ts │ ├── modules │ ├── setup.ts │ └── profiles.ts │ └── utils │ ├── db.ts │ └── logger.ts ├── nodemon.json ├── .vscode ├── extensions.json ├── settings.json └── launch.json ├── .gitignore ├── patches └── node-osc+9.1.4.patch ├── LICENSE ├── forge.config.js ├── tsconfig.json ├── .github └── workflows │ └── release.yml └── package.json /.npmrc: -------------------------------------------------------------------------------- 1 | auto-install-peers=false -------------------------------------------------------------------------------- /src/resources/icons/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/resources/icons/app.ico -------------------------------------------------------------------------------- /src/resources/icons/app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/resources/icons/app.png -------------------------------------------------------------------------------- /src/resources/icons/app.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/resources/icons/app.icns -------------------------------------------------------------------------------- /src/resources/icons/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/resources/icons/icon.ico -------------------------------------------------------------------------------- /src/resources/icons/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/resources/icons/icon.png -------------------------------------------------------------------------------- /src/resources/icons/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/resources/icons/icon@2x.png -------------------------------------------------------------------------------- /src/resources/icons/icon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/resources/icons/icon@3x.png -------------------------------------------------------------------------------- /src/render/src/assets/icons/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/icons/icon.ico -------------------------------------------------------------------------------- /src/render/src/assets/pictures/deco.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/deco.png -------------------------------------------------------------------------------- /src/render/src/assets/pictures/gabin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/gabin.png -------------------------------------------------------------------------------- /src/render/src/assets/pictures/noise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/noise.png -------------------------------------------------------------------------------- /src/render/src/assets/pictures/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/loading.gif -------------------------------------------------------------------------------- /src/render/src/assets/pictures/boot-200.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/boot-200.gif -------------------------------------------------------------------------------- /src/render/src/assets/pictures/boot-500.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/boot-500.gif -------------------------------------------------------------------------------- /src/resources/json/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "HOST": "localhost", 3 | "HTTP_PORT": 1510, 4 | "OSC_PORT": 32123, 5 | "BASE_URL": "/" 6 | } -------------------------------------------------------------------------------- /src/render/src/assets/fonts/SpaceGrotesk-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/fonts/SpaceGrotesk-Bold.ttf -------------------------------------------------------------------------------- /src/render/src/assets/fonts/SpaceGrotesk-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/fonts/SpaceGrotesk-Light.ttf -------------------------------------------------------------------------------- /src/render/src/assets/pictures/obs/obs-scenes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/obs/obs-scenes.png -------------------------------------------------------------------------------- /src/render/src/assets/fonts/SpaceGrotesk-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/fonts/SpaceGrotesk-Medium.ttf -------------------------------------------------------------------------------- /src/render/src/assets/fonts/SpaceGrotesk-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/fonts/SpaceGrotesk-Regular.ttf -------------------------------------------------------------------------------- /src/render/src/assets/pictures/obs/obs-add-scene.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/obs/obs-add-scene.png -------------------------------------------------------------------------------- /src/render/src/assets/pictures/obs/obs-container.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/obs/obs-container.png -------------------------------------------------------------------------------- /src/render/src/assets/pictures/obs/obs-new-scene.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/obs/obs-new-scene.png -------------------------------------------------------------------------------- /src/render/src/assets/fonts/SpaceGrotesk-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/fonts/SpaceGrotesk-SemiBold.ttf -------------------------------------------------------------------------------- /src/render/src/assets/pictures/obs/obs-containers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/obs/obs-containers.png -------------------------------------------------------------------------------- /src/render/src/assets/pictures/vmix/vmix-add-container.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/vmix/vmix-add-container.png -------------------------------------------------------------------------------- /src/render/src/assets/pictures/vmix/vmix-overlay-sources.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/vmix/vmix-overlay-sources.png -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["src"], 3 | "ext": ".ts,.js", 4 | "ignore": ["src/render/dist"], 5 | "exec": "DEBUG=true npm run preview -- -- -- --no-auto-open" 6 | } -------------------------------------------------------------------------------- /src/render/src/assets/pictures/vmix/vmix-create-container.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/one-click-studio/gabin/HEAD/src/render/src/assets/pictures/vmix/vmix-create-container.png -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "dbaeumer.vscode-eslint", 4 | "vue.volar", 5 | "vue.vscode-typescript-vue-plugin", 6 | "ms-vscode.vscode-typescript-next" 7 | ] 8 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[typescript]": { 3 | "editor.defaultFormatter": "esbenp.prettier-vscode" 4 | }, 5 | "[javascript]": { 6 | "editor.defaultFormatter": "esbenp.prettier-vscode" 7 | }, 8 | "[json]": { 9 | "editor.defaultFormatter": "esbenp.prettier-vscode" 10 | } 11 | } -------------------------------------------------------------------------------- /src/render/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Gabin 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | mac-dist 4 | out 5 | build 6 | database.json 7 | *.log* 8 | .env 9 | test.sh 10 | certificate.p12 11 | .DS_Store 12 | /test-results/ 13 | /playwright-report/ 14 | /playwright/.cache/ 15 | /tests 16 | /tests-examples 17 | playwright.config.ts 18 | * copy.* 19 | *.wav 20 | build-mac.sh 21 | .idea 22 | -------------------------------------------------------------------------------- /src/render/src/components/basics/PopUp/PopUp.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/render/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { resolve } from 'path' 2 | import { defineConfig } from 'vite' 3 | import vue from '@vitejs/plugin-vue' 4 | import Unocss from 'unocss/vite' 5 | 6 | // https://vitejs.dev/config/ 7 | export default defineConfig({ 8 | resolve: { 9 | alias: { 10 | '@src': resolve(__dirname, 'src'), 11 | } 12 | }, 13 | plugins: [vue(), Unocss()] 14 | }) 15 | -------------------------------------------------------------------------------- /src/render/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | tsconfig.tsbuildinfo 15 | 16 | # Editor directories and files 17 | .vscode/* 18 | !.vscode/extensions.json 19 | .idea 20 | .DS_Store 21 | *.suo 22 | *.ntvs* 23 | *.njsproj 24 | *.sln 25 | *.sw? 26 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Debug Main Process", 6 | "type": "node", 7 | "request": "launch", 8 | "cwd": "${workspaceRoot}", 9 | "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite", 10 | "windows": { 11 | "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite.cmd" 12 | }, 13 | "runtimeArgs": ["--sourcemap"] 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /src/render/src/env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module '*.vue' { 4 | import type { DefineComponent } from 'vue' 5 | const component: DefineComponent<{}, {}, any> 6 | export default component 7 | } 8 | 9 | declare module "*.ts" { 10 | const value: any; 11 | export = value; 12 | } 13 | 14 | declare module "*.png" { 15 | const value: any; 16 | export = value; 17 | } 18 | 19 | declare module "*.gif" { 20 | const value: any; 21 | export = value; 22 | } 23 | 24 | declare const __APP_VERSION__: string -------------------------------------------------------------------------------- /src/render/src/components/icons/PlayIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /patches/node-osc+9.1.4.patch: -------------------------------------------------------------------------------- 1 | diff --git a/node_modules/node-osc/dist/lib/Server.js b/node_modules/node-osc/dist/lib/Server.js 2 | index 9bfaab1..0f94cb6 100644 3 | --- a/node_modules/node-osc/dist/lib/Server.js 4 | +++ b/node_modules/node-osc/dist/lib/Server.js 5 | @@ -2,7 +2,7 @@ 6 | 7 | var node_dgram = require('node:dgram'); 8 | var node_events = require('node:events'); 9 | -var decode = require('#decode'); 10 | +var decode = require('./internal/decode'); 11 | 12 | class Server extends node_events.EventEmitter { 13 | constructor(port, host='127.0.0.1', cb) { 14 | -------------------------------------------------------------------------------- /src/render/src/components/basics/PopUp/PopUpContainer.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 28 | 29 | -------------------------------------------------------------------------------- /src/render/src/components/home/MainProfile.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 24 | -------------------------------------------------------------------------------- /src/main/servers/Connections.ts: -------------------------------------------------------------------------------- 1 | import db from '../../main/utils/db' 2 | import type { SpecificAndDefault } from '../../main/utils/db' 3 | 4 | import type { 5 | ConnectionsConfig, 6 | ConnectionType, 7 | Connection, 8 | } from '../../types/protocol' 9 | 10 | export class Connections { 11 | 12 | private d: SpecificAndDefault 13 | private all: ConnectionsConfig 14 | 15 | constructor() { 16 | this.d = db.getSpecificAndDefault(['connections'], false) 17 | this.all = this.d.defaultValue 18 | } 19 | 20 | getAll(): ConnectionsConfig { 21 | return this.all 22 | } 23 | 24 | edit(type: ConnectionType, data: Connection) { 25 | this.all[type] = data 26 | this.d.edit(this.all) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/render/src/components/basics/PopUp/PopUpBackground.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | 31 | 32 | -------------------------------------------------------------------------------- /src/render/src/views/SplashView.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/render/src/components/setup/FetchProfile.vue: -------------------------------------------------------------------------------- 1 | 27 | -------------------------------------------------------------------------------- /src/render/src/components/basics/ButtonUi.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | -------------------------------------------------------------------------------- /src/render/src/components/loading/LoadingGabin.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/render/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true, 4 | "target": "ESNext", 5 | "useDefineForClassFields": true, 6 | "module": "ESNext", 7 | "moduleResolution": "Node", 8 | "strict": true, 9 | "jsx": "preserve", 10 | "resolveJsonModule": true, 11 | "isolatedModules": true, 12 | "esModuleInterop": true, 13 | "lib": ["ESNext", "DOM"], 14 | "skipLibCheck": true, 15 | "noEmit": true, 16 | "composite": true, 17 | "allowSyntheticDefaultImports": true, 18 | "types": ["vite/client"], 19 | "baseUrl": ".", 20 | "paths": { 21 | "@src/*": ["./src/*"], 22 | "@types/*": ["../types/*"] 23 | } 24 | }, 25 | "include": [ 26 | "src/**/*.ts", 27 | "src/**/*.d.ts", 28 | "src/**/*.tsx", 29 | "src/**/*.vue", 30 | "vite.config.ts" 31 | ], 32 | } 33 | -------------------------------------------------------------------------------- /src/render/src/components/icons/ChevronLeftIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/components/icons/ChevronRightIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/render/src/components/setup/TimelineSteps.vue: -------------------------------------------------------------------------------- 1 | 26 | -------------------------------------------------------------------------------- /src/render/src/views/DisconnectView.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | -------------------------------------------------------------------------------- /src/render/src/components/icons/PlusIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/render/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "render", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "cross-env-shell \"vite --port $GABIN_CLIENT_PORT\"", 8 | "build": "vue-tsc && vite build --base=./", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "@headlessui/vue": "^1.7.7", 13 | "klona": "^2.0.5", 14 | "rxjs": "^7.8.0", 15 | "socket.io-client": "^4.6.0", 16 | "unocss": "^0.48.0", 17 | "vue": "^3.2.45", 18 | "vue-router": "^4.1.6" 19 | }, 20 | "devDependencies": { 21 | "@types/node": "^18.13.0", 22 | "@unocss/reset": "^0.49.4", 23 | "@unocss/transformer-directives": "^0.49.4", 24 | "@vitejs/plugin-vue": "^3.2.0", 25 | "typescript": "^4.9.5", 26 | "unocss-preset-scrollbar": "^0.2.1", 27 | "vite": "^3.2.4", 28 | "vitest": "^0.27.1", 29 | "vue": "^3.2.45", 30 | "vue-tsc": "^1.0.9" 31 | } 32 | } -------------------------------------------------------------------------------- /src/render/src/components/icons/StopIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/components/icons/ChevronBottomIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/components/icons/ArrowRightIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/components/icons/ArrowLeftIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/render/src/views/setup/SummaryView.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 OneClickStudio 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /src/render/src/components/icons/PlayCircleIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/components/icons/CheckIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/views/LoadingView.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/render/uno.config.ts: -------------------------------------------------------------------------------- 1 | // https://github.com/unocss/unocss 2 | 3 | import { defineConfig, presetIcons, presetWind } from 'unocss' 4 | import transformerDirective from '@unocss/transformer-directives' 5 | import { presetScrollbar } from 'unocss-preset-scrollbar' 6 | 7 | export default defineConfig({ 8 | presets: [presetWind(), presetIcons(), presetScrollbar()], 9 | // @ts-ignore 10 | transformers: [transformerDirective()], 11 | theme: { 12 | colors: { 13 | bg: { 14 | 1: '#2E3242', 15 | 2: '#252935', 16 | 3: '#131726', 17 | }, 18 | content: { 19 | 1: '#FFFFFF', 20 | 2: '#A1ADBE', 21 | 3: '#383F50', 22 | negative: '#E53811', 23 | }, 24 | main: '#0033FF', 25 | mainhighlight: '#3265FF', 26 | mainhover: '#000BD7', 27 | 'negative-hover': '#DA2C13', 28 | 'black-disable': 'rgba(0, 0, 0, 0.25)', 29 | green: '#27AE60', 30 | }, 31 | fontSize: { 32 | xxs: ['0.563rem'], 33 | xs: ['0.688rem'], 34 | sm: ['0.813rem'], 35 | base: ['1rem'], 36 | m: ['1.5rem'], 37 | lg: ['2rem'], 38 | xl: ['3rem'], 39 | } 40 | }, 41 | }) 42 | -------------------------------------------------------------------------------- /src/render/src/components/basics/TooltipUi.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 19 | 20 | -------------------------------------------------------------------------------- /src/render/src/layout/BackgroundLayout.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 26 | 27 | -------------------------------------------------------------------------------- /src/render/src/components/icons/ReturnIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/components/icons/PenIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/components/icons/MinCircleIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/render/src/components/icons/ProfileIcons.vue: -------------------------------------------------------------------------------- 1 | 45 | -------------------------------------------------------------------------------- /src/main/clients/Client.ts: -------------------------------------------------------------------------------- 1 | import { BehaviorSubject } from 'rxjs' 2 | import { getLogger } from '../../main/utils/logger' 3 | 4 | import type { Subscription } from 'rxjs' 5 | import type { Logger } from '../../main/utils/logger' 6 | 7 | export class Client { 8 | reachable$ = new BehaviorSubject(false) 9 | logger: Logger 10 | private clientSubscriptions: Subscription[] = [] 11 | 12 | constructor(public name: string) { 13 | this.logger = getLogger(name) 14 | 15 | this.reachable$.subscribe((reachable) => { 16 | this.logger.info( 17 | `${this.name} client ${reachable ? 'connected' : 'disconnected'}`, 18 | ) 19 | }) 20 | } 21 | 22 | connect() { 23 | this.logger.info(`connecting ${this.name} client`) 24 | } 25 | 26 | clean() { 27 | this.logger.info(`cleaning ${this.name} client`) 28 | this.cleanClientSubscriptions() 29 | } 30 | 31 | protected addSubscription(subscription: Subscription) { 32 | this.clientSubscriptions.push(subscription) 33 | } 34 | 35 | private cleanClientSubscriptions() { 36 | for (const s of this.clientSubscriptions) { 37 | s.unsubscribe() 38 | } 39 | } 40 | 41 | get isReachable() { 42 | return this.reachable$.getValue() 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/servers/Server.ts: -------------------------------------------------------------------------------- 1 | import { BehaviorSubject } from 'rxjs' 2 | import { getLogger } from '../../main/utils/logger' 3 | 4 | import type { Subscription } from 'rxjs' 5 | import type { Logger } from '../../main/utils/logger' 6 | 7 | export class Server { 8 | reachable$ = new BehaviorSubject(false) 9 | logger: Logger 10 | private serverSubscriptions: Subscription[] = [] 11 | 12 | constructor(public name: string) { 13 | this.logger = getLogger(name) 14 | 15 | this.reachable$.subscribe((reachable) => { 16 | this.logger.info( 17 | `${this.name} server ${reachable ? 'connected' : 'disconnected'}`, 18 | ) 19 | }) 20 | } 21 | 22 | listen() { 23 | this.logger.info(`${this.name} server is listening`) 24 | } 25 | 26 | clean() { 27 | this.logger.info(`cleaning ${this.name} server`) 28 | this.cleanServerSubscriptions() 29 | } 30 | 31 | protected addSubscription(subscription: Subscription) { 32 | this.serverSubscriptions.push(subscription) 33 | } 34 | 35 | private cleanServerSubscriptions() { 36 | for (const s of this.serverSubscriptions) { 37 | s.unsubscribe() 38 | } 39 | } 40 | 41 | get isReachable() { 42 | return this.reachable$.getValue() 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/render/src/components/icons/CrossIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/render/src/components/home/Audio.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 37 | -------------------------------------------------------------------------------- /src/render/src/components/icons/BurgerMenuIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/render/src/components/icons/DotsIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/render/src/components/settings/EditConnection.vue: -------------------------------------------------------------------------------- 1 | 34 | 35 | -------------------------------------------------------------------------------- /src/render/src/components/icons/FolderIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/render/src/components/basics/ButtonContainerUi.vue: -------------------------------------------------------------------------------- 1 | 36 | 37 | -------------------------------------------------------------------------------- /src/render/src/components/icons/UserIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /forge.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | packagerConfig: { 3 | asar: true, 4 | icon: './build/resources/icons/app', 5 | ignore: [ 6 | '^/src($|/)', 7 | '^/.github($|/)', 8 | '^/.vscode($|/)', 9 | '^/forge.config.js$', 10 | '^/package-lock.json$', 11 | '^/database.json$', 12 | '^/.*\.log$', 13 | ], 14 | osxSign: {}, 15 | // osxNotarize: { 16 | // tool: 'notarytool', 17 | // appleId: process.env.APPLE_ID, 18 | // appleIdPassword: process.env.APPLE_PASSWORD, 19 | // teamId: process.env.APPLE_TEAM_ID 20 | // } 21 | }, 22 | rebuildConfig: {}, 23 | makers: [ 24 | { 25 | name: '@electron-forge/maker-squirrel', 26 | config: {}, 27 | }, 28 | { 29 | name: '@electron-forge/maker-zip', 30 | platforms: ['darwin'], 31 | }, 32 | { 33 | name: '@electron-forge/maker-deb', 34 | config: { 35 | options: { 36 | bin: 'Gabin', 37 | icon: './build/resources/icons/app.png', 38 | } 39 | }, 40 | }, 41 | ], 42 | plugins: [ 43 | { 44 | name: '@electron-forge/plugin-auto-unpack-natives', 45 | config: {}, 46 | }, 47 | ], 48 | publishers: [ 49 | { 50 | name: '@electron-forge/publisher-github', 51 | config: { 52 | repository: { 53 | owner: 'one-click-studio', 54 | name: 'gabin' 55 | }, 56 | prerelease: true, 57 | force: true 58 | } 59 | } 60 | ] 61 | }; 62 | -------------------------------------------------------------------------------- /src/render/src/components/basics/ModalUi.vue: -------------------------------------------------------------------------------- 1 | 19 | 20 | 45 | 46 | -------------------------------------------------------------------------------- /src/render/src/views/setup/SettingsView.vue: -------------------------------------------------------------------------------- 1 | 33 | 34 | -------------------------------------------------------------------------------- /src/render/README.md: -------------------------------------------------------------------------------- 1 | # Vue 3 + TypeScript + Vite 2 | 3 | This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 ` 18 | 19 | 31 | 32 | -------------------------------------------------------------------------------- /src/render/src/components/icons/PlusCircleIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/components/icons/BinIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/render/src/components/icons/PauseCircleIcon.vue: -------------------------------------------------------------------------------- 1 | 20 | -------------------------------------------------------------------------------- /src/render/src/components/icons/EyeIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/render/src/components/icons/InfoIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/components/icons/SmileIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 4 | "lib": ["es6"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 5 | "module": "commonjs", /* Specify what module code is generated. */ 6 | "rootDir": "src", /* Specify the root folder within your source files. */ 7 | "resolveJsonModule": true, /* Enable importing .json files. */ 8 | "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 9 | "outDir": "build", /* Specify an output folder for all emitted files. */ 10 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 11 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 12 | "strict": true, /* Enable all strict type-checking options. */ 13 | "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 14 | "skipLibCheck": true, /* Skip type checking all .d.ts files. */ 15 | "baseUrl": ".", 16 | "paths": { 17 | "@src/*": ["src/*"] 18 | } 19 | }, 20 | "include": [ 21 | "src/**/*" 22 | ], 23 | "exclude": [ 24 | "src/render/*" 25 | ] 26 | } -------------------------------------------------------------------------------- /src/render/src/components/basics/ToggleUi.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 45 | 46 | -------------------------------------------------------------------------------- /src/render/src/components/utils/KeyPress.vue: -------------------------------------------------------------------------------- 1 | 75 | -------------------------------------------------------------------------------- /src/render/src/components/icons/QuestionMarkIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: build-release 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - main 8 | - pre-release 9 | - test 10 | - macos-sequoia-crash 11 | 12 | jobs: 13 | build-and-publish: 14 | runs-on: ${{ matrix.os }} 15 | strategy: 16 | matrix: 17 | include: 18 | - os: macos-latest 19 | name: darwin 20 | arch: x64 21 | - os: macos-latest 22 | name: darwin 23 | arch: arm64 24 | - os: windows-latest 25 | name: win32 26 | arch: x64 27 | - os: ubuntu-latest 28 | name: linux 29 | arch: x64 30 | - os: ubuntu-latest 31 | name: linux 32 | arch: arm64 33 | fail-fast: false 34 | steps: 35 | - name: Checkout Repository 36 | uses: actions/checkout@v2 37 | 38 | - name: Decode and Install Certificate 39 | if: matrix.os == 'macos-latest' 40 | run: | 41 | echo ${{ secrets.MACOS_CERT }} | base64 --decode > certificate.p12 42 | security create-keychain -p action build.keychain 43 | security default-keychain -s build.keychain 44 | security unlock-keychain -p action build.keychain 45 | security import certificate.p12 -k build.keychain -P ${{ secrets.MACOS_CERT_PASSWORD }} -T /usr/bin/codesign 46 | security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k action build.keychain 47 | 48 | - name: Set up Node.js 49 | uses: actions/setup-node@v2 50 | with: 51 | node-version: '18' 52 | 53 | - name: Install Dependencies 54 | run: npm ci 55 | 56 | - name: Build Application 57 | run: npm run build 58 | 59 | - name: Publish Electron App 60 | env: 61 | APPLE_ID: ${{ secrets.APPLE_ID }} 62 | APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} 63 | APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} 64 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} 65 | run: npm run electron:publish -- --platform=${{ matrix.name }} --arch=${{ matrix.arch }} 66 | -------------------------------------------------------------------------------- /src/render/src/components/setup/SourcesTree.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 23 | 24 | 80 | -------------------------------------------------------------------------------- /src/render/src/components/basics/ToastUi.vue: -------------------------------------------------------------------------------- 1 | 36 | 37 | 50 | 51 | -------------------------------------------------------------------------------- /src/render/src/components/icons/CamIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/render/src/views/setup/IndexView.vue: -------------------------------------------------------------------------------- 1 | 55 | 56 | 61 | -------------------------------------------------------------------------------- /src/render/src/views/setup/VideoMixerView.vue: -------------------------------------------------------------------------------- 1 | 31 | 32 | -------------------------------------------------------------------------------- /src/render/src/components/basics/GabinFace.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 34 | 35 | -------------------------------------------------------------------------------- /src/render/src/components/icons/PaperClipIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/render/src/components/home/EditIcon.vue: -------------------------------------------------------------------------------- 1 | 36 | 37 | 74 | 75 | -------------------------------------------------------------------------------- /src/render/src/components/home/Connections.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 67 | 68 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gabin", 3 | "productName": "Gabin", 4 | "version": "0.2.18", 5 | "description": "Automate camera switching with OBS, Bitfocus Companion and any audio api.", 6 | "author": "OneClickStudio", 7 | "homepage": "https://oneclickstudio.fr", 8 | "repository": "github:one-click-studio/gabin", 9 | "main": "./build/main/index.js", 10 | "bin": "./build/main/index.js", 11 | "scripts": { 12 | "postinstall": "patch-package && npm --prefix ./src/render ci", 13 | "typecheck": "tsc --noEmit -p tsconfig.json --composite false", 14 | "build": "shx rm -rf ./build && concurrently \"npm run build:client\" \"npm run build:server\"", 15 | "build:server": "tsc && shx cp -R ./src/resources ./build/resources", 16 | "build:client": "npm --prefix ./src/render run build && shx mkdir -p ./build/render/dist && shx cp -R ./src/render/dist ./build/render", 17 | "clean": "shx rm -rf ./out && shx rm -rf ./build && shx rm -rf ./dist && shx rm -rf ./*-dist", 18 | "preview": "npm run build && npm run electron:start", 19 | "electron:start": "electron-forge start", 20 | "electron:package": "electron-forge package", 21 | "electron:make": "electron-forge make", 22 | "electron:publish": "electron-forge publish" 23 | }, 24 | "dependencies": { 25 | "audio-manager-node": "github:one-click-studio/audio-manager-node", 26 | "deep-eql": "^4.1.3", 27 | "dotenv": "^16.0.3", 28 | "electron-squirrel-startup": "^1.0.0", 29 | "fast-xml-parser": "^4.2.0", 30 | "finalhandler": "^1.2.0", 31 | "node-osc": "^9.1.4", 32 | "obs-websocket-js": "^5.0.2", 33 | "patch-package": "^8.0.0", 34 | "rxjs": "^7.8.0", 35 | "serve-static": "^1.15.0", 36 | "simple-json-db": "^2.0.0", 37 | "socket.io": "^4.6.0" 38 | }, 39 | "devDependencies": { 40 | "@electron-forge/cli": "^7.2.0", 41 | "@electron-forge/maker-deb": "^7.2.0", 42 | "@electron-forge/maker-rpm": "^7.2.0", 43 | "@electron-forge/maker-squirrel": "^7.2.0", 44 | "@electron-forge/maker-zip": "^7.2.0", 45 | "@electron-forge/plugin-auto-unpack-natives": "^7.2.0", 46 | "@electron-forge/publisher-github": "^7.2.0", 47 | "@types/deep-eql": "^4.0.0", 48 | "@types/finalhandler": "^1.2.0", 49 | "@types/node": "^18.13.0", 50 | "@types/node-osc": "^6.0.3", 51 | "@types/serve-static": "^1.15.0", 52 | "@types/wav": "^1.0.1", 53 | "concurrently": "^7.6.0", 54 | "cross-env": "^7.0.3", 55 | "electron": "^35.1.2", 56 | "nodemon": "^2.0.20", 57 | "shx": "^0.3.4", 58 | "ts-node": "^10.9.1", 59 | "typescript": "^5.0.3" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/render/src/components/icons/PizzaIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/components/utils/UtilsTools.vue: -------------------------------------------------------------------------------- 1 | 81 | -------------------------------------------------------------------------------- /src/render/src/layout/FooterLayout.vue: -------------------------------------------------------------------------------- 1 | 67 | 68 | -------------------------------------------------------------------------------- /src/render/src/components/icons/DownloadIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/views/setup/ProfileView.vue: -------------------------------------------------------------------------------- 1 | 56 | 57 | -------------------------------------------------------------------------------- /src/render/src/components/basics/InputUi.vue: -------------------------------------------------------------------------------- 1 | 48 | 49 | 74 | 75 | -------------------------------------------------------------------------------- /src/main/index.ts: -------------------------------------------------------------------------------- 1 | import { App, openApp } from './app' 2 | import { app as electronApp, systemPreferences, dialog } from 'electron' 3 | import { getLogger } from './utils/logger' 4 | const PackageJson = require('../../package.json') 5 | const DEFAULT = require('../resources/json/config.json') 6 | 7 | const logger = getLogger('main') 8 | 9 | // get args 10 | const args = process.argv.slice(2) 11 | 12 | if (args.includes('--help') || args.includes('-h')) { 13 | console.log(` 14 | Usage: gabin [options] 15 | Options: 16 | -h, --help Display this message 17 | -d, --debug Enable debug mode 18 | -v, --version Display version 19 | -s, --silent Hide logs (except errors & logs from plugins) 20 | --no-auto-open Disable auto open 21 | --autostart Enable autostart 22 | -p, --profile Profile to use 23 | 24 | Environment variables: 25 | GABIN_HOST Hostname to use (default: ${DEFAULT.HOST}) 26 | GABIN_HTTP_PORT Port to use (default: ${DEFAULT.HTTP_PORT}) 27 | GABIN_OSC_PORT Port to use (default: ${DEFAULT.OSC_PORT}) 28 | GABIN_BASE_URL Base url to use (default: ${DEFAULT.BASE_URL}) 29 | GABIN_LOGS_FOLDER Folder to store logs (default: $appdata/gabin/gabin.log) 30 | GABIN_CONFIG_FOLDER Folder to store config (default: $appdata/gabin/database.json) 31 | `) 32 | process.exit(0) 33 | } 34 | 35 | if (args.includes('--silent') || args.includes('-s')) { 36 | process.env.SILENT = 'true' 37 | } 38 | 39 | if (args.includes('--debug') || args.includes('-d')) { 40 | process.env.DEBUG = 'true' 41 | } 42 | 43 | if (args.includes('--version') || args.includes('-v')) { 44 | console.log('v' + PackageJson.version) 45 | process.exit(0) 46 | } 47 | 48 | const AUTO_OPEN = !args.includes('--no-auto-open') 49 | const AUTOSTART = args.includes('--autostart') 50 | 51 | let PROFILE: string|undefined = undefined 52 | if (args.includes('--profile') || args.includes('-p')) { 53 | const index = args.indexOf('--profile') 54 | const profile = args[index + 1] 55 | PROFILE = profile 56 | } 57 | 58 | const main = async () => { 59 | logger.info('Starting Gabin v' + PackageJson.version) 60 | 61 | 62 | electronApp.whenReady().then(async () => { 63 | if (process.platform === 'darwin') { 64 | if (electronApp.dock) { 65 | electronApp.dock.hide() 66 | } 67 | 68 | const hasAccess = await systemPreferences.askForMediaAccess('microphone'); 69 | if (!hasAccess) { 70 | await dialog.showMessageBox({ 71 | type: 'error', 72 | title: 'Microphone Access Denied', 73 | message: 'This application requires microphone access to function.' 74 | }) 75 | electronApp.quit() 76 | return 77 | } 78 | } 79 | 80 | const app = new App(AUTOSTART) 81 | await app.init(PROFILE) 82 | 83 | if (AUTO_OPEN) openApp() 84 | }) 85 | } 86 | 87 | main() 88 | -------------------------------------------------------------------------------- /src/render/src/components/icons/RocketIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/main/modules/setup.ts: -------------------------------------------------------------------------------- 1 | 2 | import { ObsServer } from '../../main/servers/ObsServer' 3 | import { OscClient } from '../../main/clients/OSCClient' 4 | import { VmixClient } from '../../main/clients/VMIXClient' 5 | import { Connections } from '../../main/servers/Connections' 6 | 7 | import { getDevices } from '../../main/modules/audioActivity' 8 | 9 | import db from '../../main/utils/db' 10 | 11 | import type { OscServer } from '../../main/servers/OscServer' 12 | import type { SpecificAndDefault } from '../../main/utils/db' 13 | import type { 14 | Connection, 15 | AudioDevice, 16 | } from '../../types/protocol' 17 | 18 | export class Setup { 19 | 20 | obs: ObsServer 21 | osc: OscClient 22 | vmix: VmixClient 23 | connections: Connections 24 | 25 | private profiles: SpecificAndDefault 26 | 27 | constructor(oscServer: OscServer) { 28 | this.osc = new OscClient(oscServer, false) 29 | this.obs = new ObsServer(false) 30 | this.vmix = new VmixClient(true) 31 | this.connections = new Connections() 32 | 33 | this.profiles = db.getSpecificAndDefault(['profiles'], false) 34 | 35 | this.profiles.configPart$.subscribe(v => { 36 | this.profiles.defaultValue = v 37 | }) 38 | } 39 | 40 | clean() { 41 | this.disconnectObs() 42 | this.disconnectOsc() 43 | this.disconnectVmix() 44 | 45 | this.obs.clean() 46 | this.osc.clean() 47 | this.vmix.clean() 48 | } 49 | 50 | connectObs(connection: Connection) { 51 | if (!this.obs.isReachable) { 52 | this.obs.connect(connection, true) 53 | } 54 | } 55 | 56 | disconnectObs() { 57 | if (this.obs.isReachable) { 58 | this.obs.clean() 59 | } 60 | } 61 | 62 | connectOsc(connection: Connection) { 63 | if (!this.osc.isReachable) { 64 | this.osc.connect(connection) 65 | } 66 | } 67 | 68 | disconnectOsc() { 69 | if (this.osc.isReachable) { 70 | this.osc.clean() 71 | } 72 | } 73 | 74 | sendOsc(path: string) { 75 | if (!this.osc.isReachable) return 76 | this.osc.send(path) 77 | } 78 | 79 | connectVmix(connection: Connection) { 80 | if (!this.vmix.isReachable) { 81 | this.vmix.connect(connection) 82 | } 83 | } 84 | 85 | disconnectVmix() { 86 | if (this.vmix.isReachable) { 87 | this.vmix.clean() 88 | } 89 | } 90 | 91 | } 92 | 93 | export const getAllAudioDevices = (): AudioDevice[] => { 94 | const aDevices: AudioDevice[] = [] 95 | 96 | const devices = getDevices() 97 | for (const d of devices) { 98 | if (!d.inputChannels) continue 99 | 100 | const host = d.host as unknown as string 101 | 102 | aDevices.push({ 103 | name: d.name, 104 | nChannels: d.inputChannels, 105 | host, 106 | }) 107 | } 108 | 109 | return aDevices 110 | } 111 | -------------------------------------------------------------------------------- /src/render/src/components/icons/UploadIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/layout/TimelineLayout.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 54 | 55 | -------------------------------------------------------------------------------- /src/main/clients/OBSClient.ts: -------------------------------------------------------------------------------- 1 | import { BehaviorSubject } from 'rxjs' 2 | 3 | import { ObsServer } from '../../main/servers/ObsServer' 4 | import { Client } from '../../main/clients/Client' 5 | 6 | import type { 7 | Asset, 8 | } from '../../types/protocol' 9 | 10 | export class ObsClient extends Client { 11 | 12 | scenes$: BehaviorSubject 13 | mainScene$: BehaviorSubject 14 | 15 | private obs: ObsServer 16 | 17 | constructor() { 18 | super('obs') 19 | 20 | this.obs = new ObsServer() 21 | this.scenes$ = this.obs.scenes$ 22 | this.mainScene$ = new BehaviorSubject(undefined) 23 | } 24 | 25 | init() { 26 | this.addSubscription( 27 | this.obs.reachable$.subscribe(r => { 28 | if (r !== this.isReachable){ 29 | this.reachable$.next(r) 30 | if (r){ 31 | this.sceneTransition(this.obs.initScene) 32 | } 33 | } 34 | }) 35 | ) 36 | 37 | this.scenes$.subscribe(scenes => { 38 | if (scenes.length > 0 && !this.isReachable){ 39 | this.sceneTransition(this.obs.initScene) 40 | } 41 | }) 42 | 43 | this.reachable$.subscribe(r => { 44 | if (r) { 45 | this.initWebsocket() 46 | } 47 | }) 48 | } 49 | 50 | override async connect() { 51 | super.connect() 52 | this.init() 53 | 54 | this.obs.connect() 55 | } 56 | 57 | override clean() { 58 | this.obs.clean() 59 | this.reachable$.next(false) 60 | 61 | super.clean() 62 | } 63 | 64 | private initWebsocket() { 65 | this.manageTransitions() 66 | } 67 | 68 | private manageTransitions() { 69 | this.obs.websocket.on('CurrentProgramSceneChanged', (data) => { 70 | this.logger.info(`scene changed to '${data.sceneName}'`) 71 | this.sceneTransition(data.sceneName) 72 | }) 73 | } 74 | 75 | private sceneTransition(sceneName: Asset['scene']['name']) { 76 | this.mainScene$.next(sceneName) 77 | } 78 | 79 | private onError(err: unknown) { 80 | this.logger.error(err) 81 | this.reachable$.next(false) 82 | } 83 | 84 | shoot(container: Asset['container'], source: Asset['source']) { 85 | if (!this.isReachable) { 86 | this.logger.error('Can\'t shoot, ObsWebsocket not connected') 87 | } 88 | 89 | const shots = container.sources 90 | const shot = shots.find(s => s.name === source.name) 91 | 92 | if (!shot) { 93 | this.logger.error('This shot does not exist', { source: source.name } ) 94 | return 95 | } 96 | 97 | this.obs.websocket 98 | .call('SetSceneItemEnabled', { 99 | sceneName: container.name, 100 | sceneItemId: shot.options.id, 101 | sceneItemEnabled: true 102 | }) 103 | .catch((err) => this.onError(err)) 104 | 105 | for (const shot_ of shots) { 106 | if (shot_.name === source.name) continue 107 | 108 | this.obs.websocket 109 | .call('SetSceneItemEnabled', { 110 | sceneName: container.name, 111 | sceneItemId: shot_.options.id, 112 | sceneItemEnabled: false, 113 | }) 114 | .catch((err) => this.onError(err)) 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/render/src/components/icons/SandwichIcon.vue: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /src/render/src/components/setup/OscTuto.vue: -------------------------------------------------------------------------------- 1 | 3 | 4 | 76 | 77 | -------------------------------------------------------------------------------- /src/render/src/layout/HeaderLayout.vue: -------------------------------------------------------------------------------- 1 | 62 | 63 | 120 | 121 | 126 | -------------------------------------------------------------------------------- /src/render/src/layout/GlobalLayout.vue: -------------------------------------------------------------------------------- 1 | 38 | 39 | 120 | -------------------------------------------------------------------------------- /src/render/src/App.vue: -------------------------------------------------------------------------------- 1 | 72 | 73 | 89 | 90 | -------------------------------------------------------------------------------- /src/render/src/components/icons/SettingsIcon.vue: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/main/utils/db.ts: -------------------------------------------------------------------------------- 1 | import JsonDb from 'simple-json-db' 2 | 3 | import path from 'path' 4 | import { app as electronApp } from 'electron' 5 | import dotenv from 'dotenv' 6 | import deepEqual from 'deep-eql' 7 | 8 | import { BehaviorSubject } from 'rxjs' 9 | import { map, distinctUntilChanged, skip } from 'rxjs/operators' 10 | import type { Observable } from 'rxjs' 11 | 12 | import { deepCopy } from '../../main/utils/utils' 13 | import type { ServerConfig } from '../../types/protocol' 14 | 15 | dotenv.config() 16 | 17 | // @ts-ignore 18 | const CONFIG_FILE = path.join((process.env.GABIN_CONFIG_FOLDER || (electronApp.isPackaged ? electronApp.getPath('userData') : '')), './database.json') 19 | 20 | const EMPTY_CONFIG = { 21 | profiles: [] 22 | } 23 | 24 | export interface SpecificAndDefault { 25 | configPart$: Observable 26 | defaultValue: any, 27 | edit: (data: any) => void 28 | } 29 | 30 | class ConfigServer { 31 | 32 | private db: JsonDb 33 | private _data: ServerConfig 34 | private _config$: BehaviorSubject 35 | config$: Observable 36 | 37 | constructor() { 38 | this.db = new JsonDb(CONFIG_FILE) 39 | 40 | this._data = this.db.JSON() as ServerConfig 41 | this._config$ = new BehaviorSubject(this._data) 42 | 43 | this.config$ = this._config$.pipe( 44 | distinctUntilChanged((a, b) => deepEqual(a, b)) 45 | ) 46 | } 47 | 48 | async connect () { 49 | this._data = this.db.JSON() as ServerConfig 50 | 51 | if (!this._data || !this._data.profiles ) { 52 | this._data = EMPTY_CONFIG 53 | } 54 | 55 | this._config$ = new BehaviorSubject(this._data) 56 | 57 | this.config$ = this._config$.pipe( 58 | distinctUntilChanged((a, b) => deepEqual(a, b)) 59 | ) 60 | 61 | this._config$ 62 | .pipe(skip(1)) 63 | .subscribe((data) => { 64 | this.saveConfig(data) 65 | }); 66 | } 67 | 68 | private getDataFromPath(path: string[], object: any, profile?: boolean): any { 69 | let data: any = object 70 | 71 | if (profile && data.profiles && data.profiles.length > 0) { 72 | 73 | for (const p of data.profiles) { 74 | if (p.active) { 75 | data = p 76 | break 77 | } 78 | } 79 | } 80 | 81 | for (const i in path){ 82 | data = data[path[i]] 83 | } 84 | return data 85 | } 86 | 87 | getSpecific(path: string[], profile?: boolean): Observable { 88 | return this._config$.pipe( 89 | map(object => this.getDataFromPath(path, object, profile)), 90 | distinctUntilChanged((a, b) => deepEqual(a, b)) 91 | ) 92 | } 93 | 94 | getDefaultValue(path: string[], profile?: boolean): any { 95 | return this.getDataFromPath(path, this.getConfigCopy(), profile) 96 | } 97 | 98 | async editSpecific(path: string[], data: any) { 99 | const _config = this.getConfigCopy() 100 | let _d: any = _config 101 | 102 | let i = 0 103 | for (i; i < path.length - 1; i++){ 104 | _d = _d[path[i]] 105 | } 106 | _d[path[i]] = data 107 | 108 | // await this.saveConfig(_config) 109 | this.editConfig(_config) 110 | } 111 | 112 | getSpecificAndDefault(path: string[], profile?: boolean): SpecificAndDefault { 113 | return { 114 | configPart$: this.getSpecific(path, profile), 115 | defaultValue: this.getDefaultValue(path, profile), 116 | edit: (data) => this.editSpecific(path, data) 117 | } 118 | } 119 | 120 | getConfigCopy(): ServerConfig { 121 | return deepCopy(this._data) 122 | } 123 | 124 | editConfig(data: ServerConfig) { 125 | this._config$.next(data) 126 | } 127 | 128 | private async saveConfig(data: ServerConfig){ 129 | this._data = data 130 | this.db.JSON(data) 131 | this.db.sync() 132 | } 133 | 134 | } 135 | 136 | const configServer = new ConfigServer() 137 | export default configServer 138 | -------------------------------------------------------------------------------- /src/main/utils/logger.ts: -------------------------------------------------------------------------------- 1 | import path from 'path' 2 | import fs from 'fs' 3 | import dotenv from 'dotenv' 4 | import { app as electronApp } from 'electron' 5 | 6 | const COLORS = { 7 | Reset : '\x1b[0m', 8 | Bright : '\x1b[1m', 9 | Dim : '\x1b[2m', 10 | Underscore : '\x1b[4m', 11 | Blink : '\x1b[5m', 12 | Reverse : '\x1b[7m', 13 | Hidden : '\x1b[8m', 14 | 15 | FgBlack : '\x1b[30m', 16 | FgRed : '\x1b[31m', 17 | FgGreen : '\x1b[32m', 18 | FgYellow : '\x1b[33m', 19 | FgBlue : '\x1b[34m', 20 | FgMagenta : '\x1b[35m', 21 | FgCyan : '\x1b[36m', 22 | FgWhite : '\x1b[37m', 23 | 24 | BgBlack : '\x1b[40m', 25 | BgRed : '\x1b[41m', 26 | BgGreen : '\x1b[42m', 27 | BgYellow : '\x1b[43m', 28 | BgBlue : '\x1b[44m', 29 | BgMagenta : '\x1b[45m', 30 | BgCyan : '\x1b[46m', 31 | BgWhite : '\x1b[47m', 32 | } 33 | 34 | type LogType = 'info' | 'debug' | 'warn' | 'error' 35 | type logFn = (obj: any, obj2?: any) => void 36 | export type Logger = { 37 | info : logFn 38 | debug : logFn 39 | warn : logFn 40 | error : logFn 41 | } 42 | 43 | export type Log = { 44 | type: LogType 45 | time: string 46 | context: string 47 | value: string 48 | } 49 | 50 | dotenv.config() 51 | 52 | const LOG_FILE = path.join((process.env.GABIN_LOGS_FOLDER || (electronApp.isPackaged ? electronApp.getPath('userData') : '')), './gabin.log') 53 | // create folder if not exists 54 | if (!fs.existsSync(path.dirname(LOG_FILE))) fs.mkdirSync(path.dirname(LOG_FILE), { recursive: true }) 55 | // create file if not exists 56 | if (!fs.existsSync(LOG_FILE)) fs.writeFileSync(LOG_FILE, '') 57 | 58 | const regulateLogSize = () => { 59 | const MAX_LOG_SIZE = 1000000 // 1MB 60 | const logSize = fs.statSync(LOG_FILE).size 61 | if (logSize > MAX_LOG_SIZE) { 62 | const data = fs.readFileSync(LOG_FILE, 'utf8') 63 | const lines = data.split('\n') 64 | 65 | const avg = logSize / lines.length 66 | const toDel = logSize - (MAX_LOG_SIZE/2) 67 | const delLines = Math.floor(toDel / avg) 68 | 69 | lines.splice(0, delLines) 70 | fs.writeFileSync(LOG_FILE, lines.join('\n')) 71 | } 72 | } 73 | 74 | regulateLogSize() 75 | 76 | const getTypeColor = (type: LogType): string => { 77 | switch (type) { 78 | case 'info': 79 | return COLORS.FgGreen 80 | case 'debug': 81 | return COLORS.FgBlue 82 | case 'error': 83 | return COLORS.FgRed 84 | case 'warn': 85 | return COLORS.FgYellow 86 | } 87 | 88 | return '' 89 | } 90 | 91 | const toString = (obj: any) => { 92 | if (!obj) { 93 | return '' 94 | } else if (obj instanceof Map){ 95 | return JSON.stringify(Array.from(obj.entries()), null, '\t') 96 | } else if (typeof obj === 'object' || typeof obj === 'function') { 97 | return JSON.stringify(obj, null, '\t') 98 | } 99 | 100 | return obj 101 | } 102 | 103 | export const getLogger = (name: string) => { 104 | 105 | const logger = (type: LogType, obj: any, obj2?: any) => { 106 | const d = new Date() 107 | const time = ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2) + ':' + ('0' + d.getSeconds()).slice(-2) 108 | 109 | const log: Log = { 110 | type, 111 | time, 112 | context: name, 113 | value: `${toString(obj)} ${toString(obj2)}`, 114 | } 115 | 116 | if (process.env.DEBUG !== 'true' && type === 'debug') return 117 | 118 | if (process.env.SILENT !== 'true') { 119 | process.stdout.write(`\n${getTypeColor(log.type)}${log.time}${COLORS.Bright} [${log.context}]${COLORS.Reset} ${log.value}`) 120 | } 121 | fs.appendFileSync(LOG_FILE, `\n${log.time} [${log.context}] : ${log.value}`) 122 | } 123 | 124 | const info = (obj: any, obj2?: any) => { 125 | logger('info', obj, obj2) 126 | } 127 | 128 | const debug = (obj: any, obj2?: any) => { 129 | logger('debug', obj, obj2) 130 | } 131 | 132 | const error = (obj: any, obj2?: any) => { 133 | logger('error', obj, obj2) 134 | } 135 | 136 | const warn = (obj: any, obj2?: any) => { 137 | logger('warn', obj, obj2) 138 | } 139 | 140 | return { info, debug, error, warn } 141 | } -------------------------------------------------------------------------------- /src/render/src/views/setup/LandingView.vue: -------------------------------------------------------------------------------- 1 | 107 | 108 | 141 | -------------------------------------------------------------------------------- /src/render/src/views/setup/ObsView.vue: -------------------------------------------------------------------------------- 1 | 86 | 87 | -------------------------------------------------------------------------------- /src/main/clients/OSCClient.ts: -------------------------------------------------------------------------------- 1 | import { BehaviorSubject, Subject } from 'rxjs' 2 | 3 | import { Client } from '../../main/clients/Client' 4 | 5 | import db from '../../main/utils/db' 6 | 7 | import type { OscServer } from '../../main/servers/OscServer' 8 | import type { 9 | Asset, 10 | MicId, 11 | Connection 12 | } from '../../types/protocol' 13 | 14 | export class OscClient extends Client { 15 | 16 | mainScene$: BehaviorSubject 17 | triggeredShot$: BehaviorSubject 18 | autocam$: BehaviorSubject 19 | micAvailability$: Subject<{mic: MicId, available: boolean}> 20 | 21 | private osc: OscServer 22 | private config: Connection | undefined 23 | 24 | constructor(osc: OscServer, fromProfile = true) { 25 | super('osc-client') 26 | 27 | this.osc = osc 28 | 29 | this.mainScene$ = new BehaviorSubject(undefined) 30 | this.triggeredShot$ = new BehaviorSubject(undefined) 31 | this.autocam$ = new BehaviorSubject(true) 32 | this.micAvailability$ = new Subject() 33 | 34 | if (fromProfile) this.getConfigFromProfile() 35 | 36 | } 37 | 38 | private getConfigFromProfile() { 39 | const config = db.getSpecificAndDefault(['connections', 'osc'], true) 40 | this.config = config.defaultValue 41 | } 42 | 43 | private splitIp(ip: string) { 44 | const c = ip.split(':') 45 | return { 46 | host: c[0], 47 | port: parseInt(c[1]) 48 | } 49 | } 50 | 51 | private init(connection?: Connection) { 52 | if (connection) { 53 | this.config = connection 54 | } 55 | 56 | this.addCommands() 57 | 58 | this.reachable$.next(true) 59 | } 60 | 61 | private addCommands() { 62 | this.osc.on('/scene/.*', (message: any) => { 63 | const scene = message.address.split('/').pop() 64 | this.sceneTransition(scene) 65 | }) 66 | this.osc.on('/source/.*', (message: any) => { 67 | const source = message.address.split('/').pop() 68 | this.sourceTrigger(source) 69 | }) 70 | this.osc.on('/mic/.*', (message: any) => { 71 | if (!message.args.length || [0,1].indexOf(message.args[0]) === -1) return 72 | 73 | const mic = message.address.split('/').pop() 74 | const available = (message.args[0]===1) 75 | this.availableMic(mic, available) 76 | }) 77 | this.osc.on('/autocam', (message: any) => { 78 | if (!message.args.length || [0,1].indexOf(message.args[0]) === -1) return 79 | const autocam = (message.args[0]===1) 80 | this.autocam(autocam) 81 | }) 82 | } 83 | 84 | override connect(connection?: Connection) { 85 | super.connect() 86 | this.init(connection) 87 | } 88 | 89 | send(path: string) { 90 | if (!this.config) return 91 | 92 | const clientIp = this.splitIp(this.config.ip) 93 | this.osc.send(path, clientIp.port, clientIp.host) 94 | } 95 | 96 | override clean() { 97 | this.reachable$.next(false) 98 | 99 | super.clean() 100 | } 101 | 102 | private sceneTransition(sceneName: Asset['scene']['name']) { 103 | this.mainScene$.next(sceneName) 104 | } 105 | 106 | private availableMic(mic: MicId, available: boolean) { 107 | this.micAvailability$.next({mic, available}) 108 | } 109 | 110 | private autocam(autocam: boolean) { 111 | this.autocam$.next(autocam) 112 | } 113 | 114 | private sourceTrigger(sourceName: Asset['source']['name']) { 115 | this.triggeredShot$.next(sourceName) 116 | } 117 | 118 | shoot(container: Asset['container'], source: Asset['source']) { 119 | if (!this.isReachable || !this.osc.isReachable) { 120 | this.logger.error('Can\'t shoot, osc not connected') 121 | } 122 | 123 | const scene_ = this.mainScene$.getValue() 124 | if (!scene_) { 125 | this.logger.error('Can\'t shoot, no scene selected') 126 | return 127 | } 128 | 129 | const shot = container.sources.find(s => s.name === source.name) 130 | if (!shot) { 131 | this.logger.error('This shot does not exist', { scene: this.mainScene$.getValue(), container: container.name, source: source.name } ) 132 | return 133 | } 134 | 135 | this.send(shot.options.path) 136 | } 137 | 138 | } 139 | -------------------------------------------------------------------------------- /src/render/src/views/RunningView.vue: -------------------------------------------------------------------------------- 1 | 84 | 85 | 122 | 123 | -------------------------------------------------------------------------------- /src/render/src/views/setup/VmixView.vue: -------------------------------------------------------------------------------- 1 | 90 | 91 | -------------------------------------------------------------------------------- /src/render/src/components/setup/VmixTuto.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 92 | 93 | -------------------------------------------------------------------------------- /src/render/src/views/setup/OscView.vue: -------------------------------------------------------------------------------- 1 | 91 | 92 | -------------------------------------------------------------------------------- /src/main/modules/profiles.ts: -------------------------------------------------------------------------------- 1 | import { Subject } from 'rxjs' 2 | 3 | import db from '../utils/db' 4 | import type { SpecificAndDefault } from '../utils/db' 5 | 6 | import type { 7 | Profile, 8 | AudioDevice, 9 | Thresholds, 10 | } from '../../types/protocol' 11 | 12 | export class Profiles { 13 | 14 | default$: Subject 15 | private profiles: SpecificAndDefault 16 | 17 | constructor() { 18 | this.profiles = db.getSpecificAndDefault(['profiles'], false) 19 | 20 | this.profiles.configPart$.subscribe(v => { 21 | this.profiles.defaultValue = v 22 | }) 23 | 24 | this.default$ = new Subject() 25 | } 26 | 27 | private getProfiles(): Profile[] { 28 | const profiles = this.profiles.defaultValue 29 | return profiles || [] 30 | } 31 | 32 | private getIndex(id: Profile['id'], profiles: Profile[]): number { 33 | const ids = profiles.map(p => p.id) 34 | return ids.indexOf(id) 35 | } 36 | 37 | private save(profiles: Profile[]) { 38 | this.profiles.edit(profiles) 39 | this.profiles.defaultValue = profiles 40 | } 41 | 42 | private isValid(profile: Profile): boolean { 43 | if (typeof profile !== 'object') return false 44 | 45 | if (profile.hasOwnProperty('id') && typeof profile.id !== 'number') return false 46 | if (profile.hasOwnProperty('name') && typeof profile.name !== 'string') return false 47 | if (profile.hasOwnProperty('settings') && typeof profile.settings !== 'object') return false 48 | 49 | return true 50 | } 51 | 52 | getAll(): Profile[] { 53 | return this.getProfiles() 54 | } 55 | 56 | set(profile: Profile) { 57 | if (!this.isValid(profile)) return 58 | 59 | const profiles = this.getProfiles() 60 | const index = this.getIndex(profile.id, profiles) 61 | 62 | // new profile 63 | if (index === -1) { 64 | profiles.push(profile) 65 | } else { 66 | profiles[index] = profile 67 | } 68 | 69 | this.save(profiles) 70 | this.setDefault(profile.id) 71 | } 72 | 73 | delete(id: Profile['id']) { 74 | const profiles = this.getProfiles() 75 | 76 | const index = this.getIndex(id, profiles) 77 | 78 | if (index > -1) { 79 | profiles.splice(index, 1) 80 | } 81 | 82 | this.save(profiles) 83 | if (profiles.length > 0){ 84 | this.setDefault(profiles[0].id) 85 | } 86 | } 87 | 88 | setDefault(id: Profile['id']) { 89 | const profiles = this.getProfiles() 90 | if (this.getIndex(id, profiles) === -1) return 91 | 92 | for (const i in profiles) { 93 | profiles[i].active = (profiles[i].id === id) 94 | } 95 | 96 | this.default$.next(id) 97 | this.save(profiles) 98 | } 99 | 100 | setDefaultByName(name: Profile['name']) { 101 | const profiles = this.getProfiles() 102 | const profile = profiles.find(p => p.name === name) 103 | if (!profile) return 104 | 105 | for (const i in profiles) { 106 | profiles[i].active = (profiles[i].name === name) 107 | } 108 | 109 | this.default$.next(profile.id) 110 | this.save(profiles) 111 | } 112 | 113 | setName(id: Profile['id'], name: Profile['name']) { 114 | const profiles = this.getProfiles() 115 | 116 | const index = this.getIndex(id, profiles) 117 | if (index > -1) { 118 | profiles[index].name = name 119 | } 120 | 121 | this.save(profiles) 122 | } 123 | 124 | setIcon(id: Profile['id'], icon: Profile['icon']) { 125 | const profiles = this.getProfiles() 126 | 127 | const index = this.getIndex(id, profiles) 128 | if (index > -1) { 129 | profiles[index].icon = icon 130 | } 131 | 132 | this.save(profiles) 133 | } 134 | 135 | setAutostart(id: Profile['id'], autostart: Profile['autostart']) { 136 | const profiles = this.getProfiles() 137 | const index = this.getIndex(id, profiles) 138 | 139 | if (index > -1) { 140 | profiles[index].autostart = autostart 141 | } 142 | 143 | this.save(profiles) 144 | } 145 | 146 | setRecord(id: Profile['id'], record: Profile['record']) { 147 | const profiles = this.getProfiles() 148 | const index = this.getIndex(id, profiles) 149 | 150 | if (index > -1) { 151 | profiles[index].record = record 152 | } 153 | 154 | this.save(profiles) 155 | } 156 | 157 | setThresholds(id: Profile['id'], deviceName: AudioDevice['name'], thresholds: Thresholds) { 158 | const profiles = this.getProfiles() 159 | const index = this.getIndex(id, profiles) 160 | 161 | if (index > -1) { 162 | for (const i in profiles[index].settings.mics) { 163 | if (profiles[index].settings.mics[i].name === deviceName) { 164 | profiles[index].settings.mics[i].thresholds = thresholds 165 | break 166 | } 167 | } 168 | } 169 | 170 | this.save(profiles) 171 | } 172 | 173 | } 174 | --------------------------------------------------------------------------------