-
+
+
+
+ Desktop-App Version: {version}
+
diff --git a/desktop/local-app/src/views/Settings.svelte b/desktop/local-app/src/views/Settings.svelte
new file mode 100644
index 00000000..1d77c9e8
--- /dev/null
+++ b/desktop/local-app/src/views/Settings.svelte
@@ -0,0 +1,59 @@
+
+
+
+
Settings
+
+
+ {#if $shortCuts}
+
+ saveShortcut("mute_toggle", e.detail)}
+ />
+
+
+
+ saveShortcut("camera_toggle", e.detail)}
+ />
+
+ {/if}
+
+
+ {}}
+ />
+
+
+
diff --git a/desktop/local-app/tsconfig.json b/desktop/local-app/tsconfig.json
index 4d6c04cf..95b38cca 100644
--- a/desktop/local-app/tsconfig.json
+++ b/desktop/local-app/tsconfig.json
@@ -13,7 +13,10 @@
* of JS in `.svelte` files.
*/
"allowJs": true,
- "checkJs": true
+ "checkJs": true,
+ "paths": {
+ "~/*": ["./*"]
+ }
},
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
"references": [{ "path": "./tsconfig.node.json" }]
diff --git a/desktop/local-app/tsconfig.node.json b/desktop/local-app/tsconfig.node.json
index e993792c..a336f895 100644
--- a/desktop/local-app/tsconfig.node.json
+++ b/desktop/local-app/tsconfig.node.json
@@ -2,7 +2,8 @@
"compilerOptions": {
"composite": true,
"module": "esnext",
- "moduleResolution": "node"
+ "moduleResolution": "node",
+ "allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
diff --git a/desktop/local-app/vite.config.ts b/desktop/local-app/vite.config.ts
index ed8db069..3f04d93d 100644
--- a/desktop/local-app/vite.config.ts
+++ b/desktop/local-app/vite.config.ts
@@ -1,7 +1,26 @@
import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import WindiCSS from "vite-plugin-windicss";
+import { svelteSVG } from "rollup-plugin-svelte-svg";
+import path from "path";
export default defineConfig({
- plugins: [svelte(), WindiCSS()],
+ resolve: {
+ alias: {
+ "~": `${path.resolve(__dirname, "src")}/`,
+ },
+ },
+ plugins: [
+ svelte(),
+ svelteSVG({
+ // optional SVGO options
+ // pass empty object to enable defaults
+ svgo: {},
+ // vite-specific
+ // https://vitejs.dev/guide/api-plugin.html#plugin-ordering
+ // enforce: 'pre' | 'post'
+ enforce: "pre",
+ }),
+ WindiCSS(),
+ ],
});
diff --git a/desktop/local-app/yarn.lock b/desktop/local-app/yarn.lock
index 5f03ded2..38ed531c 100644
--- a/desktop/local-app/yarn.lock
+++ b/desktop/local-app/yarn.lock
@@ -2,6 +2,11 @@
# yarn lockfile v1
+"@16bits/nes.css@^2.3.2":
+ version "2.3.2"
+ resolved "https://registry.yarnpkg.com/@16bits/nes.css/-/nes.css-2.3.2.tgz#e69db834119b33ae8d3cb044f106a07a17cadd6f"
+ integrity sha512-nEM5PIth+Bab5JSOa4uUR+PMNUsNTYxA55oVlG3gXI/4LoYtWS767Uv9Pu/KCbHXVvnIjt4ZXt13kZw3083qTw==
+
"@antfu/utils@^0.4.0":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@antfu/utils/-/utils-0.4.0.tgz#df100ed9922d7359bf6c99083765b5207086b9a7"
@@ -9,6 +14,11 @@
dependencies:
"@types/throttle-debounce" "^2.1.0"
+"@fontsource/press-start-2p@^4.5.2":
+ version "4.5.2"
+ resolved "https://registry.yarnpkg.com/@fontsource/press-start-2p/-/press-start-2p-4.5.2.tgz#062d56ce6dcffdd28f8ca80d9e5b86a473a37c15"
+ integrity sha512-1Wwk85zlUiirPTIw25V3z4wLXbrqaOqDV7g5akjPuthg+hY5Wv0zOPXcHRVBwb+Igh4qVLHUd6O5X27BgWTbkg==
+
"@nodelib/fs.scandir@2.1.5":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
@@ -49,6 +59,11 @@
magic-string "^0.25.7"
svelte-hmr "^0.14.9"
+"@trysound/sax@0.2.0":
+ version "0.2.0"
+ resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad"
+ integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==
+
"@tsconfig/svelte@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@tsconfig/svelte/-/svelte-2.0.1.tgz#0e8d7caa693e9b2afce5e622c0475bb0fd89c12c"
@@ -116,6 +131,11 @@ binary-extensions@^2.0.0:
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==
+boolbase@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"
+ integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24=
+
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
@@ -156,11 +176,47 @@ chokidar@^3.4.1:
optionalDependencies:
fsevents "~2.3.2"
+commander@^7.2.0:
+ version "7.2.0"
+ resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"
+ integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==
+
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
+css-select@^4.1.3:
+ version "4.2.1"
+ resolved "https://registry.yarnpkg.com/css-select/-/css-select-4.2.1.tgz#9e665d6ae4c7f9d65dbe69d0316e3221fb274cdd"
+ integrity sha512-/aUslKhzkTNCQUB2qTX84lVmfia9NyjP3WpDGtj/WxhwBzWBYUV3DgUpurHTme8UTPcPlAD1DJ+b0nN/t50zDQ==
+ dependencies:
+ boolbase "^1.0.0"
+ css-what "^5.1.0"
+ domhandler "^4.3.0"
+ domutils "^2.8.0"
+ nth-check "^2.0.1"
+
+css-tree@^1.1.2, css-tree@^1.1.3:
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.1.3.tgz#eb4870fb6fd7707327ec95c2ff2ab09b5e8db91d"
+ integrity sha512-tRpdppF7TRazZrjJ6v3stzv93qxRcSsFmW6cX0Zm2NVKpxE1WV1HblnghVv9TreireHkqI/VDEsfolRF1p6y7Q==
+ dependencies:
+ mdn-data "2.0.14"
+ source-map "^0.6.1"
+
+css-what@^5.1.0:
+ version "5.1.0"
+ resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.1.0.tgz#3f7b707aadf633baf62c2ceb8579b545bb40f7fe"
+ integrity sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw==
+
+csso@^4.2.0:
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/csso/-/csso-4.2.0.tgz#ea3a561346e8dc9f546d6febedd50187cf389529"
+ integrity sha512-wvlcdIbf6pwKEk7vHj8/Bkc0B4ylXZruLvOgs9doS5eOsOpuodOV2zJChSpkp+pRpYQLQMeF04nr3Z68Sta9jA==
+ dependencies:
+ css-tree "^1.1.2"
+
debug@^4.3.3:
version "4.3.3"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664"
@@ -178,6 +234,41 @@ detect-indent@^6.0.0:
resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.1.0.tgz#592485ebbbf6b3b1ab2be175c8393d04ca0d57e6"
integrity sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==
+dom-serializer@^1.0.1:
+ version "1.3.2"
+ resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.3.2.tgz#6206437d32ceefaec7161803230c7a20bc1b4d91"
+ integrity sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==
+ dependencies:
+ domelementtype "^2.0.1"
+ domhandler "^4.2.0"
+ entities "^2.0.0"
+
+domelementtype@^2.0.1, domelementtype@^2.2.0:
+ version "2.2.0"
+ resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.2.0.tgz#9a0b6c2782ed6a1c7323d42267183df9bd8b1d57"
+ integrity sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==
+
+domhandler@^4.2.0, domhandler@^4.3.0:
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.3.0.tgz#16c658c626cf966967e306f966b431f77d4a5626"
+ integrity sha512-fC0aXNQXqKSFTr2wDNZDhsEYjCiYsDWl3D01kwt25hm1YIPyDGHvvi3rw+PLqHAl/m71MaiF7d5zvBr0p5UB2g==
+ dependencies:
+ domelementtype "^2.2.0"
+
+domutils@^2.8.0:
+ version "2.8.0"
+ resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135"
+ integrity sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==
+ dependencies:
+ dom-serializer "^1.0.1"
+ domelementtype "^2.2.0"
+ domhandler "^4.2.0"
+
+entities@^2.0.0:
+ version "2.2.0"
+ resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55"
+ integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==
+
es6-promise@^3.1.2:
version "3.3.1"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.3.1.tgz#a08cdde84ccdbf34d027a1451bc91d4bcd28a613"
@@ -303,6 +394,11 @@ esbuild@^0.14.14:
esbuild-windows-64 "0.14.23"
esbuild-windows-arm64 "0.14.23"
+estree-walker@^0.6.1:
+ version "0.6.1"
+ resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362"
+ integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==
+
estree-walker@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac"
@@ -379,6 +475,11 @@ has@^1.0.3:
dependencies:
function-bind "^1.1.1"
+hotkeys-js@^3.8.7:
+ version "3.8.7"
+ resolved "https://registry.yarnpkg.com/hotkeys-js/-/hotkeys-js-3.8.7.tgz#c16cab978b53d7242f860ca3932e976b92399981"
+ integrity sha512-ckAx3EkUr5XjDwjEHDorHxRO2Kb7z6Z2Sxul4MbBkN8Nho7XDslQsgMJT+CiJ5Z4TgRxxvKHEpuLE3imzqy4Lg==
+
import-fresh@^3.2.1:
version "3.3.0"
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b"
@@ -460,6 +561,11 @@ magic-string@^0.25.7:
dependencies:
sourcemap-codec "^1.4.4"
+mdn-data@2.0.14:
+ version "2.0.14"
+ resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.14.tgz#7113fc4281917d63ce29b43446f701e68c25ba50"
+ integrity sha512-dn6wd0uw5GsdswPFfsgMp5NSB0/aDe6fK94YJV/AJDYXL6HVLWBsxeq7js7Ad+mU2K9LAlwpk6kN2D5mwCPVow==
+
merge2@^1.3.0:
version "1.4.1"
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
@@ -525,6 +631,13 @@ normalize-path@^3.0.0, normalize-path@~3.0.0:
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
+nth-check@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-2.0.1.tgz#2efe162f5c3da06a28959fbd3db75dbeea9f0fc2"
+ integrity sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w==
+ dependencies:
+ boolbase "^1.0.0"
+
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
@@ -576,6 +689,11 @@ postcss@^8.4.6:
picocolors "^1.0.0"
source-map-js "^1.0.2"
+prettier-plugin-svelte@^2.6.0:
+ version "2.6.0"
+ resolved "https://registry.yarnpkg.com/prettier-plugin-svelte/-/prettier-plugin-svelte-2.6.0.tgz#0e845b560b55cd1d951d6c50431b4949f8591746"
+ integrity sha512-NPSRf6Y5rufRlBleok/pqg4+1FyGsL0zYhkYP6hnueeL1J/uCm3OfOZPsLX4zqD9VAdcXfyEL2PYqGv8ZoOSfA==
+
prettier@^2.5.1:
version "2.5.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a"
@@ -619,6 +737,21 @@ rimraf@^2.5.2:
dependencies:
glob "^7.1.3"
+rollup-plugin-svelte-svg@^1.0.0-beta.6:
+ version "1.0.0-beta.6"
+ resolved "https://registry.yarnpkg.com/rollup-plugin-svelte-svg/-/rollup-plugin-svelte-svg-1.0.0-beta.6.tgz#0ee3deae2329abb1c90f50b83598aaf0bb0559fc"
+ integrity sha512-6uJb9kuaqK6p+DvkgphhGN18wvUzdT6h7MQC2B8P1omi9omC9lQC54pwaot21h6z9ibhGPLG9a1XFLeDQth/kg==
+ dependencies:
+ rollup-pluginutils "^2.8.2"
+ svgo "^2.3.1"
+
+rollup-pluginutils@^2.8.2:
+ version "2.8.2"
+ resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
+ integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==
+ dependencies:
+ estree-walker "^0.6.1"
+
rollup@^2.59.0:
version "2.67.3"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.67.3.tgz#3f04391fc296f807d067c9081d173e0a33dbd37e"
@@ -665,6 +798,11 @@ source-map-js@^1.0.2:
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c"
integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==
+source-map@^0.6.1:
+ version "0.6.1"
+ resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
+ integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
+
source-map@^0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
@@ -675,6 +813,11 @@ sourcemap-codec@^1.3.0, sourcemap-codec@^1.4.4:
resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"
integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==
+stable@^0.1.8:
+ version "0.1.8"
+ resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.8.tgz#836eb3c8382fe2936feaf544631017ce7d47a3cf"
+ integrity sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==
+
strip-indent@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-3.0.0.tgz#c32e1cee940b6b3432c771bc2c54bcce73cd3001"
@@ -739,6 +882,19 @@ svelte@^3.44.0:
resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.46.4.tgz#0c46bc4a3e20a2617a1b7dc43a722f9d6c084a38"
integrity sha512-qKJzw6DpA33CIa+C/rGp4AUdSfii0DOTCzj/2YpSKKayw5WGSS624Et9L1nU1k2OVRS9vaENQXp2CVZNU+xvIg==
+svgo@^2.3.1:
+ version "2.8.0"
+ resolved "https://registry.yarnpkg.com/svgo/-/svgo-2.8.0.tgz#4ff80cce6710dc2795f0c7c74101e6764cfccd24"
+ integrity sha512-+N/Q9kV1+F+UeWYoSiULYo4xYSDQlTgb+ayMobAXPwMnLvop7oxKMo9OzIrX5x3eS4L4f2UHhc9axXwY8DpChg==
+ dependencies:
+ "@trysound/sax" "0.2.0"
+ commander "^7.2.0"
+ css-select "^4.1.3"
+ css-tree "^1.1.3"
+ csso "^4.2.0"
+ picocolors "^1.0.0"
+ stable "^0.1.8"
+
to-regex-range@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"
diff --git a/desktop/src/app.ts b/desktop/src/app.ts
index 26b1d57a..b37f13b5 100644
--- a/desktop/src/app.ts
+++ b/desktop/src/app.ts
@@ -3,11 +3,12 @@ import { app, BrowserWindow, globalShortcut } from "electron";
import { createWindow, getWindow } from "./window";
import { createTray } from "./tray";
import autoUpdater from "./auto-updater";
-import updateAutoLaunch from "./update-auto-launch";
-import ipc, { emitMutedKeyPress } from "./ipc";
+import { updateAutoLaunch } from "./auto-launch";
+import ipc from "./ipc";
import settings from "./settings";
import { setLogLevel } from "./log";
import "./serve"; // prepare custom url scheme
+import { loadShortcuts } from "./shortcuts";
function init() {
const appLock = app.requestSingleInstanceLock();
@@ -56,10 +57,7 @@ function init() {
await createWindow();
createTray();
- // TODO
- globalShortcut.register("Alt+CommandOrControl+M", () => {
- emitMutedKeyPress();
- });
+ loadShortcuts();
});
// Quit when all windows are closed.
@@ -81,6 +79,10 @@ function init() {
app.on("quit", () => {
// TODO
});
+
+ app.on("will-quit", () => {
+ globalShortcut.unregisterAll();
+ });
}
export default {
diff --git a/desktop/src/update-auto-launch.ts b/desktop/src/auto-launch.ts
similarity index 88%
rename from desktop/src/update-auto-launch.ts
rename to desktop/src/auto-launch.ts
index 678463f4..3fac24bf 100644
--- a/desktop/src/update-auto-launch.ts
+++ b/desktop/src/auto-launch.ts
@@ -1,10 +1,10 @@
import AutoLaunch from "auto-launch";
-import isDev from "electron-is-dev";
import { app } from "electron";
+import electronIsDev from "electron-is-dev";
import settings from "./settings";
-export default async () => {
+export async function updateAutoLaunch() {
let isAutoLaunchEnabled = settings.get("auto_launch_enabled");
// set default to enabled
@@ -14,7 +14,7 @@ export default async () => {
}
// Don't run this in development
- if (isDev) {
+ if (electronIsDev) {
return;
}
@@ -38,4 +38,4 @@ export default async () => {
openAtLogin: isAutoLaunchEnabled,
openAsHidden: true,
});
-};
+}
diff --git a/desktop/src/ipc.ts b/desktop/src/ipc.ts
index e8568c83..08a40dd0 100644
--- a/desktop/src/ipc.ts
+++ b/desktop/src/ipc.ts
@@ -1,21 +1,32 @@
-import { ipcMain } from "electron";
+import { ipcMain, app } from "electron";
import electronIsDev from "electron-is-dev";
import { createAndShowNotification } from "./notification";
import { Server } from "./preload-local-app/types";
import settings from "./settings";
+import { saveShortcut } from "./shortcuts";
import { getWindow, hideAppView, showAppView } from "./window";
-export function emitMutedKeyPress() {
+export function emitMuteToggle() {
const mainWindow = getWindow();
if (!mainWindow) {
throw new Error("Main window not found");
}
- mainWindow.webContents.send("app:on-muted-key-press");
+ mainWindow.webContents.send("app:on-camera-toggle");
+}
+
+export function emitCameraToggle() {
+ const mainWindow = getWindow();
+ if (!mainWindow) {
+ throw new Error("Main window not found");
+ }
+
+ mainWindow.webContents.send("app:on-mute-toggle");
}
export default () => {
ipcMain.handle("is-development", () => electronIsDev);
+ ipcMain.handle("get-version", () => (electronIsDev ? "dev" : app.getVersion()));
// app ipc
ipcMain.on("app:notify", (event, txt) => {
@@ -30,6 +41,7 @@ export default () => {
ipcMain.handle("local-app:getServers", () => {
return (
settings.get("servers") || [
+ // TODO: remove this default server
{
_id: "1",
name: "WA Demo",
@@ -51,8 +63,17 @@ export default () => {
return true;
});
- ipcMain.handle("local-app:addServer", (event, server: Omit
) => {
+ ipcMain.handle("local-app:addServer", async (event, server: Omit) => {
const servers = settings.get("servers") || [];
+
+ try {
+ // TODO: add proper test to see if server url is valid and points to a real WA server
+ await fetch(`${server.url}/iframe_api.js`);
+ } catch (e) {
+ console.error(e);
+ return new Error("Invalid server url");
+ }
+
const newServer = {
...server,
_id: `${servers.length + 1}`,
@@ -70,4 +91,8 @@ export default () => {
);
return true;
});
+
+ ipcMain.handle("local-app:saveShortcut", (event, shortcut, key) => saveShortcut(shortcut, key));
+
+ ipcMain.handle("local-app:getShortcuts", (event) => settings.get("shortcuts") || {});
};
diff --git a/desktop/src/preload-app/preload.ts b/desktop/src/preload-app/preload.ts
index 860fee5a..13ea7105 100644
--- a/desktop/src/preload-app/preload.ts
+++ b/desktop/src/preload-app/preload.ts
@@ -1,12 +1,14 @@
import { contextBridge, ipcRenderer, IpcRendererEvent } from "electron";
+import { SettingsData } from "src/settings";
import type { WorkAdventureDesktopApi } from "./types";
const api: WorkAdventureDesktopApi = {
desktop: true,
isDevelopment: () => ipcRenderer.invoke("is-development"),
+ getVersion: () => ipcRenderer.invoke("get-version"),
notify: (txt: string) => ipcRenderer.send("app:notify", txt),
- onMutedKeyPress: (callback: (event: IpcRendererEvent) => void) =>
- ipcRenderer.on("app:on-muted-key-press", callback),
+ onMuteToggle: (callback: (event: IpcRendererEvent) => void) => ipcRenderer.on("app:on-mute-toggle", callback),
+ onCameraToggle: (callback: (event: IpcRendererEvent) => void) => ipcRenderer.on("app:on-camera-toggle", callback),
};
contextBridge.exposeInMainWorld("WorkAdventureDesktopApi", api);
diff --git a/desktop/src/preload-app/types.ts b/desktop/src/preload-app/types.ts
index df08c97c..6b004a0f 100644
--- a/desktop/src/preload-app/types.ts
+++ b/desktop/src/preload-app/types.ts
@@ -3,6 +3,8 @@ import type { IpcRendererEvent } from "electron";
export type WorkAdventureDesktopApi = {
desktop: boolean;
isDevelopment: () => Promise;
+ getVersion: () => Promise;
notify: (txt: string) => void;
- onMutedKeyPress: (callback: (event: IpcRendererEvent) => void) => void;
+ onMuteToggle: (callback: (event: IpcRendererEvent) => void) => void;
+ onCameraToggle: (callback: (event: IpcRendererEvent) => void) => void;
};
diff --git a/desktop/src/preload-local-app/preload.ts b/desktop/src/preload-local-app/preload.ts
index 527085aa..48145a96 100644
--- a/desktop/src/preload-local-app/preload.ts
+++ b/desktop/src/preload-local-app/preload.ts
@@ -1,14 +1,19 @@
import { contextBridge, ipcRenderer } from "electron";
+import { SettingsData } from "src/settings";
import type { Server, WorkAdventureLocalAppApi } from "./types";
const api: WorkAdventureLocalAppApi = {
desktop: true,
isDevelopment: () => ipcRenderer.invoke("is-development"),
+ getVersion: () => ipcRenderer.invoke("get-version"),
showLocalApp: () => ipcRenderer.invoke("local-app:showLocalApp"),
getServers: () => ipcRenderer.invoke("local-app:getServers"),
selectServer: (serverId: string) => ipcRenderer.invoke("local-app:selectServer", serverId),
addServer: (server: Omit) => ipcRenderer.invoke("local-app:addServer", server),
removeServer: (serverId: Server["_id"]) => ipcRenderer.invoke("local-app:removeServer", serverId),
+ saveShortcut: (shortcut: keyof SettingsData["shortcuts"], key: string | null) =>
+ ipcRenderer.invoke("local-app:saveShortcut", shortcut, key),
+ getShortcuts: () => ipcRenderer.invoke("local-app:getShortcuts"),
};
contextBridge.exposeInMainWorld("WorkAdventureDesktopApi", api);
diff --git a/desktop/src/preload-local-app/types.ts b/desktop/src/preload-local-app/types.ts
index 8e9f6a2d..04a58342 100644
--- a/desktop/src/preload-local-app/types.ts
+++ b/desktop/src/preload-local-app/types.ts
@@ -1,3 +1,5 @@
+import { SettingsData } from "src/settings";
+
export type Server = {
_id: string;
name: string;
@@ -7,9 +9,12 @@ export type Server = {
export type WorkAdventureLocalAppApi = {
desktop: boolean;
isDevelopment: () => Promise;
+ getVersion: () => Promise;
showLocalApp: () => Promise;
getServers: () => Promise;
selectServer: (serverId: string) => Promise;
addServer: (server: Omit) => Promise;
removeServer: (serverId: Server["_id"]) => Promise;
+ saveShortcut: (shortcut: keyof SettingsData["shortcuts"], key: string | null) => Promise;
+ getShortcuts: () => Promise;
};
diff --git a/desktop/src/settings.ts b/desktop/src/settings.ts
index 592f159f..83c35c2a 100644
--- a/desktop/src/settings.ts
+++ b/desktop/src/settings.ts
@@ -2,10 +2,11 @@ import ElectronLog from "electron-log";
import Settings from "electron-settings";
import type { Server } from "./preload-local-app/types";
-type SettingsData = {
+export type SettingsData = {
log_level: ElectronLog.LogLevel;
auto_launch_enabled: boolean;
servers: Server[];
+ shortcuts: Record<"mute_toggle" | "camera_toggle", string | null>;
};
let settings: SettingsData;
diff --git a/desktop/src/shortcuts.ts b/desktop/src/shortcuts.ts
new file mode 100644
index 00000000..66bc4abd
--- /dev/null
+++ b/desktop/src/shortcuts.ts
@@ -0,0 +1,29 @@
+import { globalShortcut } from "electron";
+import settings, { SettingsData } from "./settings";
+import { emitCameraToggle, emitMuteToggle } from "./ipc";
+
+export function loadShortcuts() {
+ globalShortcut.unregisterAll();
+
+ const shortcuts = settings.get("shortcuts");
+
+ // // mute key
+ if (shortcuts?.mute_toggle && shortcuts.mute_toggle.length > 0) {
+ globalShortcut.register(shortcuts.mute_toggle, () => {
+ emitMuteToggle();
+ });
+ }
+
+ if (shortcuts?.camera_toggle && shortcuts.camera_toggle.length > 0) {
+ globalShortcut.register(shortcuts.camera_toggle, () => {
+ emitCameraToggle();
+ });
+ }
+}
+
+export function saveShortcut(shortcut: keyof SettingsData["shortcuts"], key: string | null) {
+ const shortcuts = settings.get("shortcuts") || {};
+ shortcuts[shortcut] = key;
+ settings.set("shortcuts", shortcuts);
+ loadShortcuts();
+}