mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user