diff --git a/src-ui/app/config_page/setting_section/setting_box/about_vrct/AboutVrct.jsx b/src-ui/app/config_page/setting_section/setting_box/about_vrct/AboutVrct.jsx index a04c02bd..a939ebbe 100644 --- a/src-ui/app/config_page/setting_section/setting_box/about_vrct/AboutVrct.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/about_vrct/AboutVrct.jsx @@ -28,12 +28,12 @@ import poster_showcase_section_title from "@images/about_vrct/poster_showcase_se import clsx from "clsx"; import { useI18n } from "@useI18n"; -import { useStore_UiLanguage } from "@store"; +import { useAppearance } from "@logics_configs"; import { PosterShowcaseContents } from "./poster_showcase_contents/PosterShowcaseContents"; export const AboutVrct = () => { const { t } = useI18n(); - const { currentUiLanguage } = useStore_UiLanguage(); + const { currentUiLanguage } = useAppearance(); return (
diff --git a/src-ui/app/config_page/setting_section/setting_box/about_vrct/poster_showcase_contents/posters_contents/PostersContents.jsx b/src-ui/app/config_page/setting_section/setting_box/about_vrct/poster_showcase_contents/posters_contents/PostersContents.jsx index 6cb5ffe1..2668ea4d 100644 --- a/src-ui/app/config_page/setting_section/setting_box/about_vrct/poster_showcase_contents/posters_contents/PostersContents.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/about_vrct/poster_showcase_contents/posters_contents/PostersContents.jsx @@ -1,6 +1,6 @@ import clsx from "clsx"; import styles from "./PostersContents.module.scss"; -import { useStore_UiLanguage } from "@store"; +import { useAppearance } from "@logics_configs"; import { useStore_VrctPosterIndex } from "@store"; import ArrowLeftSvg from "@images/arrow_left.svg?react"; @@ -30,7 +30,7 @@ import poster_images_authors_m_en from "@images/about_vrct/vrct_posters/authors/ export const PostersContents = () => { const { currentVrctPosterIndex, updateVrctPosterIndex } = useStore_VrctPosterIndex(); - const { currentUiLanguage } = useStore_UiLanguage(); + const { currentUiLanguage } = useAppearance(); const updateIndex = (delta) => { diff --git a/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx b/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx index 1bc5cd07..11eb9818 100644 --- a/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/transcription/Transcription.jsx @@ -232,8 +232,8 @@ const WhisperWeightType_Box = () => { const { t } = useI18n(); const { currentWhisperWeightTypeStatus, - pendingWhisperWeightType, - downloadWhisperWeight, + pendingWhisperWeightTypeStatus, + downloadWhisperWeightTypeStatus, } = useTranscription(); const { currentSelectedWhisperWeightType, setSelectedWhisperWeightType } = useTranscription(); @@ -242,8 +242,8 @@ const WhisperWeightType_Box = () => { }; const downloadStartFunction = (id) => { - pendingWhisperWeightType(id); - downloadWhisperWeight(id); + pendingWhisperWeightTypeStatus(id); + downloadWhisperWeightTypeStatus(id); }; const new_labels = [ diff --git a/src-ui/app/config_page/setting_section/setting_box/translation/Translation.jsx b/src-ui/app/config_page/setting_section/setting_box/translation/Translation.jsx index 53cecc0e..3b142b6a 100644 --- a/src-ui/app/config_page/setting_section/setting_box/translation/Translation.jsx +++ b/src-ui/app/config_page/setting_section/setting_box/translation/Translation.jsx @@ -34,8 +34,8 @@ const CTranslate2WeightType_Box = () => { const { t } = useI18n(); const { currentCTranslate2WeightTypeStatus, - pendingCTranslate2WeightType, - downloadCTranslate2Weight, + pendingCTranslate2WeightTypeStatus, + downloadCTranslate2WeightTypeStatus, currentSelectedCTranslate2WeightType, setSelectedCTranslate2WeightType, @@ -46,8 +46,8 @@ const CTranslate2WeightType_Box = () => { }; const downloadStartFunction = (id) => { - pendingCTranslate2WeightType(id); - downloadCTranslate2Weight(id); + pendingCTranslate2WeightTypeStatus(id); + downloadCTranslate2WeightTypeStatus(id); }; const new_labels = [ diff --git a/src-ui/app/index.jsx b/src-ui/app/index.jsx index b68e2b3a..d4a8516d 100644 --- a/src-ui/app/index.jsx +++ b/src-ui/app/index.jsx @@ -5,6 +5,7 @@ import "./_index_css/root.css"; import { getCurrentWindow } from "@tauri-apps/api/window"; import { store } from "@store"; + store.appWindow = getCurrentWindow(); import { App } from "./App"; diff --git a/src-ui/logics/configs/appearance/useAppearance.js b/src-ui/logics/configs/appearance/useAppearance.js index dbf5c310..f253441f 100644 --- a/src-ui/logics/configs/appearance/useAppearance.js +++ b/src-ui/logics/configs/appearance/useAppearance.js @@ -1,201 +1,207 @@ -import { - useStore_UiLanguage, - useStore_UiScaling, - useStore_MessageLogUiScaling, - useStore_SendMessageButtonType, - useStore_ShowResendButton, - useStore_SelectedFontFamily, - useStore_Transparency, -} from "@store"; -import { useStdoutToPython } from "@useStdoutToPython"; -import { useI18n } from "@useI18n"; -import { useNotificationStatus } from "@logics_common"; +import { useAppearance_S } from "../../../ui_config_setter"; export const useAppearance = () => { - const { t } = useI18n(); - const { asyncStdoutToPython } = useStdoutToPython(); - const { showNotification_SaveSuccess } = useNotificationStatus(); + return {...useAppearance_S()}; +} - // UI Language - const { currentUiLanguage, updateUiLanguage, pendingUiLanguage } = useStore_UiLanguage(); - // UI Scaling - const { currentUiScaling, updateUiScaling, pendingUiScaling } = useStore_UiScaling(); - // Message Log Ui Scaling - const { currentMessageLogUiScaling, updateMessageLogUiScaling, pendingMessageLogUiScaling } = useStore_MessageLogUiScaling(); - // Send Message Button Type - const { currentSendMessageButtonType, updateSendMessageButtonType, pendingSendMessageButtonType } = useStore_SendMessageButtonType(); - // Show Resend Button - const { currentShowResendButton, updateShowResendButton, pendingShowResendButton } = useStore_ShowResendButton(); - // Selected Font Family - const { currentSelectedFontFamily, updateSelectedFontFamily, pendingSelectedFontFamily } = useStore_SelectedFontFamily(); - // Transparency - const { currentTransparency, updateTransparency, pendingTransparency } = useStore_Transparency(); +// import { +// useStore_UiLanguage, +// useStore_UiScaling, +// useStore_MessageLogUiScaling, +// useStore_SendMessageButtonType, +// useStore_ShowResendButton, +// useStore_SelectedFontFamily, +// useStore_Transparency, +// } from "@store"; +// import { useStdoutToPython } from "@useStdoutToPython"; +// import { useI18n } from "@useI18n"; +// import { useNotificationStatus } from "@logics_common"; + +// export const useAppearance = () => { +// const { t } = useI18n(); +// const { asyncStdoutToPython } = useStdoutToPython(); +// const { showNotification_SaveSuccess } = useNotificationStatus(); + +// // UI Language +// const { currentUiLanguage, updateUiLanguage, pendingUiLanguage } = useStore_UiLanguage(); +// // UI Scaling +// const { currentUiScaling, updateUiScaling, pendingUiScaling } = useStore_UiScaling(); +// // Message Log Ui Scaling +// const { currentMessageLogUiScaling, updateMessageLogUiScaling, pendingMessageLogUiScaling } = useStore_MessageLogUiScaling(); +// // Send Message Button Type +// const { currentSendMessageButtonType, updateSendMessageButtonType, pendingSendMessageButtonType } = useStore_SendMessageButtonType(); +// // Show Resend Button +// const { currentShowResendButton, updateShowResendButton, pendingShowResendButton } = useStore_ShowResendButton(); +// // Selected Font Family +// const { currentSelectedFontFamily, updateSelectedFontFamily, pendingSelectedFontFamily } = useStore_SelectedFontFamily(); +// // Transparency +// const { currentTransparency, updateTransparency, pendingTransparency } = useStore_Transparency(); - // UI Language - const getUiLanguage = () => { - pendingUiLanguage(); - asyncStdoutToPython("/get/data/ui_language"); - }; +// // UI Language +// const getUiLanguage = () => { +// pendingUiLanguage(); +// asyncStdoutToPython("/get/data/ui_language"); +// }; - const setUiLanguage = (selected_ui_language) => { - pendingUiLanguage(); - asyncStdoutToPython("/set/data/ui_language", selected_ui_language); - }; +// const setUiLanguage = (selected_ui_language) => { +// pendingUiLanguage(); +// asyncStdoutToPython("/set/data/ui_language", selected_ui_language); +// }; - const setSuccessUiLanguage = (selected_ui_language) => { - updateUiLanguage(selected_ui_language); - showNotification_SaveSuccess(); - }; +// const setSuccessUiLanguage = (selected_ui_language) => { +// updateUiLanguage(selected_ui_language); +// showNotification_SaveSuccess(); +// }; - // UI Scaling - const getUiScaling = () => { - pendingUiScaling(); - asyncStdoutToPython("/get/data/ui_scaling"); - }; +// // UI Scaling +// const getUiScaling = () => { +// pendingUiScaling(); +// asyncStdoutToPython("/get/data/ui_scaling"); +// }; - const setUiScaling = (selected_ui_scaling) => { - pendingUiScaling(); - asyncStdoutToPython("/set/data/ui_scaling", selected_ui_scaling); - }; +// const setUiScaling = (selected_ui_scaling) => { +// pendingUiScaling(); +// asyncStdoutToPython("/set/data/ui_scaling", selected_ui_scaling); +// }; - const setSuccessUiScaling = (selected_ui_scaling) => { - updateUiScaling(selected_ui_scaling); - showNotification_SaveSuccess(); - }; +// const setSuccessUiScaling = (selected_ui_scaling) => { +// updateUiScaling(selected_ui_scaling); +// showNotification_SaveSuccess(); +// }; - // Message Log Ui Scaling - const getMessageLogUiScaling = () => { - pendingMessageLogUiScaling(); - asyncStdoutToPython("/get/data/textbox_ui_scaling"); - }; +// // Message Log Ui Scaling +// const getMessageLogUiScaling = () => { +// pendingMessageLogUiScaling(); +// asyncStdoutToPython("/get/data/textbox_ui_scaling"); +// }; - const setMessageLogUiScaling = (selected_ui_scaling) => { - pendingMessageLogUiScaling(); - asyncStdoutToPython("/set/data/textbox_ui_scaling", selected_ui_scaling); - }; +// const setMessageLogUiScaling = (selected_ui_scaling) => { +// pendingMessageLogUiScaling(); +// asyncStdoutToPython("/set/data/textbox_ui_scaling", selected_ui_scaling); +// }; - const setSuccessMessageLogUiScaling = (selected_ui_scaling) => { - updateMessageLogUiScaling(selected_ui_scaling); - showNotification_SaveSuccess(); - }; +// const setSuccessMessageLogUiScaling = (selected_ui_scaling) => { +// updateMessageLogUiScaling(selected_ui_scaling); +// showNotification_SaveSuccess(); +// }; - // Send Message Button Type - const getSendMessageButtonType = () => { - pendingSendMessageButtonType(); - asyncStdoutToPython("/get/data/send_message_button_type"); - }; +// // Send Message Button Type +// const getSendMessageButtonType = () => { +// pendingSendMessageButtonType(); +// asyncStdoutToPython("/get/data/send_message_button_type"); +// }; - const setSendMessageButtonType = (send_message_button_type) => { - pendingSendMessageButtonType(); - asyncStdoutToPython("/set/data/send_message_button_type", send_message_button_type); - }; +// const setSendMessageButtonType = (send_message_button_type) => { +// pendingSendMessageButtonType(); +// asyncStdoutToPython("/set/data/send_message_button_type", send_message_button_type); +// }; - const setSuccessSendMessageButtonType = (send_message_button_type) => { - updateSendMessageButtonType(send_message_button_type); - showNotification_SaveSuccess(); - }; +// const setSuccessSendMessageButtonType = (send_message_button_type) => { +// updateSendMessageButtonType(send_message_button_type); +// showNotification_SaveSuccess(); +// }; - // Show Resend Button - const getShowResendButton = () => { - pendingShowResendButton(); - asyncStdoutToPython("/get/data/show_resend_button"); - }; +// // Show Resend Button +// const getShowResendButton = () => { +// pendingShowResendButton(); +// asyncStdoutToPython("/get/data/show_resend_button"); +// }; - const toggleShowResendButton = () => { - pendingShowResendButton(); - if (currentShowResendButton.data) { - asyncStdoutToPython("/set/disable/show_resend_button"); - } else { - asyncStdoutToPython("/set/enable/show_resend_button"); - } - }; - const setSuccessShowResendButton = (to_show) => { - updateShowResendButton(to_show); - showNotification_SaveSuccess(); - }; +// const toggleShowResendButton = () => { +// pendingShowResendButton(); +// if (currentShowResendButton.data) { +// asyncStdoutToPython("/set/disable/show_resend_button"); +// } else { +// asyncStdoutToPython("/set/enable/show_resend_button"); +// } +// }; +// const setSuccessShowResendButton = (to_show) => { +// updateShowResendButton(to_show); +// showNotification_SaveSuccess(); +// }; - // Selected Font Family - const getSelectedFontFamily = () => { - pendingSelectedFontFamily(); - asyncStdoutToPython("/get/data/font_family"); - }; +// // Selected Font Family +// const getSelectedFontFamily = () => { +// pendingSelectedFontFamily(); +// asyncStdoutToPython("/get/data/font_family"); +// }; - const setSelectedFontFamily = (selected_font_family) => { - pendingSelectedFontFamily(); - asyncStdoutToPython("/set/data/font_family", selected_font_family); - }; +// const setSelectedFontFamily = (selected_font_family) => { +// pendingSelectedFontFamily(); +// asyncStdoutToPython("/set/data/font_family", selected_font_family); +// }; - const setSuccessSelectedFontFamily = (selected_font_family) => { - updateSelectedFontFamily(selected_font_family); - showNotification_SaveSuccess(); - }; +// const setSuccessSelectedFontFamily = (selected_font_family) => { +// updateSelectedFontFamily(selected_font_family); +// showNotification_SaveSuccess(); +// }; - // Transparency - const getTransparency = () => { - pendingTransparency(); - asyncStdoutToPython("/get/data/transparency"); - }; +// // Transparency +// const getTransparency = () => { +// pendingTransparency(); +// asyncStdoutToPython("/get/data/transparency"); +// }; - const setTransparency = (selected_transparency) => { - pendingTransparency(); - asyncStdoutToPython("/set/data/transparency", selected_transparency); - }; +// const setTransparency = (selected_transparency) => { +// pendingTransparency(); +// asyncStdoutToPython("/set/data/transparency", selected_transparency); +// }; - const setSuccessTransparency = (selected_transparency) => { - updateTransparency(selected_transparency); - showNotification_SaveSuccess(); - }; +// const setSuccessTransparency = (selected_transparency) => { +// updateTransparency(selected_transparency); +// showNotification_SaveSuccess(); +// }; - return { - // UI Language - currentUiLanguage, - getUiLanguage, - updateUiLanguage, - setUiLanguage, - setSuccessUiLanguage, +// return { +// // UI Language +// currentUiLanguage, +// getUiLanguage, +// updateUiLanguage, +// setUiLanguage, +// setSuccessUiLanguage, - // UI Scaling - currentUiScaling, - getUiScaling, - updateUiScaling, - setUiScaling, - setSuccessUiScaling, +// // UI Scaling +// currentUiScaling, +// getUiScaling, +// updateUiScaling, +// setUiScaling, +// setSuccessUiScaling, - // Message Log Ui Scaling - currentMessageLogUiScaling, - getMessageLogUiScaling, - updateMessageLogUiScaling, - setMessageLogUiScaling, - setSuccessMessageLogUiScaling, +// // Message Log Ui Scaling +// currentMessageLogUiScaling, +// getMessageLogUiScaling, +// updateMessageLogUiScaling, +// setMessageLogUiScaling, +// setSuccessMessageLogUiScaling, - // Send Message Button Type - currentSendMessageButtonType, - getSendMessageButtonType, - setSendMessageButtonType, - setSuccessSendMessageButtonType, - updateSendMessageButtonType, +// // Send Message Button Type +// currentSendMessageButtonType, +// getSendMessageButtonType, +// setSendMessageButtonType, +// setSuccessSendMessageButtonType, +// updateSendMessageButtonType, - // Show Resend Button - currentShowResendButton, - getShowResendButton, - updateShowResendButton, - toggleShowResendButton, - setSuccessShowResendButton, +// // Show Resend Button +// currentShowResendButton, +// getShowResendButton, +// updateShowResendButton, +// toggleShowResendButton, +// setSuccessShowResendButton, - // Selected Font Family - currentSelectedFontFamily, - getSelectedFontFamily, - updateSelectedFontFamily, - setSelectedFontFamily, - setSuccessSelectedFontFamily, +// // Selected Font Family +// currentSelectedFontFamily, +// getSelectedFontFamily, +// updateSelectedFontFamily, +// setSelectedFontFamily, +// setSuccessSelectedFontFamily, - // Transparency - currentTransparency, - getTransparency, - updateTransparency, - setTransparency, - setSuccessTransparency, - }; -}; \ No newline at end of file +// // Transparency +// currentTransparency, +// getTransparency, +// updateTransparency, +// setTransparency, +// setSuccessTransparency, +// }; +// }; \ No newline at end of file diff --git a/src-ui/logics/configs/index.js b/src-ui/logics/configs/index.js index 54e7d133..50e01b55 100644 --- a/src-ui/logics/configs/index.js +++ b/src-ui/logics/configs/index.js @@ -1,11 +1,24 @@ -export { useDevice } from "./device/useDevice"; -export { useAppearance } from "./appearance/useAppearance"; -export { useOthers } from "./others/useOthers"; -export { useTranscription } from "./transcription/useTranscription"; -export { useTranslation } from "./translation/useTranslation"; -export { useVr } from "./vr/useVr"; +// export { useDevice } from "./device/useDevice"; +// export { useAppearance } from "./appearance/useAppearance"; + +export { + useAppearance, + useDevice, + useOthers, + useTranscription, + useTranslation, + useVr, + // useHotkeys, + useAdvancedSettings, +} from "../../ui_config_setter.js"; + +// export { useOthers } from "./others/useOthers"; +// export { useTranscription } from "./transcription/useTranscription"; +// export { useTranslation } from "./translation/useTranslation"; +// export { useVr } from "./vr/useVr"; export { useHotkeys } from "./hotkeys/useHotkeys"; -export { useAdvancedSettings } from "./advanced_settings/useAdvancedSettings"; +// export { useAdvancedSettings } from "./advanced_settings/useAdvancedSettings"; + export { useSupporters } from "./supporters/useSupporters"; export { usePlugins } from "./plugins/usePlugins"; diff --git a/src-ui/logics/useReceiveRoutes.js b/src-ui/logics/useReceiveRoutes.js index 92a5edde..a658fb85 100644 --- a/src-ui/logics/useReceiveRoutes.js +++ b/src-ui/logics/useReceiveRoutes.js @@ -2,8 +2,9 @@ import * as common from "@logics_common"; import * as main from "@logics_main"; import * as configs from "@logics_configs"; import { _useBackendErrorHandling } from "./_useBackendErrorHandling"; +import { SETTINGS_ARRAY } from "../ui_config_setter"; -export const ROUTE_META_LIST = [ +export const STATIC_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" }, @@ -92,154 +93,154 @@ export const ROUTE_META_LIST = [ - // Config Page - // Device - { 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: "setSuccessEnableAutoMicSelect" }, - { endpoint: "/set/disable/auto_mic_select", ns: configs, hook_name: "useDevice", method_name: "setSuccessEnableAutoMicSelect" }, - { 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: "setSuccessEnableAutoSpeakerSelect" }, - { endpoint: "/set/disable/auto_speaker_select", ns: configs, hook_name: "useDevice", method_name: "setSuccessEnableAutoSpeakerSelect" }, + // // Config Page + // // Device + // // { 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: "setSuccessEnableAutoMicSelect" }, + // // { endpoint: "/set/disable/auto_mic_select", ns: configs, hook_name: "useDevice", method_name: "setSuccessEnableAutoMicSelect" }, + // // { 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: "setSuccessEnableAutoSpeakerSelect" }, + // // { endpoint: "/set/disable/auto_speaker_select", ns: configs, hook_name: "useDevice", method_name: "setSuccessEnableAutoSpeakerSelect" }, - // Device (Mic) - { 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" }, + // // // Device (Mic) + // // { 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: "useDevice", method_name: "updateSelectedMicHost" }, - { endpoint: "/set/data/selected_mic_host", ns: configs, hook_name: "useDevice", method_name: "setSuccessSelectedMicHost" }, + // // { 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: "setSuccessSelectedMicHost" }, - { 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/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: "useDevice", method_name: "updateSelectedMicDevice" }, - { endpoint: "/set/data/selected_mic_device", ns: configs, hook_name: "useDevice", method_name: "setSuccessSelectedMicDevice" }, + // // { 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: "setSuccessSelectedMicDevice" }, - { endpoint: "/run/selected_mic_device", ns: configs, hook_name: "useDevice", method_name: "updateSelectedMicHostAndDevice" }, + // // { 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: "useDevice", method_name: "updateSpeakerDeviceList_FromBackend" }, - { endpoint: "/run/speaker_device_list", ns: configs, hook_name: "useDevice", method_name: "updateSpeakerDeviceList_FromBackend" }, + // // // Device (Speaker) + // // { 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: "useDevice", method_name: "updateSelectedSpeakerDevice" }, - { endpoint: "/set/data/selected_speaker_device", ns: configs, hook_name: "useDevice", method_name: "setSuccessSelectedSpeakerDevice" }, - { endpoint: "/run/selected_speaker_device", ns: configs, hook_name: "useDevice", 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: "setSuccessSelectedSpeakerDevice" }, + // // { endpoint: "/run/selected_speaker_device", ns: configs, hook_name: "useDevice", method_name: "updateSelectedSpeakerDevice" }, - // Device (Threshold) - { 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: "setSuccessMicThreshold" }, - { 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: "setSuccessSpeakerThreshold" }, + // // // Device (Threshold) + // // { 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: "setSuccessMicThreshold" }, + // // { 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: "setSuccessSpeakerThreshold" }, - { 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: "setSuccessEnableAutomaticMicThreshold" }, - { endpoint: "/set/disable/mic_automatic_threshold", ns: configs, hook_name: "useDevice", method_name: "setSuccessEnableAutomaticMicThreshold" }, - { 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: "setSuccessEnableAutomaticSpeakerThreshold" }, - { endpoint: "/set/disable/speaker_automatic_threshold", ns: configs, hook_name: "useDevice", method_name: "setSuccessEnableAutomaticSpeakerThreshold" }, + // // { 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: "setSuccessEnableAutomaticMicThreshold" }, + // // { endpoint: "/set/disable/mic_automatic_threshold", ns: configs, hook_name: "useDevice", method_name: "setSuccessEnableAutomaticMicThreshold" }, + // // { 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: "setSuccessEnableAutomaticSpeakerThreshold" }, + // // { endpoint: "/set/disable/speaker_automatic_threshold", ns: configs, hook_name: "useDevice", method_name: "setSuccessEnableAutomaticSpeakerThreshold" }, - // Appearance - { endpoint: "/get/data/ui_language", ns: configs, hook_name: "useAppearance", method_name: "updateUiLanguage" }, - { endpoint: "/set/data/ui_language", ns: configs, hook_name: "useAppearance", method_name: "setSuccessUiLanguage" }, + // // Appearance + // // { endpoint: "/get/data/ui_language", ns: configs, hook_name: "useAppearance", method_name: "updateUiLanguage" }, + // // { endpoint: "/set/data/ui_language", ns: configs, hook_name: "useAppearance", method_name: "setSuccessUiLanguage" }, - { endpoint: "/get/data/ui_scaling", ns: configs, hook_name: "useAppearance", method_name: "updateUiScaling" }, - { endpoint: "/set/data/ui_scaling", ns: configs, hook_name: "useAppearance", method_name: "setSuccessUiScaling" }, + // // { endpoint: "/get/data/ui_scaling", ns: configs, hook_name: "useAppearance", method_name: "updateUiScaling" }, + // // { endpoint: "/set/data/ui_scaling", ns: configs, hook_name: "useAppearance", method_name: "setSuccessUiScaling" }, - { endpoint: "/get/data/textbox_ui_scaling", ns: configs, hook_name: "useAppearance", method_name: "updateMessageLogUiScaling" }, - { endpoint: "/set/data/textbox_ui_scaling", ns: configs, hook_name: "useAppearance", method_name: "setSuccessMessageLogUiScaling" }, + // // { endpoint: "/get/data/textbox_ui_scaling", ns: configs, hook_name: "useAppearance", method_name: "updateMessageLogUiScaling" }, + // // { endpoint: "/set/data/textbox_ui_scaling", ns: configs, hook_name: "useAppearance", method_name: "setSuccessMessageLogUiScaling" }, - { endpoint: "/get/data/send_message_button_type", ns: configs, hook_name: "useAppearance", method_name: "updateSendMessageButtonType" }, - { endpoint: "/set/data/send_message_button_type", ns: configs, hook_name: "useAppearance", method_name: "setSuccessSendMessageButtonType" }, + // // { endpoint: "/get/data/send_message_button_type", ns: configs, hook_name: "useAppearance", method_name: "updateSendMessageButtonType" }, + // // { endpoint: "/set/data/send_message_button_type", ns: configs, hook_name: "useAppearance", method_name: "setSuccessSendMessageButtonType" }, - { endpoint: "/get/data/show_resend_button", ns: configs, hook_name: "useAppearance", method_name: "updateShowResendButton" }, - { endpoint: "/set/enable/show_resend_button", ns: configs, hook_name: "useAppearance", method_name: "setSuccessShowResendButton" }, - { endpoint: "/set/disable/show_resend_button", ns: configs, hook_name: "useAppearance", method_name: "setSuccessShowResendButton" }, + // // { endpoint: "/get/data/show_resend_button", ns: configs, hook_name: "useAppearance", method_name: "updateShowResendButton" }, + // // { endpoint: "/set/enable/show_resend_button", ns: configs, hook_name: "useAppearance", method_name: "setSuccessShowResendButton" }, + // // { endpoint: "/set/disable/show_resend_button", ns: configs, hook_name: "useAppearance", method_name: "setSuccessShowResendButton" }, - { endpoint: "/get/data/font_family", ns: configs, hook_name: "useAppearance", method_name: "updateSelectedFontFamily" }, - { endpoint: "/set/data/font_family", ns: configs, hook_name: "useAppearance", method_name: "setSuccessSelectedFontFamily" }, + // // { endpoint: "/get/data/font_family", ns: configs, hook_name: "useAppearance", method_name: "updateSelectedFontFamily" }, + // // { endpoint: "/set/data/font_family", ns: configs, hook_name: "useAppearance", method_name: "setSuccessSelectedFontFamily" }, - { endpoint: "/get/data/transparency", ns: configs, hook_name: "useAppearance", method_name: "updateTransparency" }, - { endpoint: "/set/data/transparency", ns: configs, hook_name: "useAppearance", method_name: "setSuccessTransparency" }, + // // { endpoint: "/get/data/transparency", ns: configs, hook_name: "useAppearance", method_name: "updateTransparency" }, + // // { endpoint: "/set/data/transparency", ns: configs, hook_name: "useAppearance", method_name: "setSuccessTransparency" }, - // Translation - { endpoint: "/get/data/deepl_auth_key", ns: configs, hook_name: "useTranslation", method_name: "updateDeepLAuthKey" }, - { endpoint: "/set/data/deepl_auth_key", ns: configs, hook_name: "useTranslation", method_name: "setSuccessDeepLAuthKey" }, - { endpoint: "/delete/data/deepl_auth_key", ns: configs, hook_name: "useTranslation", method_name: "deleteSuccessDeepLAuthKey" }, + // // Translation + // { endpoint: "/get/data/deepl_auth_key", ns: configs, hook_name: "useTranslation", method_name: "updateDeepLAuthKey" }, + // { endpoint: "/set/data/deepl_auth_key", ns: configs, hook_name: "useTranslation", method_name: "setSuccessDeepLAuthKey" }, + // { endpoint: "/delete/data/deepl_auth_key", ns: configs, hook_name: "useTranslation", method_name: "deleteSuccessDeepLAuthKey" }, - // Translation (AI Models) - { endpoint: "/get/data/selectable_ctranslate2_weight_type_dict", ns: configs, hook_name: "useTranslation", method_name: "updateDownloadedCTranslate2WeightTypeStatus" }, - { endpoint: "/get/data/ctranslate2_weight_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedCTranslate2WeightType" }, - { endpoint: "/set/data/ctranslate2_weight_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedCTranslate2WeightType" }, + // // Translation (AI Models) + // { endpoint: "/get/data/selectable_ctranslate2_weight_type_dict", ns: configs, hook_name: "useTranslation", method_name: "updateDownloadedCTranslate2WeightTypeStatus" }, + // { endpoint: "/get/data/ctranslate2_weight_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedCTranslate2WeightType" }, + // { endpoint: "/set/data/ctranslate2_weight_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedCTranslate2WeightType" }, - { endpoint: "/run/selected_translation_compute_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedTranslationComputeType" }, - { endpoint: "/get/data/selected_translation_compute_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedTranslationComputeType" }, - { endpoint: "/set/data/selected_translation_compute_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedTranslationComputeType" }, + // { endpoint: "/run/selected_translation_compute_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedTranslationComputeType" }, + // { endpoint: "/get/data/selected_translation_compute_type", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedTranslationComputeType" }, + // { endpoint: "/set/data/selected_translation_compute_type", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedTranslationComputeType" }, - { endpoint: "/run/downloaded_ctranslate2_weight", ns: configs, hook_name: "useTranslation", 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: "useTranslation", method_name: "updateDownloadProgressCTranslate2WeightTypeStatus" }, + // { endpoint: "/run/downloaded_ctranslate2_weight", ns: configs, hook_name: "useTranslation", 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: "useTranslation", method_name: "updateDownloadProgressCTranslate2WeightTypeStatus" }, - { endpoint: "/get/data/translation_compute_device_list", ns: configs, hook_name: "useTranslation", method_name: "updateSelectableTranslationComputeDeviceList_FromBackend" }, + // { endpoint: "/get/data/translation_compute_device_list", ns: configs, hook_name: "useTranslation", method_name: "updateSelectableTranslationComputeDeviceList_FromBackend" }, - { endpoint: "/get/data/selected_translation_compute_device", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedTranslationComputeDevice" }, - { endpoint: "/set/data/selected_translation_compute_device", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedTranslationComputeDevice" }, + // { endpoint: "/get/data/selected_translation_compute_device", ns: configs, hook_name: "useTranslation", method_name: "updateSelectedTranslationComputeDevice" }, + // { endpoint: "/set/data/selected_translation_compute_device", ns: configs, hook_name: "useTranslation", method_name: "setSuccessSelectedTranslationComputeDevice" }, - // Transcription - // Transcription (Mic) - { endpoint: "/get/data/mic_record_timeout", ns: configs, hook_name: "useTranscription", method_name: "updateMicRecordTimeout" }, - { endpoint: "/set/data/mic_record_timeout", ns: configs, hook_name: "useTranscription", method_name: "setSuccessMicRecordTimeout" }, + // // Transcription + // // Transcription (Mic) + // { endpoint: "/get/data/mic_record_timeout", ns: configs, hook_name: "useTranscription", method_name: "updateMicRecordTimeout" }, + // { endpoint: "/set/data/mic_record_timeout", ns: configs, hook_name: "useTranscription", method_name: "setSuccessMicRecordTimeout" }, - { endpoint: "/get/data/mic_phrase_timeout", ns: configs, hook_name: "useTranscription", method_name: "updateMicPhraseTimeout" }, - { endpoint: "/set/data/mic_phrase_timeout", ns: configs, hook_name: "useTranscription", method_name: "setSuccessMicPhraseTimeout" }, + // { endpoint: "/get/data/mic_phrase_timeout", ns: configs, hook_name: "useTranscription", method_name: "updateMicPhraseTimeout" }, + // { endpoint: "/set/data/mic_phrase_timeout", ns: configs, hook_name: "useTranscription", method_name: "setSuccessMicPhraseTimeout" }, - { endpoint: "/get/data/mic_max_phrases", ns: configs, hook_name: "useTranscription", method_name: "updateMicMaxWords" }, - { endpoint: "/set/data/mic_max_phrases", ns: configs, hook_name: "useTranscription", method_name: "setSuccessMicMaxWords" }, + // { endpoint: "/get/data/mic_max_phrases", ns: configs, hook_name: "useTranscription", method_name: "updateMicMaxWords" }, + // { endpoint: "/set/data/mic_max_phrases", ns: configs, hook_name: "useTranscription", method_name: "setSuccessMicMaxWords" }, - { endpoint: "/get/data/mic_word_filter", ns: configs, hook_name: "useTranscription", method_name: "getSuccessMicWordFilterList" }, - { endpoint: "/set/data/mic_word_filter", ns: configs, hook_name: "useTranscription", method_name: "setSuccessMicWordFilterList" }, + // { endpoint: "/get/data/mic_word_filter", ns: configs, hook_name: "useTranscription", method_name: "getSuccessMicWordFilterList" }, + // { endpoint: "/set/data/mic_word_filter", ns: configs, hook_name: "useTranscription", method_name: "setSuccessMicWordFilterList" }, - // Transcription (Speaker) - { endpoint: "/get/data/speaker_record_timeout", ns: configs, hook_name: "useTranscription", method_name: "updateSpeakerRecordTimeout" }, - { endpoint: "/set/data/speaker_record_timeout", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSpeakerRecordTimeout" }, + // // Transcription (Speaker) + // { endpoint: "/get/data/speaker_record_timeout", ns: configs, hook_name: "useTranscription", method_name: "updateSpeakerRecordTimeout" }, + // { endpoint: "/set/data/speaker_record_timeout", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSpeakerRecordTimeout" }, - { endpoint: "/get/data/speaker_phrase_timeout", ns: configs, hook_name: "useTranscription", method_name: "updateSpeakerPhraseTimeout" }, - { endpoint: "/set/data/speaker_phrase_timeout", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSpeakerPhraseTimeout" }, + // { endpoint: "/get/data/speaker_phrase_timeout", ns: configs, hook_name: "useTranscription", method_name: "updateSpeakerPhraseTimeout" }, + // { endpoint: "/set/data/speaker_phrase_timeout", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSpeakerPhraseTimeout" }, - { endpoint: "/get/data/speaker_max_phrases", ns: configs, hook_name: "useTranscription", method_name: "updateSpeakerMaxWords" }, - { endpoint: "/set/data/speaker_max_phrases", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSpeakerMaxWords" }, + // { endpoint: "/get/data/speaker_max_phrases", ns: configs, hook_name: "useTranscription", method_name: "updateSpeakerMaxWords" }, + // { endpoint: "/set/data/speaker_max_phrases", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSpeakerMaxWords" }, - // Transcription (AI Models) - { endpoint: "/get/data/selected_transcription_engine", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionEngine" }, - { endpoint: "/set/data/selected_transcription_engine", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedTranscriptionEngine" }, + // // Transcription (AI Models) + // { endpoint: "/get/data/selected_transcription_engine", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionEngine" }, + // { endpoint: "/set/data/selected_transcription_engine", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedTranscriptionEngine" }, - { endpoint: "/get/data/selectable_whisper_weight_type_dict", ns: configs, hook_name: "useTranscription", method_name: "updateDownloadedWhisperWeightTypeStatus" }, - { endpoint: "/get/data/whisper_weight_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedWhisperWeightType" }, - { endpoint: "/set/data/whisper_weight_type", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedWhisperWeightType" }, + // { endpoint: "/get/data/selectable_whisper_weight_type_dict", ns: configs, hook_name: "useTranscription", method_name: "updateDownloadedWhisperWeightTypeStatus" }, + // { endpoint: "/get/data/whisper_weight_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedWhisperWeightType" }, + // { endpoint: "/set/data/whisper_weight_type", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedWhisperWeightType" }, - { endpoint: "/run/selected_transcription_compute_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionComputeType" }, - { endpoint: "/get/data/selected_transcription_compute_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionComputeType" }, - { endpoint: "/set/data/selected_transcription_compute_type", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedTranscriptionComputeType" }, + // { endpoint: "/run/selected_transcription_compute_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionComputeType" }, + // { endpoint: "/get/data/selected_transcription_compute_type", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionComputeType" }, + // { endpoint: "/set/data/selected_transcription_compute_type", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedTranscriptionComputeType" }, - { endpoint: "/run/downloaded_whisper_weight", ns: configs, hook_name: "useTranscription", 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: "useTranscription", method_name: "updateDownloadProgressWhisperWeightTypeStatus" }, + // { endpoint: "/run/downloaded_whisper_weight", ns: configs, hook_name: "useTranscription", 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: "useTranscription", method_name: "updateDownloadProgressWhisperWeightTypeStatus" }, - { endpoint: "/get/data/transcription_compute_device_list", ns: configs, hook_name: "useTranscription", method_name: "updateSelectableTranscriptionComputeDeviceList_FromBackend" }, - { endpoint: "/get/data/selected_transcription_compute_device", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionComputeDevice" }, - { endpoint: "/set/data/selected_transcription_compute_device", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedTranscriptionComputeDevice" }, + // { endpoint: "/get/data/transcription_compute_device_list", ns: configs, hook_name: "useTranscription", method_name: "updateSelectableTranscriptionComputeDeviceList_FromBackend" }, + // { endpoint: "/get/data/selected_transcription_compute_device", ns: configs, hook_name: "useTranscription", method_name: "updateSelectedTranscriptionComputeDevice" }, + // { endpoint: "/set/data/selected_transcription_compute_device", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSelectedTranscriptionComputeDevice" }, - // Transcription (Advanced) - { endpoint: "/get/data/mic_avg_logprob", ns: configs, hook_name: "useTranscription", method_name: "updateMicAvgLogprob" }, - { endpoint: "/set/data/mic_avg_logprob", ns: configs, hook_name: "useTranscription", method_name: "setSuccessMicAvgLogprob" }, - { endpoint: "/get/data/mic_no_speech_prob", ns: configs, hook_name: "useTranscription", method_name: "updateMicNoSpeechProb" }, - { endpoint: "/set/data/mic_no_speech_prob", ns: configs, hook_name: "useTranscription", method_name: "setSuccessMicNoSpeechProb" }, - { endpoint: "/get/data/speaker_avg_logprob", ns: configs, hook_name: "useTranscription", method_name: "updateSpeakerAvgLogprob" }, - { endpoint: "/set/data/speaker_avg_logprob", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSpeakerAvgLogprob" }, - { endpoint: "/get/data/speaker_no_speech_prob", ns: configs, hook_name: "useTranscription", method_name: "updateSpeakerNoSpeechProb" }, - { endpoint: "/set/data/speaker_no_speech_prob", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSpeakerNoSpeechProb" }, + // // Transcription (Advanced) + // { endpoint: "/get/data/mic_avg_logprob", ns: configs, hook_name: "useTranscription", method_name: "updateMicAvgLogprob" }, + // { endpoint: "/set/data/mic_avg_logprob", ns: configs, hook_name: "useTranscription", method_name: "setSuccessMicAvgLogprob" }, + // { endpoint: "/get/data/mic_no_speech_prob", ns: configs, hook_name: "useTranscription", method_name: "updateMicNoSpeechProb" }, + // { endpoint: "/set/data/mic_no_speech_prob", ns: configs, hook_name: "useTranscription", method_name: "setSuccessMicNoSpeechProb" }, + // { endpoint: "/get/data/speaker_avg_logprob", ns: configs, hook_name: "useTranscription", method_name: "updateSpeakerAvgLogprob" }, + // { endpoint: "/set/data/speaker_avg_logprob", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSpeakerAvgLogprob" }, + // { endpoint: "/get/data/speaker_no_speech_prob", ns: configs, hook_name: "useTranscription", method_name: "updateSpeakerNoSpeechProb" }, + // { endpoint: "/set/data/speaker_no_speech_prob", ns: configs, hook_name: "useTranscription", method_name: "setSuccessSpeakerNoSpeechProb" }, // VR { endpoint: "/get/data/overlay_small_log", ns: configs, hook_name: "useVr", method_name: "updateIsEnabledOverlaySmallLog" }, @@ -263,49 +264,49 @@ export const ROUTE_META_LIST = [ { 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: "useOthers", method_name: "updateEnableAutoClearMessageInputBox" }, - { endpoint: "/set/enable/auto_clear_message_box", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableAutoClearMessageInputBox" }, - { endpoint: "/set/disable/auto_clear_message_box", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableAutoClearMessageInputBox" }, + // // Others + // { endpoint: "/get/data/auto_clear_message_box", ns: configs, hook_name: "useOthers", method_name: "updateEnableAutoClearMessageInputBox" }, + // { endpoint: "/set/enable/auto_clear_message_box", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableAutoClearMessageInputBox" }, + // { endpoint: "/set/disable/auto_clear_message_box", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableAutoClearMessageInputBox" }, - { endpoint: "/get/data/send_only_translated_messages", ns: configs, hook_name: "useOthers", method_name: "updateEnableSendOnlyTranslatedMessages" }, - { endpoint: "/set/enable/send_only_translated_messages", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableSendOnlyTranslatedMessages" }, - { endpoint: "/set/disable/send_only_translated_messages", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableSendOnlyTranslatedMessages" }, + // { endpoint: "/get/data/send_only_translated_messages", ns: configs, hook_name: "useOthers", method_name: "updateEnableSendOnlyTranslatedMessages" }, + // { endpoint: "/set/enable/send_only_translated_messages", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableSendOnlyTranslatedMessages" }, + // { endpoint: "/set/disable/send_only_translated_messages", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableSendOnlyTranslatedMessages" }, - { endpoint: "/get/data/logger_feature", ns: configs, hook_name: "useOthers", method_name: "updateEnableAutoExportMessageLogs" }, - { endpoint: "/set/enable/logger_feature", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableAutoExportMessageLogs" }, - { endpoint: "/set/disable/logger_feature", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableAutoExportMessageLogs" }, + // { endpoint: "/get/data/logger_feature", ns: configs, hook_name: "useOthers", method_name: "updateEnableAutoExportMessageLogs" }, + // { endpoint: "/set/enable/logger_feature", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableAutoExportMessageLogs" }, + // { endpoint: "/set/disable/logger_feature", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableAutoExportMessageLogs" }, - { endpoint: "/get/data/vrc_mic_mute_sync", ns: configs, hook_name: "useOthers", method_name: "getSuccessEnableVrcMicMuteSync" }, - { endpoint: "/set/enable/vrc_mic_mute_sync", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableVrcMicMuteSync" }, - { endpoint: "/set/disable/vrc_mic_mute_sync", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableVrcMicMuteSync" }, + // { endpoint: "/get/data/vrc_mic_mute_sync", ns: configs, hook_name: "useOthers", method_name: "getSuccessEnableVrcMicMuteSync" }, + // { endpoint: "/set/enable/vrc_mic_mute_sync", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableVrcMicMuteSync" }, + // { endpoint: "/set/disable/vrc_mic_mute_sync", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableVrcMicMuteSync" }, - { endpoint: "/get/data/send_message_to_vrc", ns: configs, hook_name: "useOthers", method_name: "updateEnableSendMessageToVrc" }, - { endpoint: "/set/enable/send_message_to_vrc", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableSendMessageToVrc" }, - { endpoint: "/set/disable/send_message_to_vrc", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableSendMessageToVrc" }, + // { endpoint: "/get/data/send_message_to_vrc", ns: configs, hook_name: "useOthers", method_name: "updateEnableSendMessageToVrc" }, + // { endpoint: "/set/enable/send_message_to_vrc", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableSendMessageToVrc" }, + // { endpoint: "/set/disable/send_message_to_vrc", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableSendMessageToVrc" }, - { endpoint: "/get/data/send_received_message_to_vrc", ns: configs, hook_name: "useOthers", method_name: "updateEnableSendReceivedMessageToVrc" }, - { endpoint: "/set/enable/send_received_message_to_vrc", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableSendReceivedMessageToVrc" }, - { endpoint: "/set/disable/send_received_message_to_vrc", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableSendReceivedMessageToVrc" }, + // { endpoint: "/get/data/send_received_message_to_vrc", ns: configs, hook_name: "useOthers", method_name: "updateEnableSendReceivedMessageToVrc" }, + // { endpoint: "/set/enable/send_received_message_to_vrc", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableSendReceivedMessageToVrc" }, + // { endpoint: "/set/disable/send_received_message_to_vrc", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableSendReceivedMessageToVrc" }, - { endpoint: "/get/data/notification_vrc_sfx", ns: configs, hook_name: "useOthers", method_name: "updateEnableNotificationVrcSfx" }, - { endpoint: "/set/enable/notification_vrc_sfx", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableNotificationVrcSfx" }, - { endpoint: "/set/disable/notification_vrc_sfx", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableNotificationVrcSfx" }, - { endpoint: "/set/disable/notification_vrc_sfx", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableNotificationVrcSfx" }, + // { endpoint: "/get/data/notification_vrc_sfx", ns: configs, hook_name: "useOthers", method_name: "updateEnableNotificationVrcSfx" }, + // { endpoint: "/set/enable/notification_vrc_sfx", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableNotificationVrcSfx" }, + // { endpoint: "/set/disable/notification_vrc_sfx", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableNotificationVrcSfx" }, + // { endpoint: "/set/disable/notification_vrc_sfx", ns: configs, hook_name: "useOthers", method_name: "setSuccessEnableNotificationVrcSfx" }, - { endpoint: "/get/data/send_message_format_parts", ns: configs, hook_name: "useOthers", method_name: "updateSendMessageFormatParts" }, - { endpoint: "/set/data/send_message_format_parts", ns: configs, hook_name: "useOthers", method_name: "setSuccessSendMessageFormatParts" }, - { endpoint: "/get/data/received_message_format_parts", ns: configs, hook_name: "useOthers", method_name: "updateReceivedMessageFormatParts" }, - { endpoint: "/set/data/received_message_format_parts", ns: configs, hook_name: "useOthers", method_name: "setSuccessReceivedMessageFormatParts" }, + // { endpoint: "/get/data/send_message_format_parts", ns: configs, hook_name: "useOthers", method_name: "updateSendMessageFormatParts" }, + // { endpoint: "/set/data/send_message_format_parts", ns: configs, hook_name: "useOthers", method_name: "setSuccessSendMessageFormatParts" }, + // { endpoint: "/get/data/received_message_format_parts", ns: configs, hook_name: "useOthers", method_name: "updateReceivedMessageFormatParts" }, + // { endpoint: "/set/data/received_message_format_parts", ns: configs, hook_name: "useOthers", method_name: "setSuccessReceivedMessageFormatParts" }, - { endpoint: "/get/data/convert_message_to_romaji", ns: configs, hook_name: "useOthers", method_name: "updateConvertMessageToRomaji" }, - { endpoint: "/set/enable/convert_message_to_romaji", ns: configs, hook_name: "useOthers", method_name: "setSuccessConvertMessageToRomaji" }, - { endpoint: "/set/disable/convert_message_to_romaji", ns: configs, hook_name: "useOthers", method_name: "setSuccessConvertMessageToRomaji" }, + // { endpoint: "/get/data/convert_message_to_romaji", ns: configs, hook_name: "useOthers", method_name: "updateConvertMessageToRomaji" }, + // { endpoint: "/set/enable/convert_message_to_romaji", ns: configs, hook_name: "useOthers", method_name: "setSuccessConvertMessageToRomaji" }, + // { endpoint: "/set/disable/convert_message_to_romaji", ns: configs, hook_name: "useOthers", method_name: "setSuccessConvertMessageToRomaji" }, - { endpoint: "/get/data/convert_message_to_hiragana", ns: configs, hook_name: "useOthers", method_name: "updateConvertMessageToHiragana" }, - { endpoint: "/set/enable/convert_message_to_hiragana", ns: configs, hook_name: "useOthers", method_name: "setSuccessConvertMessageToHiragana" }, - { endpoint: "/set/disable/convert_message_to_hiragana", ns: configs, hook_name: "useOthers", method_name: "setSuccessConvertMessageToHiragana" }, + // { endpoint: "/get/data/convert_message_to_hiragana", ns: configs, hook_name: "useOthers", method_name: "updateConvertMessageToHiragana" }, + // { endpoint: "/set/enable/convert_message_to_hiragana", ns: configs, hook_name: "useOthers", method_name: "setSuccessConvertMessageToHiragana" }, + // { endpoint: "/set/disable/convert_message_to_hiragana", ns: configs, hook_name: "useOthers", method_name: "setSuccessConvertMessageToHiragana" }, // Hotkeys { endpoint: "/get/data/hotkeys", ns: configs, hook_name: "useHotkeys", method_name: "updateHotkeys" }, @@ -315,29 +316,25 @@ export const ROUTE_META_LIST = [ { 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: "setSuccessSavedPluginsStatus" }, - // Advanced Settings - { endpoint: "/get/data/osc_ip_address", ns: configs, hook_name: "useAdvancedSettings", method_name: "updateOscIpAddress" }, - { endpoint: "/set/data/osc_ip_address", ns: configs, hook_name: "useAdvancedSettings", method_name: "setSuccessOscIpAddress" }, + // // Advanced Settings + // { endpoint: "/get/data/osc_ip_address", ns: configs, hook_name: "useAdvancedSettings", method_name: "updateOscIpAddress" }, + // { endpoint: "/set/data/osc_ip_address", ns: configs, hook_name: "useAdvancedSettings", method_name: "setSuccessOscIpAddress" }, - { endpoint: "/get/data/osc_port", ns: configs, hook_name: "useAdvancedSettings", method_name: "updateOscPort" }, - { endpoint: "/set/data/osc_port", ns: configs, hook_name: "useAdvancedSettings", method_name: "setSuccessOscPort" }, + // { endpoint: "/get/data/osc_port", ns: configs, hook_name: "useAdvancedSettings", method_name: "updateOscPort" }, + // { endpoint: "/set/data/osc_port", ns: configs, hook_name: "useAdvancedSettings", method_name: "setSuccessOscPort" }, - { endpoint: "/get/data/websocket_server", ns: configs, hook_name: "useAdvancedSettings", method_name: "updateEnableWebsocket" }, - { endpoint: "/set/enable/websocket_server", ns: configs, hook_name: "useAdvancedSettings", method_name: "setSuccessEnableWebsocket" }, - { endpoint: "/set/disable/websocket_server", ns: configs, hook_name: "useAdvancedSettings", method_name: "setSuccessEnableWebsocket" }, + // { endpoint: "/get/data/websocket_server", ns: configs, hook_name: "useAdvancedSettings", method_name: "updateEnableWebsocket" }, + // { endpoint: "/set/enable/websocket_server", ns: configs, hook_name: "useAdvancedSettings", method_name: "setSuccessEnableWebsocket" }, + // { endpoint: "/set/disable/websocket_server", ns: configs, hook_name: "useAdvancedSettings", method_name: "setSuccessEnableWebsocket" }, - { endpoint: "/get/data/websocket_host", ns: configs, hook_name: "useAdvancedSettings", method_name: "updateWebsocketHost" }, - { endpoint: "/set/data/websocket_host", ns: configs, hook_name: "useAdvancedSettings", method_name: "setSuccessWebsocketHost" }, + // { endpoint: "/get/data/websocket_host", ns: configs, hook_name: "useAdvancedSettings", method_name: "updateWebsocketHost" }, + // { endpoint: "/set/data/websocket_host", ns: configs, hook_name: "useAdvancedSettings", method_name: "setSuccessWebsocketHost" }, - { endpoint: "/get/data/websocket_port", ns: configs, hook_name: "useAdvancedSettings", method_name: "updateWebsocketPort" }, - { endpoint: "/set/data/websocket_port", ns: configs, hook_name: "useAdvancedSettings", method_name: "setSuccessWebsocketPort" }, + // { endpoint: "/get/data/websocket_port", ns: configs, hook_name: "useAdvancedSettings", method_name: "updateWebsocketPort" }, + // { endpoint: "/set/data/websocket_port", ns: configs, hook_name: "useAdvancedSettings", method_name: "setSuccessWebsocketPort" }, - // 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 + // // Not Implemented 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"]) ]; @@ -346,6 +343,8 @@ export const useReceiveRoutes = () => { const { errorHandling_Backend } = _useBackendErrorHandling(); const { updateIsBackendReady } = common.useIsBackendReady(); + const ROUTE_META_LIST = buildRouteMetaList(); + const handleInvalidEndpoint = (parsed_data) => { console.error(`Invalid endpoint: ${parsed_data.endpoint}\nresult: ${JSON.stringify(parsed_data.result)}`); }; @@ -353,7 +352,13 @@ export const useReceiveRoutes = () => { 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 hookFn = ns[hook_name]; + if (typeof hookFn === "function") { + hook_results[hook_name] = hookFn(); + } else { + console.warn(`Hook not found on namespace: ${hook_name}`); + hook_results[hook_name] = {}; + } } }); @@ -364,7 +369,7 @@ export const useReceiveRoutes = () => { const result_obj = hook_results[hook_name] || {}; const fn = result_obj[method_name]; if (fn === undefined && method_name !== null) { - console.error("Method not found.", {endpoint, hook_name, method_name, result_obj, fn}); + console.error("Method not found.", { endpoint, hook_name, method_name, result_obj, fn }); } return [endpoint, typeof fn === "function" ? fn : noop]; }) @@ -386,7 +391,6 @@ export const useReceiveRoutes = () => { return; } - switch (status) { case 200: if (endpoint in routes) { @@ -424,4 +428,168 @@ export const useReceiveRoutes = () => { const style_348 = [ "color: gray", -].join(";"); \ No newline at end of file +].join(";"); + + + +// Automatically set 'configs' for now.(This is only used in config) +const buildRouteMetaList = () => { + const namespace_module = configs; + const generated = []; + + for (const s of SETTINGS_ARRAY) { + const category = s.Category; + const base = s.Base_Name; + const ep = s.base_endpoint_name; + const hookName = `use${category}`; + const setSuccessMethodName = `setSuccess${base}`; + const updateFromBackendMethodName = `updateFromBackend${base}`; + + + if (s.add_endpoint_run_array?.includes("from_backend")) { + generated.push({ + endpoint: `/run/${ep}`, + ns: namespace_module, + hook_name: hookName, + method_name: updateFromBackendMethodName, + }); + } + + + + generated.push({ + endpoint: `/get/data/${ep}`, + ns: namespace_module, + hook_name: hookName, + method_name: updateFromBackendMethodName, + }); + + if (s.logics_template_id !== "get_list") { + generated.push({ + endpoint: `/set/data/${ep}`, + ns: namespace_module, + hook_name: hookName, + method_name: setSuccessMethodName, + }); + } + + if (s.logics_template_id === "toggle_enable_disable" || s.ui_template_id === "toggle") { + generated.push({ + endpoint: `/set/enable/${ep}`, + ns: namespace_module, + hook_name: hookName, + method_name: setSuccessMethodName, + }); + generated.push({ + endpoint: `/set/disable/${ep}`, + ns: namespace_module, + hook_name: hookName, + method_name: setSuccessMethodName, + }); + } + + if (s.logics_template_id === "weight_download_status") { + generated.push({ + endpoint: `/get/data/selectable_${ep}_type_dict`, + ns: namespace_module, + hook_name: hookName, + method_name: `updateDownloaded${base}`, + }); + + generated.push({ + endpoint: `/set/data/${ep}`, + ns: namespace_module, + hook_name: hookName, + method_name: setSuccessMethodName, + }); + + generated.push({ + endpoint: `/run/download_progress_${ep}`, + ns: namespace_module, + hook_name: hookName, + method_name: `updateDownloadProgress${base}`, + }); + + generated.push({ + endpoint: `/run/downloaded_${ep}`, + ns: namespace_module, + hook_name: hookName, + method_name: `downloaded${base}`, + }); + generated.push({ + endpoint: `/run/pending_${ep}`, + ns: namespace_module, + hook_name: hookName, + method_name: `pending${base}`, + }); + generated.push({ + endpoint: `/run/download_${ep}`, + ns: namespace_module, + hook_name: hookName, + method_name: `downloaded${base}`, + }); + generated.push({ + endpoint: `/get/data/${ep}`, + ns: namespace_module, + hook_name: hookName, + method_name: updateFromBackendMethodName, + }); + continue; + } + } + + const mergedMap = new Map(); + + for (const item of STATIC_ROUTE_META_LIST) { + if (!item || !item.endpoint) continue; + mergedMap.set(item.endpoint, { + endpoint: item.endpoint, + ns: item.ns ?? null, + hook_name: item.hook_name ?? null, + method_name: item.method_name ?? null, + }); + } + + for (const gen of generated) { + const ep = gen.endpoint; + const existing = mergedMap.get(ep); + if (!existing) { + mergedMap.set(ep, { ...gen }); + continue; + } + + const merged = { + endpoint: ep, + ns: existing.ns ?? gen.ns ?? null, + hook_name: existing.hook_name ?? gen.hook_name ?? null, + method_name: existing.method_name ?? gen.method_name ?? null, + }; + mergedMap.set(ep, merged); + } + + const mergedList = []; + + + for (const item of STATIC_ROUTE_META_LIST) { + if (!item || !item.endpoint) continue; + const merged = mergedMap.get(item.endpoint); + if (merged) { + mergedList.push(merged); + mergedMap.delete(item.endpoint); + } + } + + for (const gen of generated) { + const ep = gen.endpoint; + if (mergedMap.has(ep)) { + mergedList.push(mergedMap.get(ep)); + mergedMap.delete(ep); + } + } + + for (const remaining of mergedMap.values()) { + mergedList.push(remaining); + } + + return mergedList; +}; \ No newline at end of file diff --git a/src-ui/store.js b/src-ui/store.js index 19897723..be12b207 100644 --- a/src-ui/store.js +++ b/src-ui/store.js @@ -33,6 +33,7 @@ const generatePropertyNames = (base_name) => ({ add: `add${base_name}`, }); +export const dynamicStoreRegistry = {}; export const createAtomWithHook = (initialValue, base_name, options) => { const property_names = generatePropertyNames(base_name); @@ -109,10 +110,58 @@ export const createAtomWithHook = (initialValue, base_name, options) => { }; }; + // dynamic registry に登録(キー名は既存の命名規約に合わせる) + try { + const hookName = `useStore_${base_name}`; + const atomName = `Atom_${base_name}`; + dynamicStoreRegistry[hookName] = useHook; + dynamicStoreRegistry[atomName] = atomInstance; + } catch (e) { + // 登録失敗でも処理中断しない(開発用に console.warn してもよい) + // console.warn("dynamic registration failed for", base_name, e); + } + return { atomInstance, useHook }; }; +/** + * getStoreHook(baseName) + * dynamicStoreRegistry から useStore_ を返すヘルパー。 + * 存在しなければ undefined を返す。 + */ +export const getStoreHook = (baseName) => { + const hookName = `useStore_${baseName}`; + return dynamicStoreRegistry[hookName]; +}; + +/** + * registerMany(settingsArray) + * settingsArray を走査して createAtomWithHook を呼び出し、 + * dynamicStoreRegistry に登録します。 + * + * settingsArray の各要素は少なくとも Base_Name と default_value を持つことを期待します。 + */ +export const registerMany = (settingsArray = []) => { + for (const s of settingsArray) { + try { + // 既に同名の atom が registry にあればスキップ(上書き防止) + const hookName = `useStore_${s.Base_Name}`; + if (dynamicStoreRegistry[hookName]) { + continue; + } + + // createAtomWithHook が registry に登録してくれる + createAtomWithHook(s.default_value, s.Base_Name, s.options || {}); + } catch (e) { + // 個別エラーは無視して続行 + // console.warn("registerMany failed for", s.Base_Name, e); + } + } +}; + + + // Common export const { atomInstance: Atom_IsBackendReady, useHook: useStore_IsBackendReady } = createAtomWithHook(false, "IsBackendReady"); export const { atomInstance: Atom_IsVrctAvailable, useHook: useStore_IsVrctAvailable } = createAtomWithHook(true, "IsVrctAvailable"); @@ -178,16 +227,16 @@ export const { atomInstance: Atom_SettingBoxScrollPosition, useHook: useStore_Se export const { atomInstance: Atom_IsOpenedDropdownMenu, useHook: useStore_IsOpenedDropdownMenu } = createAtomWithHook("", "IsOpenedDropdownMenu"); // Device -export const { atomInstance: Atom_EnableAutoMicSelect, useHook: useStore_EnableAutoMicSelect } = createAtomWithHook(true, "EnableAutoMicSelect"); -export const { atomInstance: Atom_EnableAutoSpeakerSelect, useHook: useStore_EnableAutoSpeakerSelect } = createAtomWithHook(true, "EnableAutoSpeakerSelect"); +// export const { atomInstance: Atom_EnableAutoMicSelect, useHook: useStore_EnableAutoMicSelect } = createAtomWithHook(true, "EnableAutoMicSelect"); +// export const { atomInstance: Atom_EnableAutoSpeakerSelect, useHook: useStore_EnableAutoSpeakerSelect } = createAtomWithHook(true, "EnableAutoSpeakerSelect"); -export const { atomInstance: Atom_MicHostList, useHook: useStore_MicHostList } = createAtomWithHook({}, "MicHostList"); -export const { atomInstance: Atom_SelectedMicHost, useHook: useStore_SelectedMicHost } = createAtomWithHook("Nothing Selected", "SelectedMicHost"); -export const { atomInstance: Atom_MicDeviceList, useHook: useStore_MicDeviceList } = createAtomWithHook({}, "MicDeviceList"); -export const { atomInstance: Atom_SelectedMicDevice, useHook: useStore_SelectedMicDevice } = createAtomWithHook("Nothing Selected", "SelectedMicDevice"); +// export const { atomInstance: Atom_MicHostList, useHook: useStore_MicHostList } = createAtomWithHook({}, "MicHostList"); +// export const { atomInstance: Atom_SelectedMicHost, useHook: useStore_SelectedMicHost } = createAtomWithHook("Nothing Selected", "SelectedMicHost"); +// export const { atomInstance: Atom_MicDeviceList, useHook: useStore_MicDeviceList } = createAtomWithHook({}, "MicDeviceList"); +// export const { atomInstance: Atom_SelectedMicDevice, useHook: useStore_SelectedMicDevice } = createAtomWithHook("Nothing Selected", "SelectedMicDevice"); -export const { atomInstance: Atom_SpeakerDeviceList, useHook: useStore_SpeakerDeviceList } = createAtomWithHook({}, "SpeakerDeviceList"); -export const { atomInstance: Atom_SelectedSpeakerDevice, useHook: useStore_SelectedSpeakerDevice } = createAtomWithHook("Nothing Selected", "SelectedSpeakerDevice"); +// export const { atomInstance: Atom_SpeakerDeviceList, useHook: useStore_SpeakerDeviceList } = createAtomWithHook({}, "SpeakerDeviceList"); +// export const { atomInstance: Atom_SelectedSpeakerDevice, useHook: useStore_SelectedSpeakerDevice } = createAtomWithHook("Nothing Selected", "SelectedSpeakerDevice"); export const { atomInstance: Atom_MicVolume, useHook: useStore_MicVolume } = createAtomWithHook(0, "MicVolume"); export const { atomInstance: Atom_SpeakerVolume, useHook: useStore_SpeakerVolume } = createAtomWithHook(0, "SpeakerVolume"); @@ -195,57 +244,57 @@ export const { atomInstance: Atom_SpeakerVolume, useHook: useStore_SpeakerVolume export const { atomInstance: Atom_MicThresholdCheckStatus, useHook: useStore_MicThresholdCheckStatus } = createAtomWithHook(false, "MicThresholdCheckStatus", {is_state_ok: true}); export const { atomInstance: Atom_SpeakerThresholdCheckStatus, useHook: useStore_SpeakerThresholdCheckStatus } = createAtomWithHook(false, "SpeakerThresholdCheckStatus", {is_state_ok: true}); -export const { atomInstance: Atom_MicThreshold, useHook: useStore_MicThreshold } = createAtomWithHook(0, "MicThreshold"); -export const { atomInstance: Atom_SpeakerThreshold, useHook: useStore_SpeakerThreshold } = createAtomWithHook(0, "SpeakerThreshold"); +// export const { atomInstance: Atom_MicThreshold, useHook: useStore_MicThreshold } = createAtomWithHook(0, "MicThreshold"); +// export const { atomInstance: Atom_SpeakerThreshold, useHook: useStore_SpeakerThreshold } = createAtomWithHook(0, "SpeakerThreshold"); -export const { atomInstance: Atom_EnableAutomaticMicThreshold, useHook: useStore_EnableAutomaticMicThreshold } = createAtomWithHook(false, "EnableAutomaticMicThreshold"); -export const { atomInstance: Atom_EnableAutomaticSpeakerThreshold, useHook: useStore_EnableAutomaticSpeakerThreshold } = createAtomWithHook(false, "EnableAutomaticSpeakerThreshold"); +// export const { atomInstance: Atom_EnableAutomaticMicThreshold, useHook: useStore_EnableAutomaticMicThreshold } = createAtomWithHook(false, "EnableAutomaticMicThreshold"); +// export const { atomInstance: Atom_EnableAutomaticSpeakerThreshold, useHook: useStore_EnableAutomaticSpeakerThreshold } = createAtomWithHook(false, "EnableAutomaticSpeakerThreshold"); // Appearance -export const { atomInstance: Atom_UiLanguage, useHook: useStore_UiLanguage } = createAtomWithHook("en", "UiLanguage"); -export const { atomInstance: Atom_UiScaling, useHook: useStore_UiScaling } = createAtomWithHook(100, "UiScaling"); -export const { atomInstance: Atom_MessageLogUiScaling, useHook: useStore_MessageLogUiScaling } = createAtomWithHook(100, "MessageLogUiScaling"); -export const { atomInstance: Atom_SendMessageButtonType, useHook: useStore_SendMessageButtonType } = createAtomWithHook("show", "SendMessageButtonType"); -export const { atomInstance: Atom_ShowResendButton, useHook: useStore_ShowResendButton } = createAtomWithHook(false, "ShowResendButton"); -export const { atomInstance: Atom_SelectedFontFamily, useHook: useStore_SelectedFontFamily } = createAtomWithHook("Yu Gothic UI", "SelectedFontFamily"); +// export const { atomInstance: Atom_UiLanguage, useHook: useStore_UiLanguage } = createAtomWithHook("en", "UiLanguage"); +// export const { atomInstance: Atom_UiScaling, useHook: useStore_UiScaling } = createAtomWithHook(100, "UiScaling"); +// export const { atomInstance: Atom_MessageLogUiScaling, useHook: useStore_MessageLogUiScaling } = createAtomWithHook(100, "MessageLogUiScaling"); +// export const { atomInstance: Atom_SendMessageButtonType, useHook: useStore_SendMessageButtonType } = createAtomWithHook("show", "SendMessageButtonType"); +// export const { atomInstance: Atom_ShowResendButton, useHook: useStore_ShowResendButton } = createAtomWithHook(false, "ShowResendButton"); +// export const { atomInstance: Atom_SelectedFontFamily, useHook: useStore_SelectedFontFamily } = createAtomWithHook("Yu Gothic UI", "SelectedFontFamily"); export const { atomInstance: Atom_SelectableFontFamilyList, useHook: useStore_SelectableFontFamilyList } = createAtomWithHook({}, "SelectableFontFamilyList"); -export const { atomInstance: Atom_Transparency, useHook: useStore_Transparency } = createAtomWithHook(100, "Transparency"); +// export const { atomInstance: Atom_Transparency, useHook: useStore_Transparency } = createAtomWithHook(100, "Transparency"); export const { atomInstance: Atom_IsOpenedMicWordFilterList, useHook: useStore_IsOpenedMicWordFilterList } = createAtomWithHook(false, "IsOpenedMicWordFilterList"); -export const { atomInstance: Atom_MicWordFilterList, useHook: useStore_MicWordFilterList } = createAtomWithHook([], "MicWordFilterList"); +// export const { atomInstance: Atom_MicWordFilterList, useHook: useStore_MicWordFilterList } = createAtomWithHook([], "MicWordFilterList"); // Translation -export const { atomInstance: Atom_DeepLAuthKey, useHook: useStore_DeepLAuthKey } = createAtomWithHook(null, "DeepLAuthKey"); -export const { atomInstance: Atom_SelectedCTranslate2WeightType, useHook: useStore_SelectedCTranslate2WeightType } = createAtomWithHook("", "SelectedCTranslate2WeightType"); -export const { atomInstance: Atom_CTranslate2WeightTypeStatus, useHook: useStore_CTranslate2WeightTypeStatus } = createAtomWithHook(ctranslate2_weight_type_status, "CTranslate2WeightTypeStatus"); +// export const { atomInstance: Atom_DeepLAuthKey, useHook: useStore_DeepLAuthKey } = createAtomWithHook(null, "DeepLAuthKey"); +// export const { atomInstance: Atom_SelectedCTranslate2WeightType, useHook: useStore_SelectedCTranslate2WeightType } = createAtomWithHook("", "SelectedCTranslate2WeightType"); +// export const { atomInstance: Atom_CTranslate2WeightTypeStatus, useHook: useStore_CTranslate2WeightTypeStatus } = createAtomWithHook(ctranslate2_weight_type_status, "CTranslate2WeightTypeStatus"); -export const { atomInstance: Atom_SelectableTranslationComputeDeviceList, useHook: useStore_SelectableTranslationComputeDeviceList } = createAtomWithHook({}, "SelectableTranslationComputeDeviceList"); -export const { atomInstance: Atom_SelectedTranslationComputeDevice, useHook: useStore_SelectedTranslationComputeDevice } = createAtomWithHook("", "SelectedTranslationComputeDevice"); -export const { atomInstance: Atom_SelectedTranslationComputeType, useHook: useStore_SelectedTranslationComputeType } = createAtomWithHook("", "SelectedTranslationComputeType"); +// export const { atomInstance: Atom_SelectableTranslationComputeDeviceList, useHook: useStore_SelectableTranslationComputeDeviceList } = createAtomWithHook({}, "SelectableTranslationComputeDeviceList"); +// export const { atomInstance: Atom_SelectedTranslationComputeDevice, useHook: useStore_SelectedTranslationComputeDevice } = createAtomWithHook("", "SelectedTranslationComputeDevice"); +// export const { atomInstance: Atom_SelectedTranslationComputeType, useHook: useStore_SelectedTranslationComputeType } = createAtomWithHook("", "SelectedTranslationComputeType"); // Transcription -export const { atomInstance: Atom_MicRecordTimeout, useHook: useStore_MicRecordTimeout } = createAtomWithHook(0, "MicRecordTimeout"); -export const { atomInstance: Atom_MicPhraseTimeout, useHook: useStore_MicPhraseTimeout } = createAtomWithHook(0, "MicPhraseTimeout"); -export const { atomInstance: Atom_MicMaxWords, useHook: useStore_MicMaxWords } = createAtomWithHook(0, "MicMaxWords"); +// export const { atomInstance: Atom_MicRecordTimeout, useHook: useStore_MicRecordTimeout } = createAtomWithHook(0, "MicRecordTimeout"); +// export const { atomInstance: Atom_MicPhraseTimeout, useHook: useStore_MicPhraseTimeout } = createAtomWithHook(0, "MicPhraseTimeout"); +// export const { atomInstance: Atom_MicMaxWords, useHook: useStore_MicMaxWords } = createAtomWithHook(0, "MicMaxWords"); -export const { atomInstance: Atom_SpeakerRecordTimeout, useHook: useStore_SpeakerRecordTimeout } = createAtomWithHook(0, "SpeakerRecordTimeout"); -export const { atomInstance: Atom_SpeakerPhraseTimeout, useHook: useStore_SpeakerPhraseTimeout } = createAtomWithHook(0, "SpeakerPhraseTimeout"); -export const { atomInstance: Atom_SpeakerMaxWords, useHook: useStore_SpeakerMaxWords } = createAtomWithHook(0, "SpeakerMaxWords"); +// export const { atomInstance: Atom_SpeakerRecordTimeout, useHook: useStore_SpeakerRecordTimeout } = createAtomWithHook(0, "SpeakerRecordTimeout"); +// export const { atomInstance: Atom_SpeakerPhraseTimeout, useHook: useStore_SpeakerPhraseTimeout } = createAtomWithHook(0, "SpeakerPhraseTimeout"); +// export const { atomInstance: Atom_SpeakerMaxWords, useHook: useStore_SpeakerMaxWords } = createAtomWithHook(0, "SpeakerMaxWords"); -export const { atomInstance: Atom_SelectedWhisperWeightType, useHook: useStore_SelectedWhisperWeightType } = createAtomWithHook("", "SelectedWhisperWeightType"); -export const { atomInstance: Atom_WhisperWeightTypeStatus, useHook: useStore_WhisperWeightTypeStatus } = createAtomWithHook(whisper_weight_type_status, "WhisperWeightTypeStatus"); -export const { atomInstance: Atom_SelectedTranscriptionEngine, useHook: useStore_SelectedTranscriptionEngine } = createAtomWithHook(whisper_weight_type_status, "SelectedTranscriptionEngine"); +// export const { atomInstance: Atom_SelectedWhisperWeightType, useHook: useStore_SelectedWhisperWeightType } = createAtomWithHook("", "SelectedWhisperWeightType"); +// export const { atomInstance: Atom_WhisperWeightTypeStatus, useHook: useStore_WhisperWeightTypeStatus } = createAtomWithHook(whisper_weight_type_status, "WhisperWeightTypeStatus"); +// export const { atomInstance: Atom_SelectedTranscriptionEngine, useHook: useStore_SelectedTranscriptionEngine } = createAtomWithHook(whisper_weight_type_status, "SelectedTranscriptionEngine"); -export const { atomInstance: Atom_SelectableTranscriptionComputeDeviceList, useHook: useStore_SelectableTranscriptionComputeDeviceList } = createAtomWithHook({}, "SelectableTranscriptionComputeDeviceList"); -export const { atomInstance: Atom_SelectedTranscriptionComputeDevice, useHook: useStore_SelectedTranscriptionComputeDevice } = createAtomWithHook("", "SelectedTranscriptionComputeDevice"); -export const { atomInstance: Atom_SelectedTranscriptionComputeType, useHook: useStore_SelectedTranscriptionComputeType } = createAtomWithHook("", "SelectedTranscriptionComputeType"); +// export const { atomInstance: Atom_SelectableTranscriptionComputeDeviceList, useHook: useStore_SelectableTranscriptionComputeDeviceList } = createAtomWithHook({}, "SelectableTranscriptionComputeDeviceList"); +// export const { atomInstance: Atom_SelectedTranscriptionComputeDevice, useHook: useStore_SelectedTranscriptionComputeDevice } = createAtomWithHook("", "SelectedTranscriptionComputeDevice"); +// export const { atomInstance: Atom_SelectedTranscriptionComputeType, useHook: useStore_SelectedTranscriptionComputeType } = createAtomWithHook("", "SelectedTranscriptionComputeType"); -export const { atomInstance: Atom_MicAvgLogprob, useHook: useStore_MicAvgLogprob } = createAtomWithHook(-0.8, "MicAvgLogprob"); -export const { atomInstance: Atom_MicNoSpeechProb, useHook: useStore_MicNoSpeechProb } = createAtomWithHook(0.6, "MicNoSpeechProb"); -export const { atomInstance: Atom_SpeakerAvgLogprob, useHook: useStore_SpeakerAvgLogprob } = createAtomWithHook(-0.8, "SpeakerAvgLogprob"); -export const { atomInstance: Atom_SpeakerNoSpeechProb, useHook: useStore_SpeakerNoSpeechProb } = createAtomWithHook(0.6, "SpeakerNoSpeechProb"); +// export const { atomInstance: Atom_MicAvgLogprob, useHook: useStore_MicAvgLogprob } = createAtomWithHook(-0.8, "MicAvgLogprob"); +// export const { atomInstance: Atom_MicNoSpeechProb, useHook: useStore_MicNoSpeechProb } = createAtomWithHook(0.6, "MicNoSpeechProb"); +// export const { atomInstance: Atom_SpeakerAvgLogprob, useHook: useStore_SpeakerAvgLogprob } = createAtomWithHook(-0.8, "SpeakerAvgLogprob"); +// export const { atomInstance: Atom_SpeakerNoSpeechProb, useHook: useStore_SpeakerNoSpeechProb } = createAtomWithHook(0.6, "SpeakerNoSpeechProb"); // VR @@ -276,45 +325,45 @@ export const { atomInstance: Atom_IsEnabledOverlayLargeLog, useHook: useStore_Is export const { atomInstance: Atom_OverlayShowOnlyTranslatedMessages, useHook: useStore_OverlayShowOnlyTranslatedMessages } = createAtomWithHook(false, "OverlayShowOnlyTranslatedMessages"); // Others -export const { atomInstance: Atom_EnableAutoClearMessageInputBox, useHook: useStore_EnableAutoClearMessageInputBox } = createAtomWithHook(true, "EnableAutoClearMessageInputBox"); -export const { atomInstance: Atom_EnableSendOnlyTranslatedMessages, useHook: useStore_EnableSendOnlyTranslatedMessages } = createAtomWithHook(false, "EnableSendOnlyTranslatedMessages"); -export const { atomInstance: Atom_EnableAutoExportMessageLogs, useHook: useStore_EnableAutoExportMessageLogs } = createAtomWithHook(false, "EnableAutoExportMessageLogs"); -export const { atomInstance: Atom_EnableVrcMicMuteSync, useHook: useStore_EnableVrcMicMuteSync } = createAtomWithHook(false, "EnableVrcMicMuteSync"); -export const { atomInstance: Atom_EnableSendMessageToVrc, useHook: useStore_EnableSendMessageToVrc } = createAtomWithHook(true, "EnableSendMessageToVrc"); -export const { atomInstance: Atom_EnableSendReceivedMessageToVrc, useHook: useStore_EnableSendReceivedMessageToVrc } = createAtomWithHook(false, "EnableSendReceivedMessageToVrc"); -export const { atomInstance: Atom_EnableNotificationVrcSfx, useHook: useStore_EnableNotificationVrcSfx } = createAtomWithHook(true, "EnableNotificationVrcSfx"); -export const { atomInstance: Atom_MessageFormat_ExampleViewFilter, useHook: useStore_MessageFormat_ExampleViewFilter } = createAtomWithHook({ - send: "Simplified", - received: "Simplified", -}, "MessageFormat_ExampleViewFilter"); -export const { atomInstance: Atom_SendMessageFormatParts, useHook: useStore_SendMessageFormatParts } = createAtomWithHook({ - message: { - prefix: "", - suffix: "" - }, - separator: "\n", - translation: { - prefix: "", - separator: "\n", - suffix: "" - }, - translation_first: false, -}, "SendMessageFormatParts"); -export const { atomInstance: Atom_ReceivedMessageFormatParts, useHook: useStore_ReceivedMessageFormatParts } = createAtomWithHook({ - message: { - prefix: "", - suffix: "" - }, - separator: "\n", - translation: { - prefix: "", - separator: "\n", - suffix: "" - }, - translation_first: false, -}, "ReceivedMessageFormatParts"); -export const { atomInstance: Atom_ConvertMessageToRomaji, useHook: useStore_ConvertMessageToRomaji } = createAtomWithHook(false, "ConvertMessageToRomaji"); -export const { atomInstance: Atom_ConvertMessageToHiragana, useHook: useStore_ConvertMessageToHiragana } = createAtomWithHook(false, "ConvertMessageToHiragana"); +// export const { atomInstance: Atom_EnableAutoClearMessageInputBox, useHook: useStore_EnableAutoClearMessageInputBox } = createAtomWithHook(true, "EnableAutoClearMessageInputBox"); +// export const { atomInstance: Atom_EnableSendOnlyTranslatedMessages, useHook: useStore_EnableSendOnlyTranslatedMessages } = createAtomWithHook(false, "EnableSendOnlyTranslatedMessages"); +// export const { atomInstance: Atom_EnableAutoExportMessageLogs, useHook: useStore_EnableAutoExportMessageLogs } = createAtomWithHook(false, "EnableAutoExportMessageLogs"); +// export const { atomInstance: Atom_EnableVrcMicMuteSync, useHook: useStore_EnableVrcMicMuteSync } = createAtomWithHook(false, "EnableVrcMicMuteSync"); +// export const { atomInstance: Atom_EnableSendMessageToVrc, useHook: useStore_EnableSendMessageToVrc } = createAtomWithHook(true, "EnableSendMessageToVrc"); +// export const { atomInstance: Atom_EnableSendReceivedMessageToVrc, useHook: useStore_EnableSendReceivedMessageToVrc } = createAtomWithHook(false, "EnableSendReceivedMessageToVrc"); +// export const { atomInstance: Atom_EnableNotificationVrcSfx, useHook: useStore_EnableNotificationVrcSfx } = createAtomWithHook(true, "EnableNotificationVrcSfx"); +// export const { atomInstance: Atom_MessageFormat_ExampleViewFilter, useHook: useStore_MessageFormat_ExampleViewFilter } = createAtomWithHook({ +// send: "Simplified", +// received: "Simplified", +// }, "MessageFormat_ExampleViewFilter"); +// export const { atomInstance: Atom_SendMessageFormatParts, useHook: useStore_SendMessageFormatParts } = createAtomWithHook({ +// message: { +// prefix: "", +// suffix: "" +// }, +// separator: "\n", +// translation: { +// prefix: "", +// separator: "\n", +// suffix: "" +// }, +// translation_first: false, +// }, "SendMessageFormatParts"); +// export const { atomInstance: Atom_ReceivedMessageFormatParts, useHook: useStore_ReceivedMessageFormatParts } = createAtomWithHook({ +// message: { +// prefix: "", +// suffix: "" +// }, +// separator: "\n", +// translation: { +// prefix: "", +// separator: "\n", +// suffix: "" +// }, +// translation_first: false, +// }, "ReceivedMessageFormatParts"); +// export const { atomInstance: Atom_ConvertMessageToRomaji, useHook: useStore_ConvertMessageToRomaji } = createAtomWithHook(false, "ConvertMessageToRomaji"); +// export const { atomInstance: Atom_ConvertMessageToHiragana, useHook: useStore_ConvertMessageToHiragana } = createAtomWithHook(false, "ConvertMessageToHiragana"); // Hotkeys @@ -332,12 +381,12 @@ export const { atomInstance: Atom_SavedPluginsStatus, useHook: useStore_SavedPlu export const { atomInstance: Atom_PluginsData, useHook: useStore_PluginsData } = createAtomWithHook([], "PluginsData"); // Advanced Settings -export const { atomInstance: Atom_OscIpAddress, useHook: useStore_OscIpAddress } = createAtomWithHook("127.0.0.1", "OscIpAddress"); -export const { atomInstance: Atom_OscPort, useHook: useStore_OscPort } = createAtomWithHook("9000", "OscPort"); +// export const { atomInstance: Atom_OscIpAddress, useHook: useStore_OscIpAddress } = createAtomWithHook("127.0.0.1", "OscIpAddress"); +// export const { atomInstance: Atom_OscPort, useHook: useStore_OscPort } = createAtomWithHook("9000", "OscPort"); -export const { atomInstance: Atom_EnableWebsocket, useHook: useStore_EnableWebsocket } = createAtomWithHook(true, "EnableWebsocket"); -export const { atomInstance: Atom_WebsocketHost, useHook: useStore_WebsocketHost } = createAtomWithHook("127.0.0.1", "WebsocketHost"); -export const { atomInstance: Atom_WebsocketPort, useHook: useStore_WebsocketPort } = createAtomWithHook("2231", "WebsocketPort"); +// export const { atomInstance: Atom_EnableWebsocket, useHook: useStore_EnableWebsocket } = createAtomWithHook(true, "EnableWebsocket"); +// export const { atomInstance: Atom_WebsocketHost, useHook: useStore_WebsocketHost } = createAtomWithHook("127.0.0.1", "WebsocketHost"); +// export const { atomInstance: Atom_WebsocketPort, useHook: useStore_WebsocketPort } = createAtomWithHook("2231", "WebsocketPort"); diff --git a/src-ui/ui_config_setter.js b/src-ui/ui_config_setter.js new file mode 100644 index 00000000..d0f6c1b5 --- /dev/null +++ b/src-ui/ui_config_setter.js @@ -0,0 +1,648 @@ +import { createAtomWithHook } from "@store"; + +import { + ctranslate2_weight_type_status, + whisper_weight_type_status, +} from "@ui_configs"; + +import { useSettingsLogics } from "./useSettingsLogics"; + + +export const SETTINGS_ARRAY = [ + // Device + { + Category: "Device", + Base_Name: "EnableAutoMicSelect", + default_value: true, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "auto_mic_select", + }, + { + Category: "Device", + Base_Name: "MicHostList", + default_value: [], + ui_template_id: "list", + logics_template_id: "get_set", + add_endpoint_run_array: ["from_backend"], + base_endpoint_name: "mic_host_list", + response_transform: "arrayToObject", + }, + { + Category: "Device", + Base_Name: "MicDeviceList", + default_value: [], + ui_template_id: "list", + logics_template_id: "get_set", + add_endpoint_run_array: ["from_backend"], + base_endpoint_name: "mic_device_list", + response_transform: "arrayToObject", + }, + { + Category: "Device", + Base_Name: "SelectedMicHost", + default_value: "", + ui_template_id: "select", + logics_template_id: "get_set", + add_endpoint_run_array: ["from_backend"], + base_endpoint_name: "selected_mic_host", + }, + { + Category: "Device", + Base_Name: "SelectedMicDevice", + default_value: "", + ui_template_id: "select", + logics_template_id: "get_set", + add_endpoint_run_array: ["from_backend"], + base_endpoint_name: "selected_mic_device", + }, + { + Category: "Device", + Base_Name: "EnableAutomaticMicThreshold", + default_value: true, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "mic_automatic_threshold", + }, + { + Category: "Device", + Base_Name: "MicThreshold", + default_value: 0, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "mic_threshold", + }, + { + Category: "Device", + Base_Name: "EnableAutoSpeakerSelect", + default_value: true, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "auto_speaker_select", + }, + { + Category: "Device", + Base_Name: "SpeakerDeviceList", + default_value: [], + ui_template_id: "list", + logics_template_id: "get_set", + add_endpoint_run_array: ["from_backend"], + base_endpoint_name: "speaker_device_list", + response_transform: "arrayToObject", + }, + { + Category: "Device", + Base_Name: "SelectedSpeakerDevice", + default_value: "", + ui_template_id: "select", + logics_template_id: "get_set", + add_endpoint_run_array: ["from_backend"], + base_endpoint_name: "selected_speaker_device", + }, + { + Category: "Device", + Base_Name: "EnableAutomaticSpeakerThreshold", + default_value: true, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "speaker_automatic_threshold", + }, + { + Category: "Device", + Base_Name: "SpeakerThreshold", + default_value: 0, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "speaker_threshold", + }, + + // Appearance + { + Category: "Appearance", + Base_Name: "UiLanguage", + default_value: "en", + ui_template_id: "select", + logics_template_id: "get_set", + base_endpoint_name: "ui_language", + }, + { + Category: "Appearance", + Base_Name: "UiScaling", + default_value: 100, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "ui_scaling", + }, + { + Category: "Appearance", + Base_Name: "MessageLogUiScaling", + default_value: 100, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "textbox_ui_scaling", + }, + { + Category: "Appearance", + Base_Name: "SendMessageButtonType", + default_value: "primary", + ui_template_id: "select", + logics_template_id: "get_set", + base_endpoint_name: "send_message_button_type", + }, + { + Category: "Appearance", + Base_Name: "ShowResendButton", + default_value: true, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "show_resend_button", + }, + { + Category: "Appearance", + Base_Name: "SelectedFontFamily", + default_value: "Yu Gothic UI", + ui_template_id: "select", + logics_template_id: "get_set", + base_endpoint_name: "font_family", + }, + { + Category: "Appearance", + Base_Name: "Transparency", + default_value: 100, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "transparency", + }, + + // Translation + // CTranslate2/Whisper weights + { + Category: "Translation", + Base_Name: "CTranslate2WeightTypeStatus", + default_value: ctranslate2_weight_type_status, + ui_template_id: "list", + logics_template_id: "weight_download_status", + base_endpoint_name: "ctranslate2_weight", + }, + { + Category: "Translation", + Base_Name: "SelectedCTranslate2WeightType", + default_value: "", + ui_template_id: "select", + logics_template_id: "get_set", + base_endpoint_name: "ctranslate2_weight_type", + }, + { + Category: "Translation", + Base_Name: "SelectedTranslationComputeType", + default_value: "", + ui_template_id: "select", + logics_template_id: "get_set", + base_endpoint_name: "selected_translation_compute_type", + }, + { + Category: "Translation", + Base_Name: "SelectableTranslationComputeDeviceList", + default_value: [], + ui_template_id: "list", + logics_template_id: "get_set", + base_endpoint_name: "translation_compute_device_list", + response_transform: "transformToIndexedArray", + }, + { + Category: "Translation", + Base_Name: "SelectedTranslationComputeDevice", + default_value: "", + ui_template_id: "select", + logics_template_id: "get_set", + base_endpoint_name: "selected_translation_compute_device", + }, + { + Category: "Translation", + Base_Name: "DeepLAuthKey", + default_value: "", + ui_template_id: "input", + logics_template_id: "get_set", + base_endpoint_name: "deepl_auth_key", + }, + + // Transcription + // Mic + { + Category: "Transcription", + Base_Name: "MicRecordTimeout", + default_value: 0, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "mic_record_timeout", + }, + { + Category: "Transcription", + Base_Name: "MicPhraseTimeout", + default_value: 0, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "mic_phrase_timeout", + }, + { + Category: "Transcription", + Base_Name: "MicMaxWords", + default_value: 0, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "mic_max_phrases", + }, + { + Category: "Transcription", + Base_Name: "MicWordFilterList", + default_value: [], + ui_template_id: "list", + logics_template_id: "get_set", + base_endpoint_name: "mic_word_filter", + }, + // Speaker + { + Category: "Transcription", + Base_Name: "SpeakerRecordTimeout", + default_value: 0, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "speaker_record_timeout", + }, + { + Category: "Transcription", + Base_Name: "SpeakerPhraseTimeout", + default_value: 0, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "speaker_phrase_timeout", + }, + { + Category: "Transcription", + Base_Name: "SpeakerMaxWords", + default_value: 0, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "speaker_max_phrases", + }, + // Engines + { + Category: "Transcription", + Base_Name: "SelectedTranscriptionEngine", + default_value: "", + ui_template_id: "select", + logics_template_id: "get_set", + base_endpoint_name: "selected_transcription_engine", + }, + { + Category: "Transcription", + Base_Name: "WhisperWeightTypeStatus", + default_value: whisper_weight_type_status, + ui_template_id: "list", + logics_template_id: "weight_download_status", + base_endpoint_name: "whisper_weight", + }, + { + Category: "Transcription", + Base_Name: "SelectedWhisperWeightType", + default_value: "", + ui_template_id: "select", + logics_template_id: "get_set", + base_endpoint_name: "whisper_weight_type", + }, + { + Category: "Transcription", + Base_Name: "SelectedTranscriptionComputeType", + default_value: "", + ui_template_id: "select", + logics_template_id: "get_set", + base_endpoint_name: "selected_transcription_compute_type", + }, + { + Category: "Transcription", + Base_Name: "SelectableTranscriptionComputeDeviceList", + default_value: [], + ui_template_id: "list", + logics_template_id: "get_set", + base_endpoint_name: "transcription_compute_device_list", + response_transform: "transformToIndexedArray", + }, + { + Category: "Transcription", + Base_Name: "SelectedTranscriptionComputeDevice", + default_value: "", + ui_template_id: "select", + logics_template_id: "get_set", + base_endpoint_name: "selected_transcription_compute_device", + }, + // Advanced + { + Category: "Transcription", + Base_Name: "MicAvgLogprob", + default_value: 0, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "mic_avg_logprob", + }, + { + Category: "Transcription", + Base_Name: "MicNoSpeechProb", + default_value: 0, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "mic_no_speech_prob", + }, + { + Category: "Transcription", + Base_Name: "SpeakerAvgLogprob", + default_value: 0, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "speaker_avg_logprob", + }, + { + Category: "Transcription", + Base_Name: "SpeakerNoSpeechProb", + default_value: 0, + ui_template_id: "slider", + logics_template_id: "get_set", + base_endpoint_name: "speaker_no_speech_prob", + }, + + // Vr + { + Category: "Vr", + Base_Name: "IsEnabledOverlaySmallLog", + default_value: false, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "overlay_small_log", + }, + { + Category: "Vr", + Base_Name: "IsEnabledOverlayLargeLog", + default_value: false, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "overlay_large_log", + }, + { + Category: "Vr", + Base_Name: "OverlaySmallLogSettings", + default_value: {}, + ui_template_id: "object", + logics_template_id: "get_set", + base_endpoint_name: "overlay_small_log_settings", + }, + { + Category: "Vr", + Base_Name: "OverlayLargeLogSettings", + default_value: {}, + ui_template_id: "object", + logics_template_id: "get_set", + base_endpoint_name: "overlay_large_log_settings", + }, + { + Category: "Vr", + Base_Name: "OverlayShowOnlyTranslatedMessages", + default_value: false, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "overlay_show_only_translated_messages", + }, + + // Others + { + Category: "Others", + Base_Name: "EnableAutoClearMessageInputBox", + default_value: false, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "auto_clear_message_box", + }, + { + Category: "Others", + Base_Name: "EnableSendOnlyTranslatedMessages", + default_value: false, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "send_only_translated_messages", + }, + { + Category: "Others", + Base_Name: "EnableAutoExportMessageLogs", + default_value: false, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "logger_feature", + }, + { + Category: "Others", + Base_Name: "EnableVrcMicMuteSync", + default_value: false, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "vrc_mic_mute_sync", + }, + { + Category: "Others", + Base_Name: "EnableSendMessageToVrc", + default_value: false, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "send_message_to_vrc", + }, + { + Category: "Others", + Base_Name: "EnableNotificationVrcSfx", + default_value: false, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "notification_vrc_sfx", + }, + { + Category: "Others", + Base_Name: "EnableSendReceivedMessageToVrc", + default_value: false, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "send_received_message_to_vrc", + }, + { + Category: "Others", + Base_Name: "MessageFormat_ExampleViewFilter", + default_value: {}, + ui_template_id: "object", + logics_template_id: "get_set", + base_endpoint_name: "message_format_example_view_filter", + }, + { + Category: "Others", + Base_Name: "SendMessageFormatParts", + default_value: [], + ui_template_id: "list", + logics_template_id: "get_set", + base_endpoint_name: "send_message_format_parts", + }, + { + Category: "Others", + Base_Name: "ReceivedMessageFormatParts", + default_value: [], + ui_template_id: "list", + logics_template_id: "get_set", + base_endpoint_name: "received_message_format_parts", + }, + { + Category: "Others", + Base_Name: "ConvertMessageToRomaji", + default_value: false, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "convert_message_to_romaji", + }, + { + Category: "Others", + Base_Name: "ConvertMessageToHiragana", + default_value: false, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "convert_message_to_hiragana", + }, + + // Hotkeys + // { + // Category: "Hotkeys", + // Base_Name: "SendMessageHotkey", + // default_value: "", + // ui_template_id: "input", + // logics_template_id: "get_set", + // base_endpoint_name: "send_message_hotkey", + // }, + + // AdvancedSettings + { + Category: "AdvancedSettings", + Base_Name: "OscIpAddress", + default_value: "127.0.0.1", + ui_template_id: "input", + logics_template_id: "get_set", + base_endpoint_name: "osc_ip_address", + }, + { + Category: "AdvancedSettings", + Base_Name: "OscPort", + default_value: 9000, + ui_template_id: "input", + logics_template_id: "get_set", + base_endpoint_name: "osc_port", + }, + { + Category: "AdvancedSettings", + Base_Name: "EnableWebsocket", + default_value: false, + ui_template_id: "toggle", + logics_template_id: "toggle_enable_disable", + base_endpoint_name: "websocket_server", + }, + { + Category: "AdvancedSettings", + Base_Name: "WebsocketHost", + default_value: "127.0.0.1", + ui_template_id: "input", + logics_template_id: "get_set", + base_endpoint_name: "websocket_host", + }, + { + Category: "AdvancedSettings", + Base_Name: "WebsocketPort", + default_value: 9001, + ui_template_id: "input", + logics_template_id: "get_set", + base_endpoint_name: "websocket_port", + }, + +]; + + + +for (const setting_data of SETTINGS_ARRAY) { + createAtomWithHook(setting_data.default_value, setting_data.Base_Name); +} + +const buildCategoryApiFromSettings = (settings, settingsArray, Category) => { + const api = {}; + const filtered = settingsArray.filter((s) => s.Category === Category); + + for (const s of filtered) { + const base = s.Base_Name; + const currentKey = `current${base}`; + const updateKey = `update${base}`; + const getKey = `get${base}`; + const setKey = `set${base}`; + const toggleKey = `toggle${base}`; + const setSuccessKey = `setSuccess${base}`; + const updateFromBackendKey = `updateFromBackend${base}`; + + if (settings[currentKey] !== undefined) api[currentKey] = settings[currentKey]; + if (settings[updateKey] !== undefined) api[updateKey] = settings[updateKey]; + if (typeof settings[getKey] === "function") api[getKey] = settings[getKey]; + if (typeof settings[setKey] === "function") api[setKey] = settings[setKey]; + if (typeof settings[toggleKey] === "function") api[toggleKey] = settings[toggleKey]; + if (typeof settings[setSuccessKey] === "function") api[setSuccessKey] = settings[setSuccessKey]; + if (typeof settings[updateFromBackendKey] === "function") api[updateFromBackendKey] = settings[updateFromBackendKey]; + + if (s.logics_template_id === "weight_download_status") { + const updateDownloadProgressKey = `updateDownloadProgress${base}`; + const updateDownloadedKey = `updateDownloaded${base}`; + const pendingKey = `pending${base}`; + const downloadedKey = `downloaded${base}`; + const downloadKey = `download${base}`; + + if (typeof settings[updateDownloadProgressKey] === "function") api[updateDownloadProgressKey] = settings[updateDownloadProgressKey]; + if (typeof settings[updateDownloadedKey] === "function") api[updateDownloadedKey] = settings[updateDownloadedKey]; + if (typeof settings[pendingKey] === "function") api[pendingKey] = settings[pendingKey]; + if (typeof settings[downloadedKey] === "function") api[downloadedKey] = settings[downloadedKey]; + if (typeof settings[downloadKey] === "function") api[downloadKey] = settings[downloadKey]; + if (typeof settings[updateFromBackendKey] === "function") api[updateFromBackendKey] = settings[updateFromBackendKey]; + } + } + + return api; +}; + +const createCategoryHook = (Category) => { + return () => { + const { settings } = useSettingsLogics(SETTINGS_ARRAY, Category); + const autoApi = buildCategoryApiFromSettings(settings, SETTINGS_ARRAY, Category); + return { ...autoApi }; + }; +}; + + + +// --- 自動エクスポート: SETTINGS_ARRAY に含まれるユニークな Category ごとに use を作って export --- +// 例: Category === "Appearance" -> export const useAppearance = createCategoryHook("Appearance"); + +// const uniqueCategories = Array.from(new Set(SETTINGS_ARRAY.map((s) => s.Category))); + +// 動的に named export を作る(静的解析を壊さないために明示的に定義) +/* eslint-disable import/prefer-default-export */ +export const useAppearance = createCategoryHook("Appearance"); +export const useDevice = createCategoryHook("Device"); +export const useTranslation = createCategoryHook("Translation"); +export const useTranscription = createCategoryHook("Transcription"); +export const useVr = createCategoryHook("Vr"); +export const useOthers = createCategoryHook("Others"); +// export const useHotkeys = createCategoryHook("Hotkeys"); +export const useAdvancedSettings = createCategoryHook("AdvancedSettings"); +// If you later add other categories, you can either manually add: +// export const useDevice = createCategoryHook("Device"); +// or uncomment the code below to auto-attach to module.exports (less ideal for tree-shaking). +// +// Auto-attach (not recommended for tree-shaking in bundlers): +// uniqueCategories.forEach((Category) => { +// const hookName = `use${Category}`; +// module.exports[hookName] = createCategoryHook(Category); +// }); + +/* eslint-enable import/prefer-default-export */ diff --git a/src-ui/useSettingsLogics.js b/src-ui/useSettingsLogics.js new file mode 100644 index 00000000..1429cd8a --- /dev/null +++ b/src-ui/useSettingsLogics.js @@ -0,0 +1,187 @@ +import * as stores from "@store"; +import { useStdoutToPython } from "@useStdoutToPython"; +import { useNotificationStatus } from "@logics_common"; +import { arrayToObject } from "@utils"; + +const transformResponse = (transformName, payload) => { + if (!transformName) return payload; + + switch (transformName) { + case "arrayToObject": + return arrayToObject(payload); + default: + return payload; + } +}; + +export const useSettingsLogics = (settingsArray, Category) => { + const { asyncStdoutToPython } = useStdoutToPython(); + const { showNotification_SaveSuccess } = useNotificationStatus(); + + const filtered = settingsArray.filter((s) => s.Category === Category); + const result = {}; + + + for (const s of filtered) { + const base = s.Base_Name; + let storeHook = undefined; + + if (typeof stores.getStoreHook === "function") { + storeHook = stores.getStoreHook(base); + } + + if (!storeHook) { + const hookName = `useStore_${base}`; + storeHook = stores[hookName]; + } + + if (!storeHook) { + console.warn(`[useSettingsLogics] store hook not found for ${base}`); + continue; + } + + const store = storeHook(); + + const currentKey = `current${base}`; + const updateKey = `update${base}`; + const pendingKey = `pending${base}`; + + const current = store[currentKey]; + const update = store[updateKey]; + const pending = store[pendingKey]; + + const currentExportName = `current${base}`; + const updateExportName = `update${base}`; + const updateFromBackendExportName = `updateFromBackend${base}`; + const getExportName = `get${base}`; + const setExportName = `set${base}`; + const toggleExportName = `toggle${base}`; + const setSuccessExportName = `setSuccess${base}`; + + const runExportName = `runSuccess${base}`; + + // To use by UI------------------------------------ + const buildGet = () => { + return () => { + if (pending) pending(); + asyncStdoutToPython(`/get/data/${s.base_endpoint_name}`); + }; + }; + + const buildSet = () => { + return (value) => { + if (pending) pending(); + asyncStdoutToPython(`/set/data/${s.base_endpoint_name}`, value); + }; + }; + + const buildRun = () => { + return () => { + asyncStdoutToPython(`/run/${s.base_endpoint_name}`); + }; + }; + + + // To use a response from backend------------------------------------ + const buildSetSuccess = (transformName) => { + return (payload) => { + const transformed = transformResponse(transformName, payload); + if (update) update(transformed); + showNotification_SaveSuccess(); + }; + }; + + const buildUpdateFromBackend = (transformName) => { + return (payload) => { + const transformed = transformResponse(transformName, payload); + if (update) update(transformed); + }; + }; + + + result[currentExportName] = current; + result[updateExportName] = update; + result[updateFromBackendExportName] = buildUpdateFromBackend(s.response_transform ?? null); + + if (s.add_endpoint_run_array?.includes("to_backend")) { + result[runExportName] = buildRun(); + } + + + if (s.logics_template_id === "get_list") { + result[getExportName] = buildGet(); + continue; + } + + if (s.logics_template_id === "get_set") { + result[getExportName] = buildGet(); + result[setExportName] = buildSet(); + result[setSuccessExportName] = buildSetSuccess(s.response_transform ?? null); + continue; + } + + if (s.logics_template_id === "toggle_enable_disable") { + result[getExportName] = buildGet(); + result[toggleExportName] = () => { + if (pending) pending(); + const isOn = current && current.data; + if (isOn) { + asyncStdoutToPython(`/set/disable/${s.base_endpoint_name}`); + } else { + asyncStdoutToPython(`/set/enable/${s.base_endpoint_name}`); + } + }; + + result[setSuccessExportName] = buildSetSuccess(s.response_transform ?? null); + continue; + } + + if (s.logics_template_id === "weight_download_status") { + result[setSuccessExportName] = buildSetSuccess(s.response_transform ?? null); + + result[`updateDownloadProgress${base}`] = (payload) => { + update((old_status) => { + return old_status.data.map((item) => + payload.weight_type === item.id + ? { ...item, progress: payload.progress * 100 } + : item + ); + }); + }; + result[`updateDownloaded${base}`] = (downloaded_weight_type_status) => { + update((old_status) => { + return old_status.data.map((item) => ({ + ...item, + is_downloaded: downloaded_weight_type_status[item.id] ?? item.is_downloaded, + })); + }); + }; + result[`pending${base}`] = (id) => { + update((old_status) => { + return old_status.data.map((item) => + id === item.id + ? { ...item, is_pending: true } + : item + ); + }); + }; + result[`downloaded${base}`] = (id) => { + update((old_status) => { + return old_status.data.map((item) => + id === item.id + ? { ...item, is_downloaded: true, is_pending: false, progress: null } + : item + ); + }); + }; + + result[`download${base}`] = (weight_type) => { + asyncStdoutToPython(`/run/download_${s.base_endpoint_name}`, weight_type); + }; + + continue; + } + } + + return { settings: result }; +};