Merge branch 'ui_refactor_and_connect_to_backend' into develop

This commit is contained in:
Sakamoto Shiina
2025-10-23 11:28:39 +09:00
23 changed files with 1151 additions and 2370 deletions

View File

@@ -3,7 +3,10 @@ import { useTranslation } from "react-i18next";
import { _Entry } from "../_atoms/_entry/_Entry";
import SwapImg from "@images/swap_icon.png";
import ArrowLeftSvg from "@images/arrow_left.svg?react";
import { useStore_IsBreakPoint } from "@store";
import {
useStore_IsBreakPoint,
useStore_MessageFormat_ExampleViewFilter,
} from "@store";
import { useAppearance } from "@logics_configs";
import { ui_configs } from "@ui_configs";
import { ResetButton } from "@common_components";
@@ -27,8 +30,6 @@ export const MessageFormat = (props) => {
<div className={message_format_container_class}>
<ExampleComponent
format={props.variable.data}
example_view_filter_variable={props.example_view_filter_variable}
exampleViewFilterToggleFunction={props.exampleViewFilterToggleFunction}
format_id={props.format_id}
/>
<div className={styles.border}></div>
@@ -41,10 +42,13 @@ export const MessageFormat = (props) => {
);
};
const ExampleComponent = ({ format, example_view_filter_variable, exampleViewFilterToggleFunction, format_id }) => {
const ExampleComponent = ({ format, format_id }) => {
const { currentUiLanguage } = useAppearance();
const { t } = useTranslation();
const {
currentMessageFormat_ExampleViewFilter,
updateMessageFormat_ExampleViewFilter,
} = useStore_MessageFormat_ExampleViewFilter();
const locale_base_path = "config_page.others.message_format_common.example_view.";
@@ -116,8 +120,8 @@ const ExampleComponent = ({ format, example_view_filter_variable, exampleViewFil
};
const svg_class_names = clsx(styles.arrow_left_svg, {
[styles.to_down]: example_view_filter_variable[format_id] === "Simplified",
[styles.to_up]: example_view_filter_variable[format_id] === "All"
[styles.to_down]: currentMessageFormat_ExampleViewFilter.data[format_id] === "Simplified",
[styles.to_up]: currentMessageFormat_ExampleViewFilter.data[format_id] === "All"
});
@@ -151,12 +155,22 @@ const ExampleComponent = ({ format, example_view_filter_variable, exampleViewFil
}
};
const exampleViewFilterToggleFunction = (format_id) => {
if (["send", "received"].includes(format_id) === false) return console.error(`format_id should be small case 'send' or 'received'. got format_id: ${format_id}`);
updateMessageFormat_ExampleViewFilter({
...currentMessageFormat_ExampleViewFilter.data,
[format_id]: currentMessageFormat_ExampleViewFilter.data[format_id] === "Simplified"
? "All"
: "Simplified"
});
};
return (
<div className={styles.example_container}>
<p className={styles.section_title}>{label_title}</p>
<div className={styles.example_view_container}>
<FilteredExampleBox format_id={format_id} id={example_view_filter_variable[format_id]} />
<FilteredExampleBox format_id={format_id} id={currentMessageFormat_ExampleViewFilter.data[format_id]} />
</div>
{ format_id === "send" &&
<div className={styles.show_more_container} onClick={() => exampleViewFilterToggleFunction(format_id)}>

View File

@@ -12,12 +12,6 @@ export const WordFilter = () => {
const { currentMicWordFilterList, updateMicWordFilterList, setMicWordFilterList } = useTranscription();
const { currentIsOpenedMicWordFilterList, updateIsOpenedMicWordFilterList } = useStore_IsOpenedMicWordFilterList();
const extractRedoableFalseItem = (updated_list) => {
return updated_list.filter(item => {
if (item.is_redoable === false) return true;
});
};
const onChangeEntry = (e) => {
setInputValue(e.target.value);
};
@@ -30,20 +24,13 @@ export const WordFilter = () => {
for (let each_input_value of input_value_array) {
each_input_value = each_input_value.trim();
if (each_input_value) {
const target_item = updated_list.find((item) => item.value === each_input_value);
if (target_item === undefined) {
// Add
updated_list = [...updated_list, { value: each_input_value, is_redoable: false }];
} else {
// Update
updated_list = updated_list.map(item =>
item.value === each_input_value ? { ...item, is_redoable: false } : item
);
const exists = updated_list.find((item) => item === each_input_value);
if (!exists) {
updated_list = [...updated_list, each_input_value];
}
}
}
const updated_list_for_restoring = extractRedoableFalseItem(updated_list).map((d) => d.value);
setMicWordFilterList(updated_list_for_restoring);
setMicWordFilterList(updated_list);
return updated_list;
});
@@ -52,25 +39,14 @@ export const WordFilter = () => {
};
const updateRedoable = (target_item_value, is_redoable) => {
const deleteAction = (target_item_value) => {
updateMicWordFilterList((prev_list) => {
const updated_list = prev_list.data.map(item =>
item.value === target_item_value ? { ...item, is_redoable: is_redoable } : item
);
const updated_list_for_restoring = extractRedoableFalseItem(updated_list).map((d) => d.value);
setMicWordFilterList(updated_list_for_restoring);
const updated_list = prev_list.data.filter((item) => item !== target_item_value);
setMicWordFilterList(updated_list);
return updated_list;
});
};
const deleteAction = (target_item_value) => {
updateRedoable(target_item_value, true);
};
const redoAction = (target_item_value) => {
updateRedoable(target_item_value, false);
};
return (
<div className={styles.container}>
@@ -78,7 +54,7 @@ export const WordFilter = () => {
<div className={styles.list_section_wrapper}>
{
currentMicWordFilterList.data.map((item, index) => {
return <WordFilterItem value={item.value} key={index} is_redoable={item.is_redoable} deleteAction={deleteAction} redoAction={redoAction}/>;
return <WordFilterItem value={item} key={index} deleteAction={deleteAction}/>;
})
}
</div>
@@ -92,45 +68,27 @@ export const WordFilter = () => {
};
import DeleteSvg from "@images/cancel.svg?react";
import RedoSvg from "@images/redo.svg?react";
import clsx from "clsx";
const WordFilterItem = (props) => {
const item_wrapper_class_names = clsx(styles["item_wrapper"], {
[styles["is_redoable"]]: props.is_redoable
});
const item_text_class_names = clsx(styles["item_text"], {
[styles["is_redoable"]]: props.is_redoable
});
const target_item_value = props.value;
const item_wrapper_class_names = clsx(styles["item_wrapper"]);
const item_text_class_names = clsx(styles["item_text"]);
return (
<div className={item_wrapper_class_names}>
<p className={item_text_class_names}>{target_item_value}</p>
{props.is_redoable
?
<button className={clsx(styles.action_button, styles.redo)} onClick={() => props.redoAction(target_item_value)}>
<RedoSvg className={styles.redo_svg}/>
</button>
:
<button className={clsx(styles.action_button, styles.delete)} onClick={() => props.deleteAction(target_item_value)}>
<DeleteSvg className={styles.delete_svg}/>
</button>
}
<p className={item_text_class_names}>{props.value}</p>
<button className={clsx(styles.action_button, styles.delete)} onClick={() => props.deleteAction(props.value)}>
<DeleteSvg className={styles.delete_svg}/>
</button>
</div>
);
};
import ArrowLeftSvg from "@images/arrow_left.svg?react";
export const WordFilterListToggleComponent = (props) => {
export const WordFilterListToggleComponent = () => {
const { t } = useI18n();
const { currentIsOpenedMicWordFilterList, updateIsOpenedMicWordFilterList } = useStore_IsOpenedMicWordFilterList();
const { currentMicWordFilterList } = useTranscription();
const svg_class_names = clsx(styles["arrow_left_svg"], {
[styles.to_down]: !currentIsOpenedMicWordFilterList.data,
[styles.to_up]: currentIsOpenedMicWordFilterList.data
@@ -140,12 +98,9 @@ export const WordFilterListToggleComponent = (props) => {
updateIsOpenedMicWordFilterList(!currentIsOpenedMicWordFilterList.data);
};
const word_filter_list_length = currentMicWordFilterList.data.filter(item => item.is_redoable === false).length;
return (
<div className={styles.toggle_button_container}>
<p className={styles.words_count_text}>{t("config_page.transcription.mic_word_filter.count_desc", {count: word_filter_list_length} )}</p>
<p className={styles.words_count_text}>{t("config_page.transcription.mic_word_filter.count_desc", {count: currentMicWordFilterList.data.length} )}</p>
<button className={styles.toggle_button_wrapper} onClick={OnclickFunction}>
<ArrowLeftSvg className={svg_class_names}/>
</button>

View File

@@ -25,16 +25,10 @@
background-color: var(--dark_800_color);
padding: 0.2rem 0.2rem 0.2rem 1rem;
border-radius: 0.4rem;
&.is_redoable {
background-color: var(--dark_850_color);
}
}
.item_text {
font-size: 1.4rem;
font-weight: 300;
&.is_redoable {
text-decoration: line-through;
}
}
.action_button {

View File

@@ -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 (
<div className={styles.container}>
<div className={styles.dev_section}>

View File

@@ -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) => {

View File

@@ -168,8 +168,6 @@ const SendMessageFormatPartsContainer = () => {
const {
currentSendMessageFormatParts,
setSendMessageFormatParts,
currentMessageFormat_ExampleViewFilter,
toggleMessageFormat_ExampleViewFilter,
} = useOthers();
return (
@@ -178,8 +176,6 @@ const SendMessageFormatPartsContainer = () => {
desc={t("config_page.others.send_message_format.desc")}
variable={currentSendMessageFormatParts}
setFunction={setSendMessageFormatParts}
example_view_filter_variable={currentMessageFormat_ExampleViewFilter.data}
exampleViewFilterToggleFunction={toggleMessageFormat_ExampleViewFilter}
format_id="send"
/>
);
@@ -190,8 +186,6 @@ const ReceivedMessageFormatPartsContainer = () => {
const {
currentReceivedMessageFormatParts,
setReceivedMessageFormatParts,
currentMessageFormat_ExampleViewFilter,
toggleMessageFormat_ExampleViewFilter,
} = useOthers();
return (
@@ -200,8 +194,6 @@ const ReceivedMessageFormatPartsContainer = () => {
desc={t("config_page.others.received_message_format.desc")}
variable={currentReceivedMessageFormatParts}
setFunction={setReceivedMessageFormatParts}
example_view_filter_variable={currentMessageFormat_ExampleViewFilter.data}
exampleViewFilterToggleFunction={toggleMessageFormat_ExampleViewFilter}
format_id="received"
/>
);

View File

@@ -232,8 +232,8 @@ const WhisperWeightType_Box = () => {
const { t } = useI18n();
const {
currentWhisperWeightTypeStatus,
pendingWhisperWeightType,
downloadWhisperWeight,
pendingWhisperWeightTypeStatus,
downloadWhisperWeightTypeStatus,
} = useTranscription();
const { currentSelectedWhisperWeightType, setSelectedWhisperWeightType } = useTranscription();
@@ -242,23 +242,16 @@ const WhisperWeightType_Box = () => {
};
const downloadStartFunction = (id) => {
pendingWhisperWeightType(id);
downloadWhisperWeight(id);
pendingWhisperWeightTypeStatus(id);
downloadWhisperWeightTypeStatus(id);
};
const new_labels = [
{ id: "tiny", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "tiny", capacity: "74.5MB"}) },
{ id: "base", label: t("config_page.transcription.whisper_weight_type.recommended_model_template", {model_name: "base", capacity: "141MB"}) },
{ id: "small", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "small", capacity: "463MB"}) },
{ id: "medium", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "medium", capacity: "1.42GB"}) },
{ id: "large-v1", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "large-v1", capacity: "2.87GB"}) },
{ id: "large-v2", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "large-v2", capacity: "2.87GB"}) },
{ id: "large-v3", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "large-v3", capacity: "2.87GB"}) },
{ id: "large-v3-turbo-int8", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "large-v3-turbo-int8", capacity: "794MB"}) },
{ id: "large-v3-turbo", label: t("config_page.transcription.whisper_weight_type.model_template", {model_name: "large-v3-turbo", capacity: "1.58GB"}) },
];
const whisper_weight_types = updateLabelsById(currentWhisperWeightTypeStatus.data, new_labels);
const whisper_weight_types = currentWhisperWeightTypeStatus.data.map(item => {
return {
...item,
label: `${item.id} (${item.capacity})`,
};
});
return (
<>

View File

@@ -34,8 +34,8 @@ const CTranslate2WeightType_Box = () => {
const { t } = useI18n();
const {
currentCTranslate2WeightTypeStatus,
pendingCTranslate2WeightType,
downloadCTranslate2Weight,
pendingCTranslate2WeightTypeStatus,
downloadCTranslate2WeightTypeStatus,
currentSelectedCTranslate2WeightType,
setSelectedCTranslate2WeightType,
@@ -46,16 +46,18 @@ const CTranslate2WeightType_Box = () => {
};
const downloadStartFunction = (id) => {
pendingCTranslate2WeightType(id);
downloadCTranslate2Weight(id);
pendingCTranslate2WeightTypeStatus(id);
downloadCTranslate2WeightTypeStatus(id);
};
const new_labels = [
{ id: "small", label: t("config_page.translation.ctranslate2_weight_type.small", {capacity: "418MB"}) },
{ id: "large", label: t("config_page.translation.ctranslate2_weight_type.large", {capacity: "1.2GB"}) },
];
const c_translate2_weight_types = updateLabelsById(currentCTranslate2WeightTypeStatus.data, new_labels);
const c_translate2_weight_types_object = currentCTranslate2WeightTypeStatus.data.map(item => {
return {
...item,
label: `${item.id} (${item.capacity})`,
};
});
return (
<>
@@ -69,7 +71,7 @@ const CTranslate2WeightType_Box = () => {
{ctranslate2: "CTranslate2"}
)}
name="ctranslate2_weight_type"
options={c_translate2_weight_types}
options={c_translate2_weight_types_object}
checked_variable={currentSelectedCTranslate2WeightType}
selectFunction={selectFunction}
downloadStartFunction={downloadStartFunction}

View File

@@ -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";

View File

@@ -11,7 +11,7 @@ export const DownloadModelsContainer = () => {
const { currentCTranslate2WeightTypeStatus } = useTranslation();
const { currentWhisperWeightTypeStatus } = useTranscription();
const c_translate_2 = currentCTranslate2WeightTypeStatus.data.find(d => d.id === "small");
const c_translate_2 = currentCTranslate2WeightTypeStatus.data.find(d => d.id === "m2m100_418M-ct2-int8");
const whisper = currentWhisperWeightTypeStatus.data.find(d => d.id === "base");
if (c_translate_2.progress === null && whisper.progress === null) return null;
@@ -19,8 +19,8 @@ export const DownloadModelsContainer = () => {
return (
<div className={styles.container}>
<div className={styles.progress_container}>
<DownloadModelsProgress progress={c_translate_2.progress} type_label="CTranslate2 Model"/>
<DownloadModelsProgress progress={whisper.progress} type_label="Whisper Model"/>
<DownloadModelsProgress progress={c_translate_2.progress} type_label="Translation Model"/>
<DownloadModelsProgress progress={whisper.progress} type_label="Transcription Model"/>
</div>
<div className={styles.labels_wrapper}>
<img src={vrct_logo_for_dark_mode} className={styles.logo_img}/>

View File

@@ -1,150 +0,0 @@
import {
useStore_OscIpAddress,
useStore_OscPort,
useStore_EnableWebsocket,
useStore_WebsocketHost,
useStore_WebsocketPort,
} from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { useNotificationStatus } from "@logics_common";
export const useAdvancedSettings = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { showNotification_Error, showNotification_SaveSuccess } = useNotificationStatus();
// OSC IP Address
const { currentOscIpAddress, updateOscIpAddress, pendingOscIpAddress } = useStore_OscIpAddress();
// OSC Port
const { currentOscPort, updateOscPort, pendingOscPort } = useStore_OscPort();
// WebSocket
const { currentEnableWebsocket, updateEnableWebsocket, pendingEnableWebsocket } = useStore_EnableWebsocket();
const { currentWebsocketHost, updateWebsocketHost, pendingWebsocketHost } = useStore_WebsocketHost();
const { currentWebsocketPort, updateWebsocketPort, pendingWebsocketPort } = useStore_WebsocketPort();
// OSC IP Address
const getOscIpAddress = () => {
pendingOscIpAddress();
asyncStdoutToPython("/get/data/osc_ip_address");
};
const setOscIpAddress = (osc_ip_address) => {
pendingOscIpAddress();
asyncStdoutToPython("/set/data/osc_ip_address", osc_ip_address);
};
const setSuccessOscIpAddress = (osc_ip_address) => {
updateOscIpAddress(osc_ip_address);
showNotification_SaveSuccess();
};
// OSC Port
const getOscPort = () => {
pendingOscPort();
asyncStdoutToPython("/get/data/osc_port");
};
const setOscPort = (osc_port) => {
pendingOscPort();
asyncStdoutToPython("/set/data/osc_port", osc_port);
};
const setSuccessOscPort = (osc_port) => {
updateOscPort(osc_port);
showNotification_SaveSuccess();
};
const saveErrorOscPort = ({ data, message, _result }) => {
updateOscPort(d => d.data);
showNotification_Error(_result);
};
// WebSocket Enable
const getEnableWebsocket = () => {
pendingEnableWebsocket();
asyncStdoutToPython("/get/data/websocket_server");
};
const toggleEnableWebsocket = () => {
pendingEnableWebsocket();
if (currentEnableWebsocket.data) {
asyncStdoutToPython("/set/disable/websocket_server");
} else {
asyncStdoutToPython("/set/enable/websocket_server");
}
};
const setSuccessEnableWebsocket = (is_enabled) => {
updateEnableWebsocket(is_enabled);
showNotification_SaveSuccess();
};
// WebSocket Host
const getWebsocketHost = () => {
pendingWebsocketHost();
asyncStdoutToPython("/get/data/websocket_host");
};
const setWebsocketHost = (websocket_host) => {
pendingWebsocketHost();
asyncStdoutToPython("/set/data/websocket_host", websocket_host);
};
const setSuccessWebsocketHost = (websocket_host) => {
updateWebsocketHost(websocket_host);
showNotification_SaveSuccess();
};
// WebSocket Port
const getWebsocketPort = () => {
pendingWebsocketPort();
asyncStdoutToPython("/get/data/websocket_port");
};
const setWebsocketPort = (websocket_port) => {
pendingWebsocketPort();
asyncStdoutToPython("/set/data/websocket_port", websocket_port);
};
const setSuccessWebsocketPort = (websocket_port) => {
updateWebsocketPort(websocket_port);
showNotification_SaveSuccess();
};
return {
// OSC IP Address
currentOscIpAddress,
getOscIpAddress,
updateOscIpAddress,
setOscIpAddress,
setSuccessOscIpAddress,
// OSC Port
currentOscPort,
getOscPort,
updateOscPort,
setOscPort,
setSuccessOscPort,
saveErrorOscPort,
// WebSocket Enable
currentEnableWebsocket,
getEnableWebsocket,
updateEnableWebsocket,
toggleEnableWebsocket,
setSuccessEnableWebsocket,
// WebSocket Host
currentWebsocketHost,
getWebsocketHost,
updateWebsocketHost,
setWebsocketHost,
setSuccessWebsocketHost,
// WebSocket Port
currentWebsocketPort,
getWebsocketPort,
updateWebsocketPort,
setWebsocketPort,
setSuccessWebsocketPort,
};
};

View File

@@ -1,201 +0,0 @@
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");
};
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();
};
// 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 setSuccessUiScaling = (selected_ui_scaling) => {
updateUiScaling(selected_ui_scaling);
showNotification_SaveSuccess();
};
// 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 setSuccessMessageLogUiScaling = (selected_ui_scaling) => {
updateMessageLogUiScaling(selected_ui_scaling);
showNotification_SaveSuccess();
};
// 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 setSuccessSendMessageButtonType = (send_message_button_type) => {
updateSendMessageButtonType(send_message_button_type);
showNotification_SaveSuccess();
};
// 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();
};
// 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 setSuccessSelectedFontFamily = (selected_font_family) => {
updateSelectedFontFamily(selected_font_family);
showNotification_SaveSuccess();
};
// Transparency
const getTransparency = () => {
pendingTransparency();
asyncStdoutToPython("/get/data/transparency");
};
const setTransparency = (selected_transparency) => {
pendingTransparency();
asyncStdoutToPython("/set/data/transparency", selected_transparency);
};
const setSuccessTransparency = (selected_transparency) => {
updateTransparency(selected_transparency);
showNotification_SaveSuccess();
};
return {
// UI Language
currentUiLanguage,
getUiLanguage,
updateUiLanguage,
setUiLanguage,
setSuccessUiLanguage,
// UI Scaling
currentUiScaling,
getUiScaling,
updateUiScaling,
setUiScaling,
setSuccessUiScaling,
// Message Log Ui Scaling
currentMessageLogUiScaling,
getMessageLogUiScaling,
updateMessageLogUiScaling,
setMessageLogUiScaling,
setSuccessMessageLogUiScaling,
// Send Message Button Type
currentSendMessageButtonType,
getSendMessageButtonType,
setSendMessageButtonType,
setSuccessSendMessageButtonType,
updateSendMessageButtonType,
// Show Resend Button
currentShowResendButton,
getShowResendButton,
updateShowResendButton,
toggleShowResendButton,
setSuccessShowResendButton,
// Selected Font Family
currentSelectedFontFamily,
getSelectedFontFamily,
updateSelectedFontFamily,
setSelectedFontFamily,
setSuccessSelectedFontFamily,
// Transparency
currentTransparency,
getTransparency,
updateTransparency,
setTransparency,
setSuccessTransparency,
};
};

View File

@@ -1,306 +0,0 @@
import {
useStore_EnableAutoMicSelect,
useStore_EnableAutoSpeakerSelect,
useStore_MicDeviceList,
useStore_MicHostList,
useStore_SpeakerDeviceList,
useStore_SelectedMicHost,
useStore_SelectedMicDevice,
useStore_SelectedSpeakerDevice,
useStore_MicThreshold,
useStore_EnableAutomaticMicThreshold,
useStore_SpeakerThreshold,
useStore_EnableAutomaticSpeakerThreshold,
} from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { arrayToObject } from "@utils";
import { useNotificationStatus } from "@logics_common";
export const useDevice = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { showNotification_SaveSuccess } = useNotificationStatus();
const { currentEnableAutoMicSelect, updateEnableAutoMicSelect, pendingEnableAutoMicSelect } = useStore_EnableAutoMicSelect();
const { currentEnableAutoSpeakerSelect, updateEnableAutoSpeakerSelect, pendingEnableAutoSpeakerSelect } = useStore_EnableAutoSpeakerSelect();
const { currentMicDeviceList, updateMicDeviceList, pendingMicDeviceList } = useStore_MicDeviceList();
const { currentMicHostList, updateMicHostList, pendingMicHostList } = useStore_MicHostList();
const { currentSpeakerDeviceList, updateSpeakerDeviceList, pendingSpeakerDeviceList } = useStore_SpeakerDeviceList();
const { currentSelectedMicHost, updateSelectedMicHost, pendingSelectedMicHost } = useStore_SelectedMicHost();
const { currentSelectedMicDevice, updateSelectedMicDevice, pendingSelectedMicDevice } = useStore_SelectedMicDevice();
const { currentSelectedSpeakerDevice, updateSelectedSpeakerDevice, pendingSelectedSpeakerDevice } = useStore_SelectedSpeakerDevice();
const { currentMicThreshold, updateMicThreshold } = useStore_MicThreshold();
const { currentEnableAutomaticMicThreshold, updateEnableAutomaticMicThreshold, pendingEnableAutomaticMicThreshold } = useStore_EnableAutomaticMicThreshold();
const { currentSpeakerThreshold, updateSpeakerThreshold } = useStore_SpeakerThreshold();
const { currentEnableAutomaticSpeakerThreshold, updateEnableAutomaticSpeakerThreshold, pendingEnableAutomaticSpeakerThreshold } = useStore_EnableAutomaticSpeakerThreshold();
// Auto Select (Mic)
const getEnableAutoMicSelect = () => {
pendingEnableAutoMicSelect();
asyncStdoutToPython("/get/data/auto_mic_select");
};
const toggleEnableAutoMicSelect = () => {
pendingEnableAutoMicSelect();
if (currentEnableAutoMicSelect.data) {
asyncStdoutToPython("/set/disable/auto_mic_select");
} else {
asyncStdoutToPython("/set/enable/auto_mic_select");
}
};
const setSuccessEnableAutoMicSelect = (enabled) => {
updateEnableAutoMicSelect(enabled);
showNotification_SaveSuccess();
};
// Auto Select (Speaker)
const getEnableAutoSpeakerSelect = () => {
pendingEnableAutoSpeakerSelect();
asyncStdoutToPython("/get/data/auto_speaker_select");
};
const toggleEnableAutoSpeakerSelect = () => {
pendingEnableAutoSpeakerSelect();
if (currentEnableAutoSpeakerSelect.data) {
asyncStdoutToPython("/set/disable/auto_speaker_select");
} else {
asyncStdoutToPython("/set/enable/auto_speaker_select");
}
};
const setSuccessEnableAutoSpeakerSelect = (enabled) => {
updateEnableAutoSpeakerSelect(enabled);
showNotification_SaveSuccess();
};
// List (Mic device)
const getMicDeviceList = () => {
pendingMicDeviceList();
asyncStdoutToPython("/get/data/mic_device_list");
};
const updateMicDeviceList_FromBackend = (payload) => {
updateMicDeviceList(arrayToObject(payload));
};
// List (Mic host)
const getMicHostList = () => {
pendingMicHostList();
asyncStdoutToPython("/get/data/mic_host_list");
};
const updateMicHostList_FromBackend = (payload) => {
updateMicHostList(arrayToObject(payload));
};
// List (Speaker device)
const getSpeakerDeviceList = () => {
pendingSpeakerDeviceList();
asyncStdoutToPython("/get/data/speaker_device_list");
};
const updateSpeakerDeviceList_FromBackend = (payload) => {
updateSpeakerDeviceList(arrayToObject(payload));
};
// Selected (Mic host)
const getSelectedMicHost = () => {
pendingSelectedMicHost();
asyncStdoutToPython("/get/data/selected_mic_host");
};
const setSelectedMicHost = (selected_mic_host) => {
pendingSelectedMicHost();
asyncStdoutToPython("/set/data/selected_mic_host", selected_mic_host);
};
const setSuccessSelectedMicHost = (payload) => {
updateSelectedMicHostAndDevice(payload); // Receive host and device from backend.
showNotification_SaveSuccess();
};
// Selected (Mic device)
const getSelectedMicDevice = () => {
pendingSelectedMicDevice();
asyncStdoutToPython("/get/data/selected_mic_device");
};
const setSelectedMicDevice = (selected_mic_device) => {
pendingSelectedMicDevice();
asyncStdoutToPython("/set/data/selected_mic_device", selected_mic_device);
};
const setSuccessSelectedMicDevice = (selected_mic_device) => {
updateSelectedMicDevice(selected_mic_device);
showNotification_SaveSuccess();
};
// Selected (Mic Device and Host)
const updateSelectedMicHostAndDevice = (payload) => {
updateSelectedMicHost(payload.host);
updateSelectedMicDevice(payload.device);
}
// Selected (Speaker device)
const getSelectedSpeakerDevice = () => {
pendingSelectedSpeakerDevice();
asyncStdoutToPython("/get/data/selected_speaker_device");
};
const setSelectedSpeakerDevice = (selected_speaker_device) => {
pendingSelectedSpeakerDevice();
asyncStdoutToPython("/set/data/selected_speaker_device", selected_speaker_device);
};
const setSuccessSelectedSpeakerDevice = (selected_speaker_device) => {
updateSelectedSpeakerDevice(selected_speaker_device);
showNotification_SaveSuccess();
};
// Threshold (Mic)
const getMicThreshold = () => {
asyncStdoutToPython("/get/data/mic_threshold");
};
const setMicThreshold = (mic_threshold) => {
asyncStdoutToPython("/set/data/mic_threshold", mic_threshold);
};
const setSuccessMicThreshold = (mic_threshold) => {
updateMicThreshold(mic_threshold);
showNotification_SaveSuccess();
};
const getEnableAutomaticMicThreshold = () => {
pendingEnableAutomaticMicThreshold();
asyncStdoutToPython("/get/data/mic_automatic_threshold");
};
const toggleEnableAutomaticMicThreshold = () => {
pendingEnableAutomaticMicThreshold();
if (currentEnableAutomaticMicThreshold.data) {
asyncStdoutToPython("/set/disable/mic_automatic_threshold");
} else {
asyncStdoutToPython("/set/enable/mic_automatic_threshold");
}
};
const setSuccessEnableAutomaticMicThreshold = (enabled) => {
updateEnableAutomaticMicThreshold(enabled);
showNotification_SaveSuccess();
};
// Threshold (Speaker)
const getSpeakerThreshold = () => {
asyncStdoutToPython("/get/data/speaker_threshold");
};
const setSpeakerThreshold = (speaker_threshold) => {
asyncStdoutToPython("/set/data/speaker_threshold", speaker_threshold);
};
const setSuccessSpeakerThreshold = (speaker_threshold) => {
updateSpeakerThreshold(speaker_threshold);
showNotification_SaveSuccess();
};
const getEnableAutomaticSpeakerThreshold = () => {
pendingEnableAutomaticSpeakerThreshold();
asyncStdoutToPython("/get/data/speaker_automatic_threshold");
};
const toggleEnableAutomaticSpeakerThreshold = () => {
pendingEnableAutomaticSpeakerThreshold();
if (currentEnableAutomaticSpeakerThreshold.data) {
asyncStdoutToPython("/set/disable/speaker_automatic_threshold");
} else {
asyncStdoutToPython("/set/enable/speaker_automatic_threshold");
}
};
const setSuccessEnableAutomaticSpeakerThreshold = (enabled) => {
updateEnableAutomaticSpeakerThreshold(enabled);
showNotification_SaveSuccess();
};
return {
currentEnableAutoMicSelect,
getEnableAutoMicSelect,
updateEnableAutoMicSelect,
toggleEnableAutoMicSelect,
setSuccessEnableAutoMicSelect,
currentEnableAutoSpeakerSelect,
getEnableAutoSpeakerSelect,
updateEnableAutoSpeakerSelect,
toggleEnableAutoSpeakerSelect,
setSuccessEnableAutoSpeakerSelect,
currentMicDeviceList,
getMicDeviceList,
updateMicDeviceList,
updateMicDeviceList_FromBackend,
currentMicHostList,
getMicHostList,
updateMicHostList,
updateMicHostList_FromBackend,
currentSpeakerDeviceList,
getSpeakerDeviceList,
updateSpeakerDeviceList,
updateSpeakerDeviceList_FromBackend,
currentSelectedMicHost,
getSelectedMicHost,
updateSelectedMicHost,
setSelectedMicHost,
setSuccessSelectedMicHost,
currentSelectedMicDevice,
getSelectedMicDevice,
updateSelectedMicDevice,
setSelectedMicDevice,
setSuccessSelectedMicDevice,
updateSelectedMicHostAndDevice,
currentSelectedSpeakerDevice,
getSelectedSpeakerDevice,
updateSelectedSpeakerDevice,
setSelectedSpeakerDevice,
setSuccessSelectedSpeakerDevice,
currentMicThreshold,
getMicThreshold,
setMicThreshold,
updateMicThreshold,
setSuccessMicThreshold,
currentEnableAutomaticMicThreshold,
getEnableAutomaticMicThreshold,
toggleEnableAutomaticMicThreshold,
updateEnableAutomaticMicThreshold,
setSuccessEnableAutomaticMicThreshold,
currentSpeakerThreshold,
getSpeakerThreshold,
setSpeakerThreshold,
updateSpeakerThreshold,
setSuccessSpeakerThreshold,
currentEnableAutomaticSpeakerThreshold,
getEnableAutomaticSpeakerThreshold,
toggleEnableAutomaticSpeakerThreshold,
updateEnableAutomaticSpeakerThreshold,
setSuccessEnableAutomaticSpeakerThreshold,
};
};

View File

@@ -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";

View File

@@ -1,367 +0,0 @@
import {
useStore_EnableAutoClearMessageInputBox,
useStore_EnableSendOnlyTranslatedMessages,
useStore_EnableAutoExportMessageLogs,
useStore_EnableVrcMicMuteSync,
useStore_EnableSendMessageToVrc,
useStore_EnableNotificationVrcSfx,
useStore_EnableSendReceivedMessageToVrc,
useStore_MessageFormat_ExampleViewFilter,
useStore_SendMessageFormatParts,
useStore_ReceivedMessageFormatParts,
useStore_ConvertMessageToRomaji,
useStore_ConvertMessageToHiragana,
} from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { useNotificationStatus } from "@logics_common";
export const useOthers = () => {
const { asyncStdoutToPython } = useStdoutToPython();
// Auto Clear Message Input Box
const { currentEnableAutoClearMessageInputBox, updateEnableAutoClearMessageInputBox, pendingEnableAutoClearMessageInputBox } = useStore_EnableAutoClearMessageInputBox();
// Send Only Translated Messages
const { currentEnableSendOnlyTranslatedMessages, updateEnableSendOnlyTranslatedMessages, pendingEnableSendOnlyTranslatedMessages } = useStore_EnableSendOnlyTranslatedMessages();
// Auto Export Message Logs
const { currentEnableAutoExportMessageLogs, updateEnableAutoExportMessageLogs, pendingEnableAutoExportMessageLogs } = useStore_EnableAutoExportMessageLogs();
// VRC Mic Mute Sync
const { currentEnableVrcMicMuteSync, updateEnableVrcMicMuteSync, pendingEnableVrcMicMuteSync } = useStore_EnableVrcMicMuteSync();
// Send Message To VRCT
const { currentEnableSendMessageToVrc, updateEnableSendMessageToVrc, pendingEnableSendMessageToVrc } = useStore_EnableSendMessageToVrc();
// Sounds
// Notification VRC SFX
const { currentEnableNotificationVrcSfx, updateEnableNotificationVrcSfx, pendingEnableNotificationVrcSfx } = useStore_EnableNotificationVrcSfx();
// Speaker2Chatbox
// Send Received Message To VRC
const { currentEnableSendReceivedMessageToVrc, updateEnableSendReceivedMessageToVrc, pendingEnableSendReceivedMessageToVrc } = useStore_EnableSendReceivedMessageToVrc();
// Message Formats
const { currentMessageFormat_ExampleViewFilter, updateMessageFormat_ExampleViewFilter, pendingMessageFormat_ExampleViewFilter } = useStore_MessageFormat_ExampleViewFilter();
// Send
const { currentSendMessageFormatParts, updateSendMessageFormatParts, pendingSendMessageFormatParts } = useStore_SendMessageFormatParts();
// Received
const { currentReceivedMessageFormatParts, updateReceivedMessageFormatParts, pendingReceivedMessageFormatParts } = useStore_ReceivedMessageFormatParts();
// Convert Message To Romaji
const { currentConvertMessageToRomaji, updateConvertMessageToRomaji, pendingConvertMessageToRomaji } = useStore_ConvertMessageToRomaji();
// Convert Message To Hiragana
const { currentConvertMessageToHiragana, updateConvertMessageToHiragana, pendingConvertMessageToHiragana } = useStore_ConvertMessageToHiragana();
const { showNotification_SaveSuccess } = useNotificationStatus();
// Auto Clear Message Input Box
const getEnableAutoClearMessageInputBox = () => {
pendingEnableAutoClearMessageInputBox();
asyncStdoutToPython("/get/data/auto_clear_message_box");
};
const toggleEnableAutoClearMessageInputBox = () => {
pendingEnableAutoClearMessageInputBox();
if (currentEnableAutoClearMessageInputBox.data) {
asyncStdoutToPython("/set/disable/auto_clear_message_box");
} else {
asyncStdoutToPython("/set/enable/auto_clear_message_box");
}
};
const setSuccessEnableAutoClearMessageInputBox = (enabled) => {
updateEnableAutoClearMessageInputBox(enabled);
showNotification_SaveSuccess();
};
// Send Only Translated Messages
const getEnableSendOnlyTranslatedMessages = () => {
pendingEnableSendOnlyTranslatedMessages();
asyncStdoutToPython("/get/data/send_only_translated_messages");
};
const toggleEnableSendOnlyTranslatedMessages = () => {
pendingEnableSendOnlyTranslatedMessages();
if (currentEnableSendOnlyTranslatedMessages.data) {
asyncStdoutToPython("/set/disable/send_only_translated_messages");
} else {
asyncStdoutToPython("/set/enable/send_only_translated_messages");
}
};
const setSuccessEnableSendOnlyTranslatedMessages = (enabled) => {
updateEnableSendOnlyTranslatedMessages(enabled);
showNotification_SaveSuccess();
};
// Auto Export Message Logs
const getEnableAutoExportMessageLogs = () => {
pendingEnableAutoExportMessageLogs();
asyncStdoutToPython("/get/data/logger_feature");
};
const toggleEnableAutoExportMessageLogs = () => {
pendingEnableAutoExportMessageLogs();
if (currentEnableAutoExportMessageLogs.data) {
asyncStdoutToPython("/set/disable/logger_feature");
} else {
asyncStdoutToPython("/set/enable/logger_feature");
}
};
const setSuccessEnableAutoExportMessageLogs = (enabled) => {
updateEnableAutoExportMessageLogs(enabled);
showNotification_SaveSuccess();
};
// VRC Mic Mute Sync
const getEnableVrcMicMuteSync = () => {
pendingEnableVrcMicMuteSync();
asyncStdoutToPython("/get/data/vrc_mic_mute_sync");
};
const toggleEnableVrcMicMuteSync = () => {
pendingEnableVrcMicMuteSync();
if (currentEnableVrcMicMuteSync.data.is_enabled) {
asyncStdoutToPython("/set/disable/vrc_mic_mute_sync");
} else {
asyncStdoutToPython("/set/enable/vrc_mic_mute_sync");
}
};
const getSuccessEnableVrcMicMuteSync = (is_enabled) => {
updateEnableVrcMicMuteSync(old => ({ ...old.data, is_enabled: is_enabled }));
};
const setSuccessEnableVrcMicMuteSync = (is_enabled) => {
updateEnableVrcMicMuteSync(old => ({ ...old.data, is_enabled: is_enabled }));
showNotification_SaveSuccess();
};
// Send Message To VRCT
const getEnableSendMessageToVrc = () => {
pendingEnableSendMessageToVrc();
asyncStdoutToPython("/get/data/send_message_to_vrc");
};
const toggleEnableSendMessageToVrc = () => {
pendingEnableSendMessageToVrc();
if (currentEnableSendMessageToVrc.data) {
asyncStdoutToPython("/set/disable/send_message_to_vrc");
} else {
asyncStdoutToPython("/set/enable/send_message_to_vrc");
}
};
const setSuccessEnableSendMessageToVrc = (enabled) => {
updateEnableSendMessageToVrc(enabled);
showNotification_SaveSuccess();
};
// Sounds
// Notification VRC SFX
const getEnableNotificationVrcSfx = () => {
pendingEnableNotificationVrcSfx();
asyncStdoutToPython("/get/data/notification_vrc_sfx");
};
const toggleEnableNotificationVrcSfx = () => {
pendingEnableNotificationVrcSfx();
if (currentEnableNotificationVrcSfx.data) {
asyncStdoutToPython("/set/disable/notification_vrc_sfx");
} else {
asyncStdoutToPython("/set/enable/notification_vrc_sfx");
}
};
const setSuccessEnableNotificationVrcSfx = (enabled) => {
updateEnableNotificationVrcSfx(enabled);
showNotification_SaveSuccess();
};
// Speaker2Chatbox
// Send Received Message To VRC
const getEnableSendReceivedMessageToVrc = () => {
pendingEnableSendReceivedMessageToVrc();
asyncStdoutToPython("/get/data/send_received_message_to_vrc");
};
const toggleEnableSendReceivedMessageToVrc = () => {
pendingEnableSendReceivedMessageToVrc();
if (currentEnableSendReceivedMessageToVrc.data) {
asyncStdoutToPython("/set/disable/send_received_message_to_vrc");
} else {
asyncStdoutToPython("/set/enable/send_received_message_to_vrc");
}
};
const setSuccessEnableSendReceivedMessageToVrc = (enabled) => {
updateEnableSendReceivedMessageToVrc(enabled);
showNotification_SaveSuccess();
};
// Message Formats
// Send
const getSendMessageFormatParts = () => {
pendingSendMessageFormatParts();
asyncStdoutToPython("/get/data/send_message_format_parts");
};
const setSendMessageFormatParts = (message_format_parts) => {
pendingSendMessageFormatParts();
asyncStdoutToPython("/set/data/send_message_format_parts", message_format_parts);
};
const setSuccessSendMessageFormatParts = (message_format_parts) => {
updateSendMessageFormatParts(message_format_parts);
showNotification_SaveSuccess();
};
// Received
const getReceivedMessageFormatParts = () => {
pendingReceivedMessageFormatParts();
asyncStdoutToPython("/get/data/received_message_format_parts");
};
const setReceivedMessageFormatParts = (message_format_parts) => {
pendingReceivedMessageFormatParts();
asyncStdoutToPython("/set/data/received_message_format_parts", message_format_parts);
};
const setSuccessReceivedMessageFormatParts = (message_format_parts) => {
updateReceivedMessageFormatParts(message_format_parts);
showNotification_SaveSuccess();
};
const toggleMessageFormat_ExampleViewFilter = (id) => {
pendingMessageFormat_ExampleViewFilter();
if (["send", "received"].includes(id) === false) return console.error(`id should be small case 'send' or 'received'. got id: ${id}`);
updateMessageFormat_ExampleViewFilter({
...currentMessageFormat_ExampleViewFilter.data,
[id]: currentMessageFormat_ExampleViewFilter.data[id] === "Simplified"
? "All"
: "Simplified"
});
};
// Convert Message To Romaji
const getConvertMessageToRomaji = () => {
pendingConvertMessageToRomaji();
asyncStdoutToPython("/get/data/convert_message_to_romaji");
};
const toggleConvertMessageToRomaji = () => {
pendingConvertMessageToRomaji();
if (currentConvertMessageToRomaji.data) {
asyncStdoutToPython("/set/disable/convert_message_to_romaji");
} else {
asyncStdoutToPython("/set/enable/convert_message_to_romaji");
}
};
const setSuccessConvertMessageToRomaji = (enabled) => {
updateConvertMessageToRomaji(enabled);
showNotification_SaveSuccess();
};
// Convert Message To Hiragana
const getConvertMessageToHiragana = () => {
pendingConvertMessageToHiragana();
asyncStdoutToPython("/get/data/convert_message_to_hiragana");
};
const toggleConvertMessageToHiragana = () => {
pendingConvertMessageToHiragana();
if (currentConvertMessageToHiragana.data) {
asyncStdoutToPython("/set/disable/convert_message_to_hiragana");
} else {
asyncStdoutToPython("/set/enable/convert_message_to_hiragana");
}
};
const setSuccessConvertMessageToHiragana = (enabled) => {
updateConvertMessageToHiragana(enabled);
showNotification_SaveSuccess();
};
return {
// Auto Clear Message Input Box
currentEnableAutoClearMessageInputBox,
getEnableAutoClearMessageInputBox,
toggleEnableAutoClearMessageInputBox,
updateEnableAutoClearMessageInputBox,
setSuccessEnableAutoClearMessageInputBox,
// Send Only Translated Messages
currentEnableSendOnlyTranslatedMessages,
getEnableSendOnlyTranslatedMessages,
toggleEnableSendOnlyTranslatedMessages,
updateEnableSendOnlyTranslatedMessages,
setSuccessEnableSendOnlyTranslatedMessages,
// Auto Export Message Logs
currentEnableAutoExportMessageLogs,
getEnableAutoExportMessageLogs,
toggleEnableAutoExportMessageLogs,
updateEnableAutoExportMessageLogs,
setSuccessEnableAutoExportMessageLogs,
// VRC Mic Mute Sync
currentEnableVrcMicMuteSync,
getEnableVrcMicMuteSync,
getSuccessEnableVrcMicMuteSync,
toggleEnableVrcMicMuteSync,
updateEnableVrcMicMuteSync,
setSuccessEnableVrcMicMuteSync,
// Send Message To VRCT
currentEnableSendMessageToVrc,
getEnableSendMessageToVrc,
toggleEnableSendMessageToVrc,
updateEnableSendMessageToVrc,
setSuccessEnableSendMessageToVrc,
// Sounds
// Notification VRC SFX
currentEnableNotificationVrcSfx,
getEnableNotificationVrcSfx,
toggleEnableNotificationVrcSfx,
updateEnableNotificationVrcSfx,
setSuccessEnableNotificationVrcSfx,
// Speaker2Chatbox
// Send Received Message To VRC
currentEnableSendReceivedMessageToVrc,
getEnableSendReceivedMessageToVrc,
toggleEnableSendReceivedMessageToVrc,
updateEnableSendReceivedMessageToVrc,
setSuccessEnableSendReceivedMessageToVrc,
// Message Formats
currentMessageFormat_ExampleViewFilter,
toggleMessageFormat_ExampleViewFilter,
// Send
currentSendMessageFormatParts,
updateSendMessageFormatParts,
getSendMessageFormatParts,
setSendMessageFormatParts,
setSuccessSendMessageFormatParts,
// Received
currentReceivedMessageFormatParts,
updateReceivedMessageFormatParts,
getReceivedMessageFormatParts,
setReceivedMessageFormatParts,
setSuccessReceivedMessageFormatParts,
// Convert Message To Romaji
currentConvertMessageToRomaji,
getConvertMessageToRomaji,
toggleConvertMessageToRomaji,
updateConvertMessageToRomaji,
setSuccessConvertMessageToRomaji,
// Convert Message To Hiragana
currentConvertMessageToHiragana,
getConvertMessageToHiragana,
toggleConvertMessageToHiragana,
updateConvertMessageToHiragana,
setSuccessConvertMessageToHiragana,
};
};

View File

@@ -1,488 +0,0 @@
import {
useStore_MicRecordTimeout,
useStore_MicPhraseTimeout,
useStore_MicMaxWords,
useStore_MicWordFilterList,
useStore_SpeakerMaxWords,
useStore_SpeakerPhraseTimeout,
useStore_SpeakerRecordTimeout,
useStore_SelectableTranscriptionComputeDeviceList,
useStore_SelectedTranscriptionEngine,
useStore_SelectedTranscriptionComputeDevice,
useStore_WhisperWeightTypeStatus,
useStore_SelectedWhisperWeightType,
useStore_SelectedTranscriptionComputeType,
useStore_MicAvgLogprob,
useStore_MicNoSpeechProb,
useStore_SpeakerAvgLogprob,
useStore_SpeakerNoSpeechProb,
} from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { transformToIndexedArray, arrayToObject } from "@utils";
import { useNotificationStatus } from "@logics_common";
export const useTranscription = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { showNotification_SaveSuccess } = useNotificationStatus();
// Mic
const { currentMicRecordTimeout, updateMicRecordTimeout, pendingMicRecordTimeout } = useStore_MicRecordTimeout();
const { currentMicPhraseTimeout, updateMicPhraseTimeout, pendingMicPhraseTimeout } = useStore_MicPhraseTimeout();
const { currentMicMaxWords, updateMicMaxWords, pendingMicMaxWords } = useStore_MicMaxWords();
const { currentMicWordFilterList, updateMicWordFilterList, pendingMicWordFilterList } = useStore_MicWordFilterList();
// Speaker
const { currentSpeakerRecordTimeout, updateSpeakerRecordTimeout, pendingSpeakerRecordTimeout } = useStore_SpeakerRecordTimeout();
const { currentSpeakerPhraseTimeout, updateSpeakerPhraseTimeout, pendingSpeakerPhraseTimeout } = useStore_SpeakerPhraseTimeout();
const { currentSpeakerMaxWords, updateSpeakerMaxWords, pendingSpeakerMaxWords } = useStore_SpeakerMaxWords();
// Transcription Engines
const { currentSelectedTranscriptionEngine, updateSelectedTranscriptionEngine, pendingSelectedTranscriptionEngine } = useStore_SelectedTranscriptionEngine();
const { currentWhisperWeightTypeStatus, updateWhisperWeightTypeStatus, pendingWhisperWeightTypeStatus } = useStore_WhisperWeightTypeStatus();
const { currentSelectedWhisperWeightType, updateSelectedWhisperWeightType, pendingSelectedWhisperWeightType } = useStore_SelectedWhisperWeightType();
const { currentSelectedTranscriptionComputeType, updateSelectedTranscriptionComputeType, pendingSelectedTranscriptionComputeType } = useStore_SelectedTranscriptionComputeType();
const { currentSelectableTranscriptionComputeDeviceList, updateSelectableTranscriptionComputeDeviceList, pendingSelectableTranscriptionComputeDeviceList } = useStore_SelectableTranscriptionComputeDeviceList();
const { currentSelectedTranscriptionComputeDevice, updateSelectedTranscriptionComputeDevice, pendingSelectedTranscriptionComputeDevice } = useStore_SelectedTranscriptionComputeDevice();
// Advanced Settings
const { currentMicAvgLogprob, updateMicAvgLogprob, pendingMicAvgLogprob } = useStore_MicAvgLogprob();
const { currentMicNoSpeechProb, updateMicNoSpeechProb, pendingMicNoSpeechProb } = useStore_MicNoSpeechProb();
const { currentSpeakerAvgLogprob, updateSpeakerAvgLogprob, pendingSpeakerAvgLogprob } = useStore_SpeakerAvgLogprob();
const { currentSpeakerNoSpeechProb, updateSpeakerNoSpeechProb, pendingSpeakerNoSpeechProb } = useStore_SpeakerNoSpeechProb();
// Mic
const getMicRecordTimeout = () => {
pendingMicRecordTimeout();
asyncStdoutToPython("/get/data/mic_record_timeout");
};
const setMicRecordTimeout = (selected_mic_record_timeout) => {
pendingMicRecordTimeout();
asyncStdoutToPython("/set/data/mic_record_timeout", selected_mic_record_timeout);
};
const setSuccessMicRecordTimeout = (value) => {
updateMicRecordTimeout(value);
showNotification_SaveSuccess();
};
const getMicPhraseTimeout = () => {
pendingMicPhraseTimeout();
asyncStdoutToPython("/get/data/mic_phrase_timeout");
};
const setMicPhraseTimeout = (selected_mic_phrase_timeout) => {
pendingMicPhraseTimeout();
asyncStdoutToPython("/set/data/mic_phrase_timeout", selected_mic_phrase_timeout);
};
const setSuccessMicPhraseTimeout = (value) => {
updateMicPhraseTimeout(value);
showNotification_SaveSuccess();
};
const getMicMaxWords = () => {
pendingMicMaxWords();
asyncStdoutToPython("/get/data/mic_max_phrases");
};
const setMicMaxWords = (selected_mic_max_phrases) => {
pendingMicMaxWords();
asyncStdoutToPython("/set/data/mic_max_phrases", selected_mic_max_phrases);
};
const setSuccessMicMaxWords = (value) => {
updateMicMaxWords(value);
showNotification_SaveSuccess();
};
const getMicWordFilterList = () => {
pendingMicWordFilterList();
asyncStdoutToPython("/get/data/mic_word_filter");
};
const setMicWordFilterList = (selected_mic_word_filter) => {
pendingMicWordFilterList();
asyncStdoutToPython("/set/data/mic_word_filter", selected_mic_word_filter);
};
const getSuccessMicWordFilterList = (payload) => {
updateMicWordFilterList((prev_list) => {
const updated_list = [...prev_list.data];
for (const value of payload) {
const existing_item = updated_list.find(item => item.value === value);
if (existing_item) {
existing_item.is_redoable = false;
} else {
updated_list.push({ value, is_redoable: false });
}
}
return updated_list;
});
};
const setSuccessMicWordFilterList = (payload) => {
updateMicWordFilterList((prev_list) => {
const updated_list = [...prev_list.data];
for (const value of payload) {
const existing_item = updated_list.find(item => item.value === value);
if (existing_item) {
existing_item.is_redoable = false;
} else {
updated_list.push({ value, is_redoable: false });
}
}
return updated_list;
});
showNotification_SaveSuccess();
};
// Speaker
const getSpeakerRecordTimeout = () => {
pendingSpeakerRecordTimeout();
asyncStdoutToPython("/get/data/speaker_record_timeout");
};
const setSpeakerRecordTimeout = (selected_speaker_record_timeout) => {
pendingSpeakerRecordTimeout();
asyncStdoutToPython("/set/data/speaker_record_timeout", selected_speaker_record_timeout);
};
const setSuccessSpeakerRecordTimeout = (value) => {
updateSpeakerRecordTimeout(value);
showNotification_SaveSuccess();
};
const getSpeakerPhraseTimeout = () => {
pendingSpeakerPhraseTimeout();
asyncStdoutToPython("/get/data/speaker_phrase_timeout");
};
const setSpeakerPhraseTimeout = (selected_speaker_phrase_timeout) => {
pendingSpeakerPhraseTimeout();
asyncStdoutToPython("/set/data/speaker_phrase_timeout", selected_speaker_phrase_timeout);
};
const setSuccessSpeakerPhraseTimeout = (value) => {
updateSpeakerPhraseTimeout(value);
showNotification_SaveSuccess();
};
const getSpeakerMaxWords = () => {
pendingSpeakerMaxWords();
asyncStdoutToPython("/get/data/speaker_max_phrases");
};
const setSpeakerMaxWords = (selected_speaker_max_phrases) => {
pendingSpeakerMaxWords();
asyncStdoutToPython("/set/data/speaker_max_phrases", selected_speaker_max_phrases);
};
const setSuccessSpeakerMaxWords = (value) => {
updateSpeakerMaxWords(value);
showNotification_SaveSuccess();
};
// Transcription Engines
// Transcription Engines (Google / Whisper)
const getSelectedTranscriptionEngine = () => {
pendingSelectedTranscriptionEngine();
asyncStdoutToPython("/get/data/selected_transcription_engine");
};
const setSelectedTranscriptionEngine = (selected_transcription_engine) => {
pendingSelectedTranscriptionEngine();
asyncStdoutToPython("/set/data/selected_transcription_engine", selected_transcription_engine);
};
const setSuccessSelectedTranscriptionEngine = (engine) => {
updateSelectedTranscriptionEngine(engine);
showNotification_SaveSuccess();
};
// Transcription Engines (Weight Type List)
const updateDownloadedWhisperWeightTypeStatus = (downloaded_weight_type_status) => {
updateWhisperWeightTypeStatus((old_status) =>
old_status.data.map((item) => ({
...item,
is_downloaded: downloaded_weight_type_status[item.id] ?? item.is_downloaded,
}))
);
};
const updateDownloadProgressWhisperWeightTypeStatus = (payload) => {
if (payload === true) return console.error("fix me.");
updateWhisperWeightTypeStatus((old_status) =>
old_status.data.map((item) =>
payload.weight_type === item.id
? { ...item, progress: payload.progress * 100 }
: item
)
);
};
const pendingWhisperWeightType = (id) => {
updateWhisperWeightTypeStatus((old_status) =>
old_status.data.map((item) =>
id === item.id
? { ...item, is_pending: true }
: item
)
);
};
const downloadedWhisperWeightType = (id) => {
updateWhisperWeightTypeStatus((old_status) =>
old_status.data.map((item) =>
id === item.id
? { ...item, is_downloaded: true, is_pending: false, progress: null }
: item
)
);
};
const downloadWhisperWeight = (weight_type) => {
asyncStdoutToPython("/run/download_whisper_weight", weight_type);
};
const getSelectedTranscriptionComputeType = () => {
pendingSelectedTranscriptionComputeType();
asyncStdoutToPython("/get/data/selected_transcription_compute_type");
};
const setSelectedTranscriptionComputeType = (selected_transcription_compute_type) => {
pendingSelectedTranscriptionComputeType();
asyncStdoutToPython("/set/data/selected_transcription_compute_type", selected_transcription_compute_type);
};
const setSuccessSelectedTranscriptionComputeType = (selected_transcription_compute_type) => {
updateSelectedTranscriptionComputeType(selected_transcription_compute_type);
showNotification_SaveSuccess();
};
// Transcription Engines (Selected Weight Type)
const getSelectedWhisperWeightType = () => {
pendingSelectedWhisperWeightType();
asyncStdoutToPython("/get/data/whisper_weight_type");
};
const setSelectedWhisperWeightType = (selected_whisper_weight_type) => {
pendingSelectedWhisperWeightType();
asyncStdoutToPython("/set/data/whisper_weight_type", selected_whisper_weight_type);
};
const setSuccessSelectedWhisperWeightType = (wt) => {
updateSelectedWhisperWeightType(wt);
showNotification_SaveSuccess();
};
// Transcription Engines (Compute Device List)
const getSelectableTranscriptionComputeDeviceList = () => {
pendingSelectableTranscriptionComputeDeviceList();
asyncStdoutToPython("/get/data/transcription_compute_device_list");
};
const updateSelectableTranscriptionComputeDeviceList_FromBackend = (payload) => {
updateSelectableTranscriptionComputeDeviceList(transformToIndexedArray(payload));
};
// Transcription Engines (Selected Compute Device)
const getSelectedTranscriptionComputeDevice = () => {
pendingSelectedTranscriptionComputeDevice();
asyncStdoutToPython("/get/data/selected_transcription_compute_device");
};
const setSelectedTranscriptionComputeDevice = (selected_transcription_compute_device) => {
pendingSelectedTranscriptionComputeDevice();
asyncStdoutToPython("/set/data/selected_transcription_compute_device", selected_transcription_compute_device);
};
const setSuccessSelectedTranscriptionComputeDevice = (dev) => {
updateSelectedTranscriptionComputeDevice(dev);
showNotification_SaveSuccess();
};
// Advanced (Mic Avg Logprob)
const getMicAvgLogprob = () => {
pendingMicAvgLogprob();
asyncStdoutToPython("/get/data/mic_avg_logprob");
};
const setMicAvgLogprob = (selected_mic_avg_logprob) => {
pendingMicAvgLogprob();
asyncStdoutToPython("/set/data/mic_avg_logprob", selected_mic_avg_logprob);
};
const setSuccessMicAvgLogprob = (selected_mic_avg_logprob) => {
updateMicAvgLogprob(selected_mic_avg_logprob);
showNotification_SaveSuccess();
};
// Advanced (Mic No Speech Prob)
const getMicNoSpeechProb = () => {
pendingMicNoSpeechProb();
asyncStdoutToPython("/get/data/mic_no_speech_prob");
};
const setMicNoSpeechProb = (selected_mic_no_speech_prob) => {
pendingMicNoSpeechProb();
asyncStdoutToPython("/set/data/mic_no_speech_prob", selected_mic_no_speech_prob);
};
const setSuccessMicNoSpeechProb = (selected_mic_no_speech_prob) => {
updateMicNoSpeechProb(selected_mic_no_speech_prob);
showNotification_SaveSuccess();
};
// Advanced (Speaker Avg Logprob)
const getSpeakerAvgLogprob = () => {
pendingSpeakerAvgLogprob();
asyncStdoutToPython("/get/data/speaker_avg_logprob");
};
const setSpeakerAvgLogprob = (selected_speaker_avg_logprob) => {
pendingSpeakerAvgLogprob();
asyncStdoutToPython("/set/data/speaker_avg_logprob", selected_speaker_avg_logprob);
};
const setSuccessSpeakerAvgLogprob = (selected_speaker_avg_logprob) => {
updateSpeakerAvgLogprob(selected_speaker_avg_logprob);
showNotification_SaveSuccess();
};
// Advanced (Speaker No Speech Prob)
const getSpeakerNoSpeechProb = () => {
pendingSpeakerNoSpeechProb();
asyncStdoutToPython("/get/data/speaker_no_speech_prob");
};
const setSpeakerNoSpeechProb = (selected_speaker_no_speech_prob) => {
pendingSpeakerNoSpeechProb();
asyncStdoutToPython("/set/data/speaker_no_speech_prob", selected_speaker_no_speech_prob);
};
const setSuccessSpeakerNoSpeechProb = (selected_speaker_no_speech_prob) => {
updateSpeakerNoSpeechProb(selected_speaker_no_speech_prob);
showNotification_SaveSuccess();
};
return {
// Mic
currentMicRecordTimeout,
getMicRecordTimeout,
updateMicRecordTimeout,
setMicRecordTimeout,
setSuccessMicRecordTimeout,
currentMicPhraseTimeout,
getMicPhraseTimeout,
updateMicPhraseTimeout,
setMicPhraseTimeout,
setSuccessMicPhraseTimeout,
currentMicMaxWords,
getMicMaxWords,
updateMicMaxWords,
setMicMaxWords,
setSuccessMicMaxWords,
currentMicWordFilterList,
getMicWordFilterList,
getSuccessMicWordFilterList,
updateMicWordFilterList,
setMicWordFilterList,
setSuccessMicWordFilterList,
// Speaker
currentSpeakerRecordTimeout,
getSpeakerRecordTimeout,
updateSpeakerRecordTimeout,
setSpeakerRecordTimeout,
setSuccessSpeakerRecordTimeout,
currentSpeakerPhraseTimeout,
getSpeakerPhraseTimeout,
updateSpeakerPhraseTimeout,
setSpeakerPhraseTimeout,
setSuccessSpeakerPhraseTimeout,
currentSpeakerMaxWords,
getSpeakerMaxWords,
updateSpeakerMaxWords,
setSpeakerMaxWords,
setSuccessSpeakerMaxWords,
// Transcription Engines
currentSelectedTranscriptionEngine,
getSelectedTranscriptionEngine,
updateSelectedTranscriptionEngine,
setSelectedTranscriptionEngine,
setSuccessSelectedTranscriptionEngine,
currentWhisperWeightTypeStatus,
updateWhisperWeightTypeStatus,
updateDownloadedWhisperWeightTypeStatus,
updateDownloadProgressWhisperWeightTypeStatus,
pendingWhisperWeightType,
downloadedWhisperWeightType,
downloadWhisperWeight,
currentSelectedWhisperWeightType,
getSelectedWhisperWeightType,
updateSelectedWhisperWeightType,
setSelectedWhisperWeightType,
setSuccessSelectedWhisperWeightType,
currentSelectedTranscriptionComputeType,
getSelectedTranscriptionComputeType,
updateSelectedTranscriptionComputeType,
setSelectedTranscriptionComputeType,
setSuccessSelectedTranscriptionComputeType,
currentSelectableTranscriptionComputeDeviceList,
getSelectableTranscriptionComputeDeviceList,
updateSelectableTranscriptionComputeDeviceList,
updateSelectableTranscriptionComputeDeviceList_FromBackend,
currentSelectedTranscriptionComputeDevice,
getSelectedTranscriptionComputeDevice,
updateSelectedTranscriptionComputeDevice,
setSelectedTranscriptionComputeDevice,
setSuccessSelectedTranscriptionComputeDevice,
// Advanced
// Mic Avg Logprob
currentMicAvgLogprob,
getMicAvgLogprob,
updateMicAvgLogprob,
setMicAvgLogprob,
setSuccessMicAvgLogprob,
// Mic No Speech Prob
currentMicNoSpeechProb,
getMicNoSpeechProb,
updateMicNoSpeechProb,
setMicNoSpeechProb,
setSuccessMicNoSpeechProb,
// Speaker Avg Logprob
currentSpeakerAvgLogprob,
getSpeakerAvgLogprob,
updateSpeakerAvgLogprob,
setSpeakerAvgLogprob,
setSuccessSpeakerAvgLogprob,
// Speaker No Speech Prob
currentSpeakerNoSpeechProb,
getSpeakerNoSpeechProb,
updateSpeakerNoSpeechProb,
setSpeakerNoSpeechProb,
setSuccessSpeakerNoSpeechProb,
};
};

View File

@@ -1,198 +0,0 @@
import {
useStore_CTranslate2WeightTypeStatus,
useStore_SelectedCTranslate2WeightType,
useStore_SelectedTranslationComputeType,
useStore_SelectableTranslationComputeDeviceList,
useStore_SelectedTranslationComputeDevice,
useStore_DeepLAuthKey,
} from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { useI18n } from "@useI18n";
import { transformToIndexedArray, arrayToObject } from "@utils";
import { useNotificationStatus } from "@logics_common";
export const useTranslation = () => {
const { t } = useI18n();
const { asyncStdoutToPython } = useStdoutToPython();
const { showNotification_SaveSuccess } = useNotificationStatus();
const { currentCTranslate2WeightTypeStatus, updateCTranslate2WeightTypeStatus, pendingCTranslate2WeightTypeStatus } = useStore_CTranslate2WeightTypeStatus();
const { currentSelectedCTranslate2WeightType, updateSelectedCTranslate2WeightType, pendingSelectedCTranslate2WeightType } = useStore_SelectedCTranslate2WeightType();
const { currentSelectedTranslationComputeType, updateSelectedTranslationComputeType, pendingSelectedTranslationComputeType } = useStore_SelectedTranslationComputeType();
const { currentSelectableTranslationComputeDeviceList, updateSelectableTranslationComputeDeviceList, pendingSelectableTranslationComputeDeviceList } = useStore_SelectableTranslationComputeDeviceList();
const { currentSelectedTranslationComputeDevice, updateSelectedTranslationComputeDevice, pendingSelectedTranslationComputeDevice } = useStore_SelectedTranslationComputeDevice();
const { currentDeepLAuthKey, updateDeepLAuthKey, pendingDeepLAuthKey } = useStore_DeepLAuthKey();
const updateDownloadedCTranslate2WeightTypeStatus = (downloaded_weight_type_status) => {
updateCTranslate2WeightTypeStatus((old_status) =>
old_status.data.map((item) => ({
...item,
is_downloaded: downloaded_weight_type_status[item.id] ?? item.is_downloaded,
}))
);
};
const updateDownloadProgressCTranslate2WeightTypeStatus = (payload) => {
if (payload === true) return console.error("fix me.");
updateCTranslate2WeightTypeStatus((old_status) =>
old_status.data.map((item) =>
payload.weight_type === item.id
? { ...item, progress: payload.progress * 100 }
: item
)
);
};
const pendingCTranslate2WeightType = (id) => {
updateCTranslate2WeightTypeStatus((old_status) =>
old_status.data.map((item) =>
id === item.id
? { ...item, is_pending: true }
: item
)
);
};
const downloadedCTranslate2WeightType = (id) => {
updateCTranslate2WeightTypeStatus((old_status) =>
old_status.data.map((item) =>
id === item.id
? { ...item, is_downloaded: true, is_pending: false, progress: null }
: item
)
);
};
const downloadCTranslate2Weight = (weight_type) => {
asyncStdoutToPython("/run/download_ctranslate2_weight", weight_type);
};
const getSelectedCTranslate2WeightType = () => {
pendingSelectedCTranslate2WeightType();
asyncStdoutToPython("/get/data/ctranslate2_weight_type");
};
const setSelectedCTranslate2WeightType = (selected_ctranslate2_weight_type) => {
pendingSelectedCTranslate2WeightType();
asyncStdoutToPython("/set/data/ctranslate2_weight_type", selected_ctranslate2_weight_type);
};
const setSuccessSelectedCTranslate2WeightType = (selected_ctranslate2_weight_type) => {
updateSelectedCTranslate2WeightType(selected_ctranslate2_weight_type);
showNotification_SaveSuccess();
};
const getSelectedTranslationComputeType = () => {
pendingSelectedTranslationComputeType();
asyncStdoutToPython("/get/data/selected_translation_compute_type");
};
const setSelectedTranslationComputeType = (selected_translation_compute_type) => {
pendingSelectedTranslationComputeType();
asyncStdoutToPython("/set/data/selected_translation_compute_type", selected_translation_compute_type);
};
const setSuccessSelectedTranslationComputeType = (selected_translation_compute_type) => {
updateSelectedTranslationComputeType(selected_translation_compute_type);
showNotification_SaveSuccess();
};
const getSelectableTranslationComputeDeviceList = () => {
pendingSelectableTranslationComputeDeviceList();
asyncStdoutToPython("/get/data/translation_compute_device_list");
};
const updateSelectableTranslationComputeDeviceList_FromBackend = (payload) => {
updateSelectableTranslationComputeDeviceList(transformToIndexedArray(payload));
};
const getSelectedTranslationComputeDevice = () => {
pendingSelectedTranslationComputeDevice();
asyncStdoutToPython("/get/data/selected_translation_compute_device");
};
const setSelectedTranslationComputeDevice = (selected_translation_compute_device) => {
pendingSelectedTranslationComputeDevice();
asyncStdoutToPython("/set/data/selected_translation_compute_device", selected_translation_compute_device);
};
const setSuccessSelectedTranslationComputeDevice = (selected_translation_compute_device) => {
updateSelectedTranslationComputeDevice(selected_translation_compute_device);
showNotification_SaveSuccess();
};
const getDeepLAuthKey = () => {
pendingDeepLAuthKey();
asyncStdoutToPython("/get/data/deepl_auth_key");
};
const setDeepLAuthKey = (selected_deepl_auth_key) => {
pendingDeepLAuthKey();
asyncStdoutToPython("/set/data/deepl_auth_key", selected_deepl_auth_key);
};
const setSuccessDeepLAuthKey = (data) => {
updateDeepLAuthKey(data);
showNotification_SaveSuccess(t("config_page.translation.deepl_auth_key.auth_key_success"), { category_id: "deepl_auth_key" });
};
const deleteDeepLAuthKey = () => {
pendingDeepLAuthKey();
asyncStdoutToPython("/delete/data/deepl_auth_key");
};
const deleteSuccessDeepLAuthKey = () => {
updateDeepLAuthKey("");
};
return {
currentCTranslate2WeightTypeStatus,
updateCTranslate2WeightTypeStatus,
updateDownloadedCTranslate2WeightTypeStatus,
updateDownloadProgressCTranslate2WeightTypeStatus,
pendingCTranslate2WeightType,
downloadedCTranslate2WeightType,
downloadCTranslate2Weight,
currentSelectedCTranslate2WeightType,
getSelectedCTranslate2WeightType,
updateSelectedCTranslate2WeightType,
setSelectedCTranslate2WeightType,
setSuccessSelectedCTranslate2WeightType,
currentSelectedTranslationComputeType,
getSelectedTranslationComputeType,
updateSelectedTranslationComputeType,
setSelectedTranslationComputeType,
setSuccessSelectedTranslationComputeType,
currentSelectableTranslationComputeDeviceList,
getSelectableTranslationComputeDeviceList,
updateSelectableTranslationComputeDeviceList,
updateSelectableTranslationComputeDeviceList_FromBackend,
currentSelectedTranslationComputeDevice,
getSelectedTranslationComputeDevice,
updateSelectedTranslationComputeDevice,
setSelectedTranslationComputeDevice,
setSuccessSelectedTranslationComputeDevice,
currentDeepLAuthKey,
getDeepLAuthKey,
updateDeepLAuthKey,
setDeepLAuthKey,
deleteDeepLAuthKey,
deleteSuccessDeepLAuthKey,
setSuccessDeepLAuthKey,
};
};

View File

@@ -1,145 +0,0 @@
import {
useStore_IsEnabledOverlaySmallLog,
useStore_IsEnabledOverlayLargeLog,
useStore_OverlaySmallLogSettings,
useStore_OverlayLargeLogSettings,
useStore_OverlayShowOnlyTranslatedMessages,
} from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { useNotificationStatus } from "@logics_common";
export const useVr = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { showNotification_SaveSuccess } = useNotificationStatus();
const { currentIsEnabledOverlaySmallLog, updateIsEnabledOverlaySmallLog, pendingIsEnabledOverlaySmallLog } = useStore_IsEnabledOverlaySmallLog();
const { currentIsEnabledOverlayLargeLog, updateIsEnabledOverlayLargeLog, pendingIsEnabledOverlayLargeLog } = useStore_IsEnabledOverlayLargeLog();
const { currentOverlaySmallLogSettings, updateOverlaySmallLogSettings, pendingOverlaySmallLogSettings } = useStore_OverlaySmallLogSettings();
const { currentOverlayLargeLogSettings, updateOverlayLargeLogSettings, pendingOverlayLargeLogSettings } = useStore_OverlayLargeLogSettings();
const { currentOverlayShowOnlyTranslatedMessages, updateOverlayShowOnlyTranslatedMessages, pendingOverlayShowOnlyTranslatedMessages } = useStore_OverlayShowOnlyTranslatedMessages();
const getIsEnabledOverlaySmallLog = () => {
pendingIsEnabledOverlaySmallLog();
asyncStdoutToPython("/get/data/overlay_small_log");
};
const toggleIsEnabledOverlaySmallLog = () => {
pendingIsEnabledOverlaySmallLog();
if (currentIsEnabledOverlaySmallLog.data) {
asyncStdoutToPython("/set/disable/overlay_small_log");
} else {
asyncStdoutToPython("/set/enable/overlay_small_log");
}
};
const setSuccessIsEnabledOverlaySmallLog = (enabled) => {
updateIsEnabledOverlaySmallLog(enabled);
showNotification_SaveSuccess();
};
const getIsEnabledOverlayLargeLog = () => {
pendingIsEnabledOverlayLargeLog();
asyncStdoutToPython("/get/data/overlay_large_log");
};
const toggleIsEnabledOverlayLargeLog = () => {
pendingIsEnabledOverlayLargeLog();
if (currentIsEnabledOverlayLargeLog.data) {
asyncStdoutToPython("/set/disable/overlay_large_log");
} else {
asyncStdoutToPython("/set/enable/overlay_large_log");
}
};
const setSuccessIsEnabledOverlayLargeLog = (enabled) => {
updateIsEnabledOverlayLargeLog(enabled);
showNotification_SaveSuccess();
};
const getOverlaySmallLogSettings = () => {
// pendingOverlaySmallLogSettings();
asyncStdoutToPython("/get/data/overlay_small_log_settings");
};
const setOverlaySmallLogSettings = (overlay_small_log_settings) => {
// pendingOverlaySmallLogSettings();
asyncStdoutToPython("/set/data/overlay_small_log_settings", overlay_small_log_settings);
};
const setSuccessOverlaySmallLogSettings = (settings) => {
updateOverlaySmallLogSettings(settings);
showNotification_SaveSuccess();
};
const getOverlayLargeLogSettings = () => {
// pendingOverlayLargeLogSettings();
asyncStdoutToPython("/get/data/overlay_large_log_settings");
};
const setOverlayLargeLogSettings = (overlay_large_log_settings) => {
// pendingOverlayLargeLogSettings();
asyncStdoutToPython("/set/data/overlay_large_log_settings", overlay_large_log_settings);
};
const setSuccessOverlayLargeLogSettings = (settings) => {
updateOverlayLargeLogSettings(settings);
showNotification_SaveSuccess();
};
const getOverlayShowOnlyTranslatedMessages = () => {
pendingOverlayShowOnlyTranslatedMessages();
asyncStdoutToPython("/get/data/overlay_show_only_translated_messages");
};
const toggleOverlayShowOnlyTranslatedMessages = () => {
pendingOverlayShowOnlyTranslatedMessages();
if (currentOverlayShowOnlyTranslatedMessages.data) {
asyncStdoutToPython("/set/disable/overlay_show_only_translated_messages");
} else {
asyncStdoutToPython("/set/enable/overlay_show_only_translated_messages");
}
};
const setSuccessOverlayShowOnlyTranslatedMessages = (enabled) => {
updateOverlayShowOnlyTranslatedMessages(enabled);
showNotification_SaveSuccess();
};
const sendTextToOverlay = (text) => {
asyncStdoutToPython("/run/send_text_overlay", text);
};
return {
currentIsEnabledOverlaySmallLog,
getIsEnabledOverlaySmallLog,
toggleIsEnabledOverlaySmallLog,
updateIsEnabledOverlaySmallLog,
setSuccessIsEnabledOverlaySmallLog,
currentIsEnabledOverlayLargeLog,
getIsEnabledOverlayLargeLog,
toggleIsEnabledOverlayLargeLog,
updateIsEnabledOverlayLargeLog,
setSuccessIsEnabledOverlayLargeLog,
currentOverlaySmallLogSettings,
getOverlaySmallLogSettings,
updateOverlaySmallLogSettings,
setOverlaySmallLogSettings,
setSuccessOverlaySmallLogSettings,
currentOverlayLargeLogSettings,
getOverlayLargeLogSettings,
updateOverlayLargeLogSettings,
setOverlayLargeLogSettings,
setSuccessOverlayLargeLogSettings,
currentOverlayShowOnlyTranslatedMessages,
getOverlayShowOnlyTranslatedMessages,
toggleOverlayShowOnlyTranslatedMessages,
updateOverlayShowOnlyTranslatedMessages,
setSuccessOverlayShowOnlyTranslatedMessages,
sendTextToOverlay,
};
};

View File

@@ -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" },
@@ -91,222 +92,7 @@ export const ROUTE_META_LIST = [
{ endpoint: "/set/data/message_box_ratio", ns: main, hook_name: "useMessageInputBoxRatio", method_name: "updateMessageInputBoxRatio" },
// Config Page
// Device
{ endpoint: "/get/data/auto_mic_select", ns: configs, hook_name: "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" },
{ 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/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" },
// 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" },
// 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" },
// 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/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/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/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 (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/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/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" },
{ 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_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" },
{ 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" },
// 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: "/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: "/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" },
// VR
{ endpoint: "/get/data/overlay_small_log", ns: configs, hook_name: "useVr", method_name: "updateIsEnabledOverlaySmallLog" },
{ endpoint: "/set/enable/overlay_small_log", ns: configs, hook_name: "useVr", method_name: "setSuccessIsEnabledOverlaySmallLog" },
{ endpoint: "/set/disable/overlay_small_log", ns: configs, hook_name: "useVr", method_name: "setSuccessIsEnabledOverlaySmallLog" },
{ endpoint: "/get/data/overlay_small_log_settings", ns: configs, hook_name: "useVr", method_name: "updateOverlaySmallLogSettings" },
{ endpoint: "/set/data/overlay_small_log_settings", ns: configs, hook_name: "useVr", method_name: "setSuccessOverlaySmallLogSettings" },
{ endpoint: "/get/data/overlay_large_log", ns: configs, hook_name: "useVr", method_name: "updateIsEnabledOverlayLargeLog" },
{ endpoint: "/set/enable/overlay_large_log", ns: configs, hook_name: "useVr", method_name: "setSuccessIsEnabledOverlayLargeLog" },
{ endpoint: "/set/disable/overlay_large_log", ns: configs, hook_name: "useVr", method_name: "setSuccessIsEnabledOverlayLargeLog" },
{ endpoint: "/get/data/overlay_large_log_settings", ns: configs, hook_name: "useVr", method_name: "updateOverlayLargeLogSettings" },
{ endpoint: "/set/data/overlay_large_log_settings", ns: configs, hook_name: "useVr", method_name: "setSuccessOverlayLargeLogSettings" },
{ endpoint: "/get/data/overlay_show_only_translated_messages", ns: configs, hook_name: "useVr", method_name: "updateOverlayShowOnlyTranslatedMessages" },
{ endpoint: "/set/enable/overlay_show_only_translated_messages", ns: configs, hook_name: "useVr", method_name: "setSuccessOverlayShowOnlyTranslatedMessages" },
{ endpoint: "/set/disable/overlay_show_only_translated_messages", ns: configs, hook_name: "useVr", method_name: "setSuccessOverlayShowOnlyTranslatedMessages" },
{ 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" },
{ 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/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_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/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_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" },
// // Config Page
// Hotkeys
{ endpoint: "/get/data/hotkeys", ns: configs, hook_name: "useHotkeys", method_name: "updateHotkeys" },
{ endpoint: "/set/data/hotkeys", ns: configs, hook_name: "useHotkeys", method_name: "setSuccessHotkeys" },
@@ -315,29 +101,7 @@ 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" },
{ 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_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" },
// 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 +110,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 +119,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 +136,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 +158,6 @@ export const useReceiveRoutes = () => {
return;
}
switch (status) {
case 200:
if (endpoint in routes) {
@@ -424,4 +195,168 @@ export const useReceiveRoutes = () => {
const style_348 = [
"color: gray",
].join(";");
].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;
};

View File

@@ -10,8 +10,6 @@ import {
import {
translator_status,
ctranslate2_weight_type_status,
whisper_weight_type_status,
} from "@ui_configs";
export const store = {
@@ -33,6 +31,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 +108,41 @@ export const createAtomWithHook = (initialValue, base_name, options) => {
};
};
try {
const hookName = `useStore_${base_name}`;
const atomName = `Atom_${base_name}`;
dynamicStoreRegistry[hookName] = useHook;
dynamicStoreRegistry[atomName] = atomInstance;
} catch (e) {
console.warn("dynamic registration failed for", base_name, e);
}
return { atomInstance, useHook };
};
export const getStoreHook = (baseName) => {
const hookName = `useStore_${baseName}`;
return dynamicStoreRegistry[hookName];
};
export const registerMany = (settingsArray = []) => {
for (const s of settingsArray) {
try {
const hookName = `useStore_${s.Base_Name}`;
if (dynamicStoreRegistry[hookName]) {
continue;
}
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,143 +208,21 @@ 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_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_MicVolume, useHook: useStore_MicVolume } = createAtomWithHook(0, "MicVolume");
export const { atomInstance: Atom_SpeakerVolume, useHook: useStore_SpeakerVolume } = createAtomWithHook(0, "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_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_SelectableFontFamilyList, useHook: useStore_SelectableFontFamilyList } = createAtomWithHook({}, "SelectableFontFamilyList");
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");
// 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_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_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_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");
// VR
export const { atomInstance: Atom_OverlaySmallLogSettings, useHook: useStore_OverlaySmallLogSettings } = createAtomWithHook({
x_pos: 0.0,
y_pos: 0.0,
z_pos: 0.0,
x_rotation: 0.0,
y_rotation: 0.0,
z_rotation: 0.0,
display_duration: 5,
fadeout_duration: 2,
tracker: "HMD",
}, "OverlaySmallLogSettings");
export const { atomInstance: Atom_IsEnabledOverlaySmallLog, useHook: useStore_IsEnabledOverlaySmallLog } = createAtomWithHook(false, "IsEnabledOverlaySmallLog");
export const { atomInstance: Atom_OverlayLargeLogSettings, useHook: useStore_OverlayLargeLogSettings } = createAtomWithHook({
x_pos: 0.0,
y_pos: 0.0,
z_pos: 0.0,
x_rotation: 0.0,
y_rotation: 0.0,
z_rotation: 0.0,
display_duration: 5,
fadeout_duration: 2,
tracker: "HMD",
}, "OverlayLargeLogSettings");
export const { atomInstance: Atom_IsEnabledOverlayLargeLog, useHook: useStore_IsEnabledOverlayLargeLog } = createAtomWithHook(false, "IsEnabledOverlayLargeLog");
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");
// Hotkeys
@@ -331,16 +239,6 @@ export const { atomInstance: Atom_LoadedPlugins, useHook: useStore_LoadedPlugins
export const { atomInstance: Atom_SavedPluginsStatus, useHook: useStore_SavedPluginsStatus } = createAtomWithHook([], "SavedPluginsStatus");
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_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");
// Supporters
export const { atomInstance: Atom_SupportersData, useHook: useStore_SupportersData } = createAtomWithHook(null, "SupportersData", {is_state_ok: true});

634
src-ui/ui_config_setter.js Normal file
View File

@@ -0,0 +1,634 @@
import { createAtomWithHook } from "@store";
import {
ctranslate2_weight_type_status,
whisper_weight_type_status,
ui_configs,
} from "@ui_configs";
import {
useSettingsLogics,
useConfigFunctions,
} 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: "OverlaySmallLogSettings",
default_value: ui_configs.overlay_small_log_default_settings,
ui_template_id: "object",
logics_template_id: "get_set",
base_endpoint_name: "overlay_small_log_settings",
},
{
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: "OverlayLargeLogSettings",
default_value: ui_configs.overlay_large_log_default_settings,
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: "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",
},
// 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, extraFunctions = {}) => {
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, ...extraFunctions };
};
const createCategoryHook = (Category) => {
return () => {
const { settings } = useSettingsLogics(SETTINGS_ARRAY, Category);
const extraFunctions = useConfigFunctions(Category);
const autoApi = buildCategoryApiFromSettings(settings, SETTINGS_ARRAY, Category, extraFunctions);
return { ...autoApi };
};
};
// --- 自動エクスポート: SETTINGS_ARRAY に含まれるユニークな Category ごとに use<Category> を作って 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 */

View File

@@ -110,21 +110,23 @@ export const translator_status = [
];
export const ctranslate2_weight_type_status = [
{ id: "small", label: "small", is_downloaded: false, progress: null },
{ id: "large", label: "large", is_downloaded: false, progress: null },
];
{ id: "m2m100_418M-ct2-int8", capacity: "418MB"},
{ id: "m2m100_1.2B-ct2-int8", capacity: "1.2GB"},
{ id: "nllb-200-distilled-1.3B-ct2-int8", capacity: "1.3GB"},
{ id: "nllb-200-3.3B-ct2-int8", capacity: "3.3GB"},
].map(item => ({ ...item, is_downloaded: false, progress: null }));
export const whisper_weight_type_status = [
{ id: "tiny", label: "tiny", is_downloaded: false, progress: null },
{ id: "base", label: "base", is_downloaded: false, progress: null },
{ id: "small", label: "small", is_downloaded: false, progress: null },
{ id: "medium", label: "medium", is_downloaded: false, progress: null },
{ id: "large-v1", label: "large-v1", is_downloaded: false, progress: null },
{ id: "large-v2", label: "large-v2", is_downloaded: false, progress: null },
{ id: "large-v3", label: "large-v3", is_downloaded: false, progress: null },
{ id: "large-v3-turbo-int8", label: "large-v3-turbo-int8", is_downloaded: false, progress: null },
{ id: "large-v3-turbo", label: "large-v3-turbo", is_downloaded: false, progress: null },
];
{ id: "tiny", capacity: "74.5MB"},
{ id: "base", capacity: "141MB"},
{ id: "small", capacity: "463MB"},
{ id: "medium", capacity: "1.42GB"},
{ id: "large-v1", capacity: "2.87GB"},
{ id: "large-v2", capacity: "2.87GB"},
{ id: "large-v3", capacity: "2.87GB"},
{ id: "large-v3-turbo-int8", capacity: "794MB"},
{ id: "large-v3-turbo", capacity: "1.58GB"},
].map(item => ({ ...item, is_downloaded: false, progress: null }));
export const supporters_data_url = "https://shiinasakamoto.github.io/vrct_supporters/assets/supporters/data.json";
export const supporters_images_url = "https://ShiinaSakamoto.github.io/vrct_supporters/assets/supporters";

203
src-ui/useSettingsLogics.js Normal file
View File

@@ -0,0 +1,203 @@
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 };
};
export const useConfigFunctions = (Category) => {
const { asyncStdoutToPython } = useStdoutToPython();
switch (Category) {
case "Vr":
return {
sendTextToOverlay: (text) => {
asyncStdoutToPython("/run/send_text_overlay", text);
},
};
default:
return {};
}
};