From dfc90508d1366a03b37772467aef965043922d52 Mon Sep 17 00:00:00 2001
From: misyaguziya <53165965+misyaguziya@users.noreply.github.com>
Date: Mon, 2 Jun 2025 15:07:33 +0900
Subject: [PATCH 01/41] [Fix] Controller: Handle VRAM overflow errors during
translation and transcription processes.
---
src-python/controller.py | 247 ++++++++++++++----
src-python/mainloop.py | 11 +
src-python/model.py | 9 +
.../transcription/transcription_whisper.py | 27 +-
4 files changed, 240 insertions(+), 54 deletions(-)
diff --git a/src-python/controller.py b/src-python/controller.py
index 89a07d3a..7adb1f87 100644
--- a/src-python/controller.py
+++ b/src-python/controller.py
@@ -259,17 +259,44 @@ class Controller:
elif config.ENABLE_TRANSLATION is False:
pass
else:
- translation, success = model.getInputTranslate(message, source_language=language)
- if all(success) is not True:
- self.changeToCTranslate2Process()
- self.run(
- 400,
- self.run_mapping["error_translation_engine"],
- {
- "message":"Translation engine limit error",
- "data": None
- },
- )
+ try:
+ translation, success = model.getInputTranslate(message, source_language=language)
+ if all(success) is not True:
+ self.changeToCTranslate2Process()
+ self.run(
+ 400,
+ self.run_mapping["error_translation_engine"],
+ {
+ "message":"Translation engine limit error",
+ "data": None
+ },
+ )
+ except Exception as e:
+ # VRAM不足エラーの検出
+ is_vram_error, error_message = model.detectVRAMError(e)
+ if is_vram_error:
+ self.run(
+ 400,
+ self.run_mapping["error_translation_mic_vram_overflow"],
+ {
+ "message":"VRAM out of memory during translation of mic",
+ "data": error_message
+ },
+ )
+ # 翻訳機能をOFFにする
+ self.setDisableTranslation()
+ self.run(
+ 400,
+ self.run_mapping["enable_translation"],
+ {
+ "message":"Translation disabled due to VRAM overflow",
+ "data": False
+ },
+ )
+ return
+ else:
+ # その他のエラーは通常通り処理
+ raise
if config.CONVERT_MESSAGE_TO_ROMAJI is True or config.CONVERT_MESSAGE_TO_HIRAGANA is True:
if config.SELECTED_TARGET_LANGUAGES[config.SELECTED_TAB_NO]["1"]["language"] == "Japanese":
@@ -346,17 +373,44 @@ class Controller:
elif config.ENABLE_TRANSLATION is False:
pass
else:
- translation, success = model.getOutputTranslate(message, source_language=language)
- if all(success) is not True:
- self.changeToCTranslate2Process()
- self.run(
- 400,
- self.run_mapping["error_translation_engine"],
- {
- "message":"Translation engine limit error",
- "data": None
- },
- )
+ try:
+ translation, success = model.getOutputTranslate(message, source_language=language)
+ if all(success) is not True:
+ self.changeToCTranslate2Process()
+ self.run(
+ 400,
+ self.run_mapping["error_translation_engine"],
+ {
+ "message":"Translation engine limit error",
+ "data": None
+ },
+ )
+ except Exception as e:
+ # VRAM不足エラーの検出
+ is_vram_error, error_message = model.detectVRAMError(e)
+ if is_vram_error:
+ self.run(
+ 400,
+ self.run_mapping["error_translation_speaker_vram_overflow"],
+ {
+ "message":"VRAM out of memory during translation of speaker",
+ "data": error_message
+ },
+ )
+ # 翻訳機能をOFFにする
+ self.setDisableTranslation()
+ self.run(
+ 400,
+ self.run_mapping["enable_translation"],
+ {
+ "message":"Translation disabled due to VRAM overflow",
+ "data": False
+ },
+ )
+ return
+ else:
+ # その他のエラーは通常通り処理
+ raise
if config.CONVERT_MESSAGE_TO_ROMAJI is True or config.CONVERT_MESSAGE_TO_HIRAGANA is True:
if config.SELECTED_TARGET_LANGUAGES[config.SELECTED_TAB_NO]["1"]["language"] == "Japanese":
@@ -417,26 +471,62 @@ class Controller:
if config.ENABLE_TRANSLATION is False:
pass
else:
- if config.USE_EXCLUDE_WORDS is True:
- replacement_message, replacement_dict = self.replaceExclamationsWithRandom(message)
- translation, success = model.getInputTranslate(replacement_message)
+ try:
+ if config.USE_EXCLUDE_WORDS is True:
+ replacement_message, replacement_dict = self.replaceExclamationsWithRandom(message)
+ translation, success = model.getInputTranslate(replacement_message)
- message = self.removeExclamations(message)
- for i in range(len(translation)):
- translation[i] = self.restoreText(translation[i], replacement_dict)
- else:
- translation, success = model.getInputTranslate(message)
+ message = self.removeExclamations(message)
+ for i in range(len(translation)):
+ translation[i] = self.restoreText(translation[i], replacement_dict)
+ else:
+ translation, success = model.getInputTranslate(message)
- if all(success) is not True:
- self.changeToCTranslate2Process()
- self.run(
- 400,
- self.run_mapping["error_translation_engine"],
- {
- "message":"Translation engine limit error",
- "data": None
- },
- )
+ if all(success) is not True:
+ self.changeToCTranslate2Process()
+ self.run(
+ 400,
+ self.run_mapping["error_translation_engine"],
+ {
+ "message":"Translation engine limit error",
+ "data": None
+ },
+ )
+ except Exception as e:
+ # VRAM不足エラーの検出
+ is_vram_error, error_message = model.detectVRAMError(e)
+ if is_vram_error:
+ self.run(
+ 400,
+ self.run_mapping["error_translation_chat_vram_overflow"],
+ {
+ "message":"VRAM out of memory during translation of chat",
+ "data": error_message
+ },
+ )
+ # 翻訳機能をOFFにする
+ self.setDisableTranslation()
+ self.run(
+ 400,
+ self.run_mapping["enable_translation"],
+ {
+ "message":"Translation disabled due to VRAM overflow",
+ "data": False
+ },
+ )
+ # エラー時は翻訳なしで返す
+ return {"status":200,
+ "result":
+ {
+ "id":id,
+ "message":message,
+ "translation":[],
+ "transliteration":[],
+ },
+ }
+ else:
+ # その他のエラーは通常通り処理
+ raise
if config.CONVERT_MESSAGE_TO_ROMAJI is True or config.CONVERT_MESSAGE_TO_HIRAGANA is True:
if config.SELECTED_TARGET_LANGUAGES[config.SELECTED_TAB_NO]["1"]["language"] == "Japanese":
@@ -514,8 +604,21 @@ class Controller:
@staticmethod
def setSelectedTranslationComputeDevice(device:str, *args, **kwargs) -> dict:
printLog("setSelectedTranslationComputeDevice", device)
+ pre_device = config.SELECTED_TRANSLATION_COMPUTE_DEVICE
config.SELECTED_TRANSLATION_COMPUTE_DEVICE = device
- model.changeTranslatorCTranslate2Model()
+ try:
+ model.changeTranslatorCTranslate2Model()
+ except Exception as e:
+ # VRAM不足エラーの検出(デバイス切り替え時)
+ is_vram_error, error_message = model.detectVRAMError(e)
+ if is_vram_error:
+ # 前のデバイス設定に戻す
+ printLog("VRAM error detected, reverting device setting")
+ config.SELECTED_TRANSLATION_COMPUTE_DEVICE = pre_device
+ model.changeTranslatorCTranslate2Model()
+ else:
+ # その他のエラーは通常通り処理
+ errorLogging()
return {"status":200,"result":config.SELECTED_TRANSLATION_COMPUTE_DEVICE}
@staticmethod
@@ -1628,8 +1731,35 @@ class Controller:
while self.device_access_status is False:
sleep(1)
self.device_access_status = False
- model.startMicTranscript(self.micMessage)
- self.device_access_status = True
+ try:
+ model.startMicTranscript(self.micMessage)
+ except Exception as e:
+ # VRAM不足エラーの検出
+ is_vram_error, error_message = model.detectVRAMError(e)
+ if is_vram_error:
+ self.run(
+ 400,
+ self.run_mapping["error_transcription_mic_vram_overflow"],
+ {
+ "message":"VRAM out of memory during mic transcription",
+ "data": error_message
+ },
+ )
+ # ここでマイクの音声認識を停止
+ self.stopTranscriptionSendMessage()
+ self.run(
+ 400,
+ self.run_mapping["enable_transcription_send"],
+ {
+ "message":"Transcription send disabled due to VRAM overflow",
+ "data": False
+ },
+ )
+ else:
+ # その他のエラーは通常通り処理
+ errorLogging()
+ finally:
+ self.device_access_status = True
@staticmethod
def stopTranscriptionSendMessage() -> None:
@@ -1650,8 +1780,35 @@ class Controller:
while self.device_access_status is False:
sleep(1)
self.device_access_status = False
- model.startSpeakerTranscript(self.speakerMessage)
- self.device_access_status = True
+ try:
+ model.startSpeakerTranscript(self.speakerMessage)
+ except Exception as e:
+ # VRAM不足エラーの検出
+ is_vram_error, error_message = model.detectVRAMError(e)
+ if is_vram_error:
+ self.run(
+ 400,
+ self.run_mapping["error_transcription_speaker_vram_overflow"],
+ {
+ "message":"VRAM out of memory during speaker transcription",
+ "data": error_message
+ },
+ )
+ # ここでスピーカーの音声認識を停止
+ self.stopTranscriptionReceiveMessage()
+ self.run(
+ 400,
+ self.run_mapping["enable_transcription_receive"],
+ {
+ "message":"Transcription receive disabled due to VRAM overflow",
+ "data": False
+ },
+ )
+ else:
+ # その他のエラーは通常通り処理
+ errorLogging()
+ finally:
+ self.device_access_status = True
@staticmethod
def stopTranscriptionReceiveMessage() -> None:
diff --git a/src-python/mainloop.py b/src-python/mainloop.py
index 00bc8cb5..28207de5 100644
--- a/src-python/mainloop.py
+++ b/src-python/mainloop.py
@@ -11,6 +11,10 @@ from utils import printLog, printResponse, errorLogging, encodeBase64 # noqa: E4
logging.getLogger("huggingface_hub").setLevel(logging.ERROR)
run_mapping = {
+ "enable_translation":"/run/enable_translation",
+ "enable_transcription_send":"/run/enable_transcription_send",
+ "enable_transcription_receive":"/run/enable_transcription_receive",
+
"connected_network":"/run/connected_network",
"enable_ai_models":"/run/enable_ai_models",
@@ -22,6 +26,13 @@ run_mapping = {
"error_device":"/run/error_device",
"error_translation_engine":"/run/error_translation_engine",
+
+ "error_translation_chat_vram_overflow":"/run/error_translation_chat_vram_overflow",
+ "error_translation_mic_vram_overflow":"/run/error_translation_mic_vram_overflow",
+ "error_translation_speaker_vram_overflow":"/run/error_translation_speaker_vram_overflow",
+ "error_transcription_mic_vram_overflow":"/run/error_transcription_mic_vram_overflow",
+ "error_transcription_speaker_vram_overflow":"/run/error_transcription_speaker_vram_overflow",
+
"word_filter":"/run/word_filter",
"download_progress_ctranslate2_weight":"/run/download_progress_ctranslate2_weight",
diff --git a/src-python/model.py b/src-python/model.py
index 3b4e51b6..b40936b5 100644
--- a/src-python/model.py
+++ b/src-python/model.py
@@ -509,6 +509,15 @@ class Model:
if isinstance(self.mic_audio_recorder, SelectedMicEnergyAndAudioRecorder):
self.mic_audio_recorder.pause()
+ # VRAM 不足エラーを検出するメソッドを追加
+ def detectVRAMError(self, error):
+ error_str = str(error)
+ if isinstance(error, ValueError) and len(error.args) > 0 and error.args[0] == "VRAM_OUT_OF_MEMORY":
+ return True, error.args[1] if len(error.args) > 1 else "VRAM out of memory"
+ if "CUDA out of memory" in error_str or "CUBLAS_STATUS_ALLOC_FAILED" in error_str:
+ return True, error_str
+ return False, None
+
def changeMicTranscriptStatus(self):
if config.VRC_MIC_MUTE_SYNC is True:
match self.mic_mute_status:
diff --git a/src-python/models/transcription/transcription_whisper.py b/src-python/models/transcription/transcription_whisper.py
index 69499260..04f89626 100644
--- a/src-python/models/transcription/transcription_whisper.py
+++ b/src-python/models/transcription/transcription_whisper.py
@@ -77,15 +77,24 @@ def downloadWhisperWeight(root, weight_type, callback=None, end_callback=None):
def getWhisperModel(root, weight_type, device="cpu", device_index=0):
path = os_path.join(root, "weights", "whisper", weight_type)
compute_type = getBestComputeType(device, device_index)
- return WhisperModel(
- path,
- device=device,
- device_index=device_index,
- compute_type=compute_type,
- cpu_threads=4,
- num_workers=1,
- local_files_only=True,
- )
+ try:
+ model = WhisperModel(
+ path,
+ device=device,
+ device_index=device_index,
+ compute_type=compute_type,
+ cpu_threads=4,
+ num_workers=1,
+ local_files_only=True,
+ )
+ return model
+ except RuntimeError as e:
+ # VRAM不足エラーの検出
+ error_message = str(e)
+ if "CUDA out of memory" in error_message or "CUBLAS_STATUS_ALLOC_FAILED" in error_message:
+ raise ValueError("VRAM_OUT_OF_MEMORY", error_message)
+ # その他のエラーは通常通り再送出
+ raise
if __name__ == "__main__":
def callback(value):
From bcef981955db69f9465f92e0c9bd177a391ee311 Mon Sep 17 00:00:00 2001
From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com>
Date: Thu, 5 Jun 2025 18:11:53 +0900
Subject: [PATCH 02/41] [Update] Change the notification UI. (Change the base
notification library from MUI to React-Toastify.)
---
package-lock.json | 14 ++
package.json | 1 +
.../app/error_boundary/AppErrorBoundary.jsx | 1 +
.../AppErrorBoundary.module.scss | 1 +
.../ReactToastifyOverrideClass.scss | 109 +++++++++++++++
.../SnackbarController.jsx | 130 +++++++++++++-----
.../SnackbarController.module.scss | 94 +++++++++++--
.../app/splash_component/SplashComponent.jsx | 2 +-
.../SplashComponent.module.scss | 2 +-
src-ui/assets/error.svg | 1 +
src-ui/logics/common/useNotificationStatus.js | 3 +-
11 files changed, 308 insertions(+), 50 deletions(-)
create mode 100644 src-ui/app/snackbar_controller/ReactToastifyOverrideClass.scss
create mode 100644 src-ui/assets/error.svg
diff --git a/package-lock.json b/package-lock.json
index f131d4a8..cbe6e142 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -28,6 +28,7 @@
"react-error-boundary": "5.0.0",
"react-i18next": "15.5.1",
"react-resizable-layout": "0.7.2",
+ "react-toastify": "11.0.5",
"sass": "1.79.4",
"semver": "7.7.1"
},
@@ -5534,6 +5535,19 @@
"react-dom": ">=17.0.0"
}
},
+ "node_modules/react-toastify": {
+ "version": "11.0.5",
+ "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-11.0.5.tgz",
+ "integrity": "sha512-EpqHBGvnSTtHYhCPLxML05NLY2ZX0JURbAdNYa6BUkk+amz4wbKBQvoKQAB0ardvSarUBuY4Q4s1sluAzZwkmA==",
+ "license": "MIT",
+ "dependencies": {
+ "clsx": "^2.1.1"
+ },
+ "peerDependencies": {
+ "react": "^18 || ^19",
+ "react-dom": "^18 || ^19"
+ }
+ },
"node_modules/react-transition-group": {
"version": "4.4.5",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz",
diff --git a/package.json b/package.json
index a2d9030f..c15471e5 100644
--- a/package.json
+++ b/package.json
@@ -43,6 +43,7 @@
"react-error-boundary": "5.0.0",
"react-i18next": "15.5.1",
"react-resizable-layout": "0.7.2",
+ "react-toastify": "11.0.5",
"sass": "1.79.4",
"semver": "7.7.1"
},
diff --git a/src-ui/app/error_boundary/AppErrorBoundary.jsx b/src-ui/app/error_boundary/AppErrorBoundary.jsx
index 4aeb34a2..37a1cc23 100644
--- a/src-ui/app/error_boundary/AppErrorBoundary.jsx
+++ b/src-ui/app/error_boundary/AppErrorBoundary.jsx
@@ -65,6 +65,7 @@ const ErrorContainer = ({error}) => {
);
};
+// Duplicated
const CloseButtonContainer = () => {
const { asyncCloseApp } = useWindow();
return (
diff --git a/src-ui/app/error_boundary/AppErrorBoundary.module.scss b/src-ui/app/error_boundary/AppErrorBoundary.module.scss
index 2abb2710..2ff85390 100644
--- a/src-ui/app/error_boundary/AppErrorBoundary.module.scss
+++ b/src-ui/app/error_boundary/AppErrorBoundary.module.scss
@@ -72,6 +72,7 @@
+// Duplicated
.close_button_wrapper {
position: absolute;
top: 0;
diff --git a/src-ui/app/snackbar_controller/ReactToastifyOverrideClass.scss b/src-ui/app/snackbar_controller/ReactToastifyOverrideClass.scss
new file mode 100644
index 00000000..9325d747
--- /dev/null
+++ b/src-ui/app/snackbar_controller/ReactToastifyOverrideClass.scss
@@ -0,0 +1,109 @@
+:root {
+ --toastify-color-light: #fff;
+ --toastify-color-dark: var(--dark_950_color);
+ --toastify-color-info: var(--sent_400_color);
+ --toastify-color-success: var(--primary_400_color);
+ --toastify-color-warning: var(--waring_bc_color);
+ --toastify-color-error: var(--error_bc_color);
+ --toastify-color-transparent: rgba(255, 255, 255, 0.7);
+
+ --toastify-icon-color-info: var(--toastify-color-info);
+ --toastify-icon-color-success: var(--toastify-color-success);
+ --toastify-icon-color-warning: var(--toastify-color-warning);
+ --toastify-icon-color-error: var(--toastify-color-error);
+
+ --toastify-container-width: fit-content;
+ --toastify-toast-width: 32rem;
+ --toastify-toast-offset: 1.6rem;
+ --toastify-toast-top: max(var(--toastify-toast-offset), env(safe-area-inset-top));
+ --toastify-toast-right: max(var(--toastify-toast-offset), env(safe-area-inset-right));
+ --toastify-toast-left: max(var(--toastify-toast-offset), env(safe-area-inset-left));
+ --toastify-toast-bottom: max(var(--toastify-toast-offset), env(safe-area-inset-bottom));
+ --toastify-toast-background: #fff;
+ --toastify-toast-padding: 1.4rem;
+ --toastify-toast-min-height: 6.4rem;
+ --toastify-toast-max-height: 80rem;
+ --toastify-toast-bd-radius: 0.6rem;
+ --toastify-toast-shadow: .0 0.4rem 1.2rem rgba(0, 0, 0, 0.1);
+ --toastify-font-family: var(--font_family);
+ --toastify-z-index: 9999;
+ --toastify-text-color-light: #757575;
+ --toastify-text-color-dark: var(--dark_basic_text_color);
+
+ /* Used only for colored theme */
+ --toastify-text-color-info: var(--dark_basic_text_color);
+ --toastify-text-color-success: var(--dark_basic_text_color);
+ --toastify-text-color-warning: var(--dark_basic_text_color);
+ --toastify-text-color-error: var(--dark_basic_text_color);
+
+ --toastify-spinner-color: #616161;
+ --toastify-spinner-color-empty-area: #e0e0e0;
+ --toastify-color-progress-light: linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55);
+ --toastify-color-progress-dark: #bb86fc;
+ --toastify-color-progress-info: var(--toastify-color-info);
+ --toastify-color-progress-success: var(--toastify-color-success);
+ --toastify-color-progress-warning: var(--toastify-color-warning);
+ --toastify-color-progress-error: var(--toastify-color-error);
+ /* used to control the opacity of the progress trail */
+ --toastify-color-progress-bgo: 0.2;
+}
+
+
+.Toastify__toast {
+ // --------------------------------------------------------
+ // Default Settings
+ // --------------------------------------------------------
+ position: relative;
+ touch-action: none;
+ // width: var(--toastify-toast-width);
+ min-height: var(--toastify-toast-min-height);
+ box-sizing: border-box;
+ margin-bottom: 1rem;
+ // padding: var(--toastify-toast-padding);
+ border-radius: 0.6rem;
+ box-shadow: none;
+ max-height: var(--toastify-toast-max-height);
+ // font-family: "Yu Gothic UI";
+ // font-family: var(--toastify-font-family);
+ // z-index: 0;
+ // display: flex;
+ // flex: 1 auto;
+ // align-items: center;
+ word-break: break-word;
+ // --------------------------------------------------------
+ // --------------------------------------------------------
+
+
+ // Comment out above and override. Commented out is just for memorization.
+ overflow: hidden;
+ display: flex;
+ justify-content: start;
+ align-items: center;
+ font-size: 1.4rem;
+ width: fit-content;
+ max-width: 50vw;
+ padding-right: 4rem;
+ background-color: var(--dark_950_color);
+ gap: 0.6rem;
+}
+
+.Toastify__progress-bar--success {
+ background: var(--success_bc_color);
+}
+
+.Toastify__progress-bar--warning {
+ background: var(--warning_bc_color);
+}
+
+.Toastify__progress-bar--error {
+ background: var(--error_bc_color);
+}
+
+
+.Toastify__toast-icon {
+ width: fit-content;
+ max-width: 2.8rem;
+ min-width: 2.8rem;
+ justify-content: center;
+ align-items: center;
+}
\ No newline at end of file
diff --git a/src-ui/app/snackbar_controller/SnackbarController.jsx b/src-ui/app/snackbar_controller/SnackbarController.jsx
index e503e695..28bd6325 100644
--- a/src-ui/app/snackbar_controller/SnackbarController.jsx
+++ b/src-ui/app/snackbar_controller/SnackbarController.jsx
@@ -1,46 +1,114 @@
+import React, { useEffect, useState } from "react";
+import { ToastContainer, toast, Bounce } from "react-toastify";
import clsx from "clsx";
-import Snackbar from "@mui/material/Snackbar";
-import Slide from "@mui/material/Slide";
+import "./ReactToastifyOverrideClass.scss";
import styles from "./SnackbarController.module.scss";
+
+import XMarkSvg from "@images/cancel.svg?react";
+import WarningSvg from "@images/warning.svg?react";
+import MegaphoneSvg from "@images/megaphone.svg?react";
+import CheckMarkSvg from "@images/check_mark.svg?react";
+import ErrorSvg from "@images/error.svg?react";
+
import { useNotificationStatus } from "@logics_common";
export const SnackbarController = () => {
const { currentNotificationStatus, closeNotification } = useNotificationStatus();
-
- const handleClose = (event, reason) => {
- closeNotification(event, reason);
- };
-
- const snackbar_classname = clsx(styles.snackbar_content, {
- [styles.is_success]: currentNotificationStatus.data.status === "success",
- [styles.is_warning]: currentNotificationStatus.data.status === "warning",
- [styles.is_error]: currentNotificationStatus.data.status === "error",
- });
+ const [containerKey, setContainerKey] = useState(0);
const settings = currentNotificationStatus.data;
- let hide_duration = 5000;
- if (settings.options?.hide_duration === null) hide_duration = null;
- if (Number(settings.options?.hide_duration)) hide_duration = settings.options.hide_duration;
+ const snackbar_classname = clsx(
+ styles.snackbar_content,
+ {
+ [styles.is_success]: settings.status === "success",
+ [styles.is_warning]: settings.status === "warning",
+ [styles.is_error]: settings.status === "error",
+ }
+ );
+
+ let hideDuration = 5000;
+ if (settings.options?.hide_duration === null) {
+ hideDuration = false;
+ } else if (Number(settings.options?.hide_duration)) {
+ hideDuration = Number(settings.options?.hide_duration);
+ }
+
+ useEffect(() => {
+ if (!settings.is_open) return;
+
+ const message_text = settings.message;
+
+ if (toast.isActive(message_text)) {
+ setContainerKey(prevKey => prevKey + 1);
+
+ setTimeout(() => {
+ toast(message_text, {
+ toastId: message_text,
+ type: settings.status,
+ autoClose: hideDuration,
+ transition: Bounce,
+ toastClassName: snackbar_classname,
+ progressClassName: styles.toast_progress,
+ closeButton:
{settings.message}
-{label}
diff --git a/src-ui/logics/common/useHandleOscQuery.js b/src-ui/logics/common/useHandleOscQuery.js index 61c2ba59..dace04d5 100644 --- a/src-ui/logics/common/useHandleOscQuery.js +++ b/src-ui/logics/common/useHandleOscQuery.js @@ -7,7 +7,10 @@ export const useHandleOscQuery = () => { const { showNotification_Warning } = useNotificationStatus(); const { updateEnableVrcMicMuteSync } = useEnableVrcMicMuteSync(); - const handleOscQuery = ({ is_osc_query_enabled, disabled_functions }) => { + const handleOscQuery = (payload) => { + const is_osc_query_enabled = payload.data; + const disabled_functions = payload.disabled_functions; + if (is_osc_query_enabled) { updateEnableVrcMicMuteSync(prev => ({ ...prev.data, diff --git a/src-ui/logics/common/useIsVrctAvailable.js b/src-ui/logics/common/useIsVrctAvailable.js index dae8911e..569a0210 100644 --- a/src-ui/logics/common/useIsVrctAvailable.js +++ b/src-ui/logics/common/useIsVrctAvailable.js @@ -1,10 +1,21 @@ import { useStore_IsVrctAvailable } from "@store"; +import { useNotificationStatus } from "@logics_common"; export const useIsVrctAvailable = () => { const { currentIsVrctAvailable, updateIsVrctAvailable } = useStore_IsVrctAvailable(); + const { showNotification_Success, showNotification_Error } = useNotificationStatus(); + + const handleAiModelsAvailability = (is_ai_models_available) => { + if (is_ai_models_available === false) { + updateIsVrctAvailable(false); + showNotification_Error("AI models have not been detected. Check the network connection and restart VRCT (it will download automatically, normally).", { hide_duration: null }); + } + }; return { currentIsVrctAvailable, updateIsVrctAvailable, + + handleAiModelsAvailability, }; }; \ No newline at end of file diff --git a/src-ui/logics/common/useMessage.js b/src-ui/logics/common/useMessage.js index 841c90dc..78986b55 100644 --- a/src-ui/logics/common/useMessage.js +++ b/src-ui/logics/common/useMessage.js @@ -42,6 +42,9 @@ export const useMessage = () => { messages: {message: message}, }); }; + const addSystemMessageLog_FromBackend = (payload) => { + addSystemMessageLog(payload.message); + }; const updateSentMessageLogById = (payload) => { updateMessageLogs(updateItemById(payload.id, payload.translation)); @@ -66,6 +69,7 @@ export const useMessage = () => { currentMessageLogs, sendMessage, addSystemMessageLog, + addSystemMessageLog_FromBackend, updateSentMessageLogById, addSentMessageLog, addReceivedMessageLog, diff --git a/src-ui/logics/common/useOpenFolder.js b/src-ui/logics/common/useOpenFolder.js index fa991f03..6ecfd6bd 100644 --- a/src-ui/logics/common/useOpenFolder.js +++ b/src-ui/logics/common/useOpenFolder.js @@ -2,16 +2,26 @@ import { useStdoutToPython } from "@useStdoutToPython"; export const useOpenFolder = () => { const { asyncStdoutToPython } = useStdoutToPython(); + const openFolder_MessageLogs = () => { asyncStdoutToPython("/run/open_filepath_logs"); }; + const openedFolder_MessageLogs = () => { + console.log("Opened Directory, Message Logs"); + }; const openFolder_ConfigFile = () => { asyncStdoutToPython("/run/open_filepath_config_file"); }; + const openedFolder_ConfigFile = () => { + console.log("Opened Directory, Config File"); + }; return { openFolder_MessageLogs, openFolder_ConfigFile, + + openedFolder_MessageLogs, + openedFolder_ConfigFile, }; }; \ No newline at end of file diff --git a/src-ui/logics/common/useSoftwareVersion.js b/src-ui/logics/common/useSoftwareVersion.js index 25c257d5..ea6e99ad 100644 --- a/src-ui/logics/common/useSoftwareVersion.js +++ b/src-ui/logics/common/useSoftwareVersion.js @@ -13,6 +13,13 @@ export const useSoftwareVersion = () => { asyncStdoutToPython("/get/data/version"); }; + const updateSoftwareVersionInfo = (payload) => { + updateLatestSoftwareVersionInfo(prev => ({ + is_update_available: payload.is_update_available, + new_version: payload.new_version || prev.data.new_version, + })); + }; + const isPluginCompatible = (main_version, lower_version, upper_version) => { // lower_version 以上かつ upper_version 以下なら互換性ありと判定 return semver.gte(main_version, lower_version) && semver.lte(main_version, upper_version); @@ -32,6 +39,7 @@ export const useSoftwareVersion = () => { getSoftwareVersion, updateSoftwareVersion, + updateSoftwareVersionInfo, currentLatestSoftwareVersionInfo, updateLatestSoftwareVersionInfo, diff --git a/src-ui/logics/configs/device/useMicDeviceList.js b/src-ui/logics/configs/device/useMicDeviceList.js index 486c3f58..d145a890 100644 --- a/src-ui/logics/configs/device/useMicDeviceList.js +++ b/src-ui/logics/configs/device/useMicDeviceList.js @@ -1,5 +1,6 @@ import { useStore_MicDeviceList } from "@store"; import { useStdoutToPython } from "@useStdoutToPython"; +import { arrayToObject } from "@utils"; export const useMicDeviceList = () => { const { asyncStdoutToPython } = useStdoutToPython(); @@ -10,9 +11,17 @@ export const useMicDeviceList = () => { asyncStdoutToPython("/get/data/mic_device_list"); }; + + const updateMicDeviceList_FromBackend = (payload) => { + updateMicDeviceList(arrayToObject(payload)); + }; + + return { currentMicDeviceList, getMicDeviceList, updateMicDeviceList, + + updateMicDeviceList_FromBackend, }; }; \ No newline at end of file diff --git a/src-ui/logics/configs/device/useMicHostList.js b/src-ui/logics/configs/device/useMicHostList.js index 39d34097..898f348c 100644 --- a/src-ui/logics/configs/device/useMicHostList.js +++ b/src-ui/logics/configs/device/useMicHostList.js @@ -1,5 +1,6 @@ import { useStore_MicHostList } from "@store"; import { useStdoutToPython } from "@useStdoutToPython"; +import { arrayToObject } from "@utils"; export const useMicHostList = () => { const { asyncStdoutToPython } = useStdoutToPython(); @@ -10,9 +11,15 @@ export const useMicHostList = () => { asyncStdoutToPython("/get/data/mic_host_list"); }; + const updateMicHostList_FromBackend = (payload) => { + updateMicHostList(arrayToObject(payload)); + }; + return { currentMicHostList, getMicHostList, updateMicHostList, + + updateMicHostList_FromBackend, }; }; \ No newline at end of file diff --git a/src-ui/logics/configs/device/useSelectedMicHost.js b/src-ui/logics/configs/device/useSelectedMicHost.js index f1c1c147..0197cfc8 100644 --- a/src-ui/logics/configs/device/useSelectedMicHost.js +++ b/src-ui/logics/configs/device/useSelectedMicHost.js @@ -1,10 +1,13 @@ import { useStore_SelectedMicHost } from "@store"; import { useStdoutToPython } from "@useStdoutToPython"; +import { useSelectedMicDevice } from "@logics_configs"; export const useSelectedMicHost = () => { const { asyncStdoutToPython } = useStdoutToPython(); const { currentSelectedMicHost, updateSelectedMicHost, pendingSelectedMicHost } = useStore_SelectedMicHost(); + const { updateSelectedMicDevice } = useSelectedMicDevice(); + const getSelectedMicHost = () => { pendingSelectedMicHost(); asyncStdoutToPython("/get/data/selected_mic_host"); @@ -15,10 +18,20 @@ export const useSelectedMicHost = () => { asyncStdoutToPython("/set/data/selected_mic_host", selected_mic_host); }; + + // Need refactoring (Duplicated, Host, Device) + const updateSelectedMicHostAndDevice = (payload) => { + updateSelectedMicHost(payload.host); + updateSelectedMicDevice(payload.device); + }; + + return { currentSelectedMicHost, getSelectedMicHost, updateSelectedMicHost, setSelectedMicHost, + + updateSelectedMicHostAndDevice, }; }; \ No newline at end of file diff --git a/src-ui/logics/configs/device/useSpeakerDeviceList.js b/src-ui/logics/configs/device/useSpeakerDeviceList.js index b0385cf8..b88ed285 100644 --- a/src-ui/logics/configs/device/useSpeakerDeviceList.js +++ b/src-ui/logics/configs/device/useSpeakerDeviceList.js @@ -1,5 +1,6 @@ import { useStore_SpeakerDeviceList } from "@store"; import { useStdoutToPython } from "@useStdoutToPython"; +import { arrayToObject } from "@utils"; export const useSpeakerDeviceList = () => { const { asyncStdoutToPython } = useStdoutToPython(); @@ -10,9 +11,16 @@ export const useSpeakerDeviceList = () => { asyncStdoutToPython("/get/data/speaker_device_list"); }; + const updateSpeakerDeviceList_FromBackend = (payload) => { + updateSpeakerDeviceList(arrayToObject(payload)); + }; + + return { currentSpeakerDeviceList, getSpeakerDeviceList, updateSpeakerDeviceList, + + updateSpeakerDeviceList_FromBackend, }; }; \ No newline at end of file diff --git a/src-ui/logics/configs/others/useEnableVrcMicMuteSync.js b/src-ui/logics/configs/others/useEnableVrcMicMuteSync.js index f8711d81..df79fd54 100644 --- a/src-ui/logics/configs/others/useEnableVrcMicMuteSync.js +++ b/src-ui/logics/configs/others/useEnableVrcMicMuteSync.js @@ -19,10 +19,18 @@ export const useEnableVrcMicMuteSync = () => { } }; + const updateEnableVrcMicMuteSync_FromBackend = (payload) => { + updateEnableVrcMicMuteSync((old_value) => { + return {...old_value.data, is_enabled: payload}; + }); + }; + return { currentEnableVrcMicMuteSync, getEnableVrcMicMuteSync, toggleEnableVrcMicMuteSync, updateEnableVrcMicMuteSync, + + updateEnableVrcMicMuteSync_FromBackend, }; }; \ No newline at end of file diff --git a/src-ui/logics/configs/transcription/useMicWordFilterList.js b/src-ui/logics/configs/transcription/useMicWordFilterList.js index a0ac5b09..1901e286 100644 --- a/src-ui/logics/configs/transcription/useMicWordFilterList.js +++ b/src-ui/logics/configs/transcription/useMicWordFilterList.js @@ -15,10 +15,27 @@ export const useMicWordFilterList = () => { asyncStdoutToPython("/set/data/mic_word_filter", selected_mic_word_filter); }; + const updateMicWordFilterList_FromBackend = (payload) => { + updateMicWordFilterList((prev_list) => { + const updated_list = [...prev_list.data]; + for (const value of payload) { + const existing_item = updated_list.find(item => item.value === value); + if (existing_item) { + existing_item.is_redoable = false; + } else { + updated_list.push({ value, is_redoable: false }); + } + } + return updated_list; + }); + }; + return { currentMicWordFilterList, getMicWordFilterList, updateMicWordFilterList, setMicWordFilterList, + + updateMicWordFilterList_FromBackend, }; }; \ No newline at end of file diff --git a/src-ui/logics/configs/transcription/useSelectableWhisperComputeDeviceList.js b/src-ui/logics/configs/transcription/useSelectableWhisperComputeDeviceList.js index 2c732651..a5528937 100644 --- a/src-ui/logics/configs/transcription/useSelectableWhisperComputeDeviceList.js +++ b/src-ui/logics/configs/transcription/useSelectableWhisperComputeDeviceList.js @@ -1,5 +1,6 @@ import { useStore_SelectableWhisperComputeDeviceList } from "@store"; import { useStdoutToPython } from "@useStdoutToPython"; +import { transformToIndexedArray } from "@utils"; export const useSelectableWhisperComputeDeviceList = () => { const { asyncStdoutToPython } = useStdoutToPython(); @@ -10,9 +11,15 @@ export const useSelectableWhisperComputeDeviceList = () => { asyncStdoutToPython("/get/data/transcription_compute_device_list"); }; + const updateSelectableWhisperComputeDeviceList_FromBackend = (payload) => { + updateSelectableWhisperComputeDeviceList(transformToIndexedArray(payload)); + }; + return { currentSelectableWhisperComputeDeviceList, getSelectableWhisperComputeDeviceList, updateSelectableWhisperComputeDeviceList, + + updateSelectableWhisperComputeDeviceList_FromBackend, }; }; \ No newline at end of file diff --git a/src-ui/logics/configs/translation/useDeepLAuthKey.js b/src-ui/logics/configs/translation/useDeepLAuthKey.js index bff8163b..89661ad1 100644 --- a/src-ui/logics/configs/translation/useDeepLAuthKey.js +++ b/src-ui/logics/configs/translation/useDeepLAuthKey.js @@ -23,6 +23,9 @@ export const useDeepLAuthKey = () => { pendingDeepLAuthKey(); asyncStdoutToPython("/delete/data/deepl_auth_key"); }; + const deletedDeepLAuthKey = () => { + updateDeepLAuthKey(""); + }; const savedDeepLAuthKey = (data) => { updateDeepLAuthKey(data); @@ -36,6 +39,7 @@ export const useDeepLAuthKey = () => { setDeepLAuthKey, deleteDeepLAuthKey, + deletedDeepLAuthKey, savedDeepLAuthKey, }; }; \ No newline at end of file diff --git a/src-ui/logics/configs/translation/useSelectableCTranslate2ComputeDeviceList.js b/src-ui/logics/configs/translation/useSelectableCTranslate2ComputeDeviceList.js index db576d9c..4ae60c1f 100644 --- a/src-ui/logics/configs/translation/useSelectableCTranslate2ComputeDeviceList.js +++ b/src-ui/logics/configs/translation/useSelectableCTranslate2ComputeDeviceList.js @@ -1,5 +1,6 @@ import { useStore_SelectableCTranslate2ComputeDeviceList } from "@store"; import { useStdoutToPython } from "@useStdoutToPython"; +import { transformToIndexedArray } from "@utils"; export const useSelectableCTranslate2ComputeDeviceList = () => { const { asyncStdoutToPython } = useStdoutToPython(); @@ -10,9 +11,15 @@ export const useSelectableCTranslate2ComputeDeviceList = () => { asyncStdoutToPython("/get/data/translation_compute_device_list"); }; + const updateSelectableCTranslate2ComputeDeviceList_FromBackend = (payload) => { + updateSelectableCTranslate2ComputeDeviceList(transformToIndexedArray(payload)); + }; + return { currentSelectableCTranslate2ComputeDeviceList, getSelectableCTranslate2ComputeDeviceList, updateSelectableCTranslate2ComputeDeviceList, + + updateSelectableCTranslate2ComputeDeviceList_FromBackend, }; }; \ No newline at end of file diff --git a/src-ui/logics/main/index.js b/src-ui/logics/main/index.js index 7cd492d6..14e817dc 100644 --- a/src-ui/logics/main/index.js +++ b/src-ui/logics/main/index.js @@ -3,5 +3,4 @@ export { useIsMainPageCompactMode } from "./useIsMainPageCompactMode"; export { useLanguageSettings } from "./useLanguageSettings"; export { useMainFunction } from "./useMainFunction"; export { useMessageLogScroll } from "./useMessageLogScroll"; -export { useMessageInputBoxRatio } from "./useMessageInputBoxRatio"; -export { useSelectableLanguageList } from "./useSelectableLanguageList"; \ No newline at end of file +export { useMessageInputBoxRatio } from "./useMessageInputBoxRatio"; \ No newline at end of file diff --git a/src-ui/logics/main/useLanguageSettings.js b/src-ui/logics/main/useLanguageSettings.js index dcee9bcf..aad7ae15 100644 --- a/src-ui/logics/main/useLanguageSettings.js +++ b/src-ui/logics/main/useLanguageSettings.js @@ -1,13 +1,10 @@ -import { useStore_SelectedPresetTabNumber, useStore_EnableMultiTranslation, useStore_SelectedYourLanguages, useStore_SelectedTargetLanguages, useStore_TranslationEngines, useStore_SelectedTranslationEngines } from "@store"; +import { useStore_SelectedPresetTabNumber, useStore_SelectedYourLanguages, useStore_SelectedTargetLanguages, useStore_TranslationEngines, useStore_SelectedTranslationEngines, useStore_SelectableLanguageList } from "@store"; import { useStdoutToPython } from "@useStdoutToPython"; +import { translator_status } from "@ui_configs"; export const useLanguageSettings = () => { const { asyncStdoutToPython } = useStdoutToPython(); - const { - currentEnableMultiTranslation, - updateEnableMultiTranslation, - pendingEnableMultiTranslation, - } = useStore_EnableMultiTranslation(); + const { currentSelectedYourLanguages, updateSelectedYourLanguages, @@ -34,10 +31,11 @@ export const useLanguageSettings = () => { pendingSelectedTranslationEngines, } = useStore_SelectedTranslationEngines(); - const getEnableMultiTranslation = () => { - pendingEnableMultiTranslation(); - asyncStdoutToPython("/get/data/multi_language_translation"); - }; + const { + currentSelectableLanguageList, + updateSelectableLanguageList, + } = useStore_SelectableLanguageList(); + const getSelectedPresetTabNumber = () => { pendingSelectedPresetTabNumber(); @@ -112,6 +110,16 @@ export const useLanguageSettings = () => { asyncStdoutToPython("/get/data/translation_engines"); }; + const updateTranslatorAvailability = (payload) => { + const keys = payload; + const updated_list = translator_status.map(translator => ({ + ...translator, + is_available: keys.includes(translator.id), + })); + updateTranslationEngines(updated_list); + }; + + const getSelectedTranslationEngines = () => { pendingSelectedTranslationEngines(); asyncStdoutToPython("/get/data/selected_translation_engines"); @@ -124,12 +132,22 @@ export const useLanguageSettings = () => { asyncStdoutToPython("/set/data/selected_translation_engines", send_obj); }; - const runLanguageSwap = () => { + const swapSelectedLanguages = () => { pendingSelectedYourLanguages(); pendingSelectedTargetLanguages(); asyncStdoutToPython("/run/swap_your_language_and_target_language"); }; + const updateBothSelectedLanguages = (payload) => { + updateSelectedYourLanguages(payload.your); + updateSelectedTargetLanguages(payload.target); + }; + + + const getSelectableLanguageList = () => { + asyncStdoutToPython("/get/data/selectable_language_list"); + }; + return { currentSelectedPresetTabNumber, @@ -137,11 +155,6 @@ export const useLanguageSettings = () => { updateSelectedPresetTabNumber, setSelectedPresetTabNumber, - currentEnableMultiTranslation, - getEnableMultiTranslation, - updateEnableMultiTranslation, - // setEnableMultiTranslation, - currentSelectedYourLanguages, getSelectedYourLanguages, updateSelectedYourLanguages, @@ -158,12 +171,18 @@ export const useLanguageSettings = () => { currentTranslationEngines, getTranslationEngines, updateTranslationEngines, + updateTranslatorAvailability, currentSelectedTranslationEngines, getSelectedTranslationEngines, updateSelectedTranslationEngines, setSelectedTranslationEngines, - runLanguageSwap, + swapSelectedLanguages, + updateBothSelectedLanguages, + + currentSelectableLanguageList, + getSelectableLanguageList, + updateSelectableLanguageList, }; }; \ No newline at end of file diff --git a/src-ui/logics/main/useSelectableLanguageList.js b/src-ui/logics/main/useSelectableLanguageList.js deleted file mode 100644 index 094530c8..00000000 --- a/src-ui/logics/main/useSelectableLanguageList.js +++ /dev/null @@ -1,17 +0,0 @@ -import { useStore_SelectableLanguageList } from "@store"; -import { useStdoutToPython } from "@useStdoutToPython"; - -export const useSelectableLanguageList = () => { - const { asyncStdoutToPython } = useStdoutToPython(); - const { currentSelectableLanguageList, updateSelectableLanguageList } = useStore_SelectableLanguageList(); - - const getSelectableLanguageList = () => { - asyncStdoutToPython("/get/data/selectable_language_list"); - }; - - return { - currentSelectableLanguageList, - getSelectableLanguageList, - updateSelectableLanguageList, - }; -}; \ No newline at end of file diff --git a/src-ui/logics/useReceiveRoutes.js b/src-ui/logics/useReceiveRoutes.js index b1d3421b..54f49203 100644 --- a/src-ui/logics/useReceiveRoutes.js +++ b/src-ui/logics/useReceiveRoutes.js @@ -1,572 +1,356 @@ -import { translator_status } from "@ui_configs"; -import { arrayToObject } from "@utils"; - +import * as common from "@logics_common"; +import * as main from "@logics_main"; +import * as configs from "@logics_configs"; import { _useBackendErrorHandling } from "./_useBackendErrorHandling"; -import { - useIsVrctAvailable, - useNotificationStatus, - useHandleNetworkConnection, - useHandleOscQuery, +export const ROUTE_META_LIST = [ + // Common + { endpoint: "/run/feed_watchdog", ns: null, hook_name: null, method_name: null }, + { endpoint: "/run/initialization_progress", ns: common, hook_name: "useInitProgress", method_name: "updateInitProgress" }, + { endpoint: "/run/enable_ai_models", ns: common, hook_name: "useIsVrctAvailable", method_name: "handleAiModelsAvailability" }, + { endpoint: "/get/data/compute_mode", ns: common, hook_name: "useComputeMode", method_name: "updateComputeMode" }, - useSoftwareVersion, - useComputeMode, - useInitProgress, - useIsBackendReady, - useWindow, - useMessage, - useVolume, -} from "@logics_common"; + { endpoint: "/get/data/main_window_geometry", ns: common, hook_name: "useWindow", method_name: "restoreWindowGeometry" }, + { endpoint: "/set/data/main_window_geometry", ns: null, hook_name: null, method_name: null }, -import { - useMainFunction, - useSelectableLanguageList, - useLanguageSettings, - useIsMainPageCompactMode, - useMessageInputBoxRatio, -} from "@logics_main"; + { endpoint: "/run/open_filepath_logs", ns: common, hook_name: "useOpenFolder", method_name: "openedFolder_MessageLogs" }, + { endpoint: "/run/open_filepath_config_file", ns: common, hook_name: "useOpenFolder", method_name: "openedFolder_ConfigFile" }, -import { - useEnableAutoMicSelect, - useEnableAutoSpeakerSelect, - useMicHostList, - useSelectedMicHost, - useMicDeviceList, - useSelectedMicDevice, - useSpeakerDeviceList, - useSelectedSpeakerDevice, - useMicThreshold, - useSpeakerThreshold, - useEnableAutoClearMessageInputBox, - useEnableSendOnlyTranslatedMessages, - useEnableAutoExportMessageLogs, - useEnableVrcMicMuteSync, - useEnableSendMessageToVrc, - useEnableSendReceivedMessageToVrc, - useSelectedFontFamily, - useUiLanguage, - useUiScaling, - useMessageLogUiScaling, - useSendMessageButtonType, - useTransparency, - useMicRecordTimeout, - useMicPhraseTimeout, - useMicMaxWords, - useMicWordFilterList, - useSpeakerRecordTimeout, - useSpeakerPhraseTimeout, - useSpeakerMaxWords, - useDeepLAuthKey, - useCTranslate2WeightTypeStatus, - useSelectableCTranslate2ComputeDeviceList, - useSelectedCTranslate2ComputeDevice, - useSelectableWhisperComputeDeviceList, - useSelectedWhisperComputeDevice, - useSelectedCTranslate2WeightType, - useSelectedTranscriptionEngine, - useSelectedWhisperWeightType, - useWhisperWeightTypeStatus, - useIsEnabledOverlaySmallLog, - useOverlaySmallLogSettings, - useIsEnabledOverlayLargeLog, - useOverlayLargeLogSettings, - useOverlayShowOnlyTranslatedMessages, - useEnableNotificationVrcSfx, - useHotkeys, - usePlugins, - useOscIpAddress, - useOscPort, - useWebsocket, -} from "@logics_configs"; + // Software Version + { endpoint: "/get/data/version", ns: common, hook_name: "useSoftwareVersion", method_name: "updateSoftwareVersion" }, + // Latest Software Version Info + { endpoint: "/run/software_update_info", ns: common, hook_name: "useSoftwareVersion", method_name: "updateLatestSoftwareVersionInfo" }, + + { endpoint: "/run/connected_network", ns: common, hook_name: "useHandleNetworkConnection", method_name: "handleNetworkConnection" }, + { endpoint: "/run/enable_osc_query", ns: common, hook_name: "useHandleOscQuery", method_name: "handleOscQuery" }, + + // Message (By typing) + { endpoint: "/run/send_message_box", ns: common, hook_name: "useMessage", method_name: "updateSentMessageLogById" }, + { endpoint: "/run/typing_message_box", ns: null, hook_name: null, method_name: null }, + { endpoint: "/run/stop_typing_message_box", ns: null, hook_name: null, method_name: null }, + // Message Transcription + { endpoint: "/run/transcription_send_mic_message", ns: common, hook_name: "useMessage", method_name: "addSentMessageLog" }, + { endpoint: "/run/transcription_receive_speaker_message", ns: common, hook_name: "useMessage", method_name: "addReceivedMessageLog" }, + + // System Messages + { endpoint: "/run/word_filter", ns: common, hook_name: "useMessage", method_name: "addSystemMessageLog_FromBackend" }, + + + // Volume + { endpoint: "/run/check_mic_volume", ns: common, hook_name: "useVolume", method_name: "updateVolumeVariable_Mic" }, + { endpoint: "/run/check_speaker_volume", ns: common, hook_name: "useVolume", method_name: "updateVolumeVariable_Speaker" }, + { endpoint: "/set/enable/check_mic_threshold", ns: common, hook_name: "useVolume", method_name: "updateMicThresholdCheckStatus" }, + { endpoint: "/set/disable/check_mic_threshold", ns: common, hook_name: "useVolume", method_name: "updateMicThresholdCheckStatus" }, + { endpoint: "/set/enable/check_speaker_threshold", ns: common, hook_name: "useVolume", method_name: "updateSpeakerThresholdCheckStatus" }, + { endpoint: "/set/disable/check_speaker_threshold", ns: common, hook_name: "useVolume", method_name: "updateSpeakerThresholdCheckStatus" }, + + + + + // Main Page + // Page Controls + { endpoint: "/get/data/main_window_sidebar_compact_mode", ns: main, hook_name: "useIsMainPageCompactMode", method_name: "updateIsMainPageCompactMode" }, + { endpoint: "/set/enable/main_window_sidebar_compact_mode", ns: main, hook_name: "useIsMainPageCompactMode", method_name: "updateIsMainPageCompactMode" }, + { endpoint: "/set/disable/main_window_sidebar_compact_mode", ns: main, hook_name: "useIsMainPageCompactMode", method_name: "updateIsMainPageCompactMode" }, + + // Main Functions + { endpoint: "/set/enable/translation", ns: main, hook_name: "useMainFunction", method_name: "updateTranslationStatus" }, + { endpoint: "/set/disable/translation", ns: main, hook_name: "useMainFunction", method_name: "updateTranslationStatus" }, + { endpoint: "/set/enable/transcription_send", ns: main, hook_name: "useMainFunction", method_name: "updateTranscriptionSendStatus" }, + { endpoint: "/set/disable/transcription_send", ns: main, hook_name: "useMainFunction", method_name: "updateTranscriptionSendStatus" }, + { endpoint: "/set/enable/transcription_receive", ns: main, hook_name: "useMainFunction", method_name: "updateTranscriptionReceiveStatus" }, + { endpoint: "/set/disable/transcription_receive", ns: main, hook_name: "useMainFunction", method_name: "updateTranscriptionReceiveStatus" }, + + // Language Settings + { endpoint: "/get/data/selected_tab_no", ns: main, hook_name: "useLanguageSettings", method_name: "updateSelectedPresetTabNumber" }, + { endpoint: "/set/data/selected_tab_no", ns: main, hook_name: "useLanguageSettings", method_name: "updateSelectedPresetTabNumber" }, + + { endpoint: "/get/data/selected_your_languages", ns: main, hook_name: "useLanguageSettings", method_name: "updateSelectedYourLanguages" }, + { endpoint: "/set/data/selected_your_languages", ns: main, hook_name: "useLanguageSettings", method_name: "updateSelectedYourLanguages" }, + { endpoint: "/get/data/selected_target_languages", ns: main, hook_name: "useLanguageSettings", method_name: "updateSelectedTargetLanguages" }, + { endpoint: "/set/data/selected_target_languages", ns: main, hook_name: "useLanguageSettings", method_name: "updateSelectedTargetLanguages" }, + + { endpoint: "/get/data/translation_engines", ns: main, hook_name: "useLanguageSettings", method_name: "updateTranslatorAvailability" }, + { endpoint: "/run/translation_engines", ns: main, hook_name: "useLanguageSettings", method_name: "updateTranslatorAvailability" }, + + { endpoint: "/get/data/selected_translation_engines", ns: main, hook_name: "useLanguageSettings", method_name: "updateSelectedTranslationEngines" }, + { endpoint: "/set/data/selected_translation_engines", ns: main, hook_name: "useLanguageSettings", method_name: "updateSelectedTranslationEngines" }, + { endpoint: "/run/selected_translation_engines", ns: main, hook_name: "useLanguageSettings", method_name: "updateSelectedTranslationEngines" }, + + { endpoint: "/run/swap_your_language_and_target_language", ns: main, hook_name: "useLanguageSettings", method_name: "updateBothSelectedLanguages" }, + + // Language Selector + { endpoint: "/get/data/selectable_language_list", ns: main, hook_name: "useLanguageSettings", method_name: "updateSelectableLanguageList" }, + + + // Message Input Box + { endpoint: "/get/data/message_box_ratio", ns: main, hook_name: "useMessageInputBoxRatio", method_name: "updateMessageInputBoxRatio" }, + { endpoint: "/set/data/message_box_ratio", ns: main, hook_name: "useMessageInputBoxRatio", method_name: "updateMessageInputBoxRatio" }, + + + + // Config Page + // Device + { endpoint: "/get/data/auto_mic_select", ns: configs, hook_name: "useEnableAutoMicSelect", method_name: "updateEnableAutoMicSelect" }, + { endpoint: "/set/enable/auto_mic_select", ns: configs, hook_name: "useEnableAutoMicSelect", method_name: "updateEnableAutoMicSelect" }, + { endpoint: "/set/disable/auto_mic_select", ns: configs, hook_name: "useEnableAutoMicSelect", method_name: "updateEnableAutoMicSelect" }, + { endpoint: "/get/data/auto_speaker_select", ns: configs, hook_name: "useEnableAutoSpeakerSelect", method_name: "updateEnableAutoSpeakerSelect" }, + { endpoint: "/set/enable/auto_speaker_select", ns: configs, hook_name: "useEnableAutoSpeakerSelect", method_name: "updateEnableAutoSpeakerSelect" }, + { endpoint: "/set/disable/auto_speaker_select", ns: configs, hook_name: "useEnableAutoSpeakerSelect", method_name: "updateEnableAutoSpeakerSelect" }, + + // Device (Mic) + { endpoint: "/get/data/mic_host_list", ns: configs, hook_name: "useMicHostList", method_name: "updateMicHostList_FromBackend" }, + { endpoint: "/run/mic_host_list", ns: configs, hook_name: "useMicHostList", method_name: "updateMicHostList_FromBackend" }, + + { endpoint: "/get/data/selected_mic_host", ns: configs, hook_name: "useSelectedMicHost", method_name: "updateSelectedMicHost" }, + { endpoint: "/set/data/selected_mic_host", ns: configs, hook_name: "useSelectedMicHost", method_name: "updateSelectedMicHostAndDevice" }, // Need refactoring (Duplicated, Host, Device) + + + { endpoint: "/get/data/mic_device_list", ns: configs, hook_name: "useMicDeviceList", method_name: "updateMicDeviceList_FromBackend" }, + { endpoint: "/run/mic_device_list", ns: configs, hook_name: "useMicDeviceList", method_name: "updateMicDeviceList_FromBackend" }, + + { endpoint: "/get/data/selected_mic_device", ns: configs, hook_name: "useSelectedMicDevice", method_name: "updateSelectedMicDevice" }, + { endpoint: "/set/data/selected_mic_device", ns: configs, hook_name: "useSelectedMicDevice", method_name: "updateSelectedMicDevice" }, + + { endpoint: "/run/selected_mic_device", ns: configs, hook_name: "useSelectedMicHost", method_name: "updateSelectedMicHostAndDevice" }, // Need refactoring (Duplicated, Host, Device) + + // Device (Speaker) + { endpoint: "/get/data/speaker_device_list", ns: configs, hook_name: "useSpeakerDeviceList", method_name: "updateSpeakerDeviceList_FromBackend" }, + { endpoint: "/run/speaker_device_list", ns: configs, hook_name: "useSpeakerDeviceList", method_name: "updateSpeakerDeviceList_FromBackend" }, + + { endpoint: "/get/data/selected_speaker_device", ns: configs, hook_name: "useSelectedSpeakerDevice", method_name: "updateSelectedSpeakerDevice" }, + { endpoint: "/set/data/selected_speaker_device", ns: configs, hook_name: "useSelectedSpeakerDevice", method_name: "updateSelectedSpeakerDevice" }, + { endpoint: "/run/selected_speaker_device", ns: configs, hook_name: "useSelectedSpeakerDevice", method_name: "updateSelectedSpeakerDevice" }, + + // Device (Threshold) + { endpoint: "/get/data/mic_threshold", ns: configs, hook_name: "useMicThreshold", method_name: "updateMicThreshold" }, + { endpoint: "/set/data/mic_threshold", ns: configs, hook_name: "useMicThreshold", method_name: "updateMicThreshold" }, + { endpoint: "/get/data/speaker_threshold", ns: configs, hook_name: "useSpeakerThreshold", method_name: "updateSpeakerThreshold" }, + { endpoint: "/set/data/speaker_threshold", ns: configs, hook_name: "useSpeakerThreshold", method_name: "updateSpeakerThreshold" }, + + { endpoint: "/get/data/mic_automatic_threshold", ns: configs, hook_name: "useMicThreshold", method_name: "updateEnableAutomaticMicThreshold" }, + { endpoint: "/set/enable/mic_automatic_threshold", ns: configs, hook_name: "useMicThreshold", method_name: "updateEnableAutomaticMicThreshold" }, + { endpoint: "/set/disable/mic_automatic_threshold", ns: configs, hook_name: "useMicThreshold", method_name: "updateEnableAutomaticMicThreshold" }, + { endpoint: "/get/data/speaker_automatic_threshold", ns: configs, hook_name: "useSpeakerThreshold", method_name: "updateEnableAutomaticSpeakerThreshold" }, + { endpoint: "/set/enable/speaker_automatic_threshold", ns: configs, hook_name: "useSpeakerThreshold", method_name: "updateEnableAutomaticSpeakerThreshold" }, + { endpoint: "/set/disable/speaker_automatic_threshold", ns: configs, hook_name: "useSpeakerThreshold", method_name: "updateEnableAutomaticSpeakerThreshold" }, + + + // Appearance + { endpoint: "/get/data/ui_language", ns: configs, hook_name: "useUiLanguage", method_name: "updateUiLanguage" }, + { endpoint: "/set/data/ui_language", ns: configs, hook_name: "useUiLanguage", method_name: "updateUiLanguage" }, + + { endpoint: "/get/data/ui_scaling", ns: configs, hook_name: "useUiScaling", method_name: "updateUiScaling" }, + { endpoint: "/set/data/ui_scaling", ns: configs, hook_name: "useUiScaling", method_name: "updateUiScaling" }, + + { endpoint: "/get/data/textbox_ui_scaling", ns: configs, hook_name: "useMessageLogUiScaling", method_name: "updateMessageLogUiScaling" }, + { endpoint: "/set/data/textbox_ui_scaling", ns: configs, hook_name: "useMessageLogUiScaling", method_name: "updateMessageLogUiScaling" }, + + { endpoint: "/get/data/send_message_button_type", ns: configs, hook_name: "useSendMessageButtonType", method_name: "updateSendMessageButtonType" }, + { endpoint: "/set/data/send_message_button_type", ns: configs, hook_name: "useSendMessageButtonType", method_name: "updateSendMessageButtonType" }, + + { endpoint: "/get/data/font_family", ns: configs, hook_name: "useSelectedFontFamily", method_name: "updateSelectedFontFamily" }, + { endpoint: "/set/data/font_family", ns: configs, hook_name: "useSelectedFontFamily", method_name: "updateSelectedFontFamily" }, + + { endpoint: "/get/data/transparency", ns: configs, hook_name: "useTransparency", method_name: "updateTransparency" }, + { endpoint: "/set/data/transparency", ns: configs, hook_name: "useTransparency", method_name: "updateTransparency" }, + + // Translation + { endpoint: "/get/data/deepl_auth_key", ns: configs, hook_name: "useDeepLAuthKey", method_name: "updateDeepLAuthKey" }, + { endpoint: "/set/data/deepl_auth_key", ns: configs, hook_name: "useDeepLAuthKey", method_name: "savedDeepLAuthKey" }, + { endpoint: "/delete/data/deepl_auth_key", ns: configs, hook_name: "useDeepLAuthKey", method_name: "deletedDeepLAuthKey" }, + + // Translation (AI Models) + { endpoint: "/get/data/ctranslate2_weight_type", ns: configs, hook_name: "useSelectedCTranslate2WeightType", method_name: "updateSelectedCTranslate2WeightType" }, + { endpoint: "/set/data/ctranslate2_weight_type", ns: configs, hook_name: "useSelectedCTranslate2WeightType", method_name: "updateSelectedCTranslate2WeightType" }, + + { endpoint: "/get/data/selectable_ctranslate2_weight_type_dict", ns: configs, hook_name: "useCTranslate2WeightTypeStatus", method_name: "updateDownloadedCTranslate2WeightTypeStatus" }, + + { endpoint: "/get/data/translation_compute_device_list", ns: configs, hook_name: "useSelectableCTranslate2ComputeDeviceList", method_name: "updateSelectableCTranslate2ComputeDeviceList_FromBackend" }, + + { endpoint: "/get/data/selected_translation_compute_device", ns: configs, hook_name: "useSelectedCTranslate2ComputeDevice", method_name: "updateSelectedCTranslate2ComputeDevice" }, + { endpoint: "/set/data/selected_translation_compute_device", ns: configs, hook_name: "useSelectedCTranslate2ComputeDevice", method_name: "updateSelectedCTranslate2ComputeDevice" }, + + { endpoint: "/run/downloaded_ctranslate2_weight", ns: configs, hook_name: "useCTranslate2WeightTypeStatus", method_name: "downloadedCTranslate2WeightType" }, + { endpoint: "/run/download_ctranslate2_weight", ns: null, hook_name: null, method_name: null }, + { endpoint: "/run/download_progress_ctranslate2_weight", ns: configs, hook_name: "useCTranslate2WeightTypeStatus", method_name: "updateDownloadProgressCTranslate2WeightTypeStatus" }, + + // Transcription + // Transcription (Mic) + { endpoint: "/get/data/mic_record_timeout", ns: configs, hook_name: "useMicRecordTimeout", method_name: "updateMicRecordTimeout" }, + { endpoint: "/set/data/mic_record_timeout", ns: configs, hook_name: "useMicRecordTimeout", method_name: "updateMicRecordTimeout" }, + + { endpoint: "/get/data/mic_phrase_timeout", ns: configs, hook_name: "useMicPhraseTimeout", method_name: "updateMicPhraseTimeout" }, + { endpoint: "/set/data/mic_phrase_timeout", ns: configs, hook_name: "useMicPhraseTimeout", method_name: "updateMicPhraseTimeout" }, + + { endpoint: "/get/data/mic_max_phrases", ns: configs, hook_name: "useMicMaxWords", method_name: "updateMicMaxWords" }, + { endpoint: "/set/data/mic_max_phrases", ns: configs, hook_name: "useMicMaxWords", method_name: "updateMicMaxWords" }, + + { endpoint: "/get/data/mic_word_filter", ns: configs, hook_name: "useMicWordFilterList", method_name: "updateMicWordFilterList_FromBackend" }, + { endpoint: "/set/data/mic_word_filter", ns: configs, hook_name: "useMicWordFilterList", method_name: "updateMicWordFilterList_FromBackend" }, + + // Transcription (Speaker) + { endpoint: "/get/data/speaker_record_timeout", ns: configs, hook_name: "useSpeakerRecordTimeout", method_name: "updateSpeakerRecordTimeout" }, + { endpoint: "/set/data/speaker_record_timeout", ns: configs, hook_name: "useSpeakerRecordTimeout", method_name: "updateSpeakerRecordTimeout" }, + + { endpoint: "/get/data/speaker_phrase_timeout", ns: configs, hook_name: "useSpeakerPhraseTimeout", method_name: "updateSpeakerPhraseTimeout" }, + { endpoint: "/set/data/speaker_phrase_timeout", ns: configs, hook_name: "useSpeakerPhraseTimeout", method_name: "updateSpeakerPhraseTimeout" }, + + { endpoint: "/get/data/speaker_max_phrases", ns: configs, hook_name: "useSpeakerMaxWords", method_name: "updateSpeakerMaxWords" }, + { endpoint: "/set/data/speaker_max_phrases", ns: configs, hook_name: "useSpeakerMaxWords", method_name: "updateSpeakerMaxWords" }, + + // Transcription (AI Models) + { endpoint: "/get/data/selected_transcription_engine", ns: configs, hook_name: "useSelectedTranscriptionEngine", method_name: "updateSelectedTranscriptionEngine" }, + { endpoint: "/set/data/selected_transcription_engine", ns: configs, hook_name: "useSelectedTranscriptionEngine", method_name: "updateSelectedTranscriptionEngine" }, + + { endpoint: "/get/data/whisper_weight_type", ns: configs, hook_name: "useSelectedWhisperWeightType", method_name: "updateSelectedWhisperWeightType" }, + { endpoint: "/set/data/whisper_weight_type", ns: configs, hook_name: "useSelectedWhisperWeightType", method_name: "updateSelectedWhisperWeightType" }, + + { endpoint: "/get/data/selectable_whisper_weight_type_dict", ns: configs, hook_name: "useWhisperWeightTypeStatus", method_name: "updateDownloadedWhisperWeightTypeStatus" }, + + { endpoint: "/run/downloaded_whisper_weight", ns: configs, hook_name: "useWhisperWeightTypeStatus", method_name: "downloadedWhisperWeightType" }, + { endpoint: "/run/download_whisper_weight", ns: null, hook_name: null, method_name: null }, + { endpoint: "/run/download_progress_whisper_weight", ns: configs, hook_name: "useWhisperWeightTypeStatus", method_name: "updateDownloadProgressWhisperWeightTypeStatus" }, + + { endpoint: "/get/data/transcription_compute_device_list", ns: configs, hook_name: "useSelectableWhisperComputeDeviceList", method_name: "updateSelectableWhisperComputeDeviceList_FromBackend" }, + { endpoint: "/get/data/selected_transcription_compute_device", ns: configs, hook_name: "useSelectedWhisperComputeDevice", method_name: "updateSelectedWhisperComputeDevice" }, + { endpoint: "/set/data/selected_transcription_compute_device", ns: configs, hook_name: "useSelectedWhisperComputeDevice", method_name: "updateSelectedWhisperComputeDevice" }, + + // VR + { endpoint: "/get/data/overlay_small_log", ns: configs, hook_name: "useIsEnabledOverlaySmallLog", method_name: "updateIsEnabledOverlaySmallLog" }, + { endpoint: "/set/enable/overlay_small_log", ns: configs, hook_name: "useIsEnabledOverlaySmallLog", method_name: "updateIsEnabledOverlaySmallLog" }, + { endpoint: "/set/disable/overlay_small_log", ns: configs, hook_name: "useIsEnabledOverlaySmallLog", method_name: "updateIsEnabledOverlaySmallLog" }, + + { endpoint: "/get/data/overlay_small_log_settings", ns: configs, hook_name: "useOverlaySmallLogSettings", method_name: "updateOverlaySmallLogSettings" }, + { endpoint: "/set/data/overlay_small_log_settings", ns: configs, hook_name: "useOverlaySmallLogSettings", method_name: "updateOverlaySmallLogSettings" }, + + { endpoint: "/get/data/overlay_large_log", ns: configs, hook_name: "useIsEnabledOverlayLargeLog", method_name: "updateIsEnabledOverlayLargeLog" }, + { endpoint: "/set/enable/overlay_large_log", ns: configs, hook_name: "useIsEnabledOverlayLargeLog", method_name: "updateIsEnabledOverlayLargeLog" }, + { endpoint: "/set/disable/overlay_large_log", ns: configs, hook_name: "useIsEnabledOverlayLargeLog", method_name: "updateIsEnabledOverlayLargeLog" }, + + { endpoint: "/get/data/overlay_large_log_settings", ns: configs, hook_name: "useOverlayLargeLogSettings", method_name: "updateOverlayLargeLogSettings" }, + { endpoint: "/set/data/overlay_large_log_settings", ns: configs, hook_name: "useOverlayLargeLogSettings", method_name: "updateOverlayLargeLogSettings" }, + + { endpoint: "/get/data/overlay_show_only_translated_messages", ns: configs, hook_name: "useOverlayShowOnlyTranslatedMessages", method_name: "updateOverlayShowOnlyTranslatedMessages" }, + { endpoint: "/set/enable/overlay_show_only_translated_messages", ns: configs, hook_name: "useOverlayShowOnlyTranslatedMessages", method_name: "updateOverlayShowOnlyTranslatedMessages" }, + { endpoint: "/set/disable/overlay_show_only_translated_messages", ns: configs, hook_name: "useOverlayShowOnlyTranslatedMessages", method_name: "updateOverlayShowOnlyTranslatedMessages" }, + + { endpoint: "/run/send_text_overlay", ns: null, hook_name: null, method_name: null }, + + + // Others + { endpoint: "/get/data/auto_clear_message_box", ns: configs, hook_name: "useEnableAutoClearMessageInputBox", method_name: "updateEnableAutoClearMessageInputBox" }, + { endpoint: "/set/enable/auto_clear_message_box", ns: configs, hook_name: "useEnableAutoClearMessageInputBox", method_name: "updateEnableAutoClearMessageInputBox" }, + { endpoint: "/set/disable/auto_clear_message_box", ns: configs, hook_name: "useEnableAutoClearMessageInputBox", method_name: "updateEnableAutoClearMessageInputBox" }, + + { endpoint: "/get/data/send_only_translated_messages", ns: configs, hook_name: "useEnableSendOnlyTranslatedMessages", method_name: "updateEnableSendOnlyTranslatedMessages" }, + { endpoint: "/set/enable/send_only_translated_messages", ns: configs, hook_name: "useEnableSendOnlyTranslatedMessages", method_name: "updateEnableSendOnlyTranslatedMessages" }, + { endpoint: "/set/disable/send_only_translated_messages", ns: configs, hook_name: "useEnableSendOnlyTranslatedMessages", method_name: "updateEnableSendOnlyTranslatedMessages" }, + + { endpoint: "/get/data/logger_feature", ns: configs, hook_name: "useEnableAutoExportMessageLogs", method_name: "updateEnableAutoExportMessageLogs" }, + { endpoint: "/set/enable/logger_feature", ns: configs, hook_name: "useEnableAutoExportMessageLogs", method_name: "updateEnableAutoExportMessageLogs" }, + { endpoint: "/set/disable/logger_feature", ns: configs, hook_name: "useEnableAutoExportMessageLogs", method_name: "updateEnableAutoExportMessageLogs" }, + + { endpoint: "/get/data/vrc_mic_mute_sync", ns: configs, hook_name: "useEnableVrcMicMuteSync", method_name: "updateEnableVrcMicMuteSync_FromBackend" }, + { endpoint: "/set/enable/vrc_mic_mute_sync", ns: configs, hook_name: "useEnableVrcMicMuteSync", method_name: "updateEnableVrcMicMuteSync_FromBackend" }, + { endpoint: "/set/disable/vrc_mic_mute_sync", ns: configs, hook_name: "useEnableVrcMicMuteSync", method_name: "updateEnableVrcMicMuteSync_FromBackend" }, + + + { endpoint: "/get/data/send_message_to_vrc", ns: configs, hook_name: "useEnableSendMessageToVrc", method_name: "updateEnableSendMessageToVrc" }, + { endpoint: "/set/enable/send_message_to_vrc", ns: configs, hook_name: "useEnableSendMessageToVrc", method_name: "updateEnableSendMessageToVrc" }, + { endpoint: "/set/disable/send_message_to_vrc", ns: configs, hook_name: "useEnableSendMessageToVrc", method_name: "updateEnableSendMessageToVrc" }, + + { endpoint: "/get/data/send_received_message_to_vrc", ns: configs, hook_name: "useEnableSendReceivedMessageToVrc", method_name: "updateEnableSendReceivedMessageToVrc" }, + { endpoint: "/set/enable/send_received_message_to_vrc", ns: configs, hook_name: "useEnableSendReceivedMessageToVrc", method_name: "updateEnableSendReceivedMessageToVrc" }, + { endpoint: "/set/disable/send_received_message_to_vrc", ns: configs, hook_name: "useEnableSendReceivedMessageToVrc", method_name: "updateEnableSendReceivedMessageToVrc" }, + + { endpoint: "/get/data/notification_vrc_sfx", ns: configs, hook_name: "useEnableNotificationVrcSfx", method_name: "updateEnableNotificationVrcSfx" }, + { endpoint: "/set/enable/notification_vrc_sfx", ns: configs, hook_name: "useEnableNotificationVrcSfx", method_name: "updateEnableNotificationVrcSfx" }, + { endpoint: "/set/disable/notification_vrc_sfx", ns: configs, hook_name: "useEnableNotificationVrcSfx", method_name: "updateEnableNotificationVrcSfx" }, + + // Hotkeys + { endpoint: "/get/data/hotkeys", ns: configs, hook_name: "useHotkeys", method_name: "updateHotkeys" }, + { endpoint: "/set/data/hotkeys", ns: configs, hook_name: "useHotkeys", method_name: "updateHotkeys" }, + + // Plugins + { endpoint: "/get/data/plugins_status", ns: configs, hook_name: "usePlugins", method_name: "updateSavedPluginsStatus" }, + { endpoint: "/set/data/plugins_status", ns: configs, hook_name: "usePlugins", method_name: "updateSavedPluginsStatus" }, + + // Advanced Settings + { endpoint: "/get/data/osc_ip_address", ns: configs, hook_name: "useOscIpAddress", method_name: "updateOscIpAddress" }, + { endpoint: "/set/data/osc_ip_address", ns: configs, hook_name: "useOscIpAddress", method_name: "updateOscIpAddress" }, + + { endpoint: "/get/data/osc_port", ns: configs, hook_name: "useOscPort", method_name: "updateOscPort" }, + { endpoint: "/set/data/osc_port", ns: configs, hook_name: "useOscPort", method_name: "updateOscPort" }, + + { endpoint: "/get/data/websocket_server", ns: configs, hook_name: "useWebsocket", method_name: "updateEnableWebsocket" }, + { endpoint: "/set/enable/websocket_server", ns: configs, hook_name: "useWebsocket", method_name: "updateEnableWebsocket" }, + { endpoint: "/set/disable/websocket_server", ns: configs, hook_name: "useWebsocket", method_name: "updateEnableWebsocket" }, + + { endpoint: "/get/data/websocket_host", ns: configs, hook_name: "useWebsocket", method_name: "updateWebsocketHost" }, + { endpoint: "/set/data/websocket_host", ns: configs, hook_name: "useWebsocket", method_name: "updateWebsocketHost" }, + + { endpoint: "/get/data/websocket_port", ns: configs, hook_name: "useWebsocket", method_name: "updateWebsocketPort" }, + { endpoint: "/set/data/websocket_port", ns: configs, hook_name: "useWebsocket", method_name: "updateWebsocketPort" }, + + + // Not Implemented Yet... + { endpoint: "/get/data/mic_avg_logprob", ns: null, hook_name: null, method_name: null }, // Not implemented on UI yet + { endpoint: "/get/data/mic_no_speech_prob", ns: null, hook_name: null, method_name: null }, // Not implemented on UI yet + { endpoint: "/get/data/speaker_avg_logprob", ns: null, hook_name: null, method_name: null }, // Not implemented on UI yet + { endpoint: "/get/data/speaker_no_speech_prob", ns: null, hook_name: null, method_name: null }, // Not implemented on UI yet + { endpoint: "/get/data/convert_message_to_romaji", ns: null, hook_name: null, method_name: null }, // Not implemented on UI yet + { endpoint: "/get/data/convert_message_to_hiragana", ns: null, hook_name: null, method_name: null }, // Not implemented on UI yet + { endpoint: "/get/data/transcription_engines", ns: null, hook_name: null, method_name: null }, // Not implemented on UI yet. (if ai_models has not been detected, this will be blank array[]. if the ai_models are ok but just network has not connected, it'l be only ["Whisper"]) +]; export const useReceiveRoutes = () => { - const { updateIsVrctAvailable } = useIsVrctAvailable(); - const { updateComputeMode } = useComputeMode(); - const { updateInitProgress } = useInitProgress(); - const { updateIsBackendReady } = useIsBackendReady(); - const { handleOscQuery } = useHandleOscQuery(); - const { restoreWindowGeometry } = useWindow(); - const { updateIsMainPageCompactMode } = useIsMainPageCompactMode(); - const { - updateTranslationStatus, - updateTranscriptionSendStatus, - updateTranscriptionReceiveStatus, - } = useMainFunction(); - const { - updateSelectedPresetTabNumber, - updateEnableMultiTranslation, - updateSelectedYourLanguages, - updateSelectedTargetLanguages, - updateTranslationEngines, - updateSelectedTranslationEngines, - } = useLanguageSettings(); - const { updateSelectableLanguageList } = useSelectableLanguageList(); - const { - addSystemMessageLog, - updateSentMessageLogById, - addSentMessageLog, - addReceivedMessageLog, - } = useMessage(); - const { updateLatestSoftwareVersionInfo } = useSoftwareVersion(); - const { updateSoftwareVersion } = useSoftwareVersion(); - const { updateEnableAutoMicSelect } = useEnableAutoMicSelect(); - const { updateEnableAutoSpeakerSelect } = useEnableAutoSpeakerSelect(); - const { updateMicHostList } = useMicHostList(); - const { updateSelectedMicHost } = useSelectedMicHost(); - const { updateMicDeviceList } = useMicDeviceList(); - const { updateSelectedMicDevice } = useSelectedMicDevice(); - const { updateSpeakerDeviceList } = useSpeakerDeviceList(); - const { updateSelectedSpeakerDevice } = useSelectedSpeakerDevice(); - const { updateMicThreshold, updateEnableAutomaticMicThreshold } = useMicThreshold(); - const { updateSpeakerThreshold, updateEnableAutomaticSpeakerThreshold } = useSpeakerThreshold(); + const { showNotification_Error } = common.useNotificationStatus(); + const { errorHandling_Backend } = _useBackendErrorHandling(); + const { updateIsBackendReady } = common.useIsBackendReady(); - const { updateEnableAutoClearMessageInputBox } = useEnableAutoClearMessageInputBox(); - const { updateEnableSendOnlyTranslatedMessages } = useEnableSendOnlyTranslatedMessages(); - const { updateEnableAutoExportMessageLogs } = useEnableAutoExportMessageLogs(); - const { updateEnableVrcMicMuteSync } = useEnableVrcMicMuteSync(); - const { updateEnableSendMessageToVrc } = useEnableSendMessageToVrc(); - const { updateEnableSendReceivedMessageToVrc } = useEnableSendReceivedMessageToVrc(); - - const { updateSendMessageButtonType } = useSendMessageButtonType(); - const { updateUiLanguage } = useUiLanguage(); - const { updateUiScaling } = useUiScaling(); - const { updateMessageLogUiScaling } = useMessageLogUiScaling(); - const { - updateVolumeVariable_Mic, - updateVolumeVariable_Speaker, - updateMicThresholdCheckStatus, - updateSpeakerThresholdCheckStatus, - } = useVolume(); - - const { updateMessageInputBoxRatio } = useMessageInputBoxRatio(); - const { updateSelectedFontFamily } = useSelectedFontFamily(); - const { updateTransparency } = useTransparency(); - - const { updateMicRecordTimeout } = useMicRecordTimeout(); - const { updateMicPhraseTimeout } = useMicPhraseTimeout(); - const { updateMicMaxWords } = useMicMaxWords(); - const { updateMicWordFilterList } = useMicWordFilterList(); - - const { updateSpeakerRecordTimeout } = useSpeakerRecordTimeout(); - const { updateSpeakerPhraseTimeout } = useSpeakerPhraseTimeout(); - const { updateSpeakerMaxWords } = useSpeakerMaxWords(); - - const { updateDeepLAuthKey, savedDeepLAuthKey } = useDeepLAuthKey(); - const { updateSelectedCTranslate2WeightType } = useSelectedCTranslate2WeightType(); - const { - updateDownloadedCTranslate2WeightTypeStatus, - updateDownloadProgressCTranslate2WeightTypeStatus, - downloadedCTranslate2WeightType, - } = useCTranslate2WeightTypeStatus(); - const { updateSelectableCTranslate2ComputeDeviceList } = useSelectableCTranslate2ComputeDeviceList(); - const { updateSelectedCTranslate2ComputeDevice } = useSelectedCTranslate2ComputeDevice(); - const { updateSelectableWhisperComputeDeviceList } = useSelectableWhisperComputeDeviceList(); - const { updateSelectedWhisperComputeDevice } = useSelectedWhisperComputeDevice(); - - const { updateSelectedTranscriptionEngine } = useSelectedTranscriptionEngine(); - const { updateSelectedWhisperWeightType } = useSelectedWhisperWeightType(); - const { - updateDownloadedWhisperWeightTypeStatus, - updateDownloadProgressWhisperWeightTypeStatus, - downloadedWhisperWeightType, - } = useWhisperWeightTypeStatus(); - - const { updateOverlaySmallLogSettings } = useOverlaySmallLogSettings(); - const { updateIsEnabledOverlaySmallLog } = useIsEnabledOverlaySmallLog(); - const { updateOverlayLargeLogSettings } = useOverlayLargeLogSettings(); - const { updateIsEnabledOverlayLargeLog } = useIsEnabledOverlayLargeLog(); - const { updateOverlayShowOnlyTranslatedMessages } = useOverlayShowOnlyTranslatedMessages(); - const { updateEnableNotificationVrcSfx } = useEnableNotificationVrcSfx(); - - const { updateHotkeys } = useHotkeys(); - const { updateSavedPluginsStatus } = usePlugins(); - - const { updateOscIpAddress } = useOscIpAddress(); - const { updateOscPort } = useOscPort(); - const { - updateEnableWebsocket, - updateWebsocketHost, - updateWebsocketPort, - } = useWebsocket(); - - - - const { showNotification_Success, showNotification_Error } = useNotificationStatus(); - - const { handleNetworkConnection } = useHandleNetworkConnection(); - - const { - errorHandling_Backend, - } = _useBackendErrorHandling(); - - const routes = { - // Common - "/run/feed_watchdog": () => {}, - "/run/initialization_progress": updateInitProgress, - "/run/enable_ai_models": (is_ai_models_available) => { - if (is_ai_models_available === false) { - updateIsVrctAvailable(false); - showNotification_Error("AI models have not been detected. Check the network connection and restart VRCT (it will download automatically, normally).", { hide_duration: null }); - } - }, - "/get/data/compute_mode": updateComputeMode, - "/get/data/main_window_geometry": restoreWindowGeometry, - "/set/data/main_window_geometry": () => {}, - "/run/open_filepath_logs": () => console.log("Opened Directory, Message Logs"), - "/run/open_filepath_config_file": () => console.log("Opened Directory, Config File"), - "/run/software_update_info": (payload) => { - updateLatestSoftwareVersionInfo(prev => ({ - is_update_available: payload.is_update_available, - new_version: payload.new_version || prev.data.new_version, - })); - }, - "/run/connected_network": handleNetworkConnection, - "/run/enable_osc_query": ({data, disabled_functions}) => { - handleOscQuery({ - is_osc_query_enabled: data, - disabled_functions: disabled_functions, - }); - }, - - // Main Page - // Page Controls - "/get/data/main_window_sidebar_compact_mode": updateIsMainPageCompactMode, - "/set/enable/main_window_sidebar_compact_mode": updateIsMainPageCompactMode, - "/set/disable/main_window_sidebar_compact_mode": updateIsMainPageCompactMode, - // Main Functions - "/set/enable/translation": updateTranslationStatus, - "/set/disable/translation": updateTranslationStatus, - "/set/enable/transcription_send": updateTranscriptionSendStatus, - "/set/disable/transcription_send": updateTranscriptionSendStatus, - "/set/enable/transcription_receive": updateTranscriptionReceiveStatus, - "/set/disable/transcription_receive": updateTranscriptionReceiveStatus, - - // Language Settings - "/get/data/selected_tab_no": updateSelectedPresetTabNumber, - "/set/data/selected_tab_no": updateSelectedPresetTabNumber, - "/get/data/multi_language_translation": updateEnableMultiTranslation, - "/get/data/selected_your_languages": updateSelectedYourLanguages, - "/set/data/selected_your_languages": updateSelectedYourLanguages, - "/get/data/selected_target_languages": updateSelectedTargetLanguages, - "/set/data/selected_target_languages": updateSelectedTargetLanguages, - - "/get/data/translation_engines": (payload) => { - const updateTranslatorAvailability = (keys) => { - return translator_status.map(translator => ({ - ...translator, - is_available: keys.includes(translator.id), - })); - }; - const updated_list = updateTranslatorAvailability(payload); - updateTranslationEngines(updated_list); - }, - "/run/translation_engines": (payload) => { - const updateTranslatorAvailability = (keys) => { - return translator_status.map(translator => ({ - ...translator, - is_available: keys.includes(translator.id), - })); - }; - const updated_list = updateTranslatorAvailability(payload); - updateTranslationEngines(updated_list); - }, - "/get/data/selected_translation_engines": updateSelectedTranslationEngines, - "/set/data/selected_translation_engines": updateSelectedTranslationEngines, - "/run/selected_translation_engines": updateSelectedTranslationEngines, - - "/run/swap_your_language_and_target_language": (payload) => { - updateSelectedYourLanguages(payload.your); - updateSelectedTargetLanguages(payload.target); - }, - - - // Language Selector - "/get/data/selectable_language_list": updateSelectableLanguageList, - - // Message - "/run/send_message_box": updateSentMessageLogById, - "/run/typing_message_box": ()=>{}, - "/run/stop_typing_message_box": ()=>{}, - "/run/transcription_send_mic_message": addSentMessageLog, - "/run/transcription_receive_speaker_message": addReceivedMessageLog, - - // Message Box - "/get/data/message_box_ratio": updateMessageInputBoxRatio, - "/set/data/message_box_ratio": updateMessageInputBoxRatio, - - - // Config Page - // Common - "/get/data/version": updateSoftwareVersion, - - // Device Tab - "/get/data/auto_mic_select": updateEnableAutoMicSelect, - "/set/enable/auto_mic_select": updateEnableAutoMicSelect, - "/set/disable/auto_mic_select": updateEnableAutoMicSelect, - "/get/data/auto_speaker_select": updateEnableAutoSpeakerSelect, - "/set/enable/auto_speaker_select": updateEnableAutoSpeakerSelect, - "/set/disable/auto_speaker_select": updateEnableAutoSpeakerSelect, - - "/get/data/mic_host_list": (payload) => updateMicHostList(arrayToObject(payload)), - "/run/mic_host_list": (payload) => updateMicHostList(arrayToObject(payload)), - "/get/data/selected_mic_host": updateSelectedMicHost, - "/set/data/selected_mic_host": (payload) => { - updateSelectedMicHost(payload.host); - updateSelectedMicDevice(payload.device); - }, - - "/get/data/mic_device_list": (payload) => updateMicDeviceList(arrayToObject(payload)), - "/run/mic_device_list": (payload) => updateMicDeviceList(arrayToObject(payload)), - "/get/data/selected_mic_device": updateSelectedMicDevice, - "/set/data/selected_mic_device": updateSelectedMicDevice, - - "/run/selected_mic_device": (payload) => { - - updateSelectedMicHost(payload.host); - updateSelectedMicDevice(payload.device); - }, - - "/get/data/speaker_device_list": (payload) => updateSpeakerDeviceList(arrayToObject(payload)), - "/run/speaker_device_list": (payload) => updateSpeakerDeviceList(arrayToObject(payload)), - "/get/data/selected_speaker_device": updateSelectedSpeakerDevice, - "/set/data/selected_speaker_device": updateSelectedSpeakerDevice, - "/run/selected_speaker_device": updateSelectedSpeakerDevice, - - "/run/check_mic_volume": updateVolumeVariable_Mic, - "/run/check_speaker_volume": updateVolumeVariable_Speaker, - "/set/enable/check_mic_threshold": updateMicThresholdCheckStatus, - "/set/disable/check_mic_threshold": updateMicThresholdCheckStatus, - "/set/enable/check_speaker_threshold": updateSpeakerThresholdCheckStatus, - "/set/disable/check_speaker_threshold": updateSpeakerThresholdCheckStatus, - - "/get/data/mic_threshold": updateMicThreshold, - "/set/data/mic_threshold": updateMicThreshold, - "/get/data/speaker_threshold": updateSpeakerThreshold, - "/set/data/speaker_threshold": updateSpeakerThreshold, - - "/get/data/mic_automatic_threshold": updateEnableAutomaticMicThreshold, - "/set/enable/mic_automatic_threshold": updateEnableAutomaticMicThreshold, - "/set/disable/mic_automatic_threshold": updateEnableAutomaticMicThreshold, - "/get/data/speaker_automatic_threshold": updateEnableAutomaticSpeakerThreshold, - "/set/enable/speaker_automatic_threshold": updateEnableAutomaticSpeakerThreshold, - "/set/disable/speaker_automatic_threshold": updateEnableAutomaticSpeakerThreshold, - - // Appearance - "/get/data/ui_language": updateUiLanguage, - "/set/data/ui_language": updateUiLanguage, - - "/get/data/ui_scaling": updateUiScaling, - "/set/data/ui_scaling": updateUiScaling, - - "/get/data/textbox_ui_scaling": updateMessageLogUiScaling, - "/set/data/textbox_ui_scaling": updateMessageLogUiScaling, - - "/get/data/send_message_button_type": updateSendMessageButtonType, - "/set/data/send_message_button_type": updateSendMessageButtonType, - - "/get/data/font_family": updateSelectedFontFamily, - "/set/data/font_family": updateSelectedFontFamily, - - "/get/data/transparency": updateTransparency, - "/set/data/transparency": updateTransparency, - - // Translation - "/get/data/deepl_auth_key": updateDeepLAuthKey, - "/set/data/deepl_auth_key": savedDeepLAuthKey, - "/delete/data/deepl_auth_key": () => updateDeepLAuthKey(""), - - "/get/data/ctranslate2_weight_type": updateSelectedCTranslate2WeightType, - "/set/data/ctranslate2_weight_type": updateSelectedCTranslate2WeightType, - - "/get/data/selectable_ctranslate2_weight_type_dict": updateDownloadedCTranslate2WeightTypeStatus, - - "/get/data/translation_compute_device_list": (payload) => updateSelectableCTranslate2ComputeDeviceList(transformToIndexedArray(payload)), - "/get/data/selected_translation_compute_device": updateSelectedCTranslate2ComputeDevice, - "/set/data/selected_translation_compute_device": updateSelectedCTranslate2ComputeDevice, - - "/run/downloaded_ctranslate2_weight": downloadedCTranslate2WeightType, - "/run/download_ctranslate2_weight": () => {}, - "/run/download_progress_ctranslate2_weight": updateDownloadProgressCTranslate2WeightTypeStatus, - - // Transcription - "/get/data/mic_record_timeout": updateMicRecordTimeout, - "/set/data/mic_record_timeout": updateMicRecordTimeout, - - "/get/data/mic_phrase_timeout": updateMicPhraseTimeout, - "/set/data/mic_phrase_timeout": updateMicPhraseTimeout, - - "/get/data/mic_max_phrases": updateMicMaxWords, - "/set/data/mic_max_phrases": updateMicMaxWords, - - "/get/data/mic_word_filter": (payload) => { - updateMicWordFilterList((prev_list) => { - const updated_list = [...prev_list.data]; - for (const value of payload) { - const existing_item = updated_list.find(item => item.value === value); - if (existing_item) { - existing_item.is_redoable = false; - } else { - updated_list.push({ value, is_redoable: false }); - } - } - return updated_list; - }); - }, - "/set/data/mic_word_filter": (payload) => { - updateMicWordFilterList((prev_list) => { - const updated_list = [...prev_list.data]; - for (const value of payload) { - const existing_item = updated_list.find(item => item.value === value); - if (existing_item) { - existing_item.is_redoable = false; - } else { - updated_list.push({ value, is_redoable: false }); - } - } - return updated_list; - }); - }, - "/run/word_filter": (payload) => addSystemMessageLog(payload.message), - - - "/get/data/speaker_record_timeout": updateSpeakerRecordTimeout, - "/set/data/speaker_record_timeout": updateSpeakerRecordTimeout, - - "/get/data/speaker_phrase_timeout": updateSpeakerPhraseTimeout, - "/set/data/speaker_phrase_timeout": updateSpeakerPhraseTimeout, - - "/get/data/speaker_max_phrases": updateSpeakerMaxWords, - "/set/data/speaker_max_phrases": updateSpeakerMaxWords, - - "/get/data/selected_transcription_engine": updateSelectedTranscriptionEngine, - "/set/data/selected_transcription_engine": updateSelectedTranscriptionEngine, - - "/get/data/whisper_weight_type": updateSelectedWhisperWeightType, - "/set/data/whisper_weight_type": updateSelectedWhisperWeightType, - - "/get/data/selectable_whisper_weight_type_dict": updateDownloadedWhisperWeightTypeStatus, - - "/run/downloaded_whisper_weight": downloadedWhisperWeightType, - "/run/download_whisper_weight": () => {}, - "/run/download_progress_whisper_weight": updateDownloadProgressWhisperWeightTypeStatus, - - "/get/data/transcription_compute_device_list": (payload) => updateSelectableWhisperComputeDeviceList(transformToIndexedArray(payload)), - "/get/data/selected_transcription_compute_device": updateSelectedWhisperComputeDevice, - "/set/data/selected_transcription_compute_device": updateSelectedWhisperComputeDevice, - - // VR - "/get/data/overlay_small_log": updateIsEnabledOverlaySmallLog, - "/set/enable/overlay_small_log": updateIsEnabledOverlaySmallLog, - "/set/disable/overlay_small_log": updateIsEnabledOverlaySmallLog, - - "/get/data/overlay_small_log_settings": updateOverlaySmallLogSettings, - "/set/data/overlay_small_log_settings": updateOverlaySmallLogSettings, - - "/get/data/overlay_large_log": updateIsEnabledOverlayLargeLog, - "/set/enable/overlay_large_log": updateIsEnabledOverlayLargeLog, - "/set/disable/overlay_large_log": updateIsEnabledOverlayLargeLog, - - "/get/data/overlay_large_log_settings": updateOverlayLargeLogSettings, - "/set/data/overlay_large_log_settings": updateOverlayLargeLogSettings, - - "/get/data/overlay_show_only_translated_messages": updateOverlayShowOnlyTranslatedMessages, - "/set/enable/overlay_show_only_translated_messages": updateOverlayShowOnlyTranslatedMessages, - "/set/disable/overlay_show_only_translated_messages": updateOverlayShowOnlyTranslatedMessages, - - "/run/send_text_overlay": () => {}, - - // Others Tab - "/get/data/auto_clear_message_box": updateEnableAutoClearMessageInputBox, - "/set/enable/auto_clear_message_box": updateEnableAutoClearMessageInputBox, - "/set/disable/auto_clear_message_box": updateEnableAutoClearMessageInputBox, - - "/get/data/send_only_translated_messages": updateEnableSendOnlyTranslatedMessages, - "/set/enable/send_only_translated_messages": updateEnableSendOnlyTranslatedMessages, - "/set/disable/send_only_translated_messages": updateEnableSendOnlyTranslatedMessages, - - "/get/data/logger_feature": updateEnableAutoExportMessageLogs, - "/set/enable/logger_feature": updateEnableAutoExportMessageLogs, - "/set/disable/logger_feature": updateEnableAutoExportMessageLogs, - - "/get/data/vrc_mic_mute_sync": (payload) => updateEnableVrcMicMuteSync((old_value) => { - return {...old_value.data, is_enabled: payload}; - }), - "/set/enable/vrc_mic_mute_sync": (payload) => updateEnableVrcMicMuteSync((old_value) => { - return {...old_value.data, is_enabled: payload}; - }), - "/set/disable/vrc_mic_mute_sync": (payload) => updateEnableVrcMicMuteSync((old_value) => { - return {...old_value.data, is_enabled: payload}; - }), - - "/get/data/send_message_to_vrc": updateEnableSendMessageToVrc, - "/set/enable/send_message_to_vrc": updateEnableSendMessageToVrc, - "/set/disable/send_message_to_vrc": updateEnableSendMessageToVrc, - - "/get/data/send_received_message_to_vrc": updateEnableSendReceivedMessageToVrc, - "/set/enable/send_received_message_to_vrc": updateEnableSendReceivedMessageToVrc, - "/set/disable/send_received_message_to_vrc": updateEnableSendReceivedMessageToVrc, - - "/get/data/notification_vrc_sfx": updateEnableNotificationVrcSfx, - "/set/enable/notification_vrc_sfx": updateEnableNotificationVrcSfx, - "/set/disable/notification_vrc_sfx": updateEnableNotificationVrcSfx, - - // Hotkeys - "/get/data/hotkeys": updateHotkeys, - "/set/data/hotkeys": updateHotkeys, - - // Plugins - "/get/data/plugins_status": updateSavedPluginsStatus, - "/set/data/plugins_status": updateSavedPluginsStatus, - - // Advanced Settings - "/get/data/osc_ip_address": updateOscIpAddress, - "/set/data/osc_ip_address": updateOscIpAddress, - - "/get/data/osc_port": updateOscPort, - "/set/data/osc_port": updateOscPort, - - "/get/data/websocket_server": updateEnableWebsocket, - "/set/enable/websocket_server": updateEnableWebsocket, - "/set/disable/websocket_server": updateEnableWebsocket, - - "/get/data/websocket_host": updateWebsocketHost, - "/set/data/websocket_host": updateWebsocketHost, - - "/get/data/websocket_port": updateWebsocketPort, - "/set/data/websocket_port": updateWebsocketPort, - - "/get/data/mic_avg_logprob": ()=>{}, // Not implemented on UI yet - "/get/data/mic_no_speech_prob": ()=>{}, // Not implemented on UI yet - "/get/data/speaker_avg_logprob": ()=>{}, // Not implemented on UI yet - "/get/data/speaker_no_speech_prob": ()=>{}, // Not implemented on UI yet - "/get/data/convert_message_to_romaji": ()=>{}, // Not implemented on UI yet - "/get/data/convert_message_to_hiragana": ()=>{}, // Not implemented on UI yet - "/get/data/transcription_engines": ()=>{}, // Not implemented on UI yet. (if ai_models has not been detected, this will be blank array[]. if the ai_models are ok but just network has not connected, it'l be only ["Whisper"]) + const handleInvalidEndpoint = (parsed_data) => { + console.error(`Invalid endpoint: ${parsed_data.endpoint}\nresult: ${JSON.stringify(parsed_data.result)}`); }; + const hook_results = {}; + ROUTE_META_LIST.forEach(({ ns, hook_name }) => { + if (ns && hook_name && !(hook_name in hook_results)) { + hook_results[hook_name] = ns[hook_name](); + } + }); + + const noop = () => {}; + + const routes = Object.fromEntries( + ROUTE_META_LIST.map(({ endpoint, hook_name, method_name }) => { + const result_obj = hook_results[hook_name] || {}; + const fn = result_obj[method_name]; + return [endpoint, typeof fn === "function" ? fn : noop]; + }) + ); + + const receiveRoutes = (parsed_data) => { - const initDataSyncProcess = (payload) => { - for (const [endpoint, value] of Object.entries(payload)) { - const route = routes[endpoint]; - (route) ? route(value) : console.error(`Invalid endpoint: ${endpoint}\nvalue: ${JSON.stringify(value)}`); - } - }; + const { endpoint, status, result } = parsed_data; - const handleInvalidEndpoint = (parsed_data) => { - console.error(`Invalid endpoint: ${parsed_data.endpoint}\nresult: ${JSON.stringify(parsed_data.result)}`); - }; - - if (parsed_data.endpoint === "/run/initialization_complete") { - initDataSyncProcess(parsed_data.result); + if (endpoint === "/run/initialization_complete") { + Object.entries(result).forEach(([ep, value]) => { + if (ep in routes) { + routes[ep](value); + } else { + handleInvalidEndpoint({ endpoint: ep, result: value }); + } + }); updateIsBackendReady(true); return; - }; + } - switch (parsed_data.status) { + + switch (status) { case 200: - const route = routes[parsed_data.endpoint]; - if (route) { - route(parsed_data.result); + if (endpoint in routes) { + routes[endpoint](result); } else { handleInvalidEndpoint(parsed_data); } @@ -580,31 +364,24 @@ export const useReceiveRoutes = () => { result: parsed_data.result, }); break; - case 500: - showNotification_Error( - `An error occurred. Please restart VRCT or contact the developers. ${JSON.stringify(parsed_data.result)}`, { hide_duration: null }); - break; case 348: // console.log(`from backend: %c ${JSON.stringify(parsed_data)}`, style_348); break; + case 500: + showNotification_Error( + `An error occurred. Please restart VRCT or contact the developers. ${JSON.stringify(parsed_data.result)}`, { hide_duration: null }); + break; + default: console.log("Received data status does not match.", parsed_data); - break; } - }; + return { receiveRoutes }; }; const style_348 = [ "color: gray", -].join(";"); - -const transformToIndexedArray = (devices) => { - return devices.reduce((result, device, index) => { - result[index] = device; - return result; - }, {}); -}; \ No newline at end of file +].join(";"); \ No newline at end of file diff --git a/src-ui/store.js b/src-ui/store.js index fcd4c0fd..159385ae 100644 --- a/src-ui/store.js +++ b/src-ui/store.js @@ -153,7 +153,6 @@ export const { atomInstance: Atom_TranscriptionReceiveStatus, useHook: useStore_ export const { atomInstance: Atom_ForegroundStatus, useHook: useStore_ForegroundStatus } = createAtomWithHook(false, "ForegroundStatus", {is_state_ok: true}); export const { atomInstance: Atom_SelectedPresetTabNumber, useHook: useStore_SelectedPresetTabNumber } = createAtomWithHook("1", "SelectedPresetTabNumber"); -export const { atomInstance: Atom_EnableMultiTranslation, useHook: useStore_EnableMultiTranslation } = createAtomWithHook(false, "EnableMultiTranslation"); export const { atomInstance: Atom_SelectedYourLanguages, useHook: useStore_SelectedYourLanguages } = createAtomWithHook({}, "SelectedYourLanguages"); export const { atomInstance: Atom_SelectedTargetLanguages, useHook: useStore_SelectedTargetLanguages } = createAtomWithHook({}, "SelectedTargetLanguages"); diff --git a/src-ui/utils.js b/src-ui/utils.js index 96a87c75..2f5f8bdc 100644 --- a/src-ui/utils.js +++ b/src-ui/utils.js @@ -57,4 +57,12 @@ export const genNumArray = (count, start_from = 0) => { export const genNumObjArray = (count, start_from = 0) => { return arrayToObject(genNumArray(count, start_from)); +}; + +// This is using for only AI models compute device list, currently. (CTranslate2, Whisper) +export const transformToIndexedArray = (devices) => { + return devices.reduce((result, device, index) => { + result[index] = device; + return result; + }, {}); }; \ No newline at end of file From 488655263919d85e41d98b7923f91bae4198fee9 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sat, 14 Jun 2025 03:24:39 +0900 Subject: [PATCH 23/41] [Refactor] Put together device-related logic into useDevice. --- .../ThresholdComponent.jsx | 7 +- .../slider_and_meter/SliderAndMeter.jsx | 7 +- .../setting_box/device/Device.jsx | 44 +-- src-ui/logics/configs/device/useDevice.js | 257 ++++++++++++++++++ .../configs/device/useEnableAutoMicSelect.js | 28 -- .../device/useEnableAutoSpeakerSelect.js | 28 -- .../logics/configs/device/useMicDeviceList.js | 27 -- .../logics/configs/device/useMicHostList.js | 25 -- .../logics/configs/device/useMicThreshold.js | 42 --- .../configs/device/useSelectedMicDevice.js | 24 -- .../configs/device/useSelectedMicHost.js | 37 --- .../device/useSelectedSpeakerDevice.js | 24 -- .../configs/device/useSpeakerDeviceList.js | 26 -- .../configs/device/useSpeakerThreshold.js | 42 --- src-ui/logics/configs/index.js | 11 +- src-ui/logics/useReceiveRoutes.js | 60 ++-- 16 files changed, 318 insertions(+), 371 deletions(-) create mode 100644 src-ui/logics/configs/device/useDevice.js delete mode 100644 src-ui/logics/configs/device/useEnableAutoMicSelect.js delete mode 100644 src-ui/logics/configs/device/useEnableAutoSpeakerSelect.js delete mode 100644 src-ui/logics/configs/device/useMicDeviceList.js delete mode 100644 src-ui/logics/configs/device/useMicHostList.js delete mode 100644 src-ui/logics/configs/device/useMicThreshold.js delete mode 100644 src-ui/logics/configs/device/useSelectedMicDevice.js delete mode 100644 src-ui/logics/configs/device/useSelectedMicHost.js delete mode 100644 src-ui/logics/configs/device/useSelectedSpeakerDevice.js delete mode 100644 src-ui/logics/configs/device/useSpeakerDeviceList.js delete mode 100644 src-ui/logics/configs/device/useSpeakerThreshold.js diff --git a/src-ui/app/config_page/setting_section/setting_box/_components/threshold_component/ThresholdComponent.jsx b/src-ui/app/config_page/setting_section/setting_box/_components/threshold_component/ThresholdComponent.jsx index 018f3845..e9fb29fb 100644 --- a/src-ui/app/config_page/setting_section/setting_box/_components/threshold_component/ThresholdComponent.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/_components/threshold_component/ThresholdComponent.jsx @@ -7,8 +7,7 @@ import { useVolume } from "@logics_common"; import MicSvg from "@images/mic.svg?react"; import HeadphonesSvg from "@images/headphones.svg?react"; import { - useMicThreshold, - useSpeakerThreshold, + useDevice, } from "@logics_configs"; export const ThresholdComponent = (props) => { @@ -27,7 +26,7 @@ const MicComponent = (props) => { currentMicThreshold, setMicThreshold, currentEnableAutomaticMicThreshold, - } = useMicThreshold(); + } = useDevice(); const [ui_threshold, setUiThreshold] = useState(currentMicThreshold.data); const { volumeCheckStart_Mic, @@ -84,7 +83,7 @@ const SpeakerComponent = (props) => { currentSpeakerThreshold, setSpeakerThreshold, currentEnableAutomaticSpeakerThreshold, - } = useSpeakerThreshold(); + } = useDevice(); const [ui_threshold, setUiThreshold] = useState(currentSpeakerThreshold.data); const { volumeCheckStart_Speaker, diff --git a/src-ui/app/config_page/setting_section/setting_box/_components/threshold_component/slider_and_meter/SliderAndMeter.jsx b/src-ui/app/config_page/setting_section/setting_box/_components/threshold_component/slider_and_meter/SliderAndMeter.jsx index 8c67637c..475f2410 100644 --- a/src-ui/app/config_page/setting_section/setting_box/_components/threshold_component/slider_and_meter/SliderAndMeter.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/_components/threshold_component/slider_and_meter/SliderAndMeter.jsx @@ -4,8 +4,7 @@ import { useStore_SpeakerVolume, } from "@store"; import { - useMicThreshold, - useSpeakerThreshold, + useDevice, } from "@logics_configs"; export const SliderAndMeter = (props) => { @@ -24,7 +23,7 @@ export const SliderAndMeter = (props) => { const ThresholdVolumeMeter_Mic = (props) => { const { currentMicVolume } = useStore_MicVolume(); - const { currentEnableAutomaticMicThreshold } = useMicThreshold(); + const { currentEnableAutomaticMicThreshold } = useDevice(); const currentVolumeVariable = Math.min(currentMicVolume.data, props.max); const volume_width_percentage = (currentVolumeVariable / props.max) * 100; @@ -50,7 +49,7 @@ const ThresholdVolumeMeter_Mic = (props) => { const ThresholdVolumeMeter_Speaker = (props) => { const { currentSpeakerVolume } = useStore_SpeakerVolume(); - const { currentEnableAutomaticSpeakerThreshold } = useSpeakerThreshold(); + const { currentEnableAutomaticSpeakerThreshold } = useDevice(); const currentVolumeVariable = Math.min(currentSpeakerVolume.data, props.max); const volume_width_percentage = (currentVolumeVariable / props.max) * 100; diff --git a/src-ui/app/config_page/setting_section/setting_box/device/Device.jsx b/src-ui/app/config_page/setting_section/setting_box/device/Device.jsx index 56b11398..d3f20645 100644 --- a/src-ui/app/config_page/setting_section/setting_box/device/Device.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/device/Device.jsx @@ -4,16 +4,7 @@ import clsx from "clsx"; import { useStore_IsBreakPoint } from "@store"; import { ui_configs } from "@ui_configs"; import { - useEnableAutoMicSelect, - useMicHostList, - useSelectedMicHost, - useMicDeviceList, - useSelectedMicDevice, - useMicThreshold, - useEnableAutoSpeakerSelect, - useSpeakerDeviceList, - useSelectedSpeakerDevice, - useSpeakerThreshold, + useDevice, } from "@logics_configs"; import { @@ -38,13 +29,21 @@ export const Device = () => { const Mic_Container = () => { const { t } = useTranslation(); - const { currentEnableAutoMicSelect, toggleEnableAutoMicSelect } = useEnableAutoMicSelect(); - const { currentSelectedMicHost, setSelectedMicHost } = useSelectedMicHost(); - const { currentMicHostList } = useMicHostList(); - const { currentSelectedMicDevice, setSelectedMicDevice } = useSelectedMicDevice(); - const { currentMicDeviceList } = useMicDeviceList(); + const { + currentEnableAutoMicSelect, + toggleEnableAutoMicSelect, + currentMicDeviceList, + currentMicHostList, + + currentSelectedMicHost, + setSelectedMicHost, + currentSelectedMicDevice, + setSelectedMicDevice, + + currentEnableAutomaticMicThreshold, + toggleEnableAutomaticMicThreshold, + } = useDevice(); const { onMouseLeaveFunction } = useOnMouseLeaveDropdownMenu(); - const { currentEnableAutomaticMicThreshold, toggleEnableAutomaticMicThreshold } = useMicThreshold(); const selectFunction_host = (selected_data) => { setSelectedMicHost(selected_data.selected_id); @@ -139,11 +138,16 @@ const Mic_Container = () => { const Speaker_Container = () => { const { t } = useTranslation(); - const { currentEnableAutoSpeakerSelect, toggleEnableAutoSpeakerSelect } = useEnableAutoSpeakerSelect(); - const { currentSelectedSpeakerDevice, setSelectedSpeakerDevice } = useSelectedSpeakerDevice(); - const { currentSpeakerDeviceList } = useSpeakerDeviceList(); + const { + currentEnableAutoSpeakerSelect, + toggleEnableAutoSpeakerSelect, + currentSpeakerDeviceList, + currentSelectedSpeakerDevice, + setSelectedSpeakerDevice, + currentEnableAutomaticSpeakerThreshold, + toggleEnableAutomaticSpeakerThreshold, + } = useDevice(); const { onMouseLeaveFunction } = useOnMouseLeaveDropdownMenu(); - const { currentEnableAutomaticSpeakerThreshold, toggleEnableAutomaticSpeakerThreshold } = useSpeakerThreshold(); const selectFunction = (selected_data) => { setSelectedSpeakerDevice(selected_data.selected_id); diff --git a/src-ui/logics/configs/device/useDevice.js b/src-ui/logics/configs/device/useDevice.js new file mode 100644 index 00000000..25a05f1c --- /dev/null +++ b/src-ui/logics/configs/device/useDevice.js @@ -0,0 +1,257 @@ +import { + useStore_EnableAutoMicSelect, + useStore_EnableAutoSpeakerSelect, + + useStore_MicDeviceList, + useStore_MicHostList, + useStore_SpeakerDeviceList, + + useStore_SelectedMicHost, + useStore_SelectedMicDevice, + + useStore_SelectedSpeakerDevice, + + useStore_MicThreshold, + useStore_EnableAutomaticMicThreshold, + useStore_SpeakerThreshold, + useStore_EnableAutomaticSpeakerThreshold, +} from "@store"; +import { useStdoutToPython } from "@useStdoutToPython"; +import { arrayToObject } from "@utils"; + +export const useDevice = () => { + const { asyncStdoutToPython } = useStdoutToPython(); + + const { currentEnableAutoMicSelect, updateEnableAutoMicSelect, pendingEnableAutoMicSelect } = useStore_EnableAutoMicSelect(); + const { currentEnableAutoSpeakerSelect, updateEnableAutoSpeakerSelect, pendingEnableAutoSpeakerSelect } = useStore_EnableAutoSpeakerSelect(); + + const { currentMicDeviceList, updateMicDeviceList, pendingMicDeviceList } = useStore_MicDeviceList(); + const { currentMicHostList, updateMicHostList, pendingMicHostList } = useStore_MicHostList(); + const { currentSpeakerDeviceList, updateSpeakerDeviceList, pendingSpeakerDeviceList } = useStore_SpeakerDeviceList(); + + const { currentSelectedMicHost, updateSelectedMicHost, pendingSelectedMicHost } = useStore_SelectedMicHost(); + const { currentSelectedMicDevice, updateSelectedMicDevice, pendingSelectedMicDevice } = useStore_SelectedMicDevice(); + + const { currentSelectedSpeakerDevice, updateSelectedSpeakerDevice, pendingSelectedSpeakerDevice } = useStore_SelectedSpeakerDevice(); + + const { updateMicThreshold, currentMicThreshold } = useStore_MicThreshold(); + const { updateEnableAutomaticMicThreshold, currentEnableAutomaticMicThreshold, pendingEnableAutomaticMicThreshold } = useStore_EnableAutomaticMicThreshold(); + + const { updateSpeakerThreshold, currentSpeakerThreshold } = useStore_SpeakerThreshold(); + const { updateEnableAutomaticSpeakerThreshold, currentEnableAutomaticSpeakerThreshold, pendingEnableAutomaticSpeakerThreshold } = useStore_EnableAutomaticSpeakerThreshold(); + + // Auto Select (Mic) + const getEnableAutoMicSelect = () => { + pendingEnableAutoMicSelect(); + asyncStdoutToPython("/get/data/auto_mic_select"); + }; + + const toggleEnableAutoMicSelect = () => { + pendingEnableAutoMicSelect(); + if (currentEnableAutoMicSelect.data) { + asyncStdoutToPython("/set/disable/auto_mic_select"); + } else { + asyncStdoutToPython("/set/enable/auto_mic_select"); + } + }; + // Auto Select (Speaker) + const getEnableAutoSpeakerSelect = () => { + pendingEnableAutoSpeakerSelect(); + asyncStdoutToPython("/get/data/auto_speaker_select"); + }; + + const toggleEnableAutoSpeakerSelect = () => { + pendingEnableAutoSpeakerSelect(); + if (currentEnableAutoSpeakerSelect.data) { + asyncStdoutToPython("/set/disable/auto_speaker_select"); + } else { + asyncStdoutToPython("/set/enable/auto_speaker_select"); + } + }; + + + // List (Mic device) + const getMicDeviceList = () => { + pendingMicDeviceList(); + asyncStdoutToPython("/get/data/mic_device_list"); + }; + + const updateMicDeviceList_FromBackend = (payload) => { + updateMicDeviceList(arrayToObject(payload)); + }; + // List (Mic host) + const getMicHostList = () => { + pendingMicHostList(); + asyncStdoutToPython("/get/data/mic_host_list"); + }; + + const updateMicHostList_FromBackend = (payload) => { + updateMicHostList(arrayToObject(payload)); + }; + // List (Speaker device) + const getSpeakerDeviceList = () => { + pendingSpeakerDeviceList(); + asyncStdoutToPython("/get/data/speaker_device_list"); + }; + + const updateSpeakerDeviceList_FromBackend = (payload) => { + updateSpeakerDeviceList(arrayToObject(payload)); + }; + + + // Selected (Mic host) + const getSelectedMicHost = () => { + pendingSelectedMicHost(); + asyncStdoutToPython("/get/data/selected_mic_host"); + }; + + const setSelectedMicHost = (selected_mic_host) => { + pendingSelectedMicHost(); + asyncStdoutToPython("/set/data/selected_mic_host", selected_mic_host); + }; + // Selected (Mic device) + const getSelectedMicDevice = () => { + pendingSelectedMicDevice(); + asyncStdoutToPython("/get/data/selected_mic_device"); + }; + + const setSelectedMicDevice = (selected_mic_device) => { + pendingSelectedMicDevice(); + asyncStdoutToPython("/set/data/selected_mic_device", selected_mic_device); + }; + + // Selected (Mic and Host) + const updateSelectedMicHostAndDevice = (payload) => { + updateSelectedMicHost(payload.host); + updateSelectedMicDevice(payload.device); + }; + + // Selected (Speaker device) + const getSelectedSpeakerDevice = () => { + pendingSelectedSpeakerDevice(); + asyncStdoutToPython("/get/data/selected_speaker_device"); + }; + + const setSelectedSpeakerDevice = (selected_speaker_device) => { + pendingSelectedSpeakerDevice(); + asyncStdoutToPython("/set/data/selected_speaker_device", selected_speaker_device); + }; + + + // Threshold (Mic) + const getMicThreshold = () => { + asyncStdoutToPython("/get/data/mic_threshold"); + }; + + const setMicThreshold = (mic_threshold) => { + asyncStdoutToPython("/set/data/mic_threshold", mic_threshold); + }; + + const getEnableAutomaticMicThreshold = () => { + pendingEnableAutomaticMicThreshold(); + asyncStdoutToPython("/get/data/mic_automatic_threshold"); + }; + + const toggleEnableAutomaticMicThreshold = () => { + pendingEnableAutomaticMicThreshold(); + if (currentEnableAutomaticMicThreshold.data) { + asyncStdoutToPython("/set/disable/mic_automatic_threshold"); + } else { + asyncStdoutToPython("/set/enable/mic_automatic_threshold"); + } + }; + // Threshold (Speaker) + const getSpeakerThreshold = () => { + asyncStdoutToPython("/get/data/speaker_threshold"); + }; + + const setSpeakerThreshold = (speaker_threshold) => { + asyncStdoutToPython("/set/data/speaker_threshold", speaker_threshold); + }; + + const getEnableAutomaticSpeakerThreshold = () => { + pendingEnableAutomaticSpeakerThreshold(); + asyncStdoutToPython("/get/data/speaker_automatic_threshold"); + }; + + const toggleEnableAutomaticSpeakerThreshold = () => { + pendingEnableAutomaticSpeakerThreshold(); + if (currentEnableAutomaticSpeakerThreshold.data) { + asyncStdoutToPython("/set/disable/speaker_automatic_threshold"); + } else { + asyncStdoutToPython("/set/enable/speaker_automatic_threshold"); + } + }; + + + + return { + currentEnableAutoMicSelect, + getEnableAutoMicSelect, + updateEnableAutoMicSelect, + toggleEnableAutoMicSelect, + + currentEnableAutoSpeakerSelect, + getEnableAutoSpeakerSelect, + updateEnableAutoSpeakerSelect, + toggleEnableAutoSpeakerSelect, + + + currentMicDeviceList, + getMicDeviceList, + updateMicDeviceList, + updateMicDeviceList_FromBackend, + + currentMicHostList, + getMicHostList, + updateMicHostList, + updateMicHostList_FromBackend, + + currentSpeakerDeviceList, + getSpeakerDeviceList, + updateSpeakerDeviceList, + updateSpeakerDeviceList_FromBackend, + + + currentSelectedMicHost, + getSelectedMicHost, + updateSelectedMicHost, + setSelectedMicHost, + + currentSelectedMicDevice, + getSelectedMicDevice, + updateSelectedMicDevice, + setSelectedMicDevice, + + updateSelectedMicHostAndDevice, + + + currentSelectedSpeakerDevice, + getSelectedSpeakerDevice, + updateSelectedSpeakerDevice, + setSelectedSpeakerDevice, + + + currentMicThreshold, + getMicThreshold, + setMicThreshold, + updateMicThreshold, + + currentEnableAutomaticMicThreshold, + getEnableAutomaticMicThreshold, + toggleEnableAutomaticMicThreshold, + updateEnableAutomaticMicThreshold, + + currentSpeakerThreshold, + getSpeakerThreshold, + setSpeakerThreshold, + updateSpeakerThreshold, + + currentEnableAutomaticSpeakerThreshold, + getEnableAutomaticSpeakerThreshold, + toggleEnableAutomaticSpeakerThreshold, + updateEnableAutomaticSpeakerThreshold, + + + }; +}; \ No newline at end of file diff --git a/src-ui/logics/configs/device/useEnableAutoMicSelect.js b/src-ui/logics/configs/device/useEnableAutoMicSelect.js deleted file mode 100644 index c9f7e5d6..00000000 --- a/src-ui/logics/configs/device/useEnableAutoMicSelect.js +++ /dev/null @@ -1,28 +0,0 @@ -import { useStore_EnableAutoMicSelect } from "@store"; -import { useStdoutToPython } from "@useStdoutToPython"; - -export const useEnableAutoMicSelect = () => { - const { asyncStdoutToPython } = useStdoutToPython(); - const { currentEnableAutoMicSelect, updateEnableAutoMicSelect, pendingEnableAutoMicSelect } = useStore_EnableAutoMicSelect(); - - const getEnableAutoMicSelect = () => { - pendingEnableAutoMicSelect(); - asyncStdoutToPython("/get/data/auto_mic_select"); - }; - - const toggleEnableAutoMicSelect = () => { - pendingEnableAutoMicSelect(); - if (currentEnableAutoMicSelect.data) { - asyncStdoutToPython("/set/disable/auto_mic_select"); - } else { - asyncStdoutToPython("/set/enable/auto_mic_select"); - } - }; - - return { - currentEnableAutoMicSelect, - getEnableAutoMicSelect, - updateEnableAutoMicSelect, - toggleEnableAutoMicSelect, - }; -}; \ No newline at end of file diff --git a/src-ui/logics/configs/device/useEnableAutoSpeakerSelect.js b/src-ui/logics/configs/device/useEnableAutoSpeakerSelect.js deleted file mode 100644 index 406cbf25..00000000 --- a/src-ui/logics/configs/device/useEnableAutoSpeakerSelect.js +++ /dev/null @@ -1,28 +0,0 @@ -import { useStore_EnableAutoSpeakerSelect } from "@store"; -import { useStdoutToPython } from "@useStdoutToPython"; - -export const useEnableAutoSpeakerSelect = () => { - const { asyncStdoutToPython } = useStdoutToPython(); - const { currentEnableAutoSpeakerSelect, updateEnableAutoSpeakerSelect, pendingEnableAutoSpeakerSelect } = useStore_EnableAutoSpeakerSelect(); - - const getEnableAutoSpeakerSelect = () => { - pendingEnableAutoSpeakerSelect(); - asyncStdoutToPython("/get/data/auto_speaker_select"); - }; - - const toggleEnableAutoSpeakerSelect = () => { - pendingEnableAutoSpeakerSelect(); - if (currentEnableAutoSpeakerSelect.data) { - asyncStdoutToPython("/set/disable/auto_speaker_select"); - } else { - asyncStdoutToPython("/set/enable/auto_speaker_select"); - } - }; - - return { - currentEnableAutoSpeakerSelect, - getEnableAutoSpeakerSelect, - updateEnableAutoSpeakerSelect, - toggleEnableAutoSpeakerSelect, - }; -}; \ No newline at end of file diff --git a/src-ui/logics/configs/device/useMicDeviceList.js b/src-ui/logics/configs/device/useMicDeviceList.js deleted file mode 100644 index d145a890..00000000 --- a/src-ui/logics/configs/device/useMicDeviceList.js +++ /dev/null @@ -1,27 +0,0 @@ -import { useStore_MicDeviceList } from "@store"; -import { useStdoutToPython } from "@useStdoutToPython"; -import { arrayToObject } from "@utils"; - -export const useMicDeviceList = () => { - const { asyncStdoutToPython } = useStdoutToPython(); - const { currentMicDeviceList, updateMicDeviceList, pendingMicDeviceList } = useStore_MicDeviceList(); - - const getMicDeviceList = () => { - pendingMicDeviceList(); - asyncStdoutToPython("/get/data/mic_device_list"); - }; - - - const updateMicDeviceList_FromBackend = (payload) => { - updateMicDeviceList(arrayToObject(payload)); - }; - - - return { - currentMicDeviceList, - getMicDeviceList, - updateMicDeviceList, - - updateMicDeviceList_FromBackend, - }; -}; \ No newline at end of file diff --git a/src-ui/logics/configs/device/useMicHostList.js b/src-ui/logics/configs/device/useMicHostList.js deleted file mode 100644 index 898f348c..00000000 --- a/src-ui/logics/configs/device/useMicHostList.js +++ /dev/null @@ -1,25 +0,0 @@ -import { useStore_MicHostList } from "@store"; -import { useStdoutToPython } from "@useStdoutToPython"; -import { arrayToObject } from "@utils"; - -export const useMicHostList = () => { - const { asyncStdoutToPython } = useStdoutToPython(); - const { currentMicHostList, updateMicHostList, pendingMicHostList } = useStore_MicHostList(); - - const getMicHostList = () => { - pendingMicHostList(); - asyncStdoutToPython("/get/data/mic_host_list"); - }; - - const updateMicHostList_FromBackend = (payload) => { - updateMicHostList(arrayToObject(payload)); - }; - - return { - currentMicHostList, - getMicHostList, - updateMicHostList, - - updateMicHostList_FromBackend, - }; -}; \ No newline at end of file diff --git a/src-ui/logics/configs/device/useMicThreshold.js b/src-ui/logics/configs/device/useMicThreshold.js deleted file mode 100644 index a6224c38..00000000 --- a/src-ui/logics/configs/device/useMicThreshold.js +++ /dev/null @@ -1,42 +0,0 @@ -import { useStore_MicThreshold, useStore_EnableAutomaticMicThreshold } from "@store"; -import { useStdoutToPython } from "@useStdoutToPython"; - -export const useMicThreshold = () => { - const { asyncStdoutToPython } = useStdoutToPython(); - const { updateMicThreshold, currentMicThreshold } = useStore_MicThreshold(); - const { updateEnableAutomaticMicThreshold, currentEnableAutomaticMicThreshold, pendingEnableAutomaticMicThreshold } = useStore_EnableAutomaticMicThreshold(); - - const getMicThreshold = () => { - asyncStdoutToPython("/get/data/mic_threshold"); - }; - - const setMicThreshold = (mic_threshold) => { - asyncStdoutToPython("/set/data/mic_threshold", mic_threshold); - }; - - const getEnableAutomaticMicThreshold = () => { - pendingEnableAutomaticMicThreshold(); - asyncStdoutToPython("/get/data/mic_automatic_threshold"); - }; - - const toggleEnableAutomaticMicThreshold = () => { - pendingEnableAutomaticMicThreshold(); - if (currentEnableAutomaticMicThreshold.data) { - asyncStdoutToPython("/set/disable/mic_automatic_threshold"); - } else { - asyncStdoutToPython("/set/enable/mic_automatic_threshold"); - } - }; - - return { - currentMicThreshold, - getMicThreshold, - setMicThreshold, - updateMicThreshold, - - currentEnableAutomaticMicThreshold, - getEnableAutomaticMicThreshold, - toggleEnableAutomaticMicThreshold, - updateEnableAutomaticMicThreshold, - }; -}; \ No newline at end of file diff --git a/src-ui/logics/configs/device/useSelectedMicDevice.js b/src-ui/logics/configs/device/useSelectedMicDevice.js deleted file mode 100644 index 6bd7d11a..00000000 --- a/src-ui/logics/configs/device/useSelectedMicDevice.js +++ /dev/null @@ -1,24 +0,0 @@ -import { useStore_SelectedMicDevice } from "@store"; -import { useStdoutToPython } from "@useStdoutToPython"; - -export const useSelectedMicDevice = () => { - const { asyncStdoutToPython } = useStdoutToPython(); - const { currentSelectedMicDevice, updateSelectedMicDevice, pendingSelectedMicDevice } = useStore_SelectedMicDevice(); - - const getSelectedMicDevice = () => { - pendingSelectedMicDevice(); - asyncStdoutToPython("/get/data/selected_mic_device"); - }; - - const setSelectedMicDevice = (selected_mic_device) => { - pendingSelectedMicDevice(); - asyncStdoutToPython("/set/data/selected_mic_device", selected_mic_device); - }; - - return { - currentSelectedMicDevice, - getSelectedMicDevice, - updateSelectedMicDevice, - setSelectedMicDevice, - }; -}; \ No newline at end of file diff --git a/src-ui/logics/configs/device/useSelectedMicHost.js b/src-ui/logics/configs/device/useSelectedMicHost.js deleted file mode 100644 index 0197cfc8..00000000 --- a/src-ui/logics/configs/device/useSelectedMicHost.js +++ /dev/null @@ -1,37 +0,0 @@ -import { useStore_SelectedMicHost } from "@store"; -import { useStdoutToPython } from "@useStdoutToPython"; -import { useSelectedMicDevice } from "@logics_configs"; - -export const useSelectedMicHost = () => { - const { asyncStdoutToPython } = useStdoutToPython(); - const { currentSelectedMicHost, updateSelectedMicHost, pendingSelectedMicHost } = useStore_SelectedMicHost(); - - const { updateSelectedMicDevice } = useSelectedMicDevice(); - - const getSelectedMicHost = () => { - pendingSelectedMicHost(); - asyncStdoutToPython("/get/data/selected_mic_host"); - }; - - const setSelectedMicHost = (selected_mic_host) => { - pendingSelectedMicHost(); - asyncStdoutToPython("/set/data/selected_mic_host", selected_mic_host); - }; - - - // Need refactoring (Duplicated, Host, Device) - const updateSelectedMicHostAndDevice = (payload) => { - updateSelectedMicHost(payload.host); - updateSelectedMicDevice(payload.device); - }; - - - return { - currentSelectedMicHost, - getSelectedMicHost, - updateSelectedMicHost, - setSelectedMicHost, - - updateSelectedMicHostAndDevice, - }; -}; \ No newline at end of file diff --git a/src-ui/logics/configs/device/useSelectedSpeakerDevice.js b/src-ui/logics/configs/device/useSelectedSpeakerDevice.js deleted file mode 100644 index 672a9267..00000000 --- a/src-ui/logics/configs/device/useSelectedSpeakerDevice.js +++ /dev/null @@ -1,24 +0,0 @@ -import { useStore_SelectedSpeakerDevice } from "@store"; -import { useStdoutToPython } from "@useStdoutToPython"; - -export const useSelectedSpeakerDevice = () => { - const { asyncStdoutToPython } = useStdoutToPython(); - const { currentSelectedSpeakerDevice, updateSelectedSpeakerDevice, pendingSelectedSpeakerDevice } = useStore_SelectedSpeakerDevice(); - - const getSelectedSpeakerDevice = () => { - pendingSelectedSpeakerDevice(); - asyncStdoutToPython("/get/data/selected_speaker_device"); - }; - - const setSelectedSpeakerDevice = (selected_speaker_device) => { - pendingSelectedSpeakerDevice(); - asyncStdoutToPython("/set/data/selected_speaker_device", selected_speaker_device); - }; - - return { - currentSelectedSpeakerDevice, - getSelectedSpeakerDevice, - updateSelectedSpeakerDevice, - setSelectedSpeakerDevice, - }; -}; \ No newline at end of file diff --git a/src-ui/logics/configs/device/useSpeakerDeviceList.js b/src-ui/logics/configs/device/useSpeakerDeviceList.js deleted file mode 100644 index b88ed285..00000000 --- a/src-ui/logics/configs/device/useSpeakerDeviceList.js +++ /dev/null @@ -1,26 +0,0 @@ -import { useStore_SpeakerDeviceList } from "@store"; -import { useStdoutToPython } from "@useStdoutToPython"; -import { arrayToObject } from "@utils"; - -export const useSpeakerDeviceList = () => { - const { asyncStdoutToPython } = useStdoutToPython(); - const { currentSpeakerDeviceList, updateSpeakerDeviceList, pendingSpeakerDeviceList } = useStore_SpeakerDeviceList(); - - const getSpeakerDeviceList = () => { - pendingSpeakerDeviceList(); - asyncStdoutToPython("/get/data/speaker_device_list"); - }; - - const updateSpeakerDeviceList_FromBackend = (payload) => { - updateSpeakerDeviceList(arrayToObject(payload)); - }; - - - return { - currentSpeakerDeviceList, - getSpeakerDeviceList, - updateSpeakerDeviceList, - - updateSpeakerDeviceList_FromBackend, - }; -}; \ No newline at end of file diff --git a/src-ui/logics/configs/device/useSpeakerThreshold.js b/src-ui/logics/configs/device/useSpeakerThreshold.js deleted file mode 100644 index c21fe2ef..00000000 --- a/src-ui/logics/configs/device/useSpeakerThreshold.js +++ /dev/null @@ -1,42 +0,0 @@ -import { useStore_SpeakerThreshold, useStore_EnableAutomaticSpeakerThreshold } from "@store"; -import { useStdoutToPython } from "@useStdoutToPython"; - -export const useSpeakerThreshold = () => { - const { asyncStdoutToPython } = useStdoutToPython(); - const { updateSpeakerThreshold, currentSpeakerThreshold } = useStore_SpeakerThreshold(); - const { updateEnableAutomaticSpeakerThreshold, currentEnableAutomaticSpeakerThreshold, pendingEnableAutomaticSpeakerThreshold } = useStore_EnableAutomaticSpeakerThreshold(); - - const getSpeakerThreshold = () => { - asyncStdoutToPython("/get/data/speaker_threshold"); - }; - - const setSpeakerThreshold = (speaker_threshold) => { - asyncStdoutToPython("/set/data/speaker_threshold", speaker_threshold); - }; - - const getEnableAutomaticSpeakerThreshold = () => { - pendingEnableAutomaticSpeakerThreshold(); - asyncStdoutToPython("/get/data/speaker_automatic_threshold"); - }; - - const toggleEnableAutomaticSpeakerThreshold = () => { - pendingEnableAutomaticSpeakerThreshold(); - if (currentEnableAutomaticSpeakerThreshold.data) { - asyncStdoutToPython("/set/disable/speaker_automatic_threshold"); - } else { - asyncStdoutToPython("/set/enable/speaker_automatic_threshold"); - } - }; - - return { - currentSpeakerThreshold, - getSpeakerThreshold, - setSpeakerThreshold, - updateSpeakerThreshold, - - currentEnableAutomaticSpeakerThreshold, - getEnableAutomaticSpeakerThreshold, - toggleEnableAutomaticSpeakerThreshold, - updateEnableAutomaticSpeakerThreshold, - }; -}; \ No newline at end of file diff --git a/src-ui/logics/configs/index.js b/src-ui/logics/configs/index.js index 03214771..aadb1519 100644 --- a/src-ui/logics/configs/index.js +++ b/src-ui/logics/configs/index.js @@ -1,13 +1,4 @@ -export { useEnableAutoMicSelect } from "./device/useEnableAutoMicSelect"; -export { useEnableAutoSpeakerSelect } from "./device/useEnableAutoSpeakerSelect"; -export { useMicDeviceList } from "./device/useMicDeviceList"; -export { useMicHostList } from "./device/useMicHostList"; -export { useMicThreshold } from "./device/useMicThreshold"; -export { useSelectedMicDevice } from "./device/useSelectedMicDevice"; -export { useSelectedMicHost } from "./device/useSelectedMicHost"; -export { useSelectedSpeakerDevice } from "./device/useSelectedSpeakerDevice"; -export { useSpeakerDeviceList } from "./device/useSpeakerDeviceList"; -export { useSpeakerThreshold } from "./device/useSpeakerThreshold"; +export { useDevice } from "./device/useDevice"; export { useMessageLogUiScaling } from "./appearance/useMessageLogUiScaling"; export { useSelectedFontFamily } from "./appearance/useSelectedFontFamily"; diff --git a/src-ui/logics/useReceiveRoutes.js b/src-ui/logics/useReceiveRoutes.js index 54f49203..8961c2cf 100644 --- a/src-ui/logics/useReceiveRoutes.js +++ b/src-ui/logics/useReceiveRoutes.js @@ -91,49 +91,49 @@ export const ROUTE_META_LIST = [ // Config Page // Device - { endpoint: "/get/data/auto_mic_select", ns: configs, hook_name: "useEnableAutoMicSelect", method_name: "updateEnableAutoMicSelect" }, - { endpoint: "/set/enable/auto_mic_select", ns: configs, hook_name: "useEnableAutoMicSelect", method_name: "updateEnableAutoMicSelect" }, - { endpoint: "/set/disable/auto_mic_select", ns: configs, hook_name: "useEnableAutoMicSelect", method_name: "updateEnableAutoMicSelect" }, - { endpoint: "/get/data/auto_speaker_select", ns: configs, hook_name: "useEnableAutoSpeakerSelect", method_name: "updateEnableAutoSpeakerSelect" }, - { endpoint: "/set/enable/auto_speaker_select", ns: configs, hook_name: "useEnableAutoSpeakerSelect", method_name: "updateEnableAutoSpeakerSelect" }, - { endpoint: "/set/disable/auto_speaker_select", ns: configs, hook_name: "useEnableAutoSpeakerSelect", method_name: "updateEnableAutoSpeakerSelect" }, + { endpoint: "/get/data/auto_mic_select", ns: configs, hook_name: "useDevice", method_name: "updateEnableAutoMicSelect" }, + { endpoint: "/set/enable/auto_mic_select", ns: configs, hook_name: "useDevice", method_name: "updateEnableAutoMicSelect" }, + { endpoint: "/set/disable/auto_mic_select", ns: configs, hook_name: "useDevice", method_name: "updateEnableAutoMicSelect" }, + { endpoint: "/get/data/auto_speaker_select", ns: configs, hook_name: "useDevice", method_name: "updateEnableAutoSpeakerSelect" }, + { endpoint: "/set/enable/auto_speaker_select", ns: configs, hook_name: "useDevice", method_name: "updateEnableAutoSpeakerSelect" }, + { endpoint: "/set/disable/auto_speaker_select", ns: configs, hook_name: "useDevice", method_name: "updateEnableAutoSpeakerSelect" }, // Device (Mic) - { endpoint: "/get/data/mic_host_list", ns: configs, hook_name: "useMicHostList", method_name: "updateMicHostList_FromBackend" }, - { endpoint: "/run/mic_host_list", ns: configs, hook_name: "useMicHostList", method_name: "updateMicHostList_FromBackend" }, + { endpoint: "/get/data/mic_host_list", ns: configs, hook_name: "useDevice", method_name: "updateMicHostList_FromBackend" }, + { endpoint: "/run/mic_host_list", ns: configs, hook_name: "useDevice", method_name: "updateMicHostList_FromBackend" }, - { endpoint: "/get/data/selected_mic_host", ns: configs, hook_name: "useSelectedMicHost", method_name: "updateSelectedMicHost" }, - { endpoint: "/set/data/selected_mic_host", ns: configs, hook_name: "useSelectedMicHost", method_name: "updateSelectedMicHostAndDevice" }, // Need refactoring (Duplicated, Host, Device) + { endpoint: "/get/data/selected_mic_host", ns: configs, hook_name: "useDevice", method_name: "updateSelectedMicHost" }, + { endpoint: "/set/data/selected_mic_host", ns: configs, hook_name: "useDevice", method_name: "updateSelectedMicHostAndDevice" }, - { endpoint: "/get/data/mic_device_list", ns: configs, hook_name: "useMicDeviceList", method_name: "updateMicDeviceList_FromBackend" }, - { endpoint: "/run/mic_device_list", ns: configs, hook_name: "useMicDeviceList", method_name: "updateMicDeviceList_FromBackend" }, + { endpoint: "/get/data/mic_device_list", ns: configs, hook_name: "useDevice", method_name: "updateMicDeviceList_FromBackend" }, + { endpoint: "/run/mic_device_list", ns: configs, hook_name: "useDevice", method_name: "updateMicDeviceList_FromBackend" }, - { endpoint: "/get/data/selected_mic_device", ns: configs, hook_name: "useSelectedMicDevice", method_name: "updateSelectedMicDevice" }, - { endpoint: "/set/data/selected_mic_device", ns: configs, hook_name: "useSelectedMicDevice", method_name: "updateSelectedMicDevice" }, + { endpoint: "/get/data/selected_mic_device", ns: configs, hook_name: "useDevice", method_name: "updateSelectedMicDevice" }, + { endpoint: "/set/data/selected_mic_device", ns: configs, hook_name: "useDevice", method_name: "updateSelectedMicDevice" }, - { endpoint: "/run/selected_mic_device", ns: configs, hook_name: "useSelectedMicHost", method_name: "updateSelectedMicHostAndDevice" }, // Need refactoring (Duplicated, Host, Device) + { endpoint: "/run/selected_mic_device", ns: configs, hook_name: "useDevice", method_name: "updateSelectedMicHostAndDevice" }, // Device (Speaker) - { endpoint: "/get/data/speaker_device_list", ns: configs, hook_name: "useSpeakerDeviceList", method_name: "updateSpeakerDeviceList_FromBackend" }, - { endpoint: "/run/speaker_device_list", ns: configs, hook_name: "useSpeakerDeviceList", method_name: "updateSpeakerDeviceList_FromBackend" }, + { endpoint: "/get/data/speaker_device_list", ns: configs, hook_name: "useDevice", method_name: "updateSpeakerDeviceList_FromBackend" }, + { endpoint: "/run/speaker_device_list", ns: configs, hook_name: "useDevice", method_name: "updateSpeakerDeviceList_FromBackend" }, - { endpoint: "/get/data/selected_speaker_device", ns: configs, hook_name: "useSelectedSpeakerDevice", method_name: "updateSelectedSpeakerDevice" }, - { endpoint: "/set/data/selected_speaker_device", ns: configs, hook_name: "useSelectedSpeakerDevice", method_name: "updateSelectedSpeakerDevice" }, - { endpoint: "/run/selected_speaker_device", ns: configs, hook_name: "useSelectedSpeakerDevice", method_name: "updateSelectedSpeakerDevice" }, + { endpoint: "/get/data/selected_speaker_device", ns: configs, hook_name: "useDevice", method_name: "updateSelectedSpeakerDevice" }, + { endpoint: "/set/data/selected_speaker_device", ns: configs, hook_name: "useDevice", method_name: "updateSelectedSpeakerDevice" }, + { endpoint: "/run/selected_speaker_device", ns: configs, hook_name: "useDevice", method_name: "updateSelectedSpeakerDevice" }, // Device (Threshold) - { endpoint: "/get/data/mic_threshold", ns: configs, hook_name: "useMicThreshold", method_name: "updateMicThreshold" }, - { endpoint: "/set/data/mic_threshold", ns: configs, hook_name: "useMicThreshold", method_name: "updateMicThreshold" }, - { endpoint: "/get/data/speaker_threshold", ns: configs, hook_name: "useSpeakerThreshold", method_name: "updateSpeakerThreshold" }, - { endpoint: "/set/data/speaker_threshold", ns: configs, hook_name: "useSpeakerThreshold", method_name: "updateSpeakerThreshold" }, + { endpoint: "/get/data/mic_threshold", ns: configs, hook_name: "useDevice", method_name: "updateMicThreshold" }, + { endpoint: "/set/data/mic_threshold", ns: configs, hook_name: "useDevice", method_name: "updateMicThreshold" }, + { endpoint: "/get/data/speaker_threshold", ns: configs, hook_name: "useDevice", method_name: "updateSpeakerThreshold" }, + { endpoint: "/set/data/speaker_threshold", ns: configs, hook_name: "useDevice", method_name: "updateSpeakerThreshold" }, - { endpoint: "/get/data/mic_automatic_threshold", ns: configs, hook_name: "useMicThreshold", method_name: "updateEnableAutomaticMicThreshold" }, - { endpoint: "/set/enable/mic_automatic_threshold", ns: configs, hook_name: "useMicThreshold", method_name: "updateEnableAutomaticMicThreshold" }, - { endpoint: "/set/disable/mic_automatic_threshold", ns: configs, hook_name: "useMicThreshold", method_name: "updateEnableAutomaticMicThreshold" }, - { endpoint: "/get/data/speaker_automatic_threshold", ns: configs, hook_name: "useSpeakerThreshold", method_name: "updateEnableAutomaticSpeakerThreshold" }, - { endpoint: "/set/enable/speaker_automatic_threshold", ns: configs, hook_name: "useSpeakerThreshold", method_name: "updateEnableAutomaticSpeakerThreshold" }, - { endpoint: "/set/disable/speaker_automatic_threshold", ns: configs, hook_name: "useSpeakerThreshold", method_name: "updateEnableAutomaticSpeakerThreshold" }, + { endpoint: "/get/data/mic_automatic_threshold", ns: configs, hook_name: "useDevice", method_name: "updateEnableAutomaticMicThreshold" }, + { endpoint: "/set/enable/mic_automatic_threshold", ns: configs, hook_name: "useDevice", method_name: "updateEnableAutomaticMicThreshold" }, + { endpoint: "/set/disable/mic_automatic_threshold", ns: configs, hook_name: "useDevice", method_name: "updateEnableAutomaticMicThreshold" }, + { endpoint: "/get/data/speaker_automatic_threshold", ns: configs, hook_name: "useDevice", method_name: "updateEnableAutomaticSpeakerThreshold" }, + { endpoint: "/set/enable/speaker_automatic_threshold", ns: configs, hook_name: "useDevice", method_name: "updateEnableAutomaticSpeakerThreshold" }, + { endpoint: "/set/disable/speaker_automatic_threshold", ns: configs, hook_name: "useDevice", method_name: "updateEnableAutomaticSpeakerThreshold" }, // Appearance From acae7644ebbf4854a98514c2d7e668d10e337b48 Mon Sep 17 00:00:00 2001 From: misyaguziya <53165965+misyaguziya@users.noreply.github.com> Date: Sun, 15 Jun 2025 15:54:41 +0900 Subject: [PATCH 24/41] =?UTF-8?q?[bugfix]=20ttf=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E3=83=90=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-python/model.py | 12 +++---- src-python/models/overlay/overlay_image.py | 40 ++++++++++++++-------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src-python/model.py b/src-python/model.py index b40936b5..6646ee1e 100644 --- a/src-python/model.py +++ b/src-python/model.py @@ -96,7 +96,7 @@ class Model: "large": overlay_large_log_settings, } self.overlay = Overlay(overlay_settings) - self.overlay_image = OverlayImage() + self.overlay_image = OverlayImage(config.PATH_LOCAL) self.mic_audio_queue = None self.mic_mute_status = None self.kks = kakasi() @@ -725,13 +725,13 @@ class Model: def createOverlayImageSmallMessage(self, message): ui_language = config.UI_LANGUAGE convert_languages = { - "en": "Japanese", + "en": "Default", "jp": "Japanese", "ko":"Korean", "zh-Hans":"Chinese Simplified", "zh-Hant":"Chinese Traditional", } - language = convert_languages.get(ui_language, "Japanese") + language = convert_languages.get(ui_language, "Default") return self.overlay_image.createOverlayImageSmallLog(message, language) def clearOverlayImageSmallLog(self): @@ -777,14 +777,14 @@ class Model: def createOverlayImageLargeMessage(self, message): ui_language = config.UI_LANGUAGE convert_languages = { - "en": "Japanese", + "en": "Default", "jp": "Japanese", "ko":"Korean", "zh-Hans":"Chinese Simplified", "zh-Hant":"Chinese Traditional", } - language = convert_languages.get(ui_language, "Japanese") - overlay_image = OverlayImage() + language = convert_languages.get(ui_language, "Default") + overlay_image = OverlayImage(config.PATH_LOCAL) for _ in range(2): overlay_image.createOverlayImageLargeLog("send", message, language) diff --git a/src-python/models/overlay/overlay_image.py b/src-python/models/overlay/overlay_image.py index 52fd242d..39de7f83 100644 --- a/src-python/models/overlay/overlay_image.py +++ b/src-python/models/overlay/overlay_image.py @@ -11,14 +11,20 @@ except ImportError: class OverlayImage: LANGUAGES = { - "Japanese": "NotoSansJP-Regular", - "Korean": "NotoSansKR-Regular", - "Chinese Simplified": "NotoSansSC-Regular", - "Chinese Traditional": "NotoSansTC-Regular", + "Default": "NotoSansJP-Regular.ttf", + "Japanese": "NotoSansJP-Regular.ttf", + "Korean": "NotoSansKR-Regular.ttf", + "Chinese Simplified": "NotoSansSC-Regular.ttf", + "Chinese Traditional": "NotoSansTC-Regular.ttf", } - def __init__(self): + def __init__(self, root_path: str=None): self.message_log = [] + if root_path is None: + self.root_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts") + else: + self.root_path = os_path.join(root_path, "_internal", "fonts") + print(self.root_path) @staticmethod def concatenateImagesVertically(img1: Image, img2: Image, margin: int = 0) -> Image: @@ -54,16 +60,16 @@ class OverlayImage: return colors def createTextboxSmallLog(self, text:str, language:str, text_color:tuple, base_width:int, base_height:int, font_size:int) -> Image: - font_family = self.LANGUAGES.get(language, "NotoSansJP-Regular") + font_family = self.LANGUAGES.get(language, self.LANGUAGES["Default"]) img = Image.new("RGBA", (base_width, base_height), (0, 0, 0, 0)) draw = ImageDraw.Draw(img) try: - font_path = os_path.join(os_path.dirname(os_path.dirname(os_path.dirname(__file__))), "fonts", f"{font_family}.ttf") + font_path = os_path.join(self.root_path, font_family) font = ImageFont.truetype(font_path, font_size) except Exception: errorLogging() - font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", f"{font_family}.ttf") + font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family) font = ImageFont.truetype(font_path, font_size) text_width = draw.textlength(text, font) @@ -98,7 +104,9 @@ class OverlayImage: draw = ImageDraw.Draw(background) draw.rounded_rectangle([(0, 0), img.size], radius=50, fill=background_color, outline=background_outline_color, width=5) - return Image.alpha_composite(background, img) + img = Image.alpha_composite(background, img) + img.save("overlay_small.png") + return img @staticmethod def getUiSizeLargeLog() -> dict: @@ -131,17 +139,17 @@ class OverlayImage: anchor = "lm" if message_type == "receive" else "rm" text_x = 0 if message_type == "receive" else ui_size["width"] align = "left" if message_type == "receive" else "right" - font_family = self.LANGUAGES.get(language, "NotoSansJP-Regular") + font_family = self.LANGUAGES.get(language, self.LANGUAGES["Default"]) img = Image.new("RGBA", (0, 0), (0, 0, 0, 0)) draw = ImageDraw.Draw(img) try: - font_path = os_path.join(os_path.dirname(os_path.dirname(os_path.dirname(__file__))), "fonts", f"{font_family}.ttf") + font_path = os_path.join(self.root_path, font_family) font = ImageFont.truetype(font_path, font_size) except Exception: errorLogging() - font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", f"{font_family}.ttf") + font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family) font = ImageFont.truetype(font_path, font_size) text_width = draw.textlength(text, font) @@ -172,11 +180,11 @@ class OverlayImage: draw = ImageDraw.Draw(img) try: - font_path = os_path.join(os_path.dirname(os_path.dirname(os_path.dirname(__file__))), "fonts", "NotoSansJP-Regular.ttf") + font_path = os_path.join(self.root_path, self.LANGUAGES["Default"]) font = ImageFont.truetype(font_path, font_size) except Exception: errorLogging() - font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", "NotoSansJP-Regular.ttf") + font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", self.LANGUAGES["Default"]) font = ImageFont.truetype(font_path, font_size) text_height = font_size + ui_padding @@ -242,7 +250,9 @@ class OverlayImage: background = Image.new("RGBA", (width, height), (0, 0, 0, 0)) draw = ImageDraw.Draw(background) draw.rounded_rectangle([(0, 0), (width, height)], radius=ui_radius, fill=background_color, outline=background_outline_color, width=5) - return Image.alpha_composite(background, img) + img = Image.alpha_composite(background, img) + img.save("overlay_large.png") + return img if __name__ == "__main__": overlay = OverlayImage() From 3f38bfbba801f5c94cf4f97570082a1e456c0f7d Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sun, 15 Jun 2025 17:49:42 +0900 Subject: [PATCH 25/41] [Update] Resend Message Button: To be store-able the status. Move to Appearance settings. --- locales/en.yml | 4 ++- locales/ja.yml | 4 ++- locales/ko.yml | 1 - locales/zh-Hans.yml | 1 - locales/zh-Hant.yml | 1 - src-python/config.py | 12 ++++++++ src-python/controller.py | 14 ++++++++++ src-python/mainloop.py | 4 +++ .../setting_box/appearance/Appearance.jsx | 17 +++++++++++ .../message_container/MessageContainer.jsx | 6 ++-- .../MessageLogSettingsContainer.jsx | 17 ----------- .../configs/appearance/useShowResendButton.js | 28 +++++++++++++++++++ src-ui/logics/configs/index.js | 1 + src-ui/logics/main/index.js | 1 - .../logics/main/useIsVisibleResendButton.js | 15 ---------- src-ui/logics/useReceiveRoutes.js | 4 +++ src-ui/store.js | 2 +- 17 files changed, 90 insertions(+), 42 deletions(-) create mode 100644 src-ui/logics/configs/appearance/useShowResendButton.js delete mode 100644 src-ui/logics/main/useIsVisibleResendButton.js diff --git a/locales/en.yml b/locales/en.yml index 5138f697..24bb73a8 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -50,7 +50,6 @@ main_page: received: "Received" system: "System" - show_resend_button: "Show Resend Button" resend_button_on_hover_desc: "Press And Hold To Send" state_text_enabled: "Enabled" @@ -120,6 +119,9 @@ config_page: hide: "Hide (Use Enter key to send)" show: "Show" show_and_disable_enter_key: "Show and disable sending using the Enter key." + show_resend_button: + label: "Show Resend Button" + desc: "When hovering over a sent message log, the resend button appears. Click to edit, long press to resend." font_family: label: "Font Family" ui_language: diff --git a/locales/ja.yml b/locales/ja.yml index a9a6901b..bd0ffe60 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -50,7 +50,6 @@ main_page: received: "受信" system: "システム" - show_resend_button: "再送信ボタンを表示する" resend_button_on_hover_desc: "長押しで送信" state_text_enabled: "有効" @@ -120,6 +119,9 @@ config_page: hide: "非表示 (エンターキーを使って送信)" show: "表示" show_and_disable_enter_key: "表示し、エンターキーでの送信を無効" + show_resend_button: + label: "再送信ボタンを表示する" + desc: "送信済メッセージログにマウスホバーすると、再送信ボタンが表示されます。クリックで編集モード、長押しで再送信します。" font_family: label: "使用フォント" ui_language: diff --git a/locales/ko.yml b/locales/ko.yml index 139f41a7..39df6d4a 100644 --- a/locales/ko.yml +++ b/locales/ko.yml @@ -47,7 +47,6 @@ main_page: received: "수신" system: "시스템" - show_resend_button: resend_button_on_hover_desc: state_text_enabled: "Enabled" diff --git a/locales/zh-Hans.yml b/locales/zh-Hans.yml index 0a13c7f8..dd1dafc7 100644 --- a/locales/zh-Hans.yml +++ b/locales/zh-Hans.yml @@ -47,7 +47,6 @@ main_page: received: "接受" system: "系统" - show_resend_button: resend_button_on_hover_desc: state_text_enabled: "启用" diff --git a/locales/zh-Hant.yml b/locales/zh-Hant.yml index 4fd2fce4..08210a7d 100644 --- a/locales/zh-Hant.yml +++ b/locales/zh-Hant.yml @@ -47,7 +47,6 @@ main_page: received: "已接收" system: "系統" - show_resend_button: resend_button_on_hover_desc: state_text_enabled: "啟用" diff --git a/src-python/config.py b/src-python/config.py index 64c09440..e7df74e5 100644 --- a/src-python/config.py +++ b/src-python/config.py @@ -407,6 +407,17 @@ class Config: self._MESSAGE_BOX_RATIO = value self.saveConfig(inspect.currentframe().f_code.co_name, value, immediate_save=True) + @property + @json_serializable('SHOW_RESEND_BUTTON') + def SHOW_RESEND_BUTTON(self): + return self._SHOW_RESEND_BUTTON + + @SHOW_RESEND_BUTTON.setter + def SHOW_RESEND_BUTTON(self, value): + if isinstance(value, bool): + self._SHOW_RESEND_BUTTON = value + self.saveConfig(inspect.currentframe().f_code.co_name, value) + @property @json_serializable('FONT_FAMILY') def FONT_FAMILY(self): @@ -1090,6 +1101,7 @@ class Config: self._UI_SCALING = 100 self._TEXTBOX_UI_SCALING = 100 self._MESSAGE_BOX_RATIO = 10 + self._SHOW_RESEND_BUTTON = False self._FONT_FAMILY = "Yu Gothic UI" self._UI_LANGUAGE = "en" self._MAIN_WINDOW_GEOMETRY = { diff --git a/src-python/controller.py b/src-python/controller.py index 969fff98..760166f1 100644 --- a/src-python/controller.py +++ b/src-python/controller.py @@ -832,6 +832,20 @@ class Controller: config.MESSAGE_BOX_RATIO = data return {"status":200, "result":config.MESSAGE_BOX_RATIO} + @staticmethod + def getShowResendButton(*args, **kwargs) -> dict: + return {"status":200, "result":config.SHOW_RESEND_BUTTON} + + @staticmethod + def setEnableShowResendButton(*args, **kwargs) -> dict: + config.SHOW_RESEND_BUTTON = True + return {"status":200, "result":config.SHOW_RESEND_BUTTON} + + @staticmethod + def setDisableShowResendButton(*args, **kwargs) -> dict: + config.SHOW_RESEND_BUTTON = False + return {"status":200, "result":config.SHOW_RESEND_BUTTON} + @staticmethod def getFontFamily(*args, **kwargs) -> dict: return {"status":200, "result":config.FONT_FAMILY} diff --git a/src-python/mainloop.py b/src-python/mainloop.py index 28207de5..fa1b0da9 100644 --- a/src-python/mainloop.py +++ b/src-python/mainloop.py @@ -131,6 +131,10 @@ mapping = { "/get/data/message_box_ratio": {"status": True, "variable":controller.getMessageBoxRatio}, "/set/data/message_box_ratio": {"status": True, "variable":controller.setMessageBoxRatio}, + "/get/data/show_resend_button": {"status": True, "variable":controller.getShowResendButton}, + "/set/enable/show_resend_button": {"status": True, "variable":controller.setEnableShowResendButton}, + "/set/disable/show_resend_button": {"status": True, "variable":controller.setDisableShowResendButton}, + "/get/data/font_family": {"status": True, "variable":controller.getFontFamily}, "/set/data/font_family": {"status": True, "variable":controller.setFontFamily}, diff --git a/src-ui/app/config_page/setting_section/setting_box/appearance/Appearance.jsx b/src-ui/app/config_page/setting_section/setting_box/appearance/Appearance.jsx index d9ecb7c6..29a300cb 100644 --- a/src-ui/app/config_page/setting_section/setting_box/appearance/Appearance.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/appearance/Appearance.jsx @@ -14,6 +14,7 @@ import { useUiScaling, useMessageLogUiScaling, useSendMessageButtonType, + useShowResendButton, useSelectedFontFamily, useTransparency, } from "@logics_configs"; @@ -22,6 +23,7 @@ import { SliderContainer, DropdownMenuContainer, RadioButtonContainer, + CheckboxContainer, } from "../_templates/Templates"; export const Appearance = () => { @@ -31,6 +33,7 @@ export const Appearance = () => {{t("main_page.message_log.show_resend_button")}
-