[Refactor] Change aliases and move test_data.js.

This commit is contained in:
Sakamoto Shiina
2025-06-11 18:34:13 +09:00
parent f229d9ec95
commit 1fcb765ca0
69 changed files with 108 additions and 106 deletions

View File

@@ -1,11 +1,16 @@
import { invoke } from "@tauri-apps/api/core";
import { Command } from "@tauri-apps/plugin-shell";
import { useEffect, useRef } from "react";
import { useStartPython } from "@logics/useStartPython";
import { useStdoutToPython } from "@logics/useStdoutToPython";
import { useStore_SelectableFontFamilyList } from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { useReceiveRoutes } from "@useReceiveRoutes";
import { store, useStore_SelectableFontFamilyList } from "@store";
import { arrayToObject } from "@utils";
import {
useNotificationStatus,
} from "@logics_common";
export const StartPythonController = () => {
const { asyncStartPython } = useStartPython();
const hasRunRef = useRef(false);
@@ -26,6 +31,34 @@ export const StartPythonController = () => {
return null;
};
const useStartPython = () => {
const { receiveRoutes } = useReceiveRoutes();
const { showNotification_Success, showNotification_Error } = useNotificationStatus();
const asyncStartPython = async () => {
const command = Command.sidecar("bin/VRCT-sidecar");
command.on("error", error => console.error(`error: "${error}"`));
command.stdout.on("data", (line) => {
let parsed_data = "";
try {
parsed_data = JSON.parse(line);
receiveRoutes(parsed_data);
} catch (error) {
console.log(error, line);
}
});
command.stderr.on("data", line => {
showNotification_Error(
`An error occurred. Please restart VRCT or contact the developers. The last line:${JSON.stringify(line)}`, { hide_duration: null });
console.error("stderr", line);
});
const backend_subprocess = await command.spawn();
store.backend_subprocess = backend_subprocess;
};
return { asyncStartPython };
};
const useAsyncFetchFonts = () => {
const { updateSelectableFontFamilyList } = useStore_SelectableFontFamilyList();
const asyncFetchFonts = async () => {