Skip to content

Commit

Permalink
Merge branch 'main' into change-hotkey
Browse files Browse the repository at this point in the history
  • Loading branch information
tsym77yoshi authored May 26, 2024
2 parents f9fc14c + bba1060 commit 9f431ef
Show file tree
Hide file tree
Showing 53 changed files with 3,580 additions and 1,087 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = {
},
],
"@typescript-eslint/no-unused-vars": [
"warn",
process.env.NODE_ENV === "development" ? "warn" : "error", // 開発時のみwarn
{
ignoreRestSiblings: true,
},
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ npm run license:generate -- -o voicevox_licenses.json
npm run license:merge -- -o public/licenses.json -i engine_licenses.json -i voicevox_licenses.json
```

## リント(静的解析)

コードの静的解析を行い、バグを未然に防ぎます。プルリクエストを送る前に実行してください。

```bash
npm run lint
```

## コードフォーマット

コードのフォーマットを整えます。プルリクエストを送る前に実行してください。
Expand Down
2 changes: 1 addition & 1 deletion _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ ba = "ba" # 7zコマンドの-baオプション
commitish = "commitish" # softprops/action-gh-releaseのオプションの1つ

[files]
extend-exclude = ["package-lock.json", "src/store/project.ts", "*.svg"]
extend-exclude = ["package-lock.json", "src/domain/project/index.ts", "*.svg"]
9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"buffer": "6.0.3",
"clone-deep": "4.0.1",
"dayjs": "1.10.7",
"electron-log": "5.0.0",
"electron-log": "5.1.2",
"electron-window-state": "5.0.3",
"encoding-japanese": "1.0.30",
"fast-array-diff": "1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion public/qAndA.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Windows/Mac/Linux 搭載の PC に対応しています。

※Windows:Windows 10・Windows 11
※Mac:macOS Catalina 以降
※Mac:macOS 12(Monterey)以降
※Linux:Ubuntu 20.04

#### GPU 版
Expand Down
13 changes: 13 additions & 0 deletions src/@types/immer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// immerの内部APIの型定義。exportsで指定されていないファイルを参照するために用意したもの。
declare module "immer/src/plugins/patches" {
export function enablePatches(): void;
}
declare module "immer/src/plugins/mapset" {
export function enableMapSet(): void;
}
declare module "immer/src/utils/plugins" {
import { Patch } from "immer";
export function getPlugin(name: "Patches"): {
applyPatches_: (state: unknown, patches: Patch[]) => void;
};
}
8 changes: 8 additions & 0 deletions src/@types/vuex.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// vuexのexportsにtypeがないのを回避するWorkaround。
// https://github.com/vuejs/vuex/issues/2213#issuecomment-1592267216
declare module "vuex" {
export * from "vuex/types/index.d.ts";
export * from "vuex/types/helpers.d.ts";
export * from "vuex/types/logger.d.ts";
export * from "vuex/types/vue.d.ts";
}
15 changes: 15 additions & 0 deletions src/backend/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,21 @@ let win: BrowserWindow;

process.on("uncaughtException", (error) => {
log.error(error);

if (isDevelopment) {
app.exit(1);
} else {
const { message, name } = error;
let detailedMessage = "";
detailedMessage += `メインプロセスで原因不明のエラーが発生しました。\n`;
detailedMessage += `エラー名: ${name}\n`;
detailedMessage += `メッセージ: ${message}\n`;
if (error.stack) {
detailedMessage += `スタックトレース: \n${error.stack}`;
}

dialog.showErrorBox("エラー", detailedMessage);
}
});
process.on("unhandledRejection", (reason) => {
log.error(reason);
Expand Down
25 changes: 16 additions & 9 deletions src/backend/electron/manager/engineManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,17 @@ export class EngineManager {
return undefined;
}

return new Promise<void>((resolve, reject) => {
log.info(
`ENGINE ${engineId}: Killing process (PID=${engineProcess.pid})`,
const enginePid = engineProcess.pid;
if (enginePid == undefined) {
// エンジン起動済みの場合来ないはず
// 万が一の場合はエンジン停止済みとみなす
log.error(
`ENGINE ${engineId}: Process PID is undefined, assuming closed`,
);
return undefined;
}
return new Promise<void>((resolve, reject) => {
log.info(`ENGINE ${engineId}: Killing process (PID=${enginePid})`);

// エラーダイアログを抑制
engineProcessContainer.willQuitEngine = true;
Expand All @@ -434,12 +441,12 @@ export class EngineManager {
resolve();
});

try {
engineProcess.pid != undefined && treeKill(engineProcess.pid);
} catch (error: unknown) {
log.error(`ENGINE ${engineId}: Error during killing process`);
reject(error);
}
treeKill(enginePid, (error) => {
if (error != undefined) {
log.error(`ENGINE ${engineId}: Error during killing process`);
reject(error);
}
});
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/CharacterButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
<script setup lang="ts">
import { debounce, QBtn } from "quasar";
import { computed, Ref, ref } from "vue";
import { base64ImageToUri } from "@/helpers/imageHelper";
import { base64ImageToUri } from "@/helpers/base64Helper";
import { useStore } from "@/store";
import { CharacterInfo, SpeakerId, Voice } from "@/type/preload";
import { formatCharacterStyleName } from "@/store/utility";
Expand Down
1 change: 0 additions & 1 deletion src/components/Dialog/AllDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ const isCharacterOrderDialogOpenComputed = computed({
}),
});
// TODO: デフォルトスタイル選択(ソング)の実装
// デフォルトスタイル選択(トーク)
const orderedTalkCharacterInfos = computed(() => {
return filterCharacterInfosByStyleType(
Expand Down
74 changes: 45 additions & 29 deletions src/components/Dialog/DictionaryManageDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,12 @@
@click="discardOrNotDialog(cancel)"
/>
<div class="word-list-header text-no-wrap">
<div class="row word-list-title text-h5">単語一覧</div>
<div class="row no-wrap">
<QBtn
outline
text-color="warning"
class="text-no-wrap text-bold col-sm q-ma-sm"
:disable="uiLocked || !isDeletable"
@click="deleteWord"
>削除</QBtn
>
<QBtn
outline
text-color="display"
class="text-no-wrap text-bold col-sm q-ma-sm"
:disable="uiLocked || !selectedId"
@click="editWord"
>編集</QBtn
>
<div class="row word-list-title">
<span class="text-h5 col-8">単語一覧</span>
<QBtn
outline
text-color="display"
class="text-no-wrap text-bold col-sm q-ma-sm"
class="text-no-wrap text-bold col"
:disable="uiLocked"
@click="newWord"
>追加</QBtn
Expand All @@ -85,12 +69,42 @@
active-class="active-word"
@click="selectWord(key)"
@dblclick="editWord"
@mouseover="hoveredKey = key"
@mouseleave="hoveredKey = undefined"
>
<QItemSection>
<QItemLabel class="text-display">{{
<QItemLabel lines="1" class="text-display">{{
value.surface
}}</QItemLabel>
<QItemLabel caption>{{ value.yomi }}</QItemLabel>
<QItemLabel lines="1" caption>{{ value.yomi }}</QItemLabel>
</QItemSection>

<QItemSection
v-if="!uiLocked && (hoveredKey === key || selectedId === key)"
side
>
<div class="q-gutter-xs">
<QBtn
size="12px"
flat
dense
round
icon="edit"
@click.stop="editWord"
>
<QTooltip :delay="500">編集</QTooltip>
</QBtn>
<QBtn
size="12px"
flat
dense
round
icon="delete_outline"
@click.stop="deleteWord"
>
<QTooltip :delay="500">削除</QTooltip>
</QBtn>
</div>
</QItemSection>
</QItem>
</QList>
Expand Down Expand Up @@ -259,7 +273,7 @@ import {
convertHiraToKana,
convertLongVowel,
createKanaRegex,
} from "@/store/utility";
} from "@/domain/japanese";
const defaultDictPriority = 5;
Expand All @@ -280,6 +294,9 @@ const uiLocked = ref(false); // ダイアログ内でstore.getters.UI_LOCKEDは
const nowGenerating = ref(false);
const nowPlaying = ref(false);
// word-list の要素のうち、どの要素がホバーされているか
const hoveredKey = ref<string | undefined>(undefined);
const loadingDictState = ref<null | "loading" | "synchronizing">("loading");
const userDict = ref<Record<string, UserDictWord>>({});
Expand Down Expand Up @@ -555,11 +572,10 @@ const saveWord = async () => {
await loadingDictProcess();
toInitialState();
};
const isDeletable = computed(() => !!selectedId.value);
const deleteWord = async () => {
const result = await store.dispatch("SHOW_WARNING_DIALOG", {
title: "登録された単語を削除しますか?",
message: "削除された単語は復旧できません",
message: "削除された単語は元に戻せません",
actionName: "削除",
});
if (result === "OK") {
Expand Down Expand Up @@ -594,9 +610,8 @@ const discardOrNotDialog = async (okCallback: () => void) => {
if (isWordChanged.value) {
const result = await store.dispatch("SHOW_WARNING_DIALOG", {
title: "単語の追加・変更を破棄しますか?",
message:
"このまま続行すると、単語の追加・変更は破棄されてリセットされます。",
actionName: "続行",
message: "破棄すると、単語の追加・変更はリセットされます。",
actionName: "破棄",
});
if (result === "OK") {
okCallback();
Expand Down Expand Up @@ -676,13 +691,14 @@ const toDialogClosedState = () => {
.word-list {
// menubar-height + toolbar-height + window-border-width +
// 82(title & buttons) + 30(margin 15x2)
// 36(title & buttons) + 30(margin 15x2)
height: calc(
100vh - #{vars.$menubar-height + vars.$toolbar-height +
vars.$window-border-width + 82px + 30px}
vars.$window-border-width + 36px + 30px}
);
width: 100%;
overflow-y: auto;
padding-bottom: 16px;
}
.active-word {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/EngineManageDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { useStore } from "@/store";
import { base64ImageToUri } from "@/helpers/imageHelper";
import { base64ImageToUri } from "@/helpers/base64Helper";
import { EngineDirValidationResult, EngineId } from "@/type/preload";
import type { SupportedFeatures } from "@/openapi/models/SupportedFeatures";
Expand Down
3 changes: 2 additions & 1 deletion src/components/Dialog/ToolBarCustomDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ const finishOrNotDialog = async () => {
if (isChanged.value) {
const result = await store.dispatch("SHOW_WARNING_DIALOG", {
title: "カスタマイズを終了しますか?",
message: "このまま終了すると、カスタマイズは破棄されてリセットされます。",
message:
"保存せずに終了すると、カスタマイズは破棄されてリセットされます。",
actionName: "終了",
});
if (result === "OK") {
Expand Down
33 changes: 20 additions & 13 deletions src/components/Menu/MenuBar/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import TitleBarButtons from "./TitleBarButtons.vue";
import TitleBarEditorSwitcher from "./TitleBarEditorSwitcher.vue";
import { EditorType } from "@/type/preload";
import { useStore } from "@/store";
import { base64ImageToUri } from "@/helpers/imageHelper";
import { base64ImageToUri } from "@/helpers/base64Helper";
import { useHotkeyManager } from "@/plugins/hotkeyPlugin";
const props = defineProps<{
Expand Down Expand Up @@ -96,6 +96,9 @@ const titleText = computed(
);
const canUndo = computed(() => store.getters.CAN_UNDO(props.editor));
const canRedo = computed(() => store.getters.CAN_REDO(props.editor));
const isMultiSelectEnabled = computed(
() => store.state.experimentalSetting.enableMultiSelect,
);
// FIXME: App.vue内に移動する
watch(titleText, (newTitle) => {
Expand Down Expand Up @@ -363,18 +366,22 @@ const menudata = computed<MenuItemData[]>(() => [
disabled: !canRedo.value,
disableWhenUiLocked: true,
},
{
type: "button",
label: "全セルを選択",
onClick: async () => {
if (!uiLocked.value) {
await store.dispatch("SET_SELECTED_AUDIO_KEYS", {
audioKeys: audioKeys.value,
});
}
},
disableWhenUiLocked: true,
},
...(isMultiSelectEnabled.value
? [
{
type: "button",
label: "すべて選択",
onClick: async () => {
if (!uiLocked.value && isMultiSelectEnabled.value) {
await store.dispatch("SET_SELECTED_AUDIO_KEYS", {
audioKeys: audioKeys.value,
});
}
},
disableWhenUiLocked: true,
} as const,
]
: []),
...props.editSubMenuData,
],
},
Expand Down
Loading

0 comments on commit 9f431ef

Please sign in to comment.