From ea24c96a79fc1642f899d2c5fe3b35481e0c5cd4 Mon Sep 17 00:00:00 2001 From: LynithDev <61880709+LynithDev@users.noreply.github.com> Date: Tue, 28 Jan 2025 17:05:29 +0100 Subject: [PATCH] fix: Enable dev tools in prod builds --- apps/desktop/Cargo.toml | 2 +- apps/desktop/src/api/commands/mod.rs | 8 +++++ .../src/ui/components/ErrorBoundary.tsx | 33 ++++++++++--------- .../settings/about/SettingsDeveloper.tsx | 6 ++++ .../settings/launcher/SettingsAppearance.tsx | 2 +- packages/client/src/bindings.ts | 3 ++ 6 files changed, 36 insertions(+), 18 deletions(-) diff --git a/apps/desktop/Cargo.toml b/apps/desktop/Cargo.toml index 12eb05c3..db4ddc0a 100644 --- a/apps/desktop/Cargo.toml +++ b/apps/desktop/Cargo.toml @@ -70,6 +70,6 @@ objc = { workspace = true } webkit2gtk = { workspace = true } [features] -default = [ "custom-protocol" ] +default = [ "custom-protocol", "devtools" ] devtools = [ "tauri/devtools" ] custom-protocol = [ "tauri/custom-protocol" ] diff --git a/apps/desktop/src/api/commands/mod.rs b/apps/desktop/src/api/commands/mod.rs index 8e6043ec..59f68ffc 100644 --- a/apps/desktop/src/api/commands/mod.rs +++ b/apps/desktop/src/api/commands/mod.rs @@ -88,10 +88,18 @@ macro_rules! collect_commands { get_featured_packages, get_zulu_packages, install_java_from_package, + open_dev_tools, ] }}; } +#[specta::specta] +#[tauri::command] +pub fn open_dev_tools(_webview: tauri::WebviewWindow) { + #[cfg(feature = "devtools")] + _webview.open_devtools(); +} + #[specta::specta] #[tauri::command] pub async fn get_zulu_packages() -> Result, String> { diff --git a/apps/frontend/src/ui/components/ErrorBoundary.tsx b/apps/frontend/src/ui/components/ErrorBoundary.tsx index 19161654..ae36ba26 100644 --- a/apps/frontend/src/ui/components/ErrorBoundary.tsx +++ b/apps/frontend/src/ui/components/ErrorBoundary.tsx @@ -1,25 +1,26 @@ import type { ParentProps } from 'solid-js'; -import { ErrorBoundary as Boundary, Match, Switch } from 'solid-js'; +import { XIcon } from '@untitled-theme/icons-solid'; +import { ErrorBoundary as Boundary } from 'solid-js'; +import Button from './base/Button'; function ErrorBoundary(props: ParentProps) { return ( - - - ( -
-

An unexpected error has occurred

+ ( +
+
+
+

Error

{err.toString()}

- )} - > - {props.children} - - - - {props.children} - - + +
+
+ )} + > + {props.children} +
); } diff --git a/apps/frontend/src/ui/pages/settings/about/SettingsDeveloper.tsx b/apps/frontend/src/ui/pages/settings/about/SettingsDeveloper.tsx index 17c64d5d..1c3e7718 100644 --- a/apps/frontend/src/ui/pages/settings/about/SettingsDeveloper.tsx +++ b/apps/frontend/src/ui/pages/settings/about/SettingsDeveloper.tsx @@ -1,5 +1,6 @@ import { useNavigate } from '@solidjs/router'; import { CodeBrowserIcon, EyeIcon, GitMergeIcon, LinkExternal01Icon, PlusIcon, RefreshCcw05Icon } from '@untitled-theme/icons-solid'; +import { bridge } from '~imports'; import Button from '~ui/components/base/Button'; import Toggle from '~ui/components/base/Toggle'; import ScrollableContainer from '~ui/components/ScrollableContainer'; @@ -30,6 +31,10 @@ function SettingsDeveloper() { setNotiCounter(count => count + 1); } + function openDevTools() { + bridge.commands.openDevTools(); + } + return (

Developer Options

@@ -43,6 +48,7 @@ function SettingsDeveloper() {