From 3a4486e661e2c4d7e6a9e8af82acde9a45804d32 Mon Sep 17 00:00:00 2001 From: nekename <63245705+nekename@users.noreply.github.com> Date: Fri, 26 Jun 2026 18:44:20 +0100 Subject: [PATCH] chore: reformat codebase using Prettier due to frequent instability in the Deno formatter --- .prettierignore | 1 + .vscode/OpenDeck.code-workspace | 9 +- .vscode/launch.json | 12 +- AGENTS.md | 7 ++ README.md | 33 +++--- deno.json | 5 - deno.lock | 15 +++ package.json | 12 +- .../propertyInspector/deviceBrightness.html | 30 ++--- .../propertyInspector/inputSimulation.html | 58 ++++++---- .../assets/propertyInspector/openUrl.html | 34 +++--- .../assets/propertyInspector/runCommand.html | 39 ++++--- .../assets/propertyInspector/sdpi.css | 13 ++- .../propertyInspector/switchProfile.html | 34 +++--- .../build.ts | 3 +- scripts/bump_version.ts | 5 +- src-tauri/capabilities/main.json | 12 +- src-tauri/tauri.conf.json | 6 +- src/app.css | 32 +++++- src/app.html | 2 +- src/components/ActionList.svelte | 25 ++-- src/components/DeviceSelector.svelte | 10 +- src/components/DeviceView.svelte | 50 ++++---- src/components/InstanceEditor.svelte | 33 ++---- src/components/Key.svelte | 39 ++----- src/components/ListedPlugin.svelte | 5 +- src/components/NoDevicesDetected.svelte | 2 +- src/components/ParentActionView.svelte | 17 ++- src/components/PluginDetails.svelte | 12 +- src/components/PluginManager.svelte | 48 +++++--- src/components/ProfileManager.svelte | 25 ++-- src/components/PropertyInspectorView.svelte | 107 ++++++++++-------- src/components/SettingsView.svelte | 33 +++--- src/components/Tooltip.svelte | 6 +- src/lib/i18n.ts | 7 +- src/lib/propertyInspector.ts | 4 +- src/lib/rendererHelper.ts | 36 +++--- src/routes/+page.svelte | 13 +-- 38 files changed, 431 insertions(+), 403 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..0e4b780 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +LICENSE.md diff --git a/.vscode/OpenDeck.code-workspace b/.vscode/OpenDeck.code-workspace index 4dca38e..e9737b7 100644 --- a/.vscode/OpenDeck.code-workspace +++ b/.vscode/OpenDeck.code-workspace @@ -1,11 +1,8 @@ { - "folders": [ - { "path": ".." }, - { "path": "../plugins/com.amansprojects.starterpack.sdPlugin" } - ], + "folders": [{ "path": ".." }, { "path": "../plugins/com.amansprojects.starterpack.sdPlugin" }], "settings": { "editor.insertSpaces": false, "files.insertFinalNewline": true, - "files.trimTrailingWhitespace": true - } + "files.trimTrailingWhitespace": true, + }, } diff --git a/.vscode/launch.json b/.vscode/launch.json index 02ffb08..833094b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,11 +6,7 @@ "request": "launch", "name": "Debug (debug)", "cargo": { - "args": [ - "build", - "--manifest-path=./src-tauri/Cargo.toml", - "--no-default-features" - ] + "args": ["build", "--manifest-path=./src-tauri/Cargo.toml", "--no-default-features"] }, "preLaunchTask": "frontend:dev" }, @@ -19,11 +15,7 @@ "request": "launch", "name": "Debug (release)", "cargo": { - "args": [ - "build", - "--release", - "--manifest-path=./src-tauri/Cargo.toml" - ] + "args": ["build", "--release", "--manifest-path=./src-tauri/Cargo.toml"] }, "preLaunchTask": "frontend:build" } diff --git a/AGENTS.md b/AGENTS.md index 979d167..544f7ae 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,6 +3,7 @@ ## Token Efficiency Respond like smart caveman. Cut all filler, keep technical substance. + - Drop articles (a, an, the), filler (just, really, basically, actually). - Drop pleasantries (sure, certainly, happy to). - No hedging. Fragments fine. Short synonyms. @@ -12,6 +13,7 @@ Respond like smart caveman. Cut all filler, keep technical substance. ## Architecture Overview OpenDeck is a Tauri desktop application for controlling Elgato Stream Deck devices. It's built with: + - **Backend**: Rust (Tauri v2) - device communication, plugin management, WebSocket/HTTP servers - **Frontend**: SvelteKit + TypeScript + Tailwind CSS v4 - UI rendered in webview - **Build Tool**: Deno (not Node.js) - manages tasks and dependencies @@ -19,6 +21,7 @@ OpenDeck is a Tauri desktop application for controlling Elgato Stream Deck devic ### Core Architecture Pattern OpenDeck acts as a **host application** that communicates with **plugins** (separate processes): + 1. Plugins connect via WebSocket (port dynamically allocated, starting from 57116) 2. Static assets served via `tiny_http` webserver (port = WebSocket port + 2) 3. Plugin property inspectors (HTML/JS) run in iframes and use separate WebSocket connections @@ -53,12 +56,14 @@ plugins/com.amansprojects.starterpack.sdPlugin/ # Plugin with basic actions ### Type Synchronization TypeScript types in `src/lib/` **must** mirror Rust structs in `src-tauri/src/shared.rs`: + - `Context`, `ActionInstance`, `ActionState`, `DeviceInfo`, `Profile` - Changes to Rust structs require updating corresponding TypeScript types ### Context System A `Context` identifies a button/encoder position: + ```rust struct Context { device: String, // Device vendor prefix and serial number @@ -111,6 +116,7 @@ An `ActionContext` extends this with an action instance index for nested actions ### Profile Management Profiles are device-specific JSON files in `//.json`: + ```rust // Read profile let locks = crate::store::profiles::acquire_locks().await; @@ -147,6 +153,7 @@ Auto-switching: `application_watcher.rs` polls active window every 250ms, trigge ### WebSocket Protocol Port allocation: `PORT_BASE` (WebSocket), `PORT_BASE + 2` (HTTP static files) + - Dynamic port selection: Tries ports starting at 57116 until both WebSocket and HTTP ports are available - Registration: Plugins send `RegisterEvent::RegisterPlugin { uuid }`, property inspectors send `RegisterPropertyInspector` - Message queuing: `PLUGIN_QUEUES` buffers messages until plugin connects diff --git a/README.md b/README.md index b02b27a..65b327e 100644 --- a/README.md +++ b/README.md @@ -30,19 +30,21 @@ Special thanks go to the developers of [Tauri](https://github.com/tauri-apps/tau > [!TIP] > If you're using a Debian, Ubuntu, Fedora, Fedora Atomic, openSUSE or Arch-based distribution, you can try the automated installation script: +> > ```bash > curl -sSL https://raw.githubusercontent.com/nekename/OpenDeck/main/install_opendeck.sh | bash > ``` +> > The script installs OpenDeck from a released .deb or .rpm file, the AUR, or Flathub, appropriately, and also installs and reloads the appropriate udev subsystem rules. Additionally, you can choose to install Wine and/or Node.js from your distribution during the process. - Download the latest release from [GitHub Releases](https://github.com/nekename/OpenDeck/releases/latest). - - You should avoid AppImage releases of OpenDeck as they tend to have problems (you should also just avoid AppImages in general). - - For users of Arch-based distributions, there are the `opendeck` and `opendeck-bin` AUR packages for the latest release, as well as the `opendeck-git` AUR package for the latest commit on the `main` branch of this repository. + - You should avoid AppImage releases of OpenDeck as they tend to have problems (you should also just avoid AppImages in general). + - For users of Arch-based distributions, there are the `opendeck` and `opendeck-bin` AUR packages for the latest release, as well as the `opendeck-git` AUR package for the latest commit on the `main` branch of this repository. - Install OpenDeck using your package manager of choice. - Install the appropriate udev subsystem rules from [here](https://raw.githubusercontent.com/OpenActionAPI/rust-elgato-streamdeck/main/40-streamdeck.rules): - - If you're using a `.deb` or `.rpm` release artifact, this file should be installed automatically. - - Otherwise, download and copy it to the correct location with `sudo cp 40-streamdeck.rules /etc/udev/rules.d/`. - - In both cases, you will need to reload your udev subsystem rules with `sudo udevadm control --reload-rules && sudo udevadm trigger`. + - If you're using a `.deb` or `.rpm` release artifact, this file should be installed automatically. + - Otherwise, download and copy it to the correct location with `sudo cp 40-streamdeck.rules /etc/udev/rules.d/`. + - In both cases, you will need to reload your udev subsystem rules with `sudo udevadm control --reload-rules && sudo udevadm trigger`. - If you intend to use some compiled plugins that are not compiled for Linux, you will need to have [Wine](https://www.winehq.org/) installed on your system. Some plugins may also depend on Wine Mono (which is sometimes, but not always included, in your distro's packaging of Wine). > [!NOTE] @@ -57,14 +59,14 @@ Special thanks go to the developers of [Tauri](https://github.com/tauri-apps/tau - Download the latest release from [GitHub Releases](https://github.com/nekename/OpenDeck/releases/latest). - If you downloaded a `.dmg`, open the downloaded disk image and drag the application inside into your Applications folder; otherwise, extract the `.tar.gz` to your Applications folder. -- Open the installed application. Note: if you receive a warning about OpenDeck being distributed by an unknown developer, *right-click the app in Finder and then click Open* to suppress the warning. +- Open the installed application. Note: if you receive a warning about OpenDeck being distributed by an unknown developer, _right-click the app in Finder and then click Open_ to suppress the warning. - If you intend to use plugins that are only compiled for Windows, you will need to have [Wine](https://www.winehq.org/) installed on your system. ## Support ### How do I...? -To edit an action's settings, left-click on it to display its *property inspector*. To remove an action, right-click on it and choose "Delete" from the context menu. +To edit an action's settings, left-click on it to display its _property inspector_. To remove an action, right-click on it and choose "Delete" from the context menu. To edit an action's appearance, right-click on it and select "Edit" from the context menu. You can then customise the image and text for each of its states. Left-click on the image to choose an image from your filesystem or right-click on the image to reset it to the plugin-provided default. @@ -77,13 +79,13 @@ To change other options, open Settings. From here, you can also view information - Ensure you are running the latest version of OpenDeck, as well as recent versions of related software (e.g. Spotify or OBS). - Check the [FAQ](https://github.com/nekename/OpenDeck/wiki/0.-FAQ) and [GitHub Issues](https://github.com/nekename/OpenDeck/issues) to see if there's a fix for your problem already. - Check the OpenDeck log file for any important messages. This file should be included with any support request. - - You can also run OpenDeck from the terminal to see the logs directly if it's easier than finding the log file or if the log file is empty or missing details. - - For issues with plugins, you can also check the plugin's logs (in the same folder, sometimes as well as a file named `plugin.log` or similar in the plugin's own folder). - - The log directory can be opened from the settings page of OpenDeck, or alternatively located manually at the paths below: - - Linux: `~/.local/share/opendeck/logs/` - - Flatpak: `~/.var/app/me.amankhanna.opendeck/data/opendeck/logs/` - - Windows: `%appdata%\opendeck\logs\` - - macOS: `~/Library/Logs/opendeck/` + - You can also run OpenDeck from the terminal to see the logs directly if it's easier than finding the log file or if the log file is empty or missing details. + - For issues with plugins, you can also check the plugin's logs (in the same folder, sometimes as well as a file named `plugin.log` or similar in the plugin's own folder). + - The log directory can be opened from the settings page of OpenDeck, or alternatively located manually at the paths below: + - Linux: `~/.local/share/opendeck/logs/` + - Flatpak: `~/.var/app/me.amankhanna.opendeck/data/opendeck/logs/` + - Windows: `%appdata%\opendeck\logs\` + - macOS: `~/Library/Logs/opendeck/` - When trying to run compiled plugins built for Windows on Linux or macOS, please ensure you have the latest version of Wine (and Wine Mono) installed on your system. - If your device isn't showing up, ensure you have the correct permissions to access it (e.g. on Linux, installing udev subsystem rules and restarting your system), and that you have restarted OpenDeck since connecting it. @@ -101,11 +103,12 @@ To change other options, open Settings. From here, you can also view information You'll need to ensure that all of the [prerequisites for building a Tauri application](https://tauri.app/start/prerequisites) are satisfied to build OpenDeck, as well as making sure that [Deno](https://deno.com/) is installed. On Linux, you'll also need `libudev` and `libdbus` installed for your distribution. After running `deno install`, you can use `deno task tauri dev` and `deno task tauri build` to work with OpenDeck. Before each commit, please ensure that all of the following are completed: + 1. Rust code has been linted using `cargo clippy` and it discovers no violations 2. Rust code has been formatted using `cargo fmt` 3. TypeScript code has been checked using `deno check` and linted using `deno lint` and they discover no violations 4. Svelte code has been linted using `deno task check` and it discovers no violations -5. Frontend code has been formatted using `deno fmt --unstable-component` +5. Frontend code has been formatted using `deno task format` When submitting contributions, please adhere to the [Conventional Commits specification](https://conventionalcommits.org/) for commit messages. You will also need to [sign your commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits). Feel free to reach out on the support channels above for guidance when contributing! diff --git a/deno.json b/deno.json index 99dbc38..44d8b60 100644 --- a/deno.json +++ b/deno.json @@ -1,10 +1,5 @@ { "exclude": ["src-tauri", "node_modules", "build", ".svelte-kit"], - "fmt": { - "exclude": ["**/*.md", "**/.*/**/*.md"], - "useTabs": true, - "lineWidth": 200 - }, "lint": { "rules": { "exclude": ["no-explicit-any"] diff --git a/deno.lock b/deno.lock index 61b551f..52f66ed 100644 --- a/deno.lock +++ b/deno.lock @@ -19,6 +19,8 @@ "npm:marked-base-url@^1.1.0": "1.1.8_marked@17.0.1", "npm:marked@17": "17.0.1", "npm:phosphor-svelte@2": "2.0.1_svelte@4.2.20", + "npm:prettier-plugin-svelte@^3.5.0": "3.5.2_prettier@3.8.4_svelte@4.2.20", + "npm:prettier@^3.8.0": "3.8.4", "npm:svelte-check@^4.3.0": "4.3.6_svelte@4.2.20_typescript@5.9.3", "npm:svelte@^4.2.0": "4.2.20", "npm:tailwindcss@^4.1.0": "4.1.18", @@ -919,6 +921,17 @@ "source-map-js" ] }, + "prettier-plugin-svelte@3.5.2_prettier@3.8.4_svelte@4.2.20": { + "integrity": "sha512-ItFouLvzSFE3ulNl4DKoWM3BGcbDCNVpIyy/Y3F2gC3aNiGLxtFUdffVqO5Z5hhYG+DFT5KULWaxmeFFpdbvaQ==", + "dependencies": [ + "prettier", + "svelte" + ] + }, + "prettier@3.8.4": { + "integrity": "sha512-N2MylSdi48+5N/6S5j+maeHbUSIzzZ5uOcX5Hm4QpV8Dkb1HFjfAKTKX6yNPJQD9AhcT3ifHNB66tWTTJDi11Q==", + "bin": true + }, "readdirp@4.1.2": { "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==" }, @@ -1071,6 +1084,8 @@ "npm:marked-base-url@^1.1.0", "npm:marked@17", "npm:phosphor-svelte@2", + "npm:prettier-plugin-svelte@^3.5.0", + "npm:prettier@^3.8.0", "npm:svelte-check@^4.3.0", "npm:svelte@^4.2.0", "npm:tailwindcss@^4.1.0", diff --git a/package.json b/package.json index 311a829..efdc16f 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "dev": "vite dev", "build": "vite build", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "tauri": "tauri" + "tauri": "tauri", + "format": "prettier --write ." }, "devDependencies": { "@sveltejs/adapter-static": "^3.0", @@ -17,6 +18,8 @@ "@tailwindcss/vite": "^4.1", "@tauri-apps/cli": "^2.10", "lightningcss": "^1.31", + "prettier": "^3.8", + "prettier-plugin-svelte": "^3.5", "svelte": "^4.2", "svelte-check": "^4.3", "tailwindcss": "^4.1", @@ -33,5 +36,12 @@ "marked-alert": "^2.1", "marked-base-url": "^1.1", "phosphor-svelte": "^2.0" + }, + "prettier": { + "useTabs": true, + "printWidth": 160, + "plugins": [ + "prettier-plugin-svelte" + ] } } diff --git a/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/deviceBrightness.html b/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/deviceBrightness.html index 0df3471..7120bf0 100644 --- a/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/deviceBrightness.html +++ b/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/deviceBrightness.html @@ -1,4 +1,4 @@ - + diff --git a/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/inputSimulation.html b/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/inputSimulation.html index 4fa8939..9de3183 100644 --- a/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/inputSimulation.html +++ b/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/inputSimulation.html @@ -1,4 +1,4 @@ - + diff --git a/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/runCommand.html b/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/runCommand.html index 2017f0f..a311575 100644 --- a/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/runCommand.html +++ b/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/runCommand.html @@ -1,4 +1,4 @@ - + @@ -63,7 +67,8 @@

- Usages of %d will be substituted with the number of ticks turned, where negative values signify counterclockwise rotation and positive values signify clockwise rotation. + Usages of %d will be substituted with the number of ticks turned, where negative values signify counterclockwise rotation and positive + values signify clockwise rotation.


diff --git a/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/sdpi.css b/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/sdpi.css index 20ba930..a51871a 100644 --- a/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/sdpi.css +++ b/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/sdpi.css @@ -19,7 +19,18 @@ html { html, body { - font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; + font-family: + system-ui, + -apple-system, + BlinkMacSystemFont, + "Segoe UI", + Roboto, + Helvetica, + Arial, + sans-serif, + "Apple Color Emoji", + "Segoe UI Emoji", + "Segoe UI Symbol"; font-size: 9pt; background-color: var(--sdpi-bgcolor); color: #9a9a9a; diff --git a/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/switchProfile.html b/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/switchProfile.html index e753013..63bd0d2 100644 --- a/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/switchProfile.html +++ b/plugins/com.amansprojects.starterpack.sdPlugin/assets/propertyInspector/switchProfile.html @@ -1,4 +1,4 @@ - + - - {#key device} {$t("device_view.grid_description")}
{#each { length: device.columns } as _, c} handleDrop(event, "Keypad", (r * device.columns) + c)} - on:dragstart={(event) => handleDragStart(event, "Keypad", (r * device.columns) + c)} + on:drop={(event) => handleDrop(event, "Keypad", r * device.columns + c)} + on:dragstart={(event) => handleDragStart(event, "Keypad", r * device.columns + c)} {handlePaste} size={device.id.startsWith("sd-") && device.rows == 4 && device.columns == 8 ? 192 : 144} label="{$t('device_view.key')} {String.fromCharCode(65 + r)}{c + 1}" @@ -248,11 +233,11 @@ {/each} {/if} handleDrop(event, "Keypad", (device.rows * device.columns) + i)} - on:dragstart={(event) => handleDragStart(event, "Keypad", (device.rows * device.columns) + i)} + on:drop={(event) => handleDrop(event, "Keypad", device.rows * device.columns + i)} + on:dragstart={(event) => handleDragStart(event, "Keypad", device.rows * device.columns + i)} {handlePaste} size={device.id.startsWith("sd-") && device.rows == 4 && device.columns == 8 ? 192 : 144} isTouchPoint @@ -263,3 +248,18 @@
{/key} + + diff --git a/src/components/InstanceEditor.svelte b/src/components/InstanceEditor.svelte index 44e23fd..1ce9c12 100644 --- a/src/components/InstanceEditor.svelte +++ b/src/components/InstanceEditor.svelte @@ -73,7 +73,7 @@ {/each} - +
@@ -141,12 +141,7 @@ class="mt-1 px-0.5 text-sm text-neutral-300 bg-neutral-600 hover:bg-neutral-500 transition-colors border border-neutral-500 rounded-lg" > {$t("instance_editor.background")} - + {:else} - - - diff --git a/src/components/ListedPlugin.svelte b/src/components/ListedPlugin.svelte index 2742e31..8257dd8 100644 --- a/src/components/ListedPlugin.svelte +++ b/src/components/ListedPlugin.svelte @@ -10,10 +10,7 @@ export let secondaryActionLabel: string = ""; -
+
{name}

{name}

diff --git a/src/components/NoDevicesDetected.svelte b/src/components/NoDevicesDetected.svelte index eba287e..9183564 100644 --- a/src/components/NoDevicesDetected.svelte +++ b/src/components/NoDevicesDetected.svelte @@ -5,7 +5,7 @@ import { invoke } from "@tauri-apps/api/core"; let buildInfo: string; - (async () => buildInfo = await invoke("get_build_info"))(); + (async () => (buildInfo = await invoke("get_build_info")))();
diff --git a/src/components/ParentActionView.svelte b/src/components/ParentActionView.svelte index 5a0bc85..13b2808 100644 --- a/src/components/ParentActionView.svelte +++ b/src/components/ParentActionView.svelte @@ -33,10 +33,7 @@ async function addAction(action: Action) { if ( (parentUuid == "opendeck.multiaction" && !action.supported_in_multi_actions) || - ( - parentUuid == "opendeck.toggleaction" && - (action.uuid == "opendeck.multiaction" || action.uuid == "opendeck.toggleaction") - ) + (parentUuid == "opendeck.toggleaction" && (action.uuid == "opendeck.multiaction" || action.uuid == "opendeck.toggleaction")) ) { return; } @@ -113,7 +110,7 @@ />
- +

{parentUuid == "opendeck.toggleaction" ? $t("parent_action.toggle") : $t("parent_action.multi")}

@@ -121,7 +118,7 @@
$inspectedInstance = null} + on:click={() => ($inspectedInstance = null)} role="list" aria-label="{parentUuid == 'opendeck.toggleaction' ? $t('parent_action.toggle') : $t('parent_action.multi')} {$t('parent_action.children')}" on:keydown={handleListKeydown} @@ -130,8 +127,8 @@
$inspectedInstance = instance.context} - on:focus|stopPropagation={() => $inspectedInstance = instance.context} + on:click|stopPropagation={() => ($inspectedInstance = instance.context)} + on:focus|stopPropagation={() => ($inspectedInstance = instance.context)} on:keydown={(e) => { if (e.key == "Delete") removeInstance(index, true); }} @@ -163,8 +160,8 @@ class="flex flex-row items-center mx-4 mt-2 mb-4 p-3 bg-neutral-700 hover:bg-neutral-600 transition-colors border border-dashed border-neutral-600 rounded-lg focus-within:outline-solid focus-within:outline-offset-2 focus-within:outline-blue-500" on:dragover={handleDragOver} on:drop={handleDrop} - on:click={() => $inspectedInstance = null} - on:focus={() => $inspectedInstance = null} + on:click={() => ($inspectedInstance = null)} + on:focus={() => ($inspectedInstance = null)} on:keydown={(e) => { if ((e.ctrlKey || e.metaKey) && e.key == "v") handlePaste(); }} diff --git a/src/components/PluginDetails.svelte b/src/components/PluginDetails.svelte index 4e942a9..4c574a8 100644 --- a/src/components/PluginDetails.svelte +++ b/src/components/PluginDetails.svelte @@ -74,20 +74,12 @@
- {details.name} + {details.name}
{details.name}
{$t("plugin_details.by")} - Author avatar + Author avatar installed = await invoke("list_plugins"))(); + (async () => (installed = await invoke("list_plugins")))(); let plugins: { [id: string]: GitHubPlugin }; - (async () => plugins = await (await fetch("https://openactionapi.github.io/plugins/catalogue.json")).json())(); + (async () => (plugins = await (await fetch("https://openactionapi.github.io/plugins/catalogue.json")).json()))(); let showArchive: boolean = false; let archivePlugins: any[] | null = null; @@ -179,8 +194,7 @@ for (const plugin of installed) { if (!checkedPlugins.has(plugin.id)) { checkedPlugins.add(plugin.id); - isUpdateAvailable(plugin) - .then((version) => availableUpdates = { ...availableUpdates, [plugin.id]: version }); + isUpdateAvailable(plugin).then((version) => (availableUpdates = { ...availableUpdates, [plugin.id]: version })); } } } @@ -207,7 +221,7 @@ @@ -223,12 +237,12 @@ /> - +

{$t("plugin_manager.title")}

{$t("plugin_manager.installed")}

- + {#each installed.sort((a, b) => (a.builtin && !b.builtin) ? -1 : (b.builtin && !a.builtin) ? 1 : @@ -324,7 +338,7 @@ name={plugin.name} subtitle={plugin.author} hidden={!plugin.name.toLowerCase().includes(query.toLowerCase())} - action={() => openDetailsView = id} + action={() => (openDetailsView = id)} actionLabel={$t("plugin_manager.view_details")} > @@ -406,12 +420,14 @@ // @ts-expect-error installPluginGitHub(openDetailsView, plugins[openDetailsView]); }} - close={() => openDetailsView = null} + close={() => (openDetailsView = null)} /> {/if} {#if choices} -
+

{$t("plugin_manager.choose_asset")}

{#if profile != value} - +

{device.name}

{$t("profile_manager.application_profiles.hint.1")} {$t("profile_manager.application_profiles.hint.2")} - {#each Object.entries(applicationProfiles).sort((a, b) => a[0] == "opendeck_default" ? -1 : b[0] == "opendeck_default" ? 1 : a[0].localeCompare(b[0])) as [appName, devices]} + {#each Object.entries(applicationProfiles).sort( (a, b) => (a[0] == "opendeck_default" ? -1 : b[0] == "opendeck_default" ? 1 : a[0].localeCompare(b[0])), ) as [appName, devices]} {#if devices[device.id]} @@ -320,7 +319,9 @@ + {$t("settings.sleep_timeout_minutes.minutes")} - {$t("settings.sleep_timeout_minutes.tooltip")} + {$t("settings.sleep_timeout_minutes.tooltip")}
- {$t("settings.sleep_when_computer_locked.tooltip")} + {$t("settings.sleep_when_computer_locked.tooltip")}
diff --git a/src/components/Tooltip.svelte b/src/components/Tooltip.svelte index 1c775e8..d4f9f2f 100644 --- a/src/components/Tooltip.svelte +++ b/src/components/Tooltip.svelte @@ -5,11 +5,7 @@ -
show = true} - on:mouseleave={() => show = false} -> +
(show = true)} on:mouseleave={() => (show = false)}> {#if show}
diff --git a/src/lib/i18n.ts b/src/lib/i18n.ts index a734288..ef2bdb5 100644 --- a/src/lib/i18n.ts +++ b/src/lib/i18n.ts @@ -40,4 +40,9 @@ function translate(locale: string, key: string, vars: { [x: string]: any }) { return text; } -export const t = derived(locale, ($locale) => (key: string, vars = {}) => translate($locale, key, vars)); +export const t = derived( + locale, + ($locale) => + (key: string, vars = {}) => + translate($locale, key, vars), +); diff --git a/src/lib/propertyInspector.ts b/src/lib/propertyInspector.ts index becb653..596ac06 100644 --- a/src/lib/propertyInspector.ts +++ b/src/lib/propertyInspector.ts @@ -24,7 +24,5 @@ document.addEventListener("keydown", (event) => { }); globalThis.addEventListener("blur", () => openContextMenu.set(null)); -export type CopiedItem = - | { type: "instance"; source: Context } - | { type: "action"; action: Action }; +export type CopiedItem = { type: "instance"; source: Context } | { type: "action"; action: Action }; export const copiedItem: Writable = writable(null); diff --git a/src/lib/rendererHelper.ts b/src/lib/rendererHelper.ts index b4ef545..0a63c8a 100644 --- a/src/lib/rendererHelper.ts +++ b/src/lib/rendererHelper.ts @@ -31,7 +31,7 @@ export class CanvasLock { currentLock = Promise.resolve(); async lock() { let unlockNext: () => void; - const willLock = new Promise((resolve) => unlockNext = resolve); + const willLock = new Promise((resolve) => (unlockNext = resolve)); const previousLock = this.currentLock; this.currentLock = willLock; await previousLock; @@ -68,7 +68,7 @@ export async function renderImage( context.save(); if (rotation) { context.translate(canvas.width / 2, canvas.height / 2); - context.rotate(rotation * Math.PI / 180); + context.rotate((rotation * Math.PI) / 180); context.translate(-canvas.width / 2, -canvas.height / 2); } @@ -109,33 +109,33 @@ export async function renderImage( if (state.show) { const size = state.size * 2 * scale; context.textAlign = "center"; - context.font = (state.style.includes("Bold") ? "bold " : "") + (state.style.includes("Italic") ? "italic " : "") + - `${size}px "${state.family}", sans-serif`; + context.font = + (state.style.includes("Bold") ? "bold " : "") + (state.style.includes("Italic") ? "italic " : "") + `${size}px "${state.family}", sans-serif`; context.fillStyle = state.colour; context.strokeStyle = state.stroke_colour; context.lineWidth = state.stroke_size * scale; context.textBaseline = "top"; const x = canvas.width / 2; - let y = canvas.height / 2 - (size * state.text.split("\n").length * 0.5); + let y = canvas.height / 2 - size * state.text.split("\n").length * 0.5; switch (state.alignment) { case "top": y = context.lineWidth; break; case "bottom": - y = canvas.height - (size * state.text.split("\n").length) - context.lineWidth; + y = canvas.height - size * state.text.split("\n").length - context.lineWidth; break; } for (const [index, line] of Object.entries(state.text.split("\n"))) { - context.strokeText(line, x, y + (size * parseInt(index))); - context.fillText(line, x, y + (size * parseInt(index))); + context.strokeText(line, x, y + size * parseInt(index)); + context.fillText(line, x, y + size * parseInt(index)); if (state.underline) { const width = context.measureText(line).width; // Set to black for the outline, since it uses the same fill style info as the text colour. context.fillStyle = "black"; - context.fillRect(x - (width / 2) - 3, y + (size * parseInt(index)) + size, width + 6, 9); + context.fillRect(x - width / 2 - 3, y + size * parseInt(index) + size, width + 6, 9); // Reset to the user's choice of text colour. context.fillStyle = state.colour; - context.fillRect(x - (width / 2), y + (size * parseInt(index)) + size + 4, width, 3); + context.fillRect(x - width / 2, y + size * parseInt(index) + size + 4, width, 3); } } } @@ -168,13 +168,7 @@ export async function renderImage( const newContext = smallCanvas.getContext("2d"); const margin = 0.1; if (newContext) { - newContext.drawImage( - canvas, - canvas.width * margin, - canvas.height * margin, - canvas.width * (1 - (margin * 2)), - canvas.height * (1 - (margin * 2)), - ); + newContext.drawImage(canvas, canvas.width * margin, canvas.height * margin, canvas.width * (1 - margin * 2), canvas.height * (1 - margin * 2)); context.clearRect(0, 0, canvas.width, canvas.height); context.drawImage(smallCanvas, 0, 0); } @@ -195,10 +189,12 @@ export async function resizeImage(source: string): Promise { const image = document.createElement("img"); image.crossOrigin = "anonymous"; image.src = source; - await new Promise((resolve) => image.onload = resolve); + await new Promise((resolve) => (image.onload = resolve)); - let xOffset = 0, yOffset = 0; - let xScaled = canvas.width, yScaled = canvas.height; + let xOffset = 0, + yOffset = 0; + let xScaled = canvas.width, + yScaled = canvas.height; if (image.width > image.height) { const ratio = image.height / image.width; yScaled = canvas.height * ratio; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 5717b77..ce27688 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -29,19 +29,10 @@
{appName == "opendeck_default" ? $t("profile_manager.default_profile") : appName}: