Compare commits

...

37 Commits

Author SHA1 Message Date
MathieuG-P 769dab2896 Add changelog for 1.5.0-alpha.2 2024-07-22 18:26:13 +02:00
MathieuG-P 8f1f998c5a Update to 1.5.0-alpha.2 2024-07-22 17:59:22 +02:00
MathieuG-P 48d03cccbb Merge pull request #524 from Zagrios/bugfix/fix-timeout-when-downloading-maps-from-bsv
[bugfix] Downloading maps sometimes times out
2024-07-21 15:44:30 +02:00
MathieuG-P 7d54ae79f7 Merge pull request #523 from Zagrios/bugfix/unable-to-install-bsipa-when-its-path-contain-spaces
[bugfix] unable to install BSIPA if BSIPA path was containing spaces
2024-07-21 15:41:23 +02:00
MathieuG-P c46fdd56f6 Merge pull request #522 from Zagrios/bugfix/495/bug-custom-map-runtime-not-displaying-correctly-in-bsmanager
[bugfix] fix sometimes maps duration were wrong
2024-07-21 15:41:10 +02:00
MathieuG-P 22dc1ca511 [bugfix] fix timeout when downloading maps 2024-07-21 15:36:33 +02:00
MathieuG-P 709105b9f4 [bugfix] fixed : unable to install BSIPA if BSIPA path was containing spaces + wrong translation when bsipa was throwing errors 2024-07-21 14:53:49 +02:00
MathieuG-P 1c0cfb6b89 [bugfix] playlist duraction was always NaN 2024-07-21 14:10:30 +02:00
MathieuG-P 7ebc1bff16 [bugfix] fix sometimes maps duration were wrong 2024-07-21 14:09:14 +02:00
MathieuG-P 0e1cda5050 Merge pull request #517 from Zagrios/bugfix/playlist-maps-with-malformed-hash-doesnt-get-loaded
[bugfix] fix playlist maps with malformed hash doesnt get loaded + improve playlist maps reading reliability
2024-07-17 20:42:12 +02:00
MathieuG-P 331626bd1e Merge pull request #518 from Zagrios/bugfix/crash-when-changing-audio-volume
[bugfix] fix crash when changing audio volume
2024-07-17 20:41:31 +02:00
MathieuG-P ea62f2443f [bugfix-517] use regex.exec instead of .match 2024-07-17 20:35:31 +02:00
MathieuG-P 532ab08e46 [bugfix] fix crash when changing audio volume 2024-07-17 20:32:53 +02:00
MathieuG-P a6fa55719d [bugfix] fix playlist maps with malformed hash doesnt get loaded + improve playlist maps reading reliability 2024-07-17 20:26:54 +02:00
MathieuG-P 163857a14f Merge pull request #513 from Zagrios/bugfix/bsm-crashs-when-loading-playlists-with-an-invalid-playlist-file
[bugfix] Bsm crashs when loading playlists with an invalid playlist file
2024-07-15 21:54:53 +02:00
MathieuG-P 854e0e2761 Merge branch 'master' into bugfix/bsm-crashs-when-loading-playlists-with-an-invalid-playlist-file 2024-07-15 21:50:13 +02:00
MathieuG-P eba6f916a3 Merge pull request #514 from Zagrios/bugfix/read-playlists-in-sub-folders
[bugfix] Playlists in sub folders doesn't get loaded
2024-07-15 21:43:03 +02:00
MathieuG-P 9790f35749 [bugfix] Playlists in sub folders doesn't get loaded 2024-07-15 21:35:26 +02:00
MathieuG-P 93d3cbc8bf [bugfix] Bsm crashs when loading playlists with an invalid playlist file 2024-07-15 20:59:26 +02:00
MathieuG-P 51ea1b130b Merge pull request #512 from Zagrios/chore/update-changelog
Chore/update changelog
2024-07-15 15:58:10 +02:00
shidorien d020b72f20 Add web site button to ChangelogModal component 2024-07-15 15:51:19 +02:00
shidorien f2ac952cd9 Update changelogs.json with new features, fixes, and improvements 2024-07-15 15:23:38 +02:00
shidorien 189d2388fb add missing scrollbar 2024-07-15 15:16:42 +02:00
shidorien 1c989a2402 Update changelog for BSManager 1.5.0-alpha.1 release 2024-07-15 15:11:17 +02:00
shidorien 959e60127d Update changelog for BSManager 1.5.0-alpha.1 2024-07-15 15:08:22 +02:00
shidorien 0faa0f1288 Update changelog for BSManager 1.5.0-alpha.1 2024-07-15 15:00:53 +02:00
shidorien 5ad25f58d5 Update changelogs.json with BSManager 1.5.0-alpha.1 release 2024-07-15 14:57:39 +02:00
shidorien 8ace5e6a7a Add changelog fort 1.5.0-alpha.1 2024-07-15 14:46:14 +02:00
MathieuG-P 185d01e7b4 version to 1.5.0-alpha.1 2024-07-14 22:34:29 +02:00
MathieuG-P 755e407372 Merge pull request #511 from Zagrios/bugfix/bsipa-installation-never-throw-error-even-if-bsipa-process-errors
[bugfix] During the BSIPA installation, no errors are displayed, even if BSIPA generates errors
2024-07-14 21:27:01 +02:00
MathieuG-P 4f123b69ef [bugfix] bsipa installation never show error even if bsipa throw errors 2024-07-14 21:22:25 +02:00
MathieuG-P 7e2334f8fc Merge pull request #509 from Insprill/fix/linux-build
Fix Linux build & crash on startup
2024-07-14 17:46:13 +02:00
MathieuG-P 5be533ccfb chore: Update Linux publishing command in package.json 2024-07-14 17:32:45 +02:00
MathieuG-P b8eafd5f9b chore: Update Linux publishing command in package.json 2024-07-14 17:23:19 +02:00
MathieuG-P 3f3bb959c4 Merge branch 'github-action/build-linux' 2024-07-14 17:17:21 +02:00
MathieuG-P c4d5db809b build for linux 2024-07-14 15:52:51 +02:00
Pierce Thompson 8ecc9d30b3 Fix Linux build 2024-07-13 15:13:15 -04:00
23 changed files with 277 additions and 101 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [windows-latest]
os: [windows-latest, ubuntu-latest]
steps:
- name: Check out Git repository
@@ -30,5 +30,5 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: release
name: release-${{ matrix.os }}
path: release
+4 -1
View File
@@ -2,6 +2,9 @@
name: Realease Linux
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
on:
workflow_dispatch:
@@ -23,7 +26,7 @@ jobs:
node-version: 18.x
cache: "npm"
- run: npm ci
- run: npm run build && electron-builder --linux --x64 --publish always
- run: npm run publish:linux
- name: Upload artifact
uses: actions/upload-artifact@v4
+14 -1
View File
@@ -1 +1,14 @@
{}
{
"1.5.0-alpha.1":{
"htmlBody" :"<strong>BSManager continues to get better, thanks to your continued support and contributions!</strong><center>🎈🎉🎈</center><p>Note: This is an alpha release, encountering bugs is expected. Please file new issues for any bugs you find.</p><h2>Features</h2><ul><li>Added playlist support</li><li>Added Linux support (Thanks to @Insprill)</li><li>Added reset button to reset values when editing a Beat Saber version (Thanks to @Liborsaf)</li><li>Added a changelog modal</li></ul><h2>Fixes</h2><ul><li>Fixed an issue where switching between Beat Saber versions too quickly displayed mods for the wrong version</li><li>Fixed an issue where the launch window from a shortcut would never close</li><li>Advanced launch arguments are used even when the input field is closed</li><li>Fixed an issue where having many maps caused some maps to not have their information loaded</li></ul><h2>Other changes</h2><ul><li>.NET Framework is no longer required</li><li>Clear English translations for the Steam credentials popup (Thanks to @Aeywoo)</li><li>NSFW models are now blurred when browsing for models</li><li>When no mods are available for a Beat Saber version, the version number is now shown</li><li>Mods load faster</li><li>After a first full maps loading, maps load almost instantly</li><li>Improved performance in lists with lot of contents</li></ul>",
"title" : "What's new ?",
"timestamp" : 1721048400,
"version" : "1.5.0-alpha.1"
},
"1.5.0-alpha.2":{
"htmlBody" :"<strong>BSManager continues to get better, thanks to your continued support and contributions!</strong><center>🎈🎉🎈</center><p>Note: This is an alpha release, encountering bugs is expected. Please file new issues for any bugs you find.</p><h4>Alpha changes</h4><ul><li>Fixed an issue where BSIPA could not be installed if the BS version&#39;s path contained spaces #523</li><li>Fixed a crash when changing audio volume #518</li><li>Fixed an issue where playlist maps with a malformed hash were not loaded #517</li><li>Improved reliability of reading maps from a playlist file #517</li><li>Playlists in sub-folders are now loaded #514</li><li>Fixed a crash when loading an invalid playlist file #513</li></ul><h2>Features</h2><ul> <li>Added playlist support</li> <li>Added Linux support (Thanks to @Insprill)</li> <li>Added reset button to reset values when editing a Beat Saber version (Thanks to @Liborsaf)</li> <li>Added a changelog modal</li></ul><h3>Fixes</h3><ul><li>Fixed an issue where switching between Beat Saber versions too quickly displayed mods for the wrong version #472</li><li>Fixed an issue where the launch window from a shortcut would never close #485</li><li>Advanced launch arguments are used even when the input field is closed #496</li><li>Fixed an issue where having many maps caused some maps to not have their information loaded #503</li><li>Fixed an issue where downloading maps sometimes resulted in a timeout error #524</li><li>Fixed an issue where the duration of maps could be wrong in some cases #522</li></ul><h2>Other changes</h2><ul> <li>.NET Framework is no longer required</li> <li>Clear English translations for the Steam credentials popup (Thanks to @Aeywoo)</li> <li>NSFW models are now blurred when browsing for models</li> <li>When no mods are available for a Beat Saber version, the version number is now shown</li> <li>Mods load faster</li> <li>After a first full maps loading, maps load almost instantly</li> <li>Improved performance in lists with lot of contents</li></ul>",
"title" : "What's new ?",
"timestamp" : 1721665382,
"version" : "1.5.0-alpha.2"
}
}
+41 -2
View File
@@ -1,12 +1,12 @@
{
"name": "bs-manager",
"version": "1.5.0",
"version": "1.5.0-alpha.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "bs-manager",
"version": "1.5.0",
"version": "1.5.0-alpha.1",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
@@ -27,6 +27,7 @@
"electron-store": "^8.1.0",
"electron-updater": "^6.2.1",
"fast-deep-equal": "^3.1.3",
"format-duration": "^3.0.2",
"framer-motion": "^11.2.6",
"fs-extra": "^11.2.0",
"got": "^14.4.1",
@@ -11201,6 +11202,23 @@
"esbuild": ">=0.12 <1"
}
},
"node_modules/esbuild/node_modules/@esbuild/linux-x64": {
"version": "0.20.1",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.1.tgz",
"integrity": "sha512-5gRPk7pKuaIB+tmH+yKd2aQTRpqlf1E4f/mC+tawIm/CGJemZcHZpp2ic8oD83nKgUPMEd0fNanrnFljiruuyA==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/escalade": {
"version": "3.1.1",
"dev": true,
@@ -12746,6 +12764,11 @@
"node": ">= 18"
}
},
"node_modules/format-duration": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/format-duration/-/format-duration-3.0.2.tgz",
"integrity": "sha512-pKzJDSRgK2lqAiPW3uizDaIJaJnataZclsahz25UMwfdryBGDa+1HlbXGjzpMvX/2kMh4O0sNevFXKaEfCjHsA=="
},
"node_modules/formdata-polyfill": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
@@ -18827,6 +18850,22 @@
"query-process-win32-x64-msvc": "0.0.3"
}
},
"node_modules/query-process-linux-x64-gnu": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/query-process-linux-x64-gnu/-/query-process-linux-x64-gnu-0.0.3.tgz",
"integrity": "sha512-j1tGcNnGyVCABJ1PHZD1gKuyuomNzsPow3NDuZzUGjPqvKu67RsmKJJJOhMyT1SvUkcqdLFdtS1KTD20I4GS5Q==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/query-process-win32-x64-msvc": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/query-process-win32-x64-msvc/-/query-process-win32-x64-msvc-0.0.3.tgz",
+4 -2
View File
@@ -2,7 +2,7 @@
"name": "bs-manager",
"description": "Manage maps, mods and more for Beat Saber",
"main": "./src/main/main.ts",
"version": "1.5.0",
"version": "1.5.0-alpha.2",
"scripts": {
"build-rust-scripts": "node -r esbuild-register ./.erb/scripts/build-rust-scripts.js",
"build": "concurrently \"npm run build:main\" \"npm run build:renderer\"",
@@ -18,7 +18,8 @@
"start:preload": "cross-env NODE_ENV=development webpack --config ./.erb/configs/webpack.config.preload.dev.ts",
"start:renderer": "cross-env NODE_ENV=development webpack serve --config ./.erb/configs/webpack.config.renderer.dev.ts",
"test": "jest",
"publish": "npm run build && electron-builder -c.win.certificateSha1=842a817a51e2a1d360fcd62f54bf5f9193e919e1 --publish always --win --x64"
"publish": "npm run build && electron-builder -c.win.certificateSha1=842a817a51e2a1d360fcd62f54bf5f9193e919e1 --publish always --win --x64",
"publish:linux": "npm run build && electron-builder --publish always --linux --x64"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
@@ -247,6 +248,7 @@
"electron-store": "^8.1.0",
"electron-updater": "^6.2.1",
"fast-deep-equal": "^3.1.3",
"format-duration": "^3.0.2",
"framer-motion": "^11.2.6",
"fs-extra": "^11.2.0",
"got": "^14.4.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "bs-manager",
"version": "1.5.0",
"version": "1.5.0-alpha.2",
"description": "BSManager",
"main": "./dist/main/main.js",
"author": {
@@ -7,10 +7,10 @@ import { RequestService } from "../request.service";
import { LocalMapsManagerService } from "./maps/local-maps-manager.service";
import log from "electron-log";
import { WindowManagerService } from "../window-manager.service";
import { BPList, DownloadPlaylistProgressionData } from "shared/models/playlists/playlist.interface";
import { readFileSync } from "fs";
import { BPList, DownloadPlaylistProgressionData, PlaylistSong } from "shared/models/playlists/playlist.interface";
import { readFileSync, Stats } from "fs";
import { BeatSaverService } from "../thrid-party/beat-saver/beat-saver.service";
import { copy, ensureDir, pathExists, pathExistsSync, readdirSync, realpath, writeFileSync } from "fs-extra";
import { copy, ensureDir, pathExists, pathExistsSync, realpath, writeFileSync } from "fs-extra";
import { Progression, getUniqueFileNamePath, unlinkPath } from "../../helpers/fs.helpers";
import { FileAssociationService } from "../file-association.service";
import { SongDetailsCacheService } from "./maps/song-details-cache.service";
@@ -23,6 +23,10 @@ import { isValidUrl } from "shared/helpers/url.helpers";
import { Archive } from "main/models/archive.class";
import { CustomError } from "shared/models/exceptions/custom-error.class";
import { BsmLocalMap } from "shared/models/maps/bsm-local-map.interface";
import { tryit } from "shared/helpers/error.helpers";
import recursiveReadDir from "recursive-readdir";
import { BsvMapDetail, SongDetails } from "shared/models/maps";
import { findHashInString } from "shared/helpers/string.helpers";
export class LocalPlaylistsManagerService {
private static instance: LocalPlaylistsManagerService;
@@ -136,6 +140,14 @@ export class LocalPlaylistsManagerService {
const bpList: BPList = isLocalFile ? JSON.parse(readFileSync(source).toString()) : await this.request.getJSON<BPList>(source);
if(!bpList?.playlistTitle) {
throw new Error(`Invalid playlist file ${source}`);
}
bpList.songs = (bpList.songs ?? []).map(s => s.hash ? (
{ ...s, hash: findHashInString(s.hash) ?? s.hash }
) : s).filter(Boolean);
return bpList;
}
@@ -155,13 +167,22 @@ export class LocalPlaylistsManagerService {
throw new Error(`Playlists folder not found ${folerPath}`);
}
const playlists = readdirSync(folerPath).filter(file => path.extname(file) === ".bplist");
progress.total = playlists.length;
const ignoreFunc = (file: string, stats: Stats): boolean => {
if(stats.isFile() && path.extname(file) !== ".bplist") { return true; }
return false;
}
for (const playlist of playlists) {
const playlistPath = path.join(folerPath, playlist);
const bpList = await this.readPlaylistFromSource(playlistPath);
const playlistPaths = (await recursiveReadDir(folerPath, [ignoreFunc]));
progress.total = playlistPaths.length;
for (const playlistPath of playlistPaths) {
const {result: bpList, error} = await tryit(() => this.readPlaylistFromSource(playlistPath));
if(error) {
log.error(error);
continue;
}
const localBpList: LocalBPList = { ...bpList, path: playlistPath };
bpLists.push(localBpList);
@@ -175,6 +196,25 @@ export class LocalPlaylistsManagerService {
});
}
private getSongDetailsFromPlaylistSong(song: PlaylistSong): SongDetails | undefined {
let songDetails: SongDetails;
const songHash = findHashInString(song.hash);
if(songHash){
songDetails = this.songDetails.getSongDetails(song.hash);
}
if(song.key && !songDetails){
songDetails = this.songDetails.getSongDetailsById(song.key);
}
const levelIdHash = findHashInString(song.levelid);
if(levelIdHash && !songDetails){
songDetails = this.songDetails.getSongDetails(levelIdHash);
}
return songDetails;
}
public getLocalBPListDetails(localBPList: LocalBPList): LocalBPListsDetails {
const tryExtractPlaylistId = (url: string) => {
@@ -185,27 +225,28 @@ export class LocalPlaylistsManagerService {
const bpListDetails: LocalBPListsDetails = {
...localBPList,
duration: 0,
nbMaps: localBPList.songs?.length ?? 0,
id: localBPList.customData?.syncURL ? tryExtractPlaylistId(localBPList.customData.syncURL) : undefined
}
const songsDetails = localBPList.songs?.map(s => {
if(s.hash){
return this.songDetails.getSongDetails(s.hash);
}
if(s.key){
return this.songDetails.getSongDetailsById(s.key);
}
return undefined;
}).filter(Boolean);
const mappers = new Set<number>();
if(songsDetails?.length){
bpListDetails.duration = songsDetails.reduce((acc, song) => acc + song.duration, 0);
bpListDetails.nbMappers = new Set(songsDetails.map(s => s.uploader.id)).size;
bpListDetails.minNps = Math.min(...songsDetails.map(s => Math.min(...s.difficulties.map(d => d.nps || 0))));
bpListDetails.maxNps = Math.max(...songsDetails.map(s => Math.max(...s.difficulties.map(d => d.nps || 0))));
for(const song of localBPList.songs){
const songDetails = this.getSongDetailsFromPlaylistSong(song);
if(!songDetails) { continue; }
bpListDetails.duration += songDetails?.duration ? +songDetails.duration : 0;
mappers.add(songDetails.uploader?.id);
bpListDetails.minNps = Math.min(bpListDetails?.minNps ?? 0, Math.min(...songDetails.difficulties?.map(d => d?.nps || 0) ?? [0]));
bpListDetails.maxNps = Math.max(bpListDetails?.maxNps ?? 0, Math.max(...songDetails.difficulties?.map(d => d?.nps || 0) ?? [0]));
song.songDetails = songDetails;
}
bpListDetails.nbMappers = mappers.size;
return bpListDetails;
}
@@ -261,7 +302,28 @@ export class LocalPlaylistsManagerService {
continue;
}
const [ mapDetail ] = await this.bsaver.getMapDetailsFromHashs([song.hash]);
const mapDetail = await (async () => {
let mapDetail: BsvMapDetail;
const mapHash = findHashInString(song?.hash);
if(mapHash) {
mapDetail = (await this.bsaver.getMapDetailsFromHashs([findHashInString(mapHash)])).at(0);
}
if(song.key && !mapDetail) {
mapDetail = await this.bsaver.getMapDetailsById(song.key);
}
const levelIdHash = findHashInString(song?.levelid);
if(levelIdHash && !mapDetail) {
mapDetail = (await this.bsaver.getMapDetailsFromHashs([levelIdHash])).at(0);
}
return mapDetail;
})().catch(e => {
log.error(e);
return undefined as BsvMapDetail;
});
if(!mapDetail) {
continue;
@@ -14,8 +14,9 @@ import { lastValueFrom } from "rxjs";
import JSZip from "jszip";
import { extractZip } from "../../helpers/zip.helpers";
import recursiveReadDir from "recursive-readdir";
import { minToMs } from "../../../shared/helpers/time.helpers";
import { sToMs } from "../../../shared/helpers/time.helpers";
import { ensureDir } from "fs-extra";
import { CustomError } from "shared/models/exceptions/custom-error.class";
export class BsModsManagerService {
private static instance: BsModsManagerService;
@@ -147,12 +148,22 @@ export class BsModsManagerService {
return new Promise<boolean>(resolve => {
const cmd = process.platform === 'linux'
? `screen -dmS "BSIPA" dotnet ${ipaPath} ${args.join(" ")}` // Must run through screen, otherwise BSIPA tries to move console cursor and crashes.
: `start /wait /min "" "${ipaPath}" ${args.join(" ")}`;
: `"${ipaPath}" ${args.join(" ")}`;
log.info("START IPA PROCESS", cmd);
const processIPA = spawn(cmd, { cwd: versionPath, detached: true, shell: true });
const timemout = setTimeout(() => {
log.info("Ipa process timeout");
resolve(false)
}, sToMs(30));
processIPA.stderr.on("data", data => {
log.error("IPA process stderr", data.toString());
})
processIPA.once("exit", code => {
clearTimeout(timemout);
if (code === 0) {
log.info("Ipa process exist with code 0");
return resolve(true);
@@ -161,10 +172,6 @@ export class BsModsManagerService {
resolve(false);
});
setTimeout(() => {
log.info("Ipa process timeout");
resolve(false)
}, minToMs(1));
});
}
@@ -336,7 +343,7 @@ export class BsModsManagerService {
public async installMods(mods: Mod[], version: BSVersion): Promise<InstallModsResult> {
if (!mods?.length) {
throw "no-mods";
throw CustomError.fromError(new Error("No mods to install"), "no-mods");
}
const deps = await this.resolveDependencies(mods, version);
@@ -356,7 +363,7 @@ export class BsModsManagerService {
return false;
});
if (!installed) {
throw "cannot-install-bsipa";
throw CustomError.fromError(new Error("Unable to install BSIPA"), "cannot-install-bsipa");
}
}
@@ -372,7 +379,7 @@ export class BsModsManagerService {
public async uninstallMods(mods: Mod[], version: BSVersion): Promise<UninstallModsResult> {
if (!mods?.length) {
throw "no-mods";
throw CustomError.fromError(new Error("No mods to uninstall"), "no-mods");
}
this.nbModsToUninstall = mods.length;
@@ -392,7 +399,7 @@ export class BsModsManagerService {
const mods = await this.getInstalledMods(version);
if (!mods?.length) {
throw "no-mods";
throw CustomError.fromError(new Error("This version has to mods to uninstall"), "no-mods");
}
this.nbModsToUninstall = mods.length;
+22 -18
View File
@@ -1,5 +1,5 @@
import { Agent, RequestOptions, get } from "https";
import { createWriteStream, unlink } from "fs";
import { Agent, RequestOptions } from "https";
import { createWriteStream } from "fs";
import { Progression } from "main/helpers/fs.helpers";
import { Observable, shareReplay, tap } from "rxjs";
import log from "electron-log";
@@ -8,6 +8,8 @@ import got, { Options } from "got";
import { IncomingMessage } from "http";
import { app } from "electron";
import os from "os";
import { unlinkSync } from "fs-extra";
import { tryit } from "shared/helpers/error.helpers";
export class RequestService {
private static instance: RequestService;
@@ -60,31 +62,33 @@ export class RequestService {
public downloadFile(url: string, dest: string): Observable<Progression<string>> {
return new Observable<Progression<string>>(subscriber => {
const progress: Progression<string> = { current: 0, total: 0 };
const progress: Progression<string> = { current: 0, total: 0, data: dest };
const stream = got.stream(url)
const file = createWriteStream(dest);
file.on("close", () => {
progress.data = dest;
stream.on("downloadProgress", ({ transferred, total }) => {
progress.current = transferred;
progress.total = total;
subscriber.next(progress);
});
stream.on("error", err => {
tryit(() => unlinkSync(dest));
subscriber.error(err);
});
stream.on("end", () => {
subscriber.next(progress);
subscriber.complete();
});
file.on("error", err => unlink(dest, () => subscriber.error(err)));
const req = get(url, this.requestOptionsFromDefaultInit(), res => {
progress.total = parseInt(res.headers?.["content-length"] || "0", 10);
stream.pipe(file);
res.on("data", chunk => {
progress.current += chunk.length;
subscriber.next(progress);
});
return () => {
stream.destroy();
}
res.pipe(file);
});
req.on("error", err => {
subscriber.error(err);
});
}).pipe(tap({ error: e => log.error(e, url, dest) }), shareReplay(1));
}
@@ -23,14 +23,15 @@ export class BeatSaverService {
}
public async getMapDetailsFromHashs(hashs: string[]): Promise<BsvMapDetail[]> {
const filtredHashs = hashs.map(h => h.toLowerCase()).filter(hash => !Array.from(this.cachedMapsDetails.keys()).includes(hash));
const filtredHashs = hashs.map(h => h.toLowerCase()).filter(hash => !this.cachedMapsDetails.has(hash));
const chunkHash = splitIntoChunk(filtredHashs, 50);
const mapDetails = Array.from(this.cachedMapsDetails.entries()).reduce((res, [hash, details]) => {
if (hashs.includes(hash)) {
res.push(details);
const mapDetails = hashs.reduce((acc, hash) => {
const detail = this.cachedMapsDetails.get(hash.toLowerCase());
if (detail) {
acc.push(detail);
}
return res;
return acc;
}, [] as BsvMapDetail[]);
await Promise.allSettled(
@@ -2,8 +2,7 @@ import { BsvMapDetail, MapFilter, MapRequirement, MapSpecificity, MapStyle, MapT
import { motion } from "framer-motion";
import { MutableRefObject, useEffect, useRef, useState } from "react";
import { BsmCheckbox } from "../../shared/bsm-checkbox.component";
import { minToS } from "../../../../shared/helpers/time.helpers";
import dateFormat from "dateformat";
import { minToS, sToMs } from "../../../../shared/helpers/time.helpers";
import { BsmRange } from "../../shared/bsm-range.component";
import { useTranslation } from "renderer/hooks/use-translation.hook";
import { MAP_DIFFICULTIES_COLORS } from "shared/models/maps/difficulties-colors";
@@ -13,6 +12,7 @@ import clone from "rfdc";
import { GlowEffect } from "../../shared/glow-effect.component";
import { BsmLocalMap } from "shared/models/maps/bsm-local-map.interface";
import { SongDetails } from "shared/models/maps";
import formatDuration from "format-duration";
export type Props = {
className?: string;
@@ -60,9 +60,8 @@ export function FilterPanel({ className, ref, playlist = false, filter, localDat
if (sec === MAX_DURATION) {
return "∞";
}
const date = new Date(0);
date.setSeconds(sec);
return sec > 3600 ? dateFormat(date, "h:MM:ss") : dateFormat(date, "MM:ss");
const ms = sToMs(sec);
return formatDuration(ms, { leading: true });
})();
return renderLabel(textValue, sec === MAX_DURATION);
@@ -4,7 +4,7 @@ import { BsmLink } from "../../shared/bsm-link.component";
import { BsmIcon } from "../../svgs/bsm-icon.component";
import { BsmButton } from "../../shared/bsm-button.component";
import { AnimatePresence, motion } from "framer-motion";
import { useState, Fragment, useRef } from "react";
import { useState, Fragment, useRef, useMemo } from "react";
import { LinkOpenerService } from "renderer/services/link-opener.service";
import dateFormat from "dateformat";
import { AudioPlayerService } from "renderer/services/audio-player.service";
@@ -30,6 +30,8 @@ import { BsmCheckbox } from "renderer/components/shared/bsm-checkbox.component";
import { BPListDifficulty } from "shared/models/playlists/playlist.interface";
import { useOnUpdate } from "renderer/hooks/use-on-update.hook";
import { cn } from "renderer/helpers/css-class.helpers";
import { sToMs } from "shared/helpers/time.helpers";
import formatDuration from "format-duration";
export type MapItemComponentProps<T = unknown> = {
hash: string;
@@ -106,14 +108,13 @@ export function MapItemComponent <T = unknown>({ hash, title, autor, songAutor,
return dateFormat(date, "d mmm yyyy");
});
const durationText = (() => {
const durationText = useMemo(() => {
if (!duration) {
return null;
}
const date = new Date(0);
date.setSeconds(duration);
return duration > 3600 ? dateFormat(date, "h:MM:ss") : dateFormat(date, "MM:ss");
})();
const durationMs = sToMs(duration);
return formatDuration(durationMs, { leading: true });
}, [duration]);
const parseDiffLabel = (diffLabel: string) => {
if (MAP_DIFFICULTIES.includes(diffLabel as SongDiffName)) {
@@ -3,9 +3,9 @@ import { Dispatch, SetStateAction, useState } from "react";
import { BsmRange } from "renderer/components/shared/bsm-range.component";
import { cn } from "renderer/helpers/css-class.helpers"
import { useTranslation } from "renderer/hooks/use-translation.hook";
import dateFormat from "dateformat";
import { hourToS, sToMs } from "shared/helpers/time.helpers";
import { useOnUpdate } from "renderer/hooks/use-on-update.hook";
import formatDuration from "format-duration";
type Props = {
className?: string;
@@ -81,7 +81,8 @@ export function LocalPlaylistFilterPanel({ className, filter, onChange }: Props)
return "∞";
}
return sec > 3600 ? dateFormat(sToMs(sec), "h:MM:ss") : dateFormat(sToMs(sec), "MM:ss");
const ms = sToMs(sec);
return formatDuration(ms, { leading: true });
})();
return renderLabel(textValue, sec === MAX_DURATION);
@@ -282,8 +282,9 @@ export const LocalPlaylistsListPanel = forwardRef<LocalPlaylistsListRef, Props>(
let map: BsmLocalMap;
if(playlistSong.hash){
map = maps.find(m => m.hash.toLowerCase() === playlistSong.hash.toLowerCase());
if(playlistSong.hash || playlistSong?.songDetails?.hash){
const hash = (playlistSong.hash || playlistSong.songDetails.hash).toLowerCase();
map = maps.find(m => m.hash.toLowerCase() === hash);
}
else if(playlistSong.key){
map = maps.find(m => m?.songDetails?.id === playlistSong.key);
@@ -379,8 +380,8 @@ export const LocalPlaylistsListPanel = forwardRef<LocalPlaylistsListRef, Props>(
if(!playlists){ return []; }
return playlists.filter(p => {
if(!p.playlistTitle.toLowerCase().includes(search.toLowerCase())){ return false; }
if(!p.playlistAuthor.toLowerCase().includes(search.toLowerCase())){ return false; }
if(!p.playlistTitle?.toLowerCase().includes(search.toLowerCase())){ return false; }
if(!p.playlistAuthor?.toLowerCase().includes(search.toLowerCase())){ return false; }
if(typeof p.nbMaps === "number" && (typeof playlistFiler?.minNbMaps === "number" || typeof playlistFiler?.maxNbMaps === "number")){
if(playlistFiler?.minNbMaps && p.nbMaps < playlistFiler.minNbMaps){ return false; }
@@ -5,7 +5,6 @@ import { ClockIcon } from 'renderer/components/svgs/icons/clock-icon.component';
import { MapIcon } from 'renderer/components/svgs/icons/map-icon.component';
import { PersonIcon } from 'renderer/components/svgs/icons/person-icon.component';
import { useThemeColor } from 'renderer/hooks/use-theme-color.hook';
import dateFormat from 'dateformat';
import { NpsIcon } from 'renderer/components/svgs/icons/nps-icon.component';
import { GlowEffect } from 'renderer/components/shared/glow-effect.component';
import { memo, useState } from 'react';
@@ -18,6 +17,8 @@ import { BsmBasicSpinner } from 'renderer/components/shared/bsm-basic-spinner/bs
import defaultImage from "../../../../../assets/images/default-version-img.jpg";
import equal from 'fast-deep-equal';
import { useTranslation } from 'renderer/hooks/use-translation.hook';
import { sToMs } from 'shared/helpers/time.helpers';
import formatDuration from 'format-duration';
export type PlaylistItemComponentProps = {
title?: string;
@@ -79,10 +80,14 @@ export const PlaylistItem = memo(({ title,
const showNps = minNps !== undefined && maxNps !== undefined;
const durationText = (() => {
console.log("DURATION", duration);
if (!duration) {
return null;
}
return duration > 3600 ? dateFormat(duration * 1000, "h:MM:ss") : dateFormat(duration * 1000, "MM:ss");
const durationMs = sToMs(duration);
return formatDuration(durationMs, { leading: true });
})();
return (
@@ -14,12 +14,13 @@ export const ChangelogModal: ModalComponent<void, ChangelogVersion> = ({ options
const openTwitter = () => linkOpener.open("https://twitter.com/BSManager_");
const openSupportPage = () => linkOpener.open("https://www.patreon.com/bsmanager");
const openDiscord = () => linkOpener.open("https://discord.gg/uSqbHVpKdV");
const openWebSite = () => linkOpener.open("https://bsmanager.io/");
const date = changelog?.timestamp ? new Date(changelog.timestamp * 1000).toLocaleDateString() : '';
return (
<form className="w-[350px] text-gray-800 dark:text-gray-200 h-[70vh] flex flex-col justify-between">
<h1 className=" p-4 pt-1 text-3xl uppercase tracking-wide w-full text-center text-gray-800 dark:text-gray-200 font-bold">{changelog?.title}</h1>
<div className=" overflow-y-scroll h-full content grow" dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(changelog?.htmlBody) }}/>
<div className=" overflow-y-scroll h-full content grow scrollbar-default" dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(changelog?.htmlBody) }}/>
<span className="block w-[100%] mx-auto mt-0 mb-4 h-1 rounded-full bg-main-color-1" />
<div className="flex flex-row justify-between">
<div className="my-auto flex flex-col text-sm">
@@ -39,6 +40,9 @@ export const ChangelogModal: ModalComponent<void, ChangelogVersion> = ({ options
<Tippy content="Patreon" placement="top" className="font-bold !bg-neutral-900" duration={[200, 0]} arrow={false}>
<div><BsmButton onClick={openSupportPage} className="rounded-md p-1 w-7 h-7 " icon="patreon" withBar={false} iconColor="#fff" color="#000"/></div>
</Tippy>
<Tippy content="Web Site" placement="top" className="font-bold !bg-neutral-900" duration={[200, 0]} arrow={false}>
<div><BsmButton onClick={openWebSite} className="rounded-md p-1 w-7 h-7 " icon="web-site" withBar={false} iconColor="#fff" color="#000"/></div>
</Tippy>
</div>
</div>
</form>
@@ -27,7 +27,6 @@ import { MapIcon } from "renderer/components/svgs/icons/map-icon.component";
import { PersonIcon } from "renderer/components/svgs/icons/person-icon.component";
import { ClockIcon } from "renderer/components/svgs/icons/clock-icon.component";
import { NpsIcon } from "renderer/components/svgs/icons/nps-icon.component";
import dateFormat from 'dateformat';
import { getCorrectTextColor } from "renderer/helpers/correct-text-color";
import { BPList, BPListDifficulty, PlaylistSong } from "shared/models/playlists/playlist.interface";
import { EditPlaylistInfosModal } from "./edit-playlist-infos-modal.component";
@@ -36,6 +35,9 @@ import { DraggableVirtualScroll } from "renderer/components/shared/virtual-scrol
import { BsmImage } from "renderer/components/shared/bsm-image.component";
import BeatWaiting from "../../../../../../../assets/images/apngs/beat-waiting.png";
import BeatConflict from "../../../../../../../assets/images/apngs/beat-conflict.png";
import { findHashInString } from "shared/helpers/string.helpers";
import { sToMs } from "shared/helpers/time.helpers";
import formatDuration from "format-duration";
type Props = {
maps$: Observable<BsmLocalMap[]>;
@@ -115,7 +117,7 @@ export const EditPlaylistModal: ModalComponent<BPList, Props> = ({ resolver, opt
const maps = await lastValueFrom(maps$.pipe(take(1)));
const playlistMapsRes = (playlist?.songs ?? []).reduce((acc, song) => {
const songHash = song.hash?.toLowerCase();
const songHash = song?.hash?.toLowerCase() ?? song?.songDetails?.hash?.toLowerCase() ?? findHashInString(song.levelid)?.toLowerCase();
const map = maps.find(map => map.hash === songHash);
if(map){
@@ -361,6 +363,7 @@ export const EditPlaylistModal: ModalComponent<BPList, Props> = ({ resolver, opt
const playlistDuration = useMemo(() => {
if(!playlistMaps || Object.keys(playlistMaps).length === 0){ return "0:00"; }
const durations = Object.values(playlistMaps ?? {}).map(playlistMap => {
if(!playlistMap?.map){ return 0; }
@@ -379,8 +382,8 @@ export const EditPlaylistModal: ModalComponent<BPList, Props> = ({ resolver, opt
return 0;
}).filter(duration => !Number.isNaN(duration));
const totalDuration = durations.reduce((acc, duration) => acc + duration, 0);
return totalDuration > 3600 ? dateFormat(totalDuration * 1000, "H:MM:ss") : dateFormat(totalDuration * 1000, "MM:ss");
const totalDuration = sToMs(durations.reduce((acc, duration) => acc + duration, 0));
return formatDuration(totalDuration, { leading: true });
}, [playlistMaps]);
const [playlistMinNps, playlistMaxNps] = useMemo(() => {
@@ -1,6 +1,5 @@
import { ReactNode } from "react"
import { BsmImage } from "renderer/components/shared/bsm-image.component";
import dateFormat from "dateformat";
import { MapIcon } from "renderer/components/svgs/icons/map-icon.component";
import { PersonIcon } from "renderer/components/svgs/icons/person-icon.component";
import { ClockIcon } from "renderer/components/svgs/icons/clock-icon.component";
@@ -9,6 +8,8 @@ import { useThemeColor } from "renderer/hooks/use-theme-color.hook";
import { ThemeColorGradientSpliter } from "renderer/components/shared/theme-color-gradient-spliter.component";
import { CrossIcon } from "renderer/components/svgs/icons/cross-icon.component";
import { useTranslation } from "renderer/hooks/use-translation.hook";
import { sToMs } from "shared/helpers/time.helpers";
import formatDuration from "format-duration";
export type PlaylistDetailsTemplateProps = {
title: string;
@@ -40,9 +41,8 @@ export function PlaylistDetailsTemplate({title, imagebase64, imageUrl, author, d
if (!duration) {
return null;
}
const date = new Date(0);
date.setSeconds(duration);
return duration > 3600 ? dateFormat(date, "h:MM:ss") : dateFormat(date, "MM:ss");
const durationMs = sToMs(duration);
return formatDuration(durationMs, { leading: true });
})();
return (
@@ -50,6 +50,7 @@ import { SyncIcon } from "./icons/sync-icon.component";
import { VolumeUpIcon } from "./icons/volume-up-icon.component";
import { VolumeOffIcon } from "./icons/volume-off-icon.component";
import { VolumeDownIcon } from "./icons/volume-down-icon.component";
import { WebSiteIcon } from "./icons/web-site-icon.component";
import { GermanIcon } from "./flags/german-icon.component";
import { RussianIcon } from "./flags/russian-icon.component";
import { ChineseIcon } from "./flags/chinese-icon.component";
@@ -61,7 +62,8 @@ import { ShortcutIcon } from "./icons/shortcut-icon.component";
import { BackupRestoreIcon } from "./icons/backup-restore-icon.component";
import { SongDetailDiffCharactertistic } from "shared/models/maps/song-details-cache/song-details-cache.model";
export type BsmIconType = SongDetailDiffCharactertistic | ("settings" | "trash" | "favorite" | "folder" | "bsNote" | "check" | "three-dots" | "twitch" | "eye" | "play" | "checkCircleIcon" | "discord" | "info" | "eye-cross" | "terminal" | "desktop" | "oculus" | "add" | "cross" | "task" | "github" | "close" | "thumbUpFill" | "timerFill" | "pause" | "twitter" | "sync" | "chevron-top" | "copy" | "steam" | "edit" | "export" | "patreon" | "search" | "bsMapDifficulty" | "link" | "unlink" | "download" | "filter" | "mee6" | "volume-up" | "volume-off" | "volume-down" | "shortcut" | "backup-restore" | "fr-FR-flag" | "es-ES-flag" | "en-US-flag" | "en-EN-flag" | "de-DE-flag" | "ru-RU-flag" | "zh-CN-flag" | "zh-TW-flag" | "ja-JP-flag");
export type BsmIconType = SongDetailDiffCharactertistic | ("settings" | "trash" | "favorite" | "folder" | "bsNote" | "check" | "three-dots" | "twitch" | "eye" | "play" | "checkCircleIcon" | "discord" | "info" | "eye-cross" | "terminal" | "desktop" | "oculus" | "add" | "cross" | "task" | "github" | "close" | "thumbUpFill" | "timerFill" | "pause" | "twitter" | "sync" | "chevron-top" | "copy" | "steam" | "edit" | "export" | "patreon" | "search" | "bsMapDifficulty" | "link" | "unlink" | "download" | "filter" | "mee6" | "volume-up" | "volume-off" | "volume-down" | "shortcut" | "backup-restore" | "web-site" | "fr-FR-flag" | "es-ES-flag" | "en-US-flag" | "en-EN-flag" | "de-DE-flag" | "ru-RU-flag" | "zh-CN-flag" | "zh-TW-flag" | "ja-JP-flag");
export const BsmIcon = memo(({ className, icon, style }: { className?: string; icon: BsmIconType; style?: CSSProperties }) => {
// TODO : Very ugly very messy, need to find a better way to do this
@@ -250,7 +252,13 @@ export const BsmIcon = memo(({ className, icon, style }: { className?: string; i
if (icon === "backup-restore") {
return <BackupRestoreIcon className={className} style={style} />;
}
if(icon === "web-site") {
return <WebSiteIcon className={className} style={style} />;
}
return <TrashIcon className={className} style={style} />;
};
return <>{renderIcon()}</>;
@@ -0,0 +1,9 @@
import { CSSProperties } from "react";
export function WebSiteIcon(props: { className?: string; style?: CSSProperties }) {
return (
<svg className={props.className} style={props.style} xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="currentColor">
<path d="M480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 31.5-155.5t86-127Q252-817 325-848.5T480-880q83 0 155.5 31.5t127 86q54.5 54.5 86 127T880-480q0 82-31.5 155t-86 127.5q-54.5 54.5-127 86T480-80Zm0-82q26-36 45-75t31-83H404q12 44 31 83t45 75Zm-104-16q-18-33-31.5-68.5T322-320H204q29 50 72.5 87t99.5 55Zm208 0q56-18 99.5-55t72.5-87H638q-9 38-22.5 73.5T584-178ZM170-400h136q-3-20-4.5-39.5T300-480q0-21 1.5-40.5T306-560H170q-5 20-7.5 39.5T160-480q0 21 2.5 40.5T170-400Zm216 0h188q3-20 4.5-39.5T580-480q0-21-1.5-40.5T574-560H386q-3 20-4.5 39.5T380-480q0 21 1.5 40.5T386-400Zm268 0h136q5-20 7.5-39.5T800-480q0-21-2.5-40.5T790-560H654q3 20 4.5 39.5T660-480q0 21-1.5 40.5T654-400Zm-16-240h118q-29-50-72.5-87T584-782q18 33 31.5 68.5T638-640Zm-234 0h152q-12-44-31-83t-45-75q-26 36-45 75t-31 83Zm-200 0h118q9-38 22.5-73.5T376-782q-56 18-99.5 55T204-640Z"/>
</svg>
);
}
@@ -83,7 +83,7 @@ export default function TitleBar({ template = "index.html" }: { template: AppWin
<div id="window-controls" className="h-full flex shrink-0 items-center">
<div className="h-full text-gray-800 dark:text-gray-200 pr-1 cursor-pointer flex flex-row justify-end items-center gap-2 group pl-5">
<div className="shrink-0 w-0 overflow-hidden transition-all group-hover:w-16 group-hover:overflow-visible group-active:w-16 group-active:overflow-visible text-main-color-3">
<BsmRange min={0} max={1} step={0.01} values={[volume.muted ? 0 : volume.volume]} colors={[color, "currentColor"]} onChange={val => audio.setVolume(val[0])} onFinalChange={val => audio.setFinalVolume(val[0])} />
<BsmRange min={0} max={1} step={0.01} values={[volume.muted ? 0 : volume.volume]} colors={[color, "currentColor"]} onChange={val => audio.setVolume(val[0])} onFinalChange={val => audio.setVolume(val[0])} />
</div>
<BsmButton className="shrink-0 h-[23px] w-[23px] aspect-square !bg-transparent flex items-start" iconClassName={volumeIcon === "volume-down" ? "-translate-x-[1.8px]" : null} icon={volumeIcon} withBar={false} onClick={() => audio.toggleMute()} />
</div>
@@ -11,6 +11,7 @@ import { NotificationType } from "../../shared/models/notification/notification.
import { OsDiagnosticService } from "./os-diagnostic.service";
import { ProgressBarService } from "./progress-bar.service";
import { NotificationService } from "./notification.service";
import { CustomError } from "shared/models/exceptions/custom-error.class";
export class BsModsManagerService {
private static instance: BsModsManagerService;
@@ -79,8 +80,8 @@ export class BsModsManagerService {
const desc = `notifications.mods.install-mods.msg.${isFullyInstalled ? "success" : "warning"}`;
this.notifications.notify({ type: isFullyInstalled ? NotificationType.SUCCESS : NotificationType.WARNING, title, desc, duration: this.NOTIFICATION_DURATION });
}).catch(e => {
this.notifications.notifyError({ title: "notifications.types.error", desc: `notifications.mods.install-mods.msg.errors.${e}`, duration: this.NOTIFICATION_DURATION });
}).catch((e: CustomError) => {
this.notifications.notifyError({ title: "notifications.types.error", desc: `notifications.mods.install-mods.msg.errors.${e?.code}`, duration: this.NOTIFICATION_DURATION });
}).finally(() => {
this.isInstalling$.next(false);
this.progressBar.hide();
@@ -104,8 +105,8 @@ export class BsModsManagerService {
return lastValueFrom(this.ipcService.sendV2("uninstall-mods", { mods: [mod], version })).then(() => {
this.notifications.notifySuccess({ title: "notifications.mods.uninstall-mod.titles.success", duration: this.NOTIFICATION_DURATION });
}).catch(e => {
this.notifications.notifyError({ title: "notifications.types.error", desc: `notifications.mods.uninstall-mod.msg.errors.${e}`, duration: this.NOTIFICATION_DURATION });
}).catch((e: CustomError) => {
this.notifications.notifyError({ title: "notifications.types.error", desc: `notifications.mods.uninstall-mod.msg.errors.${e?.code}`, duration: this.NOTIFICATION_DURATION });
}).finally(() => {
this.isUninstalling$.next(false);
this.progressBar.hide();
@@ -129,8 +130,8 @@ export class BsModsManagerService {
this.isUninstalling$.next(true);
return lastValueFrom(this.ipcService.sendV2("uninstall-all-mods", version)).then(() => {
this.notifications.notifySuccess({ title: "notifications.mods.uninstall-all-mods.titles.success", desc: "notifications.mods.uninstall-all-mods.msg.success", duration: this.NOTIFICATION_DURATION });
}).catch(e => {
this.notifications.notifyError({ title: "notifications.types.error", desc: `notifications.mods.uninstall-all-mods.msg.errors.${e}`, duration: this.NOTIFICATION_DURATION });
}).catch((e: CustomError) => {
this.notifications.notifyError({ title: "notifications.types.error", desc: `notifications.mods.uninstall-all-mods.msg.errors.${e?.code}`, duration: this.NOTIFICATION_DURATION });
}).finally(() => {
this.isUninstalling$.next(false);
this.progressBar.hide();
+13
View File
@@ -0,0 +1,13 @@
const HashAlgorithmsLengths = {
sha1: 40,
} as const;
export function findHashInString(str: string, algorithm: keyof typeof HashAlgorithmsLengths = 'sha1'): string | undefined {
if(!str) { return undefined; }
const hashLength = HashAlgorithmsLengths[algorithm];
const regex = new RegExp(`[a-fA-F0-9]{${hashLength}}`, "g");
const match = regex.exec(str);
return match ? match[0] : undefined;
}