Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[project-library-manage] ライブラリのインストール・アンインストール処理を実装 #1497

Open
wants to merge 76 commits into
base: project-library-manage
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
96480ca
move q-drawer
y-chan Aug 5, 2023
ec228e1
add panel to library manage dialog
y-chan Aug 6, 2023
d0fddac
add package
y-chan Aug 10, 2023
e7a613f
backend of install library
y-chan Aug 10, 2023
d078744
impl library install/uninstall action
y-chan Aug 10, 2023
a79834d
Merge remote-tracking branch 'upstream/main' into feat/library-instal…
y-chan Aug 15, 2023
859e986
fix browser sandbox error
y-chan Aug 15, 2023
3da7c45
add comment to library manager's default api
y-chan Aug 15, 2023
c8be57a
remove unused param
y-chan Aug 15, 2023
393d163
move library store
y-chan Aug 15, 2023
d418caf
use finally for tempfile post process
y-chan Aug 15, 2023
1a4b559
revert
y-chan Aug 15, 2023
8724791
remove unused import
y-chan Aug 15, 2023
5115f2f
use reload app
y-chan Aug 15, 2023
9da64ea
make it independent of DownloadableLibrary
y-chan Aug 17, 2023
a43dcec
split dialog
y-chan Aug 17, 2023
f8563e7
remove unused part
y-chan Aug 17, 2023
07030d8
remove unused part
y-chan Aug 17, 2023
1ef4a5e
use ui dispatch
y-chan Aug 17, 2023
8db4a21
remove unused arg
y-chan Aug 17, 2023
ad8b85b
move fetch statuses to store
y-chan Aug 17, 2023
1de8a2a
add reloadNeeded status
y-chan Aug 17, 2023
4871483
fix func name
y-chan Aug 17, 2023
551d695
refactor
y-chan Aug 17, 2023
43ac370
refactor (ipc/electron/vuex name change)
y-chan Aug 17, 2023
0494da2
fix test
y-chan Aug 17, 2023
3a1fb3e
lint
y-chan Aug 17, 2023
9f9dc7b
move uninstall library part to main process
y-chan Aug 17, 2023
705cd68
Merge remote-tracking branch 'upstream/project-library-manage' into f…
y-chan Aug 18, 2023
603747f
fix uninstall error
y-chan Aug 18, 2023
56be04e
fix watch error
y-chan Aug 18, 2023
15e3d33
remove size helper
y-chan Aug 18, 2023
277eb52
show more details of error status
y-chan Aug 18, 2023
3c9f6ce
update error message
y-chan Aug 20, 2023
097464c
change progress bar condition
y-chan Sep 4, 2023
443e3c0
using library size
y-chan Sep 4, 2023
e3d5d0b
fix uninstall status
y-chan Sep 6, 2023
8469f39
fix miss(remove unused import)
y-chan Sep 9, 2023
51fbb49
add comment for library manager
y-chan Sep 9, 2023
7e6aa6d
fix return type
y-chan Sep 9, 2023
9bc96bb
move to private func (set engine api)
y-chan Sep 9, 2023
51236bc
move to private func(lock by engine id)
y-chan Sep 9, 2023
21d798c
use exists sync
y-chan Sep 9, 2023
71db5ec
improve temp file close and remove process
y-chan Sep 9, 2023
3ff5d84
repeal black list style (using white list style)
y-chan Sep 9, 2023
dad6b42
remove track-color
y-chan Sep 9, 2023
2bd1e55
rename func in library install dialog
y-chan Sep 9, 2023
7e8537d
fix func name in library manage dialog
y-chan Sep 9, 2023
fff7f1b
remove comment (fix error)
y-chan Sep 9, 2023
8f9986e
use result type in library install/uninstall
y-chan Sep 10, 2023
2a66258
rename store state and dispatch/mutation
y-chan Sep 10, 2023
01fe343
remove debug log
y-chan Sep 10, 2023
a7a2133
move library install dialog in manage dialog
y-chan Sep 10, 2023
f639c1a
use props in library install dialog and refactor store
y-chan Sep 10, 2023
0e55a09
remove uninstall dialog in manage dialog
y-chan Sep 11, 2023
a2dfbe1
improve error message
y-chan Sep 11, 2023
4a14ffa
more improve error message in install/uninstall library
y-chan Sep 11, 2023
889f6c6
fix json parse error
y-chan Sep 11, 2023
7ba5553
use quasar dialog plugin
y-chan Sep 12, 2023
fa100ff
move type
y-chan Sep 12, 2023
d7c679a
more detail in error log
y-chan Sep 12, 2023
7db5ae1
remove node-fetch in devDependencies
y-chan Sep 15, 2023
0e99564
fix result type
y-chan Sep 15, 2023
c821680
change func name
y-chan Sep 15, 2023
d6ffa74
move to private func(extract error message)
y-chan Sep 15, 2023
f301c26
use content length variable
y-chan Sep 15, 2023
87b63a1
change func name in library install dialog
y-chan Sep 15, 2023
1699aaa
remove unnecessary process
y-chan Sep 15, 2023
e05d745
use tempfile closed
y-chan Sep 15, 2023
7469adb
fix store order
y-chan Sep 15, 2023
d0f990f
fix typo and right type
y-chan Sep 15, 2023
97d1028
remove unused const
y-chan Sep 15, 2023
1daec5f
fix button text
y-chan Sep 15, 2023
9b0c5b1
use "show warning dialog"
y-chan Sep 15, 2023
a88396a
remove "話者"
y-chan Sep 15, 2023
530c8ef
Merge branch 'project-library-manage' into feat/library-install-action
y-chan Sep 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,658 changes: 5,515 additions & 1,143 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"markdown-it": "12.0.4",
"move-file": "3.0.0",
"multistream": "4.1.0",
"node-fetch": "3.3.1",
y-chan marked this conversation as resolved.
Show resolved Hide resolved
"quasar": "2.11.6",
"semver": "7.3.5",
"shlex": "2.1.2",
Expand Down Expand Up @@ -83,6 +84,7 @@
"@types/markdown-it": "12.2.0",
"@types/mousetrap": "1.6.8",
"@types/multistream": "4.1.0",
"@types/node": "16.18.23",
"@types/semver": "7.3.9",
"@types/unzipper": "0.10.5",
"@types/uuid": "8.3.4",
Expand All @@ -108,7 +110,6 @@
"markdownlint": "0.23.1",
"markdownlint-cli": "0.28.1",
"mousetrap": "1.6.5",
"node-fetch": "3.3.1",
"optionator": "0.9.1",
"prettier": "2.3.0",
"sass": "1.32.13",
Expand Down
82 changes: 82 additions & 0 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
defaultToolbarButtonSetting,
engineSettingSchema,
EngineId,
LibraryInstallStatus,
} from "./type/preload";
import {
ContactTextFileName,
Expand All @@ -46,6 +47,7 @@ import EngineManager from "./background/engineManager";
import VvppManager, { isVvppFile } from "./background/vvppManager";
import configMigration014 from "./background/configMigration014";
import { failure, success } from "./type/result";
import LibraryManager from "./background/libraryManager";
import { ipcMainHandle, ipcMainSend } from "@/electron/ipc";
import { getStoreWithError } from "@/background/electronStore";

Expand Down Expand Up @@ -167,6 +169,10 @@ const engineManager = new EngineManager({
onEngineProcessError,
});
const vvppManager = new VvppManager({ vvppEngineDir });
const libraryManager = new LibraryManager({
engineManager,
tempDir: app.getPath("temp"),
});

// エンジンのフォルダを開く
function openEngineDirectory(engineId: EngineId) {
Expand Down Expand Up @@ -942,6 +948,82 @@ ipcMainHandle("READ_FILE", async (_, { filePath }) => {
}
});

ipcMainHandle(
"START_LIBRARY_DOWNLOAD_AND_INSTALL",
async (
_,
{ engineId, libraryId, libraryName, libraryDownloadUrl, librarySize }
) => {
return await libraryManager.startLibraryDownloadAndInstall(
engineId,
libraryId,
libraryName,
libraryDownloadUrl,
(status: LibraryInstallStatus) => {
if (status.status === "downloading") {
// contentLengthが0になる場合のための処理
if (status.contentLength === 0) {
win.setProgressBar(status.downloaded / librarySize);
} else {
win.setProgressBar(status.downloaded / status.contentLength);
}
} else if (
status.status === "pending" ||
status.status === "installing"
) {
win.setProgressBar(2);
} else if (status.status === "error") {
win.setProgressBar(-1);
dialog.showErrorBox(
"ライブラリのインストールに失敗しました",
status.message
);
} else if (status.status === "done") {
win.setProgressBar(-1);
y-chan marked this conversation as resolved.
Show resolved Hide resolved
} else {
// status.status === "uninstalling"
throw Error(`Invalid status: ${status.status}`);
}
ipcMainSend(win, "UPDATE_LIBRARY_INSTALL_STATUS", {
libraryId,
status,
});
}
);
}
);

ipcMainHandle(
"UNINSTALL_LIBRARY",
async (_, { engineId, libraryId, libraryName }) => {
return await libraryManager.uninstallLibrary(
engineId,
libraryId,
libraryName,
(status: LibraryInstallStatus) => {
if (status.status === "pending" || status.status === "uninstalling") {
win.setProgressBar(2);
} else if (status.status === "error") {
win.setProgressBar(-1);
dialog.showErrorBox(
"ライブラリのインストールに失敗しました",
status.message
);
} else if (status.status === "done") {
win.setProgressBar(-1);
y-chan marked this conversation as resolved.
Show resolved Hide resolved
} else {
// status.status === "downloading" || status.status === "installing"
throw Error(`Invalid status: ${status.status}`);
}
ipcMainSend(win, "UPDATE_LIBRARY_INSTALL_STATUS", {
libraryId,
status,
});
}
);
}
);

// app callback
app.on("web-contents-created", (e, contents) => {
// リンククリック時はブラウザを開く
Expand Down
Loading