[chore] use resvg-js@2.6.1-beta.0 instead of sharp; Waiting the release of v2.6.1 to merge into master

This commit is contained in:
MathieuG-P
2024-03-12 07:35:23 +01:00
parent 1db3db7bdd
commit 31e1ae2273
3 changed files with 246 additions and 874 deletions
+226 -856
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -14,10 +14,10 @@
"postinstall": "npm run electron-rebuild && npm run link-modules"
},
"dependencies": {
"@resvg/resvg-js": "2.6.1-beta.0",
"ps-list": "^7.2.0",
"query-process": "^0.0.3",
"regedit-rs": "^1.0.2",
"sharp": "^0.32.6"
"regedit-rs": "^1.0.2"
},
"license": "MIT"
}
@@ -14,7 +14,7 @@ import { WindowManagerService } from "../window-manager.service";
import { IpcService } from "../ipc.service";
import { BSVersionLibService } from "../bs-version-lib.service";
import { execOnOs } from "../../helpers/env.helpers";
import sharp from "sharp";
import { Resvg } from "@resvg/resvg-js";
import { StoreLauncherInterface } from "./store-launcher.interface";
import { SteamLauncherService } from "./steam-launcher.service";
import { OculusLauncherService } from "./oculus-launcher.service";
@@ -127,22 +127,24 @@ export class BSLauncherService {
return res;
}
private createShortcutPngBuffer(color: Color): Promise<Buffer>{
const svgBuffer = Buffer.from(`
private createShortcutPngBuffer(color: Color): Buffer{
const svg = `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 406.4 406.4" height="406.4" width="406.4">
<rect rx="69.453" height="406.4" width="406.4" fill="${color.hex()}"/>
<path d="M65.467 60.6H336.4v33.867L200.933 162.2 65.467 94.467z" fill="#fff"/>
</svg>
`);
`;
return sharp(svgBuffer).resize(256).png().toBuffer();
return new Resvg(svg, {
fitTo: { mode: "width", value: 256 }
}).render().asPng();
}
/**
* Create .png file for the shortcut with the given color
* @param {Color} color
* @returns {Promise<string>} Path of the icon
* @param {Color} color
* @returns {Promise<string>} Path of the icon
*/
private async createShortcutPng(color: Color): Promise<string>{
const pngBuffer = this.createShortcutPngBuffer(color);
@@ -211,25 +213,25 @@ export class BSLauncherService {
const bsPath: string = await (async () => {
const bsPath = await this.localVersionService.getInstalledVersionPath(launchOption.version);
return bsPath ?? this.localVersionService.getVersionPath(launchOption.version);
})().catch(e => {
log.error(e);
})().catch(e => {
log.error(e);
return null;
});
launchOption.version = (await this.localVersionService.getVersionOfBSFolder(bsPath, {
steam: launchOption.version.steam,
oculus: launchOption.version.oculus,
oculus: launchOption.version.oculus,
})) ?? launchOption.version;
launchOption.version = {...(await this.remoteVersion.getVersionDetails(launchOption.version.BSVersion)), ...launchOption.version};
this.ipc.once("shortcut-launch-options", (_data, reply) => {
reply(of(launchOption));
});
this.windows.openWindow("shortcut-launch.html");
}
}
type ShortcutParams = {
@@ -246,9 +248,9 @@ type ShortcutParams = {
/**
* Create .desktop file for url shortcut (only for linux)
* @param {string} shortcutPath
* @param options
* @returns
* @param {string} shortcutPath
* @param options
* @returns
*/
function createDesktopUrlShortcut(shortcutPath: string, options?: {
url: string